From 4ddb5bd1462e72ef8b7d9e650423d72184cc4935 Mon Sep 17 00:00:00 2001 From: Kittywhiskers Van Gogh <63189531+kwvg@users.noreply.github.com> Date: Wed, 9 Sep 2026 23:35:36 +0530 Subject: [PATCH 1/8] sdk%doc(cargo): add workspace-level author, license and URLs --- Cargo.toml | 5 +++++ pkgs/dev/Cargo.toml | 11 ++++++----- pkgs/num/Cargo.toml | 11 ++++++----- pkgs/p2p_core/Cargo.toml | 11 ++++++----- pkgs/params/Cargo.toml | 11 ++++++----- pkgs/pkc/Cargo.toml | 11 ++++++----- pkgs/pow/Cargo.toml | 11 ++++++----- pkgs/primitives/Cargo.toml | 11 ++++++----- pkgs/script/Cargo.toml | 11 ++++++----- pkgs/types/Cargo.toml | 11 ++++++----- pkgs/types/marker/Cargo.toml | 11 ++++++----- 11 files changed, 65 insertions(+), 50 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 10799d71..2f8500a6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -40,6 +40,11 @@ unsafe_code = "deny" unused_must_use = "deny" [workspace.package] +authors = ["Kittywhiskers Van Gogh "] +edition = "2021" +homepage = "https://dashpay.github.io/base-sdk" +license = "MIT" +repository = "https://github.com/dashpay/base-sdk" rust-version = "1.85.0" [profile.release] diff --git a/pkgs/dev/Cargo.toml b/pkgs/dev/Cargo.toml index 3bd71d73..8574963d 100644 --- a/pkgs/dev/Cargo.toml +++ b/pkgs/dev/Cargo.toml @@ -1,9 +1,13 @@ [package] name = "dash-dev" version = "0.0.0" -edition = "2021" -license = "MIT" publish = false +authors.workspace = true +edition.workspace = true +homepage.workspace = true +license.workspace = true +repository.workspace = true +rust-version.workspace = true [[bin]] name = "bsdk-util" @@ -85,6 +89,3 @@ sysinfo = { version = "0.33", default-features = false, features = [ [lints] workspace = true - -[package.rust-version] -workspace = true diff --git a/pkgs/num/Cargo.toml b/pkgs/num/Cargo.toml index 11579330..212690d2 100644 --- a/pkgs/num/Cargo.toml +++ b/pkgs/num/Cargo.toml @@ -1,8 +1,12 @@ [package] name = "dash-num" version = "0.0.0" -edition = "2021" -license = "MIT" +authors.workspace = true +edition.workspace = true +homepage.workspace = true +license.workspace = true +repository.workspace = true +rust-version.workspace = true [features] default = [] @@ -50,6 +54,3 @@ harness = false [lints] workspace = true - -[package.rust-version] -workspace = true diff --git a/pkgs/p2p_core/Cargo.toml b/pkgs/p2p_core/Cargo.toml index 5d700733..505faa4d 100644 --- a/pkgs/p2p_core/Cargo.toml +++ b/pkgs/p2p_core/Cargo.toml @@ -1,8 +1,12 @@ [package] name = "dash-p2p-core" version = "0.0.0" -edition = "2021" -license = "MIT" +authors.workspace = true +edition.workspace = true +homepage.workspace = true +license.workspace = true +repository.workspace = true +rust-version.workspace = true [features] default = [] @@ -53,6 +57,3 @@ rstest = "0.25" [lints] workspace = true - -[package.rust-version] -workspace = true diff --git a/pkgs/params/Cargo.toml b/pkgs/params/Cargo.toml index bac1d1c8..e15e16cf 100644 --- a/pkgs/params/Cargo.toml +++ b/pkgs/params/Cargo.toml @@ -1,8 +1,12 @@ [package] name = "dash-params" version = "0.0.0" -edition = "2021" -license = "MIT" +authors.workspace = true +edition.workspace = true +homepage.workspace = true +license.workspace = true +repository.workspace = true +rust-version.workspace = true [features] default = [] @@ -27,6 +31,3 @@ rstest = "0.25" [lints] workspace = true - -[package.rust-version] -workspace = true diff --git a/pkgs/pkc/Cargo.toml b/pkgs/pkc/Cargo.toml index fd2857a2..4a15e335 100644 --- a/pkgs/pkc/Cargo.toml +++ b/pkgs/pkc/Cargo.toml @@ -1,8 +1,12 @@ [package] name = "dash-pkc" version = "0.0.0" -edition = "2021" -license = "MIT" +authors.workspace = true +edition.workspace = true +homepage.workspace = true +license.workspace = true +repository.workspace = true +rust-version.workspace = true [dependencies] aes = { version = "0.8", default-features = false, features = [ @@ -71,9 +75,6 @@ tests = ["std", "dep:rstest"] [lints] workspace = true -[package.rust-version] -workspace = true - [[bench]] name = "pkc" path = "bench/main.rs" diff --git a/pkgs/pow/Cargo.toml b/pkgs/pow/Cargo.toml index 574e1c20..b889495e 100644 --- a/pkgs/pow/Cargo.toml +++ b/pkgs/pow/Cargo.toml @@ -1,8 +1,12 @@ [package] name = "dash-pow" version = "0.0.0" -edition = "2021" -license = "MIT" +authors.workspace = true +edition.workspace = true +homepage.workspace = true +license.workspace = true +repository.workspace = true +rust-version.workspace = true [features] default = [] @@ -47,6 +51,3 @@ required-features = ["simd"] [lints] workspace = true - -[package.rust-version] -workspace = true diff --git a/pkgs/primitives/Cargo.toml b/pkgs/primitives/Cargo.toml index 05b68089..fc9a6fd5 100644 --- a/pkgs/primitives/Cargo.toml +++ b/pkgs/primitives/Cargo.toml @@ -1,8 +1,12 @@ [package] name = "dash-primitives" version = "0.0.0" -edition = "2021" -license = "MIT" +authors.workspace = true +edition.workspace = true +homepage.workspace = true +license.workspace = true +repository.workspace = true +rust-version.workspace = true [features] default = [] @@ -63,6 +67,3 @@ serde = { version = "1", features = ["derive"] } [lints] workspace = true - -[package.rust-version] -workspace = true diff --git a/pkgs/script/Cargo.toml b/pkgs/script/Cargo.toml index cfde4c56..c45dddd9 100644 --- a/pkgs/script/Cargo.toml +++ b/pkgs/script/Cargo.toml @@ -1,8 +1,12 @@ [package] name = "dash-script" version = "0.0.0" -edition = "2021" -license = "MIT" +authors.workspace = true +edition.workspace = true +homepage.workspace = true +license.workspace = true +repository.workspace = true +rust-version.workspace = true [features] default = [] @@ -37,6 +41,3 @@ rstest = "0.25" [lints] workspace = true - -[package.rust-version] -workspace = true diff --git a/pkgs/types/Cargo.toml b/pkgs/types/Cargo.toml index 05ead6c1..9f94e346 100644 --- a/pkgs/types/Cargo.toml +++ b/pkgs/types/Cargo.toml @@ -1,8 +1,12 @@ [package] name = "dash-types" version = "0.0.0" -edition = "2021" -license = "MIT" +authors.workspace = true +edition.workspace = true +homepage.workspace = true +license.workspace = true +repository.workspace = true +rust-version.workspace = true [features] default = [] @@ -47,6 +51,3 @@ serde = { version = "1", features = ["derive"] } [lints] workspace = true - -[package.rust-version] -workspace = true diff --git a/pkgs/types/marker/Cargo.toml b/pkgs/types/marker/Cargo.toml index 319e50af..243881b6 100644 --- a/pkgs/types/marker/Cargo.toml +++ b/pkgs/types/marker/Cargo.toml @@ -1,8 +1,12 @@ [package] name = "dash-types-marker" version = "0.0.0" -edition = "2021" -license = "MIT" +authors.workspace = true +edition.workspace = true +homepage.workspace = true +license.workspace = true +repository.workspace = true +rust-version.workspace = true [lib] proc-macro = true @@ -14,6 +18,3 @@ xxhash-rust = { version = "0.8", features = ["xxh32"] } [lints] workspace = true - -[package.rust-version] -workspace = true From 09dbddfff8d33d156879381c529937b7cffdf97b Mon Sep 17 00:00:00 2001 From: Kittywhiskers Van Gogh <63189531+kwvg@users.noreply.github.com> Date: Sun, 13 Sep 2026 14:06:14 +0530 Subject: [PATCH 2/8] sdk%doc: add stub README and CHANGELOG for crates in `pkgs/` --- pkgs/num/CHANGELOG.md | 10 ++++++++++ pkgs/num/Cargo.toml | 1 + pkgs/num/README.md | 4 ++++ pkgs/p2p_core/CHANGELOG.md | 10 ++++++++++ pkgs/p2p_core/Cargo.toml | 1 + pkgs/p2p_core/README.md | 4 ++++ pkgs/params/CHANGELOG.md | 10 ++++++++++ pkgs/params/Cargo.toml | 1 + pkgs/params/README.md | 4 ++++ pkgs/pkc/CHANGELOG.md | 10 ++++++++++ pkgs/pkc/Cargo.toml | 1 + pkgs/pkc/README.md | 4 ++++ pkgs/pow/CHANGELOG.md | 10 ++++++++++ pkgs/pow/Cargo.toml | 1 + pkgs/pow/README.md | 4 ++++ pkgs/primitives/CHANGELOG.md | 10 ++++++++++ pkgs/primitives/Cargo.toml | 1 + pkgs/primitives/README.md | 4 ++++ pkgs/script/CHANGELOG.md | 10 ++++++++++ pkgs/script/Cargo.toml | 1 + pkgs/script/README.md | 4 ++++ pkgs/types/CHANGELOG.md | 10 ++++++++++ pkgs/types/Cargo.toml | 1 + pkgs/types/README.md | 4 ++++ pkgs/types/marker/Cargo.toml | 1 + pkgs/types/marker/README.md | 4 ++++ 26 files changed, 125 insertions(+) create mode 100644 pkgs/num/CHANGELOG.md create mode 100644 pkgs/num/README.md create mode 100644 pkgs/p2p_core/CHANGELOG.md create mode 100644 pkgs/p2p_core/README.md create mode 100644 pkgs/params/CHANGELOG.md create mode 100644 pkgs/params/README.md create mode 100644 pkgs/pkc/CHANGELOG.md create mode 100644 pkgs/pkc/README.md create mode 100644 pkgs/pow/CHANGELOG.md create mode 100644 pkgs/pow/README.md create mode 100644 pkgs/primitives/CHANGELOG.md create mode 100644 pkgs/primitives/README.md create mode 100644 pkgs/script/CHANGELOG.md create mode 100644 pkgs/script/README.md create mode 100644 pkgs/types/CHANGELOG.md create mode 100644 pkgs/types/README.md create mode 100644 pkgs/types/marker/README.md diff --git a/pkgs/num/CHANGELOG.md b/pkgs/num/CHANGELOG.md new file mode 100644 index 00000000..609f3fbb --- /dev/null +++ b/pkgs/num/CHANGELOG.md @@ -0,0 +1,10 @@ +# Changelog + +All notable changes to `dash-num` will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this crate adheres to +[Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [Unreleased] + +- Initial release. diff --git a/pkgs/num/Cargo.toml b/pkgs/num/Cargo.toml index 212690d2..0696c80d 100644 --- a/pkgs/num/Cargo.toml +++ b/pkgs/num/Cargo.toml @@ -1,6 +1,7 @@ [package] name = "dash-num" version = "0.0.0" +readme = "README.md" authors.workspace = true edition.workspace = true homepage.workspace = true diff --git a/pkgs/num/README.md b/pkgs/num/README.md new file mode 100644 index 00000000..1754a97e --- /dev/null +++ b/pkgs/num/README.md @@ -0,0 +1,4 @@ +[![dash-num](https://img.shields.io/github/actions/workflow/status/dashpay/base-sdk/pkg_num.yml?style=flat&logo=github&logoColor=white&label=num)](https://github.com/dashpay/base-sdk/actions/workflows/pkg_num.yml) +[![dash-num](https://img.shields.io/codecov/c/github/dashpay/base-sdk/develop?flag=dash-num&style=flat&logo=codecov&logoColor=white&label=num)](https://app.codecov.io/github/dashpay/base-sdk/tree/develop/pkgs%2Fnum) + +# dash-num diff --git a/pkgs/p2p_core/CHANGELOG.md b/pkgs/p2p_core/CHANGELOG.md new file mode 100644 index 00000000..2080eea7 --- /dev/null +++ b/pkgs/p2p_core/CHANGELOG.md @@ -0,0 +1,10 @@ +# Changelog + +All notable changes to `dash-p2p-core` will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this crate adheres to +[Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [Unreleased] + +- Initial release. diff --git a/pkgs/p2p_core/Cargo.toml b/pkgs/p2p_core/Cargo.toml index 505faa4d..074ecf2e 100644 --- a/pkgs/p2p_core/Cargo.toml +++ b/pkgs/p2p_core/Cargo.toml @@ -1,6 +1,7 @@ [package] name = "dash-p2p-core" version = "0.0.0" +readme = "README.md" authors.workspace = true edition.workspace = true homepage.workspace = true diff --git a/pkgs/p2p_core/README.md b/pkgs/p2p_core/README.md new file mode 100644 index 00000000..02221454 --- /dev/null +++ b/pkgs/p2p_core/README.md @@ -0,0 +1,4 @@ +[![dash-p2p-core](https://img.shields.io/github/actions/workflow/status/dashpay/base-sdk/pkg_p2p_core.yml?style=flat&logo=github&logoColor=white&label=p2p_core)](https://github.com/dashpay/base-sdk/actions/workflows/pkg_p2p_core.yml) +[![dash-p2p-core](https://img.shields.io/codecov/c/github/dashpay/base-sdk/develop?flag=dash-p2p-core&style=flat&logo=codecov&logoColor=white&label=p2p_core)](https://app.codecov.io/github/dashpay/base-sdk/tree/develop/pkgs%2Fp2p_core) + +# dash-p2p-core diff --git a/pkgs/params/CHANGELOG.md b/pkgs/params/CHANGELOG.md new file mode 100644 index 00000000..89ee5bcf --- /dev/null +++ b/pkgs/params/CHANGELOG.md @@ -0,0 +1,10 @@ +# Changelog + +All notable changes to `dash-params` will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this crate adheres to +[Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [Unreleased] + +- Initial release. diff --git a/pkgs/params/Cargo.toml b/pkgs/params/Cargo.toml index e15e16cf..29f077bf 100644 --- a/pkgs/params/Cargo.toml +++ b/pkgs/params/Cargo.toml @@ -1,6 +1,7 @@ [package] name = "dash-params" version = "0.0.0" +readme = "README.md" authors.workspace = true edition.workspace = true homepage.workspace = true diff --git a/pkgs/params/README.md b/pkgs/params/README.md new file mode 100644 index 00000000..1a2331d9 --- /dev/null +++ b/pkgs/params/README.md @@ -0,0 +1,4 @@ +[![dash-params](https://img.shields.io/github/actions/workflow/status/dashpay/base-sdk/pkg_params.yml?style=flat&logo=github&logoColor=white&label=params)](https://github.com/dashpay/base-sdk/actions/workflows/pkg_params.yml) +[![dash-params](https://img.shields.io/codecov/c/github/dashpay/base-sdk/develop?flag=dash-params&style=flat&logo=codecov&logoColor=white&label=params)](https://app.codecov.io/github/dashpay/base-sdk/tree/develop/pkgs%2Fparams) + +# dash-params diff --git a/pkgs/pkc/CHANGELOG.md b/pkgs/pkc/CHANGELOG.md new file mode 100644 index 00000000..d9acb68c --- /dev/null +++ b/pkgs/pkc/CHANGELOG.md @@ -0,0 +1,10 @@ +# Changelog + +All notable changes to `dash-pkc` will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this crate adheres to +[Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [Unreleased] + +- Initial release. diff --git a/pkgs/pkc/Cargo.toml b/pkgs/pkc/Cargo.toml index 4a15e335..383b663b 100644 --- a/pkgs/pkc/Cargo.toml +++ b/pkgs/pkc/Cargo.toml @@ -1,6 +1,7 @@ [package] name = "dash-pkc" version = "0.0.0" +readme = "README.md" authors.workspace = true edition.workspace = true homepage.workspace = true diff --git a/pkgs/pkc/README.md b/pkgs/pkc/README.md new file mode 100644 index 00000000..de163a73 --- /dev/null +++ b/pkgs/pkc/README.md @@ -0,0 +1,4 @@ +[![dash-pkc](https://img.shields.io/github/actions/workflow/status/dashpay/base-sdk/pkg_pkc.yml?style=flat&logo=github&logoColor=white&label=pkc)](https://github.com/dashpay/base-sdk/actions/workflows/pkg_pkc.yml) +[![dash-pkc](https://img.shields.io/codecov/c/github/dashpay/base-sdk/develop?flag=dash-pkc&style=flat&logo=codecov&logoColor=white&label=pkc)](https://app.codecov.io/github/dashpay/base-sdk/tree/develop/pkgs%2Fpkc) + +# dash-pkc diff --git a/pkgs/pow/CHANGELOG.md b/pkgs/pow/CHANGELOG.md new file mode 100644 index 00000000..e3e98de2 --- /dev/null +++ b/pkgs/pow/CHANGELOG.md @@ -0,0 +1,10 @@ +# Changelog + +All notable changes to `dash-pow` will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this crate adheres to +[Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [Unreleased] + +- Initial release. diff --git a/pkgs/pow/Cargo.toml b/pkgs/pow/Cargo.toml index b889495e..78d1d06f 100644 --- a/pkgs/pow/Cargo.toml +++ b/pkgs/pow/Cargo.toml @@ -1,6 +1,7 @@ [package] name = "dash-pow" version = "0.0.0" +readme = "README.md" authors.workspace = true edition.workspace = true homepage.workspace = true diff --git a/pkgs/pow/README.md b/pkgs/pow/README.md new file mode 100644 index 00000000..83d6d2d3 --- /dev/null +++ b/pkgs/pow/README.md @@ -0,0 +1,4 @@ +[![dash-pow](https://img.shields.io/github/actions/workflow/status/dashpay/base-sdk/pkg_pow.yml?style=flat&logo=github&logoColor=white&label=pow)](https://github.com/dashpay/base-sdk/actions/workflows/pkg_pow.yml) +[![dash-pow](https://img.shields.io/codecov/c/github/dashpay/base-sdk/develop?flag=dash-pow&style=flat&logo=codecov&logoColor=white&label=pow)](https://app.codecov.io/github/dashpay/base-sdk/tree/develop/pkgs%2Fpow) + +# dash-pow diff --git a/pkgs/primitives/CHANGELOG.md b/pkgs/primitives/CHANGELOG.md new file mode 100644 index 00000000..4461d418 --- /dev/null +++ b/pkgs/primitives/CHANGELOG.md @@ -0,0 +1,10 @@ +# Changelog + +All notable changes to `dash-primitives` will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this crate adheres to +[Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [Unreleased] + +- Initial release. diff --git a/pkgs/primitives/Cargo.toml b/pkgs/primitives/Cargo.toml index fc9a6fd5..6510d022 100644 --- a/pkgs/primitives/Cargo.toml +++ b/pkgs/primitives/Cargo.toml @@ -1,6 +1,7 @@ [package] name = "dash-primitives" version = "0.0.0" +readme = "README.md" authors.workspace = true edition.workspace = true homepage.workspace = true diff --git a/pkgs/primitives/README.md b/pkgs/primitives/README.md new file mode 100644 index 00000000..2133b4f0 --- /dev/null +++ b/pkgs/primitives/README.md @@ -0,0 +1,4 @@ +[![dash-primitives](https://img.shields.io/github/actions/workflow/status/dashpay/base-sdk/pkg_primitives.yml?style=flat&logo=github&logoColor=white&label=primitives)](https://github.com/dashpay/base-sdk/actions/workflows/pkg_primitives.yml) +[![dash-primitives](https://img.shields.io/codecov/c/github/dashpay/base-sdk/develop?flag=dash-primitives&style=flat&logo=codecov&logoColor=white&label=primitives)](https://app.codecov.io/github/dashpay/base-sdk/tree/develop/pkgs%2Fprimitives) + +# dash-primitives diff --git a/pkgs/script/CHANGELOG.md b/pkgs/script/CHANGELOG.md new file mode 100644 index 00000000..4f88a58c --- /dev/null +++ b/pkgs/script/CHANGELOG.md @@ -0,0 +1,10 @@ +# Changelog + +All notable changes to `dash-script` will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this crate adheres to +[Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [Unreleased] + +- Initial release. diff --git a/pkgs/script/Cargo.toml b/pkgs/script/Cargo.toml index c45dddd9..3bb0f570 100644 --- a/pkgs/script/Cargo.toml +++ b/pkgs/script/Cargo.toml @@ -1,6 +1,7 @@ [package] name = "dash-script" version = "0.0.0" +readme = "README.md" authors.workspace = true edition.workspace = true homepage.workspace = true diff --git a/pkgs/script/README.md b/pkgs/script/README.md new file mode 100644 index 00000000..4b5a9df1 --- /dev/null +++ b/pkgs/script/README.md @@ -0,0 +1,4 @@ +[![dash-script](https://img.shields.io/github/actions/workflow/status/dashpay/base-sdk/pkg_script.yml?style=flat&logo=github&logoColor=white&label=script)](https://github.com/dashpay/base-sdk/actions/workflows/pkg_script.yml) +[![dash-script](https://img.shields.io/codecov/c/github/dashpay/base-sdk/develop?flag=dash-script&style=flat&logo=codecov&logoColor=white&label=script)](https://app.codecov.io/github/dashpay/base-sdk/tree/develop/pkgs%2Fscript) + +# dash-script diff --git a/pkgs/types/CHANGELOG.md b/pkgs/types/CHANGELOG.md new file mode 100644 index 00000000..dd8dd35c --- /dev/null +++ b/pkgs/types/CHANGELOG.md @@ -0,0 +1,10 @@ +# Changelog + +All notable changes to `dash-types` and `dash-types-marker` will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this crate adheres to +[Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [Unreleased] + +- Initial release. diff --git a/pkgs/types/Cargo.toml b/pkgs/types/Cargo.toml index 9f94e346..7cd02bd2 100644 --- a/pkgs/types/Cargo.toml +++ b/pkgs/types/Cargo.toml @@ -1,6 +1,7 @@ [package] name = "dash-types" version = "0.0.0" +readme = "README.md" authors.workspace = true edition.workspace = true homepage.workspace = true diff --git a/pkgs/types/README.md b/pkgs/types/README.md new file mode 100644 index 00000000..532aa85d --- /dev/null +++ b/pkgs/types/README.md @@ -0,0 +1,4 @@ +[![dash-types](https://img.shields.io/github/actions/workflow/status/dashpay/base-sdk/pkg_types.yml?style=flat&logo=github&logoColor=white&label=types)](https://github.com/dashpay/base-sdk/actions/workflows/pkg_types.yml) +[![dash-types](https://img.shields.io/codecov/c/github/dashpay/base-sdk/develop?flag=dash-types&style=flat&logo=codecov&logoColor=white&label=types)](https://app.codecov.io/github/dashpay/base-sdk/tree/develop/pkgs%2Ftypes) + +# dash-types diff --git a/pkgs/types/marker/Cargo.toml b/pkgs/types/marker/Cargo.toml index 243881b6..aed30cb6 100644 --- a/pkgs/types/marker/Cargo.toml +++ b/pkgs/types/marker/Cargo.toml @@ -1,6 +1,7 @@ [package] name = "dash-types-marker" version = "0.0.0" +readme = "README.md" authors.workspace = true edition.workspace = true homepage.workspace = true diff --git a/pkgs/types/marker/README.md b/pkgs/types/marker/README.md new file mode 100644 index 00000000..98938647 --- /dev/null +++ b/pkgs/types/marker/README.md @@ -0,0 +1,4 @@ +[![dash-types](https://img.shields.io/github/actions/workflow/status/dashpay/base-sdk/pkg_types.yml?style=flat&logo=github&logoColor=white&label=types)](https://github.com/dashpay/base-sdk/actions/workflows/pkg_types.yml) +[![dash-types](https://img.shields.io/codecov/c/github/dashpay/base-sdk/develop?flag=dash-types&style=flat&logo=codecov&logoColor=white&label=types)](https://app.codecov.io/github/dashpay/base-sdk/tree/develop/pkgs%2Ftypes) + +# dash-types-marker From ad44e5d157229c134fd6c90cfab1119222c30fe0 Mon Sep 17 00:00:00 2001 From: Kittywhiskers Van Gogh <63189531+kwvg@users.noreply.github.com> Date: Thu, 10 Sep 2026 00:00:07 +0530 Subject: [PATCH 3/8] p2p_core%misc: drop `bitcoin-p2p-messages` from `types`, stub P2P msgs --- Cargo.lock | 226 +----------------- Cargo.toml | 1 - pkgs/p2p_core/Cargo.toml | 7 - pkgs/p2p_core/src/lib.rs | 3 - pkgs/p2p_core/src/msg/mod.rs | 48 ++-- pkgs/p2p_core/src/serialize.rs | 404 --------------------------------- pkgs/types/Cargo.toml | 5 +- pkgs/types/src/adapters.rs | 23 -- 8 files changed, 31 insertions(+), 686 deletions(-) delete mode 100644 pkgs/p2p_core/src/serialize.rs diff --git a/Cargo.lock b/Cargo.lock index 3476ee6b..eef34045 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -65,41 +65,6 @@ dependencies = [ "bitcoin_hashes", ] -[[package]] -name = "base64" -version = "0.22.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" - -[[package]] -name = "bech32" -version = "0.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32637268377fc7b10a8c6d51de3e7fba1ce5dd371a96e342b34e6078db558e7f" - -[[package]] -name = "bitcoin" -version = "0.33.0-beta" -source = "git+https://github.com/rust-bitcoin/rust-bitcoin?tag=bitcoin-crypto-0.2.0#11650c6c480088cc30a04e583e187cd7a84a2d8f" -dependencies = [ - "base58ck", - "base64", - "bech32", - "bitcoin-consensus-encoding", - "bitcoin-crypto", - "bitcoin-internals", - "bitcoin-io", - "bitcoin-network-kind", - "bitcoin-primitives", - "bitcoin-taproot-primitives", - "bitcoin-units", - "bitcoin_hashes", - "bitcoinconsensus", - "hex-conservative 0.3.2", - "hex-conservative 1.2.0", - "secp256k1", -] - [[package]] name = "bitcoin-consensus-encoding" version = "0.2.0" @@ -108,21 +73,6 @@ dependencies = [ "bitcoin-internals", ] -[[package]] -name = "bitcoin-crypto" -version = "0.2.0" -source = "git+https://github.com/rust-bitcoin/rust-bitcoin?tag=bitcoin-crypto-0.2.0#11650c6c480088cc30a04e583e187cd7a84a2d8f" -dependencies = [ - "base58ck", - "bitcoin-internals", - "bitcoin-network-kind", - "bitcoin_hashes", - "hex-conservative 0.3.2", - "hex-conservative 1.2.0", - "secp256k1", - "serde", -] - [[package]] name = "bitcoin-internals" version = "0.5.0" @@ -132,43 +82,6 @@ dependencies = [ "serde", ] -[[package]] -name = "bitcoin-io" -version = "0.5.0" -source = "git+https://github.com/rust-bitcoin/rust-bitcoin?tag=bitcoin-crypto-0.2.0#11650c6c480088cc30a04e583e187cd7a84a2d8f" -dependencies = [ - "bitcoin-consensus-encoding", - "bitcoin-internals", - "bitcoin_hashes", -] - -[[package]] -name = "bitcoin-network-kind" -version = "0.1.0" -source = "git+https://github.com/rust-bitcoin/rust-bitcoin?tag=bitcoin-crypto-0.2.0#11650c6c480088cc30a04e583e187cd7a84a2d8f" -dependencies = [ - "bitcoin-internals", - "serde", -] - -[[package]] -name = "bitcoin-p2p-messages" -version = "0.1.0" -source = "git+https://github.com/rust-bitcoin/rust-bitcoin?tag=bitcoin-crypto-0.2.0#11650c6c480088cc30a04e583e187cd7a84a2d8f" -dependencies = [ - "bitcoin", - "bitcoin-consensus-encoding", - "bitcoin-internals", - "bitcoin-io", - "bitcoin-network-kind", - "bitcoin-primitives", - "bitcoin-units", - "bitcoin_hashes", - "hex-conservative 0.3.2", - "hex-conservative 1.2.0", - "serde", -] - [[package]] name = "bitcoin-primitives" version = "0.102.0" @@ -183,18 +96,6 @@ dependencies = [ "serde", ] -[[package]] -name = "bitcoin-taproot-primitives" -version = "0.1.0" -source = "git+https://github.com/rust-bitcoin/rust-bitcoin?tag=bitcoin-crypto-0.2.0#11650c6c480088cc30a04e583e187cd7a84a2d8f" -dependencies = [ - "bitcoin-crypto", - "bitcoin-internals", - "bitcoin_hashes", - "secp256k1", - "serde", -] - [[package]] name = "bitcoin-units" version = "0.3.0" @@ -217,15 +118,6 @@ dependencies = [ "serde", ] -[[package]] -name = "bitcoinconsensus" -version = "0.106.0+26.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e12cba9cce5043cdda968e07b9df6d05ec6b0b38aa27a9a40bb575cf3e521ae9" -dependencies = [ - "cc", -] - [[package]] name = "bitflags" version = "2.13.1" @@ -497,7 +389,7 @@ dependencies = [ "ctutils", "hybrid-array", "num-traits", - "rand_core 0.10.1", + "rand_core", "subtle", "zeroize", ] @@ -519,7 +411,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ce6e4c961d6cd6c9a86db418387425e8bdeaf05b3c8bc1411e6dca4c252f1453" dependencies = [ "hybrid-array", - "rand_core 0.10.1", + "rand_core", ] [[package]] @@ -578,9 +470,6 @@ version = "0.0.0" dependencies = [ "bitcoin-consensus-encoding", "bitcoin-internals", - "bitcoin-p2p-messages", - "bitcoin-primitives", - "bitcoin-units", "cfg-if", "dash-dev", "dash-num", @@ -624,11 +513,11 @@ dependencies = [ "dash-types", "divan", "ff", - "getrandom 0.4.3", + "getrandom", "group", "hex-conservative 0.3.2", "k256", - "rand_core 0.10.1", + "rand_core", "rstest", "serde", "sha2 0.10.9", @@ -689,7 +578,6 @@ version = "0.0.0" dependencies = [ "base58ck", "bitcoin-consensus-encoding", - "bitcoin-p2p-messages", "bitcoin-primitives", "bitcoin_hashes", "cfg-if", @@ -811,7 +699,7 @@ dependencies = [ "ff", "group", "hybrid-array", - "rand_core 0.10.1", + "rand_core", "sec1", "subtle", "zeroize", @@ -845,7 +733,7 @@ version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a1f686ab92a9fb0eaf188f6c6c87b89490baa6fdb0db4544ba4dc47f7942489f" dependencies = [ - "rand_core 0.10.1", + "rand_core", "subtle", ] @@ -922,18 +810,6 @@ dependencies = [ "version_check", ] -[[package]] -name = "getrandom" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "899def5c37c4fd7b2664648c28120ecec138e4d395b459e5ca34f9cce2dd77fd" -dependencies = [ - "cfg-if", - "libc", - "r-efi 5.3.0", - "wasip2", -] - [[package]] name = "getrandom" version = "0.4.3" @@ -942,8 +818,8 @@ checksum = "300e883d756b2e4ec94e02791f39b04b522276138852cfc41d9fb7e904106099" dependencies = [ "cfg-if", "libc", - "r-efi 6.0.0", - "rand_core 0.10.1", + "r-efi", + "rand_core", ] [[package]] @@ -972,7 +848,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7fd1a1c7a5206c5b7a3f5a0d7ccd3ff85d0c8f5133d62a02680255b0004af5f4" dependencies = [ "ff", - "rand_core 0.10.1", + "rand_core", "subtle", ] @@ -1255,7 +1131,7 @@ version = "0.1.35" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1c00acbd29eabad4a2392fa0e921c874934dbbf4194312ad20f04a0ed67a3cb3" dependencies = [ - "getrandom 0.4.3", + "getrandom", "libc", ] @@ -1471,15 +1347,6 @@ version = "1.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3d20d5497ef88037a52ff98267d066e7f11fcc5e99bbfbd58a42336193aacec3" -[[package]] -name = "ppv-lite86" -version = "0.2.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9" -dependencies = [ - "zerocopy", -] - [[package]] name = "primefield" version = "0.14.0" @@ -1489,7 +1356,7 @@ dependencies = [ "crypto-bigint", "crypto-common 0.2.2", "ff", - "rand_core 0.10.1", + "rand_core", "subtle", "zeroize", ] @@ -1532,47 +1399,12 @@ dependencies = [ "proc-macro2", ] -[[package]] -name = "r-efi" -version = "5.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f" - [[package]] name = "r-efi" version = "6.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf" -[[package]] -name = "rand" -version = "0.9.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9ef1d0d795eb7d84685bca4f72f3649f064e6641543d3a8c415898726a57b41" -dependencies = [ - "rand_chacha", - "rand_core 0.9.5", -] - -[[package]] -name = "rand_chacha" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb" -dependencies = [ - "ppv-lite86", - "rand_core 0.9.5", -] - -[[package]] -name = "rand_core" -version = "0.9.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76afc826de14238e6e8c374ddcc1fa19e374fd8dd986b0d2af0d02377261d83c" -dependencies = [ - "getrandom 0.3.4", -] - [[package]] name = "rand_core" version = "0.10.1" @@ -1722,25 +1554,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "secp256k1" -version = "0.32.0-beta.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c5fdc7d6e800869d3fd60ff857c479bf0a83ea7bf44b389e64461e844204994" -dependencies = [ - "rand", - "secp256k1-sys", -] - -[[package]] -name = "secp256k1-sys" -version = "0.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d3be00697c88c00fe102af8dc316038cc2062eab8da646e7463f4c0e70ca9fd" -dependencies = [ - "cc", -] - [[package]] name = "semver" version = "1.0.28" @@ -1838,7 +1651,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "28d567dcbaf0049cb8ac2608a76cd95ff9e4412e1899d389ee400918ca7537f5" dependencies = [ "digest 0.11.3", - "rand_core 0.10.1", + "rand_core", ] [[package]] @@ -2065,15 +1878,6 @@ version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" -[[package]] -name = "wasip2" -version = "1.0.4+wasi-0.2.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b67efb37e106e55ce722a510d6b5f9c17f083e5fc79afc2badeb12cc313d9487" -dependencies = [ - "wit-bindgen", -] - [[package]] name = "wasm-bindgen" version = "0.2.126" @@ -2363,12 +2167,6 @@ dependencies = [ "memchr", ] -[[package]] -name = "wit-bindgen" -version = "0.57.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ebf944e87a7c253233ad6766e082e3cd714b5d03812acc24c318f549614536e" - [[package]] name = "wnaf" version = "0.14.0" diff --git a/Cargo.toml b/Cargo.toml index 2f8500a6..81750d4e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,7 +17,6 @@ resolver = "2" base58ck = { git = "https://github.com/rust-bitcoin/rust-bitcoin", tag = "bitcoin-crypto-0.2.0", default-features = false } bitcoin-consensus-encoding = { git = "https://github.com/rust-bitcoin/rust-bitcoin", tag = "bitcoin-crypto-0.2.0", default-features = false } bitcoin-internals = { git = "https://github.com/rust-bitcoin/rust-bitcoin", tag = "bitcoin-crypto-0.2.0", default-features = false } -bitcoin-p2p-messages = { git = "https://github.com/rust-bitcoin/rust-bitcoin", tag = "bitcoin-crypto-0.2.0", default-features = false } bitcoin-primitives = { git = "https://github.com/rust-bitcoin/rust-bitcoin", tag = "bitcoin-crypto-0.2.0", default-features = false } bitcoin-units = { git = "https://github.com/rust-bitcoin/rust-bitcoin", tag = "bitcoin-crypto-0.2.0", default-features = false } bitcoin_hashes = { git = "https://github.com/rust-bitcoin/rust-bitcoin", tag = "bitcoin-crypto-0.2.0", default-features = false } diff --git a/pkgs/p2p_core/Cargo.toml b/pkgs/p2p_core/Cargo.toml index 074ecf2e..893ae33a 100644 --- a/pkgs/p2p_core/Cargo.toml +++ b/pkgs/p2p_core/Cargo.toml @@ -12,8 +12,6 @@ rust-version.workspace = true [features] default = [] std = [ - "bitcoin-p2p-messages/std", - "bitcoin-primitives/std", "dash-pkc/std", "dash-primitives/std", "dash-script/std", @@ -21,7 +19,6 @@ std = [ ] serde = [ "dep:serde", - "bitcoin-p2p-messages/serde", "dash-num/serde", "dash-pkc/serde", "dash-primitives/serde", @@ -33,9 +30,6 @@ full = ["std", "serde"] [dependencies] bitcoin-consensus-encoding = { workspace = true, features = ["alloc"] } bitcoin-internals = { workspace = true } -bitcoin-p2p-messages = { workspace = true } -bitcoin-primitives = { workspace = true } -bitcoin-units = { workspace = true, features = ["alloc"] } cfg-if = "1" dash-num = { version = "0.0.0", path = "../num", features = ["codec"] } dash-pkc = { version = "0.0.0", path = "../pkc", features = ["codec"] } @@ -43,7 +37,6 @@ dash-script = { version = "0.0.0", path = "../script" } dash-params = { version = "0.0.0", path = "../params" } dash-primitives = { version = "0.0.0", path = "../primitives" } dash-types = { version = "0.0.0", path = "../types", default-features = false, features = [ - "bitcoin-p2p-messages", "codec", ] } serde = { version = "1", default-features = false, features = [ diff --git a/pkgs/p2p_core/src/lib.rs b/pkgs/p2p_core/src/lib.rs index 945cb27c..a494f72c 100644 --- a/pkgs/p2p_core/src/lib.rs +++ b/pkgs/p2p_core/src/lib.rs @@ -30,9 +30,6 @@ pub mod __private { pub use dash_primitives; pub use dash_types; } -#[cfg(feature = "serde")] -pub(crate) mod serialize; - pub use bip324::{decode_v2, encode_v2}; pub use command::CommandString; pub use error::P2pDecodeError; diff --git a/pkgs/p2p_core/src/msg/mod.rs b/pkgs/p2p_core/src/msg/mod.rs index c618caba..03108aeb 100644 --- a/pkgs/p2p_core/src/msg/mod.rs +++ b/pkgs/p2p_core/src/msg/mod.rs @@ -20,9 +20,6 @@ use crate::prelude::*; use crate::short_id::ShortId; use bitcoin_consensus_encoding as encoding; -use bitcoin_p2p_messages::message_bloom::{FilterAdd, FilterLoad}; -use bitcoin_p2p_messages::message_compact_blocks::SendCmpct; -use bitcoin_p2p_messages::message_filter::{CFCheckpt, CFHeaders, CFilter, GetCFCheckpt, GetCFHeaders, GetCFilters}; use dash_primitives::{GovObject, GovVote}; use dash_types::type_id::Unencodable; @@ -61,24 +58,6 @@ define_p2p! { GetHeaders2(GetHeaders2) => GETHEADERS2 "getheaders2" @ 163, /// Compressed block headers. Headers2(Headers2) => HEADERS2 "headers2" @ 165, - /// Request compact filters. - #[cfg_attr(feature = "serde", serde(with = "crate::serialize::get_cfilters"))] - GetCFilters(GetCFilters) => GETCFILTERS "getcfilters" @ 22, - /// Compact block filter. - #[cfg_attr(feature = "serde", serde(with = "crate::serialize::cfilter"))] - CFilter(CFilter) => CFILTER "cfilter" @ 23, - /// Request compact filter headers. - #[cfg_attr(feature = "serde", serde(with = "crate::serialize::get_cfheaders"))] - GetCFHeaders(GetCFHeaders) => GETCFHEADERS "getcfheaders" @ 24, - /// Compact filter headers. - #[cfg_attr(feature = "serde", serde(with = "crate::serialize::cfheaders"))] - CFHeaders(CFHeaders) => CFHEADERS "cfheaders" @ 25, - /// Request compact filter checkpoints. - #[cfg_attr(feature = "serde", serde(with = "crate::serialize::get_cfcheckpt"))] - GetCFCheckpt(GetCFCheckpt) => GETCFCHECKPT "getcfcheckpt" @ 26, - /// Compact filter checkpoints. - #[cfg_attr(feature = "serde", serde(with = "crate::serialize::cfcheckpt"))] - CFCheckpt(CFCheckpt) => CFCHECKPT "cfcheckpt" @ 27, /// Governance sync request. GovSync(GovSync) => GOVSYNC "govsync" @ 140, /// Governance object. @@ -89,15 +68,6 @@ define_p2p! { GetMnListDiff(GetMnListDiff) => GETMNLISTD "getmnlistd" @ 143, /// MN list diff. MnListDiff(MnListDiff) => MNLISTDIFF "mnlistdiff" @ 144, - /// BIP152: signal compact block support. - #[cfg_attr(feature = "serde", serde(with = "crate::serialize::send_cmpct"))] - SendCmpct(SendCmpct) => SENDCMPCT "sendcmpct" @ 20, - /// BIP37: load bloom filter. - #[cfg_attr(feature = "serde", serde(with = "crate::serialize::filter_load"))] - FilterLoad(FilterLoad) => FILTERLOAD "filterload" @ 8, - /// BIP37: add data to bloom filter. - #[cfg_attr(feature = "serde", serde(with = "crate::serialize::filter_add"))] - FilterAdd(FilterAdd) => FILTERADD "filteradd" @ 6, } parsed_empty { @@ -120,14 +90,32 @@ define_p2p! { BlockTxn => BLOCKTXN "blocktxn" @ 3, /// BIP152: compact block. CmpctBlock => CMPCTBLOCK "cmpctblock" @ 4, + /// BIP37: add data to bloom filter. + FilterAdd => FILTERADD "filteradd" @ 6, + /// BIP37: load bloom filter. + FilterLoad => FILTERLOAD "filterload" @ 8, /// Request block hashes. GetBlocks => GETBLOCKS "getblocks" @ 9, /// BIP152: request compact block transactions. GetBlockTxn => GETBLOCKTXN "getblocktxn" @ 10, /// BIP37: filtered block. MerkleBlock => MERKLEBLOCK "merkleblock" @ 16, + /// BIP152: signal compact block support. + SendCmpct => SENDCMPCT "sendcmpct" @ 20, /// Transaction. Tx => TX "tx" @ 21, + /// Request compact filters. + GetCFilters => GETCFILTERS "getcfilters" @ 22, + /// Compact block filter. + CFilter => CFILTER "cfilter" @ 23, + /// Request compact filter headers. + GetCFHeaders => GETCFHEADERS "getcfheaders" @ 24, + /// Compact filter headers. + CFHeaders => CFHEADERS "cfheaders" @ 25, + /// Request compact filter checkpoints. + GetCFCheckpt => GETCFCHECKPT "getcfcheckpt" @ 26, + /// Compact filter checkpoints. + CFCheckpt => CFCHECKPT "cfcheckpt" @ 27, /// BIP330: transaction reconciliation. SendTxRcncl => SENDTXRCNCL "sendtxrcncl", /// Spork broadcast/request. diff --git a/pkgs/p2p_core/src/serialize.rs b/pkgs/p2p_core/src/serialize.rs deleted file mode 100644 index b2b868db..00000000 --- a/pkgs/p2p_core/src/serialize.rs +++ /dev/null @@ -1,404 +0,0 @@ -// -// Copyright (c) 2026-present, The Dash Core developers -// SPDX-License-Identifier: MIT -// See the accompanying file LICENSE or https://opensource.org/license/MIT -// - -//! Reusable serde helpers for `#[serde(with = "...")]`. - -use crate::prelude::*; - -use bitcoin_primitives::BlockHash; -use bitcoin_units::BlockHeight; -use dash_types::type_id::Unencodable; -use serde::{Deserialize, Deserializer, Serialize, Serializer}; - -/// For [`BlockHash`](bitcoin_primitives::BlockHash) as a hex string. -mod block_hash { - use super::*; - - pub fn serialize(val: &BlockHash, s: S) -> Result { - s.serialize_str(&alloc::format!("{val}")) - } - - pub fn deserialize<'de, D: Deserializer<'de>>(d: D) -> Result { - let s = >::deserialize(d)?; - s.parse().map_err(::serde::de::Error::custom) - } -} - -/// For [`BlockHeight`](bitcoin_units::BlockHeight) as `u32`. -mod block_height { - use super::*; - - pub fn serialize(val: &BlockHeight, s: S) -> Result { - s.serialize_u32(val.to_u32()) - } - - pub fn deserialize<'de, D: Deserializer<'de>>(d: D) -> Result { - Ok(BlockHeight::from_u32(u32::deserialize(d)?)) - } -} - -/// For [`GetCFilters`](bitcoin_p2p_messages::message_filter::GetCFilters). -pub mod get_cfilters { - use super::*; - - use bitcoin_p2p_messages::message_filter::GetCFilters; - - pub fn serialize(val: &GetCFilters, s: S) -> Result { - #[derive(Serialize)] - struct Ser { - filter_type: u8, - #[serde(with = "super::block_height")] - start_height: BlockHeight, - #[serde(with = "super::block_hash")] - stop_hash: BlockHash, - } - Ser { - filter_type: val.filter_type, - start_height: val.start_height, - stop_hash: val.stop_hash, - } - .serialize(s) - } - - pub fn deserialize<'de, D: Deserializer<'de>>(d: D) -> Result { - #[derive(Deserialize)] - struct De { - filter_type: u8, - #[serde(with = "super::block_height")] - start_height: BlockHeight, - #[serde(with = "super::block_hash")] - stop_hash: BlockHash, - } - let r = De::deserialize(d)?; - Ok(GetCFilters { - filter_type: r.filter_type, - start_height: r.start_height, - stop_hash: r.stop_hash, - }) - } -} - -/// For [`CFilter`](bitcoin_p2p_messages::message_filter::CFilter). -pub mod cfilter { - use super::*; - - use bitcoin_p2p_messages::message_filter::CFilter; - - pub fn serialize(val: &CFilter, s: S) -> Result { - #[derive(Serialize)] - struct Ser<'a> { - filter_type: u8, - #[serde(with = "super::block_hash")] - block_hash: BlockHash, - filter: &'a [u8], - } - Ser { - filter_type: val.filter_type, - block_hash: val.block_hash, - filter: &val.filter, - } - .serialize(s) - } - - pub fn deserialize<'de, D: Deserializer<'de>>(d: D) -> Result { - #[derive(Deserialize)] - struct De { - filter_type: u8, - #[serde(with = "super::block_hash")] - block_hash: BlockHash, - filter: Vec, - } - let r = De::deserialize(d)?; - Ok(CFilter { - filter_type: r.filter_type, - block_hash: r.block_hash, - filter: r.filter, - }) - } -} - -/// For [`GetCFHeaders`](bitcoin_p2p_messages::message_filter::GetCFHeaders). -pub mod get_cfheaders { - use super::*; - - use bitcoin_p2p_messages::message_filter::GetCFHeaders; - - pub fn serialize(val: &GetCFHeaders, s: S) -> Result { - #[derive(Serialize)] - struct Ser { - filter_type: u8, - #[serde(with = "super::block_height")] - start_height: BlockHeight, - #[serde(with = "super::block_hash")] - stop_hash: BlockHash, - } - Ser { - filter_type: val.filter_type, - start_height: val.start_height, - stop_hash: val.stop_hash, - } - .serialize(s) - } - - pub fn deserialize<'de, D: Deserializer<'de>>(d: D) -> Result { - #[derive(Deserialize)] - struct De { - filter_type: u8, - #[serde(with = "super::block_height")] - start_height: BlockHeight, - #[serde(with = "super::block_hash")] - stop_hash: BlockHash, - } - let r = De::deserialize(d)?; - Ok(GetCFHeaders { - filter_type: r.filter_type, - start_height: r.start_height, - stop_hash: r.stop_hash, - }) - } -} - -/// For [`CFHeaders`](bitcoin_p2p_messages::message_filter::CFHeaders). -pub mod cfheaders { - use super::*; - - use bitcoin_p2p_messages::message_filter::{CFHeaders, FilterHash, FilterHeader}; - - pub fn serialize(val: &CFHeaders, s: S) -> Result { - #[derive(Serialize)] - struct Ser<'a> { - filter_type: u8, - #[serde(with = "super::block_hash")] - stop_hash: BlockHash, - previous_filter_header: FilterHeader, - filter_hashes: &'a [FilterHash], - } - Ser { - filter_type: val.filter_type, - stop_hash: val.stop_hash, - previous_filter_header: val.previous_filter_header, - filter_hashes: &val.filter_hashes, - } - .serialize(s) - } - - pub fn deserialize<'de, D: Deserializer<'de>>(d: D) -> Result { - #[derive(Deserialize)] - struct De { - filter_type: u8, - #[serde(with = "super::block_hash")] - stop_hash: BlockHash, - previous_filter_header: FilterHeader, - filter_hashes: Vec, - } - let r = De::deserialize(d)?; - Ok(CFHeaders { - filter_type: r.filter_type, - stop_hash: r.stop_hash, - previous_filter_header: r.previous_filter_header, - filter_hashes: r.filter_hashes, - }) - } -} - -/// For [`GetCFCheckpt`](bitcoin_p2p_messages::message_filter::GetCFCheckpt). -pub mod get_cfcheckpt { - use super::*; - - use bitcoin_p2p_messages::message_filter::GetCFCheckpt; - - pub fn serialize(val: &GetCFCheckpt, s: S) -> Result { - #[derive(Serialize)] - struct Ser { - filter_type: u8, - #[serde(with = "super::block_hash")] - stop_hash: BlockHash, - } - Ser { - filter_type: val.filter_type, - stop_hash: val.stop_hash, - } - .serialize(s) - } - - pub fn deserialize<'de, D: Deserializer<'de>>(d: D) -> Result { - #[derive(Deserialize)] - struct De { - filter_type: u8, - #[serde(with = "super::block_hash")] - stop_hash: BlockHash, - } - let r = De::deserialize(d)?; - Ok(GetCFCheckpt { - filter_type: r.filter_type, - stop_hash: r.stop_hash, - }) - } -} - -/// For [`FilterLoad`](bitcoin_p2p_messages::message_bloom::FilterLoad). -pub mod filter_load { - use super::*; - - use bitcoin_p2p_messages::message_bloom::{BloomFlags, FilterLoad}; - - #[derive(Clone, Debug, Eq, Hash, PartialEq, Unencodable, Serialize, Deserialize)] - enum FlagsRepr { - None, - All, - PubkeyOnly, - } - - impl From<&BloomFlags> for FlagsRepr { - fn from(f: &BloomFlags) -> Self { - match f { - BloomFlags::None => Self::None, - BloomFlags::All => Self::All, - BloomFlags::PubkeyOnly => Self::PubkeyOnly, - } - } - } - - impl From for BloomFlags { - fn from(f: FlagsRepr) -> Self { - match f { - FlagsRepr::None => Self::None, - FlagsRepr::All => Self::All, - FlagsRepr::PubkeyOnly => Self::PubkeyOnly, - } - } - } - - pub fn serialize(val: &FilterLoad, s: S) -> Result { - #[derive(Serialize)] - struct Ser<'a> { - filter: &'a [u8], - hash_funcs: u32, - tweak: u32, - flags: FlagsRepr, - } - Ser { - filter: &val.filter, - hash_funcs: val.hash_funcs, - tweak: val.tweak, - flags: FlagsRepr::from(&val.flags), - } - .serialize(s) - } - - pub fn deserialize<'de, D: Deserializer<'de>>(d: D) -> Result { - #[derive(Deserialize)] - struct De { - filter: Vec, - hash_funcs: u32, - tweak: u32, - flags: FlagsRepr, - } - let r = De::deserialize(d)?; - Ok(FilterLoad { - filter: r.filter, - hash_funcs: r.hash_funcs, - tweak: r.tweak, - flags: r.flags.into(), - }) - } -} - -/// For [`FilterAdd`](bitcoin_p2p_messages::message_bloom::FilterAdd). -pub mod filter_add { - use super::*; - - use bitcoin_p2p_messages::message_bloom::FilterAdd; - - pub fn serialize(val: &FilterAdd, s: S) -> Result { - #[derive(Serialize)] - struct Ser<'a> { - data: &'a [u8], - } - Ser { data: &val.data }.serialize(s) - } - - pub fn deserialize<'de, D: Deserializer<'de>>(d: D) -> Result { - #[derive(Deserialize)] - struct De { - data: Vec, - } - let r = De::deserialize(d)?; - Ok(FilterAdd { data: r.data }) - } -} - -/// For [`SendCmpct`](bitcoin_p2p_messages::message_compact_blocks::SendCmpct). -pub mod send_cmpct { - use super::*; - - use bitcoin_p2p_messages::message_compact_blocks::SendCmpct; - - pub fn serialize(val: &SendCmpct, s: S) -> Result { - #[derive(Serialize)] - struct Ser { - send_compact: bool, - version: u64, - } - Ser { - send_compact: val.send_compact, - version: val.version, - } - .serialize(s) - } - - pub fn deserialize<'de, D: Deserializer<'de>>(d: D) -> Result { - #[derive(Deserialize)] - struct De { - send_compact: bool, - version: u64, - } - let r = De::deserialize(d)?; - Ok(SendCmpct { - send_compact: r.send_compact, - version: r.version, - }) - } -} - -/// For [`CFCheckpt`](bitcoin_p2p_messages::message_filter::CFCheckpt). -pub mod cfcheckpt { - use super::*; - - use bitcoin_p2p_messages::message_filter::{CFCheckpt, FilterHeader}; - - pub fn serialize(val: &CFCheckpt, s: S) -> Result { - #[derive(Serialize)] - struct Ser<'a> { - filter_type: u8, - #[serde(with = "super::block_hash")] - stop_hash: BlockHash, - filter_headers: &'a [FilterHeader], - } - Ser { - filter_type: val.filter_type, - stop_hash: val.stop_hash, - filter_headers: &val.filter_headers, - } - .serialize(s) - } - - pub fn deserialize<'de, D: Deserializer<'de>>(d: D) -> Result { - #[derive(Deserialize)] - struct De { - filter_type: u8, - #[serde(with = "super::block_hash")] - stop_hash: BlockHash, - filter_headers: Vec, - } - let r = De::deserialize(d)?; - Ok(CFCheckpt { - filter_type: r.filter_type, - stop_hash: r.stop_hash, - filter_headers: r.filter_headers, - }) - } -} diff --git a/pkgs/types/Cargo.toml b/pkgs/types/Cargo.toml index 7cd02bd2..d02f80ad 100644 --- a/pkgs/types/Cargo.toml +++ b/pkgs/types/Cargo.toml @@ -13,13 +13,11 @@ rust-version.workspace = true default = [] std = [ "bitcoin-consensus-encoding?/std", - "bitcoin-p2p-messages?/std", "bitcoin-primitives?/std", "hex-conservative?/std", ] -full = ["std", "codec", "serde", "bitcoin-p2p-messages", "bitcoin-primitives"] +full = ["std", "codec", "serde", "bitcoin-primitives"] codec = ["dep:bitcoin-consensus-encoding", "dep:dash-types-marker"] -bitcoin-p2p-messages = ["codec", "dep:bitcoin-p2p-messages"] bitcoin-primitives = [ "codec", "dep:base58ck", @@ -31,7 +29,6 @@ serde = ["dep:serde", "dep:hex-conservative"] [dependencies] base58ck = { workspace = true, optional = true, features = ["alloc"] } bitcoin-consensus-encoding = { workspace = true, optional = true } -bitcoin-p2p-messages = { workspace = true, optional = true } bitcoin_hashes = { workspace = true, optional = true, features = ["alloc"] } bitcoin-primitives = { workspace = true, optional = true, features = ["alloc"] } cfg-if = "1" diff --git a/pkgs/types/src/adapters.rs b/pkgs/types/src/adapters.rs index b47bd3ea..a8a6d727 100644 --- a/pkgs/types/src/adapters.rs +++ b/pkgs/types/src/adapters.rs @@ -23,29 +23,6 @@ macro_rules! adapt_codec { } } }; - ($ty:ty, $len:expr) => { - impl $crate::codec::BaseCodec for $ty { - fn decode(data: &mut &[u8]) -> Result { - let bytes = $crate::codec::read_bytes(data, $len)?; - let mut arr = [0u8; $len]; - arr.copy_from_slice(bytes); - Ok(Self::from_byte_array(arr)) - } - - fn encode(&self, buf: &mut impl $crate::codec::EncodeBuf) { - buf.extend_from_slice(&self.to_byte_array()); - } - } - }; -} - -#[cfg(feature = "bitcoin-p2p-messages")] -mod bitcoin_p2p_messages { - // nosemgrep: macro-no-bare-foreign-crate - use ::bitcoin_p2p_messages::message_filter::{FilterHash, FilterHeader}; - - adapt_codec!(FilterHash, 32); - adapt_codec!(FilterHeader, 32); } #[cfg(feature = "bitcoin-primitives")] From 904798f05b90bbca31d7c0d319a8a084aa93c736 Mon Sep 17 00:00:00 2001 From: Kittywhiskers Van Gogh <63189531+kwvg@users.noreply.github.com> Date: Sun, 13 Sep 2026 14:25:07 +0530 Subject: [PATCH 4/8] sdk%build: bump `bitcoin-consensus-encoding` to `crates.io` release --- Cargo.lock | 53 +++++++++++++++++++++----------- Cargo.toml | 2 +- docs/samples/Cargo.lock | 45 ++++++++++++++++++--------- docs/samples/Cargo.toml | 2 +- pkgs/pkc/src/ecdsa/secret_ops.rs | 4 +-- pkgs/types/src/codec.rs | 6 ++++ pkgs/types/src/entity.rs | 36 +++++++++++++--------- pkgs/types/src/secret.rs | 46 ++++++++++++++------------- 8 files changed, 123 insertions(+), 71 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index eef34045..eee24938 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -61,7 +61,7 @@ name = "base58ck" version = "0.4.0" source = "git+https://github.com/rust-bitcoin/rust-bitcoin?tag=bitcoin-crypto-0.2.0#11650c6c480088cc30a04e583e187cd7a84a2d8f" dependencies = [ - "bitcoin-internals", + "bitcoin-internals 0.5.0", "bitcoin_hashes", ] @@ -70,7 +70,18 @@ name = "bitcoin-consensus-encoding" version = "0.2.0" source = "git+https://github.com/rust-bitcoin/rust-bitcoin?tag=bitcoin-crypto-0.2.0#11650c6c480088cc30a04e583e187cd7a84a2d8f" dependencies = [ - "bitcoin-internals", + "bitcoin-internals 0.5.0", +] + +[[package]] +name = "bitcoin-consensus-encoding" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6712f9c6fd6785b3b270884e57c441c403dc5d7e19ca45368c97c7a1de3000ec" +dependencies = [ + "bitcoin-internals 0.6.0", + "hex-conservative 1.2.0", + "serde", ] [[package]] @@ -82,13 +93,19 @@ dependencies = [ "serde", ] +[[package]] +name = "bitcoin-internals" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d573f4cf32996a8dce612e4348cece65a241f1882ed594047c9ba348e8869fa5" + [[package]] name = "bitcoin-primitives" version = "0.102.0" source = "git+https://github.com/rust-bitcoin/rust-bitcoin?tag=bitcoin-crypto-0.2.0#11650c6c480088cc30a04e583e187cd7a84a2d8f" dependencies = [ - "bitcoin-consensus-encoding", - "bitcoin-internals", + "bitcoin-consensus-encoding 0.2.0", + "bitcoin-internals 0.5.0", "bitcoin-units", "bitcoin_hashes", "hex-conservative 0.3.2", @@ -101,8 +118,8 @@ name = "bitcoin-units" version = "0.3.0" source = "git+https://github.com/rust-bitcoin/rust-bitcoin?tag=bitcoin-crypto-0.2.0#11650c6c480088cc30a04e583e187cd7a84a2d8f" dependencies = [ - "bitcoin-consensus-encoding", - "bitcoin-internals", + "bitcoin-consensus-encoding 0.2.0", + "bitcoin-internals 0.5.0", "serde", ] @@ -111,8 +128,8 @@ name = "bitcoin_hashes" version = "0.20.0" source = "git+https://github.com/rust-bitcoin/rust-bitcoin?tag=bitcoin-crypto-0.2.0#11650c6c480088cc30a04e583e187cd7a84a2d8f" dependencies = [ - "bitcoin-consensus-encoding", - "bitcoin-internals", + "bitcoin-consensus-encoding 0.2.0", + "bitcoin-internals 0.5.0", "hex-conservative 0.3.2", "hex-conservative 1.2.0", "serde", @@ -428,7 +445,7 @@ dependencies = [ name = "dash-dev" version = "0.0.0" dependencies = [ - "bitcoin-consensus-encoding", + "bitcoin-consensus-encoding 1.2.0", "built", "cfg-if", "chrono", @@ -455,7 +472,7 @@ dependencies = [ name = "dash-num" version = "0.0.0" dependencies = [ - "bitcoin-consensus-encoding", + "bitcoin-consensus-encoding 1.2.0", "dash-dev", "dash-types", "divan", @@ -468,8 +485,8 @@ dependencies = [ name = "dash-p2p-core" version = "0.0.0" dependencies = [ - "bitcoin-consensus-encoding", - "bitcoin-internals", + "bitcoin-consensus-encoding 1.2.0", + "bitcoin-internals 0.5.0", "cfg-if", "dash-dev", "dash-num", @@ -487,7 +504,7 @@ dependencies = [ name = "dash-params" version = "0.0.0" dependencies = [ - "bitcoin-consensus-encoding", + "bitcoin-consensus-encoding 1.2.0", "bitcoin-primitives", "bitcoin-units", "dash-num", @@ -504,7 +521,7 @@ version = "0.0.0" dependencies = [ "aes", "base58ck", - "bitcoin-consensus-encoding", + "bitcoin-consensus-encoding 1.2.0", "bitcoin_hashes", "blst", "cfg-if", @@ -539,8 +556,8 @@ dependencies = [ name = "dash-primitives" version = "0.0.0" dependencies = [ - "bitcoin-consensus-encoding", - "bitcoin-internals", + "bitcoin-consensus-encoding 1.2.0", + "bitcoin-internals 0.5.0", "bitcoin-primitives", "bitcoin-units", "bitcoin_hashes", @@ -563,7 +580,7 @@ name = "dash-script" version = "0.0.0" dependencies = [ "base58ck", - "bitcoin-consensus-encoding", + "bitcoin-consensus-encoding 1.2.0", "dash-num", "dash-pkc", "dash-types", @@ -577,7 +594,7 @@ name = "dash-types" version = "0.0.0" dependencies = [ "base58ck", - "bitcoin-consensus-encoding", + "bitcoin-consensus-encoding 1.2.0", "bitcoin-primitives", "bitcoin_hashes", "cfg-if", diff --git a/Cargo.toml b/Cargo.toml index 81750d4e..24e690c2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,7 +15,7 @@ resolver = "2" [workspace.dependencies] base58ck = { git = "https://github.com/rust-bitcoin/rust-bitcoin", tag = "bitcoin-crypto-0.2.0", default-features = false } -bitcoin-consensus-encoding = { git = "https://github.com/rust-bitcoin/rust-bitcoin", tag = "bitcoin-crypto-0.2.0", default-features = false } +bitcoin-consensus-encoding = { version = "1.2.0", default-features = false } bitcoin-internals = { git = "https://github.com/rust-bitcoin/rust-bitcoin", tag = "bitcoin-crypto-0.2.0", default-features = false } bitcoin-primitives = { git = "https://github.com/rust-bitcoin/rust-bitcoin", tag = "bitcoin-crypto-0.2.0", default-features = false } bitcoin-units = { git = "https://github.com/rust-bitcoin/rust-bitcoin", tag = "bitcoin-crypto-0.2.0", default-features = false } diff --git a/docs/samples/Cargo.lock b/docs/samples/Cargo.lock index aff0574a..0793c507 100644 --- a/docs/samples/Cargo.lock +++ b/docs/samples/Cargo.lock @@ -13,7 +13,7 @@ name = "base58ck" version = "0.4.0" source = "git+https://github.com/rust-bitcoin/rust-bitcoin?tag=bitcoin-crypto-0.2.0#11650c6c480088cc30a04e583e187cd7a84a2d8f" dependencies = [ - "bitcoin-internals", + "bitcoin-internals 0.5.0", "bitcoin_hashes", ] @@ -22,7 +22,18 @@ name = "bitcoin-consensus-encoding" version = "0.2.0" source = "git+https://github.com/rust-bitcoin/rust-bitcoin?tag=bitcoin-crypto-0.2.0#11650c6c480088cc30a04e583e187cd7a84a2d8f" dependencies = [ - "bitcoin-internals", + "bitcoin-internals 0.5.0", +] + +[[package]] +name = "bitcoin-consensus-encoding" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6712f9c6fd6785b3b270884e57c441c403dc5d7e19ca45368c97c7a1de3000ec" +dependencies = [ + "bitcoin-internals 0.6.0", + "hex-conservative 1.2.0", + "serde", ] [[package]] @@ -34,13 +45,19 @@ dependencies = [ "serde", ] +[[package]] +name = "bitcoin-internals" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d573f4cf32996a8dce612e4348cece65a241f1882ed594047c9ba348e8869fa5" + [[package]] name = "bitcoin-primitives" version = "0.102.0" source = "git+https://github.com/rust-bitcoin/rust-bitcoin?tag=bitcoin-crypto-0.2.0#11650c6c480088cc30a04e583e187cd7a84a2d8f" dependencies = [ - "bitcoin-consensus-encoding", - "bitcoin-internals", + "bitcoin-consensus-encoding 0.2.0", + "bitcoin-internals 0.5.0", "bitcoin-units", "bitcoin_hashes", "hex-conservative 0.3.2", @@ -53,8 +70,8 @@ name = "bitcoin-units" version = "0.3.0" source = "git+https://github.com/rust-bitcoin/rust-bitcoin?tag=bitcoin-crypto-0.2.0#11650c6c480088cc30a04e583e187cd7a84a2d8f" dependencies = [ - "bitcoin-consensus-encoding", - "bitcoin-internals", + "bitcoin-consensus-encoding 0.2.0", + "bitcoin-internals 0.5.0", "serde", ] @@ -63,8 +80,8 @@ name = "bitcoin_hashes" version = "0.20.0" source = "git+https://github.com/rust-bitcoin/rust-bitcoin?tag=bitcoin-crypto-0.2.0#11650c6c480088cc30a04e583e187cd7a84a2d8f" dependencies = [ - "bitcoin-consensus-encoding", - "bitcoin-internals", + "bitcoin-consensus-encoding 0.2.0", + "bitcoin-internals 0.5.0", "hex-conservative 0.3.2", "hex-conservative 1.2.0", "serde", @@ -86,7 +103,7 @@ checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" name = "dash-num" version = "0.0.0" dependencies = [ - "bitcoin-consensus-encoding", + "bitcoin-consensus-encoding 1.2.0", "dash-types", "serde", ] @@ -114,8 +131,8 @@ version = "0.0.0" name = "dash-primitives" version = "0.0.0" dependencies = [ - "bitcoin-consensus-encoding", - "bitcoin-internals", + "bitcoin-consensus-encoding 1.2.0", + "bitcoin-internals 0.5.0", "bitcoin-primitives", "bitcoin-units", "bitcoin_hashes", @@ -145,7 +162,7 @@ dependencies = [ name = "dash-sample-solver" version = "0.0.0" dependencies = [ - "bitcoin-consensus-encoding", + "bitcoin-consensus-encoding 1.2.0", "bitcoin-primitives", "bitcoin-units", "dash-num", @@ -164,7 +181,7 @@ name = "dash-script" version = "0.0.0" dependencies = [ "base58ck", - "bitcoin-consensus-encoding", + "bitcoin-consensus-encoding 1.2.0", "dash-num", "dash-pkc", "dash-types", @@ -176,7 +193,7 @@ name = "dash-types" version = "0.0.0" dependencies = [ "base58ck", - "bitcoin-consensus-encoding", + "bitcoin-consensus-encoding 1.2.0", "bitcoin-primitives", "bitcoin_hashes", "cfg-if", diff --git a/docs/samples/Cargo.toml b/docs/samples/Cargo.toml index 9ca94f07..67cab308 100644 --- a/docs/samples/Cargo.toml +++ b/docs/samples/Cargo.toml @@ -3,7 +3,7 @@ members = ["parser", "solver"] resolver = "2" [workspace.dependencies] -bitcoin-consensus-encoding = { git = "https://github.com/rust-bitcoin/rust-bitcoin", tag = "bitcoin-crypto-0.2.0", default-features = false } +bitcoin-consensus-encoding = { version = "1.2.0", default-features = false } bitcoin-primitives = { git = "https://github.com/rust-bitcoin/rust-bitcoin", tag = "bitcoin-crypto-0.2.0", default-features = false } bitcoin-units = { git = "https://github.com/rust-bitcoin/rust-bitcoin", tag = "bitcoin-crypto-0.2.0", default-features = false } diff --git a/pkgs/pkc/src/ecdsa/secret_ops.rs b/pkgs/pkc/src/ecdsa/secret_ops.rs index 8593e32d..ec497f66 100644 --- a/pkgs/pkc/src/ecdsa/secret_ops.rs +++ b/pkgs/pkc/src/ecdsa/secret_ops.rs @@ -329,7 +329,7 @@ mod tests { #[case::compressed(Compression::Compressed)] #[case::uncompressed(Compression::Uncompressed)] fn consensus_bridge_roundtrip(#[case] compressed: Compression) { - use bitcoin_consensus_encoding::{encode_to_vec, Decode, Decoder}; + use bitcoin_consensus_encoding::{encode_to_vec, Decode, Decoder, DecoderStatus}; let sk = EcdsaSecretKey::from_bytes(&ALICE_SK, compressed).unwrap(); let wire = encode_to_vec(&sk); @@ -341,7 +341,7 @@ mod tests { let mut dec = ::decoder(); let mut cursor = wire.as_slice(); - while dec.push_bytes(&mut cursor).unwrap() && !cursor.is_empty() {} + while matches!(dec.push_bytes(&mut cursor).unwrap(), DecoderStatus::NeedsMore) && !cursor.is_empty() {} let back = dec.end().unwrap(); assert_eq!(*back.to_bytes(), *sk.to_bytes()); assert_eq!(back.is_compressed(), compressed.is_compressed()); diff --git a/pkgs/types/src/codec.rs b/pkgs/types/src/codec.rs index e4399aaf..62e072a0 100644 --- a/pkgs/types/src/codec.rs +++ b/pkgs/types/src/codec.rs @@ -189,6 +189,12 @@ pub trait NumCodec: Sized { fn to_base(&self) -> N; } +/// The widest wire image a type's buffering decoder will accept. +pub trait SerBound { + /// Upper bound on the encoded width, in bytes. + const MAX_SER_SIZE: usize; +} + /// Cursor-based encode/decode for consensus wire types. pub trait BaseCodec: Sized { /// Decodes from the cursor, advancing it past consumed bytes. diff --git a/pkgs/types/src/entity.rs b/pkgs/types/src/entity.rs index dd8346ec..22043227 100644 --- a/pkgs/types/src/entity.rs +++ b/pkgs/types/src/entity.rs @@ -7,12 +7,12 @@ //! Buffered codec implementation. #[cfg(feature = "codec")] -use crate::codec::DecodeError; +use crate::codec::{BaseCodec, DecodeError, SerBound}; #[cfg(feature = "codec")] use crate::prelude::*; #[cfg(feature = "codec")] -use bitcoin_consensus_encoding::{Decoder, Encoder}; +use bitcoin_consensus_encoding::{Decoder, DecoderStatus, Encoder, EncoderStatus}; #[cfg(feature = "codec")] use core::convert::Infallible; @@ -59,13 +59,9 @@ impl Encoder for VecEncoder { } } - fn advance(&mut self) -> bool { - if self.done { - false - } else { - self.done = true; - false - } + fn advance(&mut self) -> EncoderStatus { + self.done = true; + EncoderStatus::Finished } } @@ -120,15 +116,16 @@ impl Decoder for VecDecoder { type Output = T; type Error = DecodeError; - fn push_bytes(&mut self, bytes: &mut &[u8]) -> Result { + fn push_bytes(&mut self, bytes: &mut &[u8]) -> Result { let remaining = self.limit.saturating_sub(self.buf.len()); - if remaining == 0 { - return Ok(false); - } let take = bytes.len().min(remaining); self.buf.extend_from_slice(&bytes[..take]); *bytes = &bytes[take..]; - Ok(true) + if self.buf.len() < self.limit { + Ok(DecoderStatus::NeedsMore) + } else { + Ok(DecoderStatus::Ready) + } } fn end(self) -> Result { @@ -147,6 +144,13 @@ impl Decoder for VecDecoder { } } +#[cfg(feature = "codec")] +impl + SerBound, E> Default for VecDecoder { + fn default() -> Self { + Self::new(T::decode, T::MAX_SER_SIZE) + } +} + /// Generates `Encode` + `Decode` for a `BaseCodec` implementor. /// /// Stages through the growable [`VecEncoder`]/[`VecDecoder`] pair. For @@ -165,6 +169,10 @@ macro_rules! impl_type { } } + impl<$($impl_generics)*> $crate::codec::SerBound for $ty { + const MAX_SER_SIZE: usize = $max; + } + impl<$($impl_generics)*> $crate::__private::bitcoin_consensus_encoding::Decode for $ty { type Decoder = $crate::VecDecoder<$ty, $err>; fn decoder() -> Self::Decoder { diff --git a/pkgs/types/src/secret.rs b/pkgs/types/src/secret.rs index ae54de9b..3fa1e477 100644 --- a/pkgs/types/src/secret.rs +++ b/pkgs/types/src/secret.rs @@ -7,10 +7,10 @@ //! Secret-holding codec implementation. #[cfg(feature = "codec")] -use crate::codec::{DecodeError, EncodeBuf}; +use crate::codec::{BaseCodec, DecodeError, EncodeBuf}; #[cfg(feature = "codec")] -use bitcoin_consensus_encoding::{Decoder, Encoder}; +use bitcoin_consensus_encoding::{Decoder, DecoderStatus, Encoder, EncoderStatus}; #[cfg(feature = "codec")] use zeroize::Zeroize; @@ -162,13 +162,9 @@ impl Encoder for ArrEncoder { } } - fn advance(&mut self) -> bool { - if self.done { - false - } else { - self.done = true; - false - } + fn advance(&mut self) -> EncoderStatus { + self.done = true; + EncoderStatus::Finished } } @@ -215,15 +211,15 @@ impl Decoder for ArrDecoder { type Output = T; type Error = DecodeError; - fn push_bytes(&mut self, bytes: &mut &[u8]) -> Result { - let remaining = self.buf.spare(); - if remaining == 0 { - return Ok(false); - } - let take = bytes.len().min(remaining); + fn push_bytes(&mut self, bytes: &mut &[u8]) -> Result { + let take = bytes.len().min(self.buf.spare()); self.buf.extend_from_slice(&bytes[..take]); *bytes = &bytes[take..]; - Ok(true) + if self.buf.spare() == 0 { + Ok(DecoderStatus::Ready) + } else { + Ok(DecoderStatus::NeedsMore) + } } fn end(self) -> Result { @@ -244,6 +240,13 @@ impl Decoder for ArrDecoder { } } +#[cfg(feature = "codec")] +impl, const N: usize, E> Default for ArrDecoder { + fn default() -> Self { + Self::new(T::decode) + } +} + /// Generates `Encode` + `Decode` for a `BaseCodec` implementor whose /// wire image is secret. /// @@ -462,7 +465,7 @@ mod tests { use crate::codec::{DecodeError, EncodeBuf}; use crate::prelude::*; - use bitcoin_consensus_encoding::{Decoder, Encoder}; + use bitcoin_consensus_encoding::{Decoder, DecoderStatus, Encoder, EncoderStatus}; use rstest::*; use zeroize::Zeroize; @@ -484,7 +487,7 @@ mod tests { // A short write into a wide buffer must not leak the zero padding. let mut enc = ArrEncoder::new(filled::<64>(0xAB, 10)); assert_eq!(enc.current_chunk(), [0xAB; 10]); - assert!(!enc.advance()); + assert!(matches!(enc.advance(), EncoderStatus::Finished)); assert_eq!(enc.current_chunk(), &[] as &[u8]); } @@ -517,7 +520,7 @@ mod tests { let mut dec = ArrDecoder::, 8>::new(take_all); assert_eq!(dec.read_limit(), 8); let mut input: &[u8] = &[1, 2, 3]; - assert!(dec.push_bytes(&mut input).unwrap_or(false)); + assert!(matches!(dec.push_bytes(&mut input), Ok(DecoderStatus::NeedsMore))); assert!(input.is_empty()); assert_eq!(dec.read_limit(), 5); assert_eq!(dec.end().unwrap_or_default(), vec![1, 2, 3]); @@ -527,10 +530,11 @@ mod tests { fn arr_decoder_stops_at_capacity() { let mut dec = ArrDecoder::, 4>::new(take_all); let mut input: &[u8] = &[9; 10]; - assert!(dec.push_bytes(&mut input).unwrap_or(false)); + assert!(matches!(dec.push_bytes(&mut input), Ok(DecoderStatus::Ready))); assert_eq!(input.len(), 6, "excess must be left for the caller"); assert_eq!(dec.read_limit(), 0); - assert!(!dec.push_bytes(&mut input).unwrap_or(true)); + assert!(matches!(dec.push_bytes(&mut input), Ok(DecoderStatus::Ready))); + assert_eq!(input.len(), 6, "a ready decoder takes nothing more"); } /// Both encoders redact: a `{:?}` in a panic must not print key material. From 5dff250fab0cab537b6008f52dd4251a78b4824f Mon Sep 17 00:00:00 2001 From: Kittywhiskers Van Gogh <63189531+kwvg@users.noreply.github.com> Date: Thu, 10 Sep 2026 00:14:25 +0530 Subject: [PATCH 5/8] sdk%build: bump `rust-bitcoin` dependencies to `crates.io` releases --- Cargo.lock | 61 ++++++++++++++++++++++++++--------------- Cargo.toml | 10 +++---- docs/samples/Cargo.lock | 59 +++++++++++++++++++++++++-------------- docs/samples/Cargo.toml | 4 +-- 4 files changed, 84 insertions(+), 50 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index eee24938..77db402a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -59,16 +59,18 @@ checksum = "fd307490d624467aa6f74b0eabb77633d1f758a7b25f12bceb0b22e08d9726f6" [[package]] name = "base58ck" version = "0.4.0" -source = "git+https://github.com/rust-bitcoin/rust-bitcoin?tag=bitcoin-crypto-0.2.0#11650c6c480088cc30a04e583e187cd7a84a2d8f" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed6a87a8367e7a4248c8dfd783c37ef492bca1307cd4b21b4cfad9cfd15bf060" dependencies = [ "bitcoin-internals 0.5.0", - "bitcoin_hashes", + "bitcoin_hashes 0.20.0", ] [[package]] name = "bitcoin-consensus-encoding" -version = "0.2.0" -source = "git+https://github.com/rust-bitcoin/rust-bitcoin?tag=bitcoin-crypto-0.2.0#11650c6c480088cc30a04e583e187cd7a84a2d8f" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8d7ca3dc8ff835693ad73bf1596240c06f974a31eeb3f611aaedf855f1f2725" dependencies = [ "bitcoin-internals 0.5.0", ] @@ -87,10 +89,10 @@ dependencies = [ [[package]] name = "bitcoin-internals" version = "0.5.0" -source = "git+https://github.com/rust-bitcoin/rust-bitcoin?tag=bitcoin-crypto-0.2.0#11650c6c480088cc30a04e583e187cd7a84a2d8f" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a30a22d1f112dde8e16be7b45c63645dc165cef254f835b3e1e9553e485cfa64" dependencies = [ "hex-conservative 0.3.2", - "serde", ] [[package]] @@ -98,27 +100,31 @@ name = "bitcoin-internals" version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d573f4cf32996a8dce612e4348cece65a241f1882ed594047c9ba348e8869fa5" +dependencies = [ + "serde", +] [[package]] name = "bitcoin-primitives" -version = "0.102.0" -source = "git+https://github.com/rust-bitcoin/rust-bitcoin?tag=bitcoin-crypto-0.2.0#11650c6c480088cc30a04e583e187cd7a84a2d8f" +version = "0.103.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82e12cb1814d037edbd667554c2c0e6b067db72c83ee935b645a6b5829aca908" dependencies = [ - "bitcoin-consensus-encoding 0.2.0", - "bitcoin-internals 0.5.0", + "bitcoin-consensus-encoding 1.2.0", + "bitcoin-internals 0.6.0", "bitcoin-units", - "bitcoin_hashes", - "hex-conservative 0.3.2", + "bitcoin_hashes 1.2.0", "hex-conservative 1.2.0", "serde", ] [[package]] name = "bitcoin-units" -version = "0.3.0" -source = "git+https://github.com/rust-bitcoin/rust-bitcoin?tag=bitcoin-crypto-0.2.0#11650c6c480088cc30a04e583e187cd7a84a2d8f" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ae6dcb008158c2bdbe698470280439844be5f640310e4f5d6ef0a0209e066c2" dependencies = [ - "bitcoin-consensus-encoding 0.2.0", + "bitcoin-consensus-encoding 1.2.0", "bitcoin-internals 0.5.0", "serde", ] @@ -126,11 +132,22 @@ dependencies = [ [[package]] name = "bitcoin_hashes" version = "0.20.0" -source = "git+https://github.com/rust-bitcoin/rust-bitcoin?tag=bitcoin-crypto-0.2.0#11650c6c480088cc30a04e583e187cd7a84a2d8f" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a8a45c2b41c457a9a9e4670422fcbdf109afb3b22bc920b4045e8bdfd788a3d" dependencies = [ - "bitcoin-consensus-encoding 0.2.0", + "bitcoin-consensus-encoding 0.1.0", "bitcoin-internals 0.5.0", "hex-conservative 0.3.2", +] + +[[package]] +name = "bitcoin_hashes" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5304e53726dbe5f93141535e102ed97b5bf4714fbecefdda8f9fb98d7fdaff0e" +dependencies = [ + "bitcoin-consensus-encoding 1.2.0", + "bitcoin-internals 0.6.0", "hex-conservative 1.2.0", "serde", ] @@ -486,7 +503,7 @@ name = "dash-p2p-core" version = "0.0.0" dependencies = [ "bitcoin-consensus-encoding 1.2.0", - "bitcoin-internals 0.5.0", + "bitcoin-internals 0.6.0", "cfg-if", "dash-dev", "dash-num", @@ -522,7 +539,7 @@ dependencies = [ "aes", "base58ck", "bitcoin-consensus-encoding 1.2.0", - "bitcoin_hashes", + "bitcoin_hashes 1.2.0", "blst", "cfg-if", "dash-dev", @@ -557,10 +574,10 @@ name = "dash-primitives" version = "0.0.0" dependencies = [ "bitcoin-consensus-encoding 1.2.0", - "bitcoin-internals 0.5.0", + "bitcoin-internals 0.6.0", "bitcoin-primitives", "bitcoin-units", - "bitcoin_hashes", + "bitcoin_hashes 1.2.0", "cfg-if", "dash-dev", "dash-num", @@ -596,7 +613,7 @@ dependencies = [ "base58ck", "bitcoin-consensus-encoding 1.2.0", "bitcoin-primitives", - "bitcoin_hashes", + "bitcoin_hashes 1.2.0", "cfg-if", "dash-types-marker", "hex-conservative 0.3.2", diff --git a/Cargo.toml b/Cargo.toml index 24e690c2..0ee07e5f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,12 +14,12 @@ members = [ resolver = "2" [workspace.dependencies] -base58ck = { git = "https://github.com/rust-bitcoin/rust-bitcoin", tag = "bitcoin-crypto-0.2.0", default-features = false } +base58ck = { version = "0.4.0", default-features = false } bitcoin-consensus-encoding = { version = "1.2.0", default-features = false } -bitcoin-internals = { git = "https://github.com/rust-bitcoin/rust-bitcoin", tag = "bitcoin-crypto-0.2.0", default-features = false } -bitcoin-primitives = { git = "https://github.com/rust-bitcoin/rust-bitcoin", tag = "bitcoin-crypto-0.2.0", default-features = false } -bitcoin-units = { git = "https://github.com/rust-bitcoin/rust-bitcoin", tag = "bitcoin-crypto-0.2.0", default-features = false } -bitcoin_hashes = { git = "https://github.com/rust-bitcoin/rust-bitcoin", tag = "bitcoin-crypto-0.2.0", default-features = false } +bitcoin-internals = { version = "0.6.0", default-features = false } +bitcoin-primitives = { version = "0.103.0", default-features = false } +bitcoin-units = { version = "0.5.0", default-features = false } +bitcoin_hashes = { version = "1.2.0", default-features = false } [workspace.lints.clippy] expect_used = "deny" diff --git a/docs/samples/Cargo.lock b/docs/samples/Cargo.lock index 0793c507..a629f9fb 100644 --- a/docs/samples/Cargo.lock +++ b/docs/samples/Cargo.lock @@ -11,16 +11,18 @@ checksum = "d3fb67a6e08acf24fdeccbac2cb6ac4305825bd1f117462e0e6f2f193345ad56" [[package]] name = "base58ck" version = "0.4.0" -source = "git+https://github.com/rust-bitcoin/rust-bitcoin?tag=bitcoin-crypto-0.2.0#11650c6c480088cc30a04e583e187cd7a84a2d8f" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed6a87a8367e7a4248c8dfd783c37ef492bca1307cd4b21b4cfad9cfd15bf060" dependencies = [ "bitcoin-internals 0.5.0", - "bitcoin_hashes", + "bitcoin_hashes 0.20.0", ] [[package]] name = "bitcoin-consensus-encoding" -version = "0.2.0" -source = "git+https://github.com/rust-bitcoin/rust-bitcoin?tag=bitcoin-crypto-0.2.0#11650c6c480088cc30a04e583e187cd7a84a2d8f" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8d7ca3dc8ff835693ad73bf1596240c06f974a31eeb3f611aaedf855f1f2725" dependencies = [ "bitcoin-internals 0.5.0", ] @@ -39,10 +41,10 @@ dependencies = [ [[package]] name = "bitcoin-internals" version = "0.5.0" -source = "git+https://github.com/rust-bitcoin/rust-bitcoin?tag=bitcoin-crypto-0.2.0#11650c6c480088cc30a04e583e187cd7a84a2d8f" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a30a22d1f112dde8e16be7b45c63645dc165cef254f835b3e1e9553e485cfa64" dependencies = [ "hex-conservative 0.3.2", - "serde", ] [[package]] @@ -50,27 +52,31 @@ name = "bitcoin-internals" version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d573f4cf32996a8dce612e4348cece65a241f1882ed594047c9ba348e8869fa5" +dependencies = [ + "serde", +] [[package]] name = "bitcoin-primitives" -version = "0.102.0" -source = "git+https://github.com/rust-bitcoin/rust-bitcoin?tag=bitcoin-crypto-0.2.0#11650c6c480088cc30a04e583e187cd7a84a2d8f" +version = "0.103.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82e12cb1814d037edbd667554c2c0e6b067db72c83ee935b645a6b5829aca908" dependencies = [ - "bitcoin-consensus-encoding 0.2.0", - "bitcoin-internals 0.5.0", + "bitcoin-consensus-encoding 1.2.0", + "bitcoin-internals 0.6.0", "bitcoin-units", - "bitcoin_hashes", - "hex-conservative 0.3.2", + "bitcoin_hashes 1.2.0", "hex-conservative 1.2.0", "serde", ] [[package]] name = "bitcoin-units" -version = "0.3.0" -source = "git+https://github.com/rust-bitcoin/rust-bitcoin?tag=bitcoin-crypto-0.2.0#11650c6c480088cc30a04e583e187cd7a84a2d8f" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ae6dcb008158c2bdbe698470280439844be5f640310e4f5d6ef0a0209e066c2" dependencies = [ - "bitcoin-consensus-encoding 0.2.0", + "bitcoin-consensus-encoding 1.2.0", "bitcoin-internals 0.5.0", "serde", ] @@ -78,11 +84,22 @@ dependencies = [ [[package]] name = "bitcoin_hashes" version = "0.20.0" -source = "git+https://github.com/rust-bitcoin/rust-bitcoin?tag=bitcoin-crypto-0.2.0#11650c6c480088cc30a04e583e187cd7a84a2d8f" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a8a45c2b41c457a9a9e4670422fcbdf109afb3b22bc920b4045e8bdfd788a3d" dependencies = [ - "bitcoin-consensus-encoding 0.2.0", + "bitcoin-consensus-encoding 0.1.0", "bitcoin-internals 0.5.0", "hex-conservative 0.3.2", +] + +[[package]] +name = "bitcoin_hashes" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5304e53726dbe5f93141535e102ed97b5bf4714fbecefdda8f9fb98d7fdaff0e" +dependencies = [ + "bitcoin-consensus-encoding 1.2.0", + "bitcoin-internals 0.6.0", "hex-conservative 1.2.0", "serde", ] @@ -113,7 +130,7 @@ name = "dash-pkc" version = "0.0.0" dependencies = [ "base58ck", - "bitcoin_hashes", + "bitcoin_hashes 1.2.0", "cfg-if", "dash-num", "dash-types", @@ -132,10 +149,10 @@ name = "dash-primitives" version = "0.0.0" dependencies = [ "bitcoin-consensus-encoding 1.2.0", - "bitcoin-internals 0.5.0", + "bitcoin-internals 0.6.0", "bitcoin-primitives", "bitcoin-units", - "bitcoin_hashes", + "bitcoin_hashes 1.2.0", "cfg-if", "dash-num", "dash-pkc", @@ -195,7 +212,7 @@ dependencies = [ "base58ck", "bitcoin-consensus-encoding 1.2.0", "bitcoin-primitives", - "bitcoin_hashes", + "bitcoin_hashes 1.2.0", "cfg-if", "dash-types-marker", "hex-conservative 0.3.2", diff --git a/docs/samples/Cargo.toml b/docs/samples/Cargo.toml index 67cab308..722b16ea 100644 --- a/docs/samples/Cargo.toml +++ b/docs/samples/Cargo.toml @@ -4,8 +4,8 @@ resolver = "2" [workspace.dependencies] bitcoin-consensus-encoding = { version = "1.2.0", default-features = false } -bitcoin-primitives = { git = "https://github.com/rust-bitcoin/rust-bitcoin", tag = "bitcoin-crypto-0.2.0", default-features = false } -bitcoin-units = { git = "https://github.com/rust-bitcoin/rust-bitcoin", tag = "bitcoin-crypto-0.2.0", default-features = false } +bitcoin-primitives = { version = "0.103.0", default-features = false } +bitcoin-units = { version = "0.5.0", default-features = false } [workspace.lints.clippy] expect_used = "deny" From d7b5a56397e2572bfb204bc3d8c242b9dd452611 Mon Sep 17 00:00:00 2001 From: Kittywhiskers Van Gogh <63189531+kwvg@users.noreply.github.com> Date: Sun, 13 Sep 2026 14:21:14 +0530 Subject: [PATCH 6/8] sdk%lint(cargo): use `cargo-deny` to refuse yanked releases --- Cargo.lock | 5 +++-- contrib/README.md | 8 ++++++-- contrib/nix/mods/nixpkgs.nix | 1 + deny.toml | 6 ++++++ maint/README.md | 2 +- maint/lint/lint_cargo.py | 24 +++++++++++++++++++++++- 6 files changed, 40 insertions(+), 6 deletions(-) create mode 100644 deny.toml diff --git a/Cargo.lock b/Cargo.lock index 77db402a..c13fc2c5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2203,13 +2203,14 @@ dependencies = [ [[package]] name = "wnaf" -version = "0.14.0" +version = "0.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab12e7090f27e2ffd9322651492942d50c2926094af30601e1964337db39daf1" +checksum = "795ca18b3fdb5e62bf982199278341ddcf7ebf7d32e25e212ad05d496e95f6fa" dependencies = [ "ff", "group", "hybrid-array", + "primefield", ] [[package]] diff --git a/contrib/README.md b/contrib/README.md index 627ac8f0..f1522a55 100644 --- a/contrib/README.md +++ b/contrib/README.md @@ -32,6 +32,7 @@ source .venv/bin/activate [`pyproject.toml`](../pyproject.toml) supplies most but not all dependencies needed to run the lint suite, the following packages need to be additionally sourced. +* [cargo-deny](https://github.com/EmbarkStudios/cargo-deny) * [Git](https://git-scm.com/install/) * [CodeQL 2.24 or higher](https://github.com/github/codeql-cli-binaries/releases) (Rust support was added in 2.23.3, [source](https://github.blog/changelog/2025-10-23-codeql-2-23-3-adds-a-new-rust-query-rust-support-and-easier-c-c-scanning/)) @@ -46,7 +47,7 @@ packages need to be additionally sourced. > ([source](https://docs.brew.sh/FAQ#what-does-keg-only-mean)). ```bash -brew install codeql git node@24 +brew install cargo-deny codeql git node@24 ``` ### Linux/WSL @@ -79,12 +80,15 @@ cargo install taplo-cli # Required because Debian trixie ships Node 20.x, deprecated in April 2026 curl -fsSL https://deb.nodesource.com/setup_24.x | sudo -E bash - sudo apt install git nodejs -y + +# `cargo-deny` is currently unavailable on Debian (https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=951368) +cargo install --locked cargo-deny ``` #### Fedora ```bash -sudo dnf install -y git nodejs24 +sudo dnf install -y cargo-deny git nodejs24 ``` diff --git a/contrib/nix/mods/nixpkgs.nix b/contrib/nix/mods/nixpkgs.nix index 38f2dc1a..62f7b593 100644 --- a/contrib/nix/mods/nixpkgs.nix +++ b/contrib/nix/mods/nixpkgs.nix @@ -24,6 +24,7 @@ let in { packages = [ + pkgs.cargo-deny pkgs.cargo-llvm-cov pkgs.git pkgs.nixfmt diff --git a/deny.toml b/deny.toml new file mode 100644 index 00000000..facf3caf --- /dev/null +++ b/deny.toml @@ -0,0 +1,6 @@ +[graph] +all-features = true + +[advisories] +unmaintained = "none" +yanked = "deny" diff --git a/maint/README.md b/maint/README.md index 753b3818..d2abdda8 100644 --- a/maint/README.md +++ b/maint/README.md @@ -14,7 +14,7 @@ use [`lint_all.py`](./lint_all.py). | Name | Purpose | Verbs | Depends on | | ---- | ------- | ---------- | ---------- | -| [`lint_cargo.py`](./lint/lint_cargo.py) | Enforce MSRV across Rust build dependency graph, check/format TOML files against [`.taplo.toml`](../.taplo.toml) | `check` , `apply`, `apply-all` | (MSRV enforcement) `cargo` (TOML formatting) `taplo` | +| [`lint_cargo.py`](./lint/lint_cargo.py) | Enforce MSRV across Rust build dependency graph, deny dependencies per [`deny.toml`](../deny.toml), check/format TOML files against [`.taplo.toml`](../.taplo.toml) | `check` , `apply`, `apply-all` | `cargo` (MSRV enforcement), `cargo-deny` (deny dependencies), `taplo` (TOML formatting) | | [`lint_codeql.py`](./lint/lint_codeql.py) | Query Rust sources against [`maint/codeql/rust/*.ql`](./codeql/rust) | `check`, `apply`, `apply-all`, `run`, `run-all` | `codeql`, `rustc` | | [`lint_javascript.py`](./lint/lint_javascript.py) | Lint Javascript sources against [`eslint.config.mjs`](js/eslint.config.mjs) | *None* | `npx` (part of Node.js), `eslint` (auto-retrieved by script) | | [`lint_markdown.py`](./lint/lint_markdown.py) | Lint Markdown [documentation](../docs/dev/about_docs.md) | *None* | `pymarkdownlnt` | diff --git a/maint/lint/lint_cargo.py b/maint/lint/lint_cargo.py index a27cf0ff..969b526d 100755 --- a/maint/lint/lint_cargo.py +++ b/maint/lint/lint_cargo.py @@ -266,9 +266,30 @@ def _check_msrv(repo_root: Path) -> int | None: return RETCODE_ERR +def _check_yanked(repo_root: Path) -> int | None: + """Fail on a yanked release, or None when cargo-deny is absent.""" + try: + deny_bin = require_bin("cargo-deny") + except FileNotFoundError as e: + print(f"{e}, skipping the yanked check", file=sys.stderr) + return None + + print("checking yanked: every crate the graph resolves") + result = subprocess.run( # noqa: S603 + [deny_bin, "check", "advisories"], + capture_output=True, + check=False, + cwd=str(repo_root), + text=True, + ) + relay(result.stdout, repo_root) + relay(result.stderr, repo_root, stream=sys.stderr) + return RETCODE_PASS if result.returncode == 0 else RETCODE_ERR + + def main() -> int: args = declare_verbs( - "Validate the crate graph is compatible with the MSRV.", + "Validate the crate graph against the MSRV and yanked releases.", { "check": "report every fault, changing nothing", "apply": f"also rewrite TOML this branch changed vs {DEFAULT_BASE}", @@ -282,6 +303,7 @@ def main() -> int: verdicts: list[int | None] = [ _check_format(repo_root, fix=fix, only=only), _check_msrv(repo_root), + _check_yanked(repo_root), ] ran = [v for v in verdicts if v is not None] if not ran: From bae18d07ad25150683f3e8b011245d207a271a5e Mon Sep 17 00:00:00 2001 From: Kittywhiskers Van Gogh <63189531+kwvg@users.noreply.github.com> Date: Thu, 10 Sep 2026 01:33:43 +0530 Subject: [PATCH 7/8] sdk%build(dev): bump `indicatif` to mitigate RUSTSEC-2025-0119 --- Cargo.lock | 51 +++++++++++++-------------------------------- deny.toml | 1 - pkgs/dev/Cargo.toml | 2 +- 3 files changed, 16 insertions(+), 38 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c13fc2c5..feffc358 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -336,14 +336,13 @@ checksum = "baf0a07a401f374238ab8e2f11a104d2851bf9ce711ec69804834de8af45c7af" [[package]] name = "console" -version = "0.15.11" +version = "0.16.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "054ccb5b10f9f2cbf51eb355ca1d05c2d279ce1804688d0db74b4733a5aeafd8" +checksum = "4fe5f465a4f6fee88fad41b85d990f84c835335e85b5d9e6e63e0d06d28cba7c" dependencies = [ "encode_unicode", "libc", - "once_cell", - "windows-sys 0.59.0", + "windows-sys", ] [[package]] @@ -758,7 +757,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" dependencies = [ "libc", - "windows-sys 0.61.2", + "windows-sys", ] [[package]] @@ -1134,14 +1133,13 @@ dependencies = [ [[package]] name = "indicatif" -version = "0.17.11" +version = "0.18.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "183b3088984b400f4cfac3620d5e076c84da5364016b4f49473de574b2586235" +checksum = "9433806cd6b4ec1aba79c021c7e4c58fb4c3b9977c085062e611ac929998fb0c" dependencies = [ "console", - "number_prefix", "portable-atomic", - "web-time", + "unit-prefix", ] [[package]] @@ -1293,12 +1291,6 @@ dependencies = [ "libc", ] -[[package]] -name = "number_prefix" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "830b246a0e5f20af87141b25c173cd1b609bd7779a4617d6ec582abaf90870f3" - [[package]] name = "once_cell" version = "1.21.4" @@ -1565,7 +1557,7 @@ dependencies = [ "errno", "libc", "linux-raw-sys", - "windows-sys 0.61.2", + "windows-sys", ] [[package]] @@ -1765,7 +1757,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "230a1b821ccbd75b185820a1f1ff7b14d21da1e442e22c0863ea5f08771a8874" dependencies = [ "rustix", - "windows-sys 0.61.2", + "windows-sys", ] [[package]] @@ -1876,6 +1868,12 @@ version = "1.0.24" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75" +[[package]] +name = "unit-prefix" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81e544489bf3d8ef66c953931f56617f423cd4b5494be343d9b9d3dda037b9a3" + [[package]] name = "url" version = "2.5.8" @@ -1957,16 +1955,6 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "web-time" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a6580f308b1fad9207618087a65c04e7a10bc77e02c8e84e9b00dd4b12fa0bb" -dependencies = [ - "js-sys", - "wasm-bindgen", -] - [[package]] name = "winapi" version = "0.3.9" @@ -2101,15 +2089,6 @@ dependencies = [ "windows-link", ] -[[package]] -name = "windows-sys" -version = "0.59.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" -dependencies = [ - "windows-targets", -] - [[package]] name = "windows-sys" version = "0.61.2" diff --git a/deny.toml b/deny.toml index facf3caf..89c16658 100644 --- a/deny.toml +++ b/deny.toml @@ -2,5 +2,4 @@ all-features = true [advisories] -unmaintained = "none" yanked = "deny" diff --git a/pkgs/dev/Cargo.toml b/pkgs/dev/Cargo.toml index 8574963d..6ef0d404 100644 --- a/pkgs/dev/Cargo.toml +++ b/pkgs/dev/Cargo.toml @@ -75,7 +75,7 @@ clap = { version = "4", default-features = false, features = [ "usage", "error-context", ], optional = true } -indicatif = { version = "0.17", default-features = false, optional = true } +indicatif = { version = "0.18", default-features = false, optional = true } json5 = { version = "0.4", optional = true } rayon = { version = "1", optional = true } serde = { version = "1", default-features = false, features = [ From dc86dda75a042b1f569786fc9cfd2ae8752f3509 Mon Sep 17 00:00:00 2001 From: Kittywhiskers Van Gogh <63189531+kwvg@users.noreply.github.com> Date: Thu, 10 Sep 2026 21:32:30 +0530 Subject: [PATCH 8/8] sdk%doc(zen): restore support for inlining code, use `text` for literal --- docs/dev/about_docs.md | 53 +++++++++- docs/preprocess.py | 235 +++++++++++++++++++++++++++++------------ 2 files changed, 215 insertions(+), 73 deletions(-) diff --git a/docs/dev/about_docs.md b/docs/dev/about_docs.md index e50a7466..5d1c619a 100644 --- a/docs/dev/about_docs.md +++ b/docs/dev/about_docs.md @@ -95,7 +95,7 @@ edits and the pages that could be affected by your edits to ensure it remains pl To splice in a whole document, or a spliced segment of it (like `setup`), the syntax is as below. -```markdown +```text ``` @@ -106,14 +106,59 @@ To splice in a whole document, or a spliced segment of it (like `setup`), the sy To create a spliceable segment, wrap the desired text in `start` and `end` markers carrying its label (like `setup`). -```markdown +```text Carried into the splice. ``` Links in spliced material are resolved against the file that defines them, not the page splicing it in (see -[link processing](#link-processing)). Splices may nest, and a directive inside a code fence is inert. +[link processing](#link-processing)). Splices may nest. + +#### Inlining + +> [!TIP] +> To write directives as literal text without parsing it, wrap the text segment in a code block with +> formatting type text (i.e. ```text). This will instruct the preprocessor to *not* interpret the +> captured segment as directives, quoting or otherwise. + +Example code has a recurring problem of staleness, where (especially in early incubation), code segments may undergo +radical changes in shape, scope and location. This can result in examples that at best, don't compile at all and at +worst, enact behaviors that do not match the text description or mislead the reader. + +This is avoided by using segments from the live codebase, as shown below for inlining a complete file. + +````text +```toml + +``` +```` + +> [!WARNING] +> Splicing non-Markdown files outside code blocks is prohibited as Markdown files undergo additional processing steps +> and such files have a high tendency of disturbing the final page render. + +And for partial inlining, the syntax is similar to regular splicing. + +````text +# In Markdown + +```rust + +``` +```` + +With its counterpart in a source file appearing like so. + +```rust +// In Rust + +// [start:vec-codec] +impl Encoder for VecEncoder { + // ... +} +// [end:vec-codec] +``` ### Omitting @@ -124,7 +169,7 @@ situations where most of the file is included _except_ for a small portion. Omis To omit a segment, use the following syntax. Unlike other labels, `omit` can be used repeatedly but typos of `omit` will be treated as ordinary spliceable segments. -```markdown +```text Rendered on GitHub, absent from the site. diff --git a/docs/preprocess.py b/docs/preprocess.py index 4e50daf8..a8889e02 100644 --- a/docs/preprocess.py +++ b/docs/preprocess.py @@ -15,6 +15,7 @@ from contextlib import contextmanager from pathlib import Path from tempfile import TemporaryDirectory +from textwrap import dedent from typing import TYPE_CHECKING from common import off_disk, root_dir, spelt_as_stored @@ -99,8 +100,11 @@ def run(self, lines: list[str]) -> list[str]: # Matches a code block, and whatever trails the marker on that line. _FENCE_RE = re.compile(r"^\s*(`{3,}|~{3,})(.*)$") +# Info string of a fence holding a directive as the syntax being shown. +_LITERAL_INFO = "text" + # Matches a splice from another file, or one named section from it. -_INCLUDE_RE = re.compile(r"^\s*\s*$") +_INCLUDE_RE = re.compile(r"^(\s*)\s*$") # Matches any directive-shaped comment, by the verb and label it names. _DIRECTIVE_RE = re.compile(r"^\s*\s*$") @@ -114,6 +118,11 @@ def run(self, lines: list[str]) -> list[str]: # Matches a bound of such a segment. _OMIT_RE = re.compile(rf"^\s*\s*$") +# Matches a line holding a marker. +_MARKER_ONLY_RE = re.compile( + r"^[\s/*#<>!;%-]*\[(?:start|end):[^\]]+\][\s/*#<>!;%-]*$" +) + # Matches the target of an inline link, and any title trailing it. _LINK_RE = re.compile( r"\]\(\s*(<[^<>]*>|[^\s()]+)" @@ -123,6 +132,9 @@ def run(self, lines: list[str]) -> list[str]: # Directory holding this extension, which is the documentation root. _DOCS_ROOT = Path(__file__).resolve().parent +# Suffix of a file that is prose, and so a page rather than a quotation. +_PAGE_SUFFIX = ".md" + # Stems Zensical serves as a directory's own index, matched as spelt here. _INDEX_STEMS = frozenset({"README", "index"}) @@ -173,8 +185,14 @@ def _named_directive(line: str) -> None: class _Fences: """Running fence state over a sequence of lines.""" - def __init__(self, opener: str | None = None) -> None: + def __init__(self, opener: str | None = None, info: str = "") -> None: self.opener = opener + self.info = info + + @property + def literal(self) -> bool: + """Whether the open fence shows a directive rather than using it.""" + return self.opener is not None and self.info == _LITERAL_INFO def covers(self, line: str) -> bool: """Whether *line* is fenced, counting the fence markers themselves.""" @@ -184,6 +202,7 @@ def covers(self, line: str) -> bool: found, trailing = marker.group(1), marker.group(2) if self.opener is None: self.opener = found + self.info = trailing.strip() # A closing fence carries no info string, so a marker that does is # content the block holds rather than the end of it. elif ( @@ -192,6 +211,7 @@ def covers(self, line: str) -> bool: and not trailing.strip() ): self.opener = None + self.info = "" return True @@ -203,6 +223,16 @@ def _opens_a_fence(lines: list[str]) -> bool: return fences.opener is not None +def _quoted(lines: list[str]) -> list[str]: + """Return *lines* as code, at their own margin and without markers. + + A region may hold the bounds of another, which name a segment rather + than the code the reader is being shown. + """ + kept = (line for line in lines if not _MARKER_ONLY_RE.match(line)) + return dedent("\n".join(kept)).strip("\n").splitlines() + + def forge_url(repo_url: str, branch: str, source: Path) -> str: """Return the URL *source* is served from, by its kind.""" kind = "tree" if source.is_dir() else "blob" @@ -237,22 +267,28 @@ def _expand( output: list[str] = [] for line in lines: - # A directive inside a fence is the syntax being shown, not used. - fenced = fences.covers(line) - match = None if fenced else _INCLUDE_RE.match(line) + fences.covers(line) + # A directive a literal fence holds is the syntax being shown. + if fences.literal: + output.append(line) + continue + match = _INCLUDE_RE.match(line) if match is None: - if not fenced: - _named_directive(line) + _named_directive(line) output.append(line) continue if budget <= 0: - raise ValueError(f"{match.group(1)}: includes nested past the limit") - spliced = self._include(match.group(1), fences) - output.extend(self._expand(spliced, budget - 1, fences)) + raise ValueError(f"{match.group(2)}: includes nested past the limit") + # A directive stands at the margin of whatever holds it, so what it + # splices in has to be laid out from there and not from column zero. + margin = match.group(1) + spliced = self._include(match.group(2), fences, budget) + output.extend(margin + text if text else text for text in spliced) return output - def _include(self, spec: str, fences: _Fences) -> list[str]: + def _include(self, spec: str, fences: _Fences, budget: int) -> list[str]: + """Return the lines *spec* names, as the prose or the code they are.""" name, _, section = spec.partition(":") source = (root_dir() / name).resolve() # An absolute *name* would displace the root it is joined to, so the @@ -261,13 +297,25 @@ def _include(self, spec: str, fences: _Fences) -> list[str]: raise ValueError(f"{spec}: outside the repository") if not source.is_file(): raise ValueError(f"{spec}: no such file in the repository") + prose = source.suffix == _PAGE_SUFFIX + if not prose and fences.opener is None: + raise ValueError(f"{spec}: outside a code fence") - lines = _strip_omitted(source.read_text(encoding="utf-8").splitlines()) + lines = source.read_text(encoding="utf-8").splitlines() + if prose: + lines = _strip_omitted(lines) if section: lines = _section(lines, section, spec) + if not prose: + # Code holds no link the site can resolve and no directive it + # reads, so it stands as stored, at the margin its fence sets. + return _quoted(lines) + # `_rebase` walks these same lines, so it takes a copy of the fence # state at the splice point rather than advancing the caller's. - return self._rebase(lines, source.parent, _Fences(fences.opener)) + held = _Fences(fences.opener, fences.info) + spliced = self._rebase(lines, source.parent, held) + return self._expand(spliced, budget - 1, fences) def _rebase( self, lines: list[str], home: Path, fences: _Fences, @@ -376,6 +424,7 @@ def makeExtension(**kwargs: object) -> PreprocessorHost: """Construct the extension.""" return PreprocessorHost(**kwargs) + # Stand-in forge the tests resolve their fixtures against. _REPO = "https://forge.test/owner/repo" _BRANCH = "trunk" @@ -428,12 +477,22 @@ def test_include_splices_a_section(self) -> None: assert "above" not in out assert "below" not in out - def test_include_refuses_an_unknown_section(self) -> None: + def test_include_refuses_what_it_cannot_carry(self) -> None: import pytest with self._scratch(whole="nothing marked\n") as home: - with pytest.raises(ValueError, match="no such section"): - self._render(f'\n') + code = self._carve(home, "demo.rs", "fn main() {}\n") + cases = ( + ("/etc/hosts", "outside the repository"), + ("../../../../etc/hosts", "outside the repository"), + (f"{home}/gone.md", "no such file"), + (f"{home}/whole.md:mid", "no such section"), + # Code read as prose would be rendered as prose. + (code, "outside a code fence"), + ) + for spec, message in cases: + with pytest.raises(ValueError, match=message): + self._render(f'\n') def test_section_refuses_an_unclosed_fence(self) -> None: import pytest @@ -444,22 +503,17 @@ def test_section_refuses_an_unclosed_fence(self) -> None: with pytest.raises(ValueError, match="leaves a fence open"): self._render(f'\n') - def test_include_rejects_an_absolute_path(self) -> None: - import pytest - - with pytest.raises(ValueError, match="outside the repository"): - self._render('\n') - - def test_include_rejects_a_traversal(self) -> None: - import pytest - - with pytest.raises(ValueError, match="outside the repository"): - self._render('\n') - - def test_include_inside_a_fence_is_left_alone(self) -> None: - out = self._render('```\n\n```\n') - assert "[include:maint/unconv.toml]" in out - assert "[global]" not in out + def test_a_literal_fence_shows_the_directive_it_holds(self) -> None: + held = [ + "", + "", + "", + "", + ] + # Neither read nor refused, so a misspelt verb is text like the rest. + assert self._pointer().run(["```text", *held, "```"]) == [ + "```text", *held, "```", + ] def test_a_misspelt_directive_is_refused(self) -> None: import pytest @@ -471,13 +525,9 @@ def test_a_section_marker_is_a_known_directive(self) -> None: out = self._render("\nkept\n\n") assert "kept" in out - def test_a_misspelt_directive_in_a_fence_is_left_alone(self) -> None: - out = self._render("```\n\n```\n") - assert "[inclde:README.md]" in out - def test_include_nests(self) -> None: with self._scratch( - outer='\n', + outer='```toml\n\n```\n', ) as home: out = self._render(f'\n') assert "[include:" not in out @@ -533,21 +583,69 @@ def test_omit_applies_to_spliced_material(self) -> None: assert "carried" in out assert "nope.md" not in out - def test_titled_link_is_rebased(self) -> None: - with self._scratch(page='[a](../README.md "root")\n') as home: - out = self._render(f'\n') - assert f'href="{_REPO}/blob/{_BRANCH}/README.md"' in out - assert 'title="root"' in out - - def test_caged_link_is_rebased(self) -> None: - with self._scratch(page="[a](<../README.md>)\n") as home: - out = self._render(f'\n') - assert f'href="{_REPO}/blob/{_BRANCH}/README.md"' in out - - def test_bare_link_is_rebased(self) -> None: - with self._scratch(page="[a](../maint/unconv.toml)\n") as home: - out = self._render(f'\n') - assert f'href="{_REPO}/blob/{_BRANCH}/maint/unconv.toml"' in out + @staticmethod + def _carve(home: Path, name: str, text: str) -> str: + """Write *text* to *name* under *home* and return the spec for it.""" + (root_dir() / home / name).write_text(text, encoding="utf-8") + return f"{home}/{name}" + + def test_code_stands_in_the_fence_holding_it(self) -> None: + body = ( + "fn skipped() {}\n" + " // [start:shown]\n" + " fn shown() {\n" + " // [start:inner]\n" + " let x = 1;\n" + " // [end:inner]\n" + " }\n" + " // [end:shown]\n" + ) + def fenced(spec: str, margin: str = "") -> list[str]: + return [ + f"{margin}```rust", + f"{margin}", + f"{margin}```", + ] + + with self._scratch() as home: + spec = self._carve(home, "demo.rs", body) + whole = self._pointer().run(fenced(spec)) + region = self._pointer().run(fenced(f"{spec}:shown")) + held = self._pointer().run(fenced(f"{spec}:shown", " ")) + # A marker names a segment rather than the code being shown, so it is + # dropped wherever it falls, and a region is read at its own margin. + assert whole == [ + "```rust", + "fn skipped() {}", + " fn shown() {", + " let x = 1;", + " }", + "```", + ] + assert region == [ + "```rust", + "fn shown() {", + " let x = 1;", + "}", + "```", + ] + # A fence the page indents, such as one a content tab holds, carries + # the code it shows at that margin rather than at column zero. + assert held == [" " + line for line in region] + + def test_a_link_is_rebased_in_every_form_it_is_written(self) -> None: + blob = f"{_REPO}/blob/{_BRANCH}" + cases = ( + ('[a](../README.md "root")', + (f'href="{blob}/README.md"', 'title="root"')), + ("[a](<../README.md>)", (f'href="{blob}/README.md"',)), + ("[a](../maint/unconv.toml)", (f'href="{blob}/maint/unconv.toml"',)), + ) + for source, expected in cases: + with self._scratch(page=f"{source}\n") as home: + out = self._render(f'\n') + for fragment in expected: + assert fragment in out, source def test_page_under_docs_is_addressed_from_the_site(self) -> None: with self._scratch(page="[a](../docs/dev/guide_rust.md)\n") as home: @@ -560,12 +658,19 @@ def test_off_disk_link_is_left_alone(self) -> None: assert 'href="tel:+15551212"' in out assert 'href="irc://x/y"' in out - def test_missing_link_target_is_refused(self) -> None: + def test_a_link_naming_no_file_is_refused(self) -> None: import pytest - with self._scratch(page="[a](./nope.md)\n") as home: - with pytest.raises(ValueError, match="no such file"): - self._render(f'\n') + # A wrong-case link is refused either as missing or as misspelt, by + # the case rules of the host the tests run on. + cases = ( + ("[a](./nope.md)", "no such file"), + ("[a](../README.MD)", r"no such file|not spelt"), + ) + for source, message in cases: + with self._scratch(page=f"{source}\n") as home: + with pytest.raises(ValueError, match=message): + self._render(f'\n') @staticmethod def _pointer() -> IncludePreprocessor: @@ -590,17 +695,9 @@ def test_spelling_check_matches_the_stored_name(self) -> None: assert not spelt_as_stored(root, root / "README.MD") assert not spelt_as_stored(root, root / "Docs" / "README.md") - def test_wrong_case_link_is_refused(self) -> None: - import pytest - - # Refused either as missing or as misspelt, by the host's case rules. - with self._scratch(page="[a](../README.MD)\n") as home: - with pytest.raises(ValueError, match=r"no such file|not spelt"): - self._render(f'\n') - def test_include_survives_a_fenced_info_string(self) -> None: out = self._render( - '```\n```text\n\n```\n' + '```text\n```markdown\n\n```\n' ) assert "[include:maint/unconv.toml]" in out assert "[global]" not in out @@ -616,16 +713,16 @@ def test_site_root_link_is_left_for_postprocessing(self) -> None: assert 'href="/dev/about_docs/"' in out def test_a_fence_an_include_opens_holds_over_the_parent(self) -> None: - with self._scratch(opener="```\n", body="spliced text\n") as home: + with self._scratch(opener="```text\n", body="spliced text\n") as home: out = self._pointer().run([ f'', f'', "```", f'', ]) - # Held back while the fence the first splice opened is still open, - # then spliced once the parent's own marker closes that fence. - assert out[0] == "```" + # Held back while the literal fence the first splice opened is still + # open, then spliced once the parent's own marker closes that fence. + assert out[0] == "```text" assert out[1].startswith("