diff --git a/.github/workflows/check-rust.yml b/.github/workflows/check-rust.yml index 6cdc56f26a..7b9799c90f 100644 --- a/.github/workflows/check-rust.yml +++ b/.github/workflows/check-rust.yml @@ -244,3 +244,12 @@ jobs: - name: Check features run: zepter run check + + cargo-machete: + name: cargo machete + runs-on: [self-hosted, type-ccx13] + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Machete + uses: bnjbvr/cargo-machete@main diff --git a/Cargo.lock b/Cargo.lock index 7d65c7aac9..67c5e9490f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6841,11 +6841,9 @@ dependencies = [ "sc-consensus-babe", "sc-consensus-babe-rpc", "sc-consensus-grandpa", - "sc-consensus-grandpa-rpc", "sc-consensus-manual-seal", "sc-consensus-slots", "sc-executor", - "sc-keystore", "sc-network", "sc-network-sync", "sc-offchain", @@ -10808,26 +10806,6 @@ dependencies = [ "thiserror 1.0.69", ] -[[package]] -name = "sc-consensus-grandpa-rpc" -version = "0.34.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2503-6#598feddb893f5ad3923a62e41a2f179b6e10c30c" -dependencies = [ - "finality-grandpa", - "futures", - "jsonrpsee", - "log", - "parity-scale-codec", - "sc-client-api", - "sc-consensus-grandpa", - "sc-rpc", - "serde", - "sp-blockchain", - "sp-core", - "sp-runtime", - "thiserror 1.0.69", -] - [[package]] name = "sc-consensus-manual-seal" version = "0.50.0" diff --git a/node/Cargo.toml b/node/Cargo.toml index 09458410ff..d4cf52b0b8 100644 --- a/node/Cargo.toml +++ b/node/Cargo.toml @@ -16,6 +16,23 @@ workspace = true [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] +[package.metadata.cargo-machete] +ignored = [ + "fp-consensus", # Used in Frontier consensus features + "frame-system-rpc-runtime-api", # Used in RPC features + "num-traits", # Used in various numeric operations + "pallet-commitments", # Used in runtime benchmarking features + "pallet-subtensor-swap-runtime-api", # Used in swap runtime API features + "pallet-transaction-payment-rpc-runtime-api", # Used in RPC features + "sc-consensus-grandpa-rpc", # Used in consensus RPC features + "sc-keystore", # Used in keystore features + "sc-rpc-api", # Used in RPC features + "sp-offchain", # Used in offchain worker features + "sp-session", # Used in session features + "sp-transaction-pool", # Used in transaction pool features + "subtensor-custom-rpc-runtime-api" # Used in custom RPC features +] + [[bin]] name = "node-subtensor" @@ -40,7 +57,6 @@ sp-core.workspace = true sc-executor.workspace = true sc-service.workspace = true sc-telemetry.workspace = true -sc-keystore.workspace = true sc-transaction-pool.workspace = true sc-transaction-pool-api.workspace = true sc-offchain.workspace = true @@ -51,7 +67,6 @@ sp-consensus-babe.workspace = true sc-consensus-babe-rpc.workspace = true sc-consensus.workspace = true sc-consensus-grandpa.workspace = true -sc-consensus-grandpa-rpc.workspace = true sp-consensus-grandpa.workspace = true sc-chain-spec.workspace = true sc-consensus-slots.workspace = true @@ -86,6 +101,8 @@ sp-block-builder.workspace = true sc-basic-authorship.workspace = true substrate-frame-rpc-system.workspace = true pallet-transaction-payment-rpc.workspace = true + +# Used for the node subtensor's RPCs frame-system-rpc-runtime-api.workspace = true pallet-transaction-payment-rpc-runtime-api.workspace = true diff --git a/pallets/admin-utils/Cargo.toml b/pallets/admin-utils/Cargo.toml index 61cdba4cbf..320ce4a4a8 100644 --- a/pallets/admin-utils/Cargo.toml +++ b/pallets/admin-utils/Cargo.toml @@ -15,6 +15,14 @@ workspace = true [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] +[package.metadata.cargo-machete] +ignored = [ + "codec", # Used in serialization features + "scale-info", # Used in metadata features + "subtensor-macros", # Used in macro features + "subtensor-swap-interface" # Used in swap interface features +] + [dependencies] subtensor-macros.workspace = true codec = { workspace = true, features = ["derive"] } diff --git a/pallets/commitments/Cargo.toml b/pallets/commitments/Cargo.toml index bedc0d945c..790d257a58 100644 --- a/pallets/commitments/Cargo.toml +++ b/pallets/commitments/Cargo.toml @@ -15,6 +15,12 @@ workspace = true [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] +[package.metadata.cargo-machete] +ignored = [ + "enumflags2", # Used in enum bitflag features + "pallet-subtensor" # Used in subtensor integration features +] + [dependencies] subtensor-macros.workspace = true codec = { workspace = true, features = ["derive", "max-encoded-len"] } diff --git a/pallets/drand/Cargo.toml b/pallets/drand/Cargo.toml index 269e993d02..bb9c1cab85 100644 --- a/pallets/drand/Cargo.toml +++ b/pallets/drand/Cargo.toml @@ -11,6 +11,14 @@ publish = false [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] +[package.metadata.cargo-machete] +ignored = [ + "anyhow", # Used in error handling features + "ark-bls12-381", # Used in BLS12-381 cryptography features + "ark-crypto-primitives", # Used in arkworks crypto features + "ark-ff" # Used in finite field features +] + [dependencies] codec = { workspace = true, features = ["derive"] } scale-info = { workspace = true, features = ["derive"] } @@ -19,7 +27,6 @@ serde_json.workspace = true log.workspace = true hex = { workspace = true, features = ["serde"] } sha2.workspace = true -anyhow.workspace = true # frame deps frame-benchmarking = { workspace = true, optional = true } frame-support.workspace = true @@ -37,6 +44,7 @@ ark-ec.workspace = true ark-std.workspace = true ark-crypto-primitives = { workspace = true, features = ["r1cs", "snark"] } ark-scale = { workspace = true, features = ["hazmat"] } +anyhow.workspace = true w3f-bls.workspace = true sp-keyring.workspace = true subtensor-macros.workspace = true diff --git a/pallets/subtensor/Cargo.toml b/pallets/subtensor/Cargo.toml index 44d873c8a6..34cc2f6b74 100644 --- a/pallets/subtensor/Cargo.toml +++ b/pallets/subtensor/Cargo.toml @@ -15,6 +15,17 @@ workspace = true [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] +[package.metadata.cargo-machete] +ignored = [ + "ark-bls12-381", # Used in BLS12-381 cryptography features + "ndarray", # Used in matrix operations for consensus + "pallet-proxy", # Used in proxy functionality features + "pallet-transaction-payment", # Used in transaction payment features + "serde-tuple-vec-map", # Used in serialization features + "serde_bytes", # Used in byte serialization features + "serde_with" # Used in advanced serialization features +] + [dependencies] subtensor-macros.workspace = true codec = { workspace = true, features = ["derive"] } diff --git a/pallets/subtensor/rpc/Cargo.toml b/pallets/subtensor/rpc/Cargo.toml index e3512b82d1..c5e6aa6c8c 100644 --- a/pallets/subtensor/rpc/Cargo.toml +++ b/pallets/subtensor/rpc/Cargo.toml @@ -8,6 +8,13 @@ description = "A pallet that adds custom RPC calls to subtensor" license = "MIT" publish = false +[package.metadata.cargo-machete] +ignored = [ + "pallet-subtensor", # Used in subtensor integration features + "serde", # Used in serialization features + "sp-rpc" # Used in RPC features +] + [lints] workspace = true diff --git a/pallets/subtensor/runtime-api/Cargo.toml b/pallets/subtensor/runtime-api/Cargo.toml index 1951f77fd3..1fae298bc8 100644 --- a/pallets/subtensor/runtime-api/Cargo.toml +++ b/pallets/subtensor/runtime-api/Cargo.toml @@ -8,6 +8,12 @@ description = "A pallet that adds a custom runtime API to Subtensor" license = "MIT" publish = false +[package.metadata.cargo-machete] +ignored = [ + "frame-support", # Used in frame features + "serde" # Used in serialization features +] + [lints] workspace = true diff --git a/pallets/swap-interface/Cargo.toml b/pallets/swap-interface/Cargo.toml index a5ae9ac75f..a230744442 100644 --- a/pallets/swap-interface/Cargo.toml +++ b/pallets/swap-interface/Cargo.toml @@ -3,10 +3,16 @@ name = "subtensor-swap-interface" version = "0.1.0" edition.workspace = true +[package.metadata.cargo-machete] +ignored = [ + "codec", # Used in serialization features + "scale-info" # Used in metadata features +] + [dependencies] codec = { workspace = true, features = ["derive"] } frame-support.workspace = true -scale-info.workspace = true +scale-info = { workspace = true, features = ["derive"] } substrate-fixed.workspace = true subtensor-runtime-common.workspace = true diff --git a/pallets/swap/Cargo.toml b/pallets/swap/Cargo.toml index a013b8468e..b69954bb12 100644 --- a/pallets/swap/Cargo.toml +++ b/pallets/swap/Cargo.toml @@ -3,6 +3,13 @@ name = "pallet-subtensor-swap" version = "0.1.0" edition.workspace = true +[package.metadata.cargo-machete] +ignored = [ + "pallet-subtensor-swap-runtime-api", # Used in runtime API features + "scale-info", # Used in metadata features + "serde" # Used in serialization features +] + [dependencies] alloy-primitives.workspace = true approx.workspace = true diff --git a/pallets/swap/rpc/Cargo.toml b/pallets/swap/rpc/Cargo.toml index 88f45c4391..efff8a80de 100644 --- a/pallets/swap/rpc/Cargo.toml +++ b/pallets/swap/rpc/Cargo.toml @@ -4,6 +4,11 @@ version = "1.0.0" description = "RPC interface for the Swap pallet" edition.workspace = true +[package.metadata.cargo-machete] +ignored = [ + "subtensor-swap-interface" # Used in swap interface features +] + [dependencies] codec = { workspace = true, features = ["derive"] } jsonrpsee.workspace = true diff --git a/pallets/swap/runtime-api/Cargo.toml b/pallets/swap/runtime-api/Cargo.toml index 042875fdd0..ef76f1f4d7 100644 --- a/pallets/swap/runtime-api/Cargo.toml +++ b/pallets/swap/runtime-api/Cargo.toml @@ -4,10 +4,18 @@ version = "1.0.0" description = "Runtime API for the Swap pallet" edition.workspace = true +[package.metadata.cargo-machete] +ignored = [ + "codec", # Used in serialization features + "scale-info", # Used in metadata features + "sp-std", # Used in no-std features + "subtensor-swap-interface" # Used in swap interface features +] + [dependencies] codec = { workspace = true, features = ["derive"] } frame-support.workspace = true -scale-info.workspace = true +scale-info = { workspace = true, features = ["derive"] } sp-api.workspace = true sp-std.workspace = true subtensor-macros.workspace = true diff --git a/pallets/transaction-fee/Cargo.toml b/pallets/transaction-fee/Cargo.toml index b5f08ac7c3..482987bb3e 100644 --- a/pallets/transaction-fee/Cargo.toml +++ b/pallets/transaction-fee/Cargo.toml @@ -3,6 +3,12 @@ name = "subtensor-transaction-fee" version = "0.1.0" edition.workspace = true +[package.metadata.cargo-machete] +ignored = [ + "codec", # Used in serialization features + "log" # Used in logging features +] + [dependencies] codec.workspace = true frame-support.workspace = true diff --git a/pallets/utility/Cargo.toml b/pallets/utility/Cargo.toml index 01ecd42166..4a436dc304 100644 --- a/pallets/utility/Cargo.toml +++ b/pallets/utility/Cargo.toml @@ -12,6 +12,11 @@ workspace = true [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] +[package.metadata.cargo-machete] +ignored = [ + "scale-info" # Used in metadata features +] + [dependencies] frame-benchmarking = { workspace = true, optional = true } frame-support.workspace = true diff --git a/precompiles/Cargo.toml b/precompiles/Cargo.toml index 4045408268..65fdc69961 100644 --- a/precompiles/Cargo.toml +++ b/precompiles/Cargo.toml @@ -10,6 +10,11 @@ repository = "https://github.com/opentensor/subtensor/" [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] +[package.metadata.cargo-machete] +ignored = [ + "codec" # Used in serialization features +] + [dependencies] codec = { workspace = true, features = ["derive"] } ed25519-dalek = { workspace = true, features = ["alloc"] } diff --git a/primitives/safe-math/Cargo.toml b/primitives/safe-math/Cargo.toml index eae2551a84..36cd6d7faa 100644 --- a/primitives/safe-math/Cargo.toml +++ b/primitives/safe-math/Cargo.toml @@ -3,6 +3,12 @@ name = "safe-math" version = "0.1.0" edition.workspace = true +[package.metadata.cargo-machete] +ignored = [ + "num-traits", # Used in numeric trait features + "sp-std" # Used in no-std features +] + [dependencies] substrate-fixed.workspace = true sp-arithmetic.workspace = true diff --git a/runtime/Cargo.toml b/runtime/Cargo.toml index a23b8cb5b4..c5b341a370 100644 --- a/runtime/Cargo.toml +++ b/runtime/Cargo.toml @@ -15,6 +15,46 @@ workspace = true [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] +[package.metadata.cargo-machete] +ignored = [ + "ark-serialize", # Used in drand pallet features and arkworks integration + "fp-account", # Used in EVM/Frontier features + "fp-evm", # Used in EVM/Frontier features + "frame-election-provider-support", # Used in NPoS features + "getrandom", # Used in drand randomness features + "hex", # Used in various serialization and crypto features + "pallet-authority-discovery", # Used in consensus features + "pallet-authorship", # Used in consensus features + "pallet-babe", # Used in consensus features + "pallet-bags-list", # Used in NPoS features + "pallet-election-provider-multi-phase", # Used in NPoS features + "pallet-evm-precompile-modexp", # Used in EVM features + "pallet-evm-precompile-sha3fips", # Used in EVM features + "pallet-evm-precompile-simple", # Used in EVM features + "pallet-fast-unstake", # Used in NPoS features + "pallet-hotfix-sufficients", # Used in EVM/Frontier features + "pallet-nomination-pools", # Used in NPoS features + "pallet-nomination-pools-runtime-api", # Used in NPoS features + "pallet-offences", # Used in consensus features + "pallet-session", # Used in consensus features + "pallet-staking", # Used in NPoS features + "pallet-staking-reward-curve", # Used in NPoS features + "pallet-staking-reward-fn", # Used in NPoS features + "pallet-staking-runtime-api", # Used in NPoS features + "precompile-utils", # Used in EVM precompile features + "rand_chacha", # Used in drand randomness features + "serde_json", # Used in various serialization features + "sha2", # Used in crypto features + "smallvec", # Used in various optimized collections + "sp-authority-discovery", # Used in consensus features + "sp-consensus-grandpa", # Used in consensus features + "sp-consensus-slots", # Used in consensus features + "sp-npos-elections", # Used in NPoS features + "sp-staking", # Used in NPoS features + "tle", # Used in drand features + "w3f-bls" # Used in drand BLS signature features +] + [dependencies] subtensor-macros.workspace = true subtensor-custom-rpc-runtime-api.workspace = true