From e9aea6d2386b95456f40971477b3ca0b9225c088 Mon Sep 17 00:00:00 2001 From: Liam Date: Tue, 16 Apr 2024 10:02:18 +0400 Subject: [PATCH 1/3] fix: propagate features --- Cargo.lock | 9 ++++++ node/Cargo.toml | 8 +++++ pallets/admin-utils/Cargo.toml | 22 +++++++++++-- pallets/collective/Cargo.toml | 6 +++- pallets/commitments/Cargo.toml | 10 +++++- pallets/registry/Cargo.toml | 8 ++++- pallets/subtensor/Cargo.toml | 38 ++++++++++++++++++++-- pallets/subtensor/rpc/Cargo.toml | 9 +++++- pallets/subtensor/runtime-api/Cargo.toml | 7 ++++- runtime/Cargo.toml | 10 ++++++ zepter.yaml | 40 ++++++++++++++++++++++++ 11 files changed, 158 insertions(+), 9 deletions(-) create mode 100644 zepter.yaml diff --git a/Cargo.lock b/Cargo.lock index 081d27187..f0b634768 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -743,6 +743,7 @@ dependencies = [ "iana-time-zone", "js-sys", "num-traits", + "serde", "wasm-bindgen", "windows-targets 0.52.4", ] @@ -1326,6 +1327,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4" dependencies = [ "powerfmt", + "serde", ] [[package]] @@ -7152,8 +7154,14 @@ version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "89df7a26519371a3cce44fbb914c2819c84d9b897890987fa3ab096491cc0ea8" dependencies = [ + "base64 0.13.1", + "chrono", + "hex", + "indexmap 1.9.3", "serde", + "serde_json", "serde_with_macros", + "time", ] [[package]] @@ -8180,6 +8188,7 @@ source = "git+https://github.com/encointer/substrate-fixed.git?tag=v0.5.9#a4fb46 dependencies = [ "parity-scale-codec", "scale-info", + "serde", "typenum 1.16.0", ] diff --git a/node/Cargo.toml b/node/Cargo.toml index aa76411b7..d02eab74a 100644 --- a/node/Cargo.toml +++ b/node/Cargo.toml @@ -85,6 +85,10 @@ runtime-benchmarks = [ "node-subtensor-runtime/runtime-benchmarks", "frame-benchmarking/runtime-benchmarks", "frame-benchmarking-cli/runtime-benchmarks", + "frame-system/runtime-benchmarks", + "sc-service/runtime-benchmarks", + "sp-runtime/runtime-benchmarks", + "pallet-commitments/runtime-benchmarks" ] pow-faucet = [] @@ -93,4 +97,8 @@ pow-faucet = [] try-runtime = [ "node-subtensor-runtime/try-runtime", "try-runtime-cli/try-runtime", + "frame-system/try-runtime", + "pallet-transaction-payment/try-runtime", + "sp-runtime/try-runtime", + "pallet-commitments/try-runtime" ] diff --git a/pallets/admin-utils/Cargo.toml b/pallets/admin-utils/Cargo.toml index 49f97a275..d9ff8647a 100644 --- a/pallets/admin-utils/Cargo.toml +++ b/pallets/admin-utils/Cargo.toml @@ -48,6 +48,24 @@ std = [ "scale-info/std", "pallet-subtensor/std", "sp-consensus-aura/std", + "pallet-balances/std", + "sp-runtime/std", + "sp-tracing/std", + "sp-weights/std", + "log/std" +] +runtime-benchmarks = [ + "frame-benchmarking/runtime-benchmarks", + "frame-support/runtime-benchmarks", + "frame-system/runtime-benchmarks", + "pallet-balances/runtime-benchmarks", + "sp-runtime/runtime-benchmarks", + "pallet-subtensor/runtime-benchmarks" +] +try-runtime = [ + "frame-support/try-runtime", + "frame-system/try-runtime", + "pallet-balances/try-runtime", + "sp-runtime/try-runtime", + "pallet-subtensor/try-runtime" ] -runtime-benchmarks = ["frame-benchmarking/runtime-benchmarks"] -try-runtime = ["frame-support/try-runtime"] diff --git a/pallets/collective/Cargo.toml b/pallets/collective/Cargo.toml index 89497dda2..0f7eb33f8 100644 --- a/pallets/collective/Cargo.toml +++ b/pallets/collective/Cargo.toml @@ -48,4 +48,8 @@ runtime-benchmarks = [ "frame-system/runtime-benchmarks", "sp-runtime/runtime-benchmarks", ] -try-runtime = ["frame-support/try-runtime"] +try-runtime = [ + "frame-support/try-runtime", + "frame-system/try-runtime", + "sp-runtime/try-runtime" +] diff --git a/pallets/commitments/Cargo.toml b/pallets/commitments/Cargo.toml index f83a630f9..db6bad359 100644 --- a/pallets/commitments/Cargo.toml +++ b/pallets/commitments/Cargo.toml @@ -43,11 +43,19 @@ std = [ "frame-system/std", "scale-info/std", "sp-std/std", + "sp-runtime/std", + "enumflags2/std" ] runtime-benchmarks = [ "frame-benchmarking/runtime-benchmarks", "frame-support/runtime-benchmarks", "frame-system/runtime-benchmarks", "sp-runtime/runtime-benchmarks", + "pallet-balances/runtime-benchmarks" +] +try-runtime = [ + "frame-support/try-runtime", + "frame-system/try-runtime", + "pallet-balances/try-runtime", + "sp-runtime/try-runtime" ] -try-runtime = ["frame-support/try-runtime"] diff --git a/pallets/registry/Cargo.toml b/pallets/registry/Cargo.toml index 4d903e4cd..4e0c0bade 100644 --- a/pallets/registry/Cargo.toml +++ b/pallets/registry/Cargo.toml @@ -42,6 +42,8 @@ std = [ "frame-system/std", "scale-info/std", "sp-std/std", + "sp-runtime/std", + "enumflags2/std" ] runtime-benchmarks = [ "frame-benchmarking/runtime-benchmarks", @@ -49,4 +51,8 @@ runtime-benchmarks = [ "frame-system/runtime-benchmarks", "sp-runtime/runtime-benchmarks", ] -try-runtime = ["frame-support/try-runtime"] +try-runtime = [ + "frame-support/try-runtime", + "frame-system/try-runtime", + "sp-runtime/try-runtime" +] diff --git a/pallets/subtensor/Cargo.toml b/pallets/subtensor/Cargo.toml index 122bb728a..069f179ac 100644 --- a/pallets/subtensor/Cargo.toml +++ b/pallets/subtensor/Cargo.toml @@ -68,7 +68,41 @@ std = [ "scale-info/std", "pallet-collective/std", "pallet-membership/std", + "substrate-fixed/std", + "pallet-balances/std", + "pallet-transaction-payment/std", + "pallet-utility/std", + "sp-core/std", + "sp-io/std", + "sp-runtime/std", + "sp-std/std", + "sp-tracing/std", + "sp-version/std", + "hex/std", + "log/std", + "ndarray/std", + "serde/std", + "serde_bytes/std", + "serde_with/std" +] +runtime-benchmarks = [ + "frame-benchmarking/runtime-benchmarks", + "frame-support/runtime-benchmarks", + "frame-system/runtime-benchmarks", + "pallet-balances/runtime-benchmarks", + "pallet-membership/runtime-benchmarks", + "pallet-utility/runtime-benchmarks", + "sp-runtime/runtime-benchmarks", + "pallet-collective/runtime-benchmarks" +] +try-runtime = [ + "frame-support/try-runtime", + "frame-system/try-runtime", + "pallet-balances/try-runtime", + "pallet-membership/try-runtime", + "pallet-transaction-payment/try-runtime", + "pallet-utility/try-runtime", + "sp-runtime/try-runtime", + "pallet-collective/try-runtime" ] -runtime-benchmarks = ["frame-benchmarking/runtime-benchmarks"] -try-runtime = ["frame-support/try-runtime"] pow-faucet = [] diff --git a/pallets/subtensor/rpc/Cargo.toml b/pallets/subtensor/rpc/Cargo.toml index 28d5cbeda..f9a95c851 100644 --- a/pallets/subtensor/rpc/Cargo.toml +++ b/pallets/subtensor/rpc/Cargo.toml @@ -32,5 +32,12 @@ pallet-subtensor = { version = "4.0.0-dev", path = "../../subtensor", default-fe [features] default = ["std"] -std = ["sp-api/std", "sp-runtime/std", "subtensor-custom-rpc-runtime-api/std"] +std = [ + "sp-api/std", + "sp-runtime/std", + "subtensor-custom-rpc-runtime-api/std", + "pallet-subtensor/std", + "codec/std", + "serde/std" +] pow-faucet = [] diff --git a/pallets/subtensor/runtime-api/Cargo.toml b/pallets/subtensor/runtime-api/Cargo.toml index 0131f7988..8193d504b 100644 --- a/pallets/subtensor/runtime-api/Cargo.toml +++ b/pallets/subtensor/runtime-api/Cargo.toml @@ -18,5 +18,10 @@ pallet-subtensor = { version = "4.0.0-dev", path = "../../subtensor", default-fe [features] default = ["std"] -std = ["sp-api/std"] +std = [ + "sp-api/std", + "frame-support/std", + "pallet-subtensor/std", + "serde/std" +] pow-faucet = [] diff --git a/runtime/Cargo.toml b/runtime/Cargo.toml index cad2e98d9..90eebec59 100644 --- a/runtime/Cargo.toml +++ b/runtime/Cargo.toml @@ -125,6 +125,8 @@ std = [ "pallet-membership/std", "pallet-registry/std", "pallet-admin-utils/std", + "subtensor-custom-rpc-runtime-api/std", + "serde_json/std" ] runtime-benchmarks = [ "frame-benchmarking/runtime-benchmarks", @@ -142,6 +144,10 @@ runtime-benchmarks = [ "pallet-registry/runtime-benchmarks", "pallet-commitments/runtime-benchmarks", "pallet-admin-utils/runtime-benchmarks", + "pallet-multisig/runtime-benchmarks", + "pallet-preimage/runtime-benchmarks", + "pallet-scheduler/runtime-benchmarks", + "pallet-sudo/runtime-benchmarks" ] try-runtime = [ "frame-try-runtime/try-runtime", @@ -162,4 +168,8 @@ try-runtime = [ "pallet-multisig/try-runtime", "pallet-scheduler/try-runtime", "pallet-preimage/try-runtime", + "sp-runtime/try-runtime", + "pallet-admin-utils/try-runtime", + "pallet-commitments/try-runtime", + "pallet-registry/try-runtime" ] diff --git a/zepter.yaml b/zepter.yaml new file mode 100644 index 000000000..db1f33097 --- /dev/null +++ b/zepter.yaml @@ -0,0 +1,40 @@ +version: + format: 1 + # Minimum version of the binary that is expected to work. This is just for printing a nice error + # message when someone tries to use an older version. + binary: 0.13.2 + +# The examples in this file assume crate `A` to have a dependency on crate `B`. +workflows: + check: + - [ + "lint", + # Check that `A` activates the features of `B`. + "propagate-feature", + # These are the features to check: + "--features=try-runtime,runtime-benchmarks,std", + # Do not try to add a new section into `[features]` of `A` only because `B` expose that feature. There are edge-cases where this is still needed, but we can add them manually. + "--left-side-feature-missing=ignore", + # Ignore the case that `A` it outside of the workspace. Otherwise it will report errors in external dependencies that we have no influence on. + "--left-side-outside-workspace=ignore", + # Some features imply that they activate a specific dependency as non-optional. Otherwise the default behaviour with a `?` is used. + "--feature-enables-dep=try-runtime:frame-try-runtime,runtime-benchmarks:frame-benchmarking", + # Auxillary flags: + "--offline", + "--locked", + "--show-path", + "--quiet", + ] + # Same as `check`, but with the `--fix` flag. + default: + - [$check.0, "--fix"] + +# Will be displayed when any workflow fails: +help: + text: | + Polkadot-SDK uses the Zepter CLI to detect abnormalities in the feature configuration. + It looks like one more more checks failed; please check the console output. You can try to automatically address them by running `zepter`. + Otherwise please ask directly in the Merge Request, GitHub Discussions or on Matrix Chat, thank you. + links: + - "https://github.com/paritytech/polkadot-sdk/issues/1831" + - "https://github.com/ggwpez/zepter" From f5d9d53bcd567c154d0458b4ae9d48e81e9abfdf Mon Sep 17 00:00:00 2001 From: Liam Date: Tue, 16 Apr 2024 10:19:07 +0400 Subject: [PATCH 2/3] feat: feature prop ci check --- .github/workflows/check-rust.yml | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/.github/workflows/check-rust.yml b/.github/workflows/check-rust.yml index 599f14589..c81e2c30f 100644 --- a/.github/workflows/check-rust.yml +++ b/.github/workflows/check-rust.yml @@ -4,7 +4,6 @@ concurrency: group: ci-${{ github.ref }} cancel-in-progress: true - on: ## Run automatically for all PRs against main, regardless of what the changes are ## to be safe and so we can more easily force re-run the CI when github is being @@ -270,8 +269,8 @@ jobs: cargo clippy -- -D clippy::panic \ -D clippy::todo \ -D clippy::unimplemented -# -D clippy::indexing_slicing \ -# -D clippy::unwrap_used \ + # -D clippy::indexing_slicing \ + # -D clippy::unwrap_used \ # ensures cargo fix has no trivial changes that can be applied cargo-fix: @@ -331,3 +330,25 @@ jobs: else echo "No changes detected after running 'cargo fix --workspace' ✅" fi + + check-feature-propagation: + name: Check Cargo feature propatation with zepter + runs-on: ubuntu-22.04 + + steps: + - name: Install stable Rust + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + + - name: Install Zepter + run: cargo install --locked -q zepter && zepter --version + + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 # Dont clone historic commits. + + - name: Check features + run: zepter run check From 61f9268bb194d84cad2a440eed9be07f41f0058b Mon Sep 17 00:00:00 2001 From: Liam Date: Tue, 16 Apr 2024 10:21:33 +0400 Subject: [PATCH 3/3] fix: ci job name --- .github/workflows/check-rust.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/check-rust.yml b/.github/workflows/check-rust.yml index c81e2c30f..61178b20a 100644 --- a/.github/workflows/check-rust.yml +++ b/.github/workflows/check-rust.yml @@ -332,7 +332,7 @@ jobs: fi check-feature-propagation: - name: Check Cargo feature propatation with zepter + name: zepter run check runs-on: ubuntu-22.04 steps: