diff --git a/.github/workflows/check-bittensor-e2e-tests.yml.yml b/.github/workflows/check-bittensor-e2e-tests.yml.yml index fcaaf9ff0f..aaec7df656 100644 --- a/.github/workflows/check-bittensor-e2e-tests.yml.yml +++ b/.github/workflows/check-bittensor-e2e-tests.yml.yml @@ -109,7 +109,7 @@ jobs: repository: ${{ github.event.pull_request.head.repo.full_name }} ref: ${{ github.event.pull_request.head.ref }} - - name: Patch non-fast-block node + - name: Patch non-fast-runtime node run: | chmod +x ./scripts/localnet_patch.sh ./scripts/localnet_patch.sh diff --git a/Cargo.lock b/Cargo.lock index be72efe82b..e523ea8b50 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -972,11 +972,11 @@ dependencies = [ [[package]] name = "async-lock" -version = "3.4.0" +version = "3.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff6e472cdea888a4bd64f342f09b3f50e1886d32afe8df3d663c01140b811b18" +checksum = "5fd03604047cee9b6ce9de9f70c6cd540a0520c813cbd49bae61f33ab80ed1dc" dependencies = [ - "event-listener 5.4.0", + "event-listener 5.4.1", "event-listener-strategy", "pin-project-lite", ] @@ -1005,7 +1005,7 @@ dependencies = [ "async-task", "blocking", "cfg-if", - "event-listener 5.4.0", + "event-listener 5.4.1", "futures-lite", "rustix 1.0.8", ] @@ -1544,9 +1544,9 @@ checksum = "fd6c0e7b807d60291f42f33f58480c0bfafe28ed08286446f45e463728cf9c1c" [[package]] name = "cc" -version = "1.2.30" +version = "1.2.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "deec109607ca693028562ed836a5f1c4b8bd77755c4e132fc5ce11b0b6211ae7" +checksum = "c3a42d84bb6b69d3a8b3eaacf0d88f179e1929695e1ad012b6cf64d9caaa5fd2" dependencies = [ "jobserver", "libc", @@ -2923,6 +2923,17 @@ dependencies = [ "syn 2.0.104", ] +[[package]] +name = "enumn" +version = "0.1.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f9ed6b3789237c8a0c1c505af1c7eb2c560df6186f01b098c3a1064ea532f38" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.104", +] + [[package]] name = "env_logger" version = "0.10.2" @@ -3041,9 +3052,9 @@ checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" [[package]] name = "event-listener" -version = "5.4.0" +version = "5.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3492acde4c3fc54c845eaab3eed8bd00c7a7d881f78bfc801e43a93dec1331ae" +checksum = "e13b66accf52311f30a0db42147dadea9850cb48cd070028831ae5f5d4b856ab" dependencies = [ "concurrent-queue", "parking", @@ -3056,14 +3067,14 @@ version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8be9f3dfaaffdae2972880079a491a1a8bb7cbed0b8dd7a347f668b4150a3b93" dependencies = [ - "event-listener 5.4.0", + "event-listener 5.4.1", "pin-project-lite", ] [[package]] name = "evm" version = "0.42.0" -source = "git+https://github.com/rust-ethereum/evm?branch=v0.x#6ca5a72bc8942f4860137155dd9033526fd362a5" +source = "git+https://github.com/rust-ethereum/evm?rev=6ca5a72bc8942f4860137155dd9033526fd362a5#6ca5a72bc8942f4860137155dd9033526fd362a5" dependencies = [ "auto_impl", "environmental", @@ -3083,7 +3094,7 @@ dependencies = [ [[package]] name = "evm-core" version = "0.42.0" -source = "git+https://github.com/rust-ethereum/evm?branch=v0.x#6ca5a72bc8942f4860137155dd9033526fd362a5" +source = "git+https://github.com/rust-ethereum/evm?rev=6ca5a72bc8942f4860137155dd9033526fd362a5#6ca5a72bc8942f4860137155dd9033526fd362a5" dependencies = [ "parity-scale-codec", "primitive-types 0.13.1", @@ -3094,7 +3105,7 @@ dependencies = [ [[package]] name = "evm-gasometer" version = "0.42.0" -source = "git+https://github.com/rust-ethereum/evm?branch=v0.x#6ca5a72bc8942f4860137155dd9033526fd362a5" +source = "git+https://github.com/rust-ethereum/evm?rev=6ca5a72bc8942f4860137155dd9033526fd362a5#6ca5a72bc8942f4860137155dd9033526fd362a5" dependencies = [ "environmental", "evm-core", @@ -3105,7 +3116,7 @@ dependencies = [ [[package]] name = "evm-runtime" version = "0.42.0" -source = "git+https://github.com/rust-ethereum/evm?branch=v0.x#6ca5a72bc8942f4860137155dd9033526fd362a5" +source = "git+https://github.com/rust-ethereum/evm?rev=6ca5a72bc8942f4860137155dd9033526fd362a5#6ca5a72bc8942f4860137155dd9033526fd362a5" dependencies = [ "auto_impl", "environmental", @@ -3205,7 +3216,7 @@ dependencies = [ [[package]] name = "fc-api" version = "1.0.0-dev" -source = "git+https://github.com/opentensor/frontier?rev=c591df98c524e1599c45f93cf4685248088ac014#c591df98c524e1599c45f93cf4685248088ac014" +source = "git+https://github.com/opentensor/frontier?rev=830e61f370d88f7ace1c5a5659dd58db75a19844#830e61f370d88f7ace1c5a5659dd58db75a19844" dependencies = [ "async-trait", "fp-storage", @@ -3217,7 +3228,7 @@ dependencies = [ [[package]] name = "fc-aura" version = "1.0.0-dev" -source = "git+https://github.com/opentensor/frontier?rev=c591df98c524e1599c45f93cf4685248088ac014#c591df98c524e1599c45f93cf4685248088ac014" +source = "git+https://github.com/opentensor/frontier?rev=830e61f370d88f7ace1c5a5659dd58db75a19844#830e61f370d88f7ace1c5a5659dd58db75a19844" dependencies = [ "fc-rpc", "fp-storage", @@ -3230,10 +3241,26 @@ dependencies = [ "sp-timestamp", ] +[[package]] +name = "fc-babe" +version = "1.0.0-dev" +source = "git+https://github.com/opentensor/frontier?rev=830e61f370d88f7ace1c5a5659dd58db75a19844#830e61f370d88f7ace1c5a5659dd58db75a19844" +dependencies = [ + "fc-rpc", + "sc-client-api", + "sc-consensus-babe", + "sp-api", + "sp-blockchain", + "sp-consensus-babe", + "sp-inherents", + "sp-runtime", + "sp-timestamp", +] + [[package]] name = "fc-consensus" version = "2.0.0-dev" -source = "git+https://github.com/opentensor/frontier?rev=c591df98c524e1599c45f93cf4685248088ac014#c591df98c524e1599c45f93cf4685248088ac014" +source = "git+https://github.com/opentensor/frontier?rev=830e61f370d88f7ace1c5a5659dd58db75a19844#830e61f370d88f7ace1c5a5659dd58db75a19844" dependencies = [ "async-trait", "fp-consensus", @@ -3249,7 +3276,7 @@ dependencies = [ [[package]] name = "fc-db" version = "2.0.0-dev" -source = "git+https://github.com/opentensor/frontier?rev=c591df98c524e1599c45f93cf4685248088ac014#c591df98c524e1599c45f93cf4685248088ac014" +source = "git+https://github.com/opentensor/frontier?rev=830e61f370d88f7ace1c5a5659dd58db75a19844#830e61f370d88f7ace1c5a5659dd58db75a19844" dependencies = [ "async-trait", "ethereum", @@ -3279,7 +3306,7 @@ dependencies = [ [[package]] name = "fc-mapping-sync" version = "2.0.0-dev" -source = "git+https://github.com/opentensor/frontier?rev=c591df98c524e1599c45f93cf4685248088ac014#c591df98c524e1599c45f93cf4685248088ac014" +source = "git+https://github.com/opentensor/frontier?rev=830e61f370d88f7ace1c5a5659dd58db75a19844#830e61f370d88f7ace1c5a5659dd58db75a19844" dependencies = [ "fc-db", "fc-storage", @@ -3302,7 +3329,7 @@ dependencies = [ [[package]] name = "fc-rpc" version = "2.0.0-dev" -source = "git+https://github.com/opentensor/frontier?rev=c591df98c524e1599c45f93cf4685248088ac014#c591df98c524e1599c45f93cf4685248088ac014" +source = "git+https://github.com/opentensor/frontier?rev=830e61f370d88f7ace1c5a5659dd58db75a19844#830e61f370d88f7ace1c5a5659dd58db75a19844" dependencies = [ "ethereum", "ethereum-types 0.15.1", @@ -3353,7 +3380,7 @@ dependencies = [ [[package]] name = "fc-rpc-core" version = "1.1.0-dev" -source = "git+https://github.com/opentensor/frontier?rev=c591df98c524e1599c45f93cf4685248088ac014#c591df98c524e1599c45f93cf4685248088ac014" +source = "git+https://github.com/opentensor/frontier?rev=830e61f370d88f7ace1c5a5659dd58db75a19844#830e61f370d88f7ace1c5a5659dd58db75a19844" dependencies = [ "ethereum", "ethereum-types 0.15.1", @@ -3368,7 +3395,7 @@ dependencies = [ [[package]] name = "fc-storage" version = "1.0.0-dev" -source = "git+https://github.com/opentensor/frontier?rev=c591df98c524e1599c45f93cf4685248088ac014#c591df98c524e1599c45f93cf4685248088ac014" +source = "git+https://github.com/opentensor/frontier?rev=830e61f370d88f7ace1c5a5659dd58db75a19844#830e61f370d88f7ace1c5a5659dd58db75a19844" dependencies = [ "ethereum", "ethereum-types 0.15.1", @@ -3474,6 +3501,12 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" +[[package]] +name = "fixedbitset" +version = "0.5.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d674e81391d1e1ab681a28d99df07927c6d4aa5b027d7da16ba32d1d21ecd99" + [[package]] name = "flume" version = "0.11.1" @@ -3542,7 +3575,7 @@ dependencies = [ [[package]] name = "fp-account" version = "1.0.0-dev" -source = "git+https://github.com/opentensor/frontier?rev=c591df98c524e1599c45f93cf4685248088ac014#c591df98c524e1599c45f93cf4685248088ac014" +source = "git+https://github.com/opentensor/frontier?rev=830e61f370d88f7ace1c5a5659dd58db75a19844#830e61f370d88f7ace1c5a5659dd58db75a19844" dependencies = [ "hex", "impl-serde 0.5.0", @@ -3561,7 +3594,7 @@ dependencies = [ [[package]] name = "fp-consensus" version = "2.0.0-dev" -source = "git+https://github.com/opentensor/frontier?rev=c591df98c524e1599c45f93cf4685248088ac014#c591df98c524e1599c45f93cf4685248088ac014" +source = "git+https://github.com/opentensor/frontier?rev=830e61f370d88f7ace1c5a5659dd58db75a19844#830e61f370d88f7ace1c5a5659dd58db75a19844" dependencies = [ "ethereum", "parity-scale-codec", @@ -3572,7 +3605,7 @@ dependencies = [ [[package]] name = "fp-ethereum" version = "1.0.0-dev" -source = "git+https://github.com/opentensor/frontier?rev=c591df98c524e1599c45f93cf4685248088ac014#c591df98c524e1599c45f93cf4685248088ac014" +source = "git+https://github.com/opentensor/frontier?rev=830e61f370d88f7ace1c5a5659dd58db75a19844#830e61f370d88f7ace1c5a5659dd58db75a19844" dependencies = [ "ethereum", "ethereum-types 0.15.1", @@ -3584,7 +3617,7 @@ dependencies = [ [[package]] name = "fp-evm" version = "3.0.0-dev" -source = "git+https://github.com/opentensor/frontier?rev=c591df98c524e1599c45f93cf4685248088ac014#c591df98c524e1599c45f93cf4685248088ac014" +source = "git+https://github.com/opentensor/frontier?rev=830e61f370d88f7ace1c5a5659dd58db75a19844#830e61f370d88f7ace1c5a5659dd58db75a19844" dependencies = [ "environmental", "evm", @@ -3600,7 +3633,7 @@ dependencies = [ [[package]] name = "fp-rpc" version = "3.0.0-dev" -source = "git+https://github.com/opentensor/frontier?rev=c591df98c524e1599c45f93cf4685248088ac014#c591df98c524e1599c45f93cf4685248088ac014" +source = "git+https://github.com/opentensor/frontier?rev=830e61f370d88f7ace1c5a5659dd58db75a19844#830e61f370d88f7ace1c5a5659dd58db75a19844" dependencies = [ "ethereum", "ethereum-types 0.15.1", @@ -3616,7 +3649,7 @@ dependencies = [ [[package]] name = "fp-self-contained" version = "1.0.0-dev" -source = "git+https://github.com/opentensor/frontier?rev=c591df98c524e1599c45f93cf4685248088ac014#c591df98c524e1599c45f93cf4685248088ac014" +source = "git+https://github.com/opentensor/frontier?rev=830e61f370d88f7ace1c5a5659dd58db75a19844#830e61f370d88f7ace1c5a5659dd58db75a19844" dependencies = [ "frame-support", "parity-scale-codec", @@ -3628,7 +3661,7 @@ dependencies = [ [[package]] name = "fp-storage" version = "2.0.0" -source = "git+https://github.com/opentensor/frontier?rev=c591df98c524e1599c45f93cf4685248088ac014#c591df98c524e1599c45f93cf4685248088ac014" +source = "git+https://github.com/opentensor/frontier?rev=830e61f370d88f7ace1c5a5659dd58db75a19844#830e61f370d88f7ace1c5a5659dd58db75a19844" dependencies = [ "parity-scale-codec", "serde", @@ -3738,6 +3771,33 @@ dependencies = [ "sp-crypto-hashing 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "frame-election-provider-solution-type" +version = "16.1.1" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2503-6#598feddb893f5ad3923a62e41a2f179b6e10c30c" +dependencies = [ + "proc-macro-crate 3.3.0", + "proc-macro2", + "quote", + "syn 2.0.104", +] + +[[package]] +name = "frame-election-provider-support" +version = "40.1.1" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2503-6#598feddb893f5ad3923a62e41a2f179b6e10c30c" +dependencies = [ + "frame-election-provider-solution-type", + "frame-support", + "frame-system", + "parity-scale-codec", + "scale-info", + "sp-arithmetic", + "sp-core", + "sp-npos-elections", + "sp-runtime", +] + [[package]] name = "frame-executive" version = "40.0.1" @@ -4054,9 +4114,9 @@ checksum = "9e5c1b78ca4aae1ac06c48a526a655760685149f0d465d21f37abfe57ce075c6" [[package]] name = "futures-lite" -version = "2.6.0" +version = "2.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5edaec856126859abb19ed65f39e90fea3a9574b9707f13539acf4abf7eb532" +checksum = "f78e10609fe0e0b3f4157ffab1876319b5b0db102a2c60dc4626306dc46b44ad" dependencies = [ "fastrand", "futures-core", @@ -6743,6 +6803,7 @@ dependencies = [ "cumulus-primitives-proof-size-hostfunction", "fc-api", "fc-aura", + "fc-babe", "fc-consensus", "fc-db", "fc-mapping-sync", @@ -6759,6 +6820,7 @@ dependencies = [ "futures", "hex", "jsonrpsee", + "log", "memmap2 0.9.7", "node-subtensor-runtime", "num-traits", @@ -6776,6 +6838,8 @@ dependencies = [ "sc-client-api", "sc-consensus", "sc-consensus-aura", + "sc-consensus-babe", + "sc-consensus-babe-rpc", "sc-consensus-grandpa", "sc-consensus-grandpa-rpc", "sc-consensus-manual-seal", @@ -6798,7 +6862,9 @@ dependencies = [ "sp-blockchain", "sp-consensus", "sp-consensus-aura", + "sp-consensus-babe", "sp-consensus-grandpa", + "sp-consensus-slots", "sp-core", "sp-crypto-ec-utils 0.15.0", "sp-inherents", @@ -6828,6 +6894,7 @@ dependencies = [ "fp-rpc", "fp-self-contained", "frame-benchmarking", + "frame-election-provider-support", "frame-executive", "frame-metadata 20.0.0", "frame-metadata-hash-extension", @@ -6841,28 +6908,42 @@ dependencies = [ "log", "pallet-admin-utils", "pallet-aura", + "pallet-authority-discovery", + "pallet-authorship", + "pallet-babe", + "pallet-bags-list", "pallet-balances", "pallet-base-fee", "pallet-collective", "pallet-commitments", "pallet-crowdloan", "pallet-drand", + "pallet-election-provider-multi-phase", "pallet-ethereum", "pallet-evm", "pallet-evm-chain-id", "pallet-evm-precompile-modexp", "pallet-evm-precompile-sha3fips", "pallet-evm-precompile-simple", + "pallet-fast-unstake", "pallet-grandpa", "pallet-hotfix-sufficients", "pallet-insecure-randomness-collective-flip", "pallet-membership", "pallet-multisig", + "pallet-nomination-pools", + "pallet-nomination-pools-runtime-api", + "pallet-offences", "pallet-preimage", "pallet-proxy 38.0.0", "pallet-registry", "pallet-safe-mode", "pallet-scheduler", + "pallet-session", + "pallet-staking", + "pallet-staking-reward-curve", + "pallet-staking-reward-fn", + "pallet-staking-runtime-api", "pallet-subtensor", "pallet-subtensor-swap", "pallet-subtensor-swap-runtime-api", @@ -6872,6 +6953,7 @@ dependencies = [ "pallet-transaction-payment-rpc-runtime-api", "pallet-utility 38.0.0", "parity-scale-codec", + "polkadot-runtime-common", "precompile-utils", "rand_chacha 0.3.1", "scale-info", @@ -6879,15 +6961,21 @@ dependencies = [ "sha2 0.10.9", "smallvec", "sp-api", + "sp-authority-discovery", "sp-block-builder", "sp-consensus-aura", + "sp-consensus-babe", + "sp-consensus-grandpa", + "sp-consensus-slots", "sp-core", "sp-genesis-builder", "sp-inherents", "sp-io", + "sp-npos-elections", "sp-offchain", "sp-runtime", "sp-session", + "sp-staking", "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2503-6)", "sp-storage 22.0.0", "sp-tracing 17.1.0", @@ -7224,7 +7312,7 @@ dependencies = [ "expander", "indexmap 2.10.0", "itertools 0.11.0", - "petgraph", + "petgraph 0.6.5", "proc-macro-crate 3.3.0", "proc-macro2", "quote", @@ -7270,6 +7358,38 @@ dependencies = [ "subtensor-swap-interface", ] +[[package]] +name = "pallet-asset-conversion" +version = "22.0.0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2503-6#598feddb893f5ad3923a62e41a2f179b6e10c30c" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "log", + "parity-scale-codec", + "scale-info", + "sp-api", + "sp-arithmetic", + "sp-core", + "sp-io", + "sp-runtime", +] + +[[package]] +name = "pallet-asset-rate" +version = "19.0.0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2503-6#598feddb893f5ad3923a62e41a2f179b6e10c30c" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "parity-scale-codec", + "scale-info", + "sp-core", + "sp-runtime", +] + [[package]] name = "pallet-aura" version = "39.0.0" @@ -7286,6 +7406,21 @@ dependencies = [ "sp-runtime", ] +[[package]] +name = "pallet-authority-discovery" +version = "40.0.0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2503-6#598feddb893f5ad3923a62e41a2f179b6e10c30c" +dependencies = [ + "frame-support", + "frame-system", + "pallet-session", + "parity-scale-codec", + "scale-info", + "sp-application-crypto", + "sp-authority-discovery", + "sp-runtime", +] + [[package]] name = "pallet-authorship" version = "40.0.0" @@ -7299,6 +7434,50 @@ dependencies = [ "sp-runtime", ] +[[package]] +name = "pallet-babe" +version = "40.0.0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2503-6#598feddb893f5ad3923a62e41a2f179b6e10c30c" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "log", + "pallet-authorship", + "pallet-session", + "pallet-timestamp", + "parity-scale-codec", + "scale-info", + "sp-application-crypto", + "sp-consensus-babe", + "sp-core", + "sp-io", + "sp-runtime", + "sp-session", + "sp-staking", +] + +[[package]] +name = "pallet-bags-list" +version = "39.1.0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2503-6#598feddb893f5ad3923a62e41a2f179b6e10c30c" +dependencies = [ + "aquamarine", + "docify", + "frame-benchmarking", + "frame-election-provider-support", + "frame-support", + "frame-system", + "log", + "pallet-balances", + "parity-scale-codec", + "scale-info", + "sp-core", + "sp-io", + "sp-runtime", + "sp-tracing 17.1.0", +] + [[package]] name = "pallet-balances" version = "41.1.0" @@ -7318,7 +7497,7 @@ dependencies = [ [[package]] name = "pallet-base-fee" version = "1.0.0" -source = "git+https://github.com/opentensor/frontier?rev=c591df98c524e1599c45f93cf4685248088ac014#c591df98c524e1599c45f93cf4685248088ac014" +source = "git+https://github.com/opentensor/frontier?rev=830e61f370d88f7ace1c5a5659dd58db75a19844#830e61f370d88f7ace1c5a5659dd58db75a19844" dependencies = [ "fp-evm", "frame-support", @@ -7329,6 +7508,24 @@ dependencies = [ "sp-runtime", ] +[[package]] +name = "pallet-broker" +version = "0.19.2" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2503-6#598feddb893f5ad3923a62e41a2f179b6e10c30c" +dependencies = [ + "bitvec", + "frame-benchmarking", + "frame-support", + "frame-system", + "log", + "parity-scale-codec", + "scale-info", + "sp-api", + "sp-arithmetic", + "sp-core", + "sp-runtime", +] + [[package]] name = "pallet-collective" version = "4.0.0-dev" @@ -7426,10 +7623,45 @@ dependencies = [ "w3f-bls", ] +[[package]] +name = "pallet-election-provider-multi-phase" +version = "39.2.0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2503-6#598feddb893f5ad3923a62e41a2f179b6e10c30c" +dependencies = [ + "frame-benchmarking", + "frame-election-provider-support", + "frame-support", + "frame-system", + "log", + "pallet-election-provider-support-benchmarking", + "parity-scale-codec", + "rand 0.8.5", + "scale-info", + "sp-arithmetic", + "sp-core", + "sp-io", + "sp-npos-elections", + "sp-runtime", + "strum 0.26.3", +] + +[[package]] +name = "pallet-election-provider-support-benchmarking" +version = "39.0.0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2503-6#598feddb893f5ad3923a62e41a2f179b6e10c30c" +dependencies = [ + "frame-benchmarking", + "frame-election-provider-support", + "frame-system", + "parity-scale-codec", + "sp-npos-elections", + "sp-runtime", +] + [[package]] name = "pallet-ethereum" version = "4.0.0-dev" -source = "git+https://github.com/opentensor/frontier?rev=c591df98c524e1599c45f93cf4685248088ac014#c591df98c524e1599c45f93cf4685248088ac014" +source = "git+https://github.com/opentensor/frontier?rev=830e61f370d88f7ace1c5a5659dd58db75a19844#830e61f370d88f7ace1c5a5659dd58db75a19844" dependencies = [ "ethereum", "ethereum-types 0.15.1", @@ -7452,7 +7684,7 @@ dependencies = [ [[package]] name = "pallet-evm" version = "6.0.0-dev" -source = "git+https://github.com/opentensor/frontier?rev=c591df98c524e1599c45f93cf4685248088ac014#c591df98c524e1599c45f93cf4685248088ac014" +source = "git+https://github.com/opentensor/frontier?rev=830e61f370d88f7ace1c5a5659dd58db75a19844#830e61f370d88f7ace1c5a5659dd58db75a19844" dependencies = [ "cumulus-primitives-storage-weight-reclaim", "environmental", @@ -7476,7 +7708,7 @@ dependencies = [ [[package]] name = "pallet-evm-chain-id" version = "1.0.0-dev" -source = "git+https://github.com/opentensor/frontier?rev=c591df98c524e1599c45f93cf4685248088ac014#c591df98c524e1599c45f93cf4685248088ac014" +source = "git+https://github.com/opentensor/frontier?rev=830e61f370d88f7ace1c5a5659dd58db75a19844#830e61f370d88f7ace1c5a5659dd58db75a19844" dependencies = [ "frame-support", "frame-system", @@ -7487,7 +7719,7 @@ dependencies = [ [[package]] name = "pallet-evm-precompile-bn128" version = "2.0.0-dev" -source = "git+https://github.com/opentensor/frontier?rev=c591df98c524e1599c45f93cf4685248088ac014#c591df98c524e1599c45f93cf4685248088ac014" +source = "git+https://github.com/opentensor/frontier?rev=830e61f370d88f7ace1c5a5659dd58db75a19844#830e61f370d88f7ace1c5a5659dd58db75a19844" dependencies = [ "fp-evm", "sp-core", @@ -7497,7 +7729,7 @@ dependencies = [ [[package]] name = "pallet-evm-precompile-dispatch" version = "2.0.0-dev" -source = "git+https://github.com/opentensor/frontier?rev=c591df98c524e1599c45f93cf4685248088ac014#c591df98c524e1599c45f93cf4685248088ac014" +source = "git+https://github.com/opentensor/frontier?rev=830e61f370d88f7ace1c5a5659dd58db75a19844#830e61f370d88f7ace1c5a5659dd58db75a19844" dependencies = [ "fp-evm", "frame-support", @@ -7509,7 +7741,7 @@ dependencies = [ [[package]] name = "pallet-evm-precompile-modexp" version = "2.0.0-dev" -source = "git+https://github.com/opentensor/frontier?rev=c591df98c524e1599c45f93cf4685248088ac014#c591df98c524e1599c45f93cf4685248088ac014" +source = "git+https://github.com/opentensor/frontier?rev=830e61f370d88f7ace1c5a5659dd58db75a19844#830e61f370d88f7ace1c5a5659dd58db75a19844" dependencies = [ "fp-evm", "num", @@ -7518,7 +7750,7 @@ dependencies = [ [[package]] name = "pallet-evm-precompile-sha3fips" version = "2.0.0-dev" -source = "git+https://github.com/opentensor/frontier?rev=c591df98c524e1599c45f93cf4685248088ac014#c591df98c524e1599c45f93cf4685248088ac014" +source = "git+https://github.com/opentensor/frontier?rev=830e61f370d88f7ace1c5a5659dd58db75a19844#830e61f370d88f7ace1c5a5659dd58db75a19844" dependencies = [ "fp-evm", "tiny-keccak", @@ -7527,13 +7759,31 @@ dependencies = [ [[package]] name = "pallet-evm-precompile-simple" version = "2.0.0-dev" -source = "git+https://github.com/opentensor/frontier?rev=c591df98c524e1599c45f93cf4685248088ac014#c591df98c524e1599c45f93cf4685248088ac014" +source = "git+https://github.com/opentensor/frontier?rev=830e61f370d88f7ace1c5a5659dd58db75a19844#830e61f370d88f7ace1c5a5659dd58db75a19844" dependencies = [ "fp-evm", "ripemd", "sp-io", ] +[[package]] +name = "pallet-fast-unstake" +version = "39.0.0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2503-6#598feddb893f5ad3923a62e41a2f179b6e10c30c" +dependencies = [ + "docify", + "frame-benchmarking", + "frame-election-provider-support", + "frame-support", + "frame-system", + "log", + "parity-scale-codec", + "scale-info", + "sp-io", + "sp-runtime", + "sp-staking", +] + [[package]] name = "pallet-grandpa" version = "40.0.0" @@ -7559,7 +7809,7 @@ dependencies = [ [[package]] name = "pallet-hotfix-sufficients" version = "1.0.0" -source = "git+https://github.com/opentensor/frontier?rev=c591df98c524e1599c45f93cf4685248088ac014#c591df98c524e1599c45f93cf4685248088ac014" +source = "git+https://github.com/opentensor/frontier?rev=830e61f370d88f7ace1c5a5659dd58db75a19844#830e61f370d88f7ace1c5a5659dd58db75a19844" dependencies = [ "frame-benchmarking", "frame-support", @@ -7571,6 +7821,22 @@ dependencies = [ "sp-runtime", ] +[[package]] +name = "pallet-identity" +version = "40.1.0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2503-6#598feddb893f5ad3923a62e41a2f179b6e10c30c" +dependencies = [ + "enumflags2", + "frame-benchmarking", + "frame-support", + "frame-system", + "log", + "parity-scale-codec", + "scale-info", + "sp-io", + "sp-runtime", +] + [[package]] name = "pallet-insecure-randomness-collective-flip" version = "28.0.0" @@ -7598,6 +7864,37 @@ dependencies = [ "sp-runtime", ] +[[package]] +name = "pallet-message-queue" +version = "43.1.0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2503-6#598feddb893f5ad3923a62e41a2f179b6e10c30c" +dependencies = [ + "environmental", + "frame-benchmarking", + "frame-support", + "frame-system", + "log", + "parity-scale-codec", + "scale-info", + "sp-arithmetic", + "sp-core", + "sp-io", + "sp-runtime", + "sp-weights", +] + +[[package]] +name = "pallet-mmr" +version = "40.0.0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2503-6#598feddb893f5ad3923a62e41a2f179b6e10c30c" +dependencies = [ + "log", + "parity-scale-codec", + "polkadot-sdk-frame", + "scale-info", + "sp-mmr-primitives", +] + [[package]] name = "pallet-multisig" version = "40.1.0" @@ -7609,6 +7906,49 @@ dependencies = [ "scale-info", ] +[[package]] +name = "pallet-nomination-pools" +version = "38.1.0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2503-6#598feddb893f5ad3923a62e41a2f179b6e10c30c" +dependencies = [ + "frame-support", + "frame-system", + "log", + "pallet-balances", + "parity-scale-codec", + "scale-info", + "sp-core", + "sp-io", + "sp-runtime", + "sp-staking", + "sp-tracing 17.1.0", +] + +[[package]] +name = "pallet-nomination-pools-runtime-api" +version = "36.0.0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2503-6#598feddb893f5ad3923a62e41a2f179b6e10c30c" +dependencies = [ + "pallet-nomination-pools", + "parity-scale-codec", + "sp-api", +] + +[[package]] +name = "pallet-offences" +version = "39.0.0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2503-6#598feddb893f5ad3923a62e41a2f179b6e10c30c" +dependencies = [ + "frame-support", + "frame-system", + "log", + "parity-scale-codec", + "scale-info", + "serde", + "sp-runtime", + "sp-staking", +] + [[package]] name = "pallet-preimage" version = "40.0.0" @@ -7702,41 +8042,93 @@ dependencies = [ ] [[package]] -name = "pallet-scheduler" -version = "41.2.0" +name = "pallet-scheduler" +version = "41.2.0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2503-6#598feddb893f5ad3923a62e41a2f179b6e10c30c" +dependencies = [ + "docify", + "frame-benchmarking", + "frame-support", + "frame-system", + "log", + "parity-scale-codec", + "scale-info", + "sp-io", + "sp-runtime", + "sp-weights", +] + +[[package]] +name = "pallet-session" +version = "40.0.1" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2503-6#598feddb893f5ad3923a62e41a2f179b6e10c30c" +dependencies = [ + "frame-support", + "frame-system", + "impl-trait-for-tuples", + "log", + "pallet-timestamp", + "parity-scale-codec", + "scale-info", + "sp-core", + "sp-io", + "sp-runtime", + "sp-session", + "sp-staking", + "sp-state-machine", + "sp-trie", +] + +[[package]] +name = "pallet-staking" +version = "40.1.1" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2503-6#598feddb893f5ad3923a62e41a2f179b6e10c30c" +dependencies = [ + "frame-benchmarking", + "frame-election-provider-support", + "frame-support", + "frame-system", + "log", + "pallet-authorship", + "pallet-session", + "parity-scale-codec", + "rand_chacha 0.3.1", + "scale-info", + "serde", + "sp-application-crypto", + "sp-io", + "sp-runtime", + "sp-staking", +] + +[[package]] +name = "pallet-staking-reward-curve" +version = "12.0.0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2503-6#598feddb893f5ad3923a62e41a2f179b6e10c30c" +dependencies = [ + "proc-macro-crate 3.3.0", + "proc-macro2", + "quote", + "syn 2.0.104", +] + +[[package]] +name = "pallet-staking-reward-fn" +version = "22.0.1" source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2503-6#598feddb893f5ad3923a62e41a2f179b6e10c30c" dependencies = [ - "docify", - "frame-benchmarking", - "frame-support", - "frame-system", "log", - "parity-scale-codec", - "scale-info", - "sp-io", - "sp-runtime", - "sp-weights", + "sp-arithmetic", ] [[package]] -name = "pallet-session" -version = "40.0.1" +name = "pallet-staking-runtime-api" +version = "26.0.0" source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2503-6#598feddb893f5ad3923a62e41a2f179b6e10c30c" dependencies = [ - "frame-support", - "frame-system", - "impl-trait-for-tuples", - "log", - "pallet-timestamp", "parity-scale-codec", - "scale-info", - "sp-core", - "sp-io", - "sp-runtime", - "sp-session", + "sp-api", "sp-staking", - "sp-state-machine", - "sp-trie", ] [[package]] @@ -7768,6 +8160,7 @@ dependencies = [ "pallet-utility 38.0.0", "parity-scale-codec", "parity-util-mem", + "polkadot-runtime-common", "rand 0.8.5", "rand_chacha 0.3.1", "safe-math", @@ -7920,6 +8313,25 @@ dependencies = [ "sp-weights", ] +[[package]] +name = "pallet-treasury" +version = "39.0.0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2503-6#598feddb893f5ad3923a62e41a2f179b6e10c30c" +dependencies = [ + "docify", + "frame-benchmarking", + "frame-support", + "frame-system", + "impl-trait-for-tuples", + "log", + "pallet-balances", + "parity-scale-codec", + "scale-info", + "serde", + "sp-core", + "sp-runtime", +] + [[package]] name = "pallet-utility" version = "38.0.0" @@ -7954,6 +8366,20 @@ dependencies = [ "sp-runtime", ] +[[package]] +name = "pallet-vesting" +version = "40.1.0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2503-6#598feddb893f5ad3923a62e41a2f179b6e10c30c" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "log", + "parity-scale-codec", + "scale-info", + "sp-runtime", +] + [[package]] name = "parity-bip39" version = "2.0.1" @@ -8212,7 +8638,17 @@ version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4c5cc86750666a3ed20bdaf5ca2a0344f9c67674cae0515bec2da16fbaa47db" dependencies = [ - "fixedbitset", + "fixedbitset 0.4.2", + "indexmap 2.10.0", +] + +[[package]] +name = "petgraph" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3672b37090dbd86368a4145bc067582552b29c27377cad4e0a306c97f9bd7772" +dependencies = [ + "fixedbitset 0.5.7", "indexmap 2.10.0", ] @@ -8275,6 +8711,16 @@ version = "0.3.32" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7edddbd0b52d732b21ad9a5fab5c704c14cd949e5e9a1ec5929a24fded1b904c" +[[package]] +name = "polkadot-ckb-merkle-mountain-range" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "221c71b432b38e494a0fdedb5f720e4cb974edf03a0af09e5b2238dbac7e6947" +dependencies = [ + "cfg-if", + "itertools 0.10.5", +] + [[package]] name = "polkadot-core-primitives" version = "17.1.0" @@ -8444,6 +8890,115 @@ dependencies = [ "thiserror 1.0.69", ] +[[package]] +name = "polkadot-runtime-common" +version = "19.1.0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2503-6#598feddb893f5ad3923a62e41a2f179b6e10c30c" +dependencies = [ + "bitvec", + "frame-benchmarking", + "frame-election-provider-support", + "frame-support", + "frame-system", + "impl-trait-for-tuples", + "libsecp256k1", + "log", + "pallet-asset-rate", + "pallet-authorship", + "pallet-babe", + "pallet-balances", + "pallet-broker", + "pallet-election-provider-multi-phase", + "pallet-fast-unstake", + "pallet-identity", + "pallet-session", + "pallet-staking", + "pallet-staking-reward-fn", + "pallet-timestamp", + "pallet-transaction-payment", + "pallet-treasury", + "pallet-vesting", + "parity-scale-codec", + "polkadot-primitives", + "polkadot-runtime-parachains", + "rustc-hex", + "scale-info", + "serde", + "slot-range-helper", + "sp-api", + "sp-core", + "sp-inherents", + "sp-io", + "sp-keyring", + "sp-npos-elections", + "sp-runtime", + "sp-session", + "sp-staking", + "staging-xcm", + "staging-xcm-builder", + "staging-xcm-executor", + "static_assertions", +] + +[[package]] +name = "polkadot-runtime-metrics" +version = "20.0.0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2503-6#598feddb893f5ad3923a62e41a2f179b6e10c30c" +dependencies = [ + "bs58", + "frame-benchmarking", + "parity-scale-codec", + "polkadot-primitives", + "sp-tracing 17.1.0", +] + +[[package]] +name = "polkadot-runtime-parachains" +version = "19.1.0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2503-6#598feddb893f5ad3923a62e41a2f179b6e10c30c" +dependencies = [ + "bitflags 1.3.2", + "bitvec", + "frame-benchmarking", + "frame-support", + "frame-system", + "impl-trait-for-tuples", + "log", + "pallet-authority-discovery", + "pallet-authorship", + "pallet-babe", + "pallet-balances", + "pallet-broker", + "pallet-message-queue", + "pallet-mmr", + "pallet-session", + "pallet-staking", + "pallet-timestamp", + "parity-scale-codec", + "polkadot-core-primitives", + "polkadot-parachain-primitives", + "polkadot-primitives", + "polkadot-runtime-metrics", + "rand 0.8.5", + "rand_chacha 0.3.1", + "scale-info", + "serde", + "sp-api", + "sp-application-crypto", + "sp-arithmetic", + "sp-core", + "sp-inherents", + "sp-io", + "sp-keystore", + "sp-runtime", + "sp-session", + "sp-staking", + "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2503-6)", + "staging-xcm", + "staging-xcm-executor", + "static_assertions", +] + [[package]] name = "polkadot-sdk" version = "0.7.0" @@ -8622,9 +9177,9 @@ checksum = "23eff02c070c70f31878a3d915e88a914ecf3e153741e2fb572dde28cce20fde" [[package]] name = "polling" -version = "3.9.0" +version = "3.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ee9b2fa7a4517d2c91ff5bc6c297a427a96749d15f98fcdbb22c05571a4d4b7" +checksum = "b5bd19146350fe804f7cb2669c851c03d69da628803dab0d98018142aaa5d829" dependencies = [ "cfg-if", "concurrent-queue", @@ -8690,7 +9245,7 @@ dependencies = [ [[package]] name = "precompile-utils" version = "0.1.0" -source = "git+https://github.com/opentensor/frontier?rev=c591df98c524e1599c45f93cf4685248088ac014#c591df98c524e1599c45f93cf4685248088ac014" +source = "git+https://github.com/opentensor/frontier?rev=830e61f370d88f7ace1c5a5659dd58db75a19844#830e61f370d88f7ace1c5a5659dd58db75a19844" dependencies = [ "environmental", "evm", @@ -8714,7 +9269,7 @@ dependencies = [ [[package]] name = "precompile-utils-macro" version = "0.1.0" -source = "git+https://github.com/opentensor/frontier?rev=c591df98c524e1599c45f93cf4685248088ac014#c591df98c524e1599c45f93cf4685248088ac014" +source = "git+https://github.com/opentensor/frontier?rev=830e61f370d88f7ace1c5a5659dd58db75a19844#830e61f370d88f7ace1c5a5659dd58db75a19844" dependencies = [ "case", "num_enum", @@ -8997,7 +9552,7 @@ dependencies = [ "log", "multimap", "once_cell", - "petgraph", + "petgraph 0.7.1", "prettyplease", "prost 0.13.5", "prost-types", @@ -9565,9 +10120,9 @@ dependencies = [ [[package]] name = "ruint" -version = "1.15.0" +version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11256b5fe8c68f56ac6f39ef0720e592f33d2367a4782740d9c9142e889c7fb4" +checksum = "9ecb38f82477f20c5c3d62ef52d7c4e536e38ea9b73fb570a20c5cae0e14bcf6" dependencies = [ "alloy-rlp", "ark-ff 0.3.0", @@ -10166,6 +10721,28 @@ dependencies = [ "thiserror 1.0.69", ] +[[package]] +name = "sc-consensus-babe-rpc" +version = "0.49.0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2503-6#598feddb893f5ad3923a62e41a2f179b6e10c30c" +dependencies = [ + "futures", + "jsonrpsee", + "sc-consensus-babe", + "sc-consensus-epochs", + "sc-rpc-api", + "serde", + "sp-api", + "sp-application-crypto", + "sp-blockchain", + "sp-consensus", + "sp-consensus-babe", + "sp-core", + "sp-keystore", + "sp-runtime", + "thiserror 1.0.69", +] + [[package]] name = "sc-consensus-epochs" version = "0.48.0" @@ -11445,9 +12022,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.141" +version = "1.0.142" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30b9eff21ebe718216c6ec64e1d9ac57087aad11efc64e32002bce4a0d4c03d3" +checksum = "030fedb782600dcbd6f02d479bf0d817ac3bb40d644745b769d6a96bc3afc5a7" dependencies = [ "itoa", "memchr", @@ -11599,9 +12176,9 @@ checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" [[package]] name = "signal-hook-registry" -version = "1.4.5" +version = "1.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9203b8055f63a2a00e2f593bb0510367fe707d7ff1e5c872de2f537b339e5410" +checksum = "b2a4719bff48cee6b39d12c020eeb490953ad2443b7055bd0b21fca26bd8c28b" dependencies = [ "libc", ] @@ -11668,6 +12245,17 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "826167069c09b99d56f31e9ae5c99049e932a98c9dc2dac47645b08dbbf76ba7" +[[package]] +name = "slot-range-helper" +version = "17.0.0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2503-6#598feddb893f5ad3923a62e41a2f179b6e10c30c" +dependencies = [ + "enumn", + "parity-scale-codec", + "paste", + "sp-runtime", +] + [[package]] name = "smallvec" version = "1.15.1" @@ -11709,7 +12297,7 @@ dependencies = [ "derive_more 0.99.20", "ed25519-zebra", "either", - "event-listener 5.4.0", + "event-listener 5.4.1", "fnv", "futures-lite", "futures-util", @@ -11758,7 +12346,7 @@ dependencies = [ "bs58", "derive_more 0.99.20", "either", - "event-listener 5.4.0", + "event-listener 5.4.1", "fnv", "futures-channel", "futures-lite", @@ -12078,7 +12666,7 @@ dependencies = [ [[package]] name = "sp-crypto-ec-utils" version = "0.10.0" -source = "git+https://github.com/paritytech/polkadot-sdk#177b03958c766fe053f28424ee6f6748644bb794" +source = "git+https://github.com/paritytech/polkadot-sdk#59fb2e7482d471a7ec4e8d3b30499497efa7b34c" dependencies = [ "ark-bls12-377", "ark-bls12-377-ext", @@ -12174,7 +12762,7 @@ dependencies = [ [[package]] name = "sp-debug-derive" version = "14.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk#177b03958c766fe053f28424ee6f6748644bb794" +source = "git+https://github.com/paritytech/polkadot-sdk#59fb2e7482d471a7ec4e8d3b30499497efa7b34c" dependencies = [ "proc-macro2", "quote", @@ -12184,7 +12772,7 @@ dependencies = [ [[package]] name = "sp-externalities" version = "0.25.0" -source = "git+https://github.com/paritytech/polkadot-sdk#177b03958c766fe053f28424ee6f6748644bb794" +source = "git+https://github.com/paritytech/polkadot-sdk#59fb2e7482d471a7ec4e8d3b30499497efa7b34c" dependencies = [ "environmental", "parity-scale-codec", @@ -12303,6 +12891,36 @@ dependencies = [ "sp-application-crypto", ] +[[package]] +name = "sp-mmr-primitives" +version = "36.1.0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2503-6#598feddb893f5ad3923a62e41a2f179b6e10c30c" +dependencies = [ + "log", + "parity-scale-codec", + "polkadot-ckb-merkle-mountain-range", + "scale-info", + "serde", + "sp-api", + "sp-core", + "sp-debug-derive 14.0.0 (git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2503-6)", + "sp-runtime", + "thiserror 1.0.69", +] + +[[package]] +name = "sp-npos-elections" +version = "36.2.0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2503-6#598feddb893f5ad3923a62e41a2f179b6e10c30c" +dependencies = [ + "parity-scale-codec", + "scale-info", + "serde", + "sp-arithmetic", + "sp-core", + "sp-runtime", +] + [[package]] name = "sp-offchain" version = "36.0.0" @@ -12364,7 +12982,7 @@ dependencies = [ [[package]] name = "sp-runtime-interface" version = "24.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk#177b03958c766fe053f28424ee6f6748644bb794" +source = "git+https://github.com/paritytech/polkadot-sdk#59fb2e7482d471a7ec4e8d3b30499497efa7b34c" dependencies = [ "bytes", "impl-trait-for-tuples", @@ -12401,7 +13019,7 @@ dependencies = [ [[package]] name = "sp-runtime-interface-proc-macro" version = "17.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk#177b03958c766fe053f28424ee6f6748644bb794" +source = "git+https://github.com/paritytech/polkadot-sdk#59fb2e7482d471a7ec4e8d3b30499497efa7b34c" dependencies = [ "Inflector", "expander", @@ -12503,12 +13121,12 @@ source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable [[package]] name = "sp-std" version = "14.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk#177b03958c766fe053f28424ee6f6748644bb794" +source = "git+https://github.com/paritytech/polkadot-sdk#59fb2e7482d471a7ec4e8d3b30499497efa7b34c" [[package]] name = "sp-storage" version = "19.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk#177b03958c766fe053f28424ee6f6748644bb794" +source = "git+https://github.com/paritytech/polkadot-sdk#59fb2e7482d471a7ec4e8d3b30499497efa7b34c" dependencies = [ "impl-serde 0.5.0", "parity-scale-codec", @@ -12544,7 +13162,7 @@ dependencies = [ [[package]] name = "sp-tracing" version = "16.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk#177b03958c766fe053f28424ee6f6748644bb794" +source = "git+https://github.com/paritytech/polkadot-sdk#59fb2e7482d471a7ec4e8d3b30499497efa7b34c" dependencies = [ "parity-scale-codec", "regex", @@ -12641,7 +13259,7 @@ dependencies = [ [[package]] name = "sp-wasm-interface" version = "20.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk#177b03958c766fe053f28424ee6f6748644bb794" +source = "git+https://github.com/paritytech/polkadot-sdk#59fb2e7482d471a7ec4e8d3b30499497efa7b34c" dependencies = [ "anyhow", "impl-trait-for-tuples", @@ -12731,7 +13349,7 @@ dependencies = [ "crc", "crossbeam-queue", "either", - "event-listener 5.4.0", + "event-listener 5.4.1", "futures-core", "futures-intrusive", "futures-io", @@ -12856,6 +13474,50 @@ dependencies = [ "xcm-procedural", ] +[[package]] +name = "staging-xcm-builder" +version = "20.1.1" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2503-6#598feddb893f5ad3923a62e41a2f179b6e10c30c" +dependencies = [ + "environmental", + "frame-support", + "frame-system", + "impl-trait-for-tuples", + "pallet-asset-conversion", + "pallet-transaction-payment", + "parity-scale-codec", + "polkadot-parachain-primitives", + "scale-info", + "sp-arithmetic", + "sp-core", + "sp-io", + "sp-runtime", + "sp-weights", + "staging-xcm", + "staging-xcm-executor", + "tracing", +] + +[[package]] +name = "staging-xcm-executor" +version = "19.1.2" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2503-6#598feddb893f5ad3923a62e41a2f179b6e10c30c" +dependencies = [ + "environmental", + "frame-benchmarking", + "frame-support", + "impl-trait-for-tuples", + "parity-scale-codec", + "scale-info", + "sp-arithmetic", + "sp-core", + "sp-io", + "sp-runtime", + "sp-weights", + "staging-xcm", + "tracing", +] + [[package]] name = "static_assertions" version = "1.1.0" @@ -13162,6 +13824,7 @@ dependencies = [ "approx", "frame-support", "parity-scale-codec", + "polkadot-runtime-common", "scale-info", "serde", "sp-core", @@ -13675,9 +14338,9 @@ dependencies = [ [[package]] name = "tokio" -version = "1.47.0" +version = "1.47.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43864ed400b6043a4757a25c7a64a8efde741aed79a056a2fb348a406701bb35" +checksum = "89e49afdadebb872d3145a5638b59eb0691ea23e46ca484037cfab3b76b95038" dependencies = [ "backtrace", "bytes", @@ -13744,9 +14407,9 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.15" +version = "0.7.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66a539a9ad6d5d281510d5bd368c973d636c02dbf8a67300bfb6b950696ad7df" +checksum = "14307c986784f72ef81c89db7d9e28d6ac26d16213b109ea501696195e6e3ce5" dependencies = [ "bytes", "futures-core", @@ -15495,9 +16158,9 @@ dependencies = [ [[package]] name = "zerovec" -version = "0.11.2" +version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a05eb080e015ba39cc9e23bbe5e7fb04d5fb040350f99f34e338d5fdd294428" +checksum = "bdbb9122ea75b11bf96e7492afb723e8a7fbe12c67417aa95e7e3d18144d37cd" dependencies = [ "yoke", "zerofrom", diff --git a/Cargo.toml b/Cargo.toml index 20c2878366..461c810fe6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -112,7 +112,6 @@ expander = "2" ahash = { version = "0.8", default-features = false } regex = { version = "1.11.1", default-features = false } - frame-benchmarking = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false } frame-benchmarking-cli = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false } frame-executive = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false } @@ -126,6 +125,7 @@ frame-metadata = { version = "20.0.0", default-features = false } pallet-proxy = { path = "pallets/proxy", default-features = false } pallet-utility = { path = "pallets/utility", default-features = false } +pallet-babe = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false } pallet-aura = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false } pallet-balances = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false } pallet-grandpa = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false } @@ -142,11 +142,29 @@ pallet-transaction-payment-rpc = { git = "https://github.com/paritytech/polkadot pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false } pallet-root-testing = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false } +# NPoS +frame-election-provider-support = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false } +pallet-authority-discovery = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false } +pallet-authorship = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false } +pallet-bags-list = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false } +pallet-election-provider-multi-phase = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false } +pallet-fast-unstake = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false } +pallet-nomination-pools = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false } +pallet-nomination-pools-runtime-api = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false } +pallet-session = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false } +pallet-staking = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false } +pallet-staking-runtime-api = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false } +pallet-staking-reward-fn = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false } +pallet-staking-reward-curve = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false } +pallet-offences = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false } + sc-basic-authorship = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false } sc-cli = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false } sc-client-api = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false } sc-consensus = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false } sc-consensus-aura = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false } +sc-consensus-babe = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false } +sc-consensus-babe-rpc = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false } sc-consensus-grandpa = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false } sc-consensus-grandpa-rpc = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false } sc-chain-spec-derive = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false } @@ -166,11 +184,16 @@ sc-consensus-manual-seal = { git = "https://github.com/paritytech/polkadot-sdk.g sc-network-sync = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false } sp-api = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false } +sp-authority-discovery = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false } sp-arithmetic = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false } sp-block-builder = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false } sp-blockchain = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false } +sp-staking = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false } sp-consensus = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false } sp-consensus-aura = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false } +sp-consensus-babe = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false } +sp-consensus-slots = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false } +sp-npos-elections = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false } sp-consensus-grandpa = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false } sp-genesis-builder = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false } sp-core = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false } @@ -198,35 +221,38 @@ substrate-prometheus-endpoint = { git = "https://github.com/paritytech/polkadot- cumulus-primitives-proof-size-hostfunction = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false } +runtime-common = { package = "polkadot-runtime-common", git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2503-6", default-features = false } + # Frontier -fp-evm = { git = "https://github.com/opentensor/frontier", rev = "c591df98c524e1599c45f93cf4685248088ac014", default-features = false } -fp-rpc = { git = "https://github.com/opentensor/frontier", rev = "c591df98c524e1599c45f93cf4685248088ac014", default-features = false } -fp-self-contained = { git = "https://github.com/opentensor/frontier", rev = "c591df98c524e1599c45f93cf4685248088ac014", default-features = false } -fp-account = { git = "https://github.com/opentensor/frontier", rev = "c591df98c524e1599c45f93cf4685248088ac014", default-features = false } -fc-storage = { git = "https://github.com/opentensor/frontier", rev = "c591df98c524e1599c45f93cf4685248088ac014", default-features = false } -fc-db = { git = "https://github.com/opentensor/frontier", rev = "c591df98c524e1599c45f93cf4685248088ac014", default-features = false } -fc-consensus = { git = "https://github.com/opentensor/frontier", rev = "c591df98c524e1599c45f93cf4685248088ac014", default-features = false } -fp-consensus = { git = "https://github.com/opentensor/frontier", rev = "c591df98c524e1599c45f93cf4685248088ac014", default-features = false } -fp-dynamic-fee = { git = "https://github.com/opentensor/frontier", rev = "c591df98c524e1599c45f93cf4685248088ac014", default-features = false } -fc-api = { git = "https://github.com/opentensor/frontier", rev = "c591df98c524e1599c45f93cf4685248088ac014", default-features = false } -fc-rpc = { git = "https://github.com/opentensor/frontier", rev = "c591df98c524e1599c45f93cf4685248088ac014", default-features = false } -fc-rpc-core = { git = "https://github.com/opentensor/frontier", rev = "c591df98c524e1599c45f93cf4685248088ac014", default-features = false } -fc-aura = { git = "https://github.com/opentensor/frontier", rev = "c591df98c524e1599c45f93cf4685248088ac014", default-features = false } -fc-mapping-sync = { git = "https://github.com/opentensor/frontier", rev = "c591df98c524e1599c45f93cf4685248088ac014", default-features = false } -precompile-utils = { git = "https://github.com/opentensor/frontier", rev = "c591df98c524e1599c45f93cf4685248088ac014", default-features = false } +fp-evm = { git = "https://github.com/opentensor/frontier", rev = "830e61f370d88f7ace1c5a5659dd58db75a19844", default-features = false } +fp-rpc = { git = "https://github.com/opentensor/frontier", rev = "830e61f370d88f7ace1c5a5659dd58db75a19844", default-features = false } +fp-self-contained = { git = "https://github.com/opentensor/frontier", rev = "830e61f370d88f7ace1c5a5659dd58db75a19844", default-features = false } +fp-account = { git = "https://github.com/opentensor/frontier", rev = "830e61f370d88f7ace1c5a5659dd58db75a19844", default-features = false } +fc-storage = { git = "https://github.com/opentensor/frontier", rev = "830e61f370d88f7ace1c5a5659dd58db75a19844", default-features = false } +fc-db = { git = "https://github.com/opentensor/frontier", rev = "830e61f370d88f7ace1c5a5659dd58db75a19844", default-features = false } +fc-consensus = { git = "https://github.com/opentensor/frontier", rev = "830e61f370d88f7ace1c5a5659dd58db75a19844", default-features = false } +fp-consensus = { git = "https://github.com/opentensor/frontier", rev = "830e61f370d88f7ace1c5a5659dd58db75a19844", default-features = false } +fp-dynamic-fee = { git = "https://github.com/opentensor/frontier", rev = "830e61f370d88f7ace1c5a5659dd58db75a19844", default-features = false } +fc-api = { git = "https://github.com/opentensor/frontier", rev = "830e61f370d88f7ace1c5a5659dd58db75a19844", default-features = false } +fc-rpc = { git = "https://github.com/opentensor/frontier", rev = "830e61f370d88f7ace1c5a5659dd58db75a19844", default-features = false } +fc-rpc-core = { git = "https://github.com/opentensor/frontier", rev = "830e61f370d88f7ace1c5a5659dd58db75a19844", default-features = false } +fc-aura = { git = "https://github.com/opentensor/frontier", rev = "830e61f370d88f7ace1c5a5659dd58db75a19844", default-features = false } +fc-babe = { git = "https://github.com/opentensor/frontier", rev = "830e61f370d88f7ace1c5a5659dd58db75a19844", default-features = false } +fc-mapping-sync = { git = "https://github.com/opentensor/frontier", rev = "830e61f370d88f7ace1c5a5659dd58db75a19844", default-features = false } +precompile-utils = { git = "https://github.com/opentensor/frontier", rev = "830e61f370d88f7ace1c5a5659dd58db75a19844", default-features = false } # Frontier FRAME -pallet-base-fee = { git = "https://github.com/opentensor/frontier", rev = "c591df98c524e1599c45f93cf4685248088ac014", default-features = false } -pallet-dynamic-fee = { git = "https://github.com/opentensor/frontier", rev = "c591df98c524e1599c45f93cf4685248088ac014", default-features = false } -pallet-ethereum = { git = "https://github.com/opentensor/frontier", rev = "c591df98c524e1599c45f93cf4685248088ac014", default-features = false } -pallet-evm = { git = "https://github.com/opentensor/frontier", rev = "c591df98c524e1599c45f93cf4685248088ac014", default-features = false } -pallet-evm-precompile-dispatch = { git = "https://github.com/opentensor/frontier", rev = "c591df98c524e1599c45f93cf4685248088ac014", default-features = false } -pallet-evm-chain-id = { git = "https://github.com/opentensor/frontier", rev = "c591df98c524e1599c45f93cf4685248088ac014", default-features = false } -pallet-evm-precompile-modexp = { git = "https://github.com/opentensor/frontier", rev = "c591df98c524e1599c45f93cf4685248088ac014", default-features = false } -pallet-evm-precompile-sha3fips = { git = "https://github.com/opentensor/frontier", rev = "c591df98c524e1599c45f93cf4685248088ac014", default-features = false } -pallet-evm-precompile-simple = { git = "https://github.com/opentensor/frontier", rev = "c591df98c524e1599c45f93cf4685248088ac014", default-features = false } -pallet-evm-precompile-bn128 = { git = "https://github.com/opentensor/frontier", rev = "c591df98c524e1599c45f93cf4685248088ac014", default-features = false } -pallet-hotfix-sufficients = { git = "https://github.com/opentensor/frontier", rev = "c591df98c524e1599c45f93cf4685248088ac014", default-features = false } +pallet-base-fee = { git = "https://github.com/opentensor/frontier", rev = "830e61f370d88f7ace1c5a5659dd58db75a19844", default-features = false } +pallet-dynamic-fee = { git = "https://github.com/opentensor/frontier", rev = "830e61f370d88f7ace1c5a5659dd58db75a19844", default-features = false } +pallet-ethereum = { git = "https://github.com/opentensor/frontier", rev = "830e61f370d88f7ace1c5a5659dd58db75a19844", default-features = false } +pallet-evm = { git = "https://github.com/opentensor/frontier", rev = "830e61f370d88f7ace1c5a5659dd58db75a19844", default-features = false } +pallet-evm-precompile-dispatch = { git = "https://github.com/opentensor/frontier", rev = "830e61f370d88f7ace1c5a5659dd58db75a19844", default-features = false } +pallet-evm-chain-id = { git = "https://github.com/opentensor/frontier", rev = "830e61f370d88f7ace1c5a5659dd58db75a19844", default-features = false } +pallet-evm-precompile-modexp = { git = "https://github.com/opentensor/frontier", rev = "830e61f370d88f7ace1c5a5659dd58db75a19844", default-features = false } +pallet-evm-precompile-sha3fips = { git = "https://github.com/opentensor/frontier", rev = "830e61f370d88f7ace1c5a5659dd58db75a19844", default-features = false } +pallet-evm-precompile-simple = { git = "https://github.com/opentensor/frontier", rev = "830e61f370d88f7ace1c5a5659dd58db75a19844", default-features = false } +pallet-evm-precompile-bn128 = { git = "https://github.com/opentensor/frontier", rev = "830e61f370d88f7ace1c5a5659dd58db75a19844", default-features = false } +pallet-hotfix-sufficients = { git = "https://github.com/opentensor/frontier", rev = "830e61f370d88f7ace1c5a5659dd58db75a19844", default-features = false } #DRAND pallet-drand = { path = "pallets/drand", default-features = false } diff --git a/Dockerfile-localnet b/Dockerfile-localnet index d95a2f1a2c..82cf5759aa 100644 --- a/Dockerfile-localnet +++ b/Dockerfile-localnet @@ -29,23 +29,23 @@ ENV PATH="/root/.cargo/bin:${PATH}" RUN rustup toolchain install RUN rustup target add wasm32-unknown-unknown -## Build fast-blocks node +## Build fast-runtime node RUN ./scripts/localnet.sh --build-only -# Build non-fast-blocks +# Build non-fast-runtime RUN ./scripts/localnet.sh False --build-only # Verify the binaries was produced -RUN test -e /build/target/fast-blocks/release/node-subtensor -RUN test -e /build/target/non-fast-blocks/release/node-subtensor +RUN test -e /build/target/fast-runtime/release/node-subtensor +RUN test -e /build/target/non-fast-runtime/release/node-subtensor FROM $BASE_IMAGE AS subtensor-localnet # Copy binaries -COPY --from=builder /build/target/fast-blocks/release/node-subtensor target/fast-blocks/release/node-subtensor -RUN chmod +x target/fast-blocks/release/node-subtensor +COPY --from=builder /build/target/fast-runtime/release/node-subtensor target/fast-runtime/release/node-subtensor +RUN chmod +x target/fast-runtime/release/node-subtensor -COPY --from=builder /build/target/non-fast-blocks/release/node-subtensor target/non-fast-blocks/release/node-subtensor -RUN chmod +x target/non-fast-blocks/release/node-subtensor +COPY --from=builder /build/target/non-fast-runtime/release/node-subtensor target/non-fast-runtime/release/node-subtensor +RUN chmod +x target/non-fast-runtime/release/node-subtensor COPY --from=builder /build/snapshot.json /snapshot.json diff --git a/common/Cargo.toml b/common/Cargo.toml index b1b0f1bbf2..b4be88f01b 100644 --- a/common/Cargo.toml +++ b/common/Cargo.toml @@ -20,6 +20,7 @@ sp-runtime.workspace = true substrate-fixed.workspace = true subtensor-macros.workspace = true approx = { workspace = true, optional = true } +runtime-common = { workspace = true } [lints] workspace = true @@ -27,7 +28,7 @@ workspace = true [features] default = ["std"] approx = ["dep:approx"] -fast-blocks = [] +fast-runtime = [] std = [ "codec/std", "frame-support/std", @@ -36,4 +37,5 @@ std = [ "sp-core/std", "sp-runtime/std", "substrate-fixed/std", + "runtime-common/std" ] diff --git a/common/src/lib.rs b/common/src/lib.rs index 8a0093f01e..f8199b8a6e 100644 --- a/common/src/lib.rs +++ b/common/src/lib.rs @@ -5,6 +5,7 @@ use codec::{ Compact, CompactAs, Decode, DecodeWithMemTracking, Encode, Error as CodecError, MaxEncodedLen, }; use frame_support::pallet_prelude::*; +use runtime_common::prod_or_fast; use scale_info::TypeInfo; use serde::{Deserialize, Serialize}; use sp_runtime::{ @@ -207,12 +208,7 @@ pub mod time { /// slot_duration()`. /// /// Change this to adjust the block time. - #[cfg(not(feature = "fast-blocks"))] - pub const MILLISECS_PER_BLOCK: u64 = 12000; - - /// Fast blocks for development - #[cfg(feature = "fast-blocks")] - pub const MILLISECS_PER_BLOCK: u64 = 250; + pub const MILLISECS_PER_BLOCK: u64 = prod_or_fast!(12000, 250); // NOTE: Currently it is not possible to change the slot duration after the chain has started. // Attempting to do so will brick block production. diff --git a/evm-tests/src/config.ts b/evm-tests/src/config.ts index 1d12e3d584..4cc3b27608 100644 --- a/evm-tests/src/config.ts +++ b/evm-tests/src/config.ts @@ -1,7 +1,7 @@ export const ETH_LOCAL_URL = 'http://localhost:9944' export const SUB_LOCAL_URL = 'ws://localhost:9944' export const SS58_PREFIX = 42; -// set the tx timeout as 2 second when eable the fast-blocks feature. +// set the tx timeout as 2 second when eable the fast-runtime feature. export const TX_TIMEOUT = 3000; export const IED25519VERIFY_ADDRESS = "0x0000000000000000000000000000000000000402"; @@ -55,4 +55,4 @@ export const IBalanceTransferABI = [ export const IDISPATCH_ADDRESS = "0x0000000000000000000000000000000000000006"; -export const ISTORAGE_QUERY_ADDRESS = "0x0000000000000000000000000000000000000807"; \ No newline at end of file +export const ISTORAGE_QUERY_ADDRESS = "0x0000000000000000000000000000000000000807"; diff --git a/node/Cargo.toml b/node/Cargo.toml index 3696e78f21..09458410ff 100644 --- a/node/Cargo.toml +++ b/node/Cargo.toml @@ -20,6 +20,7 @@ targets = ["x86_64-unknown-linux-gnu"] name = "node-subtensor" [dependencies] +log.workspace = true async-trait.workspace = true clap = { workspace = true, features = ["derive"] } futures = { workspace = true, features = ["thread-pool"] } @@ -30,7 +31,11 @@ hex.workspace = true memmap2.workspace = true serde_json.workspace = true +sc-chain-spec-derive.workspace = true sc-cli.workspace = true +sc-consensus-babe.workspace = true +sp-consensus.workspace = true +sp-consensus-slots.workspace = true sp-core.workspace = true sc-executor.workspace = true sc-service.workspace = true @@ -42,12 +47,12 @@ sc-offchain.workspace = true sc-network.workspace = true sc-consensus-aura.workspace = true sp-consensus-aura.workspace = true -sp-consensus.workspace = true +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-derive.workspace = true sc-chain-spec.workspace = true sc-consensus-slots.workspace = true sc-client-api.workspace = true @@ -89,12 +94,14 @@ frame-benchmarking.workspace = true frame-benchmarking-cli.workspace = true # Needed for Frontier +fc-mapping-sync.workspace = true +fc-storage.workspace = true +fc-babe.workspace = true sc-consensus-manual-seal.workspace = true sc-network-sync.workspace = true substrate-prometheus-endpoint.workspace = true # Frontier -fc-storage.workspace = true fc-db.workspace = true fc-consensus.workspace = true fc-api.workspace = true @@ -102,7 +109,6 @@ fc-rpc = { workspace = true, features = ["rpc-binary-search-estimate"] } fc-rpc-core.workspace = true fp-rpc.workspace = true fc-aura.workspace = true -fc-mapping-sync.workspace = true fp-consensus.workspace = true num-traits = { workspace = true, features = ["std"] } @@ -118,9 +124,6 @@ pallet-subtensor-swap-runtime-api = { workspace = true, features = ["std"] } substrate-build-script-utils.workspace = true [features] -default = ["rocksdb", "sql", "txpool"] -fast-blocks = ["node-subtensor-runtime/fast-blocks"] -sql = ["fc-db/sql", "fc-mapping-sync/sql"] rocksdb = [ "sc-service/rocksdb", "fc-db/rocksdb", @@ -129,6 +132,12 @@ rocksdb = [ "frame-benchmarking-cli/rocksdb", "sc-cli/rocksdb", ] +default = ["rocksdb", "sql", "txpool"] +fast-runtime = [ + "node-subtensor-runtime/fast-runtime", + "subtensor-runtime-common/fast-runtime", +] +sql = ["fc-db/sql", "fc-mapping-sync/sql"] txpool = ["fc-rpc/txpool", "fc-rpc-core/txpool"] # Dependencies that are only required if runtime benchmarking should be build. diff --git a/node/src/cli.rs b/node/src/cli.rs index d9744d44df..e46c71857b 100644 --- a/node/src/cli.rs +++ b/node/src/cli.rs @@ -1,5 +1,14 @@ -use crate::ethereum::EthConfiguration; +use crate::{ + client::{FullBackend, FullClient}, + consensus::{AuraConsensus, BabeConsensus}, + ethereum::{EthConfiguration, FrontierBackend}, + service::new_chain_ops, +}; +use node_subtensor_runtime::opaque::Block; use sc_cli::RunCmd; +use sc_consensus::BasicQueue; +use sc_service::{Configuration, TaskManager}; +use std::sync::Arc; #[derive(Debug, clap::Parser)] pub struct Cli { @@ -13,6 +22,15 @@ pub struct Cli { #[arg(long, value_enum, ignore_case = true)] pub sealing: Option, + /// Whether to try Aura or Babe consensus on first start. + /// + /// After starting, the consensus used by the node will automatically + /// switch to whatever is required to continue validating / syncing. + /// + /// TODO: Remove this after the Babe transition has settled. + #[arg(long, value_enum, ignore_case = true, default_value_t=SupportedConsensusMechanism::default())] + pub initial_consensus: SupportedConsensusMechanism, + #[command(flatten)] pub eth: EthConfiguration, } @@ -63,3 +81,37 @@ pub enum Sealing { /// Seal when transaction is executed. Instant, } + +/// Supported consensus mechanisms. +#[derive(Copy, Clone, Debug, Default, clap::ValueEnum)] +pub enum SupportedConsensusMechanism { + // Babe + Babe, + /// Aura + #[default] + Aura, +} + +// Convinience methods for static dispatch of different service methods with +// different consensus mechanisms. +impl SupportedConsensusMechanism { + pub fn new_chain_ops( + &self, + config: &mut Configuration, + eth_config: &EthConfiguration, + ) -> Result< + ( + Arc, + Arc, + BasicQueue, + TaskManager, + FrontierBackend, + ), + sc_service::Error, + > { + match self { + SupportedConsensusMechanism::Aura => new_chain_ops::(config, eth_config), + SupportedConsensusMechanism::Babe => new_chain_ops::(config, eth_config), + } + } +} diff --git a/node/src/command.rs b/node/src/command.rs index f35664f8b0..eb261bedfa 100644 --- a/node/src/command.rs +++ b/node/src/command.rs @@ -1,13 +1,16 @@ +use std::sync::{Arc, atomic::AtomicBool}; + use crate::{ chain_spec, - cli::{Cli, Subcommand}, + cli::{Cli, Subcommand, SupportedConsensusMechanism}, + consensus::BabeConsensus, ethereum::db_config_dir, service, }; use fc_db::{DatabaseSource, kv::frontier_database_dir}; -use clap::{CommandFactory, FromArgMatches, parser::ValueSource}; -use futures::TryFutureExt; +use crate::consensus::AuraConsensus; +use clap::{ArgMatches, CommandFactory, FromArgMatches, parser::ValueSource}; use node_subtensor_runtime::Block; use sc_cli::SubstrateCli; use sc_service::{ @@ -70,7 +73,7 @@ pub fn run() -> sc_cli::Result<()> { let runner = cli.create_runner(cmd)?; runner.async_run(|mut config| { let (client, _, import_queue, task_manager, _) = - service::new_chain_ops(&mut config, &cli.eth)?; + cli.initial_consensus.new_chain_ops(&mut config, &cli.eth)?; Ok((cmd.run(client, import_queue), task_manager)) }) } @@ -78,7 +81,7 @@ pub fn run() -> sc_cli::Result<()> { let runner = cli.create_runner(cmd)?; runner.async_run(|mut config| { let (client, _, _, task_manager, _) = - service::new_chain_ops(&mut config, &cli.eth)?; + cli.initial_consensus.new_chain_ops(&mut config, &cli.eth)?; Ok((cmd.run(client, config.database), task_manager)) }) } @@ -86,7 +89,7 @@ pub fn run() -> sc_cli::Result<()> { let runner = cli.create_runner(cmd)?; runner.async_run(|mut config| { let (client, _, _, task_manager, _) = - service::new_chain_ops(&mut config, &cli.eth)?; + cli.initial_consensus.new_chain_ops(&mut config, &cli.eth)?; Ok((cmd.run(client, config.chain_spec), task_manager)) }) } @@ -94,7 +97,7 @@ pub fn run() -> sc_cli::Result<()> { let runner = cli.create_runner(cmd)?; runner.async_run(|mut config| { let (client, _, import_queue, task_manager, _) = - service::new_chain_ops(&mut config, &cli.eth)?; + cli.initial_consensus.new_chain_ops(&mut config, &cli.eth)?; Ok((cmd.run(client, import_queue), task_manager)) }) } @@ -148,7 +151,7 @@ pub fn run() -> sc_cli::Result<()> { let runner = cli.create_runner(cmd)?; runner.async_run(|mut config| { let (client, backend, _, task_manager, _) = - service::new_chain_ops(&mut config, &cli.eth)?; + cli.initial_consensus.new_chain_ops(&mut config, &cli.eth)?; let aux_revert = Box::new(move |client, _, blocks| { sc_consensus_grandpa::revert(client, blocks)?; Ok(()) @@ -177,7 +180,7 @@ pub fn run() -> sc_cli::Result<()> { } = crate::service::new_partial( &config, &cli.eth, - crate::service::build_manual_seal_import_queue, + Box::new(crate::service::build_manual_seal_import_queue), )?; // This switch needs to be in the client, since the client decides @@ -229,36 +232,107 @@ pub fn run() -> sc_cli::Result<()> { let runner = cli.create_runner(cmd)?; runner.sync_run(|config| cmd.run::(&config)) } + // Start with the initial consensus type asked. None => { - let runner = cli.create_runner(&cli.run)?; - runner.run_node_until_exit(|config| async move { - let mut config = override_default_heap_pages(config, 60_000); + let arg_matches = Cli::command().get_matches(); + let cli = Cli::from_args(); + match cli.initial_consensus { + SupportedConsensusMechanism::Babe => start_babe_service(&arg_matches), + SupportedConsensusMechanism::Aura => start_aura_service(&arg_matches), + } + } + } +} - // If the operator did **not** supply `--rpc-rate-limit`, disable the limiter. - if cli.run.rpc_params.rpc_rate_limit.is_none() { - config.rpc.rate_limit = None; - } - // If the operator did **not** supply `--rpc-max-subscriptions-per-connection` set to high value. - config.rpc.max_subs_per_conn = - match arg_matches.value_source("rpc_max_subscriptions_per_connection") { - Some(ValueSource::CommandLine) => { - cli.run.rpc_params.rpc_max_subscriptions_per_connection - } - _ => 10000, - }; - // If the operator did **not** supply `--rpc-max-connections` set to high value. - config.rpc.max_connections = match arg_matches.value_source("rpc_max_connections") { - Some(ValueSource::CommandLine) => cli.run.rpc_params.rpc_max_connections, - _ => 10000, - }; - service::build_full(config, cli.eth, cli.sealing) - .map_err(Into::into) - .await - }) +fn start_babe_service(arg_matches: &ArgMatches) -> Result<(), sc_cli::Error> { + let cli = Cli::from_arg_matches(arg_matches).expect("Bad arg_matches"); + let runner = cli.create_runner(&cli.run)?; + match runner.run_node_until_exit(|config| async move { + let config = customise_config(arg_matches, config); + service::build_full::(config, cli.eth, cli.sealing, None).await + }) { + Ok(_) => Ok(()), + Err(e) => { + // Handle node needs to be in Aura mode. + if matches!( + e, + sc_service::Error::Client(sp_blockchain::Error::VersionInvalid(ref msg)) + if msg == "Unsupported or invalid BabeApi version" + ) { + log::info!( + "💡 Chain is using Aura consensus. Switching to Aura service until Babe block is detected.", + ); + start_aura_service(arg_matches) + // Handle Aura service still has DB lock. This never has been observed to take more + // than 1s to drop. + } else if matches!(e, sc_service::Error::Client(sp_blockchain::Error::Backend(ref msg)) + if msg.starts_with("IO error: lock hold by current process")) + { + log::info!("Failed to aquire DB lock, trying again in 1s..."); + std::thread::sleep(std::time::Duration::from_secs(1)); + return start_babe_service(arg_matches); + // Unknown error, return it. + } else { + Err(e.into()) + } + } + } +} + +fn start_aura_service(arg_matches: &ArgMatches) -> Result<(), sc_cli::Error> { + let cli = Cli::from_arg_matches(arg_matches).expect("Bad arg_matches"); + let runner = cli.create_runner(&cli.run)?; + + // Unlike when the Babe node fails to build due to missing BabeApi in the runtime, + // there is no way to detect the exit reason for the Aura node when it encounters a Babe block. + // + // Passing this atomic bool is a hacky solution, allowing the node to set it to true to indicate + // a Babe service should be spawned on exit instead of a regular shutdown. + let babe_switch = Arc::new(AtomicBool::new(false)); + let babe_switch_clone = babe_switch.clone(); + match runner.run_node_until_exit(|config| async move { + let config = customise_config(arg_matches, config); + service::build_full::(config, cli.eth, cli.sealing, Some(babe_switch_clone)) + .await + }) { + Ok(()) => Ok(()), + Err(e) => { + if babe_switch.load(std::sync::atomic::Ordering::Relaxed) { + start_babe_service(arg_matches) + } else { + Err(e.into()) + } } } } +fn customise_config(arg_matches: &ArgMatches, config: Configuration) -> Configuration { + let cli = Cli::from_arg_matches(arg_matches).expect("Bad arg_matches"); + + let mut config = override_default_heap_pages(config, 60_000); + + // If the operator did **not** supply `--rpc-rate-limit`, disable the limiter. + if cli.run.rpc_params.rpc_rate_limit.is_none() { + config.rpc.rate_limit = None; + } + + // If the operator did **not** supply `--rpc-max-subscriptions-per-connection` set to high value. + config.rpc.max_subs_per_conn = match arg_matches + .value_source("rpc-max-subscriptions-per-connection") + { + Some(ValueSource::CommandLine) => cli.run.rpc_params.rpc_max_subscriptions_per_connection, + _ => 10000, + }; + + // If the operator did **not** supply `--rpc-max-connections` set to high value. + config.rpc.max_connections = match arg_matches.value_source("rpc-max-connections") { + Some(ValueSource::CommandLine) => cli.run.rpc_params.rpc_max_connections, + _ => 10000, + }; + + config +} + /// Override default heap pages fn override_default_heap_pages(config: Configuration, pages: u64) -> Configuration { Configuration { diff --git a/node/src/conditional_evm_block_import.rs b/node/src/conditional_evm_block_import.rs new file mode 100644 index 0000000000..b6ba445c1f --- /dev/null +++ b/node/src/conditional_evm_block_import.rs @@ -0,0 +1,70 @@ +use sc_consensus::{BlockCheckParams, BlockImport, BlockImportParams, ImportResult}; +use sp_consensus::Error as ConsensusError; +use sp_runtime::traits::{Block as BlockT, Header}; +use std::marker::PhantomData; + +pub struct ConditionalEVMBlockImport { + inner: I, + frontier_block_import: F, + _marker: PhantomData, +} + +impl Clone for ConditionalEVMBlockImport +where + B: BlockT, + I: Clone + BlockImport, + F: Clone + BlockImport, +{ + fn clone(&self) -> Self { + ConditionalEVMBlockImport { + inner: self.inner.clone(), + frontier_block_import: self.frontier_block_import.clone(), + _marker: PhantomData, + } + } +} + +impl ConditionalEVMBlockImport +where + B: BlockT, + I: BlockImport, + I::Error: Into, + F: BlockImport, + F::Error: Into, +{ + pub fn new(inner: I, frontier_block_import: F) -> Self { + Self { + inner, + frontier_block_import, + _marker: PhantomData, + } + } +} + +#[async_trait::async_trait] +impl BlockImport for ConditionalEVMBlockImport +where + B: BlockT, + I: BlockImport + Send + Sync, + I::Error: Into, + F: BlockImport + Send + Sync, + F::Error: Into, +{ + type Error = ConsensusError; + + async fn check_block(&self, block: BlockCheckParams) -> Result { + self.inner.check_block(block).await.map_err(Into::into) + } + + async fn import_block(&self, block: BlockImportParams) -> Result { + // 4345556 - mainnet runtime upgrade block with Frontier + if *block.header.number() < 4345557u32.into() { + self.inner.import_block(block).await.map_err(Into::into) + } else { + self.frontier_block_import + .import_block(block) + .await + .map_err(Into::into) + } + } +} diff --git a/node/src/consensus/aura_consensus.rs b/node/src/consensus/aura_consensus.rs new file mode 100644 index 0000000000..b8f4326fdf --- /dev/null +++ b/node/src/consensus/aura_consensus.rs @@ -0,0 +1,218 @@ +use crate::consensus::{ConsensusMechanism, StartAuthoringParams}; +use crate::{ + client::{FullBackend, FullClient}, + conditional_evm_block_import::ConditionalEVMBlockImport, + ethereum::EthConfiguration, + service::{BIQ, FullSelectChain, GrandpaBlockImport}, +}; +use fc_consensus::FrontierBlockImport; +use jsonrpsee::tokio; +use node_subtensor_runtime::opaque::Block; +use sc_client_api::{AuxStore, BlockOf}; +use sc_consensus::{BlockImport, BoxBlockImport}; +use sc_consensus_grandpa::BlockNumberOps; +use sc_consensus_slots::{BackoffAuthoringBlocksStrategy, InherentDataProviderExt}; +use sc_service::{Configuration, TaskManager}; +use sc_telemetry::TelemetryHandle; +use sc_transaction_pool::TransactionPoolHandle; +use sp_api::ProvideRuntimeApi; +use sp_blockchain::{HeaderBackend, HeaderMetadata}; +use sp_consensus::{Environment, Proposer, SelectChain, SyncOracle}; +use sp_consensus_aura::sr25519::AuthorityId; +use sp_consensus_aura::{AuraApi, sr25519::AuthorityPair as AuraPair}; +use sp_consensus_slots::SlotDuration; +use sp_inherents::CreateInherentDataProviders; +use sp_keystore::KeystorePtr; +use sp_runtime::traits::NumberFor; +use std::{error::Error, sync::Arc}; + +pub struct AuraConsensus; + +impl ConsensusMechanism for AuraConsensus { + type InherentDataProviders = ( + sp_consensus_aura::inherents::InherentDataProvider, + sp_timestamp::InherentDataProvider, + ); + + fn start_authoring( + self, + task_manager: &mut TaskManager, + params: StartAuthoringParams, + ) -> Result<(), sp_consensus::Error> + where + C: ProvideRuntimeApi + + BlockOf + + AuxStore + + HeaderBackend + + HeaderMetadata + + Send + + Sync + + 'static, + C::Api: AuraApi, + SC: SelectChain + 'static, + I: BlockImport + Send + Sync + 'static, + PF: Environment + Send + Sync + 'static, + PF::Proposer: Proposer, + SO: SyncOracle + Send + Sync + Clone + 'static, + L: sc_consensus::JustificationSyncLink + 'static, + CIDP: CreateInherentDataProviders + Send + Sync + 'static, + CIDP::InherentDataProviders: InherentDataProviderExt + Send, + BS: BackoffAuthoringBlocksStrategy> + Send + Sync + 'static, + Error: std::error::Error + Send + From + From + 'static, + { + let aura = sc_consensus_aura::start_aura::( + sc_consensus_aura::StartAuraParams { + slot_duration: params.slot_duration, + client: params.client, + select_chain: params.select_chain, + block_import: params.block_import, + proposer_factory: params.proposer_factory, + sync_oracle: params.sync_oracle, + justification_sync_link: params.justification_sync_link, + create_inherent_data_providers: params.create_inherent_data_providers, + force_authoring: params.force_authoring, + backoff_authoring_blocks: params.backoff_authoring_blocks, + keystore: params.keystore, + block_proposal_slot_portion: params.block_proposal_slot_portion, + max_block_proposal_slot_portion: params.max_block_proposal_slot_portion, + telemetry: params.telemetry, + compatibility_mode: Default::default(), + }, + )?; + + // the AURA authoring task is considered essential, i.e. if it + // fails we take down the service with it. + task_manager + .spawn_essential_handle() + .spawn_blocking("aura", Some("block-authoring"), aura); + + Ok(()) + } + + fn frontier_consensus_data_provider( + client: Arc, + ) -> Result>, sp_blockchain::Error> { + Ok(Box::new(fc_aura::AuraConsensusDataProvider::new(client))) + } + + fn create_inherent_data_providers( + slot_duration: SlotDuration, + ) -> Result> { + let current = sp_timestamp::InherentDataProvider::from_system_time(); + let next_slot = current + .timestamp() + .as_millis() + .saturating_add(slot_duration.as_millis()); + let timestamp = sp_timestamp::InherentDataProvider::new(next_slot.into()); + let slot = + sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_slot_duration( + *timestamp, + slot_duration, + ); + Ok((slot, timestamp)) + } + + fn new() -> Self { + Self {} + } + + fn build_biq(&mut self) -> Result + where + NumberFor: BlockNumberOps, + { + let build_import_queue = Box::new( + move |client: Arc, + _backend: Arc, + config: &Configuration, + _eth_config: &EthConfiguration, + task_manager: &TaskManager, + telemetry: Option, + grandpa_block_import: GrandpaBlockImport, + _transaction_pool: Arc>| { + let conditional_block_import = ConditionalEVMBlockImport::new( + grandpa_block_import.clone(), + FrontierBlockImport::new(grandpa_block_import.clone(), client.clone()), + ); + + let slot_duration = sc_consensus_aura::slot_duration(&*client)?; + let create_inherent_data_providers = move |_, ()| async move { + let timestamp = sp_timestamp::InherentDataProvider::from_system_time(); + let slot = + sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_slot_duration( + *timestamp, + slot_duration, + ); + Ok((slot, timestamp)) + }; + + let import_queue = super::aura_wrapped_import_queue::import_queue( + sc_consensus_aura::ImportQueueParams { + block_import: conditional_block_import.clone(), + justification_import: Some(Box::new(grandpa_block_import.clone())), + client, + create_inherent_data_providers, + spawner: &task_manager.spawn_essential_handle(), + registry: config.prometheus_registry(), + check_for_equivocation: Default::default(), + telemetry, + compatibility_mode: sc_consensus_aura::CompatibilityMode::None, + }, + ) + .map_err::(Into::into)?; + + Ok(( + import_queue, + Box::new(conditional_block_import) as BoxBlockImport, + )) + }, + ); + + Ok(build_import_queue) + } + + fn slot_duration(&self, client: &FullClient) -> Result { + sc_consensus_aura::slot_duration(client).map_err(Into::into) + } + + fn spawn_essential_handles( + &self, + task_manager: &mut TaskManager, + client: Arc, + triggered: Option>, + ) -> Result<(), sc_service::Error> { + let client_clone = client.clone(); + let triggered_clone = triggered.clone(); + let slot_duration = self.slot_duration(&client)?; + task_manager.spawn_essential_handle().spawn( + "babe-switch", + None, + Box::pin(async move { + let client = client_clone; + let triggered = triggered_clone; + loop { + // Check if the runtime is Babe once per block. + if let Ok(c) = sc_consensus_babe::configuration(&*client) { + if !c.authorities.is_empty() { + log::info!("Babe runtime detected! Intentionally failing the essential handle `babe-switch` to trigger switch to Babe service."); + if let Some(triggered) = triggered { + triggered.store(true, std::sync::atomic::Ordering::SeqCst); + }; + break; + } + }; + tokio::time::sleep(slot_duration.as_duration()).await; + } + })); + Ok(()) + } + + fn rpc_methods( + &self, + _client: Arc, + _keystore: KeystorePtr, + _select_chain: FullSelectChain, + ) -> Result, sc_service::Error> { + // Aura requires no special RPC methods. + Ok(Default::default()) + } +} diff --git a/node/src/consensus/aura_wrapped_import_queue.rs b/node/src/consensus/aura_wrapped_import_queue.rs new file mode 100644 index 0000000000..c6433d8dd6 --- /dev/null +++ b/node/src/consensus/aura_wrapped_import_queue.rs @@ -0,0 +1,136 @@ +use sc_client_api::AuxStore; +use sc_client_api::BlockOf; +use sc_client_api::UsageProvider; +use sc_consensus::BlockImport; +use sc_consensus::BlockImportParams; +use sc_consensus::Verifier; +use sc_consensus::{BasicQueue, DefaultImportQueue}; +use sc_consensus_aura::AuraVerifier; +use sc_consensus_aura::CheckForEquivocation; +use sc_consensus_aura::ImportQueueParams; +use sc_consensus_slots::InherentDataProviderExt; +use sc_telemetry::TelemetryHandle; +use sp_api::ApiExt; +use sp_api::ProvideRuntimeApi; +use sp_block_builder::BlockBuilder as BlockBuilderApi; +use sp_blockchain::HeaderBackend; +use sp_consensus::error::Error as ConsensusError; +use sp_consensus_aura::AuraApi; +use sp_consensus_aura::sr25519::AuthorityId; +use sp_consensus_aura::sr25519::AuthorityPair; +use sp_consensus_babe::BABE_ENGINE_ID; +use sp_inherents::CreateInherentDataProviders; +use sp_runtime::Digest; +use sp_runtime::DigestItem; +use sp_runtime::traits::NumberFor; +use sp_runtime::traits::{Block as BlockT, Header as HeaderT}; +use std::sync::Arc; + +/// A wrapped Aura verifier which will stall verification if it encounters a +/// Babe block, rather than error out. +/// +/// This is required to prevent rapid validation failure and subsequent +/// re-fetching of the same block from peers, which triggers the peers to +/// blacklist the offending node and refuse to connect with them until they +/// are restarted +struct AuraWrappedVerifier { + inner: AuraVerifier, + _phantom: std::marker::PhantomData, +} + +impl AuraWrappedVerifier { + pub fn new( + client: Arc, + create_inherent_data_providers: CIDP, + telemetry: Option, + check_for_equivocation: CheckForEquivocation, + compatibility_mode: sc_consensus_aura::CompatibilityMode, + ) -> Self { + let verifier_params = sc_consensus_aura::BuildVerifierParams:: { + client, + create_inherent_data_providers, + telemetry, + check_for_equivocation, + compatibility_mode, + }; + let verifier = + sc_consensus_aura::build_verifier::(verifier_params); + + AuraWrappedVerifier { + inner: verifier, + _phantom: std::marker::PhantomData, + } + } +} + +#[async_trait::async_trait] +impl Verifier for AuraWrappedVerifier> +where + C: ProvideRuntimeApi + Send + Sync + sc_client_api::backend::AuxStore, + C::Api: BlockBuilderApi + AuraApi + ApiExt, + CIDP: CreateInherentDataProviders + Send + Sync, + CIDP::InherentDataProviders: InherentDataProviderExt + Send + Sync, +{ + async fn verify(&self, block: BlockImportParams) -> Result, String> { + let number: NumberFor = *block.post_header().number(); + log::debug!("Verifying block: {:?}", number); + if is_babe_digest(block.header.digest()) { + // TODO: Use a BabeVerifier to verify Babe blocks. This will + // prevent rapid validation failure and subsequent re-fetching + // of the same block from peers, which triggers the peers to + // blacklist the offending node and refuse to connect with them until they + // are restarted. + // + // Unfortunately, BabeVerifier construction logic is NOT public outside of + // its crate in vanilla Polkadot SDK, so we are unable to use it until we + // migrate to our Polkadot SDK fork. + self.inner.verify(block).await + } else { + self.inner.verify(block).await + } + } +} + +/// Start an import queue for the Aura consensus algorithm. +pub fn import_queue( + params: ImportQueueParams, +) -> Result, sp_consensus::Error> +where + B: BlockT, + C::Api: BlockBuilderApi + AuraApi + ApiExt, + C: 'static + + ProvideRuntimeApi + + BlockOf + + Send + + Sync + + AuxStore + + UsageProvider + + HeaderBackend, + I: BlockImport + Send + Sync + 'static, + S: sp_core::traits::SpawnEssentialNamed, + CIDP: CreateInherentDataProviders + Sync + Send + 'static, + CIDP::InherentDataProviders: InherentDataProviderExt + Send + Sync, +{ + let verifier = AuraWrappedVerifier::>::new( + params.client, + params.create_inherent_data_providers, + params.telemetry, + params.check_for_equivocation, + params.compatibility_mode, + ); + + Ok(BasicQueue::new( + verifier, + Box::new(params.block_import), + params.justification_import, + params.spawner, + params.registry, + )) +} + +fn is_babe_digest(digest: &Digest) -> bool { + digest + .logs() + .iter() + .any(|d| matches!(d, DigestItem::PreRuntime(engine_id, _) if engine_id == &BABE_ENGINE_ID)) +} diff --git a/node/src/consensus/babe_consensus.rs b/node/src/consensus/babe_consensus.rs new file mode 100644 index 0000000000..723bc7f7b7 --- /dev/null +++ b/node/src/consensus/babe_consensus.rs @@ -0,0 +1,231 @@ +use crate::consensus::ConsensusMechanism; +use crate::consensus::StartAuthoringParams; +use crate::{ + client::{FullBackend, FullClient}, + conditional_evm_block_import::ConditionalEVMBlockImport, + ethereum::EthConfiguration, + service::{BIQ, FullSelectChain, GrandpaBlockImport}, +}; +use fc_consensus::FrontierBlockImport; +use jsonrpsee::Methods; +use node_subtensor_runtime::opaque::Block; +use sc_client_api::{AuxStore, BlockOf}; +use sc_consensus::{BlockImport, BoxBlockImport}; +use sc_consensus_babe::{BabeLink, BabeWorkerHandle}; +use sc_consensus_babe_rpc::{Babe, BabeApiServer}; +use sc_consensus_grandpa::BlockNumberOps; +use sc_consensus_slots::{BackoffAuthoringBlocksStrategy, InherentDataProviderExt}; +use sc_service::{Configuration, TaskManager}; +use sc_telemetry::TelemetryHandle; +use sc_transaction_pool::TransactionPoolHandle; +use sc_transaction_pool_api::OffchainTransactionPoolFactory; +use sp_api::ProvideRuntimeApi; +use sp_blockchain::{HeaderBackend, HeaderMetadata}; +use sp_consensus::{Environment, Proposer, SelectChain, SyncOracle}; +use sp_consensus_aura::AuraApi; +use sp_consensus_aura::sr25519::AuthorityId; +use sp_consensus_babe::BabeApi; +use sp_consensus_slots::SlotDuration; +use sp_inherents::CreateInherentDataProviders; +use sp_keystore::KeystorePtr; +use sp_runtime::traits::NumberFor; +use std::{error::Error, sync::Arc}; + +pub struct BabeConsensus { + babe_link: Option>, + babe_worker_handle: Option>, +} + +impl ConsensusMechanism for BabeConsensus { + type InherentDataProviders = ( + sp_consensus_babe::inherents::InherentDataProvider, + sp_timestamp::InherentDataProvider, + ); + + fn start_authoring( + self, + task_manager: &mut TaskManager, + params: StartAuthoringParams, + ) -> Result<(), sp_consensus::Error> + where + C: ProvideRuntimeApi + + BlockOf + + AuxStore + + HeaderBackend + + HeaderMetadata + + Send + + Sync + + 'static, + C::Api: AuraApi + BabeApi, + SC: SelectChain + 'static, + I: BlockImport + Send + Sync + 'static, + PF: Environment + Send + Sync + 'static, + PF::Proposer: Proposer, + SO: SyncOracle + Send + Sync + Clone + 'static, + L: sc_consensus::JustificationSyncLink + 'static, + CIDP: CreateInherentDataProviders + Send + Sync + 'static, + CIDP::InherentDataProviders: InherentDataProviderExt + Send, + BS: BackoffAuthoringBlocksStrategy> + Send + Sync + 'static, + Error: std::error::Error + Send + From + From + 'static, + { + let babe = sc_consensus_babe::start_babe::( + sc_consensus_babe::BabeParams { + keystore: params.keystore, + client: params.client, + select_chain: params.select_chain, + env: params.proposer_factory, + block_import: params.block_import, + sync_oracle: params.sync_oracle, + justification_sync_link: params.justification_sync_link, + create_inherent_data_providers: params.create_inherent_data_providers, + force_authoring: params.force_authoring, + backoff_authoring_blocks: params.backoff_authoring_blocks, + babe_link: self + .babe_link + .expect("Must build the import queue before starting authoring."), + block_proposal_slot_portion: params.block_proposal_slot_portion, + max_block_proposal_slot_portion: params.max_block_proposal_slot_portion, + telemetry: params.telemetry, + }, + )?; + + // the BABE authoring task is considered essential, i.e. if it + // fails we take down the service with it. + task_manager.spawn_essential_handle().spawn_blocking( + "babe-proposer", + Some("block-authoring"), + babe, + ); + + Ok(()) + } + + fn frontier_consensus_data_provider( + client: Arc, + ) -> Result>, sp_blockchain::Error> { + Ok(Box::new(fc_babe::BabeConsensusDataProvider::new(client)?)) + } + + fn create_inherent_data_providers( + slot_duration: SlotDuration, + ) -> Result> { + let timestamp = sp_timestamp::InherentDataProvider::from_system_time(); + let slot = + sp_consensus_babe::inherents::InherentDataProvider::from_timestamp_and_slot_duration( + *timestamp, + slot_duration, + ); + Ok((slot, timestamp)) + } + + fn new() -> Self { + Self { + babe_link: None, + babe_worker_handle: None, + } + } + + fn build_biq(&mut self) -> Result + where + NumberFor: BlockNumberOps, + { + let build_import_queue = Box::new( + move |client: Arc, + backend: Arc, + config: &Configuration, + _eth_config: &EthConfiguration, + task_manager: &TaskManager, + telemetry: Option, + grandpa_block_import: GrandpaBlockImport, + transaction_pool: Arc>| { + let (babe_import, babe_link) = sc_consensus_babe::block_import( + sc_consensus_babe::configuration(&*client)?, + grandpa_block_import.clone(), + client.clone(), + )?; + + let conditional_block_import = ConditionalEVMBlockImport::new( + babe_import.clone(), + FrontierBlockImport::new(babe_import.clone(), client.clone()), + ); + + let slot_duration = babe_link.config().slot_duration(); + let create_inherent_data_providers = move |_, ()| async move { + let timestamp = sp_timestamp::InherentDataProvider::from_system_time(); + let slot = + sp_consensus_babe::inherents::InherentDataProvider::from_timestamp_and_slot_duration( + *timestamp, + slot_duration, + ); + Ok((slot, timestamp)) + }; + + let (import_queue, babe_worker_handle) = + sc_consensus_babe::import_queue(sc_consensus_babe::ImportQueueParams { + link: babe_link.clone(), + block_import: conditional_block_import.clone(), + justification_import: Some(Box::new(grandpa_block_import)), + client, + select_chain: sc_consensus::LongestChain::new(backend.clone()), + create_inherent_data_providers, + spawner: &task_manager.spawn_essential_handle(), + registry: config.prometheus_registry(), + telemetry, + offchain_tx_pool_factory: OffchainTransactionPoolFactory::new( + transaction_pool, + ), + })?; + + self.babe_link = Some(babe_link); + self.babe_worker_handle = Some(babe_worker_handle); + Ok((import_queue, Box::new(babe_import) as BoxBlockImport)) + }, + ); + + Ok(build_import_queue) + } + + fn slot_duration(&self, _client: &FullClient) -> Result { + if let Some(ref babe_link) = self.babe_link { + Ok(babe_link.config().slot_duration()) + } else { + Err(sc_service::Error::Other( + "Babe link not initialized. Ensure that the import queue has been built before calling slot_duration.".to_string() + )) + } + } + + fn spawn_essential_handles( + &self, + _task_manager: &mut TaskManager, + _client: Arc, + _triggered: Option>, + ) -> Result<(), sc_service::Error> { + // No additional Babe handles required. + Ok(()) + } + + fn rpc_methods( + &self, + client: Arc, + keystore: KeystorePtr, + select_chain: FullSelectChain, + ) -> Result, sc_service::Error> { + if let Some(ref babe_worker_handle) = self.babe_worker_handle { + Ok(vec![ + Babe::new( + client.clone(), + babe_worker_handle.clone(), + keystore, + select_chain, + ) + .into_rpc() + .into(), + ]) + } else { + Err(sc_service::Error::Other( + "Babe link not initialized. Ensure that the import queue has been built before calling slot_duration.".to_string() + )) + } + } +} diff --git a/node/src/consensus/consensus_mechanism.rs b/node/src/consensus/consensus_mechanism.rs new file mode 100644 index 0000000000..d5efb642b3 --- /dev/null +++ b/node/src/consensus/consensus_mechanism.rs @@ -0,0 +1,136 @@ +use jsonrpsee::Methods; +use node_subtensor_runtime::opaque::Block; +use sc_client_api::AuxStore; +use sc_client_api::BlockOf; +use sc_consensus::BlockImport; +use sc_consensus_aura::AuraApi; +use sc_consensus_slots::BackoffAuthoringBlocksStrategy; +use sc_consensus_slots::InherentDataProviderExt; +use sc_consensus_slots::SlotProportion; +use sc_service::{TaskManager, error::Error as ServiceError}; +use sc_telemetry::TelemetryHandle; +use sp_api::ProvideRuntimeApi; +use sp_blockchain::HeaderBackend; +use sp_blockchain::HeaderMetadata; +use sp_consensus::Proposer; +use sp_consensus::SyncOracle; +use sp_consensus::{Environment, SelectChain}; +use sp_consensus_aura::sr25519::AuthorityId as AuraAuthorityId; +use sp_consensus_babe::BabeApi; +use sp_consensus_slots::SlotDuration; +use sp_inherents::CreateInherentDataProviders; +use sp_keystore::KeystorePtr; +use sp_runtime::traits::NumberFor; +use std::sync::Arc; +use std::sync::atomic::AtomicBool; + +use crate::client::FullClient; +use crate::service::BIQ; +use crate::service::FullSelectChain; + +pub struct StartAuthoringParams { + /// The duration of a slot. + pub slot_duration: SlotDuration, + /// The client to interact with the chain. + pub client: Arc, + /// A select chain implementation to select the best block. + pub select_chain: SC, + /// The block import. + pub block_import: I, + /// The proposer factory to build proposer instances. + pub proposer_factory: PF, + /// The sync oracle that can give us the current sync status. + pub sync_oracle: SO, + /// Hook into the sync module to control the justification sync process. + pub justification_sync_link: L, + /// Something that can create the inherent data providers. + pub create_inherent_data_providers: CIDP, + /// Should we force the authoring of blocks? + pub force_authoring: bool, + /// The backoff strategy when we miss slots. + pub backoff_authoring_blocks: Option, + /// The keystore used by the node. + pub keystore: KeystorePtr, + /// The proportion of the slot dedicated to proposing. + /// + /// The block proposing will be limited to this proportion of the slot from the starting of the + /// slot. However, the proposing can still take longer when there is some lenience factor + /// applied, because there were no blocks produced for some slots. + pub block_proposal_slot_portion: SlotProportion, + /// The maximum proportion of the slot dedicated to proposing with any lenience factor applied + /// due to no blocks being produced. + pub max_block_proposal_slot_portion: Option, + /// Telemetry instance used to report telemetry metrics. + pub telemetry: Option, +} + +/// All consensus mechanism specific node logic should be covered by this trait, +/// so files like service.rs and rpc.rs can be generic over consensus mechanisms. +pub trait ConsensusMechanism { + /// IDPs inserted into the block by the ConsensusMechanism. + type InherentDataProviders: sp_inherents::InherentDataProvider + + sc_consensus_slots::InherentDataProviderExt + + 'static; + + /// Creates a new instance of the ConsensusMechanism. + fn new() -> Self; + + /// Builds a `BIQ` that uses the ConsensusMechanism. + fn build_biq(&mut self) -> Result; + + /// Returns the slot duration. + fn slot_duration(&self, client: &FullClient) -> Result; + + /// Creates IDPs for the consensus mechanism. + fn create_inherent_data_providers( + slot_duration: SlotDuration, + ) -> Result>; + + /// Creates the frontier consensus data provider with this mechanism. + fn frontier_consensus_data_provider( + client: Arc, + ) -> Result>, sp_blockchain::Error>; + + /// Starts authoring process for the consensus mechanism. + fn start_authoring( + self, + task_manager: &mut TaskManager, + params: StartAuthoringParams, + ) -> Result<(), sp_consensus::Error> + where + C: ProvideRuntimeApi + + BlockOf + + AuxStore + + HeaderBackend + + HeaderMetadata + + Send + + Sync + + 'static, + C::Api: AuraApi + BabeApi, + SC: SelectChain + 'static, + I: BlockImport + Send + Sync + 'static, + PF: Environment + Send + Sync + 'static, + PF::Proposer: Proposer, + SO: SyncOracle + Send + Sync + Clone + 'static, + L: sc_consensus::JustificationSyncLink + 'static, + CIDP: CreateInherentDataProviders + Send + Sync + 'static, + CIDP::InherentDataProviders: InherentDataProviderExt + Send, + BS: BackoffAuthoringBlocksStrategy> + Send + Sync + 'static, + Error: std::error::Error + Send + From + From + 'static; + + /// Spawns any consensus mechanism specific essential handles. + fn spawn_essential_handles( + &self, + task_manager: &mut TaskManager, + client: Arc, + triggered: Option>, + ) -> Result<(), ServiceError>; + + /// Returns any consensus mechanism specific rpc methods to register. + fn rpc_methods( + &self, + client: Arc, + keystore: KeystorePtr, + select_chain: FullSelectChain, + ) -> Result, sc_service::Error>; +} diff --git a/node/src/consensus/mod.rs b/node/src/consensus/mod.rs new file mode 100644 index 0000000000..98dc2aa28f --- /dev/null +++ b/node/src/consensus/mod.rs @@ -0,0 +1,9 @@ +mod aura_consensus; +mod aura_wrapped_import_queue; +mod babe_consensus; +mod consensus_mechanism; + +pub use aura_consensus::AuraConsensus; +pub use babe_consensus::BabeConsensus; +pub use consensus_mechanism::ConsensusMechanism; +pub use consensus_mechanism::StartAuthoringParams; diff --git a/node/src/ethereum.rs b/node/src/ethereum.rs index 9179f30598..854826f18e 100644 --- a/node/src/ethereum.rs +++ b/node/src/ethereum.rs @@ -1,5 +1,4 @@ -use fc_aura::AuraConsensusDataProvider; -pub use fc_consensus::FrontierBlockImport; +use crate::rpc::EthDeps; use fc_rpc::{ Debug, DebugApiServer, Eth, EthApiServer, EthConfig, EthDevSigner, EthFilter, EthFilterApiServer, EthPubSub, EthPubSubApiServer, EthSigner, EthTask, Net, NetApiServer, Web3, @@ -28,7 +27,6 @@ use std::{ }; use crate::client::{FullBackend, FullClient}; -use crate::rpc::EthDeps; pub type FrontierBackend = fc_db::Backend; @@ -198,6 +196,7 @@ pub async fn spawn_frontier_tasks( fn extend_rpc_aet_api( io: &mut RpcModule<()>, deps: &EthDeps, + pending_consensus_data_provider: Option>>, ) -> Result<(), Box> where P: TransactionPool< @@ -233,9 +232,7 @@ where deps.execute_gas_limit_multiplier, deps.forced_parent_hashes.clone(), deps.pending_create_inherent_data_providers.clone(), - Some(Box::new(AuraConsensusDataProvider::new( - deps.client.clone(), - ))), + pending_consensus_data_provider, ) .replace_config::() .into_rpc(), @@ -393,6 +390,7 @@ pub fn create_eth( fc_mapping_sync::EthereumBlockNotification, >, >, + pending_consensus_data_provider: Option>>, ) -> Result, Box> where P: TransactionPool< @@ -406,7 +404,7 @@ where CIDP: CreateInherentDataProviders + Send + Clone + 'static, EC: EthConfig, { - extend_rpc_aet_api::(&mut io, &deps)?; + extend_rpc_aet_api::(&mut io, &deps, pending_consensus_data_provider)?; extend_rpc_eth_filter::(&mut io, &deps)?; extend_rpc_eth_pubsub::( &mut io, diff --git a/node/src/lib.rs b/node/src/lib.rs index 81cae51451..c447a07309 100644 --- a/node/src/lib.rs +++ b/node/src/lib.rs @@ -1,6 +1,8 @@ pub mod chain_spec; pub mod cli; pub mod client; +pub mod conditional_evm_block_import; +pub mod consensus; pub mod ethereum; pub mod rpc; pub mod service; diff --git a/node/src/main.rs b/node/src/main.rs index bb8cd8e8bc..64f25acc67 100644 --- a/node/src/main.rs +++ b/node/src/main.rs @@ -1,16 +1,17 @@ //! Substrate Node Subtensor CLI library. #![warn(missing_docs)] -mod chain_spec; -#[macro_use] -mod service; #[cfg(feature = "runtime-benchmarks")] mod benchmarking; +mod chain_spec; mod cli; mod client; mod command; +mod conditional_evm_block_import; +mod consensus; mod ethereum; mod rpc; +mod service; fn main() -> sc_cli::Result<()> { command::run() diff --git a/node/src/rpc.rs b/node/src/rpc.rs index 7f4f969bec..e34826462f 100644 --- a/node/src/rpc.rs +++ b/node/src/rpc.rs @@ -5,14 +5,19 @@ #![warn(missing_docs)] -use std::{collections::BTreeMap, sync::Arc}; +use std::sync::Arc; use futures::channel::mpsc; -pub use fc_rpc::EthBlockDataCacheTask; +use crate::{ + client::{FullBackend, FullClient}, + ethereum::create_eth, +}; +use fc_rpc::EthBlockDataCacheTask; pub use fc_rpc_core::types::{FeeHistoryCache, FeeHistoryCacheLimit, FilterPool}; -use fc_storage::StorageOverride; -use jsonrpsee::RpcModule; +/// Frontier DB backend type. +pub use fc_storage::StorageOverride; +use jsonrpsee::{Methods, RpcModule}; use node_subtensor_runtime::opaque::Block; use sc_consensus_manual_seal::EngineCommand; use sc_network::service::traits::NetworkService; @@ -22,13 +27,9 @@ use sc_transaction_pool_api::TransactionPool; use sp_core::H256; use sp_inherents::CreateInherentDataProviders; use sp_runtime::{OpaqueExtrinsic, traits::BlakeTwo256, traits::Block as BlockT}; +use std::collections::BTreeMap; use subtensor_runtime_common::Hash; -use crate::{ - client::{FullBackend, FullClient}, - ethereum::create_eth, -}; - /// Extra dependencies for Ethereum compatibility. pub struct EthDeps { /// The client instance to use. @@ -103,6 +104,10 @@ pub fn create_full( fc_mapping_sync::EthereumBlockNotification, >, >, + frontier_pending_consensus_data_provider: Box< + dyn fc_rpc::pending::ConsensusDataProvider, + >, + other_methods: &[Methods], ) -> Result, Box> where P: TransactionPool< @@ -136,7 +141,7 @@ where module.merge(Swap::new(client.clone()).into_rpc())?; module.merge(System::new(client.clone(), pool.clone()).into_rpc())?; - module.merge(TransactionPayment::new(client).into_rpc())?; + module.merge(TransactionPayment::new(client.clone()).into_rpc())?; // Extend this RPC with a custom API by using the following syntax. // `YourRpcStruct` should have a reference to a client, which is needed @@ -151,12 +156,18 @@ where )?; } + // Other methods provided by the caller + for m in other_methods { + module.merge(m.clone())?; + } + // Ethereum compatibility RPCs let module = create_eth::<_, _, _, DefaultEthConfig>( module, eth, subscription_task_executor, pubsub_notification_sinks, + Some(frontier_pending_consensus_data_provider), )?; Ok(module) diff --git a/node/src/service.rs b/node/src/service.rs index ca23ddb03b..9bf3056b54 100644 --- a/node/src/service.rs +++ b/node/src/service.rs @@ -1,48 +1,60 @@ //! Service and ServiceFactory implementation. Specialized wrapper over substrate service. +use crate::consensus::ConsensusMechanism; use futures::{FutureExt, channel::mpsc, future}; use node_subtensor_runtime::{RuntimeApi, TransactionConverter, opaque::Block}; use sc_chain_spec::ChainType; use sc_client_api::{Backend as BackendT, BlockBackend}; -use sc_consensus::{ - BasicQueue, BlockCheckParams, BlockImport, BlockImportParams, BoxBlockImport, ImportResult, -}; +use sc_consensus::{BasicQueue, BoxBlockImport}; use sc_consensus_grandpa::BlockNumberOps; use sc_consensus_slots::BackoffAuthoringOnFinalizedHeadLagging; +use sc_consensus_slots::SlotProportion; use sc_network::config::SyncMode; use sc_network_sync::strategy::warp::{WarpSyncConfig, WarpSyncProvider}; use sc_service::{Configuration, PartialComponents, TaskManager, error::Error as ServiceError}; use sc_telemetry::{Telemetry, TelemetryHandle, TelemetryWorker, log}; use sc_transaction_pool::TransactionPoolHandle; use sc_transaction_pool_api::OffchainTransactionPoolFactory; -use sp_consensus::Error as ConsensusError; -use sp_consensus_aura::sr25519::AuthorityPair as AuraPair; use sp_core::H256; -use sp_runtime::traits::{Block as BlockT, Header, NumberFor}; +use sp_runtime::traits::{Block as BlockT, NumberFor}; use std::collections::HashSet; use std::str::FromStr; +use std::sync::atomic::AtomicBool; use std::{cell::RefCell, path::Path}; -use std::{marker::PhantomData, sync::Arc, time::Duration}; +use std::{sync::Arc, time::Duration}; use substrate_prometheus_endpoint::Registry; use crate::cli::Sealing; use crate::client::{FullBackend, FullClient, HostFunctions, RuntimeExecutor}; use crate::ethereum::{ - BackendType, EthConfiguration, FrontierBackend, FrontierBlockImport, FrontierPartialComponents, - StorageOverride, StorageOverrideHandler, db_config_dir, new_frontier_partial, - spawn_frontier_tasks, + BackendType, EthConfiguration, FrontierBackend, FrontierPartialComponents, StorageOverride, + StorageOverrideHandler, db_config_dir, new_frontier_partial, spawn_frontier_tasks, }; /// The minimum period of blocks on which justifications will be /// imported and generated. const GRANDPA_JUSTIFICATION_PERIOD: u32 = 512; -type FullSelectChain = sc_consensus::LongestChain; -type GrandpaBlockImport = +pub type FullSelectChain = sc_consensus::LongestChain; +pub type GrandpaBlockImport = sc_consensus_grandpa::GrandpaBlockImport; type GrandpaLinkHalf = sc_consensus_grandpa::LinkHalf; - -pub fn new_partial( +#[allow(clippy::upper_case_acronyms)] +pub type BIQ<'a> = Box< + dyn FnOnce( + Arc, + Arc, + &Configuration, + &EthConfiguration, + &TaskManager, + Option, + GrandpaBlockImport, + Arc>, + ) -> Result<(BasicQueue, BoxBlockImport), sc_service::Error> + + 'a, +>; + +pub fn new_partial( config: &Configuration, eth_config: &EthConfiguration, build_import_queue: BIQ, @@ -62,17 +74,7 @@ pub fn new_partial( ), >, ServiceError, -> -where - BIQ: FnOnce( - Arc, - &Configuration, - &EthConfiguration, - &TaskManager, - Option, - GrandpaBlockImport, - ) -> Result<(BasicQueue, BoxBlockImport), ServiceError>, -{ +> { let telemetry = config .telemetry_endpoints .clone() @@ -166,15 +168,6 @@ where } }; - let (import_queue, block_import) = build_import_queue( - client.clone(), - config, - eth_config, - &task_manager, - telemetry.as_ref().map(|x| x.handle()), - grandpa_block_import, - )?; - let transaction_pool = Arc::from( sc_transaction_pool::Builder::new( task_manager.spawn_essential_handle(), @@ -186,6 +179,17 @@ where .build(), ); + let (import_queue, block_import) = build_import_queue( + client.clone(), + backend.clone(), + config, + eth_config, + &task_manager, + telemetry.as_ref().map(|x| x.handle()), + grandpa_block_import, + transaction_pool.clone(), + )?; + Ok(PartialComponents { client, backend, @@ -204,131 +208,24 @@ where }) } -pub struct ConditionalEVMBlockImport { - inner: I, - frontier_block_import: F, - _marker: PhantomData, -} - -impl Clone for ConditionalEVMBlockImport -where - B: BlockT, - I: Clone + BlockImport, - F: Clone + BlockImport, -{ - fn clone(&self) -> Self { - ConditionalEVMBlockImport { - inner: self.inner.clone(), - frontier_block_import: self.frontier_block_import.clone(), - _marker: PhantomData, - } - } -} - -impl ConditionalEVMBlockImport -where - B: BlockT, - I: BlockImport, - I::Error: Into, - F: BlockImport, - F::Error: Into, -{ - pub fn new(inner: I, frontier_block_import: F) -> Self { - Self { - inner, - frontier_block_import, - _marker: PhantomData, - } - } -} - -#[async_trait::async_trait] -impl BlockImport for ConditionalEVMBlockImport -where - B: BlockT, - I: BlockImport + Send + Sync, - I::Error: Into, - F: BlockImport + Send + Sync, - F::Error: Into, -{ - type Error = ConsensusError; - - async fn check_block(&self, block: BlockCheckParams) -> Result { - self.inner.check_block(block).await.map_err(Into::into) - } - - async fn import_block(&self, block: BlockImportParams) -> Result { - // 4345556 - mainnet runtime upgrade block with Frontier - if *block.header.number() < 4345557u32.into() { - self.inner.import_block(block).await.map_err(Into::into) - } else { - self.frontier_block_import - .import_block(block) - .await - .map_err(Into::into) - } - } -} - -/// Build the import queue for the template runtime (aura + grandpa). -pub fn build_aura_grandpa_import_queue( - client: Arc, - config: &Configuration, - _eth_config: &EthConfiguration, - task_manager: &TaskManager, - telemetry: Option, - grandpa_block_import: GrandpaBlockImport, -) -> Result<(BasicQueue, BoxBlockImport), ServiceError> -where - NumberFor: BlockNumberOps, -{ - let conditional_block_import = ConditionalEVMBlockImport::new( - grandpa_block_import.clone(), - FrontierBlockImport::new(grandpa_block_import.clone(), client.clone()), - ); - - let slot_duration = sc_consensus_aura::slot_duration(&*client)?; - let create_inherent_data_providers = move |_, ()| async move { - let timestamp = sp_timestamp::InherentDataProvider::from_system_time(); - let slot = - sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_slot_duration( - *timestamp, - slot_duration, - ); - Ok((slot, timestamp)) - }; - - let import_queue = sc_consensus_aura::import_queue::( - sc_consensus_aura::ImportQueueParams { - block_import: conditional_block_import.clone(), - justification_import: Some(Box::new(grandpa_block_import.clone())), - client, - create_inherent_data_providers, - spawner: &task_manager.spawn_essential_handle(), - registry: config.prometheus_registry(), - check_for_equivocation: Default::default(), - telemetry, - compatibility_mode: sc_consensus_aura::CompatibilityMode::None, - }, - ) - .map_err::(Into::into)?; - - Ok((import_queue, Box::new(conditional_block_import))) -} - /// Build the import queue for the template runtime (manual seal). +#[allow(clippy::too_many_arguments)] +#[cfg(feature = "runtime-benchmarks")] pub fn build_manual_seal_import_queue( client: Arc, + _backend: Arc, config: &Configuration, _eth_config: &EthConfiguration, task_manager: &TaskManager, _telemetry: Option, grandpa_block_import: GrandpaBlockImport, + _transaction_pool_handle: Arc>, ) -> Result<(BasicQueue, BoxBlockImport), ServiceError> { - let conditional_block_import = ConditionalEVMBlockImport::new( - grandpa_block_import.clone(), - FrontierBlockImport::new(grandpa_block_import.clone(), client.clone()), - ); + let conditional_block_import = + crate::conditional_evm_block_import::ConditionalEVMBlockImport::new( + grandpa_block_import.clone(), + fc_consensus::FrontierBlockImport::new(grandpa_block_import.clone(), client.clone()), + ); Ok(( sc_consensus_manual_seal::import_queue( Box::new(conditional_block_import.clone()), @@ -340,14 +237,16 @@ pub fn build_manual_seal_import_queue( } /// Builds a new service for a full client. -pub async fn new_full( +pub async fn new_full( mut config: Configuration, eth_config: EthConfiguration, sealing: Option, + custom_service_signal: Option>, ) -> Result where NumberFor: BlockNumberOps, NB: sc_network::NetworkBackend::Hash>, + CM: ConsensusMechanism, { // Substrate doesn't seem to support fast sync option in our configuration. if matches!(config.network.sync_mode, SyncMode::LightState { .. }) { @@ -358,11 +257,8 @@ where return Err(ServiceError::Other("Unsupported sync mode".to_string())); } - let build_import_queue = if sealing.is_some() { - build_manual_seal_import_queue - } else { - build_aura_grandpa_import_queue - }; + let mut consensus_mechanism = CM::new(); + let build_import_queue = consensus_mechanism.build_biq()?; let PartialComponents { client, @@ -375,6 +271,12 @@ where other: (mut telemetry, block_import, grandpa_link, frontier_backend, storage_override), } = new_partial(&config, ð_config, build_import_queue)?; + consensus_mechanism.spawn_essential_handles( + &mut task_manager, + client.clone(), + custom_service_signal, + )?; + let FrontierPartialComponents { filter_pool, fee_history_cache, @@ -530,21 +432,15 @@ where prometheus_registry.clone(), )); - let slot_duration = sc_consensus_aura::slot_duration(&*client)?; - let pending_create_inherent_data_providers = move |_, ()| async move { - let current = sp_timestamp::InherentDataProvider::from_system_time(); - let next_slot = current - .timestamp() - .as_millis() - .saturating_add(slot_duration.as_millis()); - let timestamp = sp_timestamp::InherentDataProvider::new(next_slot.into()); - let slot = sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_slot_duration( - *timestamp, - slot_duration, - ); - Ok((slot, timestamp)) - }; + let slot_duration = consensus_mechanism.slot_duration(&client)?; + let pending_create_inherent_data_providers = + move |_, ()| async move { CM::create_inherent_data_providers(slot_duration) }; + let rpc_methods = consensus_mechanism.rpc_methods( + client.clone(), + keystore_container.keystore(), + select_chain.clone(), + )?; Box::new(move |subscription_task_executor| { let eth_deps = crate::rpc::EthDeps { client: client.clone(), @@ -583,6 +479,8 @@ where deps, subscription_task_executor, pubsub_notification_sinks.clone(), + CM::frontier_consensus_data_provider(client.clone())?, + rpc_methods.as_slice(), ) .map_err(Into::into) }) @@ -624,7 +522,7 @@ where sealing, client, transaction_pool, - select_chain, + select_chain.clone(), block_import, &task_manager, prometheus_registry.as_ref(), @@ -644,18 +542,13 @@ where telemetry.as_ref().map(|x| x.handle()), ); - let slot_duration = sc_consensus_aura::slot_duration(&*client)?; - let create_inherent_data_providers = move |_, ()| async move { - let timestamp = sp_timestamp::InherentDataProvider::from_system_time(); - let slot = sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_slot_duration( - *timestamp, - slot_duration, - ); - Ok((slot, timestamp)) - }; + let slot_duration = consensus_mechanism.slot_duration(&client)?; + let create_inherent_data_providers = + move |_, ()| async move { CM::create_inherent_data_providers(slot_duration) }; - let aura = sc_consensus_aura::start_aura::( - sc_consensus_aura::StartAuraParams { + consensus_mechanism.start_authoring( + &mut task_manager, + crate::consensus::StartAuthoringParams { slot_duration, client, select_chain, @@ -667,17 +560,11 @@ where force_authoring, backoff_authoring_blocks, keystore: keystore_container.keystore(), - block_proposal_slot_portion: sc_consensus_aura::SlotProportion::new(2f32 / 3f32), + block_proposal_slot_portion: SlotProportion::new(2f32 / 3f32), max_block_proposal_slot_portion: None, telemetry: telemetry.as_ref().map(|x| x.handle()), - compatibility_mode: sc_consensus_aura::CompatibilityMode::None, }, )?; - // the AURA authoring task is considered essential, i.e. if it - // fails we take down the service with it. - task_manager - .spawn_essential_handle() - .spawn_blocking("aura", Some("block-authoring"), aura); } if enable_grandpa { @@ -731,22 +618,35 @@ where Ok(task_manager) } -pub async fn build_full( +pub async fn build_full( config: Configuration, eth_config: EthConfiguration, sealing: Option, + custom_service_signal: Option>, ) -> Result { match config.network.network_backend { sc_network::config::NetworkBackendType::Libp2p => { - new_full::>(config, eth_config, sealing).await + new_full::, CM>( + config, + eth_config, + sealing, + custom_service_signal, + ) + .await } sc_network::config::NetworkBackendType::Litep2p => { - new_full::(config, eth_config, sealing).await + new_full::( + config, + eth_config, + sealing, + custom_service_signal, + ) + .await } } } -pub fn new_chain_ops( +pub fn new_chain_ops( config: &mut Configuration, eth_config: &EthConfiguration, ) -> Result< @@ -760,6 +660,7 @@ pub fn new_chain_ops( ServiceError, > { config.keystore = sc_service::config::KeystoreConfig::InMemory; + let mut consensus_mechanism = CM::new(); let PartialComponents { client, backend, @@ -767,7 +668,7 @@ pub fn new_chain_ops( task_manager, other, .. - } = new_partial(config, eth_config, build_aura_grandpa_import_queue)?; + } = new_partial(config, eth_config, consensus_mechanism.build_biq()?)?; Ok((client, backend, import_queue, task_manager, other.3)) } @@ -796,7 +697,7 @@ fn run_manual_seal_authorship( thread_local!(static TIMESTAMP: RefCell = const { RefCell::new(0) }); /// Provide a mock duration starting at 0 in millisecond for timestamp inherent. - /// Each call will increment timestamp by slot_duration making Aura think time has passed. + /// Each call will increment timestamp by slot_duration making the consensus logic think time has passed. struct MockTimestampInherentDataProvider; #[async_trait::async_trait] diff --git a/pallets/collective/src/lib.rs b/pallets/collective/src/lib.rs index 4a3aea5a30..f4f531e206 100644 --- a/pallets/collective/src/lib.rs +++ b/pallets/collective/src/lib.rs @@ -42,6 +42,7 @@ #![cfg_attr(not(feature = "std"), no_std)] #![recursion_limit = "128"] +use codec::DecodeWithMemTracking; use frame_support::{ dispatch::{DispatchResultWithPostInfo, GetDispatchInfo, Pays, PostDispatchInfo}, ensure, diff --git a/pallets/subtensor/Cargo.toml b/pallets/subtensor/Cargo.toml index 5479789077..44d873c8a6 100644 --- a/pallets/subtensor/Cargo.toml +++ b/pallets/subtensor/Cargo.toml @@ -43,6 +43,7 @@ share-pool.workspace = true safe-math.workspace = true approx.workspace = true subtensor-swap-interface.workspace = true +runtime-common.workspace = true subtensor-runtime-common = { workspace = true, features = ["approx"] } pallet-drand.workspace = true @@ -122,6 +123,7 @@ std = [ "subtensor-runtime-common/std", "pallet-proxy/std", "pallet-crowdloan/std", + "runtime-common/std" ] default = ["std"] runtime-benchmarks = [ @@ -140,6 +142,7 @@ runtime-benchmarks = [ "pallet-crowdloan/runtime-benchmarks", "pallet-utility/runtime-benchmarks", "sp-runtime/runtime-benchmarks", + "runtime-common/runtime-benchmarks" ] try-runtime = [ "frame-support/try-runtime", @@ -155,6 +158,7 @@ try-runtime = [ "pallet-drand/try-runtime", "pallet-proxy/try-runtime", "pallet-crowdloan/try-runtime", + "runtime-common/try-runtime" ] pow-faucet = [] -fast-blocks = [] +fast-runtime = ["subtensor-runtime-common/fast-runtime"] diff --git a/pallets/subtensor/src/lib.rs b/pallets/subtensor/src/lib.rs index f8474bff0a..5145405a36 100644 --- a/pallets/subtensor/src/lib.rs +++ b/pallets/subtensor/src/lib.rs @@ -8,6 +8,9 @@ use frame_system::{self as system, ensure_signed}; pub use pallet::*; +use codec::{Decode, DecodeWithMemTracking, Encode}; +use frame_support::sp_runtime::transaction_validity::InvalidTransaction; +use frame_support::sp_runtime::transaction_validity::ValidTransaction; use frame_support::{ dispatch::{self, DispatchInfo, DispatchResult, DispatchResultWithPostInfo, PostDispatchInfo}, ensure, @@ -15,10 +18,6 @@ use frame_support::{ pallet_prelude::*, traits::{IsSubType, tokens::fungible}, }; - -use codec::{Decode, DecodeWithMemTracking, Encode}; -use frame_support::sp_runtime::transaction_validity::InvalidTransaction; -use frame_support::sp_runtime::transaction_validity::ValidTransaction; use pallet_balances::Call as BalancesCall; // use pallet_scheduler as Scheduler; use scale_info::TypeInfo; @@ -85,6 +84,7 @@ pub mod pallet { }; use frame_system::pallet_prelude::*; use pallet_drand::types::RoundNumber; + use runtime_common::prod_or_fast; use sp_core::{ConstU32, H160, H256}; use sp_runtime::traits::{Dispatchable, TrailingZeroInput}; use sp_std::collections::vec_deque::VecDeque; @@ -800,11 +800,7 @@ pub mod pallet { #[pallet::type_value] /// Default value for applying pending items (e.g. childkeys). pub fn DefaultPendingCooldown() -> u64 { - if cfg!(feature = "fast-blocks") { - return 15; - } - - 7_200 + prod_or_fast!(7_200, 15) } #[pallet::type_value] diff --git a/pallets/subtensor/src/tests/children.rs b/pallets/subtensor/src/tests/children.rs index 50a6e506a6..a4b9a70968 100644 --- a/pallets/subtensor/src/tests/children.rs +++ b/pallets/subtensor/src/tests/children.rs @@ -4018,11 +4018,7 @@ fn test_dividend_distribution_with_children_same_coldkey_owner() { fn test_pending_cooldown_as_expected() { let curr_block = 1; // TODO: Fix when CHK splitting patched - // let expected_cooldown = if cfg!(feature = "fast-blocks") { - // 15 - // } else { - // 7200 - // }; + // let expected_cooldown = prod_or_fast!(7200, 15); new_test_ext(curr_block).execute_with(|| { let coldkey = U256::from(1); diff --git a/runtime/Cargo.toml b/runtime/Cargo.toml index b3f13dcc3b..e63f08f242 100644 --- a/runtime/Cargo.toml +++ b/runtime/Cargo.toml @@ -43,6 +43,7 @@ frame-metadata-hash-extension.workspace = true sp-api.workspace = true sp-block-builder.workspace = true sp-consensus-aura.workspace = true +sp-consensus-babe.workspace = true sp-core.workspace = true sp-storage.workspace = true sp-genesis-builder.workspace = true @@ -53,6 +54,7 @@ sp-session.workspace = true sp-std.workspace = true sp-transaction-pool.workspace = true sp-version.workspace = true +sp-authority-discovery.workspace = true subtensor-runtime-common.workspace = true subtensor-precompiles.workspace = true @@ -92,6 +94,30 @@ pallet-registry.workspace = true # Metadata commitment pallet pallet-commitments.workspace = true +# For prod_or_fast macro +runtime-common.workspace = true + +# NPoS +frame-election-provider-support = { workspace = true } +pallet-authority-discovery = { workspace = true } +pallet-babe = { workspace = true } +pallet-bags-list = { workspace = true } +pallet-staking = { workspace = true } +pallet-staking-runtime-api = { workspace = true } +pallet-session = { workspace = true } +pallet-fast-unstake = { workspace = true } +pallet-nomination-pools = { workspace = true } +pallet-nomination-pools-runtime-api = { workspace = true } +pallet-offences = { workspace = true } +pallet-authorship = { workspace = true } +pallet-election-provider-multi-phase = { workspace = true } +pallet-staking-reward-fn = { workspace = true } +pallet-staking-reward-curve = { workspace = true } +sp-staking = { workspace = true } +sp-npos-elections = { workspace = true } +sp-consensus-slots = { workspace = true } +sp-consensus-grandpa = { workspace = true } + # Frontier fp-evm.workspace = true fp-rpc.workspace = true @@ -133,9 +159,9 @@ substrate-wasm-builder = { workspace = true, optional = true } [features] default = ["std"] pow-faucet = ["pallet-subtensor/pow-faucet"] -fast-blocks = [ - "pallet-subtensor/fast-blocks", - "subtensor-runtime-common/fast-blocks", +fast-runtime = [ + "pallet-subtensor/fast-runtime", + "subtensor-runtime-common/fast-runtime", ] std = [ "frame-try-runtime?/std", @@ -151,11 +177,6 @@ std = [ "frame-system/std", "frame-try-runtime/std", "pallet-subtensor/std", - "pallet-subtensor-swap/std", - "pallet-subtensor-swap-runtime-api/std", - "substrate-fixed/std", - "subtensor-swap-interface/std", - "pallet-aura/std", "pallet-balances/std", "pallet-grandpa/std", "pallet-insecure-randomness-collective-flip/std", @@ -173,7 +194,6 @@ std = [ "precompile-utils/std", "sp-api/std", "sp-block-builder/std", - "sp-consensus-aura/std", "sp-core/std", "sp-inherents/std", "sp-offchain/std", @@ -197,6 +217,24 @@ std = [ "subtensor-precompiles/std", "subtensor-runtime-common/std", "pallet-crowdloan/std", + "pallet-babe/std", + "pallet-session/std", + "pallet-staking/std", + "pallet-election-provider-multi-phase/std", + "frame-election-provider-support/std", + "pallet-authority-discovery/std", + "pallet-authorship/std", + "pallet-bags-list/std", + "pallet-fast-unstake/std", + "pallet-nomination-pools-runtime-api/std", + "pallet-nomination-pools/std", + "pallet-offences/std", + "pallet-staking-reward-fn/std", + "pallet-staking-runtime-api/std", + "sp-authority-discovery/std", + "sp-consensus-babe/std", + "sp-npos-elections/std", + "sp-staking/std", # Frontier "fp-evm/std", "fp-rpc/std", @@ -219,6 +257,15 @@ std = [ "rand_chacha/std", "sha2/std", "w3f-bls/std", + "pallet-aura/std", + "sp-consensus-aura/std", + "sp-consensus-grandpa/std", + "sp-consensus-slots/std", + "substrate-fixed/std", + "pallet-subtensor-swap/std", + "pallet-subtensor-swap-runtime-api/std", + "subtensor-swap-interface/std", + "runtime-common/std" ] runtime-benchmarks = [ "frame-benchmarking/runtime-benchmarks", @@ -228,12 +275,10 @@ runtime-benchmarks = [ "pallet-balances/runtime-benchmarks", "pallet-grandpa/runtime-benchmarks", "pallet-timestamp/runtime-benchmarks", - "pallet-transaction-payment/runtime-benchmarks", "pallet-utility/runtime-benchmarks", "sp-runtime/runtime-benchmarks", "pallet-safe-mode/runtime-benchmarks", "pallet-subtensor/runtime-benchmarks", - "pallet-subtensor-swap/runtime-benchmarks", "pallet-collective/runtime-benchmarks", "pallet-membership/runtime-benchmarks", "pallet-proxy/runtime-benchmarks", @@ -245,19 +290,30 @@ runtime-benchmarks = [ "pallet-scheduler/runtime-benchmarks", "pallet-sudo/runtime-benchmarks", "pallet-crowdloan/runtime-benchmarks", + "pallet-babe/runtime-benchmarks", + "pallet-staking/runtime-benchmarks", + "pallet-election-provider-multi-phase/runtime-benchmarks", + "frame-election-provider-support/runtime-benchmarks", + "pallet-bags-list/runtime-benchmarks", + "pallet-fast-unstake/runtime-benchmarks", + "pallet-nomination-pools/runtime-benchmarks", + "pallet-offences/runtime-benchmarks", + "sp-staking/runtime-benchmarks", # EVM + Frontier "pallet-ethereum/runtime-benchmarks", "pallet-evm/runtime-benchmarks", "pallet-hotfix-sufficients/runtime-benchmarks", "pallet-drand/runtime-benchmarks", + "pallet-transaction-payment/runtime-benchmarks", + "pallet-subtensor-swap/runtime-benchmarks", + "runtime-common/runtime-benchmarks" ] try-runtime = [ "frame-try-runtime/try-runtime", "frame-executive/try-runtime", "frame-system/try-runtime", "frame-support/try-runtime", - "pallet-aura/try-runtime", "pallet-sudo/try-runtime", "pallet-balances/try-runtime", "pallet-grandpa/try-runtime", @@ -279,6 +335,17 @@ try-runtime = [ "pallet-commitments/try-runtime", "pallet-registry/try-runtime", "pallet-crowdloan/try-runtime", + "pallet-babe/try-runtime", + "pallet-session/try-runtime", + "pallet-staking/try-runtime", + "pallet-election-provider-multi-phase/try-runtime", + "frame-election-provider-support/try-runtime", + "pallet-authority-discovery/try-runtime", + "pallet-authorship/try-runtime", + "pallet-bags-list/try-runtime", + "pallet-fast-unstake/try-runtime", + "pallet-nomination-pools/try-runtime", + "pallet-offences/try-runtime", # EVM + Frontier "fp-self-contained/try-runtime", @@ -287,5 +354,7 @@ try-runtime = [ "pallet-evm/try-runtime", "pallet-evm-chain-id/try-runtime", "pallet-drand/try-runtime", + "pallet-aura/try-runtime", + "runtime-common/try-runtime" ] metadata-hash = ["substrate-wasm-builder/metadata-hash"] diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index db35faf7e0..1adba5d3a6 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -32,9 +32,7 @@ use frame_support::{ }; use frame_system::{EnsureNever, EnsureRoot, EnsureRootWithSuccess, RawOrigin}; use pallet_commitments::{CanCommit, OnMetadataCommitment}; -use pallet_grandpa::{ - AuthorityId as GrandpaId, AuthorityList as GrandpaAuthorityList, fg_primitives, -}; +use pallet_grandpa::{AuthorityId as GrandpaId, fg_primitives}; use pallet_registry::CanRegisterIdentity; use pallet_subtensor::rpc_info::{ delegate_info::DelegateInfo, @@ -45,9 +43,12 @@ use pallet_subtensor::rpc_info::{ stake_info::StakeInfo, subnet_info::{SubnetHyperparams, SubnetHyperparamsV2, SubnetInfo, SubnetInfov2}, }; +use runtime_common::prod_or_fast; use smallvec::smallvec; use sp_api::impl_runtime_apis; use sp_consensus_aura::sr25519::AuthorityId as AuraId; +use sp_consensus_babe::BabeConfiguration; +use sp_consensus_babe::BabeEpochConfiguration; use sp_core::{ H160, H256, OpaqueMetadata, U256, crypto::{ByteArray, KeyTypeId}, @@ -57,8 +58,8 @@ use sp_runtime::generic::Era; use sp_runtime::{ AccountId32, ApplyExtrinsicResult, ConsensusEngineId, generic, impl_opaque_keys, traits::{ - AccountIdLookup, BlakeTwo256, Block as BlockT, DispatchInfoOf, Dispatchable, NumberFor, - One, PostDispatchInfoOf, UniqueSaturatedInto, Verify, + AccountIdLookup, BlakeTwo256, Block as BlockT, DispatchInfoOf, Dispatchable, One, + PostDispatchInfoOf, UniqueSaturatedInto, Verify, }, transaction_validity::{TransactionSource, TransactionValidity, TransactionValidityError}, }; @@ -218,7 +219,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { // `spec_version`, and `authoring_version` are the same between Wasm and native. // This value is set to 100 to notify Polkadot-JS App (https://polkadot.js.org/apps) to use // the compatible custom types. - spec_version: 299, + spec_version: 300, impl_version: 1, apis: RUNTIME_API_VERSIONS, transaction_version: 1, @@ -1135,17 +1136,10 @@ impl pallet_commitments::GetTempoInterface for Runtime { } } -#[cfg(not(feature = "fast-blocks"))] -pub const INITIAL_SUBNET_TEMPO: u16 = 360; - -#[cfg(feature = "fast-blocks")] -pub const INITIAL_SUBNET_TEMPO: u16 = 10; +pub const INITIAL_SUBNET_TEMPO: u16 = prod_or_fast!(360, 10); -#[cfg(not(feature = "fast-blocks"))] -pub const INITIAL_CHILDKEY_TAKE_RATELIMIT: u64 = 216000; // 30 days at 12 seconds per block - -#[cfg(feature = "fast-blocks")] -pub const INITIAL_CHILDKEY_TAKE_RATELIMIT: u64 = 5; +// 30 days at 12 seconds per block = 216000 +pub const INITIAL_CHILDKEY_TAKE_RATELIMIT: u64 = prod_or_fast!(216000, 5); // Configure the pallet subtensor. parameter_types! { @@ -1207,11 +1201,8 @@ parameter_types! { pub const InitialDissolveNetworkScheduleDuration: BlockNumber = 5 * 24 * 60 * 60 / 12; // 5 days pub const SubtensorInitialTaoWeight: u64 = 971_718_665_099_567_868; // 0.05267697438728329% tao weight. pub const InitialEmaPriceHalvingPeriod: u64 = 201_600_u64; // 4 weeks - pub const DurationOfStartCall: u64 = if cfg!(feature = "fast-blocks") { - 10 // Only 10 blocks for fast blocks - } else { - 7 * 24 * 60 * 60 / 12 // 7 days - }; + // 7 * 24 * 60 * 60 / 12 = 7 days + pub const DurationOfStartCall: u64 = prod_or_fast!(7 * 24 * 60 * 60 / 12, 10); pub const SubtensorInitialKeySwapOnSubnetCost: u64 = 1_000_000; // 0.001 TAO pub const HotkeySwapOnSubnetInterval : BlockNumber = 5 * 24 * 60 * 60 / 12; // 5 days pub const LeaseDividendsDistributionInterval: BlockNumber = 100; // 100 blocks @@ -1604,16 +1595,10 @@ parameter_types! { pub const CrowdloanPalletId: PalletId = PalletId(*b"bt/cloan"); pub const MinimumDeposit: Balance = 10_000_000_000; // 10 TAO pub const AbsoluteMinimumContribution: Balance = 100_000_000; // 0.1 TAO - pub const MinimumBlockDuration: BlockNumber = if cfg!(feature = "fast-blocks") { - 50 - } else { - 50400 // 7 days minimum (7 * 24 * 60 * 60 / 12) - }; - pub const MaximumBlockDuration: BlockNumber = if cfg!(feature = "fast-blocks") { - 20000 - } else { - 432000 // 60 days maximum (60 * 24 * 60 * 60 / 12) - }; + // 7 days minimum (7 * 24 * 60 * 60 / 12) + pub const MinimumBlockDuration: BlockNumber = prod_or_fast!(50400, 50); + // 60 days maximum (60 * 24 * 60 * 60 / 12) + pub const MaximumBlockDuration: BlockNumber = prod_or_fast!(432000, 20000); pub const RefundContributorsLimit: u32 = 50; pub const MaxContributors: u32 = 500; } @@ -1899,7 +1884,7 @@ impl_runtime_apis! { } impl fg_primitives::GrandpaApi for Runtime { - fn grandpa_authorities() -> GrandpaAuthorityList { + fn grandpa_authorities() -> Vec<(GrandpaId, u64)> { Grandpa::grandpa_authorities() } @@ -1908,18 +1893,23 @@ impl_runtime_apis! { } fn submit_report_equivocation_unsigned_extrinsic( - _equivocation_proof: fg_primitives::EquivocationProof< + equivocation_proof: fg_primitives::EquivocationProof< ::Hash, - NumberFor, + sp_runtime::traits::NumberFor, >, - _key_owner_proof: fg_primitives::OpaqueKeyOwnershipProof, + key_owner_proof: fg_primitives::OpaqueKeyOwnershipProof, ) -> Option<()> { - None + let key_owner_proof = key_owner_proof.decode()?; + + Grandpa::submit_unsigned_equivocation_report( + equivocation_proof, + key_owner_proof, + ) } fn generate_key_ownership_proof( _set_id: fg_primitives::SetId, - _authority_id: GrandpaId, + _authority_id: fg_primitives::AuthorityId, ) -> Option { // NOTE: this is the only implementation possible since we've // defined our key owner proof type as a bottom type (i.e. a type @@ -2410,6 +2400,60 @@ impl_runtime_apis! { } } + impl sp_consensus_babe::BabeApi for Runtime { + fn configuration() -> BabeConfiguration { + let config = BabeEpochConfiguration::default(); + BabeConfiguration { + slot_duration: Default::default(), + epoch_length: Default::default(), + authorities: vec![], + randomness: Default::default(), + c: config.c, + allowed_slots: config.allowed_slots, + + } + } + + fn current_epoch_start() -> sp_consensus_babe::Slot { + Default::default() + } + + fn current_epoch() -> sp_consensus_babe::Epoch { + sp_consensus_babe::Epoch { + epoch_index: Default::default(), + start_slot: Default::default(), + duration: Default::default(), + authorities: vec![], + randomness: Default::default(), + config: BabeEpochConfiguration::default(), + } + } + + fn next_epoch() -> sp_consensus_babe::Epoch { + sp_consensus_babe::Epoch { + epoch_index: Default::default(), + start_slot: Default::default(), + duration: Default::default(), + authorities: vec![], + randomness: Default::default(), + config: BabeEpochConfiguration::default(), + } + } + + fn generate_key_ownership_proof( + _slot: sp_consensus_babe::Slot, + _authority_id: sp_consensus_babe::AuthorityId, + ) -> Option { + None + } + + fn submit_report_equivocation_unsigned_extrinsic( + _equivocation_proof: sp_consensus_babe::EquivocationProof<::Header>, + _key_owner_proof: sp_consensus_babe::OpaqueKeyOwnershipProof, + ) -> Option<()> { + None + } + } impl pallet_subtensor_swap_runtime_api::SwapRuntimeApi for Runtime { fn current_alpha_price(netuid: u16) -> u64 { diff --git a/scripts/localnet.sh b/scripts/localnet.sh index 4de17f1521..ade616b00e 100755 --- a/scripts/localnet.sh +++ b/scripts/localnet.sh @@ -30,14 +30,14 @@ if [ "$fast_blocks" == "False" ]; then : "${CHAIN:=local}" : "${BUILD_BINARY:=1}" : "${FEATURES:="pow-faucet"}" - BUILD_DIR="$BASE_DIR/target/non-fast-blocks" + BUILD_DIR="$BASE_DIR/target/non-fast-runtime" else # Block of code to execute if fast_blocks is not False echo "fast_blocks is On" : "${CHAIN:=local}" : "${BUILD_BINARY:=1}" - : "${FEATURES:="pow-faucet fast-blocks"}" - BUILD_DIR="$BASE_DIR/target/fast-blocks" + : "${FEATURES:="pow-faucet fast-runtime"}" + BUILD_DIR="$BASE_DIR/target/fast-runtime" fi # Ensure the build directory exists diff --git a/scripts/localnet_patch.sh b/scripts/localnet_patch.sh index ef9d1959bf..f5a84e8348 100755 --- a/scripts/localnet_patch.sh +++ b/scripts/localnet_patch.sh @@ -1,5 +1,5 @@ #!/bin/bash -# This file patches the code in the repository to create a docker image with the ability to run tests in non-fast-blocks +# This file patches the code in the repository to create a docker image with the ability to run tests in non-fast-runtime # mode. set -e @@ -9,24 +9,24 @@ DefaultPendingCooldown="pallets/subtensor/src/lib.rs" SetChildren="pallets/subtensor/src/utils/rate_limiting.rs" # Checkers -if ! grep -q '7 \* 24 \* 60 \* 60 / 12 // 7 days' "$DurationOfStartCall"; then - echo "Error: Target string not found in $DurationOfStartCall" - exit 1 +if ! grep -q 'pub const DurationOfStartCall: u64' "$DurationOfStartCall"; then + echo "Error: Target string not found in $DurationOfStartCall" + exit 1 fi if ! grep -q 'pub fn DefaultPendingCooldown() -> u64 {' "$DefaultPendingCooldown"; then - echo "Error: Target function not found in $DefaultPendingCooldown" - exit 1 + echo "Error: Target function not found in $DefaultPendingCooldown" + exit 1 fi if ! grep -q 'TransactionType::SetChildren => 150, // 30 minutes' "$SetChildren"; then - echo "Error: Target string not found in $SetChildren" - exit 1 + echo "Error: Target string not found in $SetChildren" + exit 1 fi # replace -perl -0777 -i -pe 's|7 \* 24 \* 60 \* 60 / 12 // 7 days|5 // Only 5 blocks for tests|' "$DurationOfStartCall" -perl -0777 -i -pe 's|pub fn DefaultPendingCooldown\(\) -> u64 \{\s*if cfg!\(feature = "fast-blocks"\) \{\s*return 15;\s*\}\s*7_200\s*\}|pub fn DefaultPendingCooldown() -> u64 {\n 15\n }|g' "$DefaultPendingCooldown" +perl -0777 -i -pe 's|pub const DurationOfStartCall: u64 = prod_or_fast!\(7 \* 24 \* 60 \* 60 / 12, 10\);|pub const DurationOfStartCall: u64 = prod_or_fast!(5, 10);|' "$DurationOfStartCall" +perl -0777 -i -pe 's|pub fn DefaultPendingCooldown\(\) -> u64 \{\s*prod_or_fast!\(7_200, 15\)\s*\}|pub fn DefaultPendingCooldown() -> u64 {\n prod_or_fast!(15, 15)\n }|g' "$DefaultPendingCooldown" perl -0777 -i -pe 's|TransactionType::SetChildren => 150, // 30 minutes|TransactionType::SetChildren => 15, // 3 min|' "$SetChildren" echo "Patch applied successfully." diff --git a/zepter.yaml b/zepter.yaml index e448fa228c..02a2cc9799 100644 --- a/zepter.yaml +++ b/zepter.yaml @@ -12,7 +12,7 @@ workflows: # Check that `A` activates the features of `B`. "propagate-feature", # These are the features to check: - "--features=try-runtime,runtime-benchmarks,std,sql,rocksdb,txpool", + "--features=try-runtime,runtime-benchmarks,std,sql,rocksdb,txpool,fast-runtime", # 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.