diff --git a/.cargo/config.toml b/.cargo/config.toml index 1bf997d519..0aaf0bbf6c 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -1,9 +1,9 @@ -[target.'cfg(target_arch = "x64_64")'] +[target.'cfg(target_arch = "x86_64")'] # Require AES-NI on x86-64 by default -rustflags = "-C target-feature=+aes" +rustflags = ["-C", "target-feature=+aes"] [target.'cfg(target_arch = "aarch64")'] # TODO: Try to remove once https://github.com/paritytech/substrate/issues/11538 is resolved # TODO: AES flag is such that we have decent performance on ARMv8, remove once `aes` crate bumps MSRV to at least # 1.61: https://github.com/RustCrypto/block-ciphers/issues/373 -rustflags = "--cfg aes_armv8" +rustflags = ["--cfg", "aes_armv8"] diff --git a/.dockerignore b/.dockerignore index 983f1aefff..68d5d1fb0c 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,4 +1,5 @@ * +!/.cargo !/crates !/domains !/orml diff --git a/.github/workflows/snapshot-build.yml b/.github/workflows/snapshot-build.yml index 1936bf354b..3a3bfff9a2 100644 --- a/.github/workflows/snapshot-build.yml +++ b/.github/workflows/snapshot-build.yml @@ -91,7 +91,7 @@ jobs: - os: ${{ fromJson(github.repository_owner == 'subspace' && '["self-hosted", "ubuntu-20.04-x86-64"]' || 'ubuntu-20.04') }} target: x86_64-unknown-linux-gnu suffix: ubuntu-x86_64-v2-${{ github.ref_name }} - rustflags: "-C target-cpu=x86-64-v2" + rustflags: "-C target-cpu=x86-64-v2 -C target-feature=+aes" - os: ${{ fromJson(github.repository_owner == 'subspace' && '["self-hosted", "ubuntu-20.04-x86-64"]' || 'ubuntu-20.04') }} target: aarch64-unknown-linux-gnu suffix: ubuntu-aarch64-${{ github.ref_name }} @@ -115,7 +115,7 @@ jobs: - os: ${{ fromJson(github.repository_owner == 'subspace' && '["self-hosted", "windows-server-2022-x86-64"]' || 'windows-2022') }} target: x86_64-pc-windows-msvc suffix: windows-x86_64-v2-${{ github.ref_name }} - rustflags: "-C target-cpu=x86-64-v2" + rustflags: "-C target-cpu=x86-64-v2 -C target-feature=+aes" runs-on: ${{ matrix.build.os }} env: PRODUCTION_TARGET: target/${{ matrix.build.target }}/production diff --git a/Cargo.lock b/Cargo.lock index 8251c60afd..0a47a5b61e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2617,6 +2617,7 @@ dependencies = [ "futures", "parity-scale-codec", "sc-client-api", + "sc-state-db", "sc-utils", "sp-api", "sp-blockchain", @@ -2838,6 +2839,7 @@ dependencies = [ name = "domain-test-service" version = "0.1.0" dependencies = [ + "cross-domain-message-gossip", "domain-client-operator", "domain-runtime-primitives", "domain-service", @@ -3421,7 +3423,7 @@ checksum = "6999dc1837253364c2ebb0704ba97994bd874e8f195d665c50b7548f6ea92764" [[package]] name = "fc-api" version = "1.0.0-dev" -source = "git+https://github.com/subspace/frontier?rev=56086daa77802eaa285894bfe4b811be66629c89#56086daa77802eaa285894bfe4b811be66629c89" +source = "git+https://github.com/subspace/frontier?rev=37ee45323120b21adc1d69ae7348bd0f7282eeae#37ee45323120b21adc1d69ae7348bd0f7282eeae" dependencies = [ "async-trait", "fp-storage", @@ -3433,7 +3435,7 @@ dependencies = [ [[package]] name = "fc-consensus" version = "2.0.0-dev" -source = "git+https://github.com/subspace/frontier?rev=56086daa77802eaa285894bfe4b811be66629c89#56086daa77802eaa285894bfe4b811be66629c89" +source = "git+https://github.com/subspace/frontier?rev=37ee45323120b21adc1d69ae7348bd0f7282eeae#37ee45323120b21adc1d69ae7348bd0f7282eeae" dependencies = [ "async-trait", "fp-consensus", @@ -3449,7 +3451,7 @@ dependencies = [ [[package]] name = "fc-db" version = "2.0.0-dev" -source = "git+https://github.com/subspace/frontier?rev=56086daa77802eaa285894bfe4b811be66629c89#56086daa77802eaa285894bfe4b811be66629c89" +source = "git+https://github.com/subspace/frontier?rev=37ee45323120b21adc1d69ae7348bd0f7282eeae#37ee45323120b21adc1d69ae7348bd0f7282eeae" dependencies = [ "async-trait", "fc-api", @@ -3468,7 +3470,7 @@ dependencies = [ [[package]] name = "fc-mapping-sync" version = "2.0.0-dev" -source = "git+https://github.com/subspace/frontier?rev=56086daa77802eaa285894bfe4b811be66629c89#56086daa77802eaa285894bfe4b811be66629c89" +source = "git+https://github.com/subspace/frontier?rev=37ee45323120b21adc1d69ae7348bd0f7282eeae#37ee45323120b21adc1d69ae7348bd0f7282eeae" dependencies = [ "fc-db", "fc-storage", @@ -3489,7 +3491,7 @@ dependencies = [ [[package]] name = "fc-rpc" version = "2.0.0-dev" -source = "git+https://github.com/subspace/frontier?rev=56086daa77802eaa285894bfe4b811be66629c89#56086daa77802eaa285894bfe4b811be66629c89" +source = "git+https://github.com/subspace/frontier?rev=37ee45323120b21adc1d69ae7348bd0f7282eeae#37ee45323120b21adc1d69ae7348bd0f7282eeae" dependencies = [ "ethereum", "ethereum-types", @@ -3543,7 +3545,7 @@ dependencies = [ [[package]] name = "fc-rpc-core" version = "1.1.0-dev" -source = "git+https://github.com/subspace/frontier?rev=56086daa77802eaa285894bfe4b811be66629c89#56086daa77802eaa285894bfe4b811be66629c89" +source = "git+https://github.com/subspace/frontier?rev=37ee45323120b21adc1d69ae7348bd0f7282eeae#37ee45323120b21adc1d69ae7348bd0f7282eeae" dependencies = [ "ethereum", "ethereum-types", @@ -3556,7 +3558,7 @@ dependencies = [ [[package]] name = "fc-storage" version = "1.0.0-dev" -source = "git+https://github.com/subspace/frontier?rev=56086daa77802eaa285894bfe4b811be66629c89#56086daa77802eaa285894bfe4b811be66629c89" +source = "git+https://github.com/subspace/frontier?rev=37ee45323120b21adc1d69ae7348bd0f7282eeae#37ee45323120b21adc1d69ae7348bd0f7282eeae" dependencies = [ "ethereum", "ethereum-types", @@ -3573,11 +3575,12 @@ dependencies = [ [[package]] name = "fdlimit" -version = "0.2.1" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c4c9e43643f5a3be4ca5b67d26b98031ff9db6806c3440ae32e02e3ceac3f1b" +checksum = "e182f7dbc2ef73d9ef67351c5fbbea084729c48362d3ce9dd44c28e32e277fe5" dependencies = [ "libc", + "thiserror", ] [[package]] @@ -3704,7 +3707,7 @@ checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] name = "fork-tree" version = "3.0.0" -source = "git+https://github.com/subspace/polkadot-sdk?rev=892bf8e938c6bd2b893d3827d1093cd81baa59a1#892bf8e938c6bd2b893d3827d1093cd81baa59a1" +source = "git+https://github.com/subspace/polkadot-sdk?rev=c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c#c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" dependencies = [ "parity-scale-codec", ] @@ -3721,7 +3724,7 @@ dependencies = [ [[package]] name = "fp-account" version = "1.0.0-dev" -source = "git+https://github.com/subspace/frontier?rev=56086daa77802eaa285894bfe4b811be66629c89#56086daa77802eaa285894bfe4b811be66629c89" +source = "git+https://github.com/subspace/frontier?rev=37ee45323120b21adc1d69ae7348bd0f7282eeae#37ee45323120b21adc1d69ae7348bd0f7282eeae" dependencies = [ "hex", "impl-serde", @@ -3740,7 +3743,7 @@ dependencies = [ [[package]] name = "fp-consensus" version = "2.0.0-dev" -source = "git+https://github.com/subspace/frontier?rev=56086daa77802eaa285894bfe4b811be66629c89#56086daa77802eaa285894bfe4b811be66629c89" +source = "git+https://github.com/subspace/frontier?rev=37ee45323120b21adc1d69ae7348bd0f7282eeae#37ee45323120b21adc1d69ae7348bd0f7282eeae" dependencies = [ "ethereum", "parity-scale-codec", @@ -3752,7 +3755,7 @@ dependencies = [ [[package]] name = "fp-ethereum" version = "1.0.0-dev" -source = "git+https://github.com/subspace/frontier?rev=56086daa77802eaa285894bfe4b811be66629c89#56086daa77802eaa285894bfe4b811be66629c89" +source = "git+https://github.com/subspace/frontier?rev=37ee45323120b21adc1d69ae7348bd0f7282eeae#37ee45323120b21adc1d69ae7348bd0f7282eeae" dependencies = [ "ethereum", "ethereum-types", @@ -3765,7 +3768,7 @@ dependencies = [ [[package]] name = "fp-evm" version = "3.0.0-dev" -source = "git+https://github.com/subspace/frontier?rev=56086daa77802eaa285894bfe4b811be66629c89#56086daa77802eaa285894bfe4b811be66629c89" +source = "git+https://github.com/subspace/frontier?rev=37ee45323120b21adc1d69ae7348bd0f7282eeae#37ee45323120b21adc1d69ae7348bd0f7282eeae" dependencies = [ "evm", "frame-support", @@ -3781,7 +3784,7 @@ dependencies = [ [[package]] name = "fp-rpc" version = "3.0.0-dev" -source = "git+https://github.com/subspace/frontier?rev=56086daa77802eaa285894bfe4b811be66629c89#56086daa77802eaa285894bfe4b811be66629c89" +source = "git+https://github.com/subspace/frontier?rev=37ee45323120b21adc1d69ae7348bd0f7282eeae#37ee45323120b21adc1d69ae7348bd0f7282eeae" dependencies = [ "ethereum", "ethereum-types", @@ -3798,7 +3801,7 @@ dependencies = [ [[package]] name = "fp-self-contained" version = "1.0.0-dev" -source = "git+https://github.com/subspace/frontier?rev=56086daa77802eaa285894bfe4b811be66629c89#56086daa77802eaa285894bfe4b811be66629c89" +source = "git+https://github.com/subspace/frontier?rev=37ee45323120b21adc1d69ae7348bd0f7282eeae#37ee45323120b21adc1d69ae7348bd0f7282eeae" dependencies = [ "frame-support", "parity-scale-codec", @@ -3810,7 +3813,7 @@ dependencies = [ [[package]] name = "fp-storage" version = "2.0.0" -source = "git+https://github.com/subspace/frontier?rev=56086daa77802eaa285894bfe4b811be66629c89#56086daa77802eaa285894bfe4b811be66629c89" +source = "git+https://github.com/subspace/frontier?rev=37ee45323120b21adc1d69ae7348bd0f7282eeae#37ee45323120b21adc1d69ae7348bd0f7282eeae" dependencies = [ "parity-scale-codec", "serde", @@ -3825,7 +3828,7 @@ checksum = "6c2141d6d6c8512188a7891b4b01590a45f6dac67afb4f255c4124dbb86d4eaa" [[package]] name = "frame-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/subspace/polkadot-sdk?rev=892bf8e938c6bd2b893d3827d1093cd81baa59a1#892bf8e938c6bd2b893d3827d1093cd81baa59a1" +source = "git+https://github.com/subspace/polkadot-sdk?rev=c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c#c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" dependencies = [ "frame-support", "frame-support-procedural", @@ -3850,7 +3853,7 @@ dependencies = [ [[package]] name = "frame-benchmarking-cli" version = "4.0.0-dev" -source = "git+https://github.com/subspace/polkadot-sdk?rev=892bf8e938c6bd2b893d3827d1093cd81baa59a1#892bf8e938c6bd2b893d3827d1093cd81baa59a1" +source = "git+https://github.com/subspace/polkadot-sdk?rev=c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c#c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" dependencies = [ "Inflector", "array-bytes", @@ -3898,7 +3901,7 @@ dependencies = [ [[package]] name = "frame-executive" version = "4.0.0-dev" -source = "git+https://github.com/subspace/polkadot-sdk?rev=892bf8e938c6bd2b893d3827d1093cd81baa59a1#892bf8e938c6bd2b893d3827d1093cd81baa59a1" +source = "git+https://github.com/subspace/polkadot-sdk?rev=c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c#c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" dependencies = [ "frame-support", "frame-system", @@ -3928,7 +3931,7 @@ dependencies = [ [[package]] name = "frame-support" version = "4.0.0-dev" -source = "git+https://github.com/subspace/polkadot-sdk?rev=892bf8e938c6bd2b893d3827d1093cd81baa59a1#892bf8e938c6bd2b893d3827d1093cd81baa59a1" +source = "git+https://github.com/subspace/polkadot-sdk?rev=c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c#c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" dependencies = [ "aquamarine", "bitflags 1.3.2", @@ -3968,7 +3971,7 @@ dependencies = [ [[package]] name = "frame-support-procedural" version = "4.0.0-dev" -source = "git+https://github.com/subspace/polkadot-sdk?rev=892bf8e938c6bd2b893d3827d1093cd81baa59a1#892bf8e938c6bd2b893d3827d1093cd81baa59a1" +source = "git+https://github.com/subspace/polkadot-sdk?rev=c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c#c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" dependencies = [ "Inflector", "cfg-expr", @@ -3986,7 +3989,7 @@ dependencies = [ [[package]] name = "frame-support-procedural-tools" version = "4.0.0-dev" -source = "git+https://github.com/subspace/polkadot-sdk?rev=892bf8e938c6bd2b893d3827d1093cd81baa59a1#892bf8e938c6bd2b893d3827d1093cd81baa59a1" +source = "git+https://github.com/subspace/polkadot-sdk?rev=c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c#c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" dependencies = [ "frame-support-procedural-tools-derive", "proc-macro-crate", @@ -3998,7 +4001,7 @@ dependencies = [ [[package]] name = "frame-support-procedural-tools-derive" version = "3.0.0" -source = "git+https://github.com/subspace/polkadot-sdk?rev=892bf8e938c6bd2b893d3827d1093cd81baa59a1#892bf8e938c6bd2b893d3827d1093cd81baa59a1" +source = "git+https://github.com/subspace/polkadot-sdk?rev=c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c#c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" dependencies = [ "proc-macro2", "quote", @@ -4008,7 +4011,7 @@ dependencies = [ [[package]] name = "frame-system" version = "4.0.0-dev" -source = "git+https://github.com/subspace/polkadot-sdk?rev=892bf8e938c6bd2b893d3827d1093cd81baa59a1#892bf8e938c6bd2b893d3827d1093cd81baa59a1" +source = "git+https://github.com/subspace/polkadot-sdk?rev=c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c#c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" dependencies = [ "cfg-if", "frame-support", @@ -4027,7 +4030,7 @@ dependencies = [ [[package]] name = "frame-system-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/subspace/polkadot-sdk?rev=892bf8e938c6bd2b893d3827d1093cd81baa59a1#892bf8e938c6bd2b893d3827d1093cd81baa59a1" +source = "git+https://github.com/subspace/polkadot-sdk?rev=c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c#c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" dependencies = [ "frame-benchmarking", "frame-support", @@ -4042,7 +4045,7 @@ dependencies = [ [[package]] name = "frame-system-rpc-runtime-api" version = "4.0.0-dev" -source = "git+https://github.com/subspace/polkadot-sdk?rev=892bf8e938c6bd2b893d3827d1093cd81baa59a1#892bf8e938c6bd2b893d3827d1093cd81baa59a1" +source = "git+https://github.com/subspace/polkadot-sdk?rev=c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c#c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" dependencies = [ "parity-scale-codec", "sp-api", @@ -4051,7 +4054,7 @@ dependencies = [ [[package]] name = "frame-try-runtime" version = "0.10.0-dev" -source = "git+https://github.com/subspace/polkadot-sdk?rev=892bf8e938c6bd2b893d3827d1093cd81baa59a1#892bf8e938c6bd2b893d3827d1093cd81baa59a1" +source = "git+https://github.com/subspace/polkadot-sdk?rev=c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c#c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" dependencies = [ "frame-support", "parity-scale-codec", @@ -7230,7 +7233,7 @@ dependencies = [ [[package]] name = "pallet-authorship" version = "4.0.0-dev" -source = "git+https://github.com/subspace/polkadot-sdk?rev=892bf8e938c6bd2b893d3827d1093cd81baa59a1#892bf8e938c6bd2b893d3827d1093cd81baa59a1" +source = "git+https://github.com/subspace/polkadot-sdk?rev=c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c#c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" dependencies = [ "frame-support", "frame-system", @@ -7244,7 +7247,7 @@ dependencies = [ [[package]] name = "pallet-babe" version = "4.0.0-dev" -source = "git+https://github.com/subspace/polkadot-sdk?rev=892bf8e938c6bd2b893d3827d1093cd81baa59a1#892bf8e938c6bd2b893d3827d1093cd81baa59a1" +source = "git+https://github.com/subspace/polkadot-sdk?rev=c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c#c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" dependencies = [ "frame-benchmarking", "frame-support", @@ -7268,7 +7271,7 @@ dependencies = [ [[package]] name = "pallet-balances" version = "4.0.0-dev" -source = "git+https://github.com/subspace/polkadot-sdk?rev=892bf8e938c6bd2b893d3827d1093cd81baa59a1#892bf8e938c6bd2b893d3827d1093cd81baa59a1" +source = "git+https://github.com/subspace/polkadot-sdk?rev=c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c#c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" dependencies = [ "frame-benchmarking", "frame-support", @@ -7283,7 +7286,7 @@ dependencies = [ [[package]] name = "pallet-base-fee" version = "1.0.0" -source = "git+https://github.com/subspace/frontier?rev=56086daa77802eaa285894bfe4b811be66629c89#56086daa77802eaa285894bfe4b811be66629c89" +source = "git+https://github.com/subspace/frontier?rev=37ee45323120b21adc1d69ae7348bd0f7282eeae#37ee45323120b21adc1d69ae7348bd0f7282eeae" dependencies = [ "fp-evm", "frame-support", @@ -7340,7 +7343,7 @@ dependencies = [ [[package]] name = "pallet-ethereum" version = "4.0.0-dev" -source = "git+https://github.com/subspace/frontier?rev=56086daa77802eaa285894bfe4b811be66629c89#56086daa77802eaa285894bfe4b811be66629c89" +source = "git+https://github.com/subspace/frontier?rev=37ee45323120b21adc1d69ae7348bd0f7282eeae#37ee45323120b21adc1d69ae7348bd0f7282eeae" dependencies = [ "ethereum", "ethereum-types", @@ -7363,7 +7366,7 @@ dependencies = [ [[package]] name = "pallet-evm" version = "6.0.0-dev" -source = "git+https://github.com/subspace/frontier?rev=56086daa77802eaa285894bfe4b811be66629c89#56086daa77802eaa285894bfe4b811be66629c89" +source = "git+https://github.com/subspace/frontier?rev=37ee45323120b21adc1d69ae7348bd0f7282eeae#37ee45323120b21adc1d69ae7348bd0f7282eeae" dependencies = [ "environmental", "evm", @@ -7388,7 +7391,7 @@ dependencies = [ [[package]] name = "pallet-evm-chain-id" version = "1.0.0-dev" -source = "git+https://github.com/subspace/frontier?rev=56086daa77802eaa285894bfe4b811be66629c89#56086daa77802eaa285894bfe4b811be66629c89" +source = "git+https://github.com/subspace/frontier?rev=37ee45323120b21adc1d69ae7348bd0f7282eeae#37ee45323120b21adc1d69ae7348bd0f7282eeae" dependencies = [ "frame-support", "frame-system", @@ -7400,7 +7403,7 @@ dependencies = [ [[package]] name = "pallet-evm-precompile-modexp" version = "2.0.0-dev" -source = "git+https://github.com/subspace/frontier?rev=56086daa77802eaa285894bfe4b811be66629c89#56086daa77802eaa285894bfe4b811be66629c89" +source = "git+https://github.com/subspace/frontier?rev=37ee45323120b21adc1d69ae7348bd0f7282eeae#37ee45323120b21adc1d69ae7348bd0f7282eeae" dependencies = [ "fp-evm", "num", @@ -7409,7 +7412,7 @@ dependencies = [ [[package]] name = "pallet-evm-precompile-sha3fips" version = "2.0.0-dev" -source = "git+https://github.com/subspace/frontier?rev=56086daa77802eaa285894bfe4b811be66629c89#56086daa77802eaa285894bfe4b811be66629c89" +source = "git+https://github.com/subspace/frontier?rev=37ee45323120b21adc1d69ae7348bd0f7282eeae#37ee45323120b21adc1d69ae7348bd0f7282eeae" dependencies = [ "fp-evm", "tiny-keccak", @@ -7418,7 +7421,7 @@ dependencies = [ [[package]] name = "pallet-evm-precompile-simple" version = "2.0.0-dev" -source = "git+https://github.com/subspace/frontier?rev=56086daa77802eaa285894bfe4b811be66629c89#56086daa77802eaa285894bfe4b811be66629c89" +source = "git+https://github.com/subspace/frontier?rev=37ee45323120b21adc1d69ae7348bd0f7282eeae#37ee45323120b21adc1d69ae7348bd0f7282eeae" dependencies = [ "fp-evm", "ripemd", @@ -7556,7 +7559,7 @@ dependencies = [ [[package]] name = "pallet-session" version = "4.0.0-dev" -source = "git+https://github.com/subspace/polkadot-sdk?rev=892bf8e938c6bd2b893d3827d1093cd81baa59a1#892bf8e938c6bd2b893d3827d1093cd81baa59a1" +source = "git+https://github.com/subspace/polkadot-sdk?rev=c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c#c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" dependencies = [ "frame-support", "frame-system", @@ -7611,7 +7614,7 @@ dependencies = [ [[package]] name = "pallet-sudo" version = "4.0.0-dev" -source = "git+https://github.com/subspace/polkadot-sdk?rev=892bf8e938c6bd2b893d3827d1093cd81baa59a1#892bf8e938c6bd2b893d3827d1093cd81baa59a1" +source = "git+https://github.com/subspace/polkadot-sdk?rev=c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c#c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" dependencies = [ "docify", "frame-benchmarking", @@ -7627,7 +7630,7 @@ dependencies = [ [[package]] name = "pallet-timestamp" version = "4.0.0-dev" -source = "git+https://github.com/subspace/polkadot-sdk?rev=892bf8e938c6bd2b893d3827d1093cd81baa59a1#892bf8e938c6bd2b893d3827d1093cd81baa59a1" +source = "git+https://github.com/subspace/polkadot-sdk?rev=c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c#c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" dependencies = [ "frame-benchmarking", "frame-support", @@ -7657,7 +7660,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment" version = "4.0.0-dev" -source = "git+https://github.com/subspace/polkadot-sdk?rev=892bf8e938c6bd2b893d3827d1093cd81baa59a1#892bf8e938c6bd2b893d3827d1093cd81baa59a1" +source = "git+https://github.com/subspace/polkadot-sdk?rev=c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c#c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" dependencies = [ "frame-support", "frame-system", @@ -7673,7 +7676,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment-rpc" version = "4.0.0-dev" -source = "git+https://github.com/subspace/polkadot-sdk?rev=892bf8e938c6bd2b893d3827d1093cd81baa59a1#892bf8e938c6bd2b893d3827d1093cd81baa59a1" +source = "git+https://github.com/subspace/polkadot-sdk?rev=c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c#c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" dependencies = [ "jsonrpsee", "pallet-transaction-payment-rpc-runtime-api", @@ -7689,7 +7692,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment-rpc-runtime-api" version = "4.0.0-dev" -source = "git+https://github.com/subspace/polkadot-sdk?rev=892bf8e938c6bd2b893d3827d1093cd81baa59a1#892bf8e938c6bd2b893d3827d1093cd81baa59a1" +source = "git+https://github.com/subspace/polkadot-sdk?rev=c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c#c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" dependencies = [ "pallet-transaction-payment", "parity-scale-codec", @@ -7719,7 +7722,7 @@ dependencies = [ [[package]] name = "pallet-utility" version = "4.0.0-dev" -source = "git+https://github.com/subspace/polkadot-sdk?rev=892bf8e938c6bd2b893d3827d1093cd81baa59a1#892bf8e938c6bd2b893d3827d1093cd81baa59a1" +source = "git+https://github.com/subspace/polkadot-sdk?rev=c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c#c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" dependencies = [ "frame-benchmarking", "frame-support", @@ -9142,7 +9145,7 @@ dependencies = [ [[package]] name = "sc-allocator" version = "4.1.0-dev" -source = "git+https://github.com/subspace/polkadot-sdk?rev=892bf8e938c6bd2b893d3827d1093cd81baa59a1#892bf8e938c6bd2b893d3827d1093cd81baa59a1" +source = "git+https://github.com/subspace/polkadot-sdk?rev=c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c#c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" dependencies = [ "log", "sp-core", @@ -9153,7 +9156,7 @@ dependencies = [ [[package]] name = "sc-basic-authorship" version = "0.10.0-dev" -source = "git+https://github.com/subspace/polkadot-sdk?rev=892bf8e938c6bd2b893d3827d1093cd81baa59a1#892bf8e938c6bd2b893d3827d1093cd81baa59a1" +source = "git+https://github.com/subspace/polkadot-sdk?rev=c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c#c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" dependencies = [ "futures", "futures-timer", @@ -9176,7 +9179,7 @@ dependencies = [ [[package]] name = "sc-block-builder" version = "0.10.0-dev" -source = "git+https://github.com/subspace/polkadot-sdk?rev=892bf8e938c6bd2b893d3827d1093cd81baa59a1#892bf8e938c6bd2b893d3827d1093cd81baa59a1" +source = "git+https://github.com/subspace/polkadot-sdk?rev=c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c#c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" dependencies = [ "parity-scale-codec", "sc-client-api", @@ -9191,7 +9194,7 @@ dependencies = [ [[package]] name = "sc-chain-spec" version = "4.0.0-dev" -source = "git+https://github.com/subspace/polkadot-sdk?rev=892bf8e938c6bd2b893d3827d1093cd81baa59a1#892bf8e938c6bd2b893d3827d1093cd81baa59a1" +source = "git+https://github.com/subspace/polkadot-sdk?rev=c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c#c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" dependencies = [ "memmap2 0.5.10", "sc-chain-spec-derive", @@ -9210,7 +9213,7 @@ dependencies = [ [[package]] name = "sc-chain-spec-derive" version = "4.0.0-dev" -source = "git+https://github.com/subspace/polkadot-sdk?rev=892bf8e938c6bd2b893d3827d1093cd81baa59a1#892bf8e938c6bd2b893d3827d1093cd81baa59a1" +source = "git+https://github.com/subspace/polkadot-sdk?rev=c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c#c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -9221,7 +9224,7 @@ dependencies = [ [[package]] name = "sc-cli" version = "0.10.0-dev" -source = "git+https://github.com/subspace/polkadot-sdk?rev=892bf8e938c6bd2b893d3827d1093cd81baa59a1#892bf8e938c6bd2b893d3827d1093cd81baa59a1" +source = "git+https://github.com/subspace/polkadot-sdk?rev=c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c#c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" dependencies = [ "array-bytes", "atomic", @@ -9261,7 +9264,7 @@ dependencies = [ [[package]] name = "sc-client-api" version = "4.0.0-dev" -source = "git+https://github.com/subspace/polkadot-sdk?rev=892bf8e938c6bd2b893d3827d1093cd81baa59a1#892bf8e938c6bd2b893d3827d1093cd81baa59a1" +source = "git+https://github.com/subspace/polkadot-sdk?rev=c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c#c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" dependencies = [ "fnv", "futures", @@ -9287,7 +9290,7 @@ dependencies = [ [[package]] name = "sc-client-db" version = "0.10.0-dev" -source = "git+https://github.com/subspace/polkadot-sdk?rev=892bf8e938c6bd2b893d3827d1093cd81baa59a1#892bf8e938c6bd2b893d3827d1093cd81baa59a1" +source = "git+https://github.com/subspace/polkadot-sdk?rev=c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c#c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" dependencies = [ "hash-db 0.16.0", "kvdb", @@ -9312,7 +9315,7 @@ dependencies = [ [[package]] name = "sc-consensus" version = "0.10.0-dev" -source = "git+https://github.com/subspace/polkadot-sdk?rev=892bf8e938c6bd2b893d3827d1093cd81baa59a1#892bf8e938c6bd2b893d3827d1093cd81baa59a1" +source = "git+https://github.com/subspace/polkadot-sdk?rev=c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c#c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" dependencies = [ "async-lock 2.8.0", "async-trait", @@ -9339,7 +9342,7 @@ dependencies = [ [[package]] name = "sc-consensus-aura" version = "0.10.0-dev" -source = "git+https://github.com/subspace/polkadot-sdk?rev=892bf8e938c6bd2b893d3827d1093cd81baa59a1#892bf8e938c6bd2b893d3827d1093cd81baa59a1" +source = "git+https://github.com/subspace/polkadot-sdk?rev=c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c#c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" dependencies = [ "async-trait", "futures", @@ -9368,7 +9371,7 @@ dependencies = [ [[package]] name = "sc-consensus-slots" version = "0.10.0-dev" -source = "git+https://github.com/subspace/polkadot-sdk?rev=892bf8e938c6bd2b893d3827d1093cd81baa59a1#892bf8e938c6bd2b893d3827d1093cd81baa59a1" +source = "git+https://github.com/subspace/polkadot-sdk?rev=c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c#c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" dependencies = [ "async-trait", "futures", @@ -9394,7 +9397,6 @@ version = "0.1.0" dependencies = [ "async-trait", "futures", - "log", "lru 0.11.1", "parity-scale-codec", "parking_lot 0.12.1", @@ -9425,6 +9427,7 @@ dependencies = [ "subspace-verification", "thiserror", "tokio", + "tracing", ] [[package]] @@ -9460,7 +9463,7 @@ dependencies = [ [[package]] name = "sc-executor" version = "0.10.0-dev" -source = "git+https://github.com/subspace/polkadot-sdk?rev=892bf8e938c6bd2b893d3827d1093cd81baa59a1#892bf8e938c6bd2b893d3827d1093cd81baa59a1" +source = "git+https://github.com/subspace/polkadot-sdk?rev=c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c#c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" dependencies = [ "parity-scale-codec", "parking_lot 0.12.1", @@ -9482,7 +9485,7 @@ dependencies = [ [[package]] name = "sc-executor-common" version = "0.10.0-dev" -source = "git+https://github.com/subspace/polkadot-sdk?rev=892bf8e938c6bd2b893d3827d1093cd81baa59a1#892bf8e938c6bd2b893d3827d1093cd81baa59a1" +source = "git+https://github.com/subspace/polkadot-sdk?rev=c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c#c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" dependencies = [ "sc-allocator", "sp-maybe-compressed-blob", @@ -9494,7 +9497,7 @@ dependencies = [ [[package]] name = "sc-executor-wasmtime" version = "0.10.0-dev" -source = "git+https://github.com/subspace/polkadot-sdk?rev=892bf8e938c6bd2b893d3827d1093cd81baa59a1#892bf8e938c6bd2b893d3827d1093cd81baa59a1" +source = "git+https://github.com/subspace/polkadot-sdk?rev=c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c#c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" dependencies = [ "anyhow", "cfg-if", @@ -9511,7 +9514,7 @@ dependencies = [ [[package]] name = "sc-informant" version = "0.10.0-dev" -source = "git+https://github.com/subspace/polkadot-sdk?rev=892bf8e938c6bd2b893d3827d1093cd81baa59a1#892bf8e938c6bd2b893d3827d1093cd81baa59a1" +source = "git+https://github.com/subspace/polkadot-sdk?rev=c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c#c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" dependencies = [ "ansi_term", "futures", @@ -9527,7 +9530,7 @@ dependencies = [ [[package]] name = "sc-keystore" version = "4.0.0-dev" -source = "git+https://github.com/subspace/polkadot-sdk?rev=892bf8e938c6bd2b893d3827d1093cd81baa59a1#892bf8e938c6bd2b893d3827d1093cd81baa59a1" +source = "git+https://github.com/subspace/polkadot-sdk?rev=c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c#c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" dependencies = [ "array-bytes", "parking_lot 0.12.1", @@ -9541,7 +9544,7 @@ dependencies = [ [[package]] name = "sc-network" version = "0.10.0-dev" -source = "git+https://github.com/subspace/polkadot-sdk?rev=892bf8e938c6bd2b893d3827d1093cd81baa59a1#892bf8e938c6bd2b893d3827d1093cd81baa59a1" +source = "git+https://github.com/subspace/polkadot-sdk?rev=c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c#c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" dependencies = [ "array-bytes", "async-channel", @@ -9583,7 +9586,7 @@ dependencies = [ [[package]] name = "sc-network-bitswap" version = "0.10.0-dev" -source = "git+https://github.com/subspace/polkadot-sdk?rev=892bf8e938c6bd2b893d3827d1093cd81baa59a1#892bf8e938c6bd2b893d3827d1093cd81baa59a1" +source = "git+https://github.com/subspace/polkadot-sdk?rev=c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c#c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" dependencies = [ "async-channel", "cid", @@ -9603,7 +9606,7 @@ dependencies = [ [[package]] name = "sc-network-common" version = "0.10.0-dev" -source = "git+https://github.com/subspace/polkadot-sdk?rev=892bf8e938c6bd2b893d3827d1093cd81baa59a1#892bf8e938c6bd2b893d3827d1093cd81baa59a1" +source = "git+https://github.com/subspace/polkadot-sdk?rev=c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c#c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" dependencies = [ "async-trait", "bitflags 1.3.2", @@ -9620,7 +9623,7 @@ dependencies = [ [[package]] name = "sc-network-gossip" version = "0.10.0-dev" -source = "git+https://github.com/subspace/polkadot-sdk?rev=892bf8e938c6bd2b893d3827d1093cd81baa59a1#892bf8e938c6bd2b893d3827d1093cd81baa59a1" +source = "git+https://github.com/subspace/polkadot-sdk?rev=c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c#c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" dependencies = [ "ahash 0.8.3", "futures", @@ -9638,7 +9641,7 @@ dependencies = [ [[package]] name = "sc-network-light" version = "0.10.0-dev" -source = "git+https://github.com/subspace/polkadot-sdk?rev=892bf8e938c6bd2b893d3827d1093cd81baa59a1#892bf8e938c6bd2b893d3827d1093cd81baa59a1" +source = "git+https://github.com/subspace/polkadot-sdk?rev=c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c#c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" dependencies = [ "array-bytes", "async-channel", @@ -9659,7 +9662,7 @@ dependencies = [ [[package]] name = "sc-network-sync" version = "0.10.0-dev" -source = "git+https://github.com/subspace/polkadot-sdk?rev=892bf8e938c6bd2b893d3827d1093cd81baa59a1#892bf8e938c6bd2b893d3827d1093cd81baa59a1" +source = "git+https://github.com/subspace/polkadot-sdk?rev=c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c#c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" dependencies = [ "array-bytes", "async-channel", @@ -9694,7 +9697,7 @@ dependencies = [ [[package]] name = "sc-network-transactions" version = "0.10.0-dev" -source = "git+https://github.com/subspace/polkadot-sdk?rev=892bf8e938c6bd2b893d3827d1093cd81baa59a1#892bf8e938c6bd2b893d3827d1093cd81baa59a1" +source = "git+https://github.com/subspace/polkadot-sdk?rev=c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c#c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" dependencies = [ "array-bytes", "futures", @@ -9712,7 +9715,7 @@ dependencies = [ [[package]] name = "sc-offchain" version = "4.0.0-dev" -source = "git+https://github.com/subspace/polkadot-sdk?rev=892bf8e938c6bd2b893d3827d1093cd81baa59a1#892bf8e938c6bd2b893d3827d1093cd81baa59a1" +source = "git+https://github.com/subspace/polkadot-sdk?rev=c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c#c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" dependencies = [ "array-bytes", "bytes", @@ -9774,7 +9777,7 @@ dependencies = [ [[package]] name = "sc-proposer-metrics" version = "0.10.0-dev" -source = "git+https://github.com/subspace/polkadot-sdk?rev=892bf8e938c6bd2b893d3827d1093cd81baa59a1#892bf8e938c6bd2b893d3827d1093cd81baa59a1" +source = "git+https://github.com/subspace/polkadot-sdk?rev=c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c#c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" dependencies = [ "log", "substrate-prometheus-endpoint", @@ -9783,7 +9786,7 @@ dependencies = [ [[package]] name = "sc-rpc" version = "4.0.0-dev" -source = "git+https://github.com/subspace/polkadot-sdk?rev=892bf8e938c6bd2b893d3827d1093cd81baa59a1#892bf8e938c6bd2b893d3827d1093cd81baa59a1" +source = "git+https://github.com/subspace/polkadot-sdk?rev=c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c#c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" dependencies = [ "futures", "jsonrpsee", @@ -9814,7 +9817,7 @@ dependencies = [ [[package]] name = "sc-rpc-api" version = "0.10.0-dev" -source = "git+https://github.com/subspace/polkadot-sdk?rev=892bf8e938c6bd2b893d3827d1093cd81baa59a1#892bf8e938c6bd2b893d3827d1093cd81baa59a1" +source = "git+https://github.com/subspace/polkadot-sdk?rev=c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c#c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" dependencies = [ "jsonrpsee", "parity-scale-codec", @@ -9833,7 +9836,7 @@ dependencies = [ [[package]] name = "sc-rpc-server" version = "4.0.0-dev" -source = "git+https://github.com/subspace/polkadot-sdk?rev=892bf8e938c6bd2b893d3827d1093cd81baa59a1#892bf8e938c6bd2b893d3827d1093cd81baa59a1" +source = "git+https://github.com/subspace/polkadot-sdk?rev=c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c#c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" dependencies = [ "http", "jsonrpsee", @@ -9848,7 +9851,7 @@ dependencies = [ [[package]] name = "sc-rpc-spec-v2" version = "0.10.0-dev" -source = "git+https://github.com/subspace/polkadot-sdk?rev=892bf8e938c6bd2b893d3827d1093cd81baa59a1#892bf8e938c6bd2b893d3827d1093cd81baa59a1" +source = "git+https://github.com/subspace/polkadot-sdk?rev=c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c#c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" dependencies = [ "array-bytes", "futures", @@ -9876,7 +9879,7 @@ dependencies = [ [[package]] name = "sc-service" version = "0.10.0-dev" -source = "git+https://github.com/subspace/polkadot-sdk?rev=892bf8e938c6bd2b893d3827d1093cd81baa59a1#892bf8e938c6bd2b893d3827d1093cd81baa59a1" +source = "git+https://github.com/subspace/polkadot-sdk?rev=c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c#c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" dependencies = [ "async-trait", "directories", @@ -9940,7 +9943,7 @@ dependencies = [ [[package]] name = "sc-state-db" version = "0.10.0-dev" -source = "git+https://github.com/subspace/polkadot-sdk?rev=892bf8e938c6bd2b893d3827d1093cd81baa59a1#892bf8e938c6bd2b893d3827d1093cd81baa59a1" +source = "git+https://github.com/subspace/polkadot-sdk?rev=c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c#c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" dependencies = [ "log", "parity-scale-codec", @@ -9951,7 +9954,7 @@ dependencies = [ [[package]] name = "sc-storage-monitor" version = "0.1.0" -source = "git+https://github.com/subspace/polkadot-sdk?rev=892bf8e938c6bd2b893d3827d1093cd81baa59a1#892bf8e938c6bd2b893d3827d1093cd81baa59a1" +source = "git+https://github.com/subspace/polkadot-sdk?rev=c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c#c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" dependencies = [ "clap", "fs4", @@ -10001,7 +10004,7 @@ dependencies = [ [[package]] name = "sc-sysinfo" version = "6.0.0-dev" -source = "git+https://github.com/subspace/polkadot-sdk?rev=892bf8e938c6bd2b893d3827d1093cd81baa59a1#892bf8e938c6bd2b893d3827d1093cd81baa59a1" +source = "git+https://github.com/subspace/polkadot-sdk?rev=c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c#c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" dependencies = [ "futures", "libc", @@ -10020,7 +10023,7 @@ dependencies = [ [[package]] name = "sc-telemetry" version = "4.0.0-dev" -source = "git+https://github.com/subspace/polkadot-sdk?rev=892bf8e938c6bd2b893d3827d1093cd81baa59a1#892bf8e938c6bd2b893d3827d1093cd81baa59a1" +source = "git+https://github.com/subspace/polkadot-sdk?rev=c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c#c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" dependencies = [ "chrono", "futures", @@ -10039,7 +10042,7 @@ dependencies = [ [[package]] name = "sc-tracing" version = "4.0.0-dev" -source = "git+https://github.com/subspace/polkadot-sdk?rev=892bf8e938c6bd2b893d3827d1093cd81baa59a1#892bf8e938c6bd2b893d3827d1093cd81baa59a1" +source = "git+https://github.com/subspace/polkadot-sdk?rev=c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c#c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" dependencies = [ "ansi_term", "atty", @@ -10068,7 +10071,7 @@ dependencies = [ [[package]] name = "sc-tracing-proc-macro" version = "4.0.0-dev" -source = "git+https://github.com/subspace/polkadot-sdk?rev=892bf8e938c6bd2b893d3827d1093cd81baa59a1#892bf8e938c6bd2b893d3827d1093cd81baa59a1" +source = "git+https://github.com/subspace/polkadot-sdk?rev=c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c#c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -10079,7 +10082,7 @@ dependencies = [ [[package]] name = "sc-transaction-pool" version = "4.0.0-dev" -source = "git+https://github.com/subspace/polkadot-sdk?rev=892bf8e938c6bd2b893d3827d1093cd81baa59a1#892bf8e938c6bd2b893d3827d1093cd81baa59a1" +source = "git+https://github.com/subspace/polkadot-sdk?rev=c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c#c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" dependencies = [ "async-trait", "futures", @@ -10105,7 +10108,7 @@ dependencies = [ [[package]] name = "sc-transaction-pool-api" version = "4.0.0-dev" -source = "git+https://github.com/subspace/polkadot-sdk?rev=892bf8e938c6bd2b893d3827d1093cd81baa59a1#892bf8e938c6bd2b893d3827d1093cd81baa59a1" +source = "git+https://github.com/subspace/polkadot-sdk?rev=c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c#c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" dependencies = [ "async-trait", "futures", @@ -10121,7 +10124,7 @@ dependencies = [ [[package]] name = "sc-utils" version = "4.0.0-dev" -source = "git+https://github.com/subspace/polkadot-sdk?rev=892bf8e938c6bd2b893d3827d1093cd81baa59a1#892bf8e938c6bd2b893d3827d1093cd81baa59a1" +source = "git+https://github.com/subspace/polkadot-sdk?rev=c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c#c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" dependencies = [ "async-channel", "futures", @@ -10654,7 +10657,7 @@ dependencies = [ [[package]] name = "sp-api" version = "4.0.0-dev" -source = "git+https://github.com/subspace/polkadot-sdk?rev=892bf8e938c6bd2b893d3827d1093cd81baa59a1#892bf8e938c6bd2b893d3827d1093cd81baa59a1" +source = "git+https://github.com/subspace/polkadot-sdk?rev=c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c#c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" dependencies = [ "hash-db 0.16.0", "log", @@ -10675,7 +10678,7 @@ dependencies = [ [[package]] name = "sp-api-proc-macro" version = "4.0.0-dev" -source = "git+https://github.com/subspace/polkadot-sdk?rev=892bf8e938c6bd2b893d3827d1093cd81baa59a1#892bf8e938c6bd2b893d3827d1093cd81baa59a1" +source = "git+https://github.com/subspace/polkadot-sdk?rev=c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c#c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" dependencies = [ "Inflector", "blake2", @@ -10689,7 +10692,7 @@ dependencies = [ [[package]] name = "sp-application-crypto" version = "23.0.0" -source = "git+https://github.com/subspace/polkadot-sdk?rev=892bf8e938c6bd2b893d3827d1093cd81baa59a1#892bf8e938c6bd2b893d3827d1093cd81baa59a1" +source = "git+https://github.com/subspace/polkadot-sdk?rev=c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c#c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" dependencies = [ "parity-scale-codec", "scale-info", @@ -10702,7 +10705,7 @@ dependencies = [ [[package]] name = "sp-arithmetic" version = "16.0.0" -source = "git+https://github.com/subspace/polkadot-sdk?rev=892bf8e938c6bd2b893d3827d1093cd81baa59a1#892bf8e938c6bd2b893d3827d1093cd81baa59a1" +source = "git+https://github.com/subspace/polkadot-sdk?rev=c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c#c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" dependencies = [ "integer-sqrt", "num-traits", @@ -10716,7 +10719,7 @@ dependencies = [ [[package]] name = "sp-block-builder" version = "4.0.0-dev" -source = "git+https://github.com/subspace/polkadot-sdk?rev=892bf8e938c6bd2b893d3827d1093cd81baa59a1#892bf8e938c6bd2b893d3827d1093cd81baa59a1" +source = "git+https://github.com/subspace/polkadot-sdk?rev=c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c#c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" dependencies = [ "sp-api", "sp-inherents", @@ -10727,7 +10730,7 @@ dependencies = [ [[package]] name = "sp-blockchain" version = "4.0.0-dev" -source = "git+https://github.com/subspace/polkadot-sdk?rev=892bf8e938c6bd2b893d3827d1093cd81baa59a1#892bf8e938c6bd2b893d3827d1093cd81baa59a1" +source = "git+https://github.com/subspace/polkadot-sdk?rev=c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c#c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" dependencies = [ "futures", "log", @@ -10745,7 +10748,7 @@ dependencies = [ [[package]] name = "sp-consensus" version = "0.10.0-dev" -source = "git+https://github.com/subspace/polkadot-sdk?rev=892bf8e938c6bd2b893d3827d1093cd81baa59a1#892bf8e938c6bd2b893d3827d1093cd81baa59a1" +source = "git+https://github.com/subspace/polkadot-sdk?rev=c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c#c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" dependencies = [ "async-trait", "futures", @@ -10760,7 +10763,7 @@ dependencies = [ [[package]] name = "sp-consensus-aura" version = "0.10.0-dev" -source = "git+https://github.com/subspace/polkadot-sdk?rev=892bf8e938c6bd2b893d3827d1093cd81baa59a1#892bf8e938c6bd2b893d3827d1093cd81baa59a1" +source = "git+https://github.com/subspace/polkadot-sdk?rev=c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c#c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" dependencies = [ "async-trait", "parity-scale-codec", @@ -10777,7 +10780,7 @@ dependencies = [ [[package]] name = "sp-consensus-babe" version = "0.10.0-dev" -source = "git+https://github.com/subspace/polkadot-sdk?rev=892bf8e938c6bd2b893d3827d1093cd81baa59a1#892bf8e938c6bd2b893d3827d1093cd81baa59a1" +source = "git+https://github.com/subspace/polkadot-sdk?rev=c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c#c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" dependencies = [ "async-trait", "parity-scale-codec", @@ -10796,7 +10799,7 @@ dependencies = [ [[package]] name = "sp-consensus-grandpa" version = "4.0.0-dev" -source = "git+https://github.com/subspace/polkadot-sdk?rev=892bf8e938c6bd2b893d3827d1093cd81baa59a1#892bf8e938c6bd2b893d3827d1093cd81baa59a1" +source = "git+https://github.com/subspace/polkadot-sdk?rev=c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c#c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" dependencies = [ "finality-grandpa", "log", @@ -10814,7 +10817,7 @@ dependencies = [ [[package]] name = "sp-consensus-slots" version = "0.10.0-dev" -source = "git+https://github.com/subspace/polkadot-sdk?rev=892bf8e938c6bd2b893d3827d1093cd81baa59a1#892bf8e938c6bd2b893d3827d1093cd81baa59a1" +source = "git+https://github.com/subspace/polkadot-sdk?rev=c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c#c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" dependencies = [ "parity-scale-codec", "scale-info", @@ -10852,7 +10855,7 @@ dependencies = [ [[package]] name = "sp-core" version = "21.0.0" -source = "git+https://github.com/subspace/polkadot-sdk?rev=892bf8e938c6bd2b893d3827d1093cd81baa59a1#892bf8e938c6bd2b893d3827d1093cd81baa59a1" +source = "git+https://github.com/subspace/polkadot-sdk?rev=c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c#c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" dependencies = [ "array-bytes", "bandersnatch_vrfs", @@ -10898,7 +10901,7 @@ dependencies = [ [[package]] name = "sp-core-hashing" version = "9.0.0" -source = "git+https://github.com/subspace/polkadot-sdk?rev=892bf8e938c6bd2b893d3827d1093cd81baa59a1#892bf8e938c6bd2b893d3827d1093cd81baa59a1" +source = "git+https://github.com/subspace/polkadot-sdk?rev=c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c#c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" dependencies = [ "blake2b_simd", "byteorder", @@ -10911,7 +10914,7 @@ dependencies = [ [[package]] name = "sp-core-hashing-proc-macro" version = "9.0.0" -source = "git+https://github.com/subspace/polkadot-sdk?rev=892bf8e938c6bd2b893d3827d1093cd81baa59a1#892bf8e938c6bd2b893d3827d1093cd81baa59a1" +source = "git+https://github.com/subspace/polkadot-sdk?rev=c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c#c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" dependencies = [ "quote", "sp-core-hashing", @@ -10921,7 +10924,7 @@ dependencies = [ [[package]] name = "sp-database" version = "4.0.0-dev" -source = "git+https://github.com/subspace/polkadot-sdk?rev=892bf8e938c6bd2b893d3827d1093cd81baa59a1#892bf8e938c6bd2b893d3827d1093cd81baa59a1" +source = "git+https://github.com/subspace/polkadot-sdk?rev=c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c#c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" dependencies = [ "kvdb", "parking_lot 0.12.1", @@ -10930,7 +10933,7 @@ dependencies = [ [[package]] name = "sp-debug-derive" version = "8.0.0" -source = "git+https://github.com/subspace/polkadot-sdk?rev=892bf8e938c6bd2b893d3827d1093cd81baa59a1#892bf8e938c6bd2b893d3827d1093cd81baa59a1" +source = "git+https://github.com/subspace/polkadot-sdk?rev=c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c#c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" dependencies = [ "proc-macro2", "quote", @@ -10988,6 +10991,7 @@ dependencies = [ "frame-system", "futures", "hash-db 0.16.0", + "log", "pallet-balances", "parity-scale-codec", "sc-cli", @@ -11031,7 +11035,7 @@ dependencies = [ [[package]] name = "sp-externalities" version = "0.19.0" -source = "git+https://github.com/subspace/polkadot-sdk?rev=892bf8e938c6bd2b893d3827d1093cd81baa59a1#892bf8e938c6bd2b893d3827d1093cd81baa59a1" +source = "git+https://github.com/subspace/polkadot-sdk?rev=c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c#c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" dependencies = [ "environmental", "parity-scale-codec", @@ -11042,7 +11046,7 @@ dependencies = [ [[package]] name = "sp-genesis-builder" version = "0.1.0" -source = "git+https://github.com/subspace/polkadot-sdk?rev=892bf8e938c6bd2b893d3827d1093cd81baa59a1#892bf8e938c6bd2b893d3827d1093cd81baa59a1" +source = "git+https://github.com/subspace/polkadot-sdk?rev=c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c#c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" dependencies = [ "serde_json", "sp-api", @@ -11053,7 +11057,7 @@ dependencies = [ [[package]] name = "sp-inherents" version = "4.0.0-dev" -source = "git+https://github.com/subspace/polkadot-sdk?rev=892bf8e938c6bd2b893d3827d1093cd81baa59a1#892bf8e938c6bd2b893d3827d1093cd81baa59a1" +source = "git+https://github.com/subspace/polkadot-sdk?rev=c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c#c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" dependencies = [ "async-trait", "impl-trait-for-tuples", @@ -11067,7 +11071,7 @@ dependencies = [ [[package]] name = "sp-io" version = "23.0.0" -source = "git+https://github.com/subspace/polkadot-sdk?rev=892bf8e938c6bd2b893d3827d1093cd81baa59a1#892bf8e938c6bd2b893d3827d1093cd81baa59a1" +source = "git+https://github.com/subspace/polkadot-sdk?rev=c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c#c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" dependencies = [ "bytes", "ed25519-dalek 2.0.0", @@ -11091,7 +11095,7 @@ dependencies = [ [[package]] name = "sp-keyring" version = "24.0.0" -source = "git+https://github.com/subspace/polkadot-sdk?rev=892bf8e938c6bd2b893d3827d1093cd81baa59a1#892bf8e938c6bd2b893d3827d1093cd81baa59a1" +source = "git+https://github.com/subspace/polkadot-sdk?rev=c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c#c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" dependencies = [ "lazy_static", "sp-core", @@ -11102,7 +11106,7 @@ dependencies = [ [[package]] name = "sp-keystore" version = "0.27.0" -source = "git+https://github.com/subspace/polkadot-sdk?rev=892bf8e938c6bd2b893d3827d1093cd81baa59a1#892bf8e938c6bd2b893d3827d1093cd81baa59a1" +source = "git+https://github.com/subspace/polkadot-sdk?rev=c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c#c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" dependencies = [ "parity-scale-codec", "parking_lot 0.12.1", @@ -11114,7 +11118,7 @@ dependencies = [ [[package]] name = "sp-maybe-compressed-blob" version = "4.1.0-dev" -source = "git+https://github.com/subspace/polkadot-sdk?rev=892bf8e938c6bd2b893d3827d1093cd81baa59a1#892bf8e938c6bd2b893d3827d1093cd81baa59a1" +source = "git+https://github.com/subspace/polkadot-sdk?rev=c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c#c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" dependencies = [ "thiserror", "zstd 0.12.4", @@ -11141,7 +11145,7 @@ dependencies = [ [[package]] name = "sp-metadata-ir" version = "0.1.0" -source = "git+https://github.com/subspace/polkadot-sdk?rev=892bf8e938c6bd2b893d3827d1093cd81baa59a1#892bf8e938c6bd2b893d3827d1093cd81baa59a1" +source = "git+https://github.com/subspace/polkadot-sdk?rev=c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c#c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" dependencies = [ "frame-metadata", "parity-scale-codec", @@ -11162,7 +11166,7 @@ dependencies = [ [[package]] name = "sp-offchain" version = "4.0.0-dev" -source = "git+https://github.com/subspace/polkadot-sdk?rev=892bf8e938c6bd2b893d3827d1093cd81baa59a1#892bf8e938c6bd2b893d3827d1093cd81baa59a1" +source = "git+https://github.com/subspace/polkadot-sdk?rev=c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c#c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" dependencies = [ "sp-api", "sp-core", @@ -11172,7 +11176,7 @@ dependencies = [ [[package]] name = "sp-panic-handler" version = "8.0.0" -source = "git+https://github.com/subspace/polkadot-sdk?rev=892bf8e938c6bd2b893d3827d1093cd81baa59a1#892bf8e938c6bd2b893d3827d1093cd81baa59a1" +source = "git+https://github.com/subspace/polkadot-sdk?rev=c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c#c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" dependencies = [ "backtrace", "lazy_static", @@ -11182,7 +11186,7 @@ dependencies = [ [[package]] name = "sp-rpc" version = "6.0.0" -source = "git+https://github.com/subspace/polkadot-sdk?rev=892bf8e938c6bd2b893d3827d1093cd81baa59a1#892bf8e938c6bd2b893d3827d1093cd81baa59a1" +source = "git+https://github.com/subspace/polkadot-sdk?rev=c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c#c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" dependencies = [ "rustc-hash", "serde", @@ -11192,7 +11196,7 @@ dependencies = [ [[package]] name = "sp-runtime" version = "24.0.0" -source = "git+https://github.com/subspace/polkadot-sdk?rev=892bf8e938c6bd2b893d3827d1093cd81baa59a1#892bf8e938c6bd2b893d3827d1093cd81baa59a1" +source = "git+https://github.com/subspace/polkadot-sdk?rev=c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c#c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" dependencies = [ "either", "hash256-std-hasher", @@ -11214,7 +11218,7 @@ dependencies = [ [[package]] name = "sp-runtime-interface" version = "17.0.0" -source = "git+https://github.com/subspace/polkadot-sdk?rev=892bf8e938c6bd2b893d3827d1093cd81baa59a1#892bf8e938c6bd2b893d3827d1093cd81baa59a1" +source = "git+https://github.com/subspace/polkadot-sdk?rev=c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c#c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" dependencies = [ "bytes", "impl-trait-for-tuples", @@ -11232,7 +11236,7 @@ dependencies = [ [[package]] name = "sp-runtime-interface-proc-macro" version = "11.0.0" -source = "git+https://github.com/subspace/polkadot-sdk?rev=892bf8e938c6bd2b893d3827d1093cd81baa59a1#892bf8e938c6bd2b893d3827d1093cd81baa59a1" +source = "git+https://github.com/subspace/polkadot-sdk?rev=c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c#c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" dependencies = [ "Inflector", "proc-macro-crate", @@ -11244,7 +11248,7 @@ dependencies = [ [[package]] name = "sp-session" version = "4.0.0-dev" -source = "git+https://github.com/subspace/polkadot-sdk?rev=892bf8e938c6bd2b893d3827d1093cd81baa59a1#892bf8e938c6bd2b893d3827d1093cd81baa59a1" +source = "git+https://github.com/subspace/polkadot-sdk?rev=c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c#c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" dependencies = [ "parity-scale-codec", "scale-info", @@ -11259,7 +11263,7 @@ dependencies = [ [[package]] name = "sp-staking" version = "4.0.0-dev" -source = "git+https://github.com/subspace/polkadot-sdk?rev=892bf8e938c6bd2b893d3827d1093cd81baa59a1#892bf8e938c6bd2b893d3827d1093cd81baa59a1" +source = "git+https://github.com/subspace/polkadot-sdk?rev=c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c#c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" dependencies = [ "impl-trait-for-tuples", "parity-scale-codec", @@ -11273,7 +11277,7 @@ dependencies = [ [[package]] name = "sp-state-machine" version = "0.28.0" -source = "git+https://github.com/subspace/polkadot-sdk?rev=892bf8e938c6bd2b893d3827d1093cd81baa59a1#892bf8e938c6bd2b893d3827d1093cd81baa59a1" +source = "git+https://github.com/subspace/polkadot-sdk?rev=c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c#c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" dependencies = [ "hash-db 0.16.0", "log", @@ -11294,7 +11298,7 @@ dependencies = [ [[package]] name = "sp-statement-store" version = "4.0.0-dev" -source = "git+https://github.com/subspace/polkadot-sdk?rev=892bf8e938c6bd2b893d3827d1093cd81baa59a1#892bf8e938c6bd2b893d3827d1093cd81baa59a1" +source = "git+https://github.com/subspace/polkadot-sdk?rev=c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c#c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" dependencies = [ "aes-gcm 0.10.2", "curve25519-dalek 4.1.1", @@ -11318,12 +11322,12 @@ dependencies = [ [[package]] name = "sp-std" version = "8.0.0" -source = "git+https://github.com/subspace/polkadot-sdk?rev=892bf8e938c6bd2b893d3827d1093cd81baa59a1#892bf8e938c6bd2b893d3827d1093cd81baa59a1" +source = "git+https://github.com/subspace/polkadot-sdk?rev=c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c#c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" [[package]] name = "sp-storage" version = "13.0.0" -source = "git+https://github.com/subspace/polkadot-sdk?rev=892bf8e938c6bd2b893d3827d1093cd81baa59a1#892bf8e938c6bd2b893d3827d1093cd81baa59a1" +source = "git+https://github.com/subspace/polkadot-sdk?rev=c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c#c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" dependencies = [ "impl-serde", "parity-scale-codec", @@ -11336,7 +11340,7 @@ dependencies = [ [[package]] name = "sp-timestamp" version = "4.0.0-dev" -source = "git+https://github.com/subspace/polkadot-sdk?rev=892bf8e938c6bd2b893d3827d1093cd81baa59a1#892bf8e938c6bd2b893d3827d1093cd81baa59a1" +source = "git+https://github.com/subspace/polkadot-sdk?rev=c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c#c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" dependencies = [ "async-trait", "parity-scale-codec", @@ -11349,7 +11353,7 @@ dependencies = [ [[package]] name = "sp-tracing" version = "10.0.0" -source = "git+https://github.com/subspace/polkadot-sdk?rev=892bf8e938c6bd2b893d3827d1093cd81baa59a1#892bf8e938c6bd2b893d3827d1093cd81baa59a1" +source = "git+https://github.com/subspace/polkadot-sdk?rev=c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c#c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" dependencies = [ "parity-scale-codec", "sp-std", @@ -11361,7 +11365,7 @@ dependencies = [ [[package]] name = "sp-transaction-pool" version = "4.0.0-dev" -source = "git+https://github.com/subspace/polkadot-sdk?rev=892bf8e938c6bd2b893d3827d1093cd81baa59a1#892bf8e938c6bd2b893d3827d1093cd81baa59a1" +source = "git+https://github.com/subspace/polkadot-sdk?rev=c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c#c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" dependencies = [ "sp-api", "sp-runtime", @@ -11370,7 +11374,7 @@ dependencies = [ [[package]] name = "sp-transaction-storage-proof" version = "4.0.0-dev" -source = "git+https://github.com/subspace/polkadot-sdk?rev=892bf8e938c6bd2b893d3827d1093cd81baa59a1#892bf8e938c6bd2b893d3827d1093cd81baa59a1" +source = "git+https://github.com/subspace/polkadot-sdk?rev=c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c#c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" dependencies = [ "async-trait", "parity-scale-codec", @@ -11385,7 +11389,7 @@ dependencies = [ [[package]] name = "sp-trie" version = "22.0.0" -source = "git+https://github.com/subspace/polkadot-sdk?rev=892bf8e938c6bd2b893d3827d1093cd81baa59a1#892bf8e938c6bd2b893d3827d1093cd81baa59a1" +source = "git+https://github.com/subspace/polkadot-sdk?rev=c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c#c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" dependencies = [ "ahash 0.8.3", "hash-db 0.16.0", @@ -11408,7 +11412,7 @@ dependencies = [ [[package]] name = "sp-version" version = "22.0.0" -source = "git+https://github.com/subspace/polkadot-sdk?rev=892bf8e938c6bd2b893d3827d1093cd81baa59a1#892bf8e938c6bd2b893d3827d1093cd81baa59a1" +source = "git+https://github.com/subspace/polkadot-sdk?rev=c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c#c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" dependencies = [ "impl-serde", "parity-scale-codec", @@ -11425,7 +11429,7 @@ dependencies = [ [[package]] name = "sp-version-proc-macro" version = "8.0.0" -source = "git+https://github.com/subspace/polkadot-sdk?rev=892bf8e938c6bd2b893d3827d1093cd81baa59a1#892bf8e938c6bd2b893d3827d1093cd81baa59a1" +source = "git+https://github.com/subspace/polkadot-sdk?rev=c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c#c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" dependencies = [ "parity-scale-codec", "proc-macro2", @@ -11436,7 +11440,7 @@ dependencies = [ [[package]] name = "sp-wasm-interface" version = "14.0.0" -source = "git+https://github.com/subspace/polkadot-sdk?rev=892bf8e938c6bd2b893d3827d1093cd81baa59a1#892bf8e938c6bd2b893d3827d1093cd81baa59a1" +source = "git+https://github.com/subspace/polkadot-sdk?rev=c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c#c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" dependencies = [ "anyhow", "impl-trait-for-tuples", @@ -11449,7 +11453,7 @@ dependencies = [ [[package]] name = "sp-weights" version = "20.0.0" -source = "git+https://github.com/subspace/polkadot-sdk?rev=892bf8e938c6bd2b893d3827d1093cd81baa59a1#892bf8e938c6bd2b893d3827d1093cd81baa59a1" +source = "git+https://github.com/subspace/polkadot-sdk?rev=c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c#c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" dependencies = [ "parity-scale-codec", "scale-info", @@ -11831,6 +11835,7 @@ dependencies = [ "sc-consensus-slots", "sc-consensus-subspace", "sc-executor", + "sc-network", "sc-network-sync", "sc-service", "sc-storage-monitor", @@ -12191,12 +12196,12 @@ dependencies = [ [[package]] name = "substrate-build-script-utils" version = "3.0.0" -source = "git+https://github.com/subspace/polkadot-sdk?rev=892bf8e938c6bd2b893d3827d1093cd81baa59a1#892bf8e938c6bd2b893d3827d1093cd81baa59a1" +source = "git+https://github.com/subspace/polkadot-sdk?rev=c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c#c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" [[package]] name = "substrate-frame-rpc-system" version = "4.0.0-dev" -source = "git+https://github.com/subspace/polkadot-sdk?rev=892bf8e938c6bd2b893d3827d1093cd81baa59a1#892bf8e938c6bd2b893d3827d1093cd81baa59a1" +source = "git+https://github.com/subspace/polkadot-sdk?rev=c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c#c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" dependencies = [ "frame-system-rpc-runtime-api", "futures", @@ -12215,7 +12220,7 @@ dependencies = [ [[package]] name = "substrate-prometheus-endpoint" version = "0.10.0-dev" -source = "git+https://github.com/subspace/polkadot-sdk?rev=892bf8e938c6bd2b893d3827d1093cd81baa59a1#892bf8e938c6bd2b893d3827d1093cd81baa59a1" +source = "git+https://github.com/subspace/polkadot-sdk?rev=c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c#c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" dependencies = [ "hyper", "log", @@ -12227,7 +12232,7 @@ dependencies = [ [[package]] name = "substrate-test-client" version = "2.0.1" -source = "git+https://github.com/subspace/polkadot-sdk?rev=892bf8e938c6bd2b893d3827d1093cd81baa59a1#892bf8e938c6bd2b893d3827d1093cd81baa59a1" +source = "git+https://github.com/subspace/polkadot-sdk?rev=c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c#c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" dependencies = [ "array-bytes", "async-trait", @@ -12253,7 +12258,7 @@ dependencies = [ [[package]] name = "substrate-test-runtime" version = "2.0.0" -source = "git+https://github.com/subspace/polkadot-sdk?rev=892bf8e938c6bd2b893d3827d1093cd81baa59a1#892bf8e938c6bd2b893d3827d1093cd81baa59a1" +source = "git+https://github.com/subspace/polkadot-sdk?rev=c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c#c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" dependencies = [ "array-bytes", "frame-executive", @@ -12296,7 +12301,7 @@ dependencies = [ [[package]] name = "substrate-test-runtime-client" version = "2.0.0" -source = "git+https://github.com/subspace/polkadot-sdk?rev=892bf8e938c6bd2b893d3827d1093cd81baa59a1#892bf8e938c6bd2b893d3827d1093cd81baa59a1" +source = "git+https://github.com/subspace/polkadot-sdk?rev=c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c#c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" dependencies = [ "futures", "sc-block-builder", @@ -12314,7 +12319,7 @@ dependencies = [ [[package]] name = "substrate-wasm-builder" version = "5.0.0-dev" -source = "git+https://github.com/subspace/polkadot-sdk?rev=892bf8e938c6bd2b893d3827d1093cd81baa59a1#892bf8e938c6bd2b893d3827d1093cd81baa59a1" +source = "git+https://github.com/subspace/polkadot-sdk?rev=c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c#c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" dependencies = [ "ansi_term", "build-helper", diff --git a/Cargo.toml b/Cargo.toml index 0dd7b4a611..9e4f6438b0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -92,42 +92,42 @@ lto = "fat" # Reason: We need to patch substrate dependency of frontier to our fork # TODO: Remove if/when we are using upstream substrate instead of fork [patch."https://github.com/paritytech/polkadot-sdk.git"] -frame-benchmarking = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -frame-support = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -frame-system = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sc-block-builder = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sc-client-db = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sc-consensus = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sc-consensus-aura = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sc-consensus-slots = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sc-client-api = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sc-network = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sc-network-common = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sc-network-sync = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sc-rpc = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sc-service = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sc-telemetry = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sc-transaction-pool = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sc-transaction-pool-api = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sc-utils = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-api = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-application-crypto = { version = "23.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-block-builder = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-blockchain = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-consensus = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-consensus-aura = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-consensus-slots = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-core = { version = "21.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-database = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-externalities = { version = "0.19.0", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-keystore = { version = "0.27.0", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-runtime-interface = { version = "17.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-state-machine = { version = "0.28.0", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-std = { version = "8.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-storage = { version = "13.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-timestamp = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-trie = { version = "22.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-inherents = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-io = { version = "23.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-runtime = { version = "24.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -substrate-prometheus-endpoint = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +frame-benchmarking = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +frame-support = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +frame-system = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sc-block-builder = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sc-client-db = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sc-consensus = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sc-consensus-aura = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sc-consensus-slots = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sc-client-api = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sc-network = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sc-network-common = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sc-network-sync = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sc-rpc = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sc-service = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sc-telemetry = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sc-transaction-pool = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sc-transaction-pool-api = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sc-utils = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-api = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-application-crypto = { version = "23.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-block-builder = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-blockchain = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-consensus = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-consensus-aura = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-consensus-slots = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-core = { version = "21.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-database = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-externalities = { version = "0.19.0", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-keystore = { version = "0.27.0", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-runtime-interface = { version = "17.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-state-machine = { version = "0.28.0", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-std = { version = "8.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-storage = { version = "13.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-timestamp = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-trie = { version = "22.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-inherents = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-io = { version = "23.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-runtime = { version = "24.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +substrate-prometheus-endpoint = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } diff --git a/Dockerfile-bootstrap-node b/Dockerfile-bootstrap-node index 4eea003fd7..b5c9e62f6b 100644 --- a/Dockerfile-bootstrap-node +++ b/Dockerfile-bootstrap-node @@ -25,6 +25,7 @@ RUN \ RUN /root/.cargo/bin/rustup target add wasm32-unknown-unknown +COPY .cargo /code/.cargo COPY Cargo.lock /code/Cargo.lock COPY Cargo.toml /code/Cargo.toml COPY rust-toolchain.toml /code/rust-toolchain.toml diff --git a/Dockerfile-bootstrap-node.aarch64 b/Dockerfile-bootstrap-node.aarch64 index 0688457823..e338397b70 100644 --- a/Dockerfile-bootstrap-node.aarch64 +++ b/Dockerfile-bootstrap-node.aarch64 @@ -25,6 +25,7 @@ RUN \ RUN /root/.cargo/bin/rustup target add wasm32-unknown-unknown +COPY .cargo /code/.cargo COPY Cargo.lock /code/Cargo.lock COPY Cargo.toml /code/Cargo.toml COPY rust-toolchain.toml /code/rust-toolchain.toml diff --git a/Dockerfile-farmer b/Dockerfile-farmer index e12882b465..186be74565 100644 --- a/Dockerfile-farmer +++ b/Dockerfile-farmer @@ -25,6 +25,7 @@ RUN \ RUN /root/.cargo/bin/rustup target add wasm32-unknown-unknown +COPY .cargo /code/.cargo COPY Cargo.lock /code/Cargo.lock COPY Cargo.toml /code/Cargo.toml COPY rust-toolchain.toml /code/rust-toolchain.toml diff --git a/Dockerfile-farmer.aarch64 b/Dockerfile-farmer.aarch64 index f65198b7a3..42a0dc0e33 100644 --- a/Dockerfile-farmer.aarch64 +++ b/Dockerfile-farmer.aarch64 @@ -25,6 +25,7 @@ RUN \ RUN /root/.cargo/bin/rustup target add wasm32-unknown-unknown +COPY .cargo /code/.cargo COPY Cargo.lock /code/Cargo.lock COPY Cargo.toml /code/Cargo.toml COPY rust-toolchain.toml /code/rust-toolchain.toml diff --git a/Dockerfile-node b/Dockerfile-node index 7b78a40ef9..dd50db59ae 100644 --- a/Dockerfile-node +++ b/Dockerfile-node @@ -25,6 +25,7 @@ RUN \ RUN /root/.cargo/bin/rustup target add wasm32-unknown-unknown +COPY .cargo /code/.cargo COPY Cargo.lock /code/Cargo.lock COPY Cargo.toml /code/Cargo.toml COPY rust-toolchain.toml /code/rust-toolchain.toml diff --git a/Dockerfile-node.aarch64 b/Dockerfile-node.aarch64 index fc47adc9bf..55693d3816 100644 --- a/Dockerfile-node.aarch64 +++ b/Dockerfile-node.aarch64 @@ -25,6 +25,7 @@ RUN \ RUN /root/.cargo/bin/rustup target add wasm32-unknown-unknown +COPY .cargo /code/.cargo COPY Cargo.lock /code/Cargo.lock COPY Cargo.toml /code/Cargo.toml COPY rust-toolchain.toml /code/rust-toolchain.toml diff --git a/Dockerfile-runtime b/Dockerfile-runtime index cca3d8cd80..6be061e62c 100644 --- a/Dockerfile-runtime +++ b/Dockerfile-runtime @@ -24,6 +24,7 @@ RUN \ RUN /root/.cargo/bin/rustup target add wasm32-unknown-unknown +COPY .cargo /code/.cargo COPY Cargo.lock /code/Cargo.lock COPY Cargo.toml /code/Cargo.toml COPY rust-toolchain.toml /code/rust-toolchain.toml diff --git a/crates/pallet-domains/Cargo.toml b/crates/pallet-domains/Cargo.toml index e10b2923f9..95542154d8 100644 --- a/crates/pallet-domains/Cargo.toml +++ b/crates/pallet-domains/Cargo.toml @@ -14,29 +14,29 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] codec = { package = "parity-scale-codec", version = "3.6.5", default-features = false, features = ["derive"] } domain-runtime-primitives = { version = "0.1.0", default-features = false, path = "../../domains/primitives/runtime" } -frame-benchmarking = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1", optional = true } -frame-support = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -frame-system = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +frame-benchmarking = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c", optional = true } +frame-support = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +frame-system = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } log = { version = "0.4.20", default-features = false } scale-info = { version = "2.7.0", default-features = false, features = ["derive"] } -sp-consensus-slots = { version = "0.10.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-core = { version = "21.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +sp-consensus-slots = { version = "0.10.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-core = { version = "21.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } sp-domains = { version = "0.1.0", default-features = false, path = "../sp-domains" } sp-domains-fraud-proof = { version = "0.1.0", default-features = false, path = "../sp-domains-fraud-proof" } -sp-io = { version = "23.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-runtime = { version = "24.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-std = { version = "8.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-version = { version = "22.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1", features = ["serde"] } +sp-io = { version = "23.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-runtime = { version = "24.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-std = { version = "8.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-version = { version = "22.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c", features = ["serde"] } subspace-core-primitives = { version = "0.1.0", default-features = false, path = "../subspace-core-primitives" } subspace-runtime-primitives = { version = "0.1.0", default-features = false, path = "../subspace-runtime-primitives" } [dev-dependencies] domain-pallet-executive = { version = "0.1.0", default-features = false, path = "../../domains/pallets/executive" } -pallet-balances = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -pallet-timestamp = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-externalities = { version = "0.19.0", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-state-machine = { version = "0.28.0", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-trie = { version = "22.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +pallet-balances = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +pallet-timestamp = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-externalities = { version = "0.19.0", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-state-machine = { version = "0.28.0", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-trie = { version = "22.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } [features] default = ["std"] diff --git a/crates/pallet-domains/src/lib.rs b/crates/pallet-domains/src/lib.rs index 3a2f47c1ac..6427baaeea 100644 --- a/crates/pallet-domains/src/lib.rs +++ b/crates/pallet-domains/src/lib.rs @@ -27,7 +27,6 @@ mod tests; pub mod block_tree; pub mod domain_registry; -pub mod migrations; pub mod runtime_registry; mod staking; mod staking_epoch; @@ -111,7 +110,7 @@ pub type DomainHashingFor = <::DomainHeader as Header>::Hashing; pub type ReceiptHashFor = <::DomainHeader as Header>::Hash; /// The current storage version. -const STORAGE_VERSION: StorageVersion = StorageVersion::new(3); +const STORAGE_VERSION: StorageVersion = StorageVersion::new(0); #[frame_support::pallet] mod pallet { @@ -1498,11 +1497,6 @@ impl Pallet { DomainStakingSummary::::get(domain_id), ) { (Some(domain_object), Some(stake_summary)) => Some(BundleProducerElectionParams { - current_operators: stake_summary - .current_operators - .keys() - .cloned() - .collect::>(), total_domain_stake: stake_summary.current_total_stake, bundle_slot_probability: domain_object.domain_config.bundle_slot_probability, }), diff --git a/crates/pallet-domains/src/migrations.rs b/crates/pallet-domains/src/migrations.rs deleted file mode 100644 index e0fe5dbccf..0000000000 --- a/crates/pallet-domains/src/migrations.rs +++ /dev/null @@ -1,154 +0,0 @@ -//! Migration module for pallet-domains - -use crate::Config; -use frame_support::traits::OnRuntimeUpgrade; -use frame_support::weights::Weight; - -pub struct VersionUncheckedMigrateV1ToV2(sp_std::marker::PhantomData); -impl OnRuntimeUpgrade for VersionUncheckedMigrateV1ToV2 { - fn on_runtime_upgrade() -> Weight { - signing_key_index_migration::index_operator_signing_keys_v1_to_v2::() - } -} - -pub struct VersionUncheckedMigrateV2ToV3(sp_std::marker::PhantomData); -impl OnRuntimeUpgrade for VersionUncheckedMigrateV2ToV3 { - fn on_runtime_upgrade() -> Weight { - signing_key_index_migration::index_operator_signing_keys_v2_to_v3::() - } -} - -pub(super) mod signing_key_index_migration { - use crate::pallet::{OperatorSigningKey as OperatorSigningKeyV3, Operators}; - use crate::Config; - use frame_support::pallet_prelude::{OptionQuery, Weight}; - use frame_support::{storage_alias, Identity}; - use sp_core::Get; - use sp_domains::{OperatorId, OperatorPublicKey}; - use sp_std::collections::btree_set::BTreeSet; - - #[storage_alias] - pub(super) type OperatorSigningKey = StorageMap< - crate::Pallet, - Identity, - OperatorPublicKey, - BTreeSet, - OptionQuery, - >; - - /// Indexes the currently used operator's signing keys into v2 domains storage. - pub(super) fn index_operator_signing_keys_v1_to_v2() -> Weight { - let mut count = 0; - Operators::::iter().for_each(|(operator_id, operator)| { - count += 1; - OperatorSigningKey::::append(operator.signing_key, operator_id) - }); - - T::DbWeight::get().reads_writes(count, count) - } - - /// Indexes the currently used operator's signing keys into v3 storage item. - pub(super) fn index_operator_signing_keys_v2_to_v3() -> Weight { - let mut count = 0; - let keys = OperatorSigningKey::::drain(); - keys.for_each(|(signing_key, operators)| { - count += 1; - let maybe_operator_id = operators.first().cloned(); - if let Some(operator_id) = maybe_operator_id { - OperatorSigningKeyV3::::insert(signing_key, operator_id) - } - }); - - T::DbWeight::get().reads_writes(count, count) - } -} - -#[cfg(test)] -mod tests { - use crate::migrations::signing_key_index_migration::OperatorSigningKey as OperatorSigningKeyV2; - use crate::pallet::{OperatorSigningKey as OperatorSigningKeyV3, Operators}; - use crate::staking::{Operator, OperatorStatus}; - use crate::tests::{new_test_ext, Test}; - use sp_core::{Pair, U256}; - use sp_domains::OperatorPair; - use std::collections::BTreeSet; - use subspace_runtime_primitives::{Balance, SSC}; - - #[test] - fn test_index_operator_signing_keys() { - let mut ext = new_test_ext(); - let create_operator = |signing_key| -> Operator { - Operator { - signing_key, - current_domain_id: Default::default(), - next_domain_id: Default::default(), - minimum_nominator_stake: 100 * SSC, - nomination_tax: Default::default(), - current_total_stake: 100 * SSC, - current_epoch_rewards: Default::default(), - total_shares: Default::default(), - status: OperatorStatus::Registered, - } - }; - - let pair_1 = OperatorPair::from_seed(&U256::from(0u32).into()); - let pair_2 = OperatorPair::from_seed(&U256::from(1u32).into()); - - ext.execute_with(|| { - // operator uses pair_1 - Operators::::insert(1, create_operator(pair_1.public())); - - // operator uses pair_2 - Operators::::insert(2, create_operator(pair_2.public())); - - // operator uses pair_2 - Operators::::insert(3, create_operator(pair_2.public())); - - assert!(!OperatorSigningKeyV2::::contains_key(pair_1.public())); - assert!(!OperatorSigningKeyV2::::contains_key(pair_2.public())); - }); - - ext.commit_all().unwrap(); - - ext.execute_with(|| { - let weights = - crate::migrations::signing_key_index_migration::index_operator_signing_keys_v1_to_v2::( - ); - assert_eq!( - weights, - ::DbWeight::get().reads_writes(3, 3), - ); - - assert_eq!( - OperatorSigningKeyV2::::get(pair_1.public()), - Some(BTreeSet::from([1])) - ); - assert_eq!( - OperatorSigningKeyV2::::get(pair_2.public()), - Some(BTreeSet::from([2, 3])) - ); - }); - - ext.commit_all().unwrap(); - - ext.execute_with(|| { - let weights = - crate::migrations::signing_key_index_migration::index_operator_signing_keys_v2_to_v3::( - ); - assert_eq!( - weights, - // only 2 migrations since we have only 2 signing keys - ::DbWeight::get().reads_writes(2, 2), - ); - - assert_eq!( - OperatorSigningKeyV3::::get(pair_1.public()), - Some(1) - ); - assert_eq!( - OperatorSigningKeyV3::::get(pair_2.public()), - Some(2) - ); - }) - } -} diff --git a/crates/pallet-domains/src/staking.rs b/crates/pallet-domains/src/staking.rs index 0dc7731690..cc482bd08b 100644 --- a/crates/pallet-domains/src/staking.rs +++ b/crates/pallet-domains/src/staking.rs @@ -552,7 +552,13 @@ where { for (operator_id, reason) in operator_ids { Operators::::try_mutate(operator_id, |maybe_operator| { - let operator = maybe_operator.as_mut().ok_or(Error::UnknownOperator)?; + let operator = match maybe_operator.as_mut() { + // If the operator is already slashed and removed due to fraud proof, when the operator + // is slash again due to invalid bundle, which happen after the ER is confirmed, we can + // not find the operator here thus just return. + None => return Ok(()), + Some(operator) => operator, + }; let mut pending_slashes = PendingSlashes::::get(operator.current_domain_id).unwrap_or_default(); @@ -1558,6 +1564,80 @@ pub(crate) mod tests { }); } + #[test] + fn slash_operators() { + let domain_id = DomainId::new(0); + let operator_free_balance = 250 * SSC; + let operator_stake = 200 * SSC; + + let operator_account_1 = 1; + let operator_account_2 = 2; + let operator_account_3 = 3; + + let pair_1 = OperatorPair::from_seed(&U256::from(0u32).into()); + let pair_2 = OperatorPair::from_seed(&U256::from(1u32).into()); + let pair_3 = OperatorPair::from_seed(&U256::from(2u32).into()); + + let mut ext = new_test_ext(); + ext.execute_with(|| { + let (operator_id_1, _) = register_operator( + domain_id, + operator_account_1, + operator_free_balance, + operator_stake, + 10 * SSC, + pair_1.public(), + Default::default(), + ); + + let (operator_id_2, _) = register_operator( + domain_id, + operator_account_2, + operator_free_balance, + operator_stake, + 10 * SSC, + pair_2.public(), + Default::default(), + ); + + let (operator_id_3, _) = register_operator( + domain_id, + operator_account_3, + operator_free_balance, + operator_stake, + 10 * SSC, + pair_3.public(), + Default::default(), + ); + + do_finalize_domain_current_epoch::(domain_id, Zero::zero()).unwrap(); + + do_slash_operators::( + vec![ + (operator_id_1, SlashedReason::InvalidBundle(1)), + (operator_id_2, SlashedReason::InvalidBundle(2)), + (operator_id_3, SlashedReason::InvalidBundle(3)), + ] + .into_iter(), + ) + .unwrap(); + + let domain_stake_summary = DomainStakingSummary::::get(domain_id).unwrap(); + assert!(!domain_stake_summary.next_operators.contains(&operator_id_1)); + assert!(!domain_stake_summary.next_operators.contains(&operator_id_2)); + assert!(!domain_stake_summary.next_operators.contains(&operator_id_3)); + + let operator = Operators::::get(operator_id_1).unwrap(); + assert_eq!(operator.status, OperatorStatus::Slashed); + + let operator = Operators::::get(operator_id_2).unwrap(); + assert_eq!(operator.status, OperatorStatus::Slashed); + + let operator = Operators::::get(operator_id_3).unwrap(); + assert_eq!(operator.status, OperatorStatus::Slashed); + }); + } + #[test] fn nominator_withdraw_while_pending_deposit_exist() { let domain_id = DomainId::new(0); diff --git a/crates/pallet-feeds/Cargo.toml b/crates/pallet-feeds/Cargo.toml index 32d9d8abfb..23e0941c29 100644 --- a/crates/pallet-feeds/Cargo.toml +++ b/crates/pallet-feeds/Cargo.toml @@ -14,16 +14,16 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] codec = { package = "parity-scale-codec", version = "3.6.5", default-features = false, features = ["derive"] } -frame-support = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -frame-system = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +frame-support = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +frame-system = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } scale-info = { version = "2.7.0", default-features = false, features = ["derive"] } -sp-core = { version = "21.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-std = { version = "8.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-runtime = { version = "24.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +sp-core = { version = "21.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-std = { version = "8.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-runtime = { version = "24.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } subspace-core-primitives = { version = "0.1.0", default-features = false, path = "../subspace-core-primitives" } [dev-dependencies] -sp-io = { version = "23.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +sp-io = { version = "23.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } [features] default = ["std"] diff --git a/crates/pallet-grandpa-finality-verifier/Cargo.toml b/crates/pallet-grandpa-finality-verifier/Cargo.toml index cfa6685db5..8d14933378 100644 --- a/crates/pallet-grandpa-finality-verifier/Cargo.toml +++ b/crates/pallet-grandpa-finality-verifier/Cargo.toml @@ -19,17 +19,17 @@ serde = { version = "1.0.183", optional = true } # Substrate Dependencies -frame-support = { git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1", default-features = false } -frame-system = { git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1", default-features = false } -sp-consensus-grandpa = { git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1", default-features = false } -sp-core = { git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1", default-features = false } -sp-runtime = { git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1", default-features = false } -sp-std = { git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1", default-features = false } +frame-support = { git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c", default-features = false } +frame-system = { git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c", default-features = false } +sp-consensus-grandpa = { git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c", default-features = false } +sp-core = { git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c", default-features = false } +sp-runtime = { git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c", default-features = false } +sp-std = { git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c", default-features = false } [dev-dependencies] ed25519-dalek = { version = "1.0", default-features = false, features = ["u64_backend"] } -sp-io = { git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-application-crypto = { git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +sp-io = { git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-application-crypto = { git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } [features] default = ["std"] diff --git a/crates/pallet-object-store/Cargo.toml b/crates/pallet-object-store/Cargo.toml index 5de4b6045a..5a287b85e3 100644 --- a/crates/pallet-object-store/Cargo.toml +++ b/crates/pallet-object-store/Cargo.toml @@ -14,18 +14,18 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] codec = { package = "parity-scale-codec", version = "3.6.5", default-features = false, features = ["derive"] } -frame-support = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -frame-system = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +frame-support = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +frame-system = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } hex = { version = "0.4.3", default-features = false, features = ["alloc"] } log = { version = "0.4.20", default-features = false } scale-info = { version = "2.7.0", default-features = false, features = ["derive"] } -sp-std = { version = "8.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +sp-std = { version = "8.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } subspace-core-primitives = { version = "0.1.0", default-features = false, path = "../subspace-core-primitives" } [dev-dependencies] -sp-core = { version = "21.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-io = { version = "23.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-runtime = { version = "24.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +sp-core = { version = "21.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-io = { version = "23.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-runtime = { version = "24.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } [features] default = ["std"] diff --git a/crates/pallet-offences-subspace/Cargo.toml b/crates/pallet-offences-subspace/Cargo.toml index 9c648bd4c8..c6f441ef3d 100644 --- a/crates/pallet-offences-subspace/Cargo.toml +++ b/crates/pallet-offences-subspace/Cargo.toml @@ -14,16 +14,16 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] codec = { package = "parity-scale-codec", version = "3.6.5", default-features = false, features = ["derive"] } -frame-support = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -frame-system = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +frame-support = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +frame-system = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } scale-info = { version = "2.7.0", default-features = false, features = ["derive"] } sp-consensus-subspace = { version = "0.1.0", default-features = false, path = "../sp-consensus-subspace" } -sp-runtime = { version = "24.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-std = { version = "8.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +sp-runtime = { version = "24.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-std = { version = "8.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } [dev-dependencies] -sp-io = { version = "23.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-core = { version = "21.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +sp-io = { version = "23.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-core = { version = "21.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } schnorrkel = "0.9.1" [features] diff --git a/crates/pallet-rewards/Cargo.toml b/crates/pallet-rewards/Cargo.toml index b937929cee..d32f6db68a 100644 --- a/crates/pallet-rewards/Cargo.toml +++ b/crates/pallet-rewards/Cargo.toml @@ -19,8 +19,8 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] codec = { package = "parity-scale-codec", version = "3.6.5", default-features = false, features = ["derive"] } -frame-support = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -frame-system = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +frame-support = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +frame-system = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } scale-info = { version = "2.7.0", default-features = false, features = ["derive"] } subspace-runtime-primitives = { version = "0.1.0", default-features = false, path = "../subspace-runtime-primitives" } diff --git a/crates/pallet-runtime-configs/Cargo.toml b/crates/pallet-runtime-configs/Cargo.toml index b2e1daa3f9..5af66fde56 100644 --- a/crates/pallet-runtime-configs/Cargo.toml +++ b/crates/pallet-runtime-configs/Cargo.toml @@ -17,13 +17,13 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] codec = { package = "parity-scale-codec", version = "3.6.5", default-features = false, features = ["derive"] } -frame-benchmarking = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1", optional = true } -frame-support = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -frame-system = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +frame-benchmarking = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c", optional = true } +frame-support = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +frame-system = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } scale-info = { version = "2.7.0", default-features = false, features = ["derive"] } -sp-core = { version = "21.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1", optional = true } -sp-runtime = { version = "24.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-std = { version = "8.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1", optional = true } +sp-core = { version = "21.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c", optional = true } +sp-runtime = { version = "24.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-std = { version = "8.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c", optional = true } [features] default = ["std"] diff --git a/crates/pallet-subspace/Cargo.toml b/crates/pallet-subspace/Cargo.toml index f516da212a..8f7789b0b2 100644 --- a/crates/pallet-subspace/Cargo.toml +++ b/crates/pallet-subspace/Cargo.toml @@ -14,18 +14,18 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] codec = { package = "parity-scale-codec", version = "3.6.5", default-features = false, features = ["derive"] } -frame-benchmarking = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1", optional = true } -frame-support = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -frame-system = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +frame-benchmarking = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c", optional = true } +frame-support = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +frame-system = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } log = { version = "0.4.20", default-features = false } scale-info = { version = "2.7.0", default-features = false, features = ["derive"] } schnorrkel = { version = "0.9.1", default-features = false, features = ["u64_backend"] } serde = { version = "1.0.183", optional = true, default-features = false, features = ["derive"] } sp-consensus-subspace = { version = "0.1.0", default-features = false, path = "../sp-consensus-subspace" } -sp-consensus-slots = { version = "0.10.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-core = { version = "21.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1", optional = true } -sp-runtime = { version = "24.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-std = { version = "8.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +sp-consensus-slots = { version = "0.10.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-core = { version = "21.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c", optional = true } +sp-runtime = { version = "24.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-std = { version = "8.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } subspace-core-primitives = { version = "0.1.0", default-features = false, path = "../subspace-core-primitives" } subspace-runtime-primitives = { version = "0.1.0", default-features = false, path = "../subspace-runtime-primitives" } subspace-verification = { version = "0.1.0", path = "../subspace-verification", default-features = false } @@ -33,12 +33,12 @@ subspace-verification = { version = "0.1.0", path = "../subspace-verification", [dev-dependencies] env_logger = "0.10.0" futures = "0.3.29" -pallet-balances = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +pallet-balances = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } pallet-offences-subspace = { version = "0.1.0", path = "../pallet-offences-subspace" } rand = { version = "0.8.5", features = ["min_const_gen"] } -sp-core = { version = "21.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-io = { version = "23.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-weights = { version = "20.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +sp-core = { version = "21.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-io = { version = "23.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-weights = { version = "20.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } subspace-archiving = { version = "0.1.0", path = "../subspace-archiving" } subspace-core-primitives = { version = "0.1.0", path = "../subspace-core-primitives" } subspace-farmer-components = { version = "0.1.0", path = "../subspace-farmer-components" } diff --git a/crates/pallet-subspace/src/lib.rs b/crates/pallet-subspace/src/lib.rs index 0f89eb45cb..09341dc893 100644 --- a/crates/pallet-subspace/src/lib.rs +++ b/crates/pallet-subspace/src/lib.rs @@ -49,8 +49,8 @@ use sp_consensus_subspace::consensus::{is_proof_of_time_valid, verify_solution}; use sp_consensus_subspace::digests::CompatibleDigestItem; use sp_consensus_subspace::offence::{OffenceDetails, OffenceError, OnOffenceHandler}; use sp_consensus_subspace::{ - ChainConstants, EquivocationProof, FarmerPublicKey, FarmerSignature, PotParameters, - PotParametersChange, SignedVote, Vote, WrappedPotOutput, + EquivocationProof, FarmerPublicKey, FarmerSignature, PotParameters, PotParametersChange, + SignedVote, Vote, WrappedPotOutput, }; use sp_runtime::generic::DigestItem; use sp_runtime::traits::{BlockNumberProvider, CheckedSub, Hash, One, Zero}; @@ -1142,25 +1142,6 @@ impl Pallet { u64::from(archived_segments) * ArchivedHistorySegment::SIZE as u64 } - - pub fn chain_constants() -> ChainConstants { - ChainConstants::V0 { - confirmation_depth_k: T::ConfirmationDepthK::get() - .try_into() - .unwrap_or_else(|_| panic!("Block number always fits in BlockNumber; qed")), - block_authoring_delay: T::BlockAuthoringDelay::get(), - era_duration: T::EraDuration::get() - .try_into() - .unwrap_or_else(|_| panic!("Block number always fits in BlockNumber; qed")), - slot_probability: T::SlotProbability::get(), - recent_segments: T::RecentSegments::get(), - recent_history_fraction: ( - T::RecentHistoryFraction::get().0, - T::RecentHistoryFraction::get().1, - ), - min_sector_lifetime: T::MinSectorLifetime::get(), - } - } } impl Pallet diff --git a/crates/pallet-transaction-fees/Cargo.toml b/crates/pallet-transaction-fees/Cargo.toml index 5645c360ea..d57d521588 100644 --- a/crates/pallet-transaction-fees/Cargo.toml +++ b/crates/pallet-transaction-fees/Cargo.toml @@ -19,8 +19,8 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] codec = { package = "parity-scale-codec", version = "3.6.5", default-features = false, features = ["derive"] } -frame-support = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -frame-system = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +frame-support = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +frame-system = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } scale-info = { version = "2.7.0", default-features = false, features = ["derive"] } subspace-runtime-primitives = { version = "0.1.0", default-features = false, path = "../subspace-runtime-primitives" } diff --git a/crates/sc-consensus-subspace-rpc/Cargo.toml b/crates/sc-consensus-subspace-rpc/Cargo.toml index 4e2810305b..7e82328e3a 100644 --- a/crates/sc-consensus-subspace-rpc/Cargo.toml +++ b/crates/sc-consensus-subspace-rpc/Cargo.toml @@ -20,17 +20,17 @@ jsonrpsee = { version = "0.16.3", features = ["server", "macros"] } lru = "0.11.0" parity-scale-codec = "3.6.5" parking_lot = "0.12.1" -sc-client-api = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +sc-client-api = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } sc-consensus-subspace = { version = "0.1.0", path = "../sc-consensus-subspace" } -sc-rpc = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sc-utils = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-api = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-consensus = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +sc-rpc = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sc-utils = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-api = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-consensus = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } sp-consensus-subspace = { version = "0.1.0", path = "../sp-consensus-subspace" } -sp-blockchain = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-core = { version = "21.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +sp-blockchain = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-core = { version = "21.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } sp-objects = { version = "0.1.0", path = "../sp-objects" } -sp-runtime = { version = "24.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +sp-runtime = { version = "24.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } subspace-archiving = { version = "0.1.0", path = "../subspace-archiving" } subspace-core-primitives = { version = "0.1.0", path = "../subspace-core-primitives" } subspace-farmer-components = { version = "0.1.0", path = "../subspace-farmer-components" } diff --git a/crates/sc-consensus-subspace-rpc/src/lib.rs b/crates/sc-consensus-subspace-rpc/src/lib.rs index d5af835e31..a2cf1dcb1a 100644 --- a/crates/sc-consensus-subspace-rpc/src/lib.rs +++ b/crates/sc-consensus-subspace-rpc/src/lib.rs @@ -29,17 +29,21 @@ use lru::LruCache; use parity_scale_codec::{Decode, Encode}; use parking_lot::Mutex; use sc_client_api::{AuxStore, BlockBackend}; -use sc_consensus_subspace::archiver::{recreate_genesis_segment, SegmentHeadersStore}; +use sc_consensus_subspace::archiver::{ + recreate_genesis_segment, ArchivedSegmentNotification, SegmentHeadersStore, +}; use sc_consensus_subspace::notification::SubspaceNotificationStream; -use sc_consensus_subspace::{ - ArchivedSegmentNotification, NewSlotNotification, RewardSigningNotification, SubspaceSyncOracle, +use sc_consensus_subspace::slot_worker::{ + NewSlotNotification, RewardSigningNotification, SubspaceSyncOracle, }; use sc_rpc::{DenyUnsafe, SubscriptionTaskExecutor}; use sc_utils::mpsc::TracingUnboundedSender; use sp_api::{ApiError, ProvideRuntimeApi}; use sp_blockchain::HeaderBackend; use sp_consensus::SyncOracle; -use sp_consensus_subspace::{FarmerPublicKey, FarmerSignature, SubspaceApi as SubspaceRuntimeApi}; +use sp_consensus_subspace::{ + ChainConstants, FarmerPublicKey, FarmerSignature, SubspaceApi as SubspaceRuntimeApi, +}; use sp_core::crypto::ByteArray; use sp_core::H256; use sp_objects::ObjectsApi; @@ -217,6 +221,7 @@ where Arc>, next_subscription_id: AtomicU64, sync_oracle: SubspaceSyncOracle, + chain_constants: ChainConstants, kzg: Kzg, deny_unsafe: DenyUnsafe, _block: PhantomData, @@ -264,6 +269,7 @@ where archived_segment_acknowledgement_senders: Arc::default(), next_subscription_id: AtomicU64::default(), sync_oracle: config.sync_oracle, + chain_constants, kzg: config.kzg, deny_unsafe: config.deny_unsafe, _block: PhantomData, @@ -301,8 +307,7 @@ where })?; let farmer_app_info: Result = try { - let slot_duration = runtime_api.slot_duration(best_hash)?; - let chain_constants = runtime_api.chain_constants(best_hash)?; + let chain_constants = &self.chain_constants; let protocol_info = FarmerProtocolInfo { history_size: runtime_api.history_size(best_hash)?, max_pieces_in_sector: runtime_api.max_pieces_in_sector(best_hash)?, @@ -314,7 +319,8 @@ where FarmerAppInfo { genesis_hash, dsn_bootstrap_nodes: self.dsn_bootstrap_nodes.clone(), - farming_timeout: slot_duration + farming_timeout: chain_constants + .slot_duration() .as_duration() .mul_f64(SlotNumber::from(chain_constants.block_authoring_delay()) as f64), protocol_info, diff --git a/crates/sc-consensus-subspace/Cargo.toml b/crates/sc-consensus-subspace/Cargo.toml index 79f9468c71..e97c81f076 100644 --- a/crates/sc-consensus-subspace/Cargo.toml +++ b/crates/sc-consensus-subspace/Cargo.toml @@ -17,36 +17,36 @@ targets = ["x86_64-unknown-linux-gnu"] async-trait = "0.1.73" codec = { package = "parity-scale-codec", version = "3.6.5", features = ["derive"] } futures = "0.3.29" -log = "0.4.20" lru = "0.11.0" parking_lot = "0.12.1" rand = "0.8.5" rand_chacha = "0.3.1" rayon = "1.8.0" schnorrkel = "0.9.1" -sc-client-api = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sc-consensus = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sc-consensus-slots = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +sc-client-api = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sc-consensus = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sc-consensus-slots = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } sc-proof-of-time = { version = "0.1.0", path = "../sc-proof-of-time" } -sc-telemetry = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sc-transaction-pool-api = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sc-utils = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-api = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-blockchain = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-block-builder = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-consensus = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +sc-telemetry = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sc-transaction-pool-api = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sc-utils = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-api = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-blockchain = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-block-builder = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-consensus = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } sp-consensus-subspace = { version = "0.1.0", path = "../sp-consensus-subspace" } -sp-consensus-slots = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-core = { version = "21.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-inherents = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +sp-consensus-slots = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-core = { version = "21.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-inherents = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } sp-objects = { version = "0.1.0", path = "../sp-objects" } -sp-runtime = { version = "24.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +sp-runtime = { version = "24.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } subspace-archiving = { version = "0.1.0", path = "../subspace-archiving" } subspace-core-primitives = { version = "0.1.0", path = "../subspace-core-primitives" } subspace-proof-of-space = { version = "0.1.0", path = "../subspace-proof-of-space" } subspace-verification = { version = "0.1.0", path = "../subspace-verification" } thiserror = "1.0.48" tokio = { version = "1.34.0", features = ["sync"] } +tracing = "0.1.37" [dev-dependencies] # TODO: Restore in the future, currently tests are mostly broken and useless diff --git a/crates/sc-consensus-subspace/src/archiver.rs b/crates/sc-consensus-subspace/src/archiver.rs index 8624e512f2..952551f94f 100644 --- a/crates/sc-consensus-subspace/src/archiver.rs +++ b/crates/sc-consensus-subspace/src/archiver.rs @@ -19,13 +19,11 @@ //! Contains implementation of archiving process in Subspace blockchain that converts blockchain //! history (blocks) into archived history (pieces). -use crate::{ - ArchivedSegmentNotification, BlockImportingNotification, SubspaceLink, - SubspaceNotificationSender, SubspaceSyncOracle, -}; +use crate::block_import::BlockImportingNotification; +use crate::slot_worker::SubspaceSyncOracle; +use crate::{SubspaceLink, SubspaceNotificationSender}; use codec::{Decode, Encode}; use futures::StreamExt; -use log::{debug, info, warn}; use parking_lot::Mutex; use rand::prelude::*; use rand_chacha::ChaCha8Rng; @@ -33,7 +31,7 @@ use rayon::prelude::*; use rayon::ThreadPoolBuilder; use sc_client_api::{AuxStore, Backend as BackendT, BlockBackend, Finalizer, LockImportRun}; use sc_telemetry::{telemetry, TelemetryHandle, CONSENSUS_INFO}; -use sc_utils::mpsc::tracing_unbounded; +use sc_utils::mpsc::{tracing_unbounded, TracingUnboundedSender}; use sp_api::ProvideRuntimeApi; use sp_blockchain::HeaderBackend; use sp_consensus::SyncOracle; @@ -44,6 +42,7 @@ use sp_runtime::traits::{Block as BlockT, CheckedSub, Header, NumberFor, One, Ze use sp_runtime::{Justifications, Saturating}; use std::error::Error; use std::future::Future; +use std::num::NonZeroUsize; use std::slice; use std::sync::atomic::{AtomicU16, Ordering}; use std::sync::Arc; @@ -51,10 +50,22 @@ use subspace_archiving::archiver::{Archiver, NewArchivedSegment}; use subspace_core_primitives::crypto::kzg::Kzg; use subspace_core_primitives::objects::BlockObjectMapping; use subspace_core_primitives::{BlockNumber, RecordedHistorySegment, SegmentHeader, SegmentIndex}; +use tracing::{debug, info, warn}; /// This corresponds to default value of `--max-runtime-instances` in Substrate const BLOCKS_TO_ARCHIVE_CONCURRENCY: usize = 8; +/// How deep (in segments) should block be in order to be finalized. +/// +/// This is required for full nodes to not prune recent history such that keep-up sync in Substrate +/// works even without archival nodes (initial sync will be done from DSN). +/// +/// Ideally, we'd decouple pruning from finalization, but it may require invasive changes in +/// Substrate and is not worth it right now. +/// https://github.com/paritytech/substrate/discussions/14359 +pub(crate) const FINALIZATION_DEPTH_IN_SEGMENTS: NonZeroUsize = + NonZeroUsize::new(5).expect("Not zero; qed"); + #[derive(Debug)] struct SegmentHeadersStoreInner { aux_store: Arc, @@ -89,10 +100,7 @@ where let mut cache = Vec::with_capacity(Self::INITIAL_CACHE_CAPACITY); let mut next_key_index = 0; - debug!( - target: "subspace", - "Started loading segment headers into cache" - ); + debug!("Started loading segment headers into cache"); while let Some(segment_headers) = aux_store .get_aux(&Self::key(next_key_index))? @@ -104,10 +112,7 @@ where cache.extend(segment_headers); next_key_index += 1; } - debug!( - target: "subspace", - "Finished loading segment headers into cache" - ); + debug!("Finished loading segment headers into cache"); Ok(Self { inner: Arc::new(SegmentHeadersStoreInner { @@ -198,15 +203,16 @@ where } } -/// How deep (in segments) should block be in order to be finalized. -/// -/// This is required for full nodes to not prune recent history such that keep-up sync in Substrate -/// works even without archival nodes (initial sync will be done from DSN). -/// -/// Ideally, we'd decouple pruning from finalization, but it may require invasive changes in -/// Substrate and is not worth it right now. -/// https://github.com/paritytech/substrate/discussions/14359 -pub(crate) const FINALIZATION_DEPTH_IN_SEGMENTS: usize = 5; +/// Notification with block header hash that needs to be signed and sender for signature. +#[derive(Debug, Clone)] +pub struct ArchivedSegmentNotification { + /// Archived segment. + pub archived_segment: Arc, + /// Sender that signified the fact of receiving archived segment by farmer. + /// + /// This must be used to send a message or else block import pipeline will get stuck. + pub acknowledgement_sender: TracingUnboundedSender<()>, +} fn find_last_archived_block( client: &Client, @@ -423,9 +429,8 @@ where // Continuing from existing initial state let last_archived_block_number = last_segment_header.last_archived_block().number; info!( - target: "subspace", - "Last archived block {}", - last_archived_block_number, + %last_archived_block_number, + "Resuming archiver from last archived block", ); // Set initial value, this is needed in case only genesis block was archived and there @@ -464,7 +469,7 @@ where archiver } else { - info!(target: "subspace", "Starting archiving from genesis"); + info!("Starting archiving from genesis"); Archiver::new(subspace_link.kzg().clone()).expect("Incorrect parameters for archiver") }; @@ -497,10 +502,8 @@ where if let Some(blocks_to_archive_to) = blocks_to_archive_to { info!( - target: "subspace", "Archiving already produced blocks {}..={}", - blocks_to_archive_from, - blocks_to_archive_to, + blocks_to_archive_from, blocks_to_archive_to, ); let thread_pool = ThreadPoolBuilder::new() @@ -556,7 +559,6 @@ where let encoded_block = encode_block(block); debug!( - target: "subspace", "Encoded block {} has size of {:.2} kiB", block_number_to_archive, encoded_block.len() as f32 / 1024.0 @@ -621,11 +623,15 @@ fn finalize_block( client .apply_finality(import_op, hash, None, true) .map_err(|error| { - warn!(target: "subspace", "Error applying finality to block {:?}: {}", (hash, number), error); + warn!( + "Error applying finality to block {:?}: {}", + (hash, number), + error + ); error })?; - debug!(target: "subspace", "Finalizing blocks up to ({:?}, {})", number, hash); + debug!("Finalizing blocks up to ({:?}, {})", number, hash); telemetry!( telemetry; @@ -725,10 +731,8 @@ where let block_hash_to_archive = block.block.hash(); debug!( - target: "subspace", "Archiving block {:?} ({})", - block_number_to_archive, - block_hash_to_archive + block_number_to_archive, block_hash_to_archive ); if parent_block_hash != best_archived_block_hash { @@ -762,7 +766,6 @@ where let encoded_block = encode_block(block); debug!( - target: "subspace", "Encoded block {} has size of {:.2} kiB", block_number_to_archive, encoded_block.len() as f32 / 1024.0 @@ -796,7 +799,7 @@ where segment_headers .iter() .flat_map(|(_k, v)| v.iter().rev()) - .nth(FINALIZATION_DEPTH_IN_SEGMENTS) + .nth(FINALIZATION_DEPTH_IN_SEGMENTS.get()) .map(|segment_header| segment_header.last_archived_block().number) }; diff --git a/crates/sc-consensus-subspace/src/block_import.rs b/crates/sc-consensus-subspace/src/block_import.rs new file mode 100644 index 0000000000..b3c66d7d6a --- /dev/null +++ b/crates/sc-consensus-subspace/src/block_import.rs @@ -0,0 +1,725 @@ +// Copyright (C) 2021 Subspace Labs, Inc. +// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0 + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +//! Block import module. +//! +//! Contains implementation of block import with corresponding checks and notifications. + +use crate::archiver::SegmentHeadersStore; +use crate::verifier::VerificationError; +use crate::{aux_schema, slot_worker, SubspaceLink}; +use futures::channel::mpsc; +use futures::StreamExt; +use sc_client_api::backend::AuxStore; +use sc_client_api::BlockBackend; +use sc_consensus::block_import::{ + BlockCheckParams, BlockImport, BlockImportParams, ForkChoiceStrategy, ImportResult, +}; +use sc_proof_of_time::verifier::PotVerifier; +use sp_api::{ApiError, ApiExt, BlockT, HeaderT, ProvideRuntimeApi}; +use sp_block_builder::BlockBuilder as BlockBuilderApi; +use sp_blockchain::HeaderBackend; +use sp_consensus_slots::Slot; +use sp_consensus_subspace::digests::{ + extract_pre_digest, extract_subspace_digest_items, SubspaceDigestItems, +}; +use sp_consensus_subspace::{ + FarmerPublicKey, FarmerSignature, PotNextSlotInput, SubspaceApi, SubspaceJustification, +}; +use sp_inherents::{CreateInherentDataProviders, InherentDataProvider}; +use sp_runtime::traits::{NumberFor, One}; +use sp_runtime::Justifications; +use std::marker::PhantomData; +use std::sync::Arc; +use subspace_core_primitives::{ + BlockNumber, HistorySize, PublicKey, SectorId, SegmentHeader, SegmentIndex, SolutionRange, +}; +use subspace_proof_of_space::Table; +use subspace_verification::{calculate_block_weight, PieceCheckParams, VerifySolutionParams}; +use tracing::warn; + +/// Notification with number of the block that is about to be imported and acknowledgement sender +/// that can be used to pause block production if desired. +#[derive(Debug, Clone)] +pub struct BlockImportingNotification +where + Block: BlockT, +{ + /// Block number + pub block_number: NumberFor, + /// Sender for pausing the block import when operator is not fast enough to process + /// the consensus block. + pub acknowledgement_sender: mpsc::Sender<()>, +} +use subspace_verification::Error as VerificationPrimitiveError; + +/// Errors encountered by the Subspace authorship task. +#[derive(Debug, thiserror::Error)] +pub enum Error { + /// Inner block import error + #[error("Inner block import error: {0}")] + InnerBlockImportError(#[from] sp_consensus::Error), + /// Error during digest item extraction + #[error("Digest item error: {0}")] + DigestItemError(#[from] sp_consensus_subspace::digests::Error), + /// Parent unavailable. Cannot import + #[error("Parent ({0}) of {1} unavailable. Cannot import")] + ParentUnavailable(Header::Hash, Header::Hash), + /// Genesis block unavailable. Cannot import + #[error("Genesis block unavailable. Cannot import")] + GenesisUnavailable, + /// Slot number must increase + #[error("Slot number must increase: parent slot: {0}, this slot: {1}")] + SlotMustIncrease(Slot, Slot), + /// Header has a bad seal + #[error("Header {0:?} has a bad seal")] + HeaderBadSeal(Header::Hash), + /// Header is unsealed + #[error("Header {0:?} is unsealed")] + HeaderUnsealed(Header::Hash), + /// Bad reward signature + #[error("Bad reward signature on {0:?}")] + BadRewardSignature(Header::Hash), + /// Missing Subspace justification + #[error("Missing Subspace justification")] + MissingSubspaceJustification, + /// Invalid Subspace justification + #[error("Invalid Subspace justification: {0}")] + InvalidSubspaceJustification(codec::Error), + /// Invalid Subspace justification contents + #[error("Invalid Subspace justification contents")] + InvalidSubspaceJustificationContents, + /// Invalid proof of time + #[error("Invalid proof of time")] + InvalidProofOfTime, + /// Solution is outside of solution range + #[error( + "Solution distance {solution_distance} is outside of solution range \ + {half_solution_range} (half of actual solution range) for slot {slot}" + )] + OutsideOfSolutionRange { + /// Time slot + slot: Slot, + /// Half of solution range + half_solution_range: SolutionRange, + /// Solution distance + solution_distance: SolutionRange, + }, + /// Invalid proof of space + #[error("Invalid proof of space")] + InvalidProofOfSpace, + /// Invalid audit chunk offset + #[error("Invalid audit chunk offset")] + InvalidAuditChunkOffset, + /// Invalid chunk witness + #[error("Invalid chunk witness")] + InvalidChunkWitness, + /// Piece verification failed + #[error("Piece verification failed")] + InvalidPieceOffset { + /// Time slot + slot: Slot, + /// Index of the piece that failed verification + piece_offset: u16, + /// How many pieces one sector is supposed to contain (max) + max_pieces_in_sector: u16, + }, + /// Piece verification failed + #[error("Piece verification failed for slot {0}")] + InvalidPiece(Slot), + /// Parent block has no associated weight + #[error("Parent block of {0} has no associated weight")] + ParentBlockNoAssociatedWeight(Header::Hash), + /// Block has invalid associated solution range + #[error("Invalid solution range for block {0}")] + InvalidSolutionRange(Header::Hash), + /// Invalid set of segment headers + #[error("Invalid set of segment headers")] + InvalidSetOfSegmentHeaders, + /// Stored segment header extrinsic was not found + #[error("Stored segment header extrinsic was not found: {0:?}")] + SegmentHeadersExtrinsicNotFound(Vec), + /// Segment header not found + #[error("Segment header for index {0} not found")] + SegmentHeaderNotFound(SegmentIndex), + /// Different segment commitment found + #[error( + "Different segment commitment for segment index {0} was found in storage, likely fork \ + below archiving point" + )] + DifferentSegmentCommitment(SegmentIndex), + /// Farmer in block list + #[error("Farmer {0} is in block list")] + FarmerInBlockList(FarmerPublicKey), + /// No block weight for parent header + #[error("No block weight for parent header {0}")] + NoBlockWeight(Header::Hash), + /// Segment commitment not found + #[error("Segment commitment for segment index {0} not found")] + SegmentCommitmentNotFound(SegmentIndex), + /// Sector expired + #[error("Sector expired")] + SectorExpired { + /// Expiration history size + expiration_history_size: HistorySize, + /// Current history size + current_history_size: HistorySize, + }, + /// Invalid history size + #[error("Invalid history size")] + InvalidHistorySize, + /// Only root plot public key is allowed + #[error("Only root plot public key is allowed")] + OnlyRootPlotPublicKeyAllowed, + /// Check inherents error + #[error("Checking inherents failed: {0}")] + CheckInherents(sp_inherents::Error), + /// Unhandled check inherents error + #[error("Checking inherents unhandled error: {}", String::from_utf8_lossy(.0))] + CheckInherentsUnhandled(sp_inherents::InherentIdentifier), + /// Create inherents error. + #[error("Creating inherents failed: {0}")] + CreateInherents(sp_inherents::Error), + /// Client error + #[error(transparent)] + Client(#[from] sp_blockchain::Error), + /// Runtime Api error. + #[error(transparent)] + RuntimeApi(#[from] ApiError), +} + +impl
From> for Error
+where + Header: HeaderT, +{ + #[inline] + fn from(error: VerificationError
) -> Self { + match error { + VerificationError::HeaderBadSeal(block_hash) => Error::HeaderBadSeal(block_hash), + VerificationError::HeaderUnsealed(block_hash) => Error::HeaderUnsealed(block_hash), + VerificationError::BadRewardSignature(block_hash) => { + Error::BadRewardSignature(block_hash) + } + VerificationError::MissingSubspaceJustification => Error::MissingSubspaceJustification, + VerificationError::InvalidSubspaceJustification(error) => { + Error::InvalidSubspaceJustification(error) + } + VerificationError::InvalidSubspaceJustificationContents => { + Error::InvalidSubspaceJustificationContents + } + VerificationError::InvalidProofOfTime => Error::InvalidProofOfTime, + VerificationError::VerificationError(slot, error) => match error { + VerificationPrimitiveError::InvalidPieceOffset { + piece_offset, + max_pieces_in_sector, + } => Error::InvalidPieceOffset { + slot, + piece_offset, + max_pieces_in_sector, + }, + VerificationPrimitiveError::InvalidPiece => Error::InvalidPiece(slot), + VerificationPrimitiveError::OutsideSolutionRange { + half_solution_range, + solution_distance, + } => Error::OutsideOfSolutionRange { + slot, + half_solution_range, + solution_distance, + }, + VerificationPrimitiveError::InvalidProofOfSpace => Error::InvalidProofOfSpace, + VerificationPrimitiveError::InvalidAuditChunkOffset => { + Error::InvalidAuditChunkOffset + } + VerificationPrimitiveError::InvalidChunkWitness => Error::InvalidChunkWitness, + VerificationPrimitiveError::SectorExpired { + expiration_history_size, + current_history_size, + } => Error::SectorExpired { + expiration_history_size, + current_history_size, + }, + VerificationPrimitiveError::InvalidHistorySize => Error::InvalidHistorySize, + }, + } + } +} + +impl
From> for String +where + Header: HeaderT, +{ + #[inline] + fn from(error: Error
) -> String { + error.to_string() + } +} + +/// A block-import handler for Subspace. +pub struct SubspaceBlockImport +where + Block: BlockT, +{ + inner: I, + client: Arc, + subspace_link: SubspaceLink, + create_inherent_data_providers: CIDP, + segment_headers_store: SegmentHeadersStore, + pot_verifier: PotVerifier, + _pos_table: PhantomData, +} + +impl Clone + for SubspaceBlockImport +where + Block: BlockT, + I: Clone, + CIDP: Clone, +{ + fn clone(&self) -> Self { + SubspaceBlockImport { + inner: self.inner.clone(), + client: self.client.clone(), + subspace_link: self.subspace_link.clone(), + create_inherent_data_providers: self.create_inherent_data_providers.clone(), + segment_headers_store: self.segment_headers_store.clone(), + pot_verifier: self.pot_verifier.clone(), + _pos_table: PhantomData, + } + } +} + +impl SubspaceBlockImport +where + PosTable: Table, + Block: BlockT, + Client: ProvideRuntimeApi + BlockBackend + HeaderBackend + AuxStore, + Client::Api: BlockBuilderApi + SubspaceApi + ApiExt, + CIDP: CreateInherentDataProviders> + Send + Sync + 'static, + AS: AuxStore + Send + Sync + 'static, + BlockNumber: From<<::Header as HeaderT>::Number>, +{ + /// Produce a Subspace block-import object to be used later on in the construction of an import-queue. + pub fn new( + client: Arc, + block_import: I, + subspace_link: SubspaceLink, + create_inherent_data_providers: CIDP, + segment_headers_store: SegmentHeadersStore, + pot_verifier: PotVerifier, + ) -> Self { + Self { + client, + inner: block_import, + subspace_link, + create_inherent_data_providers, + segment_headers_store, + pot_verifier, + _pos_table: PhantomData, + } + } + + #[allow(clippy::too_many_arguments)] + async fn block_import_verification( + &self, + block_hash: Block::Hash, + header: Block::Header, + extrinsics: Option>, + root_plot_public_key: &Option, + subspace_digest_items: &SubspaceDigestItems< + FarmerPublicKey, + FarmerPublicKey, + FarmerSignature, + >, + justifications: &Option, + skip_runtime_access: bool, + ) -> Result<(), Error> { + let block_number = *header.number(); + let parent_hash = *header.parent_hash(); + + let pre_digest = &subspace_digest_items.pre_digest; + if let Some(root_plot_public_key) = root_plot_public_key { + if &pre_digest.solution().public_key != root_plot_public_key { + // Only root plot public key is allowed. + return Err(Error::OnlyRootPlotPublicKeyAllowed); + } + } + + // Check if farmer's plot is burned. + if self + .client + .runtime_api() + .is_in_block_list(parent_hash, &pre_digest.solution().public_key) + .or_else(|error| { + if skip_runtime_access { + Ok(false) + } else { + Err(Error::RuntimeApi(error)) + } + })? + { + warn!( + public_key = %pre_digest.solution().public_key, + "Ignoring block with solution provided by farmer in block list", + ); + + return Err(Error::FarmerInBlockList( + pre_digest.solution().public_key.clone(), + )); + } + + let parent_header = self + .client + .header(parent_hash)? + .ok_or(Error::ParentUnavailable(parent_hash, block_hash))?; + + let parent_slot = extract_pre_digest(&parent_header).map(|d| d.slot())?; + + // Make sure that slot number is strictly increasing + if pre_digest.slot() <= parent_slot { + return Err(Error::SlotMustIncrease(parent_slot, pre_digest.slot())); + } + + let parent_subspace_digest_items = if block_number.is_one() { + None + } else { + Some(extract_subspace_digest_items::< + _, + FarmerPublicKey, + FarmerPublicKey, + FarmerSignature, + >(&parent_header)?) + }; + + let correct_solution_range = if block_number.is_one() { + slot_worker::extract_solution_ranges_for_block(self.client.as_ref(), parent_hash)?.0 + } else { + let parent_subspace_digest_items = parent_subspace_digest_items + .as_ref() + .expect("Always Some for non-first block; qed"); + + match parent_subspace_digest_items.next_solution_range { + Some(solution_range) => solution_range, + None => parent_subspace_digest_items.solution_range, + } + }; + + if subspace_digest_items.solution_range != correct_solution_range { + return Err(Error::InvalidSolutionRange(block_hash)); + } + + let chain_constants = self.subspace_link.chain_constants(); + + // For PoT justifications we only need to check the seed and number of checkpoints, the rest + // was already checked during stateless block verification. + { + let Some(subspace_justification) = justifications + .as_ref() + .and_then(|justifications| { + justifications + .iter() + .find_map(SubspaceJustification::try_from_justification) + }) + .transpose() + .map_err(Error::InvalidSubspaceJustification)? + else { + return Err(Error::MissingSubspaceJustification); + }; + + let SubspaceJustification::PotCheckpoints { seed, checkpoints } = + subspace_justification; + + let future_slot = pre_digest.slot() + chain_constants.block_authoring_delay(); + + if block_number.is_one() { + // In case of first block seed must match genesis seed + if seed != self.pot_verifier.genesis_seed() { + return Err(Error::InvalidSubspaceJustificationContents); + } + + // Number of checkpoints must match future slot number + if checkpoints.len() as u64 != *future_slot { + return Err(Error::InvalidSubspaceJustificationContents); + } + } else { + let parent_subspace_digest_items = parent_subspace_digest_items + .as_ref() + .expect("Always Some for non-first block; qed"); + + let parent_future_slot = parent_slot + chain_constants.block_authoring_delay(); + + let correct_input_parameters = PotNextSlotInput::derive( + subspace_digest_items.pot_slot_iterations, + parent_future_slot, + parent_subspace_digest_items + .pre_digest + .pot_info() + .future_proof_of_time(), + &subspace_digest_items.pot_parameters_change, + ); + + if seed != correct_input_parameters.seed { + return Err(Error::InvalidSubspaceJustificationContents); + } + + // Number of checkpoints must match number of proofs that were not yet seen on chain + if checkpoints.len() as u64 != (*future_slot - *parent_future_slot) { + return Err(Error::InvalidSubspaceJustificationContents); + } + } + } + + let sector_id = SectorId::new( + PublicKey::from(&pre_digest.solution().public_key).hash(), + pre_digest.solution().sector_index, + ); + + // TODO: Below `skip_runtime_access` has no impact on this, but ideally it + // should (though we don't support fast sync yet, so doesn't matter in + // practice) + let max_pieces_in_sector = self + .client + .runtime_api() + .max_pieces_in_sector(parent_hash)?; + let piece_index = sector_id.derive_piece_index( + pre_digest.solution().piece_offset, + pre_digest.solution().history_size, + max_pieces_in_sector, + chain_constants.recent_segments(), + chain_constants.recent_history_fraction(), + ); + let segment_index = piece_index.segment_index(); + + let segment_commitment = self + .segment_headers_store + .get_segment_header(segment_index) + .map(|segment_header| segment_header.segment_commitment()) + .ok_or(Error::SegmentCommitmentNotFound(segment_index))?; + + let sector_expiration_check_segment_commitment = self + .segment_headers_store + .get_segment_header( + subspace_digest_items + .pre_digest + .solution() + .history_size + .sector_expiration_check(chain_constants.min_sector_lifetime()) + .ok_or(Error::InvalidHistorySize)? + .segment_index(), + ) + .map(|segment_header| segment_header.segment_commitment()); + + // Piece is not checked during initial block verification because it requires access to + // segment header and runtime, check it now. + subspace_verification::verify_solution::( + pre_digest.solution(), + // Slot was already checked during initial block verification + pre_digest.slot().into(), + &VerifySolutionParams { + proof_of_time: subspace_digest_items.pre_digest.pot_info().proof_of_time(), + solution_range: subspace_digest_items.solution_range, + piece_check_params: Some(PieceCheckParams { + max_pieces_in_sector, + segment_commitment, + recent_segments: chain_constants.recent_segments(), + recent_history_fraction: chain_constants.recent_history_fraction(), + min_sector_lifetime: chain_constants.min_sector_lifetime(), + // TODO: Below `skip_runtime_access` has no impact on this, but ideally it + // should (though we don't support fast sync yet, so doesn't matter in + // practice) + current_history_size: self.client.runtime_api().history_size(parent_hash)?, + sector_expiration_check_segment_commitment, + }), + }, + &self.subspace_link.kzg, + ) + .map_err(|error| VerificationError::VerificationError(pre_digest.slot(), error))?; + + if !skip_runtime_access { + // If the body is passed through, we need to use the runtime to check that the + // internally-set timestamp in the inherents actually matches the slot set in the seal + // and segment headers in the inherents are set correctly. + if let Some(extrinsics) = extrinsics { + let create_inherent_data_providers = self + .create_inherent_data_providers + .create_inherent_data_providers(parent_hash, self.subspace_link.clone()) + .await + .map_err(|error| Error::Client(sp_blockchain::Error::from(error)))?; + + let inherent_data = create_inherent_data_providers + .create_inherent_data() + .await + .map_err(Error::CreateInherents)?; + + let inherent_res = self.client.runtime_api().check_inherents( + parent_hash, + Block::new(header, extrinsics), + inherent_data, + )?; + + if !inherent_res.ok() { + for (i, e) in inherent_res.into_errors() { + match create_inherent_data_providers + .try_handle_error(&i, &e) + .await + { + Some(res) => res.map_err(Error::CheckInherents)?, + None => return Err(Error::CheckInherentsUnhandled(i)), + } + } + } + } + } + + Ok(()) + } +} + +#[async_trait::async_trait] +impl BlockImport + for SubspaceBlockImport +where + PosTable: Table, + Block: BlockT, + Inner: BlockImport + Send + Sync, + Client: ProvideRuntimeApi + + BlockBackend + + HeaderBackend + + AuxStore + + Send + + Sync, + Client::Api: BlockBuilderApi + SubspaceApi + ApiExt, + CIDP: CreateInherentDataProviders> + Send + Sync + 'static, + AS: AuxStore + Send + Sync + 'static, + BlockNumber: From<<::Header as HeaderT>::Number>, +{ + type Error = Error; + + async fn import_block( + &mut self, + mut block: BlockImportParams, + ) -> Result { + let block_hash = block.post_hash(); + let block_number = *block.header.number(); + + // Early exit if block already in chain + match self.client.status(block_hash)? { + sp_blockchain::BlockStatus::InChain => { + block.fork_choice = Some(ForkChoiceStrategy::Custom(false)); + return self + .inner + .import_block(block) + .await + .map_err(Error::InnerBlockImportError); + } + sp_blockchain::BlockStatus::Unknown => {} + } + + let subspace_digest_items = extract_subspace_digest_items(&block.header)?; + let skip_execution_checks = block.state_action.skip_execution_checks(); + + let root_plot_public_key = self + .client + .runtime_api() + .root_plot_public_key(*block.header.parent_hash())?; + + self.block_import_verification( + block_hash, + block.header.clone(), + block.body.clone(), + &root_plot_public_key, + &subspace_digest_items, + &block.justifications, + skip_execution_checks, + ) + .await?; + + let parent_weight = if block_number.is_one() { + 0 + } else { + aux_schema::load_block_weight(self.client.as_ref(), block.header.parent_hash())? + .ok_or_else(|| Error::ParentBlockNoAssociatedWeight(block_hash))? + }; + + let added_weight = calculate_block_weight(subspace_digest_items.solution_range); + let total_weight = parent_weight + added_weight; + + aux_schema::write_block_weight(block_hash, total_weight, |values| { + block + .auxiliary + .extend(values.iter().map(|(k, v)| (k.to_vec(), Some(v.to_vec())))) + }); + + for (&segment_index, segment_commitment) in &subspace_digest_items.segment_commitments { + let found_segment_commitment = self + .segment_headers_store + .get_segment_header(segment_index) + .ok_or_else(|| Error::SegmentHeaderNotFound(segment_index))? + .segment_commitment(); + + if &found_segment_commitment != segment_commitment { + warn!( + "Different segment commitment for segment index {} was found in storage, \ + likely fork below archiving point. expected {:?}, found {:?}", + segment_index, segment_commitment, found_segment_commitment + ); + return Err(Error::DifferentSegmentCommitment(segment_index)); + } + } + + // The fork choice rule is that we pick the heaviest chain (i.e. smallest solution range), + // if there's a tie we go with the longest chain + let fork_choice = { + let info = self.client.info(); + + let last_best_weight = if &info.best_hash == block.header.parent_hash() { + // the parent=genesis case is already covered for loading parent weight, so we don't + // need to cover again here + parent_weight + } else { + aux_schema::load_block_weight(&*self.client, info.best_hash)? + .ok_or_else(|| Error::NoBlockWeight(info.best_hash))? + }; + + ForkChoiceStrategy::Custom(total_weight > last_best_weight) + }; + block.fork_choice = Some(fork_choice); + + let (acknowledgement_sender, mut acknowledgement_receiver) = mpsc::channel(0); + + self.subspace_link + .block_importing_notification_sender + .notify(move || BlockImportingNotification { + block_number, + acknowledgement_sender, + }); + + while acknowledgement_receiver.next().await.is_some() { + // Wait for all the acknowledgements to finish. + } + + self.inner + .import_block(block) + .await + .map_err(Error::InnerBlockImportError) + } + + async fn check_block( + &self, + block: BlockCheckParams, + ) -> Result { + self.inner.check_block(block).await.map_err(Into::into) + } +} diff --git a/crates/sc-consensus-subspace/src/lib.rs b/crates/sc-consensus-subspace/src/lib.rs index 51e8873f07..b66360076d 100644 --- a/crates/sc-consensus-subspace/src/lib.rs +++ b/crates/sc-consensus-subspace/src/lib.rs @@ -1,4 +1,3 @@ -// Copyright (C) 2019-2021 Parity Technologies (UK) Ltd. // Copyright (C) 2021 Subspace Labs, Inc. // SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0 @@ -16,518 +15,34 @@ // along with this program. If not, see . #![doc = include_str!("../README.md")] -#![feature(let_chains, try_blocks)] +#![feature(const_option, let_chains, try_blocks)] #![forbid(unsafe_code)] #![warn(missing_docs)] pub mod archiver; pub mod aux_schema; +pub mod block_import; pub mod notification; -mod slot_worker; +pub mod slot_worker; #[cfg(test)] mod tests; pub mod verifier; -use crate::archiver::{SegmentHeadersStore, FINALIZATION_DEPTH_IN_SEGMENTS}; +use crate::archiver::{ArchivedSegmentNotification, FINALIZATION_DEPTH_IN_SEGMENTS}; +use crate::block_import::BlockImportingNotification; use crate::notification::{SubspaceNotificationSender, SubspaceNotificationStream}; -use crate::slot_worker::SubspaceSlotWorker; -pub use crate::slot_worker::SubspaceSyncOracle; -use crate::verifier::VerificationError; -use futures::channel::mpsc; -use futures::StreamExt; -use log::{debug, info, warn}; +use crate::slot_worker::{NewSlotNotification, RewardSigningNotification}; use lru::LruCache; use parking_lot::Mutex; -use sc_client_api::backend::AuxStore; -use sc_client_api::{BlockBackend, BlockchainEvents, ProvideUncles, UsageProvider}; -use sc_consensus::block_import::{ - BlockCheckParams, BlockImport, BlockImportParams, ForkChoiceStrategy, ImportResult, -}; -use sc_consensus::{JustificationSyncLink, SharedBlockImport}; -use sc_consensus_slots::{BackoffAuthoringBlocksStrategy, InherentDataProviderExt, SlotProportion}; -use sc_proof_of_time::source::PotSlotInfoStream; -use sc_proof_of_time::verifier::PotVerifier; -use sc_telemetry::TelemetryHandle; -use sc_transaction_pool_api::OffchainTransactionPoolFactory; -use sc_utils::mpsc::TracingUnboundedSender; -use sp_api::{ApiError, ApiExt, BlockT, HeaderT, NumberFor, ProvideRuntimeApi}; -use sp_block_builder::BlockBuilder as BlockBuilderApi; -use sp_blockchain::{Error as ClientError, HeaderBackend, HeaderMetadata, Result as ClientResult}; -use sp_consensus::{Environment, Error as ConsensusError, Proposer, SelectChain, SyncOracle}; -use sp_consensus_slots::{Slot, SlotDuration}; -use sp_consensus_subspace::digests::{ - extract_pre_digest, extract_subspace_digest_items, Error as DigestError, SubspaceDigestItems, -}; -use sp_consensus_subspace::{ - ChainConstants, FarmerPublicKey, FarmerSignature, PotNextSlotInput, SubspaceApi, - SubspaceJustification, -}; -use sp_core::H256; -use sp_inherents::{CreateInherentDataProviders, InherentDataProvider}; -use sp_runtime::traits::One; -use sp_runtime::Justifications; -use std::future::Future; -use std::marker::PhantomData; -use std::num::NonZeroUsize; -use std::pin::Pin; +use sp_api::{BlockT, NumberFor}; +use sp_consensus_subspace::ChainConstants; use std::sync::Arc; -use subspace_archiving::archiver::NewArchivedSegment; use subspace_core_primitives::crypto::kzg::Kzg; -use subspace_core_primitives::{ - BlockNumber, HistorySize, PublicKey, Randomness, SectorId, SegmentHeader, SegmentIndex, - Solution, SolutionRange, REWARD_SIGNING_CONTEXT, -}; -use subspace_proof_of_space::Table; -use subspace_verification::{ - calculate_block_weight, Error as VerificationPrimitiveError, PieceCheckParams, - VerifySolutionParams, -}; - -/// Information about new slot that just arrived -#[derive(Debug, Copy, Clone)] -pub struct NewSlotInfo { - /// Slot - pub slot: Slot, - /// Global randomness - pub global_randomness: Randomness, - /// Acceptable solution range for block authoring - pub solution_range: SolutionRange, - /// Acceptable solution range for voting - pub voting_solution_range: SolutionRange, -} - -/// New slot notification with slot information and sender for solution for the slot. -#[derive(Debug, Clone)] -pub struct NewSlotNotification { - /// New slot information. - pub new_slot_info: NewSlotInfo, - /// Sender that can be used to send solutions for the slot. - pub solution_sender: mpsc::Sender>, -} - -/// Notification with a hash that needs to be signed to receive reward and sender for signature. -#[derive(Debug, Clone)] -pub struct RewardSigningNotification { - /// Hash to be signed. - pub hash: H256, - /// Public key of the plot identity that should create signature. - pub public_key: FarmerPublicKey, - /// Sender that can be used to send signature for the header. - pub signature_sender: TracingUnboundedSender, -} - -/// Notification with block header hash that needs to be signed and sender for signature. -#[derive(Debug, Clone)] -pub struct ArchivedSegmentNotification { - /// Archived segment. - pub archived_segment: Arc, - /// Sender that signified the fact of receiving archived segment by farmer. - /// - /// This must be used to send a message or else block import pipeline will get stuck. - pub acknowledgement_sender: TracingUnboundedSender<()>, -} - -/// Notification with number of the block that is about to be imported and acknowledgement sender -/// that can be used to pause block production if desired. -/// -/// NOTE: Block is not fully imported yet! -#[derive(Debug, Clone)] -pub struct BlockImportingNotification -where - Block: BlockT, -{ - /// Block number - pub block_number: NumberFor, - /// Sender for pausing the block import when operator is not fast enough to process - /// the consensus block. - pub acknowledgement_sender: mpsc::Sender<()>, -} - -/// Errors encountered by the Subspace authorship task. -#[derive(Debug, thiserror::Error)] -pub enum Error { - /// Error during digest item extraction - #[error("Digest item error: {0}")] - DigestItemError(#[from] DigestError), - /// Parent unavailable. Cannot import - #[error("Parent ({0}) of {1} unavailable. Cannot import")] - ParentUnavailable(Header::Hash, Header::Hash), - /// Genesis block unavailable. Cannot import - #[error("Genesis block unavailable. Cannot import")] - GenesisUnavailable, - /// Slot number must increase - #[error("Slot number must increase: parent slot: {0}, this slot: {1}")] - SlotMustIncrease(Slot, Slot), - /// Header has a bad seal - #[error("Header {0:?} has a bad seal")] - HeaderBadSeal(Header::Hash), - /// Header is unsealed - #[error("Header {0:?} is unsealed")] - HeaderUnsealed(Header::Hash), - /// Bad reward signature - #[error("Bad reward signature on {0:?}")] - BadRewardSignature(Header::Hash), - /// Missing Subspace justification - #[error("Missing Subspace justification")] - MissingSubspaceJustification, - /// Invalid Subspace justification - #[error("Invalid Subspace justification: {0}")] - InvalidSubspaceJustification(codec::Error), - /// Invalid Subspace justification contents - #[error("Invalid Subspace justification contents")] - InvalidSubspaceJustificationContents, - /// Invalid proof of time - #[error("Invalid proof of time")] - InvalidProofOfTime, - /// Solution is outside of solution range - #[error( - "Solution distance {solution_distance} is outside of solution range \ - {half_solution_range} (half of actual solution range) for slot {slot}" - )] - OutsideOfSolutionRange { - /// Time slot - slot: Slot, - /// Half of solution range - half_solution_range: SolutionRange, - /// Solution distance - solution_distance: SolutionRange, - }, - /// Invalid proof of space - #[error("Invalid proof of space")] - InvalidProofOfSpace, - /// Invalid audit chunk offset - #[error("Invalid audit chunk offset")] - InvalidAuditChunkOffset, - /// Invalid chunk witness - #[error("Invalid chunk witness")] - InvalidChunkWitness, - /// Piece verification failed - #[error("Piece verification failed")] - InvalidPieceOffset { - /// Time slot - slot: Slot, - /// Index of the piece that failed verification - piece_offset: u16, - /// How many pieces one sector is supposed to contain (max) - max_pieces_in_sector: u16, - }, - /// Piece verification failed - #[error("Piece verification failed for slot {0}")] - InvalidPiece(Slot), - /// Parent block has no associated weight - #[error("Parent block of {0} has no associated weight")] - ParentBlockNoAssociatedWeight(Header::Hash), - /// Block has invalid associated solution range - #[error("Invalid solution range for block {0}")] - InvalidSolutionRange(Header::Hash), - /// Invalid set of segment headers - #[error("Invalid set of segment headers")] - InvalidSetOfSegmentHeaders, - /// Stored segment header extrinsic was not found - #[error("Stored segment header extrinsic was not found: {0:?}")] - SegmentHeadersExtrinsicNotFound(Vec), - /// Different segment commitment found - #[error( - "Different segment commitment for segment index {0} was found in storage, likely fork \ - below archiving point" - )] - DifferentSegmentCommitment(SegmentIndex), - /// Farmer in block list - #[error("Farmer {0} is in block list")] - FarmerInBlockList(FarmerPublicKey), - /// Segment commitment not found - #[error("Segment commitment for segment index {0} not found")] - SegmentCommitmentNotFound(SegmentIndex), - /// Sector expired - #[error("Sector expired")] - SectorExpired { - /// Expiration history size - expiration_history_size: HistorySize, - /// Current history size - current_history_size: HistorySize, - }, - /// Invalid history size - #[error("Invalid history size")] - InvalidHistorySize, - /// Only root plot public key is allowed - #[error("Only root plot public key is allowed")] - OnlyRootPlotPublicKeyAllowed, - /// Check inherents error - #[error("Checking inherents failed: {0}")] - CheckInherents(sp_inherents::Error), - /// Unhandled check inherents error - #[error("Checking inherents unhandled error: {}", String::from_utf8_lossy(.0))] - CheckInherentsUnhandled(sp_inherents::InherentIdentifier), - /// Create inherents error. - #[error("Creating inherents failed: {0}")] - CreateInherents(sp_inherents::Error), - /// Client error - #[error(transparent)] - Client(#[from] sp_blockchain::Error), - /// Runtime Api error. - #[error(transparent)] - RuntimeApi(#[from] ApiError), -} - -impl
From> for Error
-where - Header: HeaderT, -{ - #[inline] - fn from(error: VerificationError
) -> Self { - match error { - VerificationError::HeaderBadSeal(block_hash) => Error::HeaderBadSeal(block_hash), - VerificationError::HeaderUnsealed(block_hash) => Error::HeaderUnsealed(block_hash), - VerificationError::BadRewardSignature(block_hash) => { - Error::BadRewardSignature(block_hash) - } - VerificationError::MissingSubspaceJustification => Error::MissingSubspaceJustification, - VerificationError::InvalidSubspaceJustification(error) => { - Error::InvalidSubspaceJustification(error) - } - VerificationError::InvalidSubspaceJustificationContents => { - Error::InvalidSubspaceJustificationContents - } - VerificationError::InvalidProofOfTime => Error::InvalidProofOfTime, - VerificationError::VerificationError(slot, error) => match error { - VerificationPrimitiveError::InvalidPieceOffset { - piece_offset, - max_pieces_in_sector, - } => Error::InvalidPieceOffset { - slot, - piece_offset, - max_pieces_in_sector, - }, - VerificationPrimitiveError::InvalidPiece => Error::InvalidPiece(slot), - VerificationPrimitiveError::OutsideSolutionRange { - half_solution_range, - solution_distance, - } => Error::OutsideOfSolutionRange { - slot, - half_solution_range, - solution_distance, - }, - VerificationPrimitiveError::InvalidProofOfSpace => Error::InvalidProofOfSpace, - VerificationPrimitiveError::InvalidAuditChunkOffset => { - Error::InvalidAuditChunkOffset - } - VerificationPrimitiveError::InvalidChunkWitness => Error::InvalidChunkWitness, - VerificationPrimitiveError::SectorExpired { - expiration_history_size, - current_history_size, - } => Error::SectorExpired { - expiration_history_size, - current_history_size, - }, - VerificationPrimitiveError::InvalidHistorySize => Error::InvalidHistorySize, - }, - } - } -} - -impl
From> for String -where - Header: HeaderT, -{ - #[inline] - fn from(error: Error
) -> String { - error.to_string() - } -} - -/// Read configuration from the runtime state at current best block. -pub fn slot_duration(client: &Client) -> ClientResult -where - Block: BlockT, - Client: AuxStore + ProvideRuntimeApi + UsageProvider, - Client::Api: SubspaceApi, -{ - let block_hash = if client.usage_info().chain.finalized_state.is_some() { - client.usage_info().chain.best_hash - } else { - debug!(target: "subspace", "No finalized state is available. Reading config from genesis"); - client.usage_info().chain.genesis_hash - }; - - Ok(client.runtime_api().slot_duration(block_hash)?) -} - -/// Parameters for Subspace. -pub struct SubspaceParams -where - Block: BlockT, - SO: SyncOracle + Send + Sync, -{ - /// The client to use - pub client: Arc, - - /// The SelectChain Strategy - pub select_chain: SC, - - /// The environment we are producing blocks for. - pub env: E, - - /// The underlying block-import object to supply our produced blocks to. - /// This must be a `SubspaceBlockImport` or a wrapper of it, otherwise - /// critical consensus logic will be omitted. - pub block_import: SharedBlockImport, - - /// A sync oracle - pub sync_oracle: SubspaceSyncOracle, - - /// 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, - - /// Force authoring of blocks even if we are offline - pub force_authoring: bool, - - /// Strategy and parameters for backing off block production. - pub backoff_authoring_blocks: Option, - - /// The source of timestamps for relative slots - pub subspace_link: SubspaceLink, - - /// Persistent storage of segment headers - pub segment_headers_store: SegmentHeadersStore, - - /// 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, - - /// Handle use to report telemetries. - pub telemetry: Option, - - /// The offchain transaction pool factory. - /// - /// Will be used when sending equivocation reports and votes. - pub offchain_tx_pool_factory: OffchainTransactionPoolFactory, - - /// Proof of time verifier - pub pot_verifier: PotVerifier, - - /// Stream with proof of time slots. - pub pot_slot_info_stream: PotSlotInfoStream, -} - -/// Start the Subspace worker. -pub fn start_subspace( - SubspaceParams { - client, - select_chain, - env, - block_import, - sync_oracle, - justification_sync_link, - create_inherent_data_providers, - force_authoring, - backoff_authoring_blocks, - subspace_link, - segment_headers_store, - block_proposal_slot_portion, - max_block_proposal_slot_portion, - telemetry, - offchain_tx_pool_factory, - pot_verifier, - pot_slot_info_stream, - }: SubspaceParams, -) -> Result -where - PosTable: Table, - Block: BlockT, - Client: ProvideRuntimeApi - + ProvideUncles - + BlockchainEvents - + HeaderBackend - + HeaderMetadata - + AuxStore - + Send - + Sync - + 'static, - Client::Api: SubspaceApi, - SC: SelectChain + 'static, - E: Environment + Send + Sync + 'static, - E::Proposer: Proposer, - SO: SyncOracle + Send + Sync + Clone + 'static, - L: JustificationSyncLink + 'static, - CIDP: CreateInherentDataProviders + Send + Sync + 'static, - CIDP::InherentDataProviders: InherentDataProviderExt + Send, - BS: BackoffAuthoringBlocksStrategy> + Send + Sync + 'static, - AS: AuxStore + Send + Sync + 'static, - Error: std::error::Error + Send + From + 'static, - BlockNumber: From<<::Header as HeaderT>::Number>, -{ - let worker = SubspaceSlotWorker { - client: client.clone(), - block_import, - env, - sync_oracle: sync_oracle.clone(), - justification_sync_link, - force_authoring, - backoff_authoring_blocks, - subspace_link: subspace_link.clone(), - reward_signing_context: schnorrkel::context::signing_context(REWARD_SIGNING_CONTEXT), - block_proposal_slot_portion, - max_block_proposal_slot_portion, - telemetry, - offchain_tx_pool_factory, - chain_constants: client - .runtime_api() - .chain_constants(client.info().best_hash) - .map_err(|error| sp_consensus::Error::ChainLookup(error.to_string()))?, - segment_headers_store, - pending_solutions: Default::default(), - pot_checkpoints: Default::default(), - pot_verifier, - _pos_table: PhantomData::, - }; - - info!(target: "subspace", "🧑‍🌾 Starting Subspace Authorship worker"); - let inner = sc_proof_of_time::start_slot_worker( - subspace_link.slot_duration(), - client, - select_chain, - worker, - sync_oracle, - create_inherent_data_providers, - pot_slot_info_stream, - ); - - Ok(SubspaceWorker { - inner: Box::pin(inner), - }) -} - -/// Worker for Subspace which implements `Future`. This must be polled. -#[must_use] -pub struct SubspaceWorker { - inner: Pin + Send + 'static>>, -} - -impl Future for SubspaceWorker { - type Output = (); - - fn poll( - mut self: Pin<&mut Self>, - cx: &mut futures::task::Context, - ) -> futures::task::Poll { - self.inner.as_mut().poll(cx) - } -} +use subspace_core_primitives::SegmentHeader; /// State that must be shared between the import queue and the authoring logic. #[derive(Clone)] pub struct SubspaceLink { - slot_duration: SlotDuration, new_slot_notification_sender: SubspaceNotificationSender, new_slot_notification_stream: SubspaceNotificationStream, reward_signing_notification_sender: SubspaceNotificationSender, @@ -541,13 +56,37 @@ pub struct SubspaceLink { /// Segment headers that are expected to appear in the corresponding blocks, used for block /// production and validation segment_headers: Arc, Vec>>>, + chain_constants: ChainConstants, kzg: Kzg, } impl SubspaceLink { - /// Get the slot duration from this link. - pub fn slot_duration(&self) -> SlotDuration { - self.slot_duration + /// Create new instance. + pub fn new(chain_constants: ChainConstants, kzg: Kzg) -> Self { + let (new_slot_notification_sender, new_slot_notification_stream) = + notification::channel("subspace_new_slot_notification_stream"); + let (reward_signing_notification_sender, reward_signing_notification_stream) = + notification::channel("subspace_reward_signing_notification_stream"); + let (archived_segment_notification_sender, archived_segment_notification_stream) = + notification::channel("subspace_archived_segment_notification_stream"); + let (block_importing_notification_sender, block_importing_notification_stream) = + notification::channel("subspace_block_importing_notification_stream"); + + Self { + new_slot_notification_sender, + new_slot_notification_stream, + reward_signing_notification_sender, + reward_signing_notification_stream, + archived_segment_notification_sender, + archived_segment_notification_stream, + block_importing_notification_sender, + block_importing_notification_stream, + segment_headers: Arc::new(Mutex::new(LruCache::new( + FINALIZATION_DEPTH_IN_SEGMENTS.saturating_add(1), + ))), + chain_constants, + kzg, + } } /// Get stream with notifications about new slot arrival with ability to send solution back. @@ -590,562 +129,13 @@ impl SubspaceLink { .unwrap_or_default() } + /// Subspace chain constants. + pub fn chain_constants(&self) -> &ChainConstants { + &self.chain_constants + } + /// Access KZG instance pub fn kzg(&self) -> &Kzg { &self.kzg } } - -/// A block-import handler for Subspace. -pub struct SubspaceBlockImport -where - Block: BlockT, -{ - inner: I, - client: Arc, - subspace_link: SubspaceLink, - create_inherent_data_providers: CIDP, - chain_constants: ChainConstants, - segment_headers_store: SegmentHeadersStore, - pot_verifier: PotVerifier, - _pos_table: PhantomData, -} - -impl Clone - for SubspaceBlockImport -where - Block: BlockT, - I: Clone, - CIDP: Clone, -{ - fn clone(&self) -> Self { - SubspaceBlockImport { - inner: self.inner.clone(), - client: self.client.clone(), - subspace_link: self.subspace_link.clone(), - create_inherent_data_providers: self.create_inherent_data_providers.clone(), - chain_constants: self.chain_constants, - segment_headers_store: self.segment_headers_store.clone(), - pot_verifier: self.pot_verifier.clone(), - _pos_table: PhantomData, - } - } -} - -impl SubspaceBlockImport -where - PosTable: Table, - Block: BlockT, - Client: ProvideRuntimeApi + BlockBackend + HeaderBackend + AuxStore, - Client::Api: BlockBuilderApi + SubspaceApi + ApiExt, - CIDP: CreateInherentDataProviders> + Send + Sync + 'static, - AS: AuxStore + Send + Sync + 'static, - BlockNumber: From<<::Header as HeaderT>::Number>, -{ - fn new( - client: Arc, - block_import: I, - subspace_link: SubspaceLink, - create_inherent_data_providers: CIDP, - chain_constants: ChainConstants, - segment_headers_store: SegmentHeadersStore, - pot_verifier: PotVerifier, - ) -> Self { - Self { - client, - inner: block_import, - subspace_link, - create_inherent_data_providers, - chain_constants, - segment_headers_store, - pot_verifier, - _pos_table: PhantomData, - } - } - - #[allow(clippy::too_many_arguments)] - async fn block_import_verification( - &self, - block_hash: Block::Hash, - header: Block::Header, - extrinsics: Option>, - root_plot_public_key: &Option, - subspace_digest_items: &SubspaceDigestItems< - FarmerPublicKey, - FarmerPublicKey, - FarmerSignature, - >, - justifications: &Option, - skip_runtime_access: bool, - ) -> Result<(), Error> { - let block_number = *header.number(); - let parent_hash = *header.parent_hash(); - - let pre_digest = &subspace_digest_items.pre_digest; - if let Some(root_plot_public_key) = root_plot_public_key { - if &pre_digest.solution().public_key != root_plot_public_key { - // Only root plot public key is allowed. - return Err(Error::OnlyRootPlotPublicKeyAllowed); - } - } - - // Check if farmer's plot is burned. - if self - .client - .runtime_api() - .is_in_block_list(parent_hash, &pre_digest.solution().public_key) - .or_else(|error| { - if skip_runtime_access { - Ok(false) - } else { - Err(Error::::RuntimeApi(error)) - } - })? - { - warn!( - target: "subspace", - "Ignoring block with solution provided by farmer in block list: {}", - pre_digest.solution().public_key - ); - - return Err(Error::FarmerInBlockList( - pre_digest.solution().public_key.clone(), - )); - } - - let parent_header = self - .client - .header(parent_hash)? - .ok_or(Error::ParentUnavailable(parent_hash, block_hash))?; - - let parent_slot = extract_pre_digest(&parent_header).map(|d| d.slot())?; - - // Make sure that slot number is strictly increasing - if pre_digest.slot() <= parent_slot { - return Err(Error::SlotMustIncrease(parent_slot, pre_digest.slot())); - } - - let parent_subspace_digest_items = if block_number.is_one() { - None - } else { - Some(extract_subspace_digest_items::< - _, - FarmerPublicKey, - FarmerPublicKey, - FarmerSignature, - >(&parent_header)?) - }; - - let correct_solution_range = if block_number.is_one() { - slot_worker::extract_solution_ranges_for_block(self.client.as_ref(), parent_hash)?.0 - } else { - let parent_subspace_digest_items = parent_subspace_digest_items - .as_ref() - .expect("Always Some for non-first block; qed"); - - match parent_subspace_digest_items.next_solution_range { - Some(solution_range) => solution_range, - None => parent_subspace_digest_items.solution_range, - } - }; - - if subspace_digest_items.solution_range != correct_solution_range { - return Err(Error::InvalidSolutionRange(block_hash)); - } - - // For PoT justifications we only need to check the seed and number of checkpoints, the rest - // was already checked during stateless block verification. - { - let Some(subspace_justification) = justifications - .as_ref() - .and_then(|justifications| { - justifications - .iter() - .find_map(SubspaceJustification::try_from_justification) - }) - .transpose() - .map_err(Error::InvalidSubspaceJustification)? - else { - return Err(Error::MissingSubspaceJustification); - }; - - let SubspaceJustification::PotCheckpoints { seed, checkpoints } = - subspace_justification; - - let future_slot = pre_digest.slot() + self.chain_constants.block_authoring_delay(); - - if block_number.is_one() { - // In case of first block seed must match genesis seed - if seed != self.pot_verifier.genesis_seed() { - return Err(Error::InvalidSubspaceJustificationContents); - } - - // Number of checkpoints must match future slot number - if checkpoints.len() as u64 != *future_slot { - return Err(Error::InvalidSubspaceJustificationContents); - } - } else { - let parent_subspace_digest_items = parent_subspace_digest_items - .as_ref() - .expect("Always Some for non-first block; qed"); - - let parent_future_slot = parent_slot + self.chain_constants.block_authoring_delay(); - - let correct_input_parameters = PotNextSlotInput::derive( - subspace_digest_items.pot_slot_iterations, - parent_future_slot, - parent_subspace_digest_items - .pre_digest - .pot_info() - .future_proof_of_time(), - &subspace_digest_items.pot_parameters_change, - ); - - if seed != correct_input_parameters.seed { - return Err(Error::InvalidSubspaceJustificationContents); - } - - // Number of checkpoints must match number of proofs that were not yet seen on chain - if checkpoints.len() as u64 != (*future_slot - *parent_future_slot) { - return Err(Error::InvalidSubspaceJustificationContents); - } - } - } - - let sector_id = SectorId::new( - PublicKey::from(&pre_digest.solution().public_key).hash(), - pre_digest.solution().sector_index, - ); - - // TODO: Below `skip_runtime_access` has no impact on this, but ideally it - // should (though we don't support fast sync yet, so doesn't matter in - // practice) - let max_pieces_in_sector = self - .client - .runtime_api() - .max_pieces_in_sector(parent_hash)?; - let piece_index = sector_id.derive_piece_index( - pre_digest.solution().piece_offset, - pre_digest.solution().history_size, - max_pieces_in_sector, - self.chain_constants.recent_segments(), - self.chain_constants.recent_history_fraction(), - ); - let segment_index = piece_index.segment_index(); - - let segment_commitment = self - .segment_headers_store - .get_segment_header(segment_index) - .map(|segment_header| segment_header.segment_commitment()) - .ok_or(Error::SegmentCommitmentNotFound(segment_index))?; - - let sector_expiration_check_segment_commitment = self - .segment_headers_store - .get_segment_header( - subspace_digest_items - .pre_digest - .solution() - .history_size - .sector_expiration_check(self.chain_constants.min_sector_lifetime()) - .ok_or(Error::InvalidHistorySize)? - .segment_index(), - ) - .map(|segment_header| segment_header.segment_commitment()); - - // Piece is not checked during initial block verification because it requires access to - // segment header and runtime, check it now. - subspace_verification::verify_solution::( - pre_digest.solution(), - // Slot was already checked during initial block verification - pre_digest.slot().into(), - &VerifySolutionParams { - proof_of_time: subspace_digest_items.pre_digest.pot_info().proof_of_time(), - solution_range: subspace_digest_items.solution_range, - piece_check_params: Some(PieceCheckParams { - max_pieces_in_sector, - segment_commitment, - recent_segments: self.chain_constants.recent_segments(), - recent_history_fraction: self.chain_constants.recent_history_fraction(), - min_sector_lifetime: self.chain_constants.min_sector_lifetime(), - // TODO: Below `skip_runtime_access` has no impact on this, but ideally it - // should (though we don't support fast sync yet, so doesn't matter in - // practice) - current_history_size: self.client.runtime_api().history_size(parent_hash)?, - sector_expiration_check_segment_commitment, - }), - }, - &self.subspace_link.kzg, - ) - .map_err(|error| VerificationError::VerificationError(pre_digest.slot(), error))?; - - if !skip_runtime_access { - // If the body is passed through, we need to use the runtime to check that the - // internally-set timestamp in the inherents actually matches the slot set in the seal - // and segment headers in the inherents are set correctly. - if let Some(extrinsics) = extrinsics { - let create_inherent_data_providers = self - .create_inherent_data_providers - .create_inherent_data_providers(parent_hash, self.subspace_link.clone()) - .await - .map_err(|error| Error::Client(sp_blockchain::Error::from(error)))?; - - let inherent_data = create_inherent_data_providers - .create_inherent_data() - .await - .map_err(Error::CreateInherents)?; - - let inherent_res = self.client.runtime_api().check_inherents( - parent_hash, - Block::new(header, extrinsics), - inherent_data, - )?; - - if !inherent_res.ok() { - for (i, e) in inherent_res.into_errors() { - match create_inherent_data_providers - .try_handle_error(&i, &e) - .await - { - Some(res) => res.map_err(Error::CheckInherents)?, - None => return Err(Error::CheckInherentsUnhandled(i)), - } - } - } - } - } - - Ok(()) - } -} - -#[async_trait::async_trait] -impl BlockImport - for SubspaceBlockImport -where - PosTable: Table, - Block: BlockT, - Inner: BlockImport + Send + Sync, - Inner::Error: Into, - Client: ProvideRuntimeApi - + BlockBackend - + HeaderBackend - + AuxStore - + Send - + Sync, - Client::Api: BlockBuilderApi + SubspaceApi + ApiExt, - CIDP: CreateInherentDataProviders> + Send + Sync + 'static, - AS: AuxStore + Send + Sync + 'static, - BlockNumber: From<<::Header as HeaderT>::Number>, -{ - type Error = ConsensusError; - - async fn import_block( - &mut self, - mut block: BlockImportParams, - ) -> Result { - let block_hash = block.post_hash(); - let block_number = *block.header.number(); - - // Early exit if block already in chain - match self.client.status(block_hash) { - Ok(sp_blockchain::BlockStatus::InChain) => { - block.fork_choice = Some(ForkChoiceStrategy::Custom(false)); - return self.inner.import_block(block).await.map_err(Into::into); - } - Ok(sp_blockchain::BlockStatus::Unknown) => {} - Err(error) => return Err(ConsensusError::ClientImport(error.to_string())), - } - - let subspace_digest_items = extract_subspace_digest_items(&block.header) - .map_err(|error| ConsensusError::ClientImport(error.to_string()))?; - let skip_execution_checks = block.state_action.skip_execution_checks(); - - let root_plot_public_key = self - .client - .runtime_api() - .root_plot_public_key(*block.header.parent_hash()) - .map_err(Error::::RuntimeApi) - .map_err(|e| ConsensusError::ClientImport(e.to_string()))?; - - self.block_import_verification( - block_hash, - block.header.clone(), - block.body.clone(), - &root_plot_public_key, - &subspace_digest_items, - &block.justifications, - skip_execution_checks, - ) - .await - .map_err(|error| ConsensusError::ClientImport(error.to_string()))?; - - let parent_weight = if block_number.is_one() { - 0 - } else { - aux_schema::load_block_weight(self.client.as_ref(), block.header.parent_hash()) - .map_err(|e| ConsensusError::ClientImport(e.to_string()))? - .ok_or_else(|| { - ConsensusError::ClientImport( - Error::::ParentBlockNoAssociatedWeight(block_hash) - .to_string(), - ) - })? - }; - - let added_weight = calculate_block_weight(subspace_digest_items.solution_range); - let total_weight = parent_weight + added_weight; - - aux_schema::write_block_weight(block_hash, total_weight, |values| { - block - .auxiliary - .extend(values.iter().map(|(k, v)| (k.to_vec(), Some(v.to_vec())))) - }); - - for (&segment_index, segment_commitment) in &subspace_digest_items.segment_commitments { - let found_segment_commitment = self - .segment_headers_store - .get_segment_header(segment_index) - .ok_or_else(|| { - ConsensusError::ClientImport(format!( - "Segment header for index {segment_index} not found" - )) - })? - .segment_commitment(); - - if &found_segment_commitment != segment_commitment { - warn!( - target: "subspace", - "Different segment commitment for segment index {} was found in storage, \ - likely fork below archiving point. expected {:?}, found {:?}", - segment_index, - segment_commitment, - found_segment_commitment - ); - return Err(ConsensusError::ClientImport( - Error::::DifferentSegmentCommitment(segment_index).to_string(), - )); - } - } - - // The fork choice rule is that we pick the heaviest chain (i.e. smallest solution range), - // if there's a tie we go with the longest chain - let fork_choice = { - let info = self.client.info(); - - let last_best_weight = if &info.best_hash == block.header.parent_hash() { - // the parent=genesis case is already covered for loading parent weight, so we don't - // need to cover again here - parent_weight - } else { - aux_schema::load_block_weight(&*self.client, info.best_hash) - .map_err(|e| ConsensusError::ChainLookup(e.to_string()))? - .ok_or_else(|| { - ConsensusError::ChainLookup( - "No block weight for parent header.".to_string(), - ) - })? - }; - - ForkChoiceStrategy::Custom(total_weight > last_best_weight) - }; - block.fork_choice = Some(fork_choice); - - let (acknowledgement_sender, mut acknowledgement_receiver) = mpsc::channel(0); - - self.subspace_link - .block_importing_notification_sender - .notify(move || BlockImportingNotification { - block_number, - acknowledgement_sender, - }); - - while acknowledgement_receiver.next().await.is_some() { - // Wait for all the acknowledgements to finish. - } - - self.inner.import_block(block).await - } - - async fn check_block( - &self, - block: BlockCheckParams, - ) -> Result { - self.inner.check_block(block).await.map_err(Into::into) - } -} - -/// Produce a Subspace block-import object to be used later on in the construction of an -/// import-queue. -/// -/// Also returns a link object used to correctly instantiate the import queue and background worker. -#[allow(clippy::type_complexity)] -pub fn block_import( - slot_duration: SlotDuration, - block_import_inner: I, - client: Arc, - kzg: Kzg, - create_inherent_data_providers: CIDP, - segment_headers_store: SegmentHeadersStore, - pot_verifier: PotVerifier, -) -> Result< - ( - SubspaceBlockImport, - SubspaceLink, - ), - sp_blockchain::Error, -> -where - PosTable: Table, - Block: BlockT, - Client: ProvideRuntimeApi + BlockBackend + HeaderBackend + AuxStore, - Client::Api: BlockBuilderApi + SubspaceApi, - CIDP: CreateInherentDataProviders> + Send + Sync + 'static, - AS: AuxStore + Send + Sync + 'static, - BlockNumber: From<<::Header as HeaderT>::Number>, -{ - let (new_slot_notification_sender, new_slot_notification_stream) = - notification::channel("subspace_new_slot_notification_stream"); - let (reward_signing_notification_sender, reward_signing_notification_stream) = - notification::channel("subspace_reward_signing_notification_stream"); - let (archived_segment_notification_sender, archived_segment_notification_stream) = - notification::channel("subspace_archived_segment_notification_stream"); - let (block_importing_notification_sender, block_importing_notification_stream) = - notification::channel("subspace_block_importing_notification_stream"); - - let chain_constants = client - .runtime_api() - .chain_constants(client.info().best_hash)?; - - let link = SubspaceLink { - slot_duration, - new_slot_notification_sender, - new_slot_notification_stream, - reward_signing_notification_sender, - reward_signing_notification_stream, - archived_segment_notification_sender, - archived_segment_notification_stream, - block_importing_notification_sender, - block_importing_notification_stream, - // TODO: Consider making `confirmation_depth_k` non-zero - segment_headers: Arc::new(Mutex::new(LruCache::new( - NonZeroUsize::new( - (FINALIZATION_DEPTH_IN_SEGMENTS + 1) - .max(chain_constants.confirmation_depth_k() as usize), - ) - .expect("Confirmation depth of zero is not supported"), - ))), - kzg, - }; - - let import = SubspaceBlockImport::new( - client, - block_import_inner, - link.clone(), - create_inherent_data_providers, - chain_constants, - segment_headers_store, - pot_verifier, - ); - - Ok((import, link)) -} diff --git a/crates/sc-consensus-subspace/src/slot_worker.rs b/crates/sc-consensus-subspace/src/slot_worker.rs index f4c134880e..aabc1cb7e4 100644 --- a/crates/sc-consensus-subspace/src/slot_worker.rs +++ b/crates/sc-consensus-subspace/src/slot_worker.rs @@ -1,4 +1,3 @@ -// Copyright (C) 2019-2021 Parity Technologies (UK) Ltd. // Copyright (C) 2021 Subspace Labs, Inc. // SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0 @@ -15,11 +14,14 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . +//! Slot worker module. +//! +//! Contains implementation of Subspace slot worker that produces block and votes. + use crate::archiver::SegmentHeadersStore; -use crate::{NewSlotInfo, NewSlotNotification, RewardSigningNotification, SubspaceLink}; +use crate::SubspaceLink; use futures::channel::mpsc; use futures::{StreamExt, TryFutureExt}; -use log::{debug, error, info, warn}; use sc_client_api::AuxStore; use sc_consensus::block_import::{BlockImportParams, StateAction}; use sc_consensus::{JustificationSyncLink, SharedBlockImport, StorageChanges}; @@ -30,7 +32,7 @@ use sc_proof_of_time::verifier::PotVerifier; use sc_proof_of_time::PotSlotWorker; use sc_telemetry::TelemetryHandle; use sc_transaction_pool_api::OffchainTransactionPoolFactory; -use sc_utils::mpsc::tracing_unbounded; +use sc_utils::mpsc::{tracing_unbounded, TracingUnboundedSender}; use schnorrkel::context::SigningContext; use sp_api::{ApiError, ApiExt, NumberFor, ProvideRuntimeApi}; use sp_blockchain::{Error as ClientError, HeaderBackend, HeaderMetadata}; @@ -40,7 +42,7 @@ use sp_consensus_subspace::digests::{ extract_pre_digest, CompatibleDigestItem, PreDigest, PreDigestPotInfo, }; use sp_consensus_subspace::{ - ChainConstants, FarmerPublicKey, FarmerSignature, PotNextSlotInput, SignedVote, SubspaceApi, + FarmerPublicKey, FarmerSignature, PotNextSlotInput, SignedVote, SubspaceApi, SubspaceJustification, Vote, }; use sp_core::crypto::ByteArray; @@ -53,12 +55,14 @@ use std::marker::PhantomData; use std::pin::Pin; use std::sync::Arc; use subspace_core_primitives::{ - BlockNumber, PotCheckpoints, PotOutput, PublicKey, RewardSignature, SectorId, Solution, + BlockNumber, PotCheckpoints, PotOutput, PublicKey, Randomness, RewardSignature, SectorId, + Solution, SolutionRange, REWARD_SIGNING_CONTEXT, }; use subspace_proof_of_space::Table; use subspace_verification::{ check_reward_signature, verify_solution, PieceCheckParams, VerifySolutionParams, }; +use tracing::{debug, error, info, warn}; /// Large enough size for any practical purposes, there shouldn't be even this many solutions. const PENDING_SOLUTIONS_CHANNEL_CAPACITY: usize = 10; @@ -104,33 +108,110 @@ where } } -pub(super) struct SubspaceSlotWorker +/// Information about new slot that just arrived +#[derive(Debug, Copy, Clone)] +pub struct NewSlotInfo { + /// Slot + pub slot: Slot, + /// Global randomness + pub global_randomness: Randomness, + /// Acceptable solution range for block authoring + pub solution_range: SolutionRange, + /// Acceptable solution range for voting + pub voting_solution_range: SolutionRange, +} + +/// New slot notification with slot information and sender for solution for the slot. +#[derive(Debug, Clone)] +pub struct NewSlotNotification { + /// New slot information. + pub new_slot_info: NewSlotInfo, + /// Sender that can be used to send solutions for the slot. + pub solution_sender: mpsc::Sender>, +} +/// Notification with a hash that needs to be signed to receive reward and sender for signature. +#[derive(Debug, Clone)] +pub struct RewardSigningNotification { + /// Hash to be signed. + pub hash: H256, + /// Public key of the plot identity that should create signature. + pub public_key: FarmerPublicKey, + /// Sender that can be used to send signature for the header. + pub signature_sender: TracingUnboundedSender, +} + +/// Parameters for [`SubspaceSlotWorker`] +pub struct SubspaceSlotWorkerOptions +where + Block: BlockT, + SO: SyncOracle + Send + Sync, +{ + /// The client to use + pub client: Arc, + /// The environment we are producing blocks for. + pub env: E, + /// The underlying block-import object to supply our produced blocks to. + /// This must be a `SubspaceBlockImport` or a wrapper of it, otherwise + /// critical consensus logic will be omitted. + pub block_import: SharedBlockImport, + /// A sync oracle + pub sync_oracle: SubspaceSyncOracle, + /// Hook into the sync module to control the justification sync process. + pub justification_sync_link: L, + /// Force authoring of blocks even if we are offline + pub force_authoring: bool, + /// Strategy and parameters for backing off block production. + pub backoff_authoring_blocks: Option, + /// The source of timestamps for relative slots + pub subspace_link: SubspaceLink, + /// Persistent storage of segment headers + pub segment_headers_store: SegmentHeadersStore, + /// 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, + /// Handle use to report telemetries. + pub telemetry: Option, + /// The offchain transaction pool factory. + /// + /// Will be used when sending equivocation reports and votes. + pub offchain_tx_pool_factory: OffchainTransactionPoolFactory, + /// Proof of time verifier + pub pot_verifier: PotVerifier, +} + +/// Subspace slot worker responsible for block and vote production +pub struct SubspaceSlotWorker where Block: BlockT, + SO: SyncOracle + Send + Sync, { - pub(super) client: Arc, - pub(super) block_import: SharedBlockImport, - pub(super) env: E, - pub(super) sync_oracle: SO, - pub(super) justification_sync_link: L, - pub(super) force_authoring: bool, - pub(super) backoff_authoring_blocks: Option, - pub(super) subspace_link: SubspaceLink, - pub(super) reward_signing_context: SigningContext, - pub(super) block_proposal_slot_portion: SlotProportion, - pub(super) max_block_proposal_slot_portion: Option, - pub(super) telemetry: Option, - pub(crate) offchain_tx_pool_factory: OffchainTransactionPoolFactory, - pub(super) chain_constants: ChainConstants, - pub(super) segment_headers_store: SegmentHeadersStore, + client: Arc, + block_import: SharedBlockImport, + env: E, + sync_oracle: SubspaceSyncOracle, + justification_sync_link: L, + force_authoring: bool, + backoff_authoring_blocks: Option, + subspace_link: SubspaceLink, + reward_signing_context: SigningContext, + block_proposal_slot_portion: SlotProportion, + max_block_proposal_slot_portion: Option, + telemetry: Option, + offchain_tx_pool_factory: OffchainTransactionPoolFactory, + segment_headers_store: SegmentHeadersStore, /// Solution receivers for challenges that were sent to farmers and expected to be received /// eventually - pub(super) pending_solutions: - BTreeMap>>, + pending_solutions: BTreeMap>>, /// Collection of PoT slots that can be retrieved later if needed by block production - pub(super) pot_checkpoints: BTreeMap, - pub(super) pot_verifier: PotVerifier, - pub(super) _pos_table: PhantomData, + pot_checkpoints: BTreeMap, + pot_verifier: PotVerifier, + _pos_table: PhantomData, } impl PotSlotWorker @@ -149,10 +230,7 @@ where self.pot_checkpoints.insert(slot, checkpoints); if self.sync_oracle.is_major_syncing() { - debug!( - target: "subspace", - "Skipping farming slot {slot} due to sync" - ); + debug!("Skipping farming slot {slot} due to sync"); return; } @@ -167,8 +245,10 @@ where Ok(solution_ranges) => solution_ranges, Err(error) => { warn!( - target: "subspace", - "Failed to extract solution ranges for block at slot {slot}: {error}" + %slot, + %best_hash, + %error, + "Failed to extract solution ranges for block" ); return; } @@ -216,7 +296,7 @@ where BlockNumber: From<<::Header as Header>::Number>, { type BlockImport = SharedBlockImport; - type SyncOracle = SO; + type SyncOracle = SubspaceSyncOracle; type JustificationSyncLink = L; type CreateProposer = Pin> + Send + 'static>>; @@ -260,8 +340,8 @@ where Ok(pre_digest) => pre_digest, Err(error) => { error!( - target: "subspace", - "Failed to parse pre-digest out of parent header: {error}" + %error, + "Failed to parse pre-digest out of parent header" ); return None; @@ -271,15 +351,16 @@ where if slot <= parent_slot { debug!( - target: "subspace", "Skipping claiming slot {slot} it must be higher than parent slot {parent_slot}", ); return None; } else { - debug!(target: "subspace", "Attempting to claim slot {}", slot); + debug!(%slot, "Attempting to claim slot"); } + let chain_constants = self.subspace_link.chain_constants(); + let parent_hash = parent_header.hash(); let runtime_api = self.client.runtime_api(); @@ -292,7 +373,7 @@ where let parent_future_slot = if parent_header.number().is_zero() { parent_slot } else { - parent_slot + self.chain_constants.block_authoring_delay() + parent_slot + chain_constants.block_authoring_delay() }; let (proof_of_time, future_proof_of_time, pot_justification) = { @@ -303,7 +384,7 @@ where let proof_of_time = self.pot_checkpoints.get(&slot)?.output(); // Future slot for which proof must be available before authoring block at this slot - let future_slot = slot + self.chain_constants.block_authoring_delay(); + let future_slot = slot + chain_constants.block_authoring_delay(); let pot_input = if parent_header.number().is_zero() { PotNextSlotInput { @@ -328,8 +409,8 @@ where parent_pot_parameters.next_parameters_change(), ) { warn!( - target: "subspace", - "Proof of time is invalid, skipping block authoring at slot {slot:?}" + %slot, + "Proof of time is invalid, skipping block authoring at slot" ); return None; } @@ -414,10 +495,9 @@ where .ok()? { warn!( - target: "subspace", - "Ignoring solution for slot {} provided by farmer in block list: {}", - slot, - solution.public_key, + %slot, + public_key = %solution.public_key, + "Ignoring solution provided by farmer in block list", ); continue; @@ -436,8 +516,8 @@ where solution.piece_offset, solution.history_size, max_pieces_in_sector, - self.chain_constants.recent_segments(), - self.chain_constants.recent_history_fraction(), + chain_constants.recent_segments(), + chain_constants.recent_history_fraction(), ) .segment_index(); let maybe_segment_commitment = self @@ -449,17 +529,16 @@ where Some(segment_commitment) => segment_commitment, None => { warn!( - target: "subspace", - "Segment commitment for segment index {} not found (slot {})", - segment_index, - slot, + %slot, + %segment_index, + "Segment commitment not found", ); continue; } }; let sector_expiration_check_segment_index = match solution .history_size - .sector_expiration_check(self.chain_constants.min_sector_lifetime()) + .sector_expiration_check(chain_constants.min_sector_lifetime()) { Some(sector_expiration_check) => sector_expiration_check.segment_index(), None => { @@ -479,9 +558,9 @@ where piece_check_params: Some(PieceCheckParams { max_pieces_in_sector, segment_commitment, - recent_segments: self.chain_constants.recent_segments(), - recent_history_fraction: self.chain_constants.recent_history_fraction(), - min_sector_lifetime: self.chain_constants.min_sector_lifetime(), + recent_segments: chain_constants.recent_segments(), + recent_history_fraction: chain_constants.recent_history_fraction(), + min_sector_lifetime: chain_constants.min_sector_lifetime(), current_history_size: history_size, sector_expiration_check_segment_commitment, }), @@ -495,7 +574,7 @@ where // block reward is claimed if solution_distance <= solution_range / 2 { if maybe_pre_digest.is_none() { - info!(target: "subspace", "🚜 Claimed block at slot {slot}"); + info!(%slot, "🚜 Claimed block at slot"); maybe_pre_digest.replace(PreDigest::V0 { slot, solution, @@ -506,15 +585,15 @@ where }); } else { info!( - target: "subspace", - "Skipping solution that has quality sufficient for block {slot} \ - because block pre-digest was already created", + %slot, + "Skipping solution that has quality sufficient for block because \ + block pre-digest was already created", ); } } else if !parent_header.number().is_zero() { // Not sending vote on top of genesis block since segment headers since piece // verification wouldn't be possible due to missing (for now) segment commitment - info!(target: "subspace", "🗳️ Claimed vote at slot {slot}"); + info!(%slot, "🗳️ Claimed vote at slot"); self.create_vote( parent_header, @@ -536,18 +615,24 @@ where .is_some() { debug!( - target: "subspace", - "Invalid solution received for slot {slot}: {error:?}", + %slot, + %error, + "Invalid solution received", ); } else { warn!( - target: "subspace", - "Invalid solution received for slot {slot}: {error:?}", + %slot, + %error, + "Invalid solution received", ); } } Err(error) => { - warn!(target: "subspace", "Invalid solution received for slot {slot}: {error:?}"); + warn!( + %slot, + %error, + "Invalid solution received", + ); } } } @@ -669,6 +754,47 @@ where AS: AuxStore + Send + Sync + 'static, BlockNumber: From<<::Header as Header>::Number>, { + /// Create new Subspace slot worker + pub fn new( + SubspaceSlotWorkerOptions { + client, + env, + block_import, + sync_oracle, + justification_sync_link, + force_authoring, + backoff_authoring_blocks, + subspace_link, + segment_headers_store, + block_proposal_slot_portion, + max_block_proposal_slot_portion, + telemetry, + offchain_tx_pool_factory, + pot_verifier, + }: SubspaceSlotWorkerOptions, + ) -> Self { + Self { + client: client.clone(), + block_import, + env, + sync_oracle, + justification_sync_link, + force_authoring, + backoff_authoring_blocks, + subspace_link, + reward_signing_context: schnorrkel::context::signing_context(REWARD_SIGNING_CONTEXT), + block_proposal_slot_portion, + max_block_proposal_slot_portion, + telemetry, + offchain_tx_pool_factory, + segment_headers_store, + pending_solutions: Default::default(), + pot_checkpoints: Default::default(), + pot_verifier, + _pos_table: PhantomData::, + } + } + async fn create_vote( &self, parent_header: &Block::Header, @@ -703,8 +829,9 @@ where Ok(signature) => signature, Err(error) => { error!( - target: "subspace", - "Failed to submit vote at slot {slot}: {error:?}", + %slot, + %error, + "Failed to submit vote", ); return; } @@ -714,8 +841,9 @@ where if let Err(error) = runtime_api.submit_vote_extrinsic(parent_hash, signed_vote) { error!( - target: "subspace", - "Failed to submit vote at slot {slot}: {error:?}", + %slot, + %error, + "Failed to submit vote", ); } } @@ -746,8 +874,8 @@ where .is_err() { warn!( - target: "subspace", - "Received invalid signature for reward hash {hash:?}" + %hash, + "Received invalid signature for reward" ); continue; } diff --git a/crates/sc-consensus-subspace/src/verifier.rs b/crates/sc-consensus-subspace/src/verifier.rs index 260ccbed27..1df226cdb3 100644 --- a/crates/sc-consensus-subspace/src/verifier.rs +++ b/crates/sc-consensus-subspace/src/verifier.rs @@ -1,8 +1,6 @@ //! Subspace block import implementation -use crate::Error; use futures::lock::Mutex; -use log::{debug, info, trace, warn}; use rand::prelude::*; use rayon::prelude::*; use sc_client_api::backend::AuxStore; @@ -38,6 +36,7 @@ use subspace_core_primitives::{BlockNumber, PublicKey, RewardSignature}; use subspace_proof_of_space::Table; use subspace_verification::{check_reward_signature, verify_solution, VerifySolutionParams}; use tokio::sync::Semaphore; +use tracing::{debug, info, trace, warn}; /// This corresponds to default value of `--max-runtime-instances` in Substrate const BLOCKS_LIST_CHECK_CONCURRENCY: usize = 8; @@ -102,6 +101,8 @@ where { /// Substrate client pub client: Arc, + /// Subspace chain constants + pub chain_constants: ChainConstants, /// Kzg instance pub kzg: Kzg, /// Chain selection rule @@ -153,11 +154,10 @@ where SelectChain: sp_consensus::SelectChain, { /// Create new instance - pub fn new( - options: SubspaceVerifierOptions, - ) -> sp_blockchain::Result { + pub fn new(options: SubspaceVerifierOptions) -> Self { let SubspaceVerifierOptions { client, + chain_constants, kzg, select_chain, telemetry, @@ -168,11 +168,7 @@ where pot_verifier, } = options; - let chain_constants = client - .runtime_api() - .chain_constants(client.info().best_hash)?; - - Ok(Self { + Self { client, kzg, select_chain, @@ -187,7 +183,7 @@ where block_list_verification_semaphore: Semaphore::new(BLOCKS_LIST_CHECK_CONCURRENCY), _pos_table: Default::default(), _block: Default::default(), - }) + } } /// Determine if full proof of time verification is needed for this block number @@ -390,7 +386,7 @@ where header: &Block::Header, author: &FarmerPublicKey, origin: &BlockOrigin, - ) -> Result<(), Error> { + ) -> Result<(), String> { // don't report any equivocations during initial sync // as they are most likely stale. if *origin == BlockOrigin::NetworkInitialSync { @@ -404,7 +400,7 @@ where // check if authorship of this header is an equivocation and return a proof if so. let equivocation_proof = match check_equivocation(&*self.client, slot_now, slot, header, author) - .map_err(Error::Client)? + .map_err(|error| error.to_string())? { Some(proof) => proof, None => return Ok(()), @@ -425,7 +421,7 @@ where .best_chain() .await .map(|h| h.hash()) - .map_err(|e| Error::Client(e.into()))?; + .map_err(|error| error.to_string())?; // submit equivocation report at best block. let mut runtime_api = self.client.runtime_api(); @@ -436,14 +432,11 @@ where ); runtime_api .submit_report_equivocation_extrinsic(best_hash, equivocation_proof) - .map_err(Error::RuntimeApi)?; + .map_err(|error| error.to_string())?; - info!(target: "subspace", "Submitted equivocation report for author {:?}", author); + info!(%author, "Submitted equivocation report for author"); } else { - info!( - target: "subspace", - "Not submitting equivocation report because node is not authoring blocks" - ); + info!("Not submitting equivocation report because node is not authoring blocks"); } Ok(()) @@ -470,25 +463,26 @@ where mut block: BlockImportParams, ) -> Result, String> { trace!( - target: "subspace", - "Verifying origin: {:?} header: {:?} justification(s): {:?} body: {:?}", - block.origin, - block.header, - block.justifications, - block.body, + origin = ?block.origin, + header = ?block.header, + justifications = ?block.justifications, + body = ?block.body, + "Verifying", ); let hash = block.header.hash(); - debug!(target: "subspace", "We have {:?} logs in this header", block.header.digest().logs().len()); + debug!( + "We have {:?} logs in this header", + block.header.digest().logs().len() + ); let subspace_digest_items = extract_subspace_digest_items::< Block::Header, FarmerPublicKey, FarmerPublicKey, FarmerSignature, - >(&block.header) - .map_err(Error::::from)?; + >(&block.header)?; // Check if farmer's plot is burned, ignore runtime API errors since this check will happen // during block import anyway @@ -509,19 +503,18 @@ where .unwrap_or_default() { warn!( - target: "subspace", - "Verifying block with solution provided by farmer in block list: {}", - subspace_digest_items.pre_digest.solution().public_key + public_key = %subspace_digest_items.pre_digest.solution().public_key, + "Verifying block with solution provided by farmer in block list" ); - return Err(Error::::FarmerInBlockList( + return Err(format!( + "Farmer {} is in block list", subspace_digest_items .pre_digest .solution() .public_key .clone(), - ) - .into()); + )); } } @@ -549,7 +542,7 @@ where &block.justifications, ) .await - .map_err(Error::::from)?; + .map_err(|error| error.to_string())?; let CheckedHeader { pre_header, @@ -575,7 +568,7 @@ where // the header is valid but let's check if there was something else already proposed at the // same slot by the given author. if there was, we will report the equivocation to the // runtime. - if let Err(err) = self + if let Err(error) = self .check_and_report_equivocation( slot_now, slot, @@ -586,13 +579,12 @@ where .await { warn!( - target: "subspace", - "Error checking/reporting Subspace equivocation: {}", - err + %error, + "Error checking/reporting Subspace equivocation" ); } - trace!(target: "subspace", "Checked {:?}; importing.", pre_header); + trace!(?pre_header, "Checked header; importing"); telemetry!( self.telemetry; CONSENSUS_TRACE; diff --git a/crates/sc-proof-of-time/Cargo.toml b/crates/sc-proof-of-time/Cargo.toml index 8fbcf082e0..787dd58838 100644 --- a/crates/sc-proof-of-time/Cargo.toml +++ b/crates/sc-proof-of-time/Cargo.toml @@ -17,17 +17,17 @@ derive_more = "0.99.17" futures = "0.3.29" lru = "0.11.0" parity-scale-codec = { version = "3.6.1", features = ["derive"] } -sc-client-api = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sc-consensus-slots = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sc-network = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sc-network-gossip = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-api = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-blockchain = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-consensus = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-consensus-slots = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +sc-client-api = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sc-consensus-slots = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sc-network = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sc-network-gossip = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-api = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-blockchain = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-consensus = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-consensus-slots = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } sp-consensus-subspace = { version = "0.1.0", path = "../sp-consensus-subspace" } -sp-inherents = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-runtime = { version = "24.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +sp-inherents = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-runtime = { version = "24.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } subspace-core-primitives = { version = "0.1.0", path = "../subspace-core-primitives" } subspace-proof-of-time = { version = "0.1.0", path = "../subspace-proof-of-time" } parking_lot = "0.12.1" diff --git a/crates/sc-proof-of-time/src/source/gossip.rs b/crates/sc-proof-of-time/src/source/gossip.rs index f0061f31a9..c8399161e6 100644 --- a/crates/sc-proof-of-time/src/source/gossip.rs +++ b/crates/sc-proof-of-time/src/source/gossip.rs @@ -22,6 +22,7 @@ use std::collections::{HashMap, VecDeque}; use std::future::poll_fn; use std::hash::{Hash, Hasher}; use std::num::{NonZeroU32, NonZeroUsize}; +use std::pin::pin; use std::sync::{atomic, Arc}; use subspace_core_primitives::{PotCheckpoints, PotSeed, SlotNumber}; use tracing::{debug, error, trace, warn}; @@ -167,31 +168,28 @@ where /// should be running on a dedicated thread. pub async fn run(mut self) { let message_receiver = self.engine.lock().messages_for(self.topic); - let mut incoming_unverified_messages = Box::pin( - message_receiver - .filter_map(|notification| async move { - notification.sender.map(|sender| { - let proof = GossipProof::decode(&mut notification.message.as_ref()) - .expect("Only valid messages get here; qed"); - - (sender, proof) - }) + let incoming_unverified_messages = + pin!(message_receiver.filter_map(|notification| async move { + notification.sender.map(|sender| { + let proof = GossipProof::decode(&mut notification.message.as_ref()) + .expect("Only valid messages get here; qed"); + + (sender, proof) }) - .fuse(), - ); + })); + let mut incoming_unverified_messages = incoming_unverified_messages.fuse(); loop { - let gossip_engine_poll = poll_fn(|cx| self.engine.lock().poll_unpin(cx)); + let mut gossip_engine_poll = poll_fn(|cx| self.engine.lock().poll_unpin(cx)).fuse(); + futures::select! { - message = incoming_unverified_messages.next() => { - if let Some((sender, proof)) = message { - self.handle_proof_candidate(sender, proof).await; - } + (sender, proof) = incoming_unverified_messages.select_next_some() => { + self.handle_proof_candidate(sender, proof).await; }, message = self.to_gossip_receiver.select_next_some() => { self.handle_to_gossip_messages(message).await }, - _ = gossip_engine_poll.fuse() => { + _ = gossip_engine_poll => { error!("Gossip engine has terminated"); return; } diff --git a/crates/sc-subspace-block-relay/Cargo.toml b/crates/sc-subspace-block-relay/Cargo.toml index 9918b82230..513b8d87a2 100644 --- a/crates/sc-subspace-block-relay/Cargo.toml +++ b/crates/sc-subspace-block-relay/Cargo.toml @@ -17,16 +17,16 @@ codec = { package = "parity-scale-codec", version = "3.6.5", default-features = derive_more = "0.99.17" futures = "0.3.29" parking_lot = "0.12.1" -sc-client-api = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sc-network = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sc-network-common = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sc-network-sync = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-api = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +sc-client-api = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sc-network = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sc-network-common = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sc-network-sync = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-api = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } sp-consensus-subspace = { version = "0.1.0", path = "../sp-consensus-subspace" } -sc-transaction-pool-api = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-runtime = { version = "24.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +sc-transaction-pool-api = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-runtime = { version = "24.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } strum_macros = "0.25.2" -substrate-prometheus-endpoint = { git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +substrate-prometheus-endpoint = { git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } thiserror = "1.0.48" tracing = "0.1.37" diff --git a/crates/sc-subspace-chain-specs/Cargo.toml b/crates/sc-subspace-chain-specs/Cargo.toml index a66c0fe98d..4f78425e92 100644 --- a/crates/sc-subspace-chain-specs/Cargo.toml +++ b/crates/sc-subspace-chain-specs/Cargo.toml @@ -12,9 +12,9 @@ include = [ ] [dependencies] -sc-chain-spec = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sc-service = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1", default-features = false } -sc-telemetry = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +sc-chain-spec = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sc-service = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c", default-features = false } +sc-telemetry = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } serde = "1.0.183" -sp-core = { version = "21.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-runtime = { version = "24.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +sp-core = { version = "21.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-runtime = { version = "24.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } diff --git a/crates/subspace-node/res/chain-spec-raw-devnet.json b/crates/sc-subspace-chain-specs/res/chain-spec-raw-devnet.json similarity index 100% rename from crates/subspace-node/res/chain-spec-raw-devnet.json rename to crates/sc-subspace-chain-specs/res/chain-spec-raw-devnet.json diff --git a/crates/subspace-node/res/chain-spec-raw-gemini-3g.json b/crates/sc-subspace-chain-specs/res/chain-spec-raw-gemini-3g.json similarity index 100% rename from crates/subspace-node/res/chain-spec-raw-gemini-3g.json rename to crates/sc-subspace-chain-specs/res/chain-spec-raw-gemini-3g.json diff --git a/crates/sc-subspace-chain-specs/src/lib.rs b/crates/sc-subspace-chain-specs/src/lib.rs index 8eb6948dbc..0373230c05 100644 --- a/crates/sc-subspace-chain-specs/src/lib.rs +++ b/crates/sc-subspace-chain-specs/src/lib.rs @@ -22,6 +22,11 @@ pub use utils::SerializableChainSpec; use sc_chain_spec::NoExtension; +/// Devnet chain spec +pub const DEVNET_CHAIN_SPEC: &str = include_str!("../res/chain-spec-raw-devnet.json"); +/// Gemini 3g chain spec +pub const GEMINI_3G_CHAIN_SPEC: &str = include_str!("../res/chain-spec-raw-gemini-3g.json"); + /// Specialized `ChainSpec` for the consensus runtime. pub type ConsensusChainSpec = SerializableChainSpec; diff --git a/crates/sp-consensus-subspace/Cargo.toml b/crates/sp-consensus-subspace/Cargo.toml index 67bace4011..66c6c1844f 100644 --- a/crates/sp-consensus-subspace/Cargo.toml +++ b/crates/sp-consensus-subspace/Cargo.toml @@ -18,17 +18,17 @@ codec = { package = "parity-scale-codec", version = "3.6.5", default-features = log = { version = "0.4.20", default-features = false } scale-info = { version = "2.7.0", default-features = false, features = ["derive"] } schnorrkel = { version = "0.9.1", default-features = false, features = ["u64_backend"] } -sp-api = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-application-crypto = { version = "23.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-consensus-slots = { version = "0.10.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-core = { version = "21.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-externalities = { version = "0.19.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-inherents = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-io = { version = "23.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-runtime = { version = "24.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-runtime-interface = { version = "17.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-std = { version = "8.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-timestamp = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1", default-features = false } +sp-api = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-application-crypto = { version = "23.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-consensus-slots = { version = "0.10.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-core = { version = "21.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-externalities = { version = "0.19.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-inherents = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-io = { version = "23.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-runtime = { version = "24.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-runtime-interface = { version = "17.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-std = { version = "8.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-timestamp = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c", default-features = false } subspace-core-primitives = { version = "0.1.0", path = "../subspace-core-primitives", default-features = false } subspace-proof-of-space = { version = "0.1.0", path = "../subspace-proof-of-space", default-features = false } subspace-verification = { version = "0.1.0", path = "../subspace-verification", default-features = false } diff --git a/crates/sp-consensus-subspace/src/inherents.rs b/crates/sp-consensus-subspace/src/inherents.rs index 19d4f4c8e6..6e6af6d467 100644 --- a/crates/sp-consensus-subspace/src/inherents.rs +++ b/crates/sp-consensus-subspace/src/inherents.rs @@ -51,7 +51,8 @@ impl IsFatalError for InherentError { #[derive(Debug, Encode, Decode)] pub struct InherentType { /// Slot at which block was created. - pub slot: Slot, + // TODO: Remove slot when breaking protocol and probably change the whole data structure to an enum + slot: Slot, /// Segment headers expected to be included in the block. pub segment_headers: Vec, } @@ -83,44 +84,23 @@ pub struct InherentDataProvider { #[cfg(feature = "std")] impl InherentDataProvider { - /// Create new inherent data provider from the given `data`. - pub fn new(slot: Slot, segment_headers: Vec) -> Self { + /// Create new inherent data provider from the given `segment_headers`. + pub fn new(segment_headers: Vec) -> Self { Self { data: InherentType { - slot, + // TODO: Remove slot when breaking protocol + slot: Default::default(), segment_headers, }, } } - /// Creates the inherent data provider by calculating the slot from the given - /// `timestamp` and `duration`. - pub fn from_timestamp_and_slot_duration( - timestamp: sp_timestamp::Timestamp, - slot_duration: sp_consensus_slots::SlotDuration, - segment_headers: Vec, - ) -> Self { - let slot = Slot::from_timestamp(timestamp, slot_duration); - - Self::new(slot, segment_headers) - } - /// Returns the `data` of this inherent data provider. pub fn data(&self) -> &InherentType { &self.data } } -#[cfg(feature = "std")] -impl sp_std::ops::Deref for InherentDataProvider { - type Target = Slot; - - #[inline] - fn deref(&self) -> &Self::Target { - &self.data.slot - } -} - #[cfg(feature = "std")] #[async_trait::async_trait] impl sp_inherents::InherentDataProvider for InherentDataProvider { diff --git a/crates/sp-consensus-subspace/src/lib.rs b/crates/sp-consensus-subspace/src/lib.rs index 7a5d1a3bad..d933a3ad3d 100644 --- a/crates/sp-consensus-subspace/src/lib.rs +++ b/crates/sp-consensus-subspace/src/lib.rs @@ -403,9 +403,9 @@ impl Default for SolutionRanges { } } -// TODO: Likely add more stuff here +// TODO: Remove V0 when we break the protocol /// Subspace blockchain constants. -#[derive(Debug, Encode, Decode, MaxEncodedLen, PartialEq, Eq, Clone, Copy, TypeInfo)] +#[derive(Debug, Encode, Decode, PartialEq, Eq, Clone, Copy, TypeInfo)] pub enum ChainConstants { /// V0 of the chain constants. #[codec(index = 0)] @@ -425,65 +425,125 @@ pub enum ChainConstants { /// Minimum lifetime of a plotted sector, measured in archived segment. min_sector_lifetime: HistorySize, }, + /// V0 of the chain constants. + #[codec(index = 1)] + V1 { + /// Depth `K` after which a block enters the recorded history. + confirmation_depth_k: BlockNumber, + /// Number of slots between slot arrival and when corresponding block can be produced. + block_authoring_delay: Slot, + /// Era duration in blocks. + era_duration: BlockNumber, + /// Slot probability. + slot_probability: (u64, u64), + /// The slot duration in milliseconds. + slot_duration: SlotDuration, + /// Number of latest archived segments that are considered "recent history". + recent_segments: HistorySize, + /// Fraction of pieces from the "recent history" (`recent_segments`) in each sector. + recent_history_fraction: (HistorySize, HistorySize), + /// Minimum lifetime of a plotted sector, measured in archived segment. + min_sector_lifetime: HistorySize, + }, } impl ChainConstants { /// Depth `K` after which a block enters the recorded history. pub fn confirmation_depth_k(&self) -> BlockNumber { - let Self::V0 { - confirmation_depth_k, - .. - } = self; - *confirmation_depth_k + match self { + Self::V0 { + confirmation_depth_k, + .. + } + | Self::V1 { + confirmation_depth_k, + .. + } => *confirmation_depth_k, + } } /// Era duration in blocks. pub fn era_duration(&self) -> BlockNumber { - let Self::V0 { era_duration, .. } = self; - *era_duration + match self { + Self::V0 { era_duration, .. } | Self::V1 { era_duration, .. } => *era_duration, + } } /// Number of slots between slot arrival and when corresponding block can be produced. pub fn block_authoring_delay(&self) -> Slot { - let Self::V0 { - block_authoring_delay, - .. - } = self; - *block_authoring_delay + match self { + Self::V0 { + block_authoring_delay, + .. + } + | Self::V1 { + block_authoring_delay, + .. + } => *block_authoring_delay, + } } /// Slot probability. pub fn slot_probability(&self) -> (u64, u64) { - let Self::V0 { - slot_probability, .. - } = self; - *slot_probability + match self { + Self::V0 { + slot_probability, .. + } + | Self::V1 { + slot_probability, .. + } => *slot_probability, + } + } + + /// The slot duration in milliseconds. + pub fn slot_duration(&self) -> SlotDuration { + match self { + Self::V0 { .. } => { + // 1000ms is used on most networks, so it is a safe default + SlotDuration::from_millis(1000) + } + Self::V1 { slot_duration, .. } => *slot_duration, + } } /// Number of latest archived segments that are considered "recent history". pub fn recent_segments(&self) -> HistorySize { - let Self::V0 { - recent_segments, .. - } = self; - *recent_segments + match self { + Self::V0 { + recent_segments, .. + } + | Self::V1 { + recent_segments, .. + } => *recent_segments, + } } /// Fraction of pieces from the "recent history" (`recent_segments`) in each sector. pub fn recent_history_fraction(&self) -> (HistorySize, HistorySize) { - let Self::V0 { - recent_history_fraction, - .. - } = self; - *recent_history_fraction + match self { + Self::V0 { + recent_history_fraction, + .. + } + | Self::V1 { + recent_history_fraction, + .. + } => *recent_history_fraction, + } } /// Minimum lifetime of a plotted sector, measured in archived segment. pub fn min_sector_lifetime(&self) -> HistorySize { - let Self::V0 { - min_sector_lifetime, - .. - } = self; - *min_sector_lifetime + match self { + Self::V0 { + min_sector_lifetime, + .. + } + | Self::V1 { + min_sector_lifetime, + .. + } => *min_sector_lifetime, + } } } @@ -688,6 +748,7 @@ sp_api::decl_runtime_apis! { /// API necessary for block authorship with Subspace. pub trait SubspaceApi { /// The slot duration in milliseconds for Subspace. + #[deprecated(note = "Use chain constants instead")] fn slot_duration() -> SlotDuration; /// Proof of time parameters diff --git a/crates/sp-domains-fraud-proof/Cargo.toml b/crates/sp-domains-fraud-proof/Cargo.toml index 54dd4efc5b..e201947b39 100644 --- a/crates/sp-domains-fraud-proof/Cargo.toml +++ b/crates/sp-domains-fraud-proof/Cargo.toml @@ -14,23 +14,24 @@ include = [ codec = { package = "parity-scale-codec", version = "3.6.5", default-features = false, features = ["derive"] } domain-block-preprocessor = { version = "0.1.0", default-features = false, path = "../../domains/client/block-preprocessor", optional = true } domain-runtime-primitives = { version = "0.1.0", default-features = false, path = "../../domains/primitives/runtime" } -frame-support = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +frame-support = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } hash-db = { version = "0.16.0", default-features = false } +log = { version = "0.4.20", default-features = false } scale-info = { version = "2.7.0", default-features = false, features = ["derive"] } -sc-client-api = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1", optional = true } -sc-executor = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1", default-features = false, optional = true } -sp-api = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-blockchain = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1", optional = true } -sp-consensus-slots = { version = "0.10.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-core = { version = "21.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +sc-client-api = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c", optional = true } +sc-executor = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c", default-features = false, optional = true } +sp-api = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-blockchain = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c", optional = true } +sp-consensus-slots = { version = "0.10.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-core = { version = "21.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } sp-domain-digests = { version = "0.1.0", default-features = false, path = "../../domains/primitives/digests" } sp-domains = { version = "0.1.0", default-features = false, path = "../sp-domains" } -sp-externalities = { version = "0.19.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-runtime = { version = "24.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-runtime-interface = { version = "17.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-state-machine = { version = "0.28.0", optional = true, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-std = { version = "8.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-trie = { version = "22.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +sp-externalities = { version = "0.19.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-runtime = { version = "24.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-runtime-interface = { version = "17.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-state-machine = { version = "0.28.0", optional = true, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-std = { version = "8.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-trie = { version = "22.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } subspace-core-primitives = { version = "0.1.0", default-features = false, path = "../subspace-core-primitives" } subspace-runtime-primitives = { version = "0.1.0", default-features = false, path = "../subspace-runtime-primitives" } trie-db = { version = "0.28.0", default-features = false } @@ -40,16 +41,16 @@ thiserror = { version = "1.0.48", optional = true } domain-block-builder = { version = "0.1.0", path = "../../domains/client/block-builder" } domain-block-preprocessor = { version = "0.1.0", path = "../../domains/client/block-preprocessor" } domain-test-service = { version = "0.1.0", path = "../../domains/test/service" } -frame-system = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +frame-system = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } futures = "0.3.29" -pallet-balances = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sc-cli = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1", default-features = false } -sc-executor = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1", default-features = false } -sc-service = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1", default-features = false } +pallet-balances = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sc-cli = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c", default-features = false } +sc-executor = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c", default-features = false } +sc-service = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c", default-features = false } subspace-test-client = { version = "0.1.0", path = "../../test/subspace-test-client" } subspace-test-service = { version = "0.1.0", path = "../../test/subspace-test-service" } subspace-runtime-primitives = { version = "0.1.0", path = "../../crates/subspace-runtime-primitives" } -substrate-test-runtime-client = { version = "2.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +substrate-test-runtime-client = { version = "2.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } tempfile = "3.8.0" tokio = "1.34.0" @@ -61,6 +62,7 @@ std = [ "domain-runtime-primitives/std", "frame-support/std", "hash-db/std", + "log/std", "scale-info/std", "domain-block-preprocessor", "sc-client-api", diff --git a/crates/sp-domains-fraud-proof/src/bundle_equivocation.rs b/crates/sp-domains-fraud-proof/src/bundle_equivocation.rs index 3d398de7c6..6639b174a1 100644 --- a/crates/sp-domains-fraud-proof/src/bundle_equivocation.rs +++ b/crates/sp-domains-fraud-proof/src/bundle_equivocation.rs @@ -95,6 +95,14 @@ where if operator_set_1 == operator_set_2 { // 2) with different hash return if bundle_header.hash() != previous_bundle_header.hash() { + log::warn!( + "Bundle equivocation occurred: Operator{}; Slot{}; DomainId{}; First Bundle{}; Second Bundle{}", + operator_set_1.0, + slot, + operator_set_1.1, + previous_bundle_header.hash(), + bundle_header.hash(), + ); Ok(Some(FraudProof::BundleEquivocation( BundleEquivocationProof { domain_id: bundle_header.header.proof_of_election.domain_id, diff --git a/crates/sp-domains-fraud-proof/src/verification.rs b/crates/sp-domains-fraud-proof/src/verification.rs index 01c5424c38..7ec0cc4d86 100644 --- a/crates/sp-domains-fraud-proof/src/verification.rs +++ b/crates/sp-domains-fraud-proof/src/verification.rs @@ -72,9 +72,13 @@ where .map(|resp| resp.into_domain_set_code_extrinsic()) .ok_or(VerificationError::FailedToDeriveDomainSetCodeExtrinsic)?; + let bad_receipt_valid_bundle_digests = bad_receipt.valid_bundle_digests(); + if valid_bundle_digests.len() != bad_receipt_valid_bundle_digests.len() { + return Err(VerificationError::InvalidBundleDigest); + } + let mut bundle_extrinsics_digests = Vec::new(); - for (bad_receipt_valid_bundle_digest, bundle_digest) in bad_receipt - .valid_bundle_digests() + for (bad_receipt_valid_bundle_digest, bundle_digest) in bad_receipt_valid_bundle_digests .into_iter() .zip(valid_bundle_digests) { @@ -521,9 +525,6 @@ where return Err(InvalidBundleEquivocationError::MismatchedOperatorAndDomain); } - // TODO: `consensus_block_hash` is an default/empty value because this field is skipped - // during encode/decode due to incompatible with Gemini-3g, thus the verificaion will fail. - // This should be fix on new network when the field is not skipped. let consensus_block_hash = header_1.header.proof_of_election.consensus_block_hash; let domain_id = header_1.header.proof_of_election.domain_id; let operator_id = header_1.header.proof_of_election.operator_id; diff --git a/crates/sp-domains/Cargo.toml b/crates/sp-domains/Cargo.toml index 3c04c347c1..c4096094de 100644 --- a/crates/sp-domains/Cargo.toml +++ b/crates/sp-domains/Cargo.toml @@ -14,7 +14,7 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] blake2 = { version = "0.10.6", default-features = false } domain-runtime-primitives = { version = "0.1.0", default-features = false, path = "../../domains/primitives/runtime" } -frame-support = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +frame-support = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } hash-db = { version = "0.16.0", default-features = false } memory-db = { version = "0.32.0", default-features = false } hexlit = "0.5.5" @@ -24,15 +24,15 @@ rand_chacha = { version = "0.3.1", default-features = false } rs_merkle = { version = "1.4.1", default-features = false } scale-info = { version = "2.7.0", default-features = false, features = ["derive"] } serde = { version = "1.0.183", default-features = false, features = ["alloc", "derive"] } -sp-api = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-application-crypto = { version = "23.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-core = { version = "21.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-runtime = { version = "24.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-runtime-interface = { version = "17.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-state-machine = { version = "0.28.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-std = { version = "8.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-trie = { version = "22.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-weights = { version = "20.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +sp-api = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-application-crypto = { version = "23.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-core = { version = "21.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-runtime = { version = "24.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-runtime-interface = { version = "17.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-state-machine = { version = "0.28.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-std = { version = "8.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-trie = { version = "22.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-weights = { version = "20.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } subspace-core-primitives = { version = "0.1.0", default-features = false, path = "../subspace-core-primitives" } subspace-runtime-primitives = { version = "0.1.0", default-features = false, path = "../subspace-runtime-primitives" } trie-db = { version = "0.28.0", default-features = false } diff --git a/crates/sp-domains/src/bundle_producer_election.rs b/crates/sp-domains/src/bundle_producer_election.rs index f1b94e6fa8..b70c68ea75 100644 --- a/crates/sp-domains/src/bundle_producer_election.rs +++ b/crates/sp-domains/src/bundle_producer_election.rs @@ -1,9 +1,8 @@ -use crate::{DomainId, OperatorId, OperatorPublicKey, ProofOfElection, StakeWeight}; +use crate::{DomainId, OperatorPublicKey, ProofOfElection, StakeWeight}; use parity_scale_codec::{Decode, Encode}; use scale_info::TypeInfo; use sp_core::crypto::{VrfPublic, Wraps}; use sp_core::sr25519::vrf::{VrfOutput, VrfSignature, VrfTranscript}; -use sp_std::vec::Vec; use subspace_core_primitives::Blake3Hash; const VRF_TRANSCRIPT_LABEL: &[u8] = b"bundle_producer_election"; @@ -54,10 +53,6 @@ pub fn is_below_threshold(vrf_output: &VrfOutput, threshold: u128) -> bool { #[derive(Debug, Decode, Encode, TypeInfo, PartialEq, Eq, Clone)] pub struct BundleProducerElectionParams { - // TODO: current operators is not required anymore. - // This is not removed right now in order to not break runtime api with new version - // marking a todo to remove it before next network. - pub current_operators: Vec, pub total_domain_stake: Balance, pub bundle_slot_probability: (u64, u64), } diff --git a/crates/sp-domains/src/lib.rs b/crates/sp-domains/src/lib.rs index f166cbdba9..340bb1ac90 100644 --- a/crates/sp-domains/src/lib.rs +++ b/crates/sp-domains/src/lib.rs @@ -544,9 +544,6 @@ pub struct ProofOfElection { /// Operator index in the OperatorRegistry. pub operator_id: OperatorId, /// Consensus block hash at which proof of election was derived. - // TODO: skipping encode/decode this field becasue it is mismatch with the struct - // on the Gemini-3g runtime, remove `#[codec(skip)]` before new network - #[codec(skip)] pub consensus_block_hash: CHash, } @@ -955,11 +952,9 @@ sp_api::decl_runtime_apis! { ) -> OpaqueBundles; /// Extract bundle from the extrinsic if the extrinsic is `submit_bundle`. - #[api_version(2)] fn extract_bundle(extrinsic: Block::Extrinsic) -> Option, Block::Hash, DomainHeader, Balance>>; /// Extract the execution receipt stored successfully from the given extrinsics. - #[api_version(2)] fn extract_receipts( domain_id: DomainId, extrinsics: Vec, diff --git a/crates/sp-lightclient/Cargo.toml b/crates/sp-lightclient/Cargo.toml index 89a82579c8..df75a8234e 100644 --- a/crates/sp-lightclient/Cargo.toml +++ b/crates/sp-lightclient/Cargo.toml @@ -19,20 +19,20 @@ include = [ codec = { package = "parity-scale-codec", version = "3.1.2", default-features = false } scale-info = { version = "2.7.0", default-features = false, features = ["derive"] } schnorrkel = { version = "0.9.1", default-features = false, features = ["u64_backend"] } -sp-arithmetic = { version = "16.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-consensus-slots = { version = "0.10.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +sp-arithmetic = { version = "16.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-consensus-slots = { version = "0.10.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } sp-consensus-subspace = { version = "0.1.0", path = "../sp-consensus-subspace", default-features = false } -sp-runtime = { version = "24.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-std = { version = "8.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +sp-runtime = { version = "24.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-std = { version = "8.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } subspace-core-primitives = { version = "0.1.0", path = "../subspace-core-primitives", default-features = false } subspace-erasure-coding = { version = "0.1.0", path = "../subspace-erasure-coding", default-features = false } subspace-verification = { version = "0.1.0", path = "../subspace-verification", default-features = false } [dev-dependencies] -frame-support = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +frame-support = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } futures = "0.3.29" rand = { version = "0.8.5", features = ["min_const_gen"] } -sp-io = { version = "23.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +sp-io = { version = "23.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } subspace-archiving = { version = "0.1.0", path = "../subspace-archiving"} subspace-core-primitives = { version = "0.1.0", path = "../subspace-core-primitives" } subspace-farmer-components = { version = "0.1.0", path = "../subspace-farmer-components" } diff --git a/crates/sp-objects/Cargo.toml b/crates/sp-objects/Cargo.toml index 0a6142db5c..eb155fb2f9 100644 --- a/crates/sp-objects/Cargo.toml +++ b/crates/sp-objects/Cargo.toml @@ -13,8 +13,8 @@ readme = "README.md" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -sp-api = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-std = { version = "8.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +sp-api = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-std = { version = "8.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } subspace-core-primitives = { version = "0.1.0", default-features = false, path = "../subspace-core-primitives" } subspace-runtime-primitives = { version = "0.1.0", default-features = false, path = "../subspace-runtime-primitives" } diff --git a/crates/subspace-farmer-components/src/plotting.rs b/crates/subspace-farmer-components/src/plotting.rs index 874158daf6..e5a646f2c6 100644 --- a/crates/subspace-farmer-components/src/plotting.rs +++ b/crates/subspace-farmer-components/src/plotting.rs @@ -514,7 +514,7 @@ where // happen at most as many times as there is number of chunks in the record, // otherwise `n+1` iterations could happen and update extra `encoded_chunk_used` // unnecessarily causing issues down the line - .take(record.iter().count()) + .take(record.len()) .zip(record.iter_mut()) // Write encoded chunk back so we can reuse original allocation .map(|(input_chunk, output_chunk)| { diff --git a/crates/subspace-farmer-components/src/sector.rs b/crates/subspace-farmer-components/src/sector.rs index 54c3d6c664..a133ea050f 100644 --- a/crates/subspace-farmer-components/src/sector.rs +++ b/crates/subspace-farmer-components/src/sector.rs @@ -503,8 +503,7 @@ impl SectorContentsMap { /// corresponds to the record to which chunk belongs and `encoded_chunk_used` indicates whether /// it was encoded. /// - /// ## Panics - /// Panics if `s_bucket` is outside of [`Record::NUM_S_BUCKETS`] range. + /// Returns error if `s_bucket` is outside of [`Record::NUM_S_BUCKETS`] range. pub fn iter_s_bucket_records( &self, s_bucket: SBucket, @@ -577,7 +576,7 @@ fn record_has_s_bucket_chunk( } else if num_encoded_record_chunks == Record::NUM_CHUNKS { None } else { - // Count how many encoded chunks we before current offset + // Count how many encoded chunks we have before current offset let encoded_before = record_bitfields[..s_bucket].count_ones(); let unencoded_before = s_bucket - encoded_before; // And how many unencoded we have total and how many before current offset diff --git a/crates/subspace-farmer/Cargo.toml b/crates/subspace-farmer/Cargo.toml index d1898b42d2..4be80afb56 100644 --- a/crates/subspace-farmer/Cargo.toml +++ b/crates/subspace-farmer/Cargo.toml @@ -24,7 +24,7 @@ clap = { version = "4.4.3", features = ["color", "derive"] } criterion = { version = "0.5.1", default-features = false, features = ["rayon", "async"] } derive_more = "0.99.17" event-listener-primitives = "2.0.1" -fdlimit = "0.2" +fdlimit = "0.3.0" futures = "0.3.29" hex = { version = "0.4.3", features = ["serde"] } jsonrpsee = { version = "0.16.3", features = ["client"] } diff --git a/crates/subspace-farmer/src/bin/subspace-farmer/commands/farm.rs b/crates/subspace-farmer/src/bin/subspace-farmer/commands/farm.rs index df4b2bd98e..08dab6b1c8 100644 --- a/crates/subspace-farmer/src/bin/subspace-farmer/commands/farm.rs +++ b/crates/subspace-farmer/src/bin/subspace-farmer/commands/farm.rs @@ -15,6 +15,7 @@ use std::fs; use std::net::SocketAddr; use std::num::{NonZeroU8, NonZeroUsize}; use std::path::PathBuf; +use std::pin::pin; use std::str::FromStr; use std::sync::Arc; use subspace_core_primitives::crypto::kzg::{embedded_kzg_settings, Kzg}; @@ -335,13 +336,12 @@ where .await .map_err(|error| anyhow::anyhow!(error))?; - let first_farm_directory = disk_farms + let first_farm_directory = &disk_farms .first() .expect("Disk farm collection is not be empty as checked above; qed") - .directory - .clone(); + .directory; - let identity = Identity::open_or_create(&first_farm_directory) + let identity = Identity::open_or_create(first_farm_directory) .map_err(|error| anyhow!("Failed to open or create identity: {error}"))?; let keypair = derive_libp2p_keypair(identity.secret_key()); let peer_id = keypair.public().to_peer_id(); @@ -407,7 +407,11 @@ where )); let _piece_cache_worker = run_future_in_dedicated_thread( - Box::pin(piece_cache_worker.run(piece_getter.clone())), + { + let future = piece_cache_worker.run(piece_getter.clone()); + + move || future + }, "cache-worker".to_string(), ); @@ -599,36 +603,34 @@ where // event handlers drop(readers_and_pieces); - let farm_fut = run_future_in_dedicated_thread( - Box::pin(async move { + let farm_fut = pin!(run_future_in_dedicated_thread( + move || async move { while let Some(result) = single_disk_farms_stream.next().await { let id = result?; info!(%id, "Farm exited successfully"); } anyhow::Ok(()) - }), + }, "farmer-farm".to_string(), - )?; - let mut farm_fut = Box::pin(farm_fut).fuse(); + )?); - let networking_fut = run_future_in_dedicated_thread( - Box::pin(async move { node_runner.run().await }), + let networking_fut = pin!(run_future_in_dedicated_thread( + move || async move { node_runner.run().await }, "farmer-networking".to_string(), - )?; - let mut networking_fut = Box::pin(networking_fut).fuse(); + )?); futures::select!( // Signal future _ = signal.fuse() => {}, // Farm future - result = farm_fut => { + result = farm_fut.fuse() => { result??; }, // Node runner future - _ = networking_fut => { + _ = networking_fut.fuse() => { info!("Node runner exited.") }, ); diff --git a/crates/subspace-farmer/src/bin/subspace-farmer/commands/farm/dsn.rs b/crates/subspace-farmer/src/bin/subspace-farmer/commands/farm/dsn.rs index 987b9f6a44..a5042b2cf1 100644 --- a/crates/subspace-farmer/src/bin/subspace-farmer/commands/farm/dsn.rs +++ b/crates/subspace-farmer/src/bin/subspace-farmer/commands/farm/dsn.rs @@ -2,8 +2,9 @@ use crate::commands::farm::DsnArgs; use parking_lot::Mutex; use prometheus_client::registry::Registry; use std::collections::HashSet; -use std::path::PathBuf; +use std::path::Path; use std::sync::{Arc, Weak}; +use subspace_farmer::node_client::NodeClientExt; use subspace_farmer::piece_cache::PieceCache; use subspace_farmer::utils::readers_and_pieces::ReadersAndPieces; use subspace_farmer::{NodeClient, NodeRpcClient, KNOWN_PEERS_CACHE_SIZE}; @@ -32,7 +33,7 @@ const TARGET_CONNECTIONS: u32 = 15; #[allow(clippy::type_complexity, clippy::too_many_arguments)] pub(super) fn configure_dsn( protocol_prefix: String, - base_path: PathBuf, + base_path: &Path, keypair: Keypair, DsnArgs { listen_on, diff --git a/crates/subspace-farmer/src/bin/subspace-farmer/utils.rs b/crates/subspace-farmer/src/bin/subspace-farmer/utils.rs index fba8f5ae2f..709deff5a5 100644 --- a/crates/subspace-farmer/src/bin/subspace-farmer/utils.rs +++ b/crates/subspace-farmer/src/bin/subspace-farmer/utils.rs @@ -1,20 +1,23 @@ use tokio::signal; pub(crate) fn raise_fd_limit() { - match std::panic::catch_unwind(fdlimit::raise_fd_limit) { - Ok(Some(limit)) => { - tracing::debug!("Increase file limit from soft to hard (limit is {limit})") + match fdlimit::raise_fd_limit() { + Ok(fdlimit::Outcome::LimitRaised { from, to }) => { + tracing::debug!( + "Increased file descriptor limit from previous (most likely soft) limit {} to \ + new (most likely hard) limit {}", + from, + to + ); } - Ok(None) => tracing::debug!("Failed to increase file limit"), - Err(err) => { - let err = if let Some(err) = err.downcast_ref::<&str>() { - *err - } else if let Some(err) = err.downcast_ref::() { - err - } else { - unreachable!("Should be unreachable as `fdlimit` uses panic macro, which should return either `&str` or `String`.") - }; - tracing::warn!("Failed to increase file limit: {err}") + Ok(fdlimit::Outcome::Unsupported) => { + // Unsupported platform (non-Linux) + } + Err(error) => { + tracing::warn!( + "Failed to increase file descriptor limit for the process due to an error: {}.", + error + ); } } } @@ -22,24 +25,21 @@ pub(crate) fn raise_fd_limit() { #[cfg(unix)] pub(crate) async fn shutdown_signal() { use futures::FutureExt; + use std::pin::pin; futures::future::select( - Box::pin( - signal::unix::signal(signal::unix::SignalKind::interrupt()) - .expect("Setting signal handlers must never fail") - .recv() - .map(|_| { - tracing::info!("Received SIGINT, shutting down farmer..."); - }), - ), - Box::pin( - signal::unix::signal(signal::unix::SignalKind::terminate()) - .expect("Setting signal handlers must never fail") - .recv() - .map(|_| { - tracing::info!("Received SIGTERM, shutting down farmer..."); - }), - ), + pin!(signal::unix::signal(signal::unix::SignalKind::interrupt()) + .expect("Setting signal handlers must never fail") + .recv() + .map(|_| { + tracing::info!("Received SIGINT, shutting down farmer..."); + }),), + pin!(signal::unix::signal(signal::unix::SignalKind::terminate()) + .expect("Setting signal handlers must never fail") + .recv() + .map(|_| { + tracing::info!("Received SIGTERM, shutting down farmer..."); + }),), ) .await; } diff --git a/crates/subspace-farmer/src/lib.rs b/crates/subspace-farmer/src/lib.rs index 8c5443b1c9..691ad98c60 100644 --- a/crates/subspace-farmer/src/lib.rs +++ b/crates/subspace-farmer/src/lib.rs @@ -1,5 +1,6 @@ #![feature( array_chunks, + assert_matches, const_option, hash_extract_if, impl_trait_in_assoc_type, diff --git a/crates/subspace-farmer/src/node_client.rs b/crates/subspace-farmer/src/node_client.rs index e0edca467b..4559e37765 100644 --- a/crates/subspace-farmer/src/node_client.rs +++ b/crates/subspace-farmer/src/node_client.rs @@ -2,6 +2,7 @@ pub(crate) mod node_rpc_client; use async_trait::async_trait; use futures::Stream; +use std::fmt; use std::pin::Pin; use subspace_core_primitives::{Piece, PieceIndex, SegmentHeader, SegmentIndex}; use subspace_rpc_primitives::{ @@ -14,7 +15,7 @@ pub type Error = Box; /// Abstraction of the Node Client #[async_trait] -pub trait NodeClient: Clone + Send + Sync + 'static { +pub trait NodeClient: Clone + fmt::Debug + Send + Sync + 'static { /// Get farmer app info async fn farmer_app_info(&self) -> Result; @@ -64,7 +65,11 @@ pub trait NodeClient: Clone + Send + Sync + 'static { &self, segment_index: SegmentIndex, ) -> Result<(), Error>; +} +/// Node Client extension methods that are not necessary for farmer as a library, but might be useful for an app +#[async_trait] +pub trait NodeClientExt: NodeClient { /// Get the last segment headers. async fn last_segment_headers(&self, limit: u64) -> Result>, Error>; } diff --git a/crates/subspace-farmer/src/node_client/node_rpc_client.rs b/crates/subspace-farmer/src/node_client/node_rpc_client.rs index 4b7a33ce97..b49853192a 100644 --- a/crates/subspace-farmer/src/node_client/node_rpc_client.rs +++ b/crates/subspace-farmer/src/node_client/node_rpc_client.rs @@ -1,4 +1,4 @@ -use crate::node_client::{Error as RpcError, Error, NodeClient}; +use crate::node_client::{Error as RpcError, Error, NodeClient, NodeClientExt}; use async_trait::async_trait; use futures::{Stream, StreamExt}; use jsonrpsee::core::client::{ClientT, SubscriptionClientT}; @@ -188,7 +188,10 @@ impl NodeClient for NodeRpcClient { ) .await?) } +} +#[async_trait] +impl NodeClientExt for NodeRpcClient { async fn last_segment_headers( &self, limit: u64, diff --git a/crates/subspace-farmer/src/piece_cache.rs b/crates/subspace-farmer/src/piece_cache.rs index dd3f938937..d354294e3b 100644 --- a/crates/subspace-farmer/src/piece_cache.rs +++ b/crates/subspace-farmer/src/piece_cache.rs @@ -1,3 +1,6 @@ +#[cfg(test)] +mod tests; + use crate::node_client::NodeClient; use crate::single_disk_farm::piece_cache::{DiskPieceCache, Offset}; use crate::utils::AsyncJoinOnDrop; @@ -8,10 +11,10 @@ use futures::{select, FutureExt, StreamExt}; use parking_lot::RwLock; use rayon::prelude::*; use std::collections::HashMap; -use std::mem; use std::num::NonZeroU16; use std::sync::Arc; -use subspace_core_primitives::{Piece, PieceIndex, SegmentIndex}; +use std::{fmt, mem}; +use subspace_core_primitives::{Piece, PieceIndex, SegmentHeader, SegmentIndex}; use subspace_farmer_components::plotting::{PieceGetter, PieceGetterRetryPolicy}; use subspace_networking::libp2p::kad::{ProviderRecord, RecordKey}; use subspace_networking::libp2p::PeerId; @@ -61,8 +64,12 @@ struct CacheWorkerState { } /// Cache worker used to drive the cache +#[derive(Debug)] #[must_use = "Cache will not work unless its worker is running"] -pub struct CacheWorker { +pub struct CacheWorker +where + NC: fmt::Debug, +{ peer_id: PeerId, node_client: NC, caches: Arc>>, @@ -104,6 +111,21 @@ where return; } + let mut segment_headers_notifications = + match self.node_client.subscribe_archived_segment_headers().await { + Ok(segment_headers_notifications) => segment_headers_notifications, + Err(error) => { + error!(%error, "Failed to subscribe to archived segments notifications"); + return; + } + }; + + // Keep up with segment indices that were potentially created since reinitialization, + // depending on the size of the diff this may pause block production for a while (due to + // subscription we have created above) + self.keep_up_after_initial_sync(&piece_getter, &mut worker_state) + .await; + loop { select! { maybe_command = worker_receiver.recv().fuse() => { @@ -114,10 +136,14 @@ where self.handle_command(command, &piece_getter, &mut worker_state).await; } - _ = self.keep_up_sync(&piece_getter, &mut worker_state).fuse() => { - // Keep-up sync only ends with subscription, which lasts for duration of an - // instance - return; + maybe_segment_header = segment_headers_notifications.next().fuse() => { + if let Some(segment_header) = maybe_segment_header { + self.process_segment_header(segment_header, &mut worker_state).await; + } else { + // Keep-up sync only ends with subscription, which lasts for duration of an + // instance + return; + } } } } @@ -154,10 +180,10 @@ where // Making offset as unoccupied and remove corresponding key from heap cache.free_offsets.push(offset); match cache.backend.read_piece_index(offset) { - Some(piece_index) => { + Ok(Some(piece_index)) => { worker_state.heap.remove(KeyWrapper(piece_index)); } - None => { + Ok(None) => { warn!( %disk_farm_index, %offset, @@ -165,6 +191,15 @@ where not freeing heap element" ); } + Err(error) => { + error!( + %error, + %disk_farm_index, + ?key, + %offset, + "Error while reading piece from cache, might be a disk corruption" + ); + } } return; } @@ -372,14 +407,13 @@ where } downloaded_pieces_count += 1; + let progress = downloaded_pieces_count as f32 / pieces_to_download_total as f32 * 100.0; if downloaded_pieces_count % INTERMEDIATE_CACHE_UPDATE_INTERVAL == 0 { - let progress = - downloaded_pieces_count as f32 / pieces_to_download_total as f32 * 100.0; *self.caches.write() = caches.clone(); info!("Piece cache sync {progress:.2}% complete"); - self.handlers.progress.call_simple(&progress); } + self.handlers.progress.call_simple(&progress); } *self.caches.write() = caches; @@ -389,33 +423,15 @@ where info!("Finished piece cache synchronization"); } - async fn keep_up_sync(&self, piece_getter: &PG, worker_state: &mut CacheWorkerState) - where - PG: PieceGetter, - { - let mut segment_headers_notifications = - match self.node_client.subscribe_archived_segment_headers().await { - Ok(segment_headers_notifications) => segment_headers_notifications, - Err(error) => { - error!(%error, "Failed to subscribe to archived segments notifications"); - return; - } - }; - - // Keep up with segment indices that were potentially created since reinitialization, - // depending on the size of the diff this may pause block production for a while (due to - // subscription we have created above) - self.keep_up_after_initial_sync(piece_getter, worker_state) - .await; - - while let Some(segment_header) = segment_headers_notifications.next().await { - let segment_index = segment_header.segment_index(); - debug!(%segment_index, "Starting to process newly archived segment"); - - if worker_state.last_segment_index >= segment_index { - continue; - } + async fn process_segment_header( + &self, + segment_header: SegmentHeader, + worker_state: &mut CacheWorkerState, + ) { + let segment_index = segment_header.segment_index(); + debug!(%segment_index, "Starting to process newly archived segment"); + if worker_state.last_segment_index < segment_index { // TODO: Can probably do concurrency here for piece_index in segment_index.segment_piece_indexes() { if !worker_state @@ -457,22 +473,22 @@ where } worker_state.last_segment_index = segment_index; + } - match self - .node_client - .acknowledge_archived_segment_header(segment_index) - .await - { - Ok(()) => { - debug!(%segment_index, "Acknowledged archived segment"); - } - Err(error) => { - error!(%segment_index, ?error, "Failed to acknowledge archived segment"); - } - }; + match self + .node_client + .acknowledge_archived_segment_header(segment_index) + .await + { + Ok(()) => { + debug!(%segment_index, "Acknowledged archived segment"); + } + Err(error) => { + error!(%segment_index, ?error, "Failed to acknowledge archived segment"); + } + }; - debug!(%segment_index, "Finished processing newly archived segment"); - } + debug!(%segment_index, "Finished processing newly archived segment"); } async fn keep_up_after_initial_sync( @@ -511,12 +527,12 @@ where for piece_index in piece_indices { let key = KeyWrapper(piece_index); if !worker_state.heap.should_include_key(key) { - trace!(%piece_index, "Piece doesn't need to be cached #1"); + trace!(%piece_index, "Piece doesn't need to be cached #2"); continue; } - trace!(%piece_index, "Piece needs to be cached #1"); + trace!(%piece_index, "Piece needs to be cached #2"); let result = piece_getter .get_piece( diff --git a/crates/subspace-farmer/src/piece_cache/tests.rs b/crates/subspace-farmer/src/piece_cache/tests.rs new file mode 100644 index 0000000000..380dcde6c0 --- /dev/null +++ b/crates/subspace-farmer/src/piece_cache/tests.rs @@ -0,0 +1,406 @@ +use crate::node_client::Error; +use crate::piece_cache::PieceCache; +use crate::single_disk_farm::piece_cache::DiskPieceCache; +use crate::NodeClient; +use futures::channel::{mpsc, oneshot}; +use futures::{SinkExt, Stream, StreamExt}; +use parking_lot::Mutex; +use rand::prelude::*; +use std::collections::HashMap; +use std::num::NonZeroU64; +use std::pin::Pin; +use std::sync::atomic::{AtomicU64, Ordering}; +use std::sync::Arc; +use std::time::Duration; +use subspace_core_primitives::{ + HistorySize, LastArchivedBlock, Piece, PieceIndex, SegmentHeader, SegmentIndex, +}; +use subspace_farmer_components::plotting::{PieceGetter, PieceGetterRetryPolicy}; +use subspace_farmer_components::FarmerProtocolInfo; +use subspace_networking::libp2p::identity; +use subspace_networking::libp2p::kad::RecordKey; +use subspace_networking::utils::multihash::ToMultihash; +use subspace_rpc_primitives::{ + FarmerAppInfo, NodeSyncStatus, RewardSignatureResponse, RewardSigningInfo, SlotInfo, + SolutionResponse, +}; +use tempfile::tempdir; + +#[derive(Debug, Clone)] +struct MockNodeClient { + current_segment_index: Arc, + pieces: Arc>>, + archived_segment_headers_stream_request_sender: + mpsc::Sender>>, + acknowledge_archived_segment_header_sender: mpsc::Sender, +} + +#[async_trait::async_trait] +impl NodeClient for MockNodeClient { + async fn farmer_app_info(&self) -> Result { + // Most of these values make no sense, but they are not used by piece cache anyway + Ok(FarmerAppInfo { + genesis_hash: [0; 32], + dsn_bootstrap_nodes: Vec::new(), + farming_timeout: Duration::default(), + protocol_info: FarmerProtocolInfo { + history_size: HistorySize::from(SegmentIndex::from( + self.current_segment_index.load(Ordering::Acquire), + )), + max_pieces_in_sector: 0, + recent_segments: HistorySize::from(SegmentIndex::ZERO), + recent_history_fraction: ( + HistorySize::from(NonZeroU64::new(1).unwrap()), + HistorySize::from(NonZeroU64::new(10).unwrap()), + ), + min_sector_lifetime: HistorySize::from(NonZeroU64::new(4).unwrap()), + }, + }) + } + + async fn subscribe_slot_info( + &self, + ) -> Result + Send + 'static>>, Error> { + unimplemented!() + } + + async fn submit_solution_response( + &self, + _solution_response: SolutionResponse, + ) -> Result<(), Error> { + unimplemented!() + } + + async fn subscribe_reward_signing( + &self, + ) -> Result + Send + 'static>>, Error> { + unimplemented!() + } + + async fn submit_reward_signature( + &self, + _reward_signature: RewardSignatureResponse, + ) -> Result<(), Error> { + unimplemented!() + } + + async fn subscribe_archived_segment_headers( + &self, + ) -> Result + Send + 'static>>, Error> { + let (tx, rx) = oneshot::channel(); + self.archived_segment_headers_stream_request_sender + .clone() + .send(tx) + .await + .unwrap(); + // Allow to delay segment headers subscription in tests + let stream = rx.await.unwrap(); + Ok(Box::pin(stream)) + } + + async fn subscribe_node_sync_status_change( + &self, + ) -> Result + Send + 'static>>, Error> { + unimplemented!() + } + + async fn segment_headers( + &self, + _segment_indexes: Vec, + ) -> Result>, Error> { + unimplemented!() + } + + async fn piece(&self, piece_index: PieceIndex) -> Result, Error> { + Ok(Some( + self.pieces + .lock() + .entry(piece_index) + .or_insert_with(|| { + let mut piece = Piece::default(); + thread_rng().fill(piece.as_mut()); + piece + }) + .clone(), + )) + } + + async fn acknowledge_archived_segment_header( + &self, + segment_index: SegmentIndex, + ) -> Result<(), Error> { + self.acknowledge_archived_segment_header_sender + .clone() + .send(segment_index) + .await + .unwrap(); + Ok(()) + } +} + +#[derive(Debug, Clone)] +struct MockPieceGetter { + pieces: Arc>>, +} + +#[async_trait::async_trait] +impl PieceGetter for MockPieceGetter { + async fn get_piece( + &self, + piece_index: PieceIndex, + _retry_policy: PieceGetterRetryPolicy, + ) -> Result, Box> { + Ok(Some( + self.pieces + .lock() + .entry(piece_index) + .or_insert_with(|| { + let mut piece = Piece::default(); + thread_rng().fill(piece.as_mut()); + piece + }) + .clone(), + )) + } +} + +#[tokio::test] +async fn basic() { + let current_segment_index = Arc::new(AtomicU64::new(0)); + let pieces = Arc::default(); + let ( + archived_segment_headers_stream_request_sender, + mut archived_segment_headers_stream_request_receiver, + ) = mpsc::channel(0); + let ( + acknowledge_archived_segment_header_sender, + mut acknowledge_archived_segment_header_receiver, + ) = mpsc::channel(0); + + let node_client = MockNodeClient { + current_segment_index: Arc::clone(¤t_segment_index), + pieces: Arc::clone(&pieces), + archived_segment_headers_stream_request_sender, + acknowledge_archived_segment_header_sender, + }; + let piece_getter = MockPieceGetter { + pieces: Arc::clone(&pieces), + }; + let public_key = + identity::PublicKey::from(identity::ed25519::PublicKey::try_from_bytes(&[42; 32]).unwrap()); + let path1 = tempdir().unwrap(); + let path2 = tempdir().unwrap(); + + { + let (piece_cache, piece_cache_worker) = + PieceCache::new(node_client.clone(), public_key.to_peer_id()); + + let piece_cache_worker_exited = tokio::spawn(piece_cache_worker.run(piece_getter.clone())); + + let initialized_fut = piece_cache + .replace_backing_caches(vec![ + DiskPieceCache::open(path1.as_ref(), 1).unwrap(), + DiskPieceCache::open(path2.as_ref(), 1).unwrap(), + ]) + .await; + + // Wait for piece cache to be initialized + initialized_fut.await.unwrap(); + + // These 2 pieces are requested from node during initialization + { + let mut requested_pieces = pieces.lock().keys().copied().collect::>(); + requested_pieces.sort(); + let expected_pieces = vec![PieceIndex::from(26), PieceIndex::from(196)]; + assert_eq!(requested_pieces, expected_pieces); + + for piece_index in requested_pieces { + piece_cache + .get_piece(RecordKey::from(piece_index.to_multihash())) + .await + .unwrap(); + } + + // Other piece indices are not requested or cached + assert!(piece_cache + .get_piece(RecordKey::from(PieceIndex::from(10).to_multihash())) + .await + .is_none()); + } + + // Update current segment header such that we keep-up after initial sync is triggered + current_segment_index.store(1, Ordering::Release); + + // Send segment headers receiver such that keep-up sync can start not + let (mut archived_segment_headers_sender, archived_segment_headers_receiver) = + mpsc::channel(0); + archived_segment_headers_stream_request_receiver + .next() + .await + .unwrap() + .send(archived_segment_headers_receiver) + .unwrap(); + + // Send segment header with the same segment index as "current", so it will have no + // side-effects, but acknowledgement will indicate that keep-up after initial sync has finished + { + let segment_header = SegmentHeader::V0 { + segment_index: SegmentIndex::ONE, + segment_commitment: Default::default(), + prev_segment_header_hash: [0; 32], + last_archived_block: LastArchivedBlock { + number: 0, + archived_progress: Default::default(), + }, + }; + + archived_segment_headers_sender + .send(segment_header) + .await + .unwrap(); + + // Wait for acknowledgement + assert_eq!( + acknowledge_archived_segment_header_receiver + .next() + .await + .unwrap(), + SegmentIndex::ONE + ); + } + + // One more piece was requested during keep-up after initial sync + { + let mut requested_pieces = pieces.lock().keys().copied().collect::>(); + requested_pieces.sort(); + let expected_pieces = vec![ + PieceIndex::from(26), + PieceIndex::from(196), + PieceIndex::from(276), + ]; + assert_eq!(requested_pieces, expected_pieces); + + let stored_pieces = vec![PieceIndex::from(196), PieceIndex::from(276)]; + for piece_index in &stored_pieces { + piece_cache + .get_piece(RecordKey::from(piece_index.to_multihash())) + .await + .unwrap(); + } + + for piece_index in requested_pieces { + if !stored_pieces.contains(&piece_index) { + // Other piece indices are not stored anymore + assert!(piece_cache + .get_piece(RecordKey::from(PieceIndex::from(10).to_multihash())) + .await + .is_none()); + } + } + } + + // Send two more segment headers (one is not enough because for above peer ID there are no pieces for it to + // store) + for segment_index in [2, 3] { + let segment_header = SegmentHeader::V0 { + segment_index: SegmentIndex::from(segment_index), + segment_commitment: Default::default(), + prev_segment_header_hash: [0; 32], + last_archived_block: LastArchivedBlock { + number: 0, + archived_progress: Default::default(), + }, + }; + + archived_segment_headers_sender + .send(segment_header) + .await + .unwrap(); + + // Wait for acknowledgement + assert_eq!( + acknowledge_archived_segment_header_receiver + .next() + .await + .unwrap(), + SegmentIndex::from(segment_index) + ); + + current_segment_index.store(segment_index, Ordering::Release); + } + + // One more piece was requested during keep-up after initial sync + { + let mut requested_pieces = pieces.lock().keys().copied().collect::>(); + requested_pieces.sort(); + let expected_pieces = vec![ + PieceIndex::from(26), + PieceIndex::from(196), + PieceIndex::from(276), + PieceIndex::from(823), + PieceIndex::from(859), + ]; + assert_eq!(requested_pieces, expected_pieces); + + let stored_pieces = vec![PieceIndex::from(823), PieceIndex::from(859)]; + for piece_index in &stored_pieces { + piece_cache + .get_piece(RecordKey::from(piece_index.to_multihash())) + .await + .unwrap(); + } + + for piece_index in requested_pieces { + if !stored_pieces.contains(&piece_index) { + // Other piece indices are not stored anymore + assert!(piece_cache + .get_piece(RecordKey::from(PieceIndex::from(10).to_multihash())) + .await + .is_none()); + } + } + } + + drop(piece_cache); + + piece_cache_worker_exited.await.unwrap(); + } + + { + // Clear requested pieces + pieces.lock().clear(); + + let (piece_cache, piece_cache_worker) = + PieceCache::new(node_client.clone(), public_key.to_peer_id()); + + let piece_cache_worker_exited = tokio::spawn(piece_cache_worker.run(piece_getter)); + + // Reopen with the same backing caches + let initialized_fut = piece_cache + .replace_backing_caches(vec![ + DiskPieceCache::open(path1.as_ref(), 1).unwrap(), + DiskPieceCache::open(path2.as_ref(), 1).unwrap(), + ]) + .await; + drop(piece_cache); + + // Wait for piece cache to be initialized + initialized_fut.await.unwrap(); + + // Same state as before, no pieces should be requested during initialization + assert_eq!(pieces.lock().len(), 0); + + let (mut archived_segment_headers_sender, archived_segment_headers_receiver) = + mpsc::channel(0); + archived_segment_headers_stream_request_receiver + .next() + .await + .unwrap() + .send(archived_segment_headers_receiver) + .unwrap(); + // Make worker exit + archived_segment_headers_sender.close().await.unwrap(); + + piece_cache_worker_exited.await.unwrap(); + } +} diff --git a/crates/subspace-farmer/src/single_disk_farm.rs b/crates/subspace-farmer/src/single_disk_farm.rs index 0c3b56a879..a43630cfe0 100644 --- a/crates/subspace-farmer/src/single_disk_farm.rs +++ b/crates/subspace-farmer/src/single_disk_farm.rs @@ -930,44 +930,46 @@ impl SingleDiskFarm { } }; - let plotting_fut = async move { + let plotting_options = PlottingOptions { + public_key, + node_client: &node_client, + pieces_in_sector, + sector_size, + sector_metadata_size, + metadata_header, + plot_file, + metadata_file, + sectors_metadata, + piece_getter: &piece_getter, + kzg: &kzg, + erasure_coding: &erasure_coding, + handlers, + modifying_sector_index, + sectors_to_plot_receiver, + downloading_semaphore, + encoding_semaphore: &encoding_semaphore, + plotting_thread_pool, + replotting_thread_pool, + stop_receiver: &mut stop_receiver.resubscribe(), + }; + + let plotting_fut = async { if start_receiver.recv().await.is_err() { // Dropped before starting - return; + return Ok(()); } if let Some(plotting_delay) = plotting_delay { if plotting_delay.await.is_err() { // Dropped before resolving - return; + return Ok(()); } } - let plotting_options = PlottingOptions { - public_key, - node_client: &node_client, - pieces_in_sector, - sector_size, - sector_metadata_size, - metadata_header, - plot_file, - metadata_file, - sectors_metadata, - piece_getter: &piece_getter, - kzg: &kzg, - erasure_coding: &erasure_coding, - handlers, - modifying_sector_index, - sectors_to_plot_receiver, - downloading_semaphore, - encoding_semaphore: &encoding_semaphore, - plotting_thread_pool, - replotting_thread_pool, - stop_receiver: &mut stop_receiver.resubscribe(), - }; - - let plotting_fut = plotting::<_, _, PosTable>(plotting_options); + plotting::<_, _, PosTable>(plotting_options).await + }; + Handle::current().block_on(async { select! { plotting_result = plotting_fut.fuse() => { if let Err(error) = plotting_result @@ -984,9 +986,7 @@ impl SingleDiskFarm { // Nothing, just exit } } - }; - - Handle::current().block_on(plotting_fut); + }); } }); let plotting_join_handle = AsyncJoinOnDrop::new(plotting_join_handle, false); diff --git a/crates/subspace-farmer/src/single_disk_farm/piece_cache.rs b/crates/subspace-farmer/src/single_disk_farm/piece_cache.rs index 9d14f70da8..91d40e68e1 100644 --- a/crates/subspace-farmer/src/single_disk_farm/piece_cache.rs +++ b/crates/subspace-farmer/src/single_disk_farm/piece_cache.rs @@ -1,3 +1,6 @@ +#[cfg(test)] +mod tests; + use derive_more::Display; use std::fs::{File, OpenOptions}; use std::path::Path; @@ -54,7 +57,20 @@ pub struct DiskPieceCache { impl DiskPieceCache { pub(super) const FILE_NAME: &'static str = "piece_cache.bin"; + #[cfg(not(test))] pub(super) fn open(directory: &Path, capacity: usize) -> Result { + Self::open_internal(directory, capacity) + } + + #[cfg(test)] + pub(crate) fn open(directory: &Path, capacity: usize) -> Result { + Self::open_internal(directory, capacity) + } + + pub(super) fn open_internal( + directory: &Path, + capacity: usize, + ) -> Result { if capacity == 0 { return Err(DiskPieceCacheError::ZeroCapacity); } @@ -99,28 +115,13 @@ impl DiskPieceCache { let mut element = vec![0; Self::element_size()]; (0..self.inner.num_elements).map(move |offset| { - if let Err(error) = - file.read_exact_at(&mut element, (offset * Self::element_size()) as u64) - { - warn!(%error, %offset, "Failed to read cache element #1"); - return (Offset(offset), None); + match Self::read_piece_internal(file, offset, &mut element) { + Ok(maybe_piece_index) => (Offset(offset), maybe_piece_index), + Err(error) => { + warn!(%error, %offset, "Failed to read cache element"); + (Offset(offset), None) + } } - - let (piece_index_bytes, piece_bytes) = element.split_at(PieceIndex::SIZE); - let piece_index = PieceIndex::from_bytes( - piece_index_bytes - .try_into() - .expect("Statically known to have correct size; qed"), - ); - // Piece index zero might mean we have piece index zero or just an empty space - let piece_index = - if piece_index != PieceIndex::ZERO || piece_bytes.iter().any(|&byte| byte != 0) { - Some(piece_index) - } else { - None - }; - - (Offset(offset), piece_index) }) } @@ -165,24 +166,20 @@ impl DiskPieceCache { /// /// NOTE: it is possible to do concurrent reads and writes, higher level logic must ensure this /// doesn't happen for the same piece being accessed! - pub(crate) fn read_piece_index(&self, offset: Offset) -> Option { + pub(crate) fn read_piece_index( + &self, + offset: Offset, + ) -> Result, DiskPieceCacheError> { let Offset(offset) = offset; if offset >= self.inner.num_elements { warn!(%offset, "Trying to read piece out of range, this must be an implementation bug"); - return None; - } - - let mut piece_index_bytes = [0; PieceIndex::SIZE]; - - if let Err(error) = self.inner.file.read_exact_at( - &mut piece_index_bytes, - (offset * Self::element_size()) as u64, - ) { - warn!(%error, %offset, "Failed to read cache piece index"); - return None; + return Err(DiskPieceCacheError::OffsetOutsideOfRange { + provided: offset, + max: self.inner.num_elements - 1, + }); } - Some(PieceIndex::from_bytes(piece_index_bytes)) + Self::read_piece_internal(&self.inner.file, offset, &mut vec![0; Self::element_size()]) } /// Read piece from cache at specified offset. @@ -195,22 +192,39 @@ impl DiskPieceCache { let Offset(offset) = offset; if offset >= self.inner.num_elements { warn!(%offset, "Trying to read piece out of range, this must be an implementation bug"); - return Ok(None); + return Err(DiskPieceCacheError::OffsetOutsideOfRange { + provided: offset, + max: self.inner.num_elements - 1, + }); } let mut element = vec![0; Self::element_size()]; - self.inner - .file - .read_exact_at(&mut element, (offset * Self::element_size()) as u64)?; + if Self::read_piece_internal(&self.inner.file, offset, &mut element)?.is_some() { + let mut piece = Piece::default(); + piece.copy_from_slice(&element[PieceIndex::SIZE..][..Piece::SIZE]); + Ok(Some(piece)) + } else { + Ok(None) + } + } + + fn read_piece_internal( + file: &File, + offset: usize, + element: &mut [u8], + ) -> Result, DiskPieceCacheError> { + file.read_exact_at(element, (offset * Self::element_size()) as u64)?; let (piece_index_bytes, remaining_bytes) = element.split_at(PieceIndex::SIZE); let (piece_bytes, expected_checksum) = remaining_bytes.split_at(Piece::SIZE); - let mut piece = Piece::default(); - piece.copy_from_slice(piece_bytes); // Verify checksum - let actual_checksum = blake3_hash_list(&[piece_index_bytes, piece.as_ref()]); + let actual_checksum = blake3_hash_list(&[piece_index_bytes, piece_bytes]); if actual_checksum != expected_checksum { + if element.iter().all(|&byte| byte == 0) { + return Ok(None); + } + debug!( actual_checksum = %hex::encode(actual_checksum), expected_checksum = %hex::encode(expected_checksum), @@ -220,7 +234,12 @@ impl DiskPieceCache { return Err(DiskPieceCacheError::ChecksumMismatch); } - Ok(Some(piece)) + let piece_index = PieceIndex::from_bytes( + piece_index_bytes + .try_into() + .expect("Statically known to have correct size; qed"), + ); + Ok(Some(piece_index)) } pub(crate) fn wipe(directory: &Path) -> io::Result<()> { diff --git a/crates/subspace-farmer/src/single_disk_farm/piece_cache/tests.rs b/crates/subspace-farmer/src/single_disk_farm/piece_cache/tests.rs new file mode 100644 index 0000000000..2c63e438b9 --- /dev/null +++ b/crates/subspace-farmer/src/single_disk_farm/piece_cache/tests.rs @@ -0,0 +1,144 @@ +use crate::single_disk_farm::piece_cache::{DiskPieceCache, Offset}; +use crate::single_disk_farm::DiskPieceCacheError; +use rand::prelude::*; +use std::assert_matches::assert_matches; +use subspace_core_primitives::{Piece, PieceIndex}; +use tempfile::tempdir; + +#[test] +fn basic() { + let path = tempdir().unwrap(); + { + let disk_piece_cache = DiskPieceCache::open(path.as_ref(), 2).unwrap(); + + // Initially empty + assert_eq!( + disk_piece_cache + .contents() + .filter(|(_offset, maybe_piece_index)| maybe_piece_index.is_some()) + .count(), + 0 + ); + + // Write first piece into cache + { + let offset = Offset(0); + let piece_index = PieceIndex::ZERO; + let piece = { + let mut piece = Piece::default(); + thread_rng().fill(piece.as_mut()); + piece + }; + + assert_eq!(disk_piece_cache.read_piece_index(offset).unwrap(), None); + assert!(disk_piece_cache.read_piece(offset).unwrap().is_none()); + + disk_piece_cache + .write_piece(offset, piece_index, &piece) + .unwrap(); + + assert_eq!( + disk_piece_cache.read_piece_index(offset).unwrap(), + Some(piece_index) + ); + assert!(disk_piece_cache.read_piece(offset).unwrap().is_some()); + } + + // One piece stored + assert_eq!( + disk_piece_cache + .contents() + .filter(|(_offset, maybe_piece_index)| maybe_piece_index.is_some()) + .count(), + 1 + ); + + // Write second piece into cache + { + let offset = Offset(1); + let piece_index = PieceIndex::from(10); + let piece = { + let mut piece = Piece::default(); + thread_rng().fill(piece.as_mut()); + piece + }; + + assert_eq!(disk_piece_cache.read_piece_index(offset).unwrap(), None); + assert!(disk_piece_cache.read_piece(offset).unwrap().is_none()); + + disk_piece_cache + .write_piece(offset, piece_index, &piece) + .unwrap(); + + assert_eq!( + disk_piece_cache.read_piece_index(offset).unwrap(), + Some(piece_index) + ); + assert!(disk_piece_cache.read_piece(offset).unwrap().is_some()); + } + + // Two pieces stored + assert_eq!( + disk_piece_cache + .contents() + .filter(|(_offset, maybe_piece_index)| maybe_piece_index.is_some()) + .count(), + 2 + ); + + // Writing beyond capacity fails + assert_matches!( + disk_piece_cache.write_piece(Offset(2), PieceIndex::ZERO, &Piece::default()), + Err(DiskPieceCacheError::OffsetOutsideOfRange { .. }) + ); + + // Override works + { + let offset = Offset(0); + let piece_index = PieceIndex::from(13); + let piece = { + let mut piece = Piece::default(); + thread_rng().fill(piece.as_mut()); + piece + }; + + disk_piece_cache + .write_piece(offset, piece_index, &piece) + .unwrap(); + + assert_eq!( + disk_piece_cache.read_piece_index(offset).unwrap(), + Some(piece_index) + ); + assert!(disk_piece_cache.read_piece(offset).unwrap().is_some()); + } + } + + // Reopening works + { + let disk_piece_cache = DiskPieceCache::open(path.as_ref(), 2).unwrap(); + // Two pieces stored + assert_eq!( + disk_piece_cache + .contents() + .filter(|(_offset, maybe_piece_index)| maybe_piece_index.is_some()) + .count(), + 2 + ); + } + + // Wiping works + { + DiskPieceCache::wipe(path.as_ref()).unwrap(); + + let disk_piece_cache = DiskPieceCache::open(path.as_ref(), 2).unwrap(); + // Wiped successfully + assert_eq!( + disk_piece_cache + .contents() + .filter(|(_offset, maybe_piece_index)| maybe_piece_index.is_some()) + .count(), + 0 + ); + } +} diff --git a/crates/subspace-farmer/src/single_disk_farm/plotting.rs b/crates/subspace-farmer/src/single_disk_farm/plotting.rs index 556ebc97e3..a85bd6e01d 100644 --- a/crates/subspace-farmer/src/single_disk_farm/plotting.rs +++ b/crates/subspace-farmer/src/single_disk_farm/plotting.rs @@ -16,6 +16,7 @@ use std::fs::File; use std::io; use std::num::{NonZeroU16, NonZeroUsize}; use std::ops::Range; +use std::pin::pin; use std::sync::atomic::Ordering; use std::sync::Arc; use std::time::Duration; @@ -289,29 +290,31 @@ where let mut sector = Vec::new(); let mut sector_metadata = Vec::new(); - let plot_sector_fut = encode_sector::( - downloaded_sector, - EncodeSectorOptions { - sector_index, - erasure_coding, - pieces_in_sector, - sector_output: &mut sector, - sector_metadata_output: &mut sector_metadata, - encoding_semaphore: Some(encoding_semaphore), - table_generator: &mut table_generator, - }, - ); - - let plotted_sector = Handle::current().block_on(async { - select! { - plotting_result = Box::pin(plot_sector_fut).fuse() => { - plotting_result.map_err(PlottingError::from) - } - _ = stop_receiver.recv().fuse() => { - Err(PlottingError::FarmIsShuttingDown) + let plotted_sector = { + let plot_sector_fut = pin!(encode_sector::( + downloaded_sector, + EncodeSectorOptions { + sector_index, + erasure_coding, + pieces_in_sector, + sector_output: &mut sector, + sector_metadata_output: &mut sector_metadata, + encoding_semaphore: Some(encoding_semaphore), + table_generator: &mut table_generator, + }, + )); + + Handle::current().block_on(async { + select! { + plotting_result = plot_sector_fut.fuse() => { + plotting_result.map_err(PlottingError::from) + } + _ = stop_receiver.recv().fuse() => { + Err(PlottingError::FarmIsShuttingDown) + } } - } - })?; + })? + }; Ok((sector, sector_metadata, table_generator, plotted_sector)) }) @@ -553,14 +556,14 @@ where info!("Node is not synced yet, pausing plotting until sync status changes"); loop { - if node_sync_status.is_synced() { - info!("Node is synced, resuming plotting"); - continue 'outer; - } - match node_sync_status_change_notifications.next().await { Some(new_node_sync_status) => { node_sync_status = new_node_sync_status; + + if node_sync_status.is_synced() { + info!("Node is synced, resuming plotting"); + continue 'outer; + } } None => { // Subscription ended, nothing left to do diff --git a/crates/subspace-farmer/src/utils.rs b/crates/subspace-farmer/src/utils.rs index e833cfbe46..c396c52c53 100644 --- a/crates/subspace-farmer/src/utils.rs +++ b/crates/subspace-farmer/src/utils.rs @@ -11,7 +11,7 @@ use futures::future::Either; use rayon::ThreadBuilder; use std::future::Future; use std::ops::Deref; -use std::pin::Pin; +use std::pin::{pin, Pin}; use std::task::{Context, Poll}; use std::{io, thread}; use tokio::runtime::Handle; @@ -94,12 +94,13 @@ impl Deref for JoinOnDrop { /// Runs future on a dedicated thread with the specified name, will block on drop until background /// thread with future is stopped too, ensuring nothing is left in memory -pub fn run_future_in_dedicated_thread( - future: Fut, +pub fn run_future_in_dedicated_thread( + create_future: CreateFut, thread_name: String, ) -> io::Result> + Send> where - Fut: Future + Unpin + Send + 'static, + CreateFut: (FnOnce() -> Fut) + Send + 'static, + Fut: Future + 'static, T: Send + 'static, { let (drop_tx, drop_rx) = oneshot::channel::<()>(); @@ -108,6 +109,8 @@ where let join_handle = thread::Builder::new().name(thread_name).spawn(move || { let _tokio_handle_guard = handle.enter(); + let future = pin!(create_future()); + let result = match handle.block_on(futures::future::select(future, drop_rx)) { Either::Left((result, _)) => result, Either::Right(_) => { diff --git a/crates/subspace-farmer/src/utils/tests.rs b/crates/subspace-farmer/src/utils/tests.rs index 75ead550a5..1da3e7f0d0 100644 --- a/crates/subspace-farmer/src/utils/tests.rs +++ b/crates/subspace-farmer/src/utils/tests.rs @@ -4,13 +4,10 @@ use tokio::sync::oneshot; #[tokio::test] async fn run_future_in_dedicated_thread_ready() { - let value = run_future_in_dedicated_thread( - Box::pin(async { future::ready(1).await }), - "ready".to_string(), - ) - .unwrap() - .await - .unwrap(); + let value = run_future_in_dedicated_thread(|| future::ready(1), "ready".to_string()) + .unwrap() + .await + .unwrap(); assert_eq!(value, 1); } @@ -19,11 +16,7 @@ async fn run_future_in_dedicated_thread_ready() { async fn run_future_in_dedicated_thread_cancellation() { // This may hang if not implemented correctly drop( - run_future_in_dedicated_thread( - Box::pin(async { future::pending::<()>().await }), - "cancellation".to_string(), - ) - .unwrap(), + run_future_in_dedicated_thread(future::pending::<()>, "cancellation".to_string()).unwrap(), ); } @@ -44,11 +37,11 @@ fn run_future_in_dedicated_thread_tokio_on_drop() { tokio::runtime::Runtime::new().unwrap().block_on(async { drop(run_future_in_dedicated_thread( - Box::pin(async { + move || async move { let s = S; let _ = receiver.await; drop(s); - }), + }, "tokio_on_drop".to_string(), )); }); diff --git a/crates/subspace-networking/examples/benchmark.rs b/crates/subspace-networking/examples/benchmark.rs index 4216851029..0b10585344 100644 --- a/crates/subspace-networking/examples/benchmark.rs +++ b/crates/subspace-networking/examples/benchmark.rs @@ -59,6 +59,8 @@ enum Command { retries: u16, #[arg(long, default_value_t = 1)] parallelism_level: u16, + #[arg(long, default_value_t = 1)] + repeat: u16, }, } @@ -92,8 +94,17 @@ async fn main() { start_with, retries, parallelism_level, + repeat, } => { - parallel_benchmark(node, max_pieces, start_with, retries, parallelism_level).await; + parallel_benchmark( + node, + max_pieces, + start_with, + retries, + parallelism_level, + repeat, + ) + .await; } } @@ -181,6 +192,7 @@ async fn parallel_benchmark( start_with: usize, retries: u16, parallelism_level: u16, + repeat: u16, ) { let start = Instant::now(); let mut stats = PieceRequestStats::default(); @@ -195,6 +207,8 @@ async fn parallel_benchmark( let mut total_duration = Duration::default(); let mut pure_total_duration = Duration::default(); let mut pending_pieces = (start_with..(start_with + max_pieces)) + .cycle() + .take(max_pieces * repeat as usize) .map(|i| { let piece_index = PieceIndex::from(i as u64); async move { diff --git a/crates/subspace-networking/examples/metrics.rs b/crates/subspace-networking/examples/metrics.rs index 96c6e0d3f3..406e81649c 100644 --- a/crates/subspace-networking/examples/metrics.rs +++ b/crates/subspace-networking/examples/metrics.rs @@ -114,23 +114,21 @@ async fn get_peer(peer_id: PeerId, node: Node) { #[cfg(unix)] pub(crate) async fn shutdown_signal() { + use std::pin::pin; + futures::future::select( - Box::pin( - signal::unix::signal(signal::unix::SignalKind::interrupt()) - .expect("Setting signal handlers must never fail") - .recv() - .map(|_| { - tracing::info!("Received SIGINT, shutting down farmer..."); - }), - ), - Box::pin( - signal::unix::signal(signal::unix::SignalKind::terminate()) - .expect("Setting signal handlers must never fail") - .recv() - .map(|_| { - tracing::info!("Received SIGTERM, shutting down farmer..."); - }), - ), + pin!(signal::unix::signal(signal::unix::SignalKind::interrupt()) + .expect("Setting signal handlers must never fail") + .recv() + .map(|_| { + tracing::info!("Received SIGINT, shutting down farmer..."); + }),), + pin!(signal::unix::signal(signal::unix::SignalKind::terminate()) + .expect("Setting signal handlers must never fail") + .recv() + .map(|_| { + tracing::info!("Received SIGTERM, shutting down farmer..."); + }),), ) .await; } diff --git a/crates/subspace-networking/src/behavior.rs b/crates/subspace-networking/src/behavior.rs index 1c45caf0e6..4d83e5a97f 100644 --- a/crates/subspace-networking/src/behavior.rs +++ b/crates/subspace-networking/src/behavior.rs @@ -5,13 +5,8 @@ mod tests; use crate::protocols::autonat_wrapper::{ Behaviour as AutonatWrapper, Config as AutonatWrapperConfig, }; -use crate::protocols::connected_peers::{ - Behaviour as ConnectedPeersBehaviour, Config as ConnectedPeersConfig, - Event as ConnectedPeersEvent, -}; -use crate::protocols::peer_info::{ - Behaviour as PeerInfoBehaviour, Config as PeerInfoConfig, Event as PeerInfoEvent, -}; +use crate::protocols::connected_peers::Config as ConnectedPeersConfig; +use crate::protocols::peer_info::Event as PeerInfoEvent; use crate::protocols::request_response::request_response_factory::{ Event as RequestResponseEvent, RequestHandler, RequestResponseFactoryBehaviour, }; @@ -19,7 +14,7 @@ use crate::protocols::reserved_peers::{ Behaviour as ReservedPeersBehaviour, Config as ReservedPeersConfig, Event as ReservedPeersEvent, }; use crate::protocols::subspace_connection_limits::Behaviour as ConnectionLimitsBehaviour; -use crate::PeerInfoProvider; +use crate::{PeerInfoConfig, PeerInfoProvider}; use derive_more::From; use libp2p::allow_block_list::{Behaviour as AllowBlockListBehaviour, BlockedPeers}; use libp2p::autonat::Event as AutonatEvent; @@ -54,12 +49,20 @@ pub(crate) struct BehaviorConfig { pub(crate) connection_limits: ConnectionLimits, /// The configuration for the [`ReservedPeersBehaviour`]. pub(crate) reserved_peers: ReservedPeersConfig, + // TODO: Restore or remove connected peer later + #[allow(dead_code)] /// The configuration for the [`PeerInfo`] protocol. pub(crate) peer_info_config: PeerInfoConfig, + // TODO: Restore or remove connected peer later + #[allow(dead_code)] /// Provides peer-info for local peer. pub(crate) peer_info_provider: Option, /// The configuration for the [`ConnectedPeers`] protocol (general instance). + // TODO: Restore or remove connected peer later + #[allow(dead_code)] pub(crate) general_connected_peers_config: Option, + // TODO: Restore or remove connected peer later + #[allow(dead_code)] /// The configuration for the [`ConnectedPeers`] protocol (special instance). pub(crate) special_connected_peers_config: Option, /// Autonat configuration. @@ -85,11 +88,12 @@ pub(crate) struct Behavior { pub(crate) request_response: RequestResponseFactoryBehaviour, pub(crate) block_list: BlockListBehaviour, pub(crate) reserved_peers: ReservedPeersBehaviour, - pub(crate) peer_info: Toggle, - pub(crate) general_connected_peers: - Toggle>, - pub(crate) special_connected_peers: - Toggle>, + // TODO: Restore or remove connected peer later + // pub(crate) peer_info: Toggle, + // pub(crate) general_connected_peers: + // Toggle>, + // pub(crate) special_connected_peers: + // Toggle>, pub(crate) autonat: AutonatWrapper, } @@ -116,9 +120,10 @@ where }) .into(); - let peer_info = config - .peer_info_provider - .map(|provider| PeerInfoBehaviour::new(config.peer_info_config, provider)); + // TODO: Restore or remove connected peer later + // let peer_info = config + // .peer_info_provider + // .map(|provider| PeerInfoBehaviour::new(config.peer_info_config, provider)); Self { connection_limits: ConnectionLimitsBehaviour::new(config.connection_limits), @@ -133,15 +138,16 @@ where .expect("RequestResponse protocols registration failed."), block_list: BlockListBehaviour::default(), reserved_peers: ReservedPeersBehaviour::new(config.reserved_peers), - peer_info: peer_info.into(), - general_connected_peers: config - .general_connected_peers_config - .map(ConnectedPeersBehaviour::new) - .into(), - special_connected_peers: config - .special_connected_peers_config - .map(ConnectedPeersBehaviour::new) - .into(), + // TODO: Restore or remove connected peer later + //peer_info: peer_info.into(), + // general_connected_peers: config + // .general_connected_peers_config + // .map(ConnectedPeersBehaviour::new) + // .into(), + // special_connected_peers: config + // .special_connected_peers_config + // .map(ConnectedPeersBehaviour::new) + // .into(), autonat: AutonatWrapper::new(config.autonat), } } @@ -158,7 +164,8 @@ pub(crate) enum Event { VoidEventStub(VoidEvent), ReservedPeers(ReservedPeersEvent), PeerInfo(PeerInfoEvent), - GeneralConnectedPeers(ConnectedPeersEvent), - SpecialConnectedPeers(ConnectedPeersEvent), + // TODO: Restore or remove connected peer later + // GeneralConnectedPeers(ConnectedPeersEvent), + // SpecialConnectedPeers(ConnectedPeersEvent), Autonat(AutonatEvent), } diff --git a/crates/subspace-networking/src/behavior/tests.rs b/crates/subspace-networking/src/behavior/tests.rs index 34db7acb6d..ccdf545483 100644 --- a/crates/subspace-networking/src/behavior/tests.rs +++ b/crates/subspace-networking/src/behavior/tests.rs @@ -230,7 +230,7 @@ async fn test_async_handler_works_with_pending_internal_future() { let (node_2, mut node_runner_2) = crate::construct(config_2).unwrap(); - let bootstrap_fut = Box::pin({ + tokio::spawn({ let node = node_2.clone(); async move { @@ -240,10 +240,6 @@ async fn test_async_handler_works_with_pending_internal_future() { } }); - tokio::spawn(async move { - bootstrap_fut.await; - }); - tokio::spawn(async move { node_runner_2.run().await; }); diff --git a/crates/subspace-networking/src/node_runner.rs b/crates/subspace-networking/src/node_runner.rs index df64166809..1c7db74551 100644 --- a/crates/subspace-networking/src/node_runner.rs +++ b/crates/subspace-networking/src/node_runner.rs @@ -2,13 +2,10 @@ use crate::behavior::persistent_parameters::{ append_p2p_suffix, remove_p2p_suffix, KnownPeersRegistry, PeerAddressRemovedEvent, PEERS_ADDRESSES_BATCH_SIZE, }; -use crate::behavior::{ - Behavior, Event, GeneralConnectedPeersInstance, SpecialConnectedPeersInstance, -}; +use crate::behavior::{Behavior, Event}; use crate::constructor; use crate::constructor::temporary_bans::TemporaryBans; use crate::constructor::{ConnectedPeersHandler, LocalOnlyRecordStore}; -use crate::protocols::connected_peers::Event as ConnectedPeersEvent; use crate::protocols::peer_info::{Event as PeerInfoEvent, PeerInfoSuccess}; use crate::protocols::request_response::request_response_factory::{ Event as RequestResponseEvent, IfDisconnected, @@ -41,6 +38,7 @@ use rand::rngs::StdRng; use rand::{Rng, SeedableRng}; use std::collections::hash_map::Entry; use std::collections::{HashMap, HashSet}; +use std::fmt; use std::fmt::Debug; use std::net::IpAddr; use std::num::NonZeroUsize; @@ -131,10 +129,16 @@ where peer_ip_addresses: HashMap>, /// Defines protocol version for the network peers. Affects network partition. protocol_version: String, + // TODO: Restore or remove connected peer later + #[allow(dead_code)] /// Defines whether we maintain a persistent connection for common peers. general_connection_decision_handler: Option, + // TODO: Restore or remove connected peer later + #[allow(dead_code)] /// Defines whether we maintain a persistent connection for special peers. special_connection_decision_handler: Option, + // TODO: Restore or remove connected peer later + #[allow(dead_code)] /// Randomness generator used for choosing Kademlia addresses. rng: StdRng, /// Addresses to bootstrap Kademlia network @@ -150,6 +154,15 @@ where disable_bootstrap_on_start: bool, } +impl fmt::Debug for NodeRunner +where + LocalRecordProvider: constructor::LocalRecordProvider + Send + Sync + 'static, +{ + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.debug_struct("NodeRunner").finish_non_exhaustive() + } +} + // Helper struct for NodeRunner configuration (clippy requirement). pub(crate) struct NodeRunnerConfig where @@ -382,6 +395,8 @@ where addresses.clear(); addresses.append(&mut external_addresses); } + + self.log_kademlia_stats(); } fn handle_random_query_interval(&mut self) { @@ -442,12 +457,13 @@ where SwarmEvent::Behaviour(Event::PeerInfo(event)) => { self.handle_peer_info_event(event).await; } - SwarmEvent::Behaviour(Event::GeneralConnectedPeers(event)) => { - self.handle_general_connected_peers_event(event).await; - } - SwarmEvent::Behaviour(Event::SpecialConnectedPeers(event)) => { - self.handle_special_connected_peers_event(event).await; - } + // TODO: Restore or remove connected peer later + // SwarmEvent::Behaviour(Event::GeneralConnectedPeers(event)) => { + // self.handle_general_connected_peers_event(event).await; + // } + // SwarmEvent::Behaviour(Event::SpecialConnectedPeers(event)) => { + // self.handle_special_connected_peers_event(event).await; + // } SwarmEvent::Behaviour(Event::Autonat(event)) => { self.handle_autonat_event(event).await; } @@ -1166,61 +1182,63 @@ where }); } - if let Some(general_connected_peers) = - self.swarm.behaviour_mut().general_connected_peers.as_mut() - { - let keep_alive = self - .general_connection_decision_handler - .as_ref() - .map(|handler| handler(&peer_info)) - .unwrap_or(false); - - general_connected_peers.update_keep_alive_status(event.peer_id, keep_alive); - } - - if let Some(special_connected_peers) = - self.swarm.behaviour_mut().special_connected_peers.as_mut() - { - let special_keep_alive = self - .special_connection_decision_handler - .as_ref() - .map(|handler| handler(&peer_info)) - .unwrap_or(false); - - special_connected_peers.update_keep_alive_status(event.peer_id, special_keep_alive); - } - } - } - - async fn handle_general_connected_peers_event( - &mut self, - event: ConnectedPeersEvent, - ) { - trace!(?event, "General connected peers event."); - - let peers = self.get_peers_to_dial().await; - - if let Some(general_connected_peers) = - self.swarm.behaviour_mut().general_connected_peers.as_mut() - { - general_connected_peers.add_peers_to_dial(&peers); + // TODO: Restore or remove connected peer later + // if let Some(general_connected_peers) = + // self.swarm.behaviour_mut().general_connected_peers.as_mut() + // { + // let keep_alive = self + // .general_connection_decision_handler + // .as_ref() + // .map(|handler| handler(&peer_info)) + // .unwrap_or(false); + // + // general_connected_peers.update_keep_alive_status(event.peer_id, keep_alive); + // } + // + // if let Some(special_connected_peers) = + // self.swarm.behaviour_mut().special_connected_peers.as_mut() + // { + // let special_keep_alive = self + // .special_connection_decision_handler + // .as_ref() + // .map(|handler| handler(&peer_info)) + // .unwrap_or(false); + // + // special_connected_peers.update_keep_alive_status(event.peer_id, special_keep_alive); + // } } } - async fn handle_special_connected_peers_event( - &mut self, - event: ConnectedPeersEvent, - ) { - trace!(?event, "Special connected peers event."); - - let peers = self.get_peers_to_dial().await; - - if let Some(special_connected_peers) = - self.swarm.behaviour_mut().special_connected_peers.as_mut() - { - special_connected_peers.add_peers_to_dial(&peers); - } - } + // TODO: Restore or remove connected peer later + // async fn handle_general_connected_peers_event( + // &mut self, + // event: ConnectedPeersEvent, + // ) { + // trace!(?event, "General connected peers event."); + // + // let peers = self.get_peers_to_dial().await; + // + // if let Some(general_connected_peers) = + // self.swarm.behaviour_mut().general_connected_peers.as_mut() + // { + // general_connected_peers.add_peers_to_dial(&peers); + // } + // } + // + // async fn handle_special_connected_peers_event( + // &mut self, + // event: ConnectedPeersEvent, + // ) { + // trace!(?event, "Special connected peers event."); + // + // let peers = self.get_peers_to_dial().await; + // + // if let Some(special_connected_peers) = + // self.swarm.behaviour_mut().special_connected_peers.as_mut() + // { + // special_connected_peers.add_peers_to_dial(&peers); + // } + // } async fn handle_autonat_event(&mut self, event: AutonatEvent) { trace!(?event, "Autonat event received."); @@ -1563,6 +1581,8 @@ where } } + // TODO: Restore or remove connected peer later + #[allow(dead_code)] async fn get_peers_to_dial(&mut self) -> Vec { let mut result_peers = Vec::with_capacity(KADEMLIA_PEERS_ADDRESSES_BATCH_SIZE + PEERS_ADDRESSES_BATCH_SIZE); @@ -1635,4 +1655,23 @@ where result_peers.retain(|(peer_id, _)| !bootstrap_nodes.contains(peer_id)); result_peers } + + fn log_kademlia_stats(&mut self) { + let mut peer_counter = 0; + let mut peer_with_no_address_counter = 0; + for kbucket in self.swarm.behaviour_mut().kademlia.kbuckets() { + for entry in kbucket.iter() { + peer_counter += 1; + if entry.node.value.len() == 0 { + peer_with_no_address_counter += 1; + } + } + } + + debug!( + peers = %peer_counter, + peers_with_no_address = %peer_with_no_address_counter, + "Kademlia stats" + ); + } } diff --git a/crates/subspace-networking/src/protocols/connected_peers.rs b/crates/subspace-networking/src/protocols/connected_peers.rs index cdcecae7be..abaf96f0ad 100644 --- a/crates/subspace-networking/src/protocols/connected_peers.rs +++ b/crates/subspace-networking/src/protocols/connected_peers.rs @@ -22,9 +22,11 @@ //! attempts, and manages a cache for candidates for permanent connections. It maintains //! a single connection for each peer. Multiple protocol instances could be instantiated. +//! TODO: Restore or remove connected peer later +#![allow(dead_code)] + mod handler; -#[cfg(not(windows))] // TODO: Restore tests on windows after changing the waiting algorithm #[cfg(test)] mod tests; @@ -32,7 +34,7 @@ use crate::utils::PeerAddress; use futures::FutureExt; use futures_timer::Delay; use handler::Handler; -use libp2p::core::{Endpoint, Multiaddr}; +use libp2p::core::{ConnectedPoint, Endpoint, Multiaddr}; use libp2p::swarm::behaviour::{ConnectionEstablished, FromSwarm}; use libp2p::swarm::dial_opts::DialOpts; use libp2p::swarm::{ @@ -47,6 +49,30 @@ use std::task::{Context, Poll, Waker}; use std::time::{Duration, Instant}; use tracing::{debug, trace}; +#[derive(Debug, Clone, PartialEq, Eq, Copy)] +pub(super) enum ConnectionType { + Outgoing, + Incoming, +} + +impl From<&ConnectedPoint> for ConnectionType { + fn from(value: &ConnectedPoint) -> Self { + match value { + ConnectedPoint::Dialer { .. } => ConnectionType::Outgoing, + ConnectedPoint::Listener { .. } => ConnectionType::Incoming, + } + } +} + +impl ConnectionType { + fn stringify(&self) -> String { + match self { + Self::Outgoing => "Outgoing".to_string(), + Self::Incoming => "Incoming".to_string(), + } + } +} + /// Represents different states of a peer permanent connection. #[derive(Debug, Clone, PartialEq, Eq)] enum ConnectionState { @@ -58,11 +84,17 @@ enum ConnectionState { /// We're waiting for a decision for some time. The decision time is limited by the /// connection timeout. - Deciding { connection_id: ConnectionId }, + Deciding { + connection_id: ConnectionId, + connection_type: ConnectionType, + }, /// Indicates that the decision has been made to maintain a permanent /// connection with the peer. No further decision-making is required for this state. - Permanent { connection_id: ConnectionId }, + Permanent { + connection_id: ConnectionId, + connection_type: ConnectionType, + }, /// Shows that the system has decided not to connect with the peer. /// No further decision-making is required for this state. @@ -79,21 +111,42 @@ impl ConnectionState { fn connection_id(&self) -> Option { match self { ConnectionState::Preparing { .. } | ConnectionState::Connecting { .. } => None, - ConnectionState::Deciding { connection_id } => Some(*connection_id), - ConnectionState::Permanent { connection_id } => Some(*connection_id), + ConnectionState::Deciding { connection_id, .. } => Some(*connection_id), + ConnectionState::Permanent { connection_id, .. } => Some(*connection_id), + ConnectionState::NotInterested => None, + } + } + + /// Returns active connection type if any. + fn connection_type(&self) -> Option { + match self { + ConnectionState::Preparing { .. } | ConnectionState::Connecting { .. } => None, + ConnectionState::Deciding { + connection_type, .. + } => Some(*connection_type), + ConnectionState::Permanent { + connection_type, .. + } => Some(*connection_type), ConnectionState::NotInterested => None, } } /// Converts [`ConnectionState`] to a string with information loss. fn stringify(&self) -> String { - match self { + let type_part = self + .connection_type() + .map(|conn_type| conn_type.stringify()) + .unwrap_or("None".to_string()); + + let state_part = match self { ConnectionState::Preparing { .. } => "ToConnect".to_string(), ConnectionState::Connecting { .. } => "Connecting".to_string(), ConnectionState::Deciding { .. } => "Deciding".to_string(), ConnectionState::Permanent { .. } => "Permanent".to_string(), ConnectionState::NotInterested => "NotInterested".to_string(), - } + }; + + format!("{0}:{1}", type_part, state_part) } } @@ -200,14 +253,22 @@ impl Behaviour { } /// Create a connection handler for the protocol. - fn new_connection_handler(&mut self, peer_id: &PeerId, connection_id: ConnectionId) -> Handler { + fn new_connection_handler( + &mut self, + peer_id: &PeerId, + connection_id: ConnectionId, + connection_type: ConnectionType, + ) -> Handler { let default_keep_alive_until = Instant::now() + self.config.decision_timeout; let (keep_alive, keep_alive_until) = if let Some(connection_state) = self.known_peers.get_mut(peer_id) { match connection_state { ConnectionState::Preparing { .. } | ConnectionState::Connecting { .. } => { // Connection attempt was successful. - *connection_state = ConnectionState::Deciding { connection_id }; + *connection_state = ConnectionState::Deciding { + connection_id, + connection_type, + }; (true, Some(default_keep_alive_until)) } @@ -217,8 +278,13 @@ impl Behaviour { } } else { // Connection from other protocols. - self.known_peers - .insert(*peer_id, ConnectionState::Deciding { connection_id }); + self.known_peers.insert( + *peer_id, + ConnectionState::Deciding { + connection_id, + connection_type, + }, + ); (true, Some(default_keep_alive_until)) }; @@ -230,13 +296,29 @@ impl Behaviour { /// Specifies the whether we should keep connections to the peer alive. The decision could /// depend on another protocol (e.g.: PeerInfo protocol event handling). pub fn update_keep_alive_status(&mut self, peer_id: PeerId, keep_alive: bool) { - let not_enough_connected_peers = - self.permanently_connected_peers() < self.config.max_connected_peers; + let current_connected_peers_number = self.permanently_connected_peers(); // It's a known peer. if let Some(connection_state) = self.known_peers.get_mut(&peer_id) { // We're connected if let Some(connection_id) = connection_state.connection_id() { + let Some(connection_type) = connection_state.connection_type() else { + debug!( + ?peer_id, + ?keep_alive, + "Detected an attempt to update status of peer with unknown connection type." + ); + return; + }; + + // We allow new permanent outgoing connections when we have total connections less + // than our desired (target) connection number or new permanent incoming + // connections when we have total connections less than the maximum allowed number. + let not_enough_connected_peers = current_connected_peers_number + < self.config.target_connected_peers + || (connection_type == ConnectionType::Incoming + && current_connected_peers_number < self.config.max_connected_peers); + if not_enough_connected_peers { trace!(%peer_id, %keep_alive, "Insufficient number of connected peers detected."); } else { @@ -246,7 +328,13 @@ impl Behaviour { // Check whether we have enough connected peers already and a positive decision let (new_connection_state, keep_alive_handler) = if not_enough_connected_peers && keep_alive { - (ConnectionState::Permanent { connection_id }, true) + ( + ConnectionState::Permanent { + connection_id, + connection_type, + }, + true, + ) } else { (ConnectionState::NotInterested, false) }; @@ -314,9 +402,9 @@ impl Behaviour { let status_count = self.known_peers .iter() - .fold(HashMap::new(), |mut result, (_, connection_state)| { + .fold(HashMap::new(), |mut result, (_, connection_info)| { result - .entry(connection_state.stringify()) + .entry(connection_info.stringify()) .and_modify(|count| *count += 1) .or_insert(1); result @@ -324,9 +412,9 @@ impl Behaviour { let peer_status = self.known_peers.iter().fold( HashMap::>::new(), - |mut result, (peer_id, connection_state)| { + |mut result, (peer_id, connection_info)| { result - .entry(connection_state.stringify()) + .entry(connection_info.stringify()) .and_modify(|peers| peers.push(*peer_id)) .or_insert(vec![*peer_id]); result @@ -351,7 +439,7 @@ impl NetworkBehaviour for Behaviour { _: &Multiaddr, _: &Multiaddr, ) -> Result, ConnectionDenied> { - Ok(self.new_connection_handler(&peer_id, connection_id)) + Ok(self.new_connection_handler(&peer_id, connection_id, ConnectionType::Incoming)) } fn handle_established_outbound_connection( @@ -361,7 +449,7 @@ impl NetworkBehaviour for Behaviour { _: &Multiaddr, _: Endpoint, ) -> Result, ConnectionDenied> { - Ok(self.new_connection_handler(&peer_id, connection_id)) + Ok(self.new_connection_handler(&peer_id, connection_id, ConnectionType::Outgoing)) } fn on_swarm_event(&mut self, event: FromSwarm) { @@ -369,12 +457,16 @@ impl NetworkBehaviour for Behaviour { FromSwarm::ConnectionEstablished(ConnectionEstablished { peer_id, connection_id, + endpoint, .. }) => { match self.known_peers.entry(peer_id) { // Connection was established without dialing from this protocol Entry::Vacant(entry) => { - entry.insert(ConnectionState::Deciding { connection_id }); + entry.insert(ConnectionState::Deciding { + connection_id, + connection_type: endpoint.into(), + }); trace!(%peer_id, "Pending peer decision..."); self.wake(); diff --git a/crates/subspace-networking/src/protocols/connected_peers/tests.rs b/crates/subspace-networking/src/protocols/connected_peers/tests.rs index 091dbedc13..ab9aaffd3e 100644 --- a/crates/subspace-networking/src/protocols/connected_peers/tests.rs +++ b/crates/subspace-networking/src/protocols/connected_peers/tests.rs @@ -189,7 +189,7 @@ async fn test_target_connected_peer_limit_number() { let mut peer1 = new_ephemeral( DECISION_TIMEOUT, Behaviour::::new(Config { - target_connected_peers: 0, + target_connected_peers: 1, max_connected_peers, decision_timeout: DECISION_TIMEOUT, ..Default::default() @@ -287,3 +287,75 @@ fn new_ephemeral(connection_timeout: Duration, behaviour: .unwrap() .build() } + +#[tokio::test()] +async fn test_connection_type_difference() { + let mut peer1 = new_ephemeral( + DECISION_TIMEOUT, + Behaviour::::new(Config { + target_connected_peers: 0, + max_connected_peers: 1, + decision_timeout: DECISION_TIMEOUT, + ..Default::default() + }), + ); + + let mut peer2 = new_ephemeral( + DECISION_TIMEOUT, + Behaviour::::new(Config { + target_connected_peers: 1, + max_connected_peers: 1, + decision_timeout: DECISION_TIMEOUT, + ..Default::default() + }), + ); + + peer1.listen().with_memory_addr_external().await; + peer2.listen().with_memory_addr_external().await; + + peer1.connect(&mut peer2).await; + + peer1 + .behaviour_mut() + .update_keep_alive_status(*peer2.local_peer_id(), true); + peer2 + .behaviour_mut() + .update_keep_alive_status(*peer1.local_peer_id(), true); + + loop { + select! { + _ = peer1.next_swarm_event().fuse() => {}, + _ = peer2.next_swarm_event().fuse() => {}, + _ = sleep(LONG_DELAY).fuse() => { + break; + } + } + } + + // Peer1 doesn't have enough slots for outgoing connections + assert!(!peer1.is_connected(peer2.local_peer_id())); + assert!(!peer2.is_connected(peer1.local_peer_id())); + + peer2.connect(&mut peer1).await; + + peer1 + .behaviour_mut() + .update_keep_alive_status(*peer2.local_peer_id(), true); + peer2 + .behaviour_mut() + .update_keep_alive_status(*peer1.local_peer_id(), true); + + loop { + select! { + _ = peer1.next_swarm_event().fuse() => {}, + _ = peer2.next_swarm_event().fuse() => {}, + _ = sleep(LONG_DELAY).fuse() => { + break; + } + } + } + + // Peer2 has enough slots for outgoing connections + assert!(peer1.is_connected(peer2.local_peer_id())); + assert!(peer2.is_connected(peer1.local_peer_id())); +} diff --git a/crates/subspace-networking/src/protocols/peer_info.rs b/crates/subspace-networking/src/protocols/peer_info.rs index 7ff7e2cc98..478b8b0272 100644 --- a/crates/subspace-networking/src/protocols/peer_info.rs +++ b/crates/subspace-networking/src/protocols/peer_info.rs @@ -1,3 +1,6 @@ +//! TODO: Restore or remove connected peer later +#![allow(dead_code)] + mod handler; mod protocol; diff --git a/crates/subspace-node/Cargo.toml b/crates/subspace-node/Cargo.toml index 81306c72ea..9e1e8730a1 100644 --- a/crates/subspace-node/Cargo.toml +++ b/crates/subspace-node/Cargo.toml @@ -29,41 +29,42 @@ domain-eth-service = { version = "0.1.0", path = "../../domains/client/eth-servi domain-service = { version = "0.1.0", path = "../../domains/service" } domain-runtime-primitives = { version = "0.1.0", path = "../../domains/primitives/runtime" } evm-domain-runtime = { version = "0.1.0", path = "../../domains/runtime/evm" } -fp-evm = { version = "3.0.0-dev", git = "https://github.com/subspace/frontier", rev = "56086daa77802eaa285894bfe4b811be66629c89" } -frame-benchmarking = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1", default-features = false } -frame-benchmarking-cli = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1", default-features = false } -frame-support = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +fp-evm = { version = "3.0.0-dev", git = "https://github.com/subspace/frontier", rev = "37ee45323120b21adc1d69ae7348bd0f7282eeae" } +frame-benchmarking = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c", default-features = false } +frame-benchmarking-cli = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c", default-features = false } +frame-support = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } futures = "0.3.29" hex = "0.4.3" hex-literal = "0.4.1" log = "0.4.20" mimalloc = "0.1.39" parity-scale-codec = "3.6.5" -sc-chain-spec = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sc-cli = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1", default-features = false } -sc-client-api = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sc-consensus-slots = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +sc-chain-spec = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sc-cli = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c", default-features = false } +sc-client-api = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sc-consensus-slots = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } sc-consensus-subspace = { version = "0.1.0", path = "../sc-consensus-subspace" } +sc-executor = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sc-network = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } sc-subspace-chain-specs = { version = "0.1.0", path = "../sc-subspace-chain-specs" } -sc-executor = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sc-service = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1", default-features = false } -sc-storage-monitor = { version = "0.1.0", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1", default-features = false } -sc-telemetry = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sc-tracing = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sc-transaction-pool-api = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sc-network-sync = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sc-utils = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +sc-service = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c", default-features = false } +sc-storage-monitor = { version = "0.1.0", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c", default-features = false } +sc-telemetry = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sc-tracing = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sc-transaction-pool-api = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sc-network-sync = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sc-utils = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } serde_json = "1.0.106" -sp-blockchain = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +sp-blockchain = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } sp-consensus-subspace = { version = "0.1.0", path = "../sp-consensus-subspace" } -sp-core = { version = "21.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +sp-core = { version = "21.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } sp-domains = { version = "0.1.0", path = "../sp-domains" } sp-domain-digests = { version = "0.1.0", path = "../../domains/primitives/digests" } sp-domains-fraud-proof = { version = "0.1.0", path = "../sp-domains-fraud-proof" } -sp-io = { version = "23.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +sp-io = { version = "23.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } sp-messenger = { version = "0.1.0", path = "../../domains/primitives/messenger" } -sp-runtime = { version = "24.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-wasm-interface = { version = "14.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +sp-runtime = { version = "24.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-wasm-interface = { version = "14.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } subspace-core-primitives = { version = "0.1.0", path = "../subspace-core-primitives" } subspace-networking = { version = "0.1.0", path = "../subspace-networking" } subspace-proof-of-space = { version = "0.1.0", path = "../subspace-proof-of-space" } @@ -74,7 +75,7 @@ thiserror = "1.0.48" tokio = "1.34.0" [build-dependencies] -substrate-build-script-utils = { version = "3.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +substrate-build-script-utils = { version = "3.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } [features] default = [] diff --git a/crates/subspace-node/src/bin/subspace-node.rs b/crates/subspace-node/src/bin/subspace-node.rs index 6b0f0d392c..a919db5cf6 100644 --- a/crates/subspace-node/src/bin/subspace-node.rs +++ b/crates/subspace-node/src/bin/subspace-node.rs @@ -450,6 +450,10 @@ fn main() -> Result<(), Error> { })? .unwrap_or_default(); + let consensus_state_pruning_mode = consensus_chain_config + .state_pruning + .clone() + .unwrap_or_default(); let consensus_chain_node = { let span = sc_tracing::tracing::info_span!( sc_tracing::logging::PREFIX_LOG_SPAN, @@ -608,6 +612,7 @@ fn main() -> Result<(), Error> { let relayer_worker = domain_client_message_relayer::worker::relay_consensus_chain_messages( consensus_chain_node.client.clone(), + consensus_state_pruning_mode, consensus_chain_node.sync_service.clone(), xdm_gossip_worker_builder.gossip_msg_sink(), ); @@ -630,6 +635,7 @@ fn main() -> Result<(), Error> { ChainId::Consensus, consensus_chain_node.client.clone(), consensus_chain_node.transaction_pool.clone(), + consensus_chain_node.network_service.clone(), consensus_msg_receiver, ); @@ -662,6 +668,7 @@ fn main() -> Result<(), Error> { consensus_offchain_tx_pool_factory: OffchainTransactionPoolFactory::new( consensus_chain_node.transaction_pool.clone(), ), + consensus_network: consensus_chain_node.network_service.clone(), block_importing_notification_stream: consensus_chain_node .block_importing_notification_stream .clone(), diff --git a/crates/subspace-node/src/chain_spec.rs b/crates/subspace-node/src/chain_spec.rs index 676610877c..b23a790911 100644 --- a/crates/subspace-node/src/chain_spec.rs +++ b/crates/subspace-node/src/chain_spec.rs @@ -23,7 +23,7 @@ use crate::domain::evm_chain_spec::{self, SpecId}; use hex_literal::hex; use parity_scale_codec::Encode; use sc_service::{ChainType, NoExtension}; -use sc_subspace_chain_specs::ConsensusChainSpec; +use sc_subspace_chain_specs::{ConsensusChainSpec, DEVNET_CHAIN_SPEC, GEMINI_3G_CHAIN_SPEC}; use sc_telemetry::TelemetryEndpoints; use sp_consensus_subspace::FarmerPublicKey; use sp_core::crypto::{Ss58Codec, UncheckedFrom}; @@ -42,8 +42,6 @@ use subspace_runtime::{ use subspace_runtime_primitives::{AccountId, Balance, BlockNumber, SSC}; const SUBSPACE_TELEMETRY_URL: &str = "wss://telemetry.subspace.network/submit/"; -const DEVNET_CHAIN_SPEC: &[u8] = include_bytes!("../res/chain-spec-raw-devnet.json"); -const GEMINI_3G_CHAIN_SPEC: &[u8] = include_bytes!("../res/chain-spec-raw-gemini-3g.json"); /// List of accounts which should receive token grants, amounts are specified in SSC. const TOKEN_GRANTS: &[(&str, u128)] = &[ @@ -159,7 +157,7 @@ pub fn gemini_3g_compiled() -> Result, vesting_schedules, GenesisParams { enable_rewards: false, - enable_storage_access: false, + enable_storage_access: true, allow_authoring_by: AllowAuthoringBy::RootFarmer( FarmerPublicKey::unchecked_from(hex_literal::hex!( "8aecbcf0b404590ddddc01ebacb205a562d12fdb5c2aa6a4035c1a20f23c9515" @@ -208,11 +206,11 @@ pub fn gemini_3g_compiled() -> Result, } pub fn gemini_3g_config() -> Result, String> { - ConsensusChainSpec::from_json_bytes(GEMINI_3G_CHAIN_SPEC) + ConsensusChainSpec::from_json_bytes(GEMINI_3G_CHAIN_SPEC.as_bytes()) } pub fn devnet_config() -> Result, String> { - ConsensusChainSpec::from_json_bytes(DEVNET_CHAIN_SPEC) + ConsensusChainSpec::from_json_bytes(DEVNET_CHAIN_SPEC.as_bytes()) } pub fn devnet_config_compiled() -> Result, String> { @@ -272,7 +270,7 @@ pub fn devnet_config_compiled() -> Result Result, String> vec![], GenesisParams { enable_rewards: false, - enable_storage_access: false, + enable_storage_access: true, allow_authoring_by: AllowAuthoringBy::Anyone, pot_slot_iterations: NonZeroU32::new(100_000_000).expect("Not zero; qed"), enable_domains: true, @@ -405,7 +403,7 @@ pub fn local_config() -> Result, String vec![], GenesisParams { enable_rewards: false, - enable_storage_access: false, + enable_storage_access: true, allow_authoring_by: AllowAuthoringBy::Anyone, pot_slot_iterations: NonZeroU32::new(100_000_000).expect("Not zero; qed"), enable_domains: true, diff --git a/crates/subspace-node/src/domain/domain_instance_starter.rs b/crates/subspace-node/src/domain/domain_instance_starter.rs index 4307e237ba..83f4e935d7 100644 --- a/crates/subspace-node/src/domain/domain_instance_starter.rs +++ b/crates/subspace-node/src/domain/domain_instance_starter.rs @@ -1,7 +1,7 @@ use super::{evm_chain_spec, DomainCli}; use crate::domain::{AccountId20, EVMDomainExecutorDispatch}; use crate::ExecutorDispatch as CExecutorDispatch; -use cross_domain_message_gossip::Message; +use cross_domain_message_gossip::{ChainTxPoolMsg, Message}; use domain_client_operator::{BootstrapResult, OperatorStreams}; use domain_eth_service::provider::EthProvider; use domain_eth_service::DefaultEthConfig; @@ -10,8 +10,10 @@ use domain_service::{FullBackend, FullClient}; use futures::StreamExt; use sc_chain_spec::ChainSpec; use sc_cli::{CliConfiguration, Database, DefaultConfigurationValues, SubstrateCli}; +use sc_consensus_subspace::block_import::BlockImportingNotification; use sc_consensus_subspace::notification::SubspaceNotificationStream; -use sc_consensus_subspace::{BlockImportingNotification, NewSlotNotification}; +use sc_consensus_subspace::slot_worker::NewSlotNotification; +use sc_network::NetworkPeers; use sc_service::{BasePath, Configuration}; use sc_transaction_pool_api::OffchainTransactionPoolFactory; use sc_utils::mpsc::{TracingUnboundedReceiver, TracingUnboundedSender}; @@ -23,7 +25,7 @@ use subspace_service::FullClient as CFullClient; /// `DomainInstanceStarter` used to start a domain instance node based on the given /// bootstrap result -pub struct DomainInstanceStarter { +pub struct DomainInstanceStarter { pub domain_cli: DomainCli, pub tokio_handle: tokio::runtime::Handle, pub consensus_client: Arc>, @@ -32,11 +34,15 @@ pub struct DomainInstanceStarter { SubspaceNotificationStream>, pub new_slot_notification_stream: SubspaceNotificationStream, pub consensus_sync_service: Arc>, - pub domain_message_receiver: TracingUnboundedReceiver>, + pub domain_message_receiver: TracingUnboundedReceiver, pub gossip_message_sink: TracingUnboundedSender, + pub consensus_network: Arc, } -impl DomainInstanceStarter { +impl DomainInstanceStarter +where + CNetwork: NetworkPeers + Send + Sync + 'static, +{ pub async fn start( self, bootstrap_result: BootstrapResult, @@ -62,6 +68,7 @@ impl DomainInstanceStarter { consensus_sync_service, domain_message_receiver, gossip_message_sink, + consensus_network, } = self; let domain_id = domain_cli.domain_id; @@ -132,6 +139,7 @@ impl DomainInstanceStarter { domain_created_at, consensus_client, consensus_offchain_tx_pool_factory, + consensus_network, consensus_network_sync_oracle: consensus_sync_service.clone(), operator_streams, gossip_message_sink, @@ -152,6 +160,7 @@ impl DomainInstanceStarter { EVMDomainExecutorDispatch, AccountId20, _, + _, >(domain_params) .await?; diff --git a/crates/subspace-runtime-primitives/Cargo.toml b/crates/subspace-runtime-primitives/Cargo.toml index 19c22ba7f0..7e41fd3c45 100644 --- a/crates/subspace-runtime-primitives/Cargo.toml +++ b/crates/subspace-runtime-primitives/Cargo.toml @@ -16,17 +16,17 @@ include = [ targets = ["x86_64-unknown-linux-gnu"] [dependencies] -frame-support = { version = "4.0.0-dev", default-features = false, optional = true, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -frame-system = { version = "4.0.0-dev", default-features = false, optional = true, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -pallet-transaction-payment = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +frame-support = { version = "4.0.0-dev", default-features = false, optional = true, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +frame-system = { version = "4.0.0-dev", default-features = false, optional = true, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +pallet-transaction-payment = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } # TODO: Should, idealy, be optional, but `sp-runtime`'s `serde` feature is enabled unconditionally by something in # Substrate and as the result our custom `Block` implementation has to derive `serde` traits essentially # unconditionally or else it doesn't compile serde = { version = "1.0.183", default-features = false, features = ["alloc", "derive"] } -sp-core = { version = "21.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-io = { version = "23.0.0", default-features = false, optional = true, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-runtime = { version = "24.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-std = { version = "8.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +sp-core = { version = "21.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-io = { version = "23.0.0", default-features = false, optional = true, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-runtime = { version = "24.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-std = { version = "8.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } subspace-core-primitives = { version = "0.1.0", default-features = false, path = "../subspace-core-primitives" } [features] diff --git a/crates/subspace-runtime/Cargo.toml b/crates/subspace-runtime/Cargo.toml index 507ca80b24..f1a1014c3a 100644 --- a/crates/subspace-runtime/Cargo.toml +++ b/crates/subspace-runtime/Cargo.toml @@ -18,54 +18,54 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] codec = { package = "parity-scale-codec", version = "3.6.5", default-features = false, features = ["derive"] } domain-runtime-primitives = { version = "0.1.0", default-features = false, path = "../../domains/primitives/runtime" } -frame-benchmarking = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1", optional = true } -frame-executive = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -frame-support = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -frame-system = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -frame-system-benchmarking = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1", optional = true } -frame-system-rpc-runtime-api = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +frame-benchmarking = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c", optional = true } +frame-executive = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +frame-support = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +frame-system = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +frame-system-benchmarking = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c", optional = true } +frame-system-rpc-runtime-api = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } orml-vesting = { version = "0.4.1-dev", default-features = false, path = "../../orml/vesting" } -pallet-balances = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +pallet-balances = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } pallet-domains = { version = "0.1.0", default-features = false, path = "../pallet-domains" } pallet-messenger = { version = "0.1.0", path = "../../domains/pallets/messenger", default-features = false } pallet-offences-subspace = { version = "0.1.0", default-features = false, path = "../pallet-offences-subspace" } pallet-rewards = { version = "0.1.0", default-features = false, path = "../pallet-rewards" } pallet-runtime-configs = { version = "0.1.0", default-features = false, path = "../pallet-runtime-configs" } pallet-subspace = { version = "0.1.0", default-features = false, features = ["serde"], path = "../pallet-subspace" } -pallet-sudo = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -pallet-timestamp = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +pallet-sudo = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +pallet-timestamp = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } pallet-transaction-fees = { version = "0.1.0", default-features = false, path = "../pallet-transaction-fees" } -pallet-transaction-payment = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -pallet-transaction-payment-rpc-runtime-api = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +pallet-transaction-payment = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +pallet-transaction-payment-rpc-runtime-api = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } pallet-transporter = { version = "0.1.0", path = "../../domains/pallets/transporter", default-features = false } -pallet-utility = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +pallet-utility = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } scale-info = { version = "2.7.0", default-features = false, features = ["derive"] } -sp-api = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-block-builder = { git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1", default-features = false, version = "4.0.0-dev" } +sp-api = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-block-builder = { git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c", default-features = false, version = "4.0.0-dev" } sp-consensus-subspace = { version = "0.1.0", default-features = false, path = "../sp-consensus-subspace" } -sp-consensus-slots = { version = "0.10.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-core = { version = "21.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +sp-consensus-slots = { version = "0.10.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-core = { version = "21.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } sp-domains = { version = "0.1.0", default-features = false, path = "../sp-domains" } sp-domains-fraud-proof = { version = "0.1.0", default-features = false, path = "../sp-domains-fraud-proof" } -sp-inherents = { git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1", default-features = false, version = "4.0.0-dev" } +sp-inherents = { git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c", default-features = false, version = "4.0.0-dev" } sp-messenger = { version = "0.1.0", default-features = false, path = "../../domains/primitives/messenger" } sp-objects = { version = "0.1.0", default-features = false, path = "../sp-objects" } -sp-offchain = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-runtime = { version = "24.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-session = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-std = { version = "8.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-transaction-pool = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-version = { version = "22.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +sp-offchain = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-runtime = { version = "24.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-session = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-std = { version = "8.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-transaction-pool = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-version = { version = "22.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } static_assertions = "1.1.0" subspace-core-primitives = { version = "0.1.0", default-features = false, path = "../subspace-core-primitives" } subspace-runtime-primitives = { version = "0.1.0", default-features = false, path = "../subspace-runtime-primitives" } [build-dependencies] -substrate-wasm-builder = { version = "5.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1", optional = true } +substrate-wasm-builder = { version = "5.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c", optional = true } [dev-dependencies] hex-literal = "0.4.1" -sp-io = { version = "23.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +sp-io = { version = "23.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } subspace-runtime-primitives = { version = "0.1.0", features = ["testing"], path = "../subspace-runtime-primitives" } [features] diff --git a/crates/subspace-runtime/src/lib.rs b/crates/subspace-runtime/src/lib.rs index ca3b93d85b..d093598990 100644 --- a/crates/subspace-runtime/src/lib.rs +++ b/crates/subspace-runtime/src/lib.rs @@ -38,7 +38,6 @@ use domain_runtime_primitives::{ BlockNumber as DomainNumber, Hash as DomainHash, MultiAccountId, TryConvertBack, }; use frame_support::inherent::ProvideInherent; -use frame_support::migrations::VersionedMigration; use frame_support::traits::{ConstU16, ConstU32, ConstU64, ConstU8, Currency, Everything, Get}; use frame_support::weights::constants::{RocksDbWeight, WEIGHT_REF_TIME_PER_SECOND}; use frame_support::weights::{ConstantMultiplier, IdentityFee, Weight}; @@ -49,7 +48,7 @@ pub use pallet_subspace::AllowAuthoringBy; use pallet_transporter::EndpointHandler; use scale_info::TypeInfo; use sp_api::{impl_runtime_apis, BlockT}; -use sp_consensus_slots::SlotDuration; +use sp_consensus_slots::{Slot, SlotDuration}; use sp_consensus_subspace::{ ChainConstants, EquivocationProof, FarmerPublicKey, PotParameters, SignedVote, SolutionRanges, Vote, @@ -103,10 +102,10 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("subspace"), impl_name: create_runtime_str!("subspace"), authoring_version: 0, - spec_version: 4, + spec_version: 0, impl_version: 0, apis: RUNTIME_API_VERSIONS, - transaction_version: 1, + transaction_version: 0, state_version: 0, }; @@ -313,6 +312,7 @@ parameter_types! { pub const PotEntropyInjectionInterval: BlockNumber = POT_ENTROPY_INJECTION_INTERVAL; pub const PotEntropyInjectionLookbackDepth: u8 = POT_ENTROPY_INJECTION_LOOKBACK_DEPTH; pub const PotEntropyInjectionDelay: SlotNumber = POT_ENTROPY_INJECTION_DELAY; + pub const EraDuration: u32 = ERA_DURATION_IN_BLOCKS; pub const SlotProbability: (u64, u64) = SLOT_PROBABILITY; pub const ExpectedVotesPerBlock: u32 = EXPECTED_VOTES_PER_BLOCK; pub const RecentSegments: HistorySize = RECENT_SEGMENTS; @@ -337,7 +337,7 @@ impl pallet_subspace::Config for Runtime { type PotEntropyInjectionInterval = PotEntropyInjectionInterval; type PotEntropyInjectionLookbackDepth = PotEntropyInjectionLookbackDepth; type PotEntropyInjectionDelay = PotEntropyInjectionDelay; - type EraDuration = ConstU32; + type EraDuration = EraDuration; type InitialSolutionRange = ConstU64; type SlotProbability = SlotProbability; type ConfirmationDepthK = ConfirmationDepthK; @@ -602,8 +602,7 @@ parameter_types! { pub const StakeEpochDuration: DomainNumber = 100; pub TreasuryAccount: AccountId = PalletId(*b"treasury").into_account_truncating(); pub const MaxPendingStakingOperation: u32 = 100; - // TODO: reset `MaxNominators` back to `100` once the gemini-3g chain spec is created - pub const MaxNominators: u32 = 0; + pub const MaxNominators: u32 = 256; pub SudoId: AccountId = Sudo::key().expect("Sudo account must exist"); } @@ -723,27 +722,6 @@ pub type SignedExtra = ( pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; -pub type VersionCheckedMigrateDomainsV1ToV2 = VersionedMigration< - 1, - 2, - pallet_domains::migrations::VersionUncheckedMigrateV1ToV2, - pallet_domains::Pallet, - ::DbWeight, ->; - -pub type VersionCheckedMigrateDomainsV2ToV3 = VersionedMigration< - 2, - 3, - pallet_domains::migrations::VersionUncheckedMigrateV2ToV3, - pallet_domains::Pallet, - ::DbWeight, ->; - -pub type Migrations = ( - VersionCheckedMigrateDomainsV1ToV2, - VersionCheckedMigrateDomainsV2ToV3, -); - /// Executive: handles dispatch to the various modules. pub type Executive = frame_executive::Executive< Runtime, @@ -751,7 +729,6 @@ pub type Executive = frame_executive::Executive< frame_system::ChainContext, Runtime, AllPalletsWithSystem, - Migrations, >; fn extract_segment_headers(ext: &UncheckedExtrinsic) -> Option> { @@ -982,11 +959,19 @@ impl_runtime_apis! { } fn chain_constants() -> ChainConstants { - Subspace::chain_constants() + ChainConstants::V1 { + confirmation_depth_k: ConfirmationDepthK::get(), + block_authoring_delay: Slot::from(BlockAuthoringDelay::get()), + era_duration: EraDuration::get(), + slot_probability: SlotProbability::get(), + slot_duration: SlotDuration::from_millis(SLOT_DURATION), + recent_segments: RecentSegments::get(), + recent_history_fraction: RecentHistoryFraction::get(), + min_sector_lifetime: MinSectorLifetime::get(), + } } } - #[api_version(2)] impl sp_domains::DomainsApi for Runtime { fn submit_bundle_unsigned( opaque_bundle: sp_domains::OpaqueBundle, ::Hash, DomainHeader, Balance>, diff --git a/crates/subspace-service/Cargo.toml b/crates/subspace-service/Cargo.toml index a5d6a1b322..e7b42ddfed 100644 --- a/crates/subspace-service/Cargo.toml +++ b/crates/subspace-service/Cargo.toml @@ -23,47 +23,47 @@ domain-runtime-primitives = { version = "0.1.0", path = "../../domains/primitive futures = "0.3.29" hex = "0.4.3" jsonrpsee = { version = "0.16.3", features = ["server"] } -pallet-transaction-payment-rpc = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +pallet-transaction-payment-rpc = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } parity-scale-codec = "3.6.5" parking_lot = "0.12.1" prometheus-client = "0.22.0" -sc-basic-authorship = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sc-chain-spec = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sc-client-api = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sc-consensus = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +sc-basic-authorship = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sc-chain-spec = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sc-client-api = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sc-consensus = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } sc-consensus-subspace = { version = "0.1.0", path = "../sc-consensus-subspace" } sc-consensus-subspace-rpc = { version = "0.1.0", path = "../sc-consensus-subspace-rpc" } -sc-consensus-slots = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sc-executor = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sc-network = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sc-network-sync = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sc-offchain = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +sc-consensus-slots = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sc-executor = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sc-network = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sc-network-sync = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sc-offchain = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } sc-proof-of-time = { version = "0.1.0", path = "../sc-proof-of-time" } -sc-rpc = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sc-rpc-api = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sc-rpc-spec-v2 = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sc-service = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1", default-features = false } +sc-rpc = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sc-rpc-api = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sc-rpc-spec-v2 = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sc-service = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c", default-features = false } sc-subspace-block-relay = { version = "0.1.0", path = "../sc-subspace-block-relay" } -sc-telemetry = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sc-tracing = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sc-transaction-pool = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sc-transaction-pool-api = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +sc-telemetry = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sc-tracing = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sc-transaction-pool = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sc-transaction-pool-api = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } schnorrkel = "0.9.1" -sp-api = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-blockchain = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-block-builder = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-consensus = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-consensus-slots = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +sp-api = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-blockchain = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-block-builder = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-consensus = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-consensus-slots = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } sp-consensus-subspace = { version = "0.1.0", path = "../sp-consensus-subspace" } -sp-core = { version = "21.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +sp-core = { version = "21.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } sp-domains = { version = "0.1.0", path = "../sp-domains" } sp-domains-fraud-proof = { version = "0.1.0", path = "../sp-domains-fraud-proof" } -sp-externalities = { version = "0.19.0", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +sp-externalities = { version = "0.19.0", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } sp-objects = { version = "0.1.0", path = "../sp-objects" } -sp-offchain = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-runtime = { version = "24.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-timestamp = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-transaction-pool = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +sp-offchain = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-runtime = { version = "24.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-timestamp = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-transaction-pool = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } static_assertions = "1.1.0" subspace-archiving = { version = "0.1.0", path = "../subspace-archiving" } subspace-core-primitives = { version = "0.1.0", path = "../subspace-core-primitives" } @@ -71,15 +71,15 @@ subspace-metrics = { version = "0.1.0", path = "../../shared/subspace-metrics" } subspace-networking = { version = "0.1.0", path = "../subspace-networking" } subspace-proof-of-space = { version = "0.1.0", path = "../subspace-proof-of-space" } subspace-runtime-primitives = { version = "0.1.0", path = "../subspace-runtime-primitives" } -substrate-frame-rpc-system = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -substrate-prometheus-endpoint = { git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +substrate-frame-rpc-system = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +substrate-prometheus-endpoint = { git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } thiserror = "1.0.48" tokio = { version = "1.34.0", features = ["sync"] } tracing = "0.1.37" -sp-session = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -frame-system-rpc-runtime-api = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -pallet-transaction-payment-rpc-runtime-api = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +sp-session = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +frame-system-rpc-runtime-api = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +pallet-transaction-payment-rpc-runtime-api = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } [features] default = [] diff --git a/crates/subspace-service/src/dsn.rs b/crates/subspace-service/src/dsn.rs index 7b6b763869..8c159e3146 100644 --- a/crates/subspace-service/src/dsn.rs +++ b/crates/subspace-service/src/dsn.rs @@ -1,12 +1,9 @@ use prometheus_client::registry::Registry; -use sc_client_api::AuxStore; -use sc_consensus_subspace::archiver::SegmentHeadersStore; use std::collections::HashSet; use std::fs; use std::num::NonZeroUsize; use std::path::PathBuf; use std::sync::Arc; -use subspace_core_primitives::{SegmentHeader, SegmentIndex}; use subspace_networking::libp2p::kad::Mode; use subspace_networking::libp2p::metrics::Metrics; use subspace_networking::libp2p::{identity, Multiaddr}; @@ -14,13 +11,11 @@ use subspace_networking::utils::strip_peer_id; use subspace_networking::{ CreationError, KademliaMode, KnownPeersManager, KnownPeersManagerConfig, KnownPeersManagerPersistenceError, Node, NodeRunner, PeerInfoProvider, - PieceByIndexRequestHandler, SegmentHeaderBySegmentIndexesRequestHandler, SegmentHeaderRequest, - SegmentHeaderResponse, + PieceByIndexRequestHandler, SegmentHeaderBySegmentIndexesRequestHandler, }; use thiserror::Error; -use tracing::{debug, error, trace}; +use tracing::{error, trace}; -const SEGMENT_HEADERS_NUMBER_LIMIT: u64 = 1000; /// Should be sufficient number of target connections for everyone, limits are higher const TARGET_CONNECTIONS: u32 = 15; @@ -78,28 +73,36 @@ pub struct DsnConfig { pub disable_bootstrap_on_start: bool, } -pub(crate) fn create_dsn_instance( +pub(crate) fn create_dsn_instance( dsn_protocol_version: String, dsn_config: DsnConfig, - segment_headers_store: SegmentHeadersStore, enable_metrics: bool, -) -> Result<(Node, NodeRunner<()>, Option), DsnConfigurationError> -where - AS: AuxStore + Sync + Send + 'static, -{ +) -> Result<(Node, NodeRunner<()>, Option), DsnConfigurationError> { trace!("Subspace networking starting."); let mut metric_registry = Registry::default(); let metrics = enable_metrics.then(|| Metrics::new(&mut metric_registry)); let networking_parameters_registry = { + // TODO: Make `base_path` point to `network` once we can clean up below migration code let path = dsn_config.base_path; + let network_path = path.join("network"); // TODO: Remove this in the future after enough upgrade time that this no longer exist if path.join("known_addresses_db").is_dir() { let _ = fs::remove_file(path.join("known_addresses_db")); } - let file_path = path.join("known_addresses.bin"); + if !network_path.is_dir() { + fs::create_dir(&network_path) + .map_err(|error| DsnConfigurationError::CreationError(CreationError::Io(error)))?; + } + if path.join("known_addresses.bin").is_dir() { + let _ = fs::rename( + path.join("known_addresses.bin"), + network_path.join("known_addresses.bin"), + ); + } + let file_path = network_path.join("known_addresses.bin"); KnownPeersManager::new(KnownPeersManagerConfig { path: Some(file_path.into_boxed_path()), @@ -129,56 +132,7 @@ where request_response_protocols: vec![ // We need to enable protocol to request pieces PieceByIndexRequestHandler::create(|_, _| async { None }), - SegmentHeaderBySegmentIndexesRequestHandler::create(move |_, req| { - let segment_indexes = match req { - SegmentHeaderRequest::SegmentIndexes { segment_indexes } => { - segment_indexes.clone() - } - SegmentHeaderRequest::LastSegmentHeaders { - segment_header_number, - } => { - let mut segment_headers_limit = *segment_header_number; - if *segment_header_number > SEGMENT_HEADERS_NUMBER_LIMIT { - debug!( - %segment_header_number, - "Segment header number exceeded the limit." - ); - - segment_headers_limit = SEGMENT_HEADERS_NUMBER_LIMIT; - } - - match segment_headers_store.max_segment_index() { - Some(max_segment_index) => { - // Several last segment indexes - (SegmentIndex::ZERO..=max_segment_index) - .rev() - .take(segment_headers_limit as usize) - .collect::>() - } - None => { - // Nothing yet - Vec::new() - } - } - } - }; - - let maybe_segment_headers = segment_indexes - .iter() - .map(|segment_index| segment_headers_store.get_segment_header(*segment_index)) - .collect::>>(); - - let result = match maybe_segment_headers { - Some(segment_headers) => Some(SegmentHeaderResponse { segment_headers }), - None => { - error!("Segment header collection contained empty segment headers."); - - None - } - }; - - async move { result } - }), + SegmentHeaderBySegmentIndexesRequestHandler::create(move |_, _| async move { None }), ], max_established_incoming_connections: dsn_config.max_in_connections, max_established_outgoing_connections: dsn_config.max_out_connections, diff --git a/crates/subspace-service/src/lib.rs b/crates/subspace-service/src/lib.rs index 147a7e1041..59d7fbd8e1 100644 --- a/crates/subspace-service/src/lib.rs +++ b/crates/subspace-service/src/lib.rs @@ -49,15 +49,22 @@ use sc_client_api::execution_extensions::ExtensionsFactory; use sc_client_api::{ AuxStore, Backend, BlockBackend, BlockchainEvents, ExecutorProvider, HeaderBackend, }; -use sc_consensus::{BasicQueue, DefaultImportQueue, ImportQueue, SharedBlockImport}; +use sc_consensus::{ + BasicQueue, BlockCheckParams, BlockImport, BlockImportParams, DefaultImportQueue, ImportQueue, + ImportResult, SharedBlockImport, +}; use sc_consensus_slots::SlotProportion; -use sc_consensus_subspace::archiver::{create_subspace_archiver, SegmentHeadersStore}; +use sc_consensus_subspace::archiver::{ + create_subspace_archiver, ArchivedSegmentNotification, SegmentHeadersStore, +}; +use sc_consensus_subspace::block_import::{BlockImportingNotification, SubspaceBlockImport}; use sc_consensus_subspace::notification::SubspaceNotificationStream; -use sc_consensus_subspace::verifier::{SubspaceVerifier, SubspaceVerifierOptions}; -use sc_consensus_subspace::{ - ArchivedSegmentNotification, BlockImportingNotification, NewSlotNotification, - RewardSigningNotification, SubspaceLink, SubspaceParams, SubspaceSyncOracle, +use sc_consensus_subspace::slot_worker::{ + NewSlotNotification, RewardSigningNotification, SubspaceSlotWorker, SubspaceSlotWorkerOptions, + SubspaceSyncOracle, }; +use sc_consensus_subspace::verifier::{SubspaceVerifier, SubspaceVerifierOptions}; +use sc_consensus_subspace::SubspaceLink; use sc_executor::{NativeElseWasmExecutor, NativeExecutionDispatch}; use sc_network::NetworkService; use sc_proof_of_time::source::gossip::pot_gossip_peers_set_config; @@ -154,6 +161,40 @@ pub enum Error { Other(Box), } +// Simple wrapper whose ony purpose is to convert error type +struct BlockImportWrapper(BI); + +#[async_trait::async_trait] +impl BlockImport for BlockImportWrapper +where + Block: BlockT, + BI: BlockImport> + + Send + + Sync, +{ + type Error = sp_consensus::Error; + + async fn check_block( + &self, + block: BlockCheckParams, + ) -> Result { + self.0 + .check_block(block) + .await + .map_err(|error| sp_consensus::Error::Other(error.into())) + } + + async fn import_block( + &mut self, + block: BlockImportParams, + ) -> Result { + self.0 + .import_block(block) + .await + .map_err(|error| sp_consensus::Error::Other(error.into())) + } +} + /// Subspace-like full client. pub type FullClient = sc_service::TFullClient>; @@ -434,9 +475,10 @@ where let kzg = tokio::task::block_in_place(|| Kzg::new(embedded_kzg_settings())); let client = Arc::new(client); + let client_info = client.info(); let pot_verifier = PotVerifier::new( - PotSeed::from_genesis(client.info().genesis_hash.as_ref(), pot_external_entropy), + PotSeed::from_genesis(client_info.genesis_hash.as_ref(), pot_external_entropy), POT_VERIFIER_CACHE_SIZE, ); @@ -465,18 +507,16 @@ where tokio::task::block_in_place(|| SegmentHeadersStore::new(client.clone())) .map_err(|error| ServiceError::Application(error.into()))?; - let (block_import, subspace_link) = sc_consensus_subspace::block_import::< - PosTable, - _, - _, - _, - _, - _, - >( - sc_consensus_subspace::slot_duration(&*client)?, + let chain_constants = client + .runtime_api() + .chain_constants(client_info.best_hash) + .map_err(|error| ServiceError::Application(error.into()))?; + + let subspace_link = SubspaceLink::new(chain_constants, kzg.clone()); + let block_import = SubspaceBlockImport::::new( client.clone(), client.clone(), - kzg.clone(), + subspace_link.clone(), { let client = client.clone(); @@ -486,7 +526,6 @@ where async move { let timestamp = sp_timestamp::InherentDataProvider::from_system_time(); - // TODO: Would be nice if the whole header was passed in here let parent_header = client .header(parent_hash)? .expect("Parent header must always exist when block is created; qed"); @@ -494,9 +533,7 @@ where let parent_block_number = parent_header.number; let subspace_inherents = - sp_consensus_subspace::inherents::InherentDataProvider::from_timestamp_and_slot_duration( - *timestamp, - subspace_link.slot_duration(), + sp_consensus_subspace::inherents::InherentDataProvider::new( subspace_link.segment_headers_for_block(parent_block_number + 1), ); @@ -506,10 +543,10 @@ where }, segment_headers_store.clone(), pot_verifier.clone(), - )?; + ); let sync_target_block_number = Arc::new(AtomicU32::new(0)); - let transaction_pool = crate::transaction_pool::new_full( + let transaction_pool = transaction_pool::new_full( config, &task_manager, client.clone(), @@ -518,6 +555,7 @@ where let verifier = SubspaceVerifier::::new(SubspaceVerifierOptions { client: client.clone(), + chain_constants, kzg, select_chain: select_chain.clone(), telemetry: telemetry.as_ref().map(|x| x.handle()), @@ -526,9 +564,9 @@ where sync_target_block_number: Arc::clone(&sync_target_block_number), is_authoring_blocks: config.role.is_authority(), pot_verifier: pot_verifier.clone(), - })?; + }); - let block_import = SharedBlockImport::new(block_import); + let block_import = SharedBlockImport::new(BlockImportWrapper(block_import)); let import_queue = BasicQueue::new( verifier, block_import.clone(), @@ -669,7 +707,6 @@ where let (node, mut node_runner, dsn_metrics_registry) = create_dsn_instance( dsn_protocol_version, dsn_config.clone(), - segment_headers_store.clone(), config.base.prometheus_config.is_some(), )?; @@ -932,65 +969,69 @@ where telemetry.as_ref().map(|x| x.handle()), ); - let subspace_config = SubspaceParams { - client: client.clone(), - select_chain: select_chain.clone(), - env: proposer_factory, - block_import, - sync_oracle: sync_oracle.clone(), - justification_sync_link: sync_service.clone(), - create_inherent_data_providers: { + let subspace_slot_worker = + SubspaceSlotWorker::::new(SubspaceSlotWorkerOptions { + client: client.clone(), + env: proposer_factory, + block_import, + sync_oracle: sync_oracle.clone(), + justification_sync_link: sync_service.clone(), + force_authoring: config.base.force_authoring, + backoff_authoring_blocks, + subspace_link: subspace_link.clone(), + segment_headers_store: segment_headers_store.clone(), + block_proposal_slot_portion, + max_block_proposal_slot_portion: None, + telemetry: telemetry.as_ref().map(|x| x.handle()), + offchain_tx_pool_factory, + pot_verifier, + }); + + let create_inherent_data_providers = { + let client = client.clone(); + let subspace_link = subspace_link.clone(); + + move |parent_hash, ()| { let client = client.clone(); let subspace_link = subspace_link.clone(); - move |parent_hash, ()| { - let client = client.clone(); - let subspace_link = subspace_link.clone(); - - async move { - let timestamp = sp_timestamp::InherentDataProvider::from_system_time(); + async move { + let timestamp = sp_timestamp::InherentDataProvider::from_system_time(); - // TODO: Would be nice if the whole header was passed in here - let parent_header = client - .header(parent_hash)? - .expect("Parent header must always exist when block is created; qed"); + // TODO: Would be nice if the whole header was passed in here + let parent_header = client + .header(parent_hash)? + .expect("Parent header must always exist when block is created; qed"); - let parent_block_number = parent_header.number; + let parent_block_number = parent_header.number; - let subspace_inherents = - sp_consensus_subspace::inherents::InherentDataProvider::from_timestamp_and_slot_duration( - *timestamp, - subspace_link.slot_duration(), - subspace_link.segment_headers_for_block(parent_block_number + 1), - ); + let subspace_inherents = + sp_consensus_subspace::inherents::InherentDataProvider::new( + subspace_link.segment_headers_for_block(parent_block_number + 1), + ); - Ok((subspace_inherents, timestamp)) - } + Ok((timestamp, subspace_inherents)) } - }, - force_authoring: config.base.force_authoring, - backoff_authoring_blocks, - subspace_link: subspace_link.clone(), - segment_headers_store: segment_headers_store.clone(), - block_proposal_slot_portion, - max_block_proposal_slot_portion: None, - telemetry: telemetry.as_ref().map(|x| x.handle()), - offchain_tx_pool_factory, - pot_verifier, - pot_slot_info_stream, + } }; - let subspace = - sc_consensus_subspace::start_subspace::( - subspace_config, - )?; + info!(target: "subspace", "🧑‍🌾 Starting Subspace Authorship worker"); + let slot_worker_task = sc_proof_of_time::start_slot_worker( + subspace_link.chain_constants().slot_duration(), + client.clone(), + select_chain.clone(), + subspace_slot_worker, + sync_oracle.clone(), + create_inherent_data_providers, + pot_slot_info_stream, + ); // Subspace authoring task is considered essential, i.e. if it fails we take down the // service with it. task_manager.spawn_essential_handle().spawn_blocking( "subspace-proposer", Some("block-authoring"), - subspace, + slot_worker_task, ); } diff --git a/crates/subspace-service/src/rpc.rs b/crates/subspace-service/src/rpc.rs index 1de37261ef..6b84a986c1 100644 --- a/crates/subspace-service/src/rpc.rs +++ b/crates/subspace-service/src/rpc.rs @@ -24,10 +24,10 @@ use jsonrpsee::RpcModule; use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApiServer}; use sc_client_api::{AuxStore, BlockBackend}; -use sc_consensus_subspace::archiver::SegmentHeadersStore; +use sc_consensus_subspace::archiver::{ArchivedSegmentNotification, SegmentHeadersStore}; use sc_consensus_subspace::notification::SubspaceNotificationStream; -use sc_consensus_subspace::{ - ArchivedSegmentNotification, NewSlotNotification, RewardSigningNotification, SubspaceSyncOracle, +use sc_consensus_subspace::slot_worker::{ + NewSlotNotification, RewardSigningNotification, SubspaceSyncOracle, }; use sc_consensus_subspace_rpc::{SubspaceRpc, SubspaceRpcApiServer, SubspaceRpcConfig}; use sc_rpc::SubscriptionTaskExecutor; diff --git a/crates/subspace-service/src/sync_from_dsn.rs b/crates/subspace-service/src/sync_from_dsn.rs index 95c667b326..b0a45848b9 100644 --- a/crates/subspace-service/src/sync_from_dsn.rs +++ b/crates/subspace-service/src/sync_from_dsn.rs @@ -40,6 +40,8 @@ const MIN_OFFLINE_PERIOD: Duration = Duration::from_secs(60); #[derive(Debug)] enum NotificationReason { NoImportedBlocks, + // TODO: Restore or remove connected peer later + #[allow(dead_code)] WentOnlineSubspace, WentOnlineSubstrate, } @@ -97,38 +99,38 @@ where async fn create_observer( network_service: &NetworkService::Hash>, - node: &Node, + _node: &Node, client: &Client, notifications_sender: mpsc::Sender, ) where Block: BlockT, Client: BlockchainEvents + Send + Sync + 'static, { - // Separate reactive observer for Subspace networking that is not a future - let _handler_id = node.on_num_established_peer_connections_change({ - // Assuming node is offline by default - let last_online = Atomic::new(None::); - let notifications_sender = notifications_sender.clone(); - - Arc::new(move |&new_connections| { - let is_online = new_connections > 0; - let was_online = last_online - .load(Ordering::AcqRel) - .map(|last_online| last_online.elapsed() < MIN_OFFLINE_PERIOD) - .unwrap_or_default(); - - if is_online && !was_online { - // Doesn't matter if sending failed here - let _ = notifications_sender - .clone() - .try_send(NotificationReason::WentOnlineSubspace); - } - - if is_online { - last_online.store(Some(Instant::now()), Ordering::Release); - } - }) - }); + // // Separate reactive observer for Subspace networking that is not a future + // let _handler_id = node.on_num_established_peer_connections_change({ + // // Assuming node is offline by default + // let last_online = Atomic::new(None::); + // let notifications_sender = notifications_sender.clone(); + // + // Arc::new(move |&new_connections| { + // let is_online = new_connections > 0; + // let was_online = last_online + // .load(Ordering::AcqRel) + // .map(|last_online| last_online.elapsed() < MIN_OFFLINE_PERIOD) + // .unwrap_or_default(); + // + // if is_online && !was_online { + // // Doesn't matter if sending failed here + // let _ = notifications_sender + // .clone() + // .try_send(NotificationReason::WentOnlineSubspace); + // } + // + // if is_online { + // last_online.store(Some(Instant::now()), Ordering::Release); + // } + // }) + // }); futures::select! { _ = create_imported_blocks_observer(client, notifications_sender.clone()).fuse() => { // Runs indefinitely diff --git a/crates/subspace-service/src/transaction_pool.rs b/crates/subspace-service/src/transaction_pool.rs index 58b601cac3..c872f2e3a0 100644 --- a/crates/subspace-service/src/transaction_pool.rs +++ b/crates/subspace-service/src/transaction_pool.rs @@ -186,58 +186,45 @@ where // If the transaction is `submit_bundle`, then extract the bundle // and check for equivocation. let runtime_api = client.runtime_api(); - let domains_api_version = runtime_api - .api_version::>(at) - .map_err(|err| { - TxPoolError::RuntimeApi(format!( - "Failed to get `DomainsApi` version for block {at:?}: {err:?}." - )) - })? - // safe to return default version as 1 since there will always be version 1. - .unwrap_or(1); - // TODO: this is keep gemini-3g compatible. Remove before a new network launch. - if domains_api_version >= 2 { - let maybe_opaque_bundle = runtime_api - .extract_bundle(at, uxt) - .map_err(|err| TxPoolError::RuntimeApi(err.to_string()))?; - if let Some(opaque_bundle) = maybe_opaque_bundle { - let slot = opaque_bundle - .sealed_header - .header - .proof_of_election - .slot_number - .into(); - - let slot_now = if diff_in_blocks > 0 { - slot + Slot::from( - u64::from(diff_in_blocks) * slot_probability.1 / slot_probability.0, - ) - } else { - slot - }; - - let maybe_equivocation_fraud_proof = check_equivocation::<_, Block, _>( - &client, - slot_now, - opaque_bundle.sealed_header, - )?; - - if let Some(equivocation_fraud_proof) = maybe_equivocation_fraud_proof { - let sent_result = - fraud_proof_submit_sink.send(equivocation_fraud_proof); - if let Err(err) = sent_result { - error!( - target: "consensus-fraud-proof-sender", - "failed to send fraud proof to be submitted: {err:?}" - ); - } - - return Err(TxPoolError::Pool( - sc_transaction_pool_api::error::Error::InvalidTransaction( - InvalidTransactionCode::BundleEquivocation.into(), - ), - )); + let maybe_opaque_bundle = runtime_api + .extract_bundle(at, uxt) + .map_err(|err| TxPoolError::RuntimeApi(err.to_string()))?; + if let Some(opaque_bundle) = maybe_opaque_bundle { + let slot = opaque_bundle + .sealed_header + .header + .proof_of_election + .slot_number + .into(); + + let slot_now = if diff_in_blocks > 0 { + slot + Slot::from( + u64::from(diff_in_blocks) * slot_probability.1 / slot_probability.0, + ) + } else { + slot + }; + + let maybe_equivocation_fraud_proof = check_equivocation::<_, Block, _>( + &client, + slot_now, + opaque_bundle.sealed_header, + )?; + + if let Some(equivocation_fraud_proof) = maybe_equivocation_fraud_proof { + let sent_result = fraud_proof_submit_sink.send(equivocation_fraud_proof); + if let Err(err) = sent_result { + error!( + target: "consensus-fraud-proof-sender", + "failed to send fraud proof to be submitted: {err:?}" + ); } + + return Err(TxPoolError::Pool( + sc_transaction_pool_api::error::Error::InvalidTransaction( + InvalidTransactionCode::BundleEquivocation.into(), + ), + )); } } } diff --git a/crates/subspace-verification/Cargo.toml b/crates/subspace-verification/Cargo.toml index 801f98a82b..62cd1a40a3 100644 --- a/crates/subspace-verification/Cargo.toml +++ b/crates/subspace-verification/Cargo.toml @@ -18,7 +18,7 @@ include = [ [dependencies] codec = { package = "parity-scale-codec", version = "3.6.5", default-features = false } schnorrkel = { version = "0.9.1", default-features = false, features = ["u64_backend"] } -sp-arithmetic = { version = "16.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +sp-arithmetic = { version = "16.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } subspace-archiving = { version = "0.1.0", path = "../subspace-archiving", default-features = false } subspace-core-primitives = { version = "0.1.0", path = "../subspace-core-primitives", default-features = false } subspace-proof-of-space = { version = "0.1.0", path = "../subspace-proof-of-space", default-features = false } diff --git a/domains/client/block-builder/Cargo.toml b/domains/client/block-builder/Cargo.toml index 7ec5c41120..4786cd6757 100644 --- a/domains/client/block-builder/Cargo.toml +++ b/domains/client/block-builder/Cargo.toml @@ -14,15 +14,15 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] codec = { package = "parity-scale-codec", version = "3.6.5", features = ["derive"] } -sc-client-api = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-api = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-blockchain = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-block-builder = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-core = { version = "21.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-inherents = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-runtime = { version = "24.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-state-machine = { version = "0.28.0", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +sc-client-api = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-api = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-blockchain = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-block-builder = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-core = { version = "21.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-inherents = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-runtime = { version = "24.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-state-machine = { version = "0.28.0", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } tracing = "0.1.37" [dev-dependencies] -substrate-test-runtime-client = { version = "2.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +substrate-test-runtime-client = { version = "2.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } diff --git a/domains/client/block-preprocessor/Cargo.toml b/domains/client/block-preprocessor/Cargo.toml index 87de76ab7e..b40b02079a 100644 --- a/domains/client/block-preprocessor/Cargo.toml +++ b/domains/client/block-preprocessor/Cargo.toml @@ -15,23 +15,23 @@ include = [ async-trait = { version = "0.1.57" } codec = { package = "parity-scale-codec", version = "3.6.5", features = ["derive"] } domain-runtime-primitives = { version = "0.1.0", path = "../../primitives/runtime" } -sc-client-api = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sc-executor = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sc-executor-common = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-api = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-blockchain = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-core = { version = "21.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +sc-client-api = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sc-executor = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sc-executor-common = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-api = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-blockchain = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-core = { version = "21.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } sp-domains = { version = "0.1.0", path = "../../../crates/sp-domains" } sp-executive = { version = "0.1.0", path = "../../primitives/executive" } -sp-inherents = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +sp-inherents = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } sp-messenger = { version = "0.1.0", path = "../../primitives/messenger" } -sp-runtime = { version = "24.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-state-machine = { version = "0.28.0", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-timestamp = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +sp-runtime = { version = "24.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-state-machine = { version = "0.28.0", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-timestamp = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } subspace-core-primitives = { version = "0.1.0", path = "../../../crates/subspace-core-primitives" } subspace-runtime-primitives = { version = "0.1.0", path = "../../../crates/subspace-runtime-primitives" } tracing = "0.1.37" [dev-dependencies] -sp-keyring = { version = "24.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-state-machine = { version = "0.28.0", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +sp-keyring = { version = "24.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-state-machine = { version = "0.28.0", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } diff --git a/domains/client/block-preprocessor/src/lib.rs b/domains/client/block-preprocessor/src/lib.rs index f5b255dac8..01bb98352e 100644 --- a/domains/client/block-preprocessor/src/lib.rs +++ b/domains/client/block-preprocessor/src/lib.rs @@ -25,11 +25,12 @@ use sp_blockchain::HeaderBackend; use sp_core::H256; use sp_domains::extrinsics::deduplicate_and_shuffle_extrinsics; use sp_domains::{ - DomainId, DomainsApi, ExecutionReceipt, HeaderHashingFor, InboxedBundle, InvalidBundleType, - OpaqueBundle, OpaqueBundles, ReceiptValidity, + DomainId, DomainsApi, ExecutionReceipt, ExtrinsicDigest, HeaderHashingFor, InboxedBundle, + InvalidBundleType, OpaqueBundle, OpaqueBundles, ReceiptValidity, }; use sp_messenger::MessengerApi; use sp_runtime::traits::{Block as BlockT, NumberFor}; +use sp_state_machine::LayoutV1; use std::collections::VecDeque; use std::marker::PhantomData; use std::sync::Arc; @@ -219,16 +220,9 @@ where .map(|(signer, tx)| { ( signer.clone(), - HeaderHashingFor::::hash_of(tx), - // TODO: enable before the new network - // NOTE: we should using the `ExtrinsicDigest` to calculate the `bundle_digest` - // to keep consistency with the `domain_block_extrinsic_root` fraud proof, but - // this is incompatible with Gemini-3g network because operators who have this - // change will produce a different ER than those who don't have, cause the ER - // derivation become non-deterministic. - // ExtrinsicDigest::new::>>( - // tx.encode(), - // ), + ExtrinsicDigest::new::>>( + tx.encode(), + ), ) }) .collect(); diff --git a/domains/client/consensus-relay-chain/Cargo.toml b/domains/client/consensus-relay-chain/Cargo.toml index c7619080bf..64ffccc61e 100644 --- a/domains/client/consensus-relay-chain/Cargo.toml +++ b/domains/client/consensus-relay-chain/Cargo.toml @@ -7,9 +7,9 @@ edition = "2021" [dependencies] async-trait = "0.1.73" -sc-consensus = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-blockchain = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-consensus = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-core = { version = "21.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-runtime = { version = "24.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -substrate-prometheus-endpoint = { git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +sc-consensus = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-blockchain = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-consensus = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-core = { version = "21.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-runtime = { version = "24.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +substrate-prometheus-endpoint = { git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } diff --git a/domains/client/cross-domain-message-gossip/Cargo.toml b/domains/client/cross-domain-message-gossip/Cargo.toml index 3cc8534e2a..4014ef7055 100644 --- a/domains/client/cross-domain-message-gossip/Cargo.toml +++ b/domains/client/cross-domain-message-gossip/Cargo.toml @@ -15,12 +15,12 @@ include = [ futures = "0.3.29" parity-scale-codec = { version = "3.6.5", features = ["derive"] } parking_lot = "0.12.1" -sc-network = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sc-network-gossip = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sc-transaction-pool-api = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sc-utils = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-blockchain = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-core = { version = "21.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +sc-network = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sc-network-gossip = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sc-transaction-pool-api = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sc-utils = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-blockchain = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-core = { version = "21.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } sp-messenger = { version = "0.1.0", default-features = false, path = "../../primitives/messenger" } -sp-runtime = { version = "24.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +sp-runtime = { version = "24.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } tracing = "0.1.37" diff --git a/domains/client/cross-domain-message-gossip/src/gossip_worker.rs b/domains/client/cross-domain-message-gossip/src/gossip_worker.rs index a5e7ee71cb..1a52c19166 100644 --- a/domains/client/cross-domain-message-gossip/src/gossip_worker.rs +++ b/domains/client/cross-domain-message-gossip/src/gossip_worker.rs @@ -2,7 +2,7 @@ use futures::{FutureExt, StreamExt}; use parity_scale_codec::{Decode, Encode}; use parking_lot::{Mutex, RwLock}; use sc_network::config::NonDefaultSetConfig; -use sc_network::PeerId; +use sc_network::{NetworkPeers, PeerId}; use sc_network_gossip::{ GossipEngine, MessageIntent, Syncing as GossipSyncing, ValidationResult, Validator, ValidatorContext, @@ -12,13 +12,21 @@ use sp_core::twox_256; use sp_messenger::messages::ChainId; use sp_runtime::traits::{Block as BlockT, Hash as HashT, Header as HeaderT}; use std::collections::{BTreeMap, HashSet}; +use std::future::poll_fn; +use std::pin::pin; use std::sync::Arc; const LOG_TARGET: &str = "cross_chain_gossip_worker"; const PROTOCOL_NAME: &str = "/subspace/cross-chain-messages"; +/// Encoded message with sender info if available. +pub struct ChainTxPoolMsg { + pub encoded_data: Vec, + pub maybe_peer: Option, +} + /// Unbounded sender to send encoded ext to listeners. -pub type ChainTxPoolSink = TracingUnboundedSender>; +pub type ChainTxPoolSink = TracingUnboundedSender; type MessageHash = [u8; 32]; /// A cross chain message with encoded data. @@ -63,7 +71,7 @@ impl GossipWorkerBuilder { self, network: Network, sync: Arc, - ) -> GossipWorker + ) -> GossipWorker where Block: BlockT, Network: sc_network_gossip::Network + Send + Sync + Clone + 'static, @@ -75,7 +83,7 @@ impl GossipWorkerBuilder { .. } = self; - let gossip_validator = Arc::new(GossipValidator::default()); + let gossip_validator = Arc::new(GossipValidator::new(network.clone())); let gossip_engine = Arc::new(Mutex::new(GossipEngine::new( network, sync, @@ -95,9 +103,9 @@ impl GossipWorkerBuilder { /// Gossip worker to gossip incoming and outgoing messages to other peers. /// Also, streams the decoded extrinsics to destination chain tx pool if available. -pub struct GossipWorker { +pub struct GossipWorker { gossip_engine: Arc>>, - gossip_validator: Arc, + gossip_validator: Arc>, gossip_msg_stream: TracingUnboundedReceiver, chain_tx_pool_sinks: BTreeMap, } @@ -114,38 +122,38 @@ fn topic() -> Block::Hash { <::Hashing as HashT>::hash(b"cross-chain-messages") } -impl GossipWorker { +impl GossipWorker { /// Starts the Gossip message worker. pub async fn run(mut self) { - let mut incoming_cross_chain_messages = Box::pin( - self.gossip_engine - .lock() - .messages_for(topic::()) - .filter_map(|notification| async move { - Message::decode(&mut ¬ification.message[..]).ok() - }), - ); + let incoming_cross_chain_messages = pin!(self + .gossip_engine + .lock() + .messages_for(topic::()) + .filter_map(|notification| async move { + Message::decode(&mut ¬ification.message[..]) + .ok() + .map(|msg| (notification.sender, msg)) + })); + let mut incoming_cross_chain_messages = incoming_cross_chain_messages.fuse(); loop { let engine = self.gossip_engine.clone(); - let gossip_engine = futures::future::poll_fn(|cx| engine.lock().poll_unpin(cx)); + let mut gossip_engine = poll_fn(|cx| engine.lock().poll_unpin(cx)).fuse(); futures::select! { - cross_chain_message = incoming_cross_chain_messages.next().fuse() => { - if let Some(msg) = cross_chain_message { + cross_chain_message = incoming_cross_chain_messages.next() => { + if let Some((maybe_peer, msg)) = cross_chain_message { tracing::debug!(target: LOG_TARGET, "Incoming cross chain message for chain from Network: {:?}", msg.chain_id); - self.handle_cross_chain_message(msg); + self.handle_cross_chain_message(msg, maybe_peer); } }, - cross_chain_message = self.gossip_msg_stream.next().fuse() => { - if let Some(msg) = cross_chain_message { - tracing::debug!(target: LOG_TARGET, "Incoming cross chain message for chain from Relayer: {:?}", msg.chain_id); - self.handle_cross_chain_message(msg); - } + msg = self.gossip_msg_stream.select_next_some() => { + tracing::debug!(target: LOG_TARGET, "Incoming cross chain message for chain from Relayer: {:?}", msg.chain_id); + self.handle_cross_chain_message(msg, None); } - _ = gossip_engine.fuse() => { + _ = gossip_engine => { tracing::error!(target: LOG_TARGET, "Gossip engine has terminated."); return; } @@ -153,7 +161,7 @@ impl GossipWorker { } } - fn handle_cross_chain_message(&mut self, msg: Message) { + fn handle_cross_chain_message(&mut self, msg: Message, maybe_peer: Option) { // mark and rebroadcast message let encoded_msg = msg.encode(); self.gossip_validator.note_broadcast(&encoded_msg); @@ -171,7 +179,14 @@ impl GossipWorker { }; // send the message to the open and ready channel - if !sink.is_closed() && sink.unbounded_send(encoded_data).is_ok() { + if !sink.is_closed() + && sink + .unbounded_send(ChainTxPoolMsg { + encoded_data, + maybe_peer, + }) + .is_ok() + { return; } @@ -187,12 +202,20 @@ impl GossipWorker { } /// Gossip validator to retain or clean up Gossiped messages. -#[derive(Debug, Default)] -struct GossipValidator { +#[derive(Debug)] +struct GossipValidator { + network: Network, should_broadcast: RwLock>, } -impl GossipValidator { +impl GossipValidator { + fn new(network: Network) -> Self { + Self { + network, + should_broadcast: Default::default(), + } + } + fn note_broadcast(&self, msg: &[u8]) { let msg_hash = twox_256(msg); let mut msg_set = self.should_broadcast.write(); @@ -212,16 +235,23 @@ impl GossipValidator { } } -impl Validator for GossipValidator { +impl Validator for GossipValidator +where + Block: BlockT, + Network: NetworkPeers + Send + Sync + 'static, +{ fn validate( &self, _context: &mut dyn ValidatorContext, - _sender: &PeerId, + sender: &PeerId, mut data: &[u8], ) -> ValidationResult { match Message::decode(&mut data) { Ok(_) => ValidationResult::ProcessAndKeep(topic::()), - Err(_) => ValidationResult::Discard, + Err(_) => { + self.network.report_peer(*sender, rep::GOSSIP_NOT_DECODABLE); + ValidationResult::Discard + } } } @@ -242,3 +272,11 @@ impl Validator for GossipValidator { }) } } + +pub(crate) mod rep { + use sc_network::ReputationChange; + + /// Reputation change when a peer sends us a gossip message that can't be decoded. + pub(crate) const GOSSIP_NOT_DECODABLE: ReputationChange = + ReputationChange::new_fatal("Cross chain message: not decodable"); +} diff --git a/domains/client/cross-domain-message-gossip/src/lib.rs b/domains/client/cross-domain-message-gossip/src/lib.rs index 56ccfc93e2..4d6f6f2501 100644 --- a/domains/client/cross-domain-message-gossip/src/lib.rs +++ b/domains/client/cross-domain-message-gossip/src/lib.rs @@ -4,6 +4,7 @@ mod gossip_worker; mod message_listener; pub use gossip_worker::{ - cdm_gossip_peers_set_config, ChainTxPoolSink, GossipWorker, GossipWorkerBuilder, Message, + cdm_gossip_peers_set_config, ChainTxPoolMsg, ChainTxPoolSink, GossipWorker, + GossipWorkerBuilder, Message, }; pub use message_listener::start_cross_chain_message_listener; diff --git a/domains/client/cross-domain-message-gossip/src/message_listener.rs b/domains/client/cross-domain-message-gossip/src/message_listener.rs index 4ac4be88e9..707fe5d7d8 100644 --- a/domains/client/cross-domain-message-gossip/src/message_listener.rs +++ b/domains/client/cross-domain-message-gossip/src/message_listener.rs @@ -1,4 +1,6 @@ +use crate::ChainTxPoolMsg; use futures::{Stream, StreamExt}; +use sc_network::NetworkPeers; use sc_transaction_pool_api::{TransactionPool, TransactionSource}; use sp_blockchain::HeaderBackend; use sp_messenger::messages::ChainId; @@ -12,15 +14,17 @@ const LOG_TARGET: &str = "domain_message_listener"; type BlockOf = ::Block; type ExtrinsicOf = <::Block as BlockT>::Extrinsic; -pub async fn start_cross_chain_message_listener( +pub async fn start_cross_chain_message_listener( chain_id: ChainId, client: Arc, tx_pool: Arc, + network: Arc, mut listener: TxnListener, ) where TxPool: TransactionPool + 'static, Client: HeaderBackend>, - TxnListener: Stream> + Unpin, + TxnListener: Stream + Unpin, + CNetwork: NetworkPeers, { tracing::info!( target: LOG_TARGET, @@ -28,21 +32,25 @@ pub async fn start_cross_chain_message_listener( chain_id ); - while let Some(encoded_ext) = listener.next().await { + while let Some(msg) = listener.next().await { tracing::debug!( target: LOG_TARGET, "Extrinsic received for Chain: {:?}", chain_id, ); - let ext = match ExtrinsicOf::::decode(&mut encoded_ext.as_ref()) { + let ext = match ExtrinsicOf::::decode(&mut msg.encoded_data.as_ref()) { Ok(ext) => ext, Err(_) => { - tracing::error!( - target: LOG_TARGET, - "Failed to decode extrinsic: {:?}", - encoded_ext - ); + if let Some(peer_id) = msg.maybe_peer { + network.report_peer(peer_id, crate::gossip_worker::rep::GOSSIP_NOT_DECODABLE); + } else { + tracing::error!( + target: LOG_TARGET, + "Failed to decode extrinsic from unknown sender: {:?}", + msg.encoded_data + ); + } continue; } }; diff --git a/domains/client/domain-operator/Cargo.toml b/domains/client/domain-operator/Cargo.toml index 3cd5ff80a6..f0923ae2f6 100644 --- a/domains/client/domain-operator/Cargo.toml +++ b/domains/client/domain-operator/Cargo.toml @@ -12,28 +12,28 @@ domain-runtime-primitives = { version = "0.1.0", path = "../../primitives/runtim futures = "0.3.29" futures-timer = "3.0.1" parking_lot = "0.12.1" -sc-client-api = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sc-consensus = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sc-transaction-pool = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sc-transaction-pool-api = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sc-utils = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-api = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-blockchain = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-block-builder = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-consensus = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-consensus-slots = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-core = { version = "21.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +sc-client-api = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sc-consensus = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sc-transaction-pool = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sc-transaction-pool-api = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sc-utils = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-api = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-blockchain = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-block-builder = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-consensus = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-consensus-slots = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-core = { version = "21.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } sp-domains = { version = "0.1.0", path = "../../../crates/sp-domains" } sp-domains-fraud-proof = { version = "0.1.0", path = "../../../crates/sp-domains-fraud-proof" } sp-domain-digests = { version = "0.1.0", path = "../../primitives/digests" } -sp-inherents = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-keystore = { version = "0.27.0", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +sp-inherents = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-keystore = { version = "0.27.0", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } sp-messenger = { version = "0.1.0", path = "../../primitives/messenger" } -sp-runtime = { version = "24.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-state-machine = { version = "0.28.0", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-transaction-pool = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-trie = { version = "22.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-weights = { version = "20.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +sp-runtime = { version = "24.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-state-machine = { version = "0.28.0", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-transaction-pool = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-trie = { version = "22.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-weights = { version = "20.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } subspace-core-primitives = { version = "0.1.0", path = "../../../crates/subspace-core-primitives" } subspace-runtime-primitives = { version = "0.1.0", path = "../../../crates/subspace-runtime-primitives" } tracing = "0.1.37" @@ -44,15 +44,15 @@ tokio = { version = "1.34.0", features = ["macros"] } domain-test-service = { version = "0.1.0", path = "../../test/service" } domain-test-primitives = { version = "0.1.0", path = "../../test/primitives" } evm-domain-test-runtime = { version = "0.1.0", path = "../../test/runtime/evm" } -frame-system = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -pallet-balances = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +frame-system = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +pallet-balances = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } pallet-domains = { version = "0.1.0", path = "../../../crates/pallet-domains" } -pallet-timestamp = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sc-cli = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1", default-features = false } -sc-service = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1", default-features = false } -sc-transaction-pool = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-state-machine = { version = "0.28.0", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +pallet-timestamp = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sc-cli = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c", default-features = false } +sc-service = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c", default-features = false } +sc-transaction-pool = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-state-machine = { version = "0.28.0", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } subspace-test-runtime = { version = "0.1.0", path = "../../../test/subspace-test-runtime" } subspace-test-service = { version = "0.1.0", path = "../../../test/subspace-test-service" } -substrate-test-runtime-client = { version = "2.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +substrate-test-runtime-client = { version = "2.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } tempfile = "3.8.0" diff --git a/domains/client/domain-operator/src/aux_schema.rs b/domains/client/domain-operator/src/aux_schema.rs index 7bc874aae2..a5f82f1250 100644 --- a/domains/client/domain-operator/src/aux_schema.rs +++ b/domains/client/domain-operator/src/aux_schema.rs @@ -312,6 +312,11 @@ where let bad_receipt_hashes_key = (BAD_RECEIPT_HASHES, bad_receipt_number).encode(); let mut bad_receipt_hashes: Vec = load_decode(backend, bad_receipt_hashes_key.as_slice())?.unwrap_or_default(); + // Return early if the bad ER is already tracked + if bad_receipt_hashes.contains(&bad_receipt_hash) { + return Ok(()); + } + bad_receipt_hashes.push(bad_receipt_hash); let mut to_insert = vec![ diff --git a/domains/client/domain-operator/src/bundle_processor.rs b/domains/client/domain-operator/src/bundle_processor.rs index dd72e291b1..44e41ba427 100644 --- a/domains/client/domain-operator/src/bundle_processor.rs +++ b/domains/client/domain-operator/src/bundle_processor.rs @@ -6,7 +6,7 @@ use domain_block_preprocessor::DomainBlockPreprocessor; use domain_runtime_primitives::DomainCoreApi; use sc_client_api::{AuxStore, BlockBackend, Finalizer, ProofProvider}; use sc_consensus::{BlockImportParams, ForkChoiceStrategy, StateAction}; -use sp_api::{ApiExt, NumberFor, ProvideRuntimeApi}; +use sp_api::{NumberFor, ProvideRuntimeApi}; use sp_blockchain::{HeaderBackend, HeaderMetadata}; use sp_consensus::BlockOrigin; use sp_core::traits::CodeExecutor; @@ -189,6 +189,12 @@ where ) -> sp_blockchain::Result<()> { let (consensus_block_hash, consensus_block_number, is_new_best) = consensus_block_info; + // Skip processing the blocks of the non-canonical chain, these blocks will be processed if + // the chain becomes canonical later + if !is_new_best { + return Ok(()); + } + tracing::debug!( "Processing consensus block #{consensus_block_number},{consensus_block_hash}" ); @@ -289,6 +295,18 @@ where head_receipt_number, )?; + // Check the consensus runtime version before submitting fraud proof. + // Even the consensus block doesn't contains bundle it may still contains + // fraud proof, thus we need to call `check_state_transition` to remove the + // bad ER info that targetted by the potential fraud proof + self.domain_receipts_checker + .check_state_transition(consensus_block_hash)?; + + // Try submit fraud proof for the previous detected bad ER + self.domain_receipts_checker + .submit_fraud_proof(consensus_block_hash) + .await?; + return Ok(None); }; @@ -318,24 +336,13 @@ where ); let block_execution_took = start.elapsed().as_millis().saturating_sub(preprocess_took); - let domain_core_api_version = self + + let reference_block_execution_duration_ms = self .client .runtime_api() - .api_version::>(domain_block_result.header_hash)? - // safe to return default version as 1 since there will always be version 1. - .unwrap_or(1); - let reference_block_execution_duration_ms = if domain_core_api_version >= 2 { - self.client - .runtime_api() - .block_weight(domain_block_result.header_hash)? - .ref_time() - / WEIGHT_REF_TIME_PER_MILLIS - } else { - // TODO: this is used to keep compatible with the gemini-3g network, remove this - // before the next network - // 2000ms is the maximum compute time set in the max domain block weight - 2000 - }; + .block_weight(domain_block_result.header_hash)? + .ref_time() + / WEIGHT_REF_TIME_PER_MILLIS; if block_execution_took >= slow_domain_block_execution_threshold(reference_block_execution_duration_ms).into() { @@ -354,24 +361,13 @@ where )?; // Check the consensus runtime version before checking bad ER and submit fraud proof. - // - // TODO: this is used to keep compatible with the gemini-3g network, because some necessary - // runtime API are introduced in `#[api_version(2)]`, remove this before the next network - let domains_api_version = self - .consensus_client - .runtime_api() - .api_version::>(consensus_block_hash)? - // safe to return default version as 1 since there will always be version 1. - .unwrap_or(1); - if domains_api_version >= 2 { - // TODO: Remove as ReceiptsChecker has been superseded by ReceiptValidator in block-preprocessor. - self.domain_receipts_checker - .check_state_transition(consensus_block_hash)?; + // TODO: Remove as ReceiptsChecker has been superseded by ReceiptValidator in block-preprocessor. + self.domain_receipts_checker + .check_state_transition(consensus_block_hash)?; - self.domain_receipts_checker - .submit_fraud_proof(consensus_block_hash) - .await?; - } + self.domain_receipts_checker + .submit_fraud_proof(consensus_block_hash) + .await?; let post_block_execution_took = start .elapsed() diff --git a/domains/client/domain-operator/src/domain_block_processor.rs b/domains/client/domain-operator/src/domain_block_processor.rs index 8445368fe8..5f923567ed 100644 --- a/domains/client/domain-operator/src/domain_block_processor.rs +++ b/domains/client/domain-operator/src/domain_block_processor.rs @@ -25,7 +25,7 @@ use sp_domains_fraud_proof::FraudProofApi; use sp_runtime::traits::{Block as BlockT, Header as HeaderT, One, Zero}; use sp_runtime::Digest; use std::cmp::Ordering; -use std::collections::VecDeque; +use std::collections::{HashSet, VecDeque}; use std::sync::Arc; struct DomainBlockBuildResult @@ -781,12 +781,18 @@ where receipts: Vec>, fraud_proofs: Vec, CBlock::Hash, Block::Header>>, ) -> Result<(), sp_blockchain::Error> { + let mut checked_receipt = HashSet::new(); let mut bad_receipts_to_write = vec![]; for execution_receipt in receipts.iter() { + let receipt_hash = execution_receipt.hash::>(); + // Skip check for genesis receipt as it is generated on the domain instantiation by // the consensus chain. - if execution_receipt.domain_block_number.is_zero() { + if execution_receipt.domain_block_number.is_zero() + // Skip check if the same receipt is already checked + || !checked_receipt.insert(receipt_hash) + { continue; } @@ -806,7 +812,7 @@ where { bad_receipts_to_write.push(( execution_receipt.consensus_block_number, - execution_receipt.hash::>(), + receipt_hash, receipt_mismatch_info, )); @@ -818,7 +824,7 @@ where { bad_receipts_to_write.push(( execution_receipt.consensus_block_number, - execution_receipt.hash::>(), + receipt_hash, ReceiptMismatchInfo::DomainExtrinsicsRoot { consensus_block_hash, }, @@ -832,7 +838,7 @@ where ) { bad_receipts_to_write.push(( execution_receipt.consensus_block_number, - execution_receipt.hash::>(), + receipt_hash, (trace_mismatch_index, consensus_block_hash).into(), )); continue; @@ -841,7 +847,7 @@ where if execution_receipt.total_rewards != local_receipt.total_rewards { bad_receipts_to_write.push(( execution_receipt.consensus_block_number, - execution_receipt.hash::>(), + receipt_hash, ReceiptMismatchInfo::TotalRewards { consensus_block_hash, }, @@ -851,7 +857,7 @@ where if execution_receipt.domain_block_hash != local_receipt.domain_block_hash { bad_receipts_to_write.push(( execution_receipt.consensus_block_number, - execution_receipt.hash::>(), + receipt_hash, ReceiptMismatchInfo::DomainBlockHash { consensus_block_hash, }, diff --git a/domains/client/domain-operator/src/domain_worker_starter.rs b/domains/client/domain-operator/src/domain_worker_starter.rs index 10933e695e..1a9fab1cc0 100644 --- a/domains/client/domain-operator/src/domain_worker_starter.rs +++ b/domains/client/domain-operator/src/domain_worker_starter.rs @@ -36,6 +36,7 @@ use sp_domains_fraud_proof::FraudProofApi; use sp_messenger::MessengerApi; use sp_runtime::traits::NumberFor; use sp_transaction_pool::runtime_api::TaggedTransactionQueue; +use std::pin::pin; use std::sync::Arc; use subspace_runtime_primitives::Balance; use tracing::{info, Instrument}; @@ -138,8 +139,8 @@ pub(super) async fn start_worker< .boxed() } }; - let mut new_slot_notification_stream = Box::pin(new_slot_notification_stream); - let mut acknowledgement_sender_stream = Box::pin(acknowledgement_sender_stream); + let mut new_slot_notification_stream = pin!(new_slot_notification_stream); + let mut acknowledgement_sender_stream = pin!(acknowledgement_sender_stream); loop { tokio::select! { // Ensure any new slot/block import must handle first before the `acknowledgement_sender_stream` diff --git a/domains/client/domain-operator/src/tests.rs b/domains/client/domain-operator/src/tests.rs index dc968d41e4..42bd86c90b 100644 --- a/domains/client/domain-operator/src/tests.rs +++ b/domains/client/domain-operator/src/tests.rs @@ -131,24 +131,41 @@ async fn test_domain_chain_fork_choice() { .await .unwrap(); - // Fork B produce a consenus block that contains bundles thus derive a domain block let mut alice_import_notification_stream = alice.client.every_import_notification_stream(); + + // Fork B produce a consenus block that contains bundles let (slot, bundle) = ferdie.produce_slot_and_wait_for_bundle_submission().await; assert!(bundle.is_some()); - ferdie + let fork_b_block_hash = ferdie .produce_block_with_slot_at(slot, common_consensus_hash, None) .await .unwrap(); - // Because the new domain block is in a stale fork thus we need to use `every_import_notification_stream` - let new_domain_block = alice_import_notification_stream.next().await.unwrap(); - assert_eq!(*new_domain_block.header.number(), 4); + // Fork B is still in the non-canonical fork thus the consensus block and bundle + // won't be processed + assert!(alice_import_notification_stream.try_recv().is_err()); // The consensus fork A is still the best fork, because fork A don't derive any new // domain block thus the best domain block is still #3 assert_eq!(ferdie.client.info().best_hash, fork_a_block_hash); assert_eq!(alice.client.info().best_number, 3); assert_eq!(alice.client.info().best_hash, domain_hash_3); + + // Produce one more consensus block on fork B to make it the best fork + let (slot, bundle) = ferdie.produce_slot_and_wait_for_bundle_submission().await; + assert!(bundle.is_some()); + let fork_b_block_hash = ferdie + .produce_block_with_slot_at(slot, fork_b_block_hash, Some(vec![])) + .await + .unwrap(); + assert_eq!(ferdie.client.info().best_hash, fork_b_block_hash); + + // It should also trigger the operator to processe consensus blocks at fork B + // thus produce more domain blocks + let domain_block_4 = alice_import_notification_stream.next().await.unwrap(); + assert_eq!(*domain_block_4.header.number(), 4); + assert_eq!(alice.client.info().best_number, 4); + assert_eq!(alice.client.info().best_hash, domain_block_4.header.hash()); } #[tokio::test(flavor = "multi_thread")] @@ -1531,11 +1548,7 @@ async fn test_invalid_domain_block_hash_proof_creation() { .is_none()); } -// Disable because the `bundle_digest` value used in the ER is inconsistent with the value -// used in the fraud proof, the fix is not deploy due to incompatible with the Gemini-3g -// TODO: enable once the fix is deployed #[tokio::test(flavor = "multi_thread")] -#[ignore] async fn test_invalid_domain_extrinsics_root_proof_creation() { let directory = TempDir::new().expect("Must be able to create temporary directory"); @@ -1668,12 +1681,7 @@ async fn test_invalid_domain_extrinsics_root_proof_creation() { .is_none()); } -// Disable because the `ProofOfElection::consensus_block_hash` is skipped during encode/decode -// due to incompatible with Gemini-3g, thus it is the empty value in the fraud proof and will -// failed when used to get the required runtime state during verification. -// TODO: enable once the field is not skipped. #[tokio::test(flavor = "multi_thread")] -#[ignore] async fn test_bundle_equivocation_fraud_proof() { let directory = TempDir::new().expect("Must be able to create temporary directory"); @@ -2835,6 +2843,13 @@ async fn test_multiple_consensus_blocks_derive_similar_domain_block() { ) .await .unwrap(); + // Produce one more consensus block to make fork B the best fork and trigger processing + // on fork B + let slot = ferdie.produce_slot(); + ferdie + .produce_block_with_slot_at(slot, consensus_block_hash_fork_b, Some(vec![])) + .await + .unwrap(); assert_ne!(consensus_block_hash_fork_a, consensus_block_hash_fork_b); @@ -2892,18 +2907,6 @@ async fn test_multiple_consensus_blocks_derive_similar_domain_block() { domain_block_header_fork_b.state_root() ); - // Produce one more block at fork A to make it the canonical chain and the operator - // should submit the ER of fork A - let (slot, bundle) = ferdie.produce_slot_and_wait_for_bundle_submission().await; - ferdie - .produce_block_with_slot_at(slot, consensus_block_hash_fork_a, None) - .await - .unwrap(); - assert_eq!( - bundle.unwrap().into_receipt().consensus_block_hash, - consensus_block_hash_fork_a - ); - // Simply produce more block produce_blocks!(ferdie, alice, 3).await.unwrap(); } diff --git a/domains/client/eth-service/Cargo.toml b/domains/client/eth-service/Cargo.toml index 2bacd8f6c2..dd1b3ce6d6 100644 --- a/domains/client/eth-service/Cargo.toml +++ b/domains/client/eth-service/Cargo.toml @@ -15,28 +15,28 @@ include = [ clap = { version = "4.4.3", features = ["derive"] } domain-runtime-primitives = { version = "0.1.0", path = "../../primitives/runtime" } domain-service = { version = "0.1.0", path = "../../service" } -fc-consensus = { version = "2.0.0-dev", git = "https://github.com/subspace/frontier", rev = "56086daa77802eaa285894bfe4b811be66629c89" } -fc-db = { version = "2.0.0-dev", git = "https://github.com/subspace/frontier", rev = "56086daa77802eaa285894bfe4b811be66629c89", default-features = false } -fc-mapping-sync = { version = "2.0.0-dev", git = "https://github.com/subspace/frontier", rev = "56086daa77802eaa285894bfe4b811be66629c89", default-features = false } -fc-rpc = { version = "2.0.0-dev", git = "https://github.com/subspace/frontier", rev = "56086daa77802eaa285894bfe4b811be66629c89", default-features = false, features = ['rpc-binary-search-estimate'] } -fc-rpc-core = { version = "1.1.0-dev", git = "https://github.com/subspace/frontier", rev = "56086daa77802eaa285894bfe4b811be66629c89" } -fc-storage = { version = "1.0.0-dev", git = "https://github.com/subspace/frontier", rev = "56086daa77802eaa285894bfe4b811be66629c89" } -fp-rpc = { version = "3.0.0-dev", git = "https://github.com/subspace/frontier", rev = "56086daa77802eaa285894bfe4b811be66629c89", features = ['default'] } +fc-consensus = { version = "2.0.0-dev", git = "https://github.com/subspace/frontier", rev = "37ee45323120b21adc1d69ae7348bd0f7282eeae" } +fc-db = { version = "2.0.0-dev", git = "https://github.com/subspace/frontier", rev = "37ee45323120b21adc1d69ae7348bd0f7282eeae", default-features = false } +fc-mapping-sync = { version = "2.0.0-dev", git = "https://github.com/subspace/frontier", rev = "37ee45323120b21adc1d69ae7348bd0f7282eeae", default-features = false } +fc-rpc = { version = "2.0.0-dev", git = "https://github.com/subspace/frontier", rev = "37ee45323120b21adc1d69ae7348bd0f7282eeae", default-features = false, features = ['rpc-binary-search-estimate'] } +fc-rpc-core = { version = "1.1.0-dev", git = "https://github.com/subspace/frontier", rev = "37ee45323120b21adc1d69ae7348bd0f7282eeae" } +fc-storage = { version = "1.0.0-dev", git = "https://github.com/subspace/frontier", rev = "37ee45323120b21adc1d69ae7348bd0f7282eeae" } +fp-rpc = { version = "3.0.0-dev", git = "https://github.com/subspace/frontier", rev = "37ee45323120b21adc1d69ae7348bd0f7282eeae", features = ['default'] } futures = "0.3.29" jsonrpsee = { version = "0.16.3", features = ["server"] } -pallet-transaction-payment-rpc = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sc-client-api = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sc-executor = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sc-rpc = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sc-network-sync = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1", default-features = false } -sc-service = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1", default-features = false } -sc-transaction-pool = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sc-transaction-pool-api = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +pallet-transaction-payment-rpc = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sc-client-api = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sc-executor = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sc-rpc = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sc-network-sync = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c", default-features = false } +sc-service = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c", default-features = false } +sc-transaction-pool = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sc-transaction-pool-api = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } serde = { version = "1.0.183", features = ["derive"] } -sp-api = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-block-builder = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-blockchain = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-core = { version = "21.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-inherents = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-runtime = { version = "24.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -substrate-frame-rpc-system = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +sp-api = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-block-builder = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-blockchain = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-core = { version = "21.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-inherents = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-runtime = { version = "24.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +substrate-frame-rpc-system = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } diff --git a/domains/client/relayer/Cargo.toml b/domains/client/relayer/Cargo.toml index ac4e7928a3..9e61907fa8 100644 --- a/domains/client/relayer/Cargo.toml +++ b/domains/client/relayer/Cargo.toml @@ -16,12 +16,13 @@ async-channel = "1.9.0" cross-domain-message-gossip = { path = "../../client/cross-domain-message-gossip" } futures = "0.3.29" parity-scale-codec = { version = "3.6.5", features = ["derive"] } -sc-client-api = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sc-utils = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-api = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-blockchain = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-consensus = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +sc-client-api = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sc-state-db = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sc-utils = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-api = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-blockchain = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-consensus = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } sp-domains = { version = "0.1.0", path = "../../../crates/sp-domains" } sp-messenger = { version = "0.1.0", path = "../../primitives/messenger" } -sp-runtime = { version = "24.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +sp-runtime = { version = "24.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } tracing = "0.1.37" diff --git a/domains/client/relayer/src/worker.rs b/domains/client/relayer/src/worker.rs index 58249c1d04..8deb8ce852 100644 --- a/domains/client/relayer/src/worker.rs +++ b/domains/client/relayer/src/worker.rs @@ -2,6 +2,7 @@ use crate::{BlockT, Error, GossipMessageSink, HeaderBackend, HeaderT, Relayer, L use futures::StreamExt; use parity_scale_codec::FullCodec; use sc_client_api::{AuxStore, BlockchainEvents, ProofProvider}; +use sc_state_db::PruningMode; use sp_api::{ApiError, ProvideRuntimeApi}; use sp_consensus::SyncOracle; use sp_domains::DomainsApi; @@ -15,6 +16,7 @@ use std::sync::Arc; /// If the node is in major sync, worker waits waits until the sync is finished. pub async fn relay_consensus_chain_messages( consensus_chain_client: Arc, + state_pruning_mode: PruningMode, sync_oracle: SO, gossip_message_sink: GossipMessageSink, ) where @@ -31,16 +33,17 @@ pub async fn relay_consensus_chain_messages( // since all the relayers will haven embed client to known the canonical chain. let result = start_relaying_messages( NumberFor::::zero(), - consensus_chain_client, + consensus_chain_client.clone(), |client, block_hash| { Relayer::submit_messages_from_consensus_chain(client, block_hash, &gossip_message_sink) }, sync_oracle, - |_, _| -> Result { - // since we just need to provide a storage proof with the state root of Consensus chain - // proof can always be generated for any consensus chain block. - // So we can always relay messages. - Ok(true) + |_, relay_number| -> Result { + Ok(is_state_available( + &state_pruning_mode, + &consensus_chain_client, + relay_number, + )) }, ) .await; @@ -59,6 +62,7 @@ pub async fn relay_consensus_chain_messages( pub async fn relay_domain_messages( consensus_chain_client: Arc, domain_client: Arc, + domain_state_pruning: PruningMode, sync_oracle: SO, gossip_message_sink: GossipMessageSink, ) where @@ -88,7 +92,7 @@ pub async fn relay_domain_messages( let result = start_relaying_messages( relay_confirmation_depth, - domain_client, + domain_client.clone(), |client, block_hash| { Relayer::submit_messages_from_domain( client, @@ -106,6 +110,11 @@ pub async fn relay_domain_messages( ))); }; + // short circuit if the domain state is unavailable to relay messages. + if !is_state_available(&domain_state_pruning, &domain_client, block_number) { + return Ok(false); + } + let api = consensus_chain_client.runtime_api(); let at = consensus_chain_client.info().best_hash; let oldest_tracked_number = api.oldest_receipt_number(at, domain_id)?; @@ -123,6 +132,32 @@ pub async fn relay_domain_messages( } } +fn is_state_available( + state_pruning_mode: &PruningMode, + client: &Arc, + relay_number: NumberFor, +) -> bool +where + Block: BlockT, + Client: HeaderBackend, +{ + match state_pruning_mode { + // all the state is available for archive and archive canonical. + // we can relay any message from any block + PruningMode::ArchiveAll | PruningMode::ArchiveCanonical => true, + // If the pruning mode is constrained, then check if the state is available for the `relay_number` + PruningMode::Constrained(constraints) => { + let max_blocks = NumberFor::::from(constraints.max_blocks.unwrap_or(0)); + let current_best_block = client.info().best_number; + match current_best_block.checked_sub(&max_blocks) { + // we still have the state available as there was no pruning yet. + None => true, + Some(available_block_state) => relay_number >= available_block_state, + } + } + } +} + async fn start_relaying_messages( relay_confirmation_depth: NumberFor, client: Arc, diff --git a/domains/client/subnet-gossip/Cargo.toml b/domains/client/subnet-gossip/Cargo.toml index 8ddad5bf03..c639f41b8a 100644 --- a/domains/client/subnet-gossip/Cargo.toml +++ b/domains/client/subnet-gossip/Cargo.toml @@ -8,12 +8,12 @@ edition = "2021" futures = "0.3.29" parity-scale-codec = { version = "3.6.5", features = ["derive"] } parking_lot = "0.12.1" -sc-network = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sc-network-common = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sc-network-gossip = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sc-utils = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-core = { version = "21.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +sc-network = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sc-network-common = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sc-network-gossip = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sc-utils = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-core = { version = "21.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } sp-domains = { version = "0.1.0", path = "../../../crates/sp-domains" } -sp-runtime = { version = "24.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +sp-runtime = { version = "24.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } subspace-runtime-primitives = { version = "0.1.0", path = "../../../crates/subspace-runtime-primitives" } tracing = "0.1.37" diff --git a/domains/client/subnet-gossip/src/worker.rs b/domains/client/subnet-gossip/src/worker.rs index fe444858c1..5b05833d13 100644 --- a/domains/client/subnet-gossip/src/worker.rs +++ b/domains/client/subnet-gossip/src/worker.rs @@ -2,11 +2,13 @@ use crate::{ topic, BundleFor, BundleReceiver, GossipMessage, GossipMessageHandler, GossipValidator, LOG_TARGET, }; -use futures::{future, FutureExt, StreamExt}; +use futures::{FutureExt, StreamExt}; use parity_scale_codec::{Decode, Encode}; use parking_lot::Mutex; use sc_network_gossip::GossipEngine; use sp_runtime::traits::Block as BlockT; +use std::future::poll_fn; +use std::pin::pin; use std::sync::Arc; /// A worker plays the executor gossip protocol. @@ -49,21 +51,21 @@ where } pub(super) async fn run(mut self) { - let mut incoming = Box::pin( - self.gossip_engine - .lock() - .messages_for(topic::()) - .filter_map(|notification| async move { - GossipMessage::::decode(&mut ¬ification.message[..]).ok() - }), - ); + let incoming = pin!(self + .gossip_engine + .lock() + .messages_for(topic::()) + .filter_map(|notification| async move { + GossipMessage::::decode(&mut ¬ification.message[..]).ok() + })); + let mut incoming = incoming.fuse(); loop { let engine = self.gossip_engine.clone(); - let gossip_engine = future::poll_fn(|cx| engine.lock().poll_unpin(cx)); + let mut gossip_engine = poll_fn(|cx| engine.lock().poll_unpin(cx)).fuse(); futures::select! { - gossip_message = incoming.next().fuse() => { + gossip_message = incoming.next() => { if let Some(message) = gossip_message { tracing::debug!(target: LOG_TARGET, ?message, "Rebroadcasting an executor gossip message"); match message { @@ -73,12 +75,10 @@ where return } } - bundle = self.bundle_receiver.next().fuse() => { - if let Some(bundle) = bundle { - self.gossip_bundle(bundle); - } + bundle = self.bundle_receiver.select_next_some() => { + self.gossip_bundle(bundle); } - _ = gossip_engine.fuse() => { + _ = gossip_engine => { tracing::error!(target: LOG_TARGET, "Gossip engine has terminated."); return; } diff --git a/domains/pallets/domain-id/Cargo.toml b/domains/pallets/domain-id/Cargo.toml index e5efdb5b91..17a1986a4b 100644 --- a/domains/pallets/domain-id/Cargo.toml +++ b/domains/pallets/domain-id/Cargo.toml @@ -14,15 +14,15 @@ include = [ [dependencies] codec = { package = "parity-scale-codec", version = "3.6.5", default-features = false, features = ["derive"] } -frame-support = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -frame-system = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +frame-support = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +frame-system = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } scale-info = { version = "2.7.0", default-features = false, features = ["derive"] } sp-domains = { version = "0.1.0", default-features = false, path = "../../../crates/sp-domains" } -sp-runtime = { version = "24.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +sp-runtime = { version = "24.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } [dev-dependencies] -sp-core = { version = "21.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-io = { version = "23.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +sp-core = { version = "21.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-io = { version = "23.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } [features] default = ["std"] diff --git a/domains/pallets/executive/Cargo.toml b/domains/pallets/executive/Cargo.toml index c07606d051..00ebc1baa9 100644 --- a/domains/pallets/executive/Cargo.toml +++ b/domains/pallets/executive/Cargo.toml @@ -13,23 +13,23 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] codec = { package = "parity-scale-codec", version = "3.6.5", default-features = false, features = ["derive"] } -frame-benchmarking = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1", optional = true } -frame-executive = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1", default-features = false } -frame-support = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1", default-features = false } -frame-system = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1", default-features = false } +frame-benchmarking = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c", optional = true } +frame-executive = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c", default-features = false } +frame-support = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c", default-features = false } +frame-system = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c", default-features = false } log = { version = "0.4.20", default-features = false } scale-info = { version = "2.7.0", default-features = false, features = ["derive"] } sp-executive = { version = "0.1.0", path = "../../primitives/executive", default-features = false } -sp-io = { version = "23.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1", default-features = false } -sp-runtime = { version = "24.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1", default-features = false } -sp-std = { version = "8.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1", default-features = false } -sp-tracing = { version = "10.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1", default-features = false } +sp-io = { version = "23.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c", default-features = false } +sp-runtime = { version = "24.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c", default-features = false } +sp-std = { version = "8.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c", default-features = false } +sp-tracing = { version = "10.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c", default-features = false } [dev-dependencies] -pallet-balances = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-core = { version = "21.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-externalities = { version = "0.19.0", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-version = { version = "22.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +pallet-balances = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-core = { version = "21.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-externalities = { version = "0.19.0", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-version = { version = "22.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } [features] default = ["std"] diff --git a/domains/pallets/messenger/Cargo.toml b/domains/pallets/messenger/Cargo.toml index 1fcb6733e2..300c66dfd2 100644 --- a/domains/pallets/messenger/Cargo.toml +++ b/domains/pallets/messenger/Cargo.toml @@ -15,23 +15,23 @@ include = [ [dependencies] codec = { package = "parity-scale-codec", version = "3.6.5", default-features = false, features = ["derive"] } -frame-benchmarking = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1", optional = true } -frame-support = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -frame-system = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +frame-benchmarking = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c", optional = true } +frame-support = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +frame-system = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } log = { version = "0.4.20", default-features = false } scale-info = { version = "2.7.0", default-features = false, features = ["derive"] } -sp-core = { version = "21.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +sp-core = { version = "21.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } sp-domains = { version = "0.1.0", default-features = false, path = "../../../crates/sp-domains" } sp-messenger = { version = "0.1.0", default-features = false, path = "../../primitives/messenger" } -sp-runtime = { version = "24.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-std = { version = "8.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-trie = { version = "22.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +sp-runtime = { version = "24.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-std = { version = "8.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-trie = { version = "22.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } [dev-dependencies] domain-runtime-primitives = { path = "../../primitives/runtime" } -pallet-balances = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +pallet-balances = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } pallet-transporter = { version = "0.1.0", path = "../transporter" } -sp-state-machine = { version = "0.28.0", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +sp-state-machine = { version = "0.28.0", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } [features] default = ["std"] diff --git a/domains/pallets/operator-rewards/Cargo.toml b/domains/pallets/operator-rewards/Cargo.toml index 4216fdd680..6b1001013e 100644 --- a/domains/pallets/operator-rewards/Cargo.toml +++ b/domains/pallets/operator-rewards/Cargo.toml @@ -14,11 +14,11 @@ include = [ [dependencies] codec = { package = "parity-scale-codec", version = "3.6.5", default-features = false, features = ["derive"] } -frame-support = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -frame-system = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +frame-support = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +frame-system = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } scale-info = { version = "2.7.0", default-features = false, features = ["derive"] } -sp-runtime = { version = "24.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-std = { version = "8.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +sp-runtime = { version = "24.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-std = { version = "8.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } [features] default = ["std"] diff --git a/domains/pallets/transporter/Cargo.toml b/domains/pallets/transporter/Cargo.toml index 069b0666aa..2fd63fb0f4 100644 --- a/domains/pallets/transporter/Cargo.toml +++ b/domains/pallets/transporter/Cargo.toml @@ -16,18 +16,18 @@ include = [ [dependencies] codec = { package = "parity-scale-codec", version = "3.6.5", default-features = false, features = ["derive"] } domain-runtime-primitives = { path = "../../primitives/runtime" , default-features = false } -frame-benchmarking = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1", optional = true } -frame-support = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -frame-system = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +frame-benchmarking = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c", optional = true } +frame-support = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +frame-system = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } scale-info = { version = "2.7.0", default-features = false, features = ["derive"] } -sp-core = { version = "21.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +sp-core = { version = "21.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } sp-messenger = { version = "0.1.0", default-features = false, path = "../../primitives/messenger" } -sp-runtime = { version = "24.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-std = { version = "8.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +sp-runtime = { version = "24.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-std = { version = "8.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } [dev-dependencies] -pallet-balances = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-io = { version = "23.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +pallet-balances = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-io = { version = "23.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } [features] default = ["std"] diff --git a/domains/primitives/digests/Cargo.toml b/domains/primitives/digests/Cargo.toml index f037e24a82..028a012d8f 100644 --- a/domains/primitives/digests/Cargo.toml +++ b/domains/primitives/digests/Cargo.toml @@ -15,7 +15,7 @@ include = [ [dependencies] codec = { package = "parity-scale-codec", version = "3.1.5", default-features = false, features = ["derive"] } -sp-runtime = { version = "24.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +sp-runtime = { version = "24.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } [features] default = ["std"] diff --git a/domains/primitives/executive/Cargo.toml b/domains/primitives/executive/Cargo.toml index 8615ca7950..2f6d3401bc 100644 --- a/domains/primitives/executive/Cargo.toml +++ b/domains/primitives/executive/Cargo.toml @@ -16,8 +16,8 @@ include = [ [dependencies] async-trait = { version = "0.1.73", optional = true } codec = { package = "parity-scale-codec", version = "3.1.5", default-features = false, features = ["derive"] } -sp-inherents = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-std = { version = "8.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +sp-inherents = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-std = { version = "8.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } [features] default = ["std"] diff --git a/domains/primitives/messenger/Cargo.toml b/domains/primitives/messenger/Cargo.toml index 6e24232535..b8dc346224 100644 --- a/domains/primitives/messenger/Cargo.toml +++ b/domains/primitives/messenger/Cargo.toml @@ -15,17 +15,17 @@ include = [ [dependencies] codec = { package = "parity-scale-codec", version = "3.6.5", default-features = false, features = ["derive"] } -frame-support = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +frame-support = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } hash-db = { version = "0.16.0", default-features = false } log = { version = "0.4.20", default-features = false } scale-info = { version = "2.7.0", default-features = false, features = ["derive"] } serde = { version = "1.0.183", default-features = false, features = ["alloc", "derive"] } -sp-api = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-core = { version = "21.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +sp-api = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-core = { version = "21.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } sp-domains = { version = "0.1.0", default-features = false, path = "../../../crates/sp-domains" } -sp-runtime = { version = "24.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-std = { version = "8.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-trie = { version = "22.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +sp-runtime = { version = "24.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-std = { version = "8.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-trie = { version = "22.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } [features] default = ["std"] diff --git a/domains/primitives/runtime/Cargo.toml b/domains/primitives/runtime/Cargo.toml index 1fe5ddebd2..a46157928c 100644 --- a/domains/primitives/runtime/Cargo.toml +++ b/domains/primitives/runtime/Cargo.toml @@ -14,13 +14,13 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] parity-scale-codec = { version = "3.6.5", default-features = false, features = ["derive"] } scale-info = { version = "2.7.0", default-features = false, features = ["derive"] } -sp-api = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-core = { version = "21.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-runtime = { version = "24.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-std = { version = "8.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +sp-api = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-core = { version = "21.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-runtime = { version = "24.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-std = { version = "8.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } subspace-core-primitives = { version = "0.1.0", path = "../../../crates/subspace-core-primitives", default-features = false } subspace-runtime-primitives = { version = "0.1.0", path = "../../../crates/subspace-runtime-primitives", default-features = false } -sp-weights = { version = "20.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +sp-weights = { version = "20.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } [features] default = ["std"] diff --git a/domains/runtime/evm/Cargo.toml b/domains/runtime/evm/Cargo.toml index d1e6d58fc2..66f9bf2978 100644 --- a/domains/runtime/evm/Cargo.toml +++ b/domains/runtime/evm/Cargo.toml @@ -20,44 +20,44 @@ targets = ["x86_64-unknown-linux-gnu"] codec = { package = "parity-scale-codec", version = "3.2.1", default-features = false, features = ["derive"] } domain-pallet-executive = { version = "0.1.0", path = "../../pallets/executive", default-features = false } domain-runtime-primitives = { version = "0.1.0", path = "../../primitives/runtime", default-features = false } -fp-account = { version = "1.0.0-dev", default-features = false, features = ["serde"], git = "https://github.com/subspace/frontier", rev = "56086daa77802eaa285894bfe4b811be66629c89" } -fp-rpc = { version = "3.0.0-dev", default-features = false, git = "https://github.com/subspace/frontier", rev = "56086daa77802eaa285894bfe4b811be66629c89" } -fp-self-contained = { version = "1.0.0-dev", default-features = false, features = ["serde"], git = "https://github.com/subspace/frontier", rev = "56086daa77802eaa285894bfe4b811be66629c89" } -frame-benchmarking = { version = "4.0.0-dev", default-features = false, optional = true, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -frame-support = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -frame-system = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -frame-system-benchmarking = { version = "4.0.0-dev", default-features = false, optional = true, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -frame-system-rpc-runtime-api = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -pallet-balances = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -pallet-base-fee = { version = "1.0.0-dev", default-features = false, git = "https://github.com/subspace/frontier", rev = "56086daa77802eaa285894bfe4b811be66629c89" } +fp-account = { version = "1.0.0-dev", default-features = false, features = ["serde"], git = "https://github.com/subspace/frontier", rev = "37ee45323120b21adc1d69ae7348bd0f7282eeae" } +fp-rpc = { version = "3.0.0-dev", default-features = false, git = "https://github.com/subspace/frontier", rev = "37ee45323120b21adc1d69ae7348bd0f7282eeae" } +fp-self-contained = { version = "1.0.0-dev", default-features = false, features = ["serde"], git = "https://github.com/subspace/frontier", rev = "37ee45323120b21adc1d69ae7348bd0f7282eeae" } +frame-benchmarking = { version = "4.0.0-dev", default-features = false, optional = true, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +frame-support = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +frame-system = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +frame-system-benchmarking = { version = "4.0.0-dev", default-features = false, optional = true, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +frame-system-rpc-runtime-api = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +pallet-balances = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +pallet-base-fee = { version = "1.0.0-dev", default-features = false, git = "https://github.com/subspace/frontier", rev = "37ee45323120b21adc1d69ae7348bd0f7282eeae" } pallet-domain-id = { version = "0.1.0", path = "../../pallets/domain-id", default-features = false } pallet-operator-rewards = { version = "0.1.0", path = "../../pallets/operator-rewards", default-features = false } -pallet-ethereum = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/frontier", rev = "56086daa77802eaa285894bfe4b811be66629c89" } -pallet-evm = { version = "6.0.0-dev", default-features = false, git = "https://github.com/subspace/frontier", rev = "56086daa77802eaa285894bfe4b811be66629c89" } -pallet-evm-chain-id = { version = "1.0.0-dev", default-features = false, git = "https://github.com/subspace/frontier", rev = "56086daa77802eaa285894bfe4b811be66629c89" } -pallet-evm-precompile-modexp = { version = "2.0.0-dev", default-features = false, git = "https://github.com/subspace/frontier", rev = "56086daa77802eaa285894bfe4b811be66629c89" } -pallet-evm-precompile-sha3fips = { version = "2.0.0-dev", default-features = false, git = "https://github.com/subspace/frontier", rev = "56086daa77802eaa285894bfe4b811be66629c89" } -pallet-evm-precompile-simple = { version = "2.0.0-dev", default-features = false, git = "https://github.com/subspace/frontier", rev = "56086daa77802eaa285894bfe4b811be66629c89" } +pallet-ethereum = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/frontier", rev = "37ee45323120b21adc1d69ae7348bd0f7282eeae" } +pallet-evm = { version = "6.0.0-dev", default-features = false, git = "https://github.com/subspace/frontier", rev = "37ee45323120b21adc1d69ae7348bd0f7282eeae" } +pallet-evm-chain-id = { version = "1.0.0-dev", default-features = false, git = "https://github.com/subspace/frontier", rev = "37ee45323120b21adc1d69ae7348bd0f7282eeae" } +pallet-evm-precompile-modexp = { version = "2.0.0-dev", default-features = false, git = "https://github.com/subspace/frontier", rev = "37ee45323120b21adc1d69ae7348bd0f7282eeae" } +pallet-evm-precompile-sha3fips = { version = "2.0.0-dev", default-features = false, git = "https://github.com/subspace/frontier", rev = "37ee45323120b21adc1d69ae7348bd0f7282eeae" } +pallet-evm-precompile-simple = { version = "2.0.0-dev", default-features = false, git = "https://github.com/subspace/frontier", rev = "37ee45323120b21adc1d69ae7348bd0f7282eeae" } pallet-messenger = { version = "0.1.0", path = "../../pallets/messenger", default-features = false } -pallet-sudo = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -pallet-timestamp = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -pallet-transaction-payment = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -pallet-transaction-payment-rpc-runtime-api = { default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +pallet-sudo = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +pallet-timestamp = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +pallet-transaction-payment = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +pallet-transaction-payment-rpc-runtime-api = { default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } pallet-transporter = { version = "0.1.0", path = "../../pallets/transporter", default-features = false } scale-info = { version = "2.7.0", default-features = false, features = ["derive"] } -sp-api = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-block-builder = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-core = { version = "21.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +sp-api = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-block-builder = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-core = { version = "21.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } sp-domains = { version = "0.1.0", path = "../../../crates/sp-domains", default-features = false } -sp-inherents = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +sp-inherents = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } sp-messenger = { version = "0.1.0", default-features = false, path = "../../primitives/messenger" } -sp-offchain = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-runtime = { version = "24.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-session = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-std = { version = "8.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-storage = { version = "13.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1", optional = true } -sp-transaction-pool = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-version = { version = "22.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +sp-offchain = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-runtime = { version = "24.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-session = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-std = { version = "8.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-storage = { version = "13.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c", optional = true } +sp-transaction-pool = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-version = { version = "22.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } subspace-core-primitives = { version = "0.1.0", path = "../../../crates/subspace-core-primitives", default-features = false } subspace-runtime-primitives = { version = "0.1.0", path = "../../../crates/subspace-runtime-primitives", default-features = false } @@ -65,7 +65,7 @@ subspace-runtime-primitives = { version = "0.1.0", path = "../../../crates/subsp subspace-runtime-primitives = { version = "0.1.0", features = ["testing"], path = "../../../crates/subspace-runtime-primitives" } [build-dependencies] -substrate-wasm-builder = { version = "5.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1", optional = true } +substrate-wasm-builder = { version = "5.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c", optional = true } [features] default = [ diff --git a/domains/runtime/evm/src/lib.rs b/domains/runtime/evm/src/lib.rs index 312c722bdb..7ed4eb84c8 100644 --- a/domains/runtime/evm/src/lib.rs +++ b/domains/runtime/evm/src/lib.rs @@ -176,8 +176,8 @@ impl fp_self_contained::SelfContainedCall for RuntimeCall { impl_opaque_keys! { pub struct SessionKeys { - /// Primarily used for adding the executor authority key into the keystore in the dev mode. - pub executor: sp_domains::OperatorKey, + /// Primarily used for adding the operator signing key into the Keystore. + pub operator: sp_domains::OperatorKey, } } @@ -520,6 +520,10 @@ impl pallet_evm::OnChargeEVMTransaction for EVMCurrencyAdapter { } } +parameter_types! { + pub const GasLimitPovSizeRatio: u64 = 4; +} + impl pallet_evm::Config for Runtime { type FeeCalculator = BaseFee; type GasWeightMapping = pallet_evm::FixedGasWeightMapping; @@ -538,7 +542,7 @@ impl pallet_evm::Config for Runtime { type OnChargeTransaction = EVMCurrencyAdapter; type OnCreate = (); type FindAuthor = FindAuthorTruncated; - type GasLimitPovSizeRatio = (); + type GasLimitPovSizeRatio = GasLimitPovSizeRatio; type Timestamp = Timestamp; type WeightInfo = pallet_evm::weights::SubstrateWeight; } diff --git a/domains/service/Cargo.toml b/domains/service/Cargo.toml index d3b4caf5bd..5583344ffe 100644 --- a/domains/service/Cargo.toml +++ b/domains/service/Cargo.toml @@ -24,43 +24,43 @@ domain-runtime-primitives = { version = "0.1.0", path = "../primitives/runtime" futures = "0.3.29" jsonrpsee = { version = "0.16.3", features = ["server"] } log = "0.4.20" -pallet-transaction-payment-rpc = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +pallet-transaction-payment-rpc = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } parity-scale-codec = "3.6.5" -sc-chain-spec = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sc-client-api = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sc-consensus = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sc-executor = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sc-network = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sc-network-common = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sc-network-sync = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sc-network-transactions = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sc-rpc = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sc-rpc-api = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sc-rpc-spec-v2 = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sc-service = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1", default-features = false } -sc-telemetry = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sc-transaction-pool = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sc-transaction-pool-api = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sc-utils = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +sc-chain-spec = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sc-client-api = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sc-consensus = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sc-executor = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sc-network = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sc-network-common = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sc-network-sync = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sc-network-transactions = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sc-rpc = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sc-rpc-api = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sc-rpc-spec-v2 = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sc-service = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c", default-features = false } +sc-telemetry = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sc-transaction-pool = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sc-transaction-pool-api = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sc-utils = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } serde = { version = "1.0.183", features = ["derive"] } -sp-api = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-block-builder = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-blockchain = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-consensus = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-consensus-slots = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-core = { version = "21.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +sp-api = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-block-builder = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-blockchain = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-consensus = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-consensus-slots = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-core = { version = "21.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } sp-domains = { version = "0.1.0", path = "../../crates/sp-domains" } sp-domains-fraud-proof = { version = "0.1.0", path = "../../crates/sp-domains-fraud-proof" } sp-messenger = { version = "0.1.0", path = "../../domains/primitives/messenger" } -sp-offchain = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-runtime = { version = "24.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-session = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-transaction-pool = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +sp-offchain = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-runtime = { version = "24.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-session = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-transaction-pool = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } subspace-core-primitives = { version = "0.1.0", path = "../../crates/subspace-core-primitives" } subspace-runtime-primitives = { version = "0.1.0", path = "../../crates/subspace-runtime-primitives" } -substrate-frame-rpc-system = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -substrate-prometheus-endpoint = { git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +substrate-frame-rpc-system = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +substrate-prometheus-endpoint = { git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } tracing = "0.1.37" [build-dependencies] -substrate-build-script-utils = { version = "3.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +substrate-build-script-utils = { version = "3.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } diff --git a/domains/service/src/domain.rs b/domains/service/src/domain.rs index d26560f1c9..3632a62142 100644 --- a/domains/service/src/domain.rs +++ b/domains/service/src/domain.rs @@ -1,6 +1,7 @@ use crate::providers::{BlockImportProvider, RpcProvider}; use crate::transaction_pool::FullChainApiWrapper; use crate::{FullBackend, FullClient}; +use cross_domain_message_gossip::ChainTxPoolMsg; use domain_client_block_preprocessor::inherents::CreateInherentDataProvider; use domain_client_message_relayer::GossipMessageSink; use domain_client_operator::{Operator, OperatorParams, OperatorStreams}; @@ -12,6 +13,7 @@ use pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi; use sc_client_api::{BlockBackend, BlockImportNotification, BlockchainEvents, ProofProvider}; use sc_consensus::SharedBlockImport; use sc_executor::{NativeElseWasmExecutor, NativeExecutionDispatch}; +use sc_network::NetworkPeers; use sc_rpc_api::DenyUnsafe; use sc_service::{ BuildNetworkParams, Configuration as ServiceConfiguration, NetworkStarter, PartialComponents, @@ -216,7 +218,7 @@ where Ok(params) } -pub struct DomainParams +pub struct DomainParams where CBlock: BlockT, { @@ -225,11 +227,12 @@ where pub domain_created_at: NumberFor, pub maybe_operator_id: Option, pub consensus_client: Arc, + pub consensus_network: Arc, pub consensus_offchain_tx_pool_factory: OffchainTransactionPoolFactory, pub consensus_network_sync_oracle: Arc, pub operator_streams: OperatorStreams, pub gossip_message_sink: GossipMessageSink, - pub domain_message_receiver: TracingUnboundedReceiver>, + pub domain_message_receiver: TracingUnboundedReceiver, pub provider: Provider, pub skip_empty_bundle_production: bool, } @@ -246,8 +249,9 @@ pub async fn new_full< ExecutorDispatch, AccountId, Provider, + CNetwork, >( - domain_params: DomainParams, + domain_params: DomainParams, ) -> sc_service::error::Result< NewFull< Arc>, @@ -322,6 +326,7 @@ where CreateInherentDataProvider, > + BlockImportProvider> + 'static, + CNetwork: NetworkPeers + Send + Sync + 'static, { let DomainParams { domain_id, @@ -331,6 +336,7 @@ where consensus_client, consensus_offchain_tx_pool_factory, consensus_network_sync_oracle, + consensus_network, operator_streams, gossip_message_sink, domain_message_receiver, @@ -371,6 +377,7 @@ where })?; let is_authority = domain_config.role.is_authority(); + let domain_state_pruning = domain_config.state_pruning.clone().unwrap_or_default(); domain_config.rpc_id_provider = provider.rpc_id(); let rpc_builder = { let deps = crate::rpc::FullDeps { @@ -467,6 +474,7 @@ where let relayer_worker = domain_client_message_relayer::worker::relay_domain_messages( consensus_client.clone(), client.clone(), + domain_state_pruning, // domain relayer will use consensus chain sync oracle instead of domain sync orcle // since domain sync oracle will always return `synced` due to force sync being set. consensus_network_sync_oracle, @@ -481,6 +489,7 @@ where ChainId::Domain(domain_id), client.clone(), params.transaction_pool.clone(), + consensus_network, domain_message_receiver, ); diff --git a/domains/test/primitives/Cargo.toml b/domains/test/primitives/Cargo.toml index 4a68891bc6..0ea8a2428b 100644 --- a/domains/test/primitives/Cargo.toml +++ b/domains/test/primitives/Cargo.toml @@ -13,7 +13,7 @@ include = [ [dependencies] codec = { package = "parity-scale-codec", version = "3.4.0", default-features = false, features = ["derive"]} -sp-api = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1", default-features = false } +sp-api = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c", default-features = false } sp-messenger = { version = "0.1.0", default-features = false, path = "../../primitives/messenger" } subspace-runtime-primitives = { version = "0.1.0", path = "../../../crates/subspace-runtime-primitives", default-features = false } diff --git a/domains/test/runtime/evm/Cargo.toml b/domains/test/runtime/evm/Cargo.toml index 24142c0bc0..fc1e28e2ce 100644 --- a/domains/test/runtime/evm/Cargo.toml +++ b/domains/test/runtime/evm/Cargo.toml @@ -21,46 +21,46 @@ codec = { package = "parity-scale-codec", version = "3.2.1", default-features = domain-pallet-executive = { version = "0.1.0", path = "../../../pallets/executive", default-features = false } domain-test-primitives = { version = "0.1.0", path = "../../primitives", default-features = false } domain-runtime-primitives = { version = "0.1.0", path = "../../../primitives/runtime", default-features = false } -fp-account = { version = "1.0.0-dev", default-features = false, features = ["serde"], git = "https://github.com/subspace/frontier", rev = "56086daa77802eaa285894bfe4b811be66629c89" } -fp-rpc = { version = "3.0.0-dev", default-features = false, git = "https://github.com/subspace/frontier", rev = "56086daa77802eaa285894bfe4b811be66629c89" } -fp-self-contained = { version = "1.0.0-dev", default-features = false, features = ["serde"], git = "https://github.com/subspace/frontier", rev = "56086daa77802eaa285894bfe4b811be66629c89" } -frame-support = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -frame-system = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -frame-system-rpc-runtime-api = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -pallet-balances = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -pallet-base-fee = { version = "1.0.0-dev", default-features = false, git = "https://github.com/subspace/frontier", rev = "56086daa77802eaa285894bfe4b811be66629c89" } +fp-account = { version = "1.0.0-dev", default-features = false, features = ["serde"], git = "https://github.com/subspace/frontier", rev = "37ee45323120b21adc1d69ae7348bd0f7282eeae" } +fp-rpc = { version = "3.0.0-dev", default-features = false, git = "https://github.com/subspace/frontier", rev = "37ee45323120b21adc1d69ae7348bd0f7282eeae" } +fp-self-contained = { version = "1.0.0-dev", default-features = false, features = ["serde"], git = "https://github.com/subspace/frontier", rev = "37ee45323120b21adc1d69ae7348bd0f7282eeae" } +frame-support = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +frame-system = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +frame-system-rpc-runtime-api = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +pallet-balances = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +pallet-base-fee = { version = "1.0.0-dev", default-features = false, git = "https://github.com/subspace/frontier", rev = "37ee45323120b21adc1d69ae7348bd0f7282eeae" } pallet-domain-id = { version = "0.1.0", path = "../../../pallets/domain-id", default-features = false } pallet-operator-rewards = { version = "0.1.0", path = "../../../pallets/operator-rewards", default-features = false } -pallet-ethereum = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/frontier", rev = "56086daa77802eaa285894bfe4b811be66629c89" } -pallet-evm = { version = "6.0.0-dev", default-features = false, git = "https://github.com/subspace/frontier", rev = "56086daa77802eaa285894bfe4b811be66629c89" } -pallet-evm-chain-id = { version = "1.0.0-dev", default-features = false, git = "https://github.com/subspace/frontier", rev = "56086daa77802eaa285894bfe4b811be66629c89" } -pallet-evm-precompile-modexp = { version = "2.0.0-dev", default-features = false, git = "https://github.com/subspace/frontier", rev = "56086daa77802eaa285894bfe4b811be66629c89" } -pallet-evm-precompile-sha3fips = { version = "2.0.0-dev", default-features = false, git = "https://github.com/subspace/frontier", rev = "56086daa77802eaa285894bfe4b811be66629c89" } -pallet-evm-precompile-simple = { version = "2.0.0-dev", default-features = false, git = "https://github.com/subspace/frontier", rev = "56086daa77802eaa285894bfe4b811be66629c89" } +pallet-ethereum = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/frontier", rev = "37ee45323120b21adc1d69ae7348bd0f7282eeae" } +pallet-evm = { version = "6.0.0-dev", default-features = false, git = "https://github.com/subspace/frontier", rev = "37ee45323120b21adc1d69ae7348bd0f7282eeae" } +pallet-evm-chain-id = { version = "1.0.0-dev", default-features = false, git = "https://github.com/subspace/frontier", rev = "37ee45323120b21adc1d69ae7348bd0f7282eeae" } +pallet-evm-precompile-modexp = { version = "2.0.0-dev", default-features = false, git = "https://github.com/subspace/frontier", rev = "37ee45323120b21adc1d69ae7348bd0f7282eeae" } +pallet-evm-precompile-sha3fips = { version = "2.0.0-dev", default-features = false, git = "https://github.com/subspace/frontier", rev = "37ee45323120b21adc1d69ae7348bd0f7282eeae" } +pallet-evm-precompile-simple = { version = "2.0.0-dev", default-features = false, git = "https://github.com/subspace/frontier", rev = "37ee45323120b21adc1d69ae7348bd0f7282eeae" } pallet-messenger = { version = "0.1.0", path = "../../../pallets/messenger", default-features = false } -pallet-sudo = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -pallet-timestamp = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -pallet-transaction-payment = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -pallet-transaction-payment-rpc-runtime-api = { default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +pallet-sudo = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +pallet-timestamp = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +pallet-transaction-payment = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +pallet-transaction-payment-rpc-runtime-api = { default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } pallet-transporter = { version = "0.1.0", path = "../../../pallets/transporter", default-features = false } scale-info = { version = "2.7.0", default-features = false, features = ["derive"] } -sp-api = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-block-builder = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-core = { version = "21.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +sp-api = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-block-builder = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-core = { version = "21.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } sp-domains = { version = "0.1.0", path = "../../../../crates/sp-domains", default-features = false } -sp-inherents = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +sp-inherents = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } sp-messenger = { version = "0.1.0", default-features = false, path = "../../../primitives/messenger" } -sp-offchain = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-runtime = { version = "24.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-session = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-std = { version = "8.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-transaction-pool = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-version = { version = "22.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +sp-offchain = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-runtime = { version = "24.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-session = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-std = { version = "8.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-transaction-pool = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-version = { version = "22.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } subspace-core-primitives = { version = "0.1.0", path = "../../../../crates/subspace-core-primitives", default-features = false } subspace-runtime-primitives = { version = "0.1.0", path = "../../../../crates/subspace-runtime-primitives", default-features = false } [build-dependencies] -substrate-wasm-builder = { version = "5.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1", optional = true } +substrate-wasm-builder = { version = "5.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c", optional = true } [features] default = [ diff --git a/domains/test/runtime/evm/src/lib.rs b/domains/test/runtime/evm/src/lib.rs index 00b925993b..d4f6c72fa2 100644 --- a/domains/test/runtime/evm/src/lib.rs +++ b/domains/test/runtime/evm/src/lib.rs @@ -176,8 +176,8 @@ impl fp_self_contained::SelfContainedCall for RuntimeCall { impl_opaque_keys! { pub struct SessionKeys { - /// Primarily used for adding the executor authority key into the keystore in the dev mode. - pub executor: sp_domains::OperatorKey, + /// Primarily used for adding the operator signing key into the keystore. + pub operator: sp_domains::OperatorKey, } } diff --git a/domains/test/service/Cargo.toml b/domains/test/service/Cargo.toml index dc7b4121e1..fcc0d48fbe 100644 --- a/domains/test/service/Cargo.toml +++ b/domains/test/service/Cargo.toml @@ -7,48 +7,49 @@ license = "GPL-3.0-or-later" homepage = "https://subspace.network" repository = "https://github.com/subspace/subspace" include = [ - "/src", - "/Cargo.toml", + "/src", + "/Cargo.toml", ] [dependencies] +cross-domain-message-gossip = { version = "0.1.0", path = "../../client/cross-domain-message-gossip" } domain-client-operator = { version = "0.1.0", path = "../../client/domain-operator" } domain-service = { version = "0.1.0", path = "../../service" } domain-test-primitives = { version = "0.1.0", path = "../primitives" } domain-runtime-primitives = { version = "0.1.0", path = "../../primitives/runtime", default-features = false } evm-domain-test-runtime = { version = "0.1.0", path = "../runtime/evm" } -fp-account = { version = "1.0.0-dev", default-features = false, features = ["serde"], git = "https://github.com/subspace/frontier", rev = "56086daa77802eaa285894bfe4b811be66629c89" } -fp-rpc = { version = "3.0.0-dev", git = "https://github.com/subspace/frontier", rev = "56086daa77802eaa285894bfe4b811be66629c89", features = ['default'] } -frame-system = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -frame-support = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +fp-account = { version = "1.0.0-dev", default-features = false, features = ["serde"], git = "https://github.com/subspace/frontier", rev = "37ee45323120b21adc1d69ae7348bd0f7282eeae" } +fp-rpc = { version = "3.0.0-dev", git = "https://github.com/subspace/frontier", rev = "37ee45323120b21adc1d69ae7348bd0f7282eeae", features = ['default'] } +frame-system = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +frame-support = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } rand = "0.8.5" -pallet-transaction-payment = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -pallet-transaction-payment-rpc = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sc-client-api = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sc-executor = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sc-network = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sc-network-sync = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sc-service = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1", default-features = false } -sc-tracing = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sc-transaction-pool-api = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sc-utils = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +pallet-transaction-payment = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +pallet-transaction-payment-rpc = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sc-client-api = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sc-executor = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sc-network = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sc-network-sync = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sc-service = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c", default-features = false } +sc-tracing = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sc-transaction-pool-api = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sc-utils = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } serde = { version = "1.0.183", features = ["derive"] } -sp-api = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-arithmetic = { version = "16.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-blockchain = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-block-builder = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-core = { version = "21.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +sp-api = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-arithmetic = { version = "16.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-blockchain = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-block-builder = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-core = { version = "21.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } sp-domains = { version = "0.1.0", path = "../../../crates/sp-domains" } -sp-keyring = { version = "24.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +sp-keyring = { version = "24.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } sp-messenger = { version = "0.1.0", path = "../../../domains/primitives/messenger" } -sp-offchain = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-runtime = { version = "24.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1", default-features = false } -sp-session = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-transaction-pool = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +sp-offchain = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-runtime = { version = "24.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c", default-features = false } +sp-session = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-transaction-pool = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } subspace-runtime-primitives = { version = "0.1.0", path = "../../../crates/subspace-runtime-primitives" } subspace-test-client = { version = "0.1.0", path = "../../../test/subspace-test-client" } subspace-test-service = { version = "0.1.0", path = "../../../test/subspace-test-service" } -substrate-frame-rpc-system = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -substrate-test-client = { version = "2.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +substrate-frame-rpc-system = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +substrate-test-client = { version = "2.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } tokio = { version = "1.34.0", features = ["macros"] } tracing = "0.1.37" diff --git a/domains/test/service/src/domain.rs b/domains/test/service/src/domain.rs index d73f4c40ab..c453d7230e 100644 --- a/domains/test/service/src/domain.rs +++ b/domains/test/service/src/domain.rs @@ -5,6 +5,7 @@ use crate::chain_spec::create_domain_spec; use crate::{ construct_extrinsic_generic, node_config, BalanceOf, EcdsaKeyring, UncheckedExtrinsicFor, }; +use cross_domain_message_gossip::ChainTxPoolMsg; use domain_client_operator::{BootstrapResult, Bootstrapper, OperatorStreams}; use domain_runtime_primitives::opaque::Block; use domain_runtime_primitives::{Balance, DomainCoreApi}; @@ -121,7 +122,7 @@ where /// Domain oeprator. pub operator: DomainOperator, /// Sink to the node's tx pool - pub tx_pool_sink: TracingUnboundedSender>, + pub tx_pool_sink: TracingUnboundedSender, _phantom_data: PhantomData<(Runtime, AccountId)>, } @@ -234,6 +235,7 @@ where mock_consensus_node.transaction_pool.clone(), ), consensus_network_sync_oracle: mock_consensus_node.sync_service.clone(), + consensus_network: mock_consensus_node.network_service.clone(), operator_streams, gossip_message_sink: gossip_msg_sink, domain_message_receiver, @@ -253,6 +255,7 @@ where ExecutorDispatch, AccountId, _, + _, >(domain_params) .await .expect("failed to build domain node"); diff --git a/orml/vesting/Cargo.toml b/orml/vesting/Cargo.toml index b5e1754d14..28add8dd3d 100644 --- a/orml/vesting/Cargo.toml +++ b/orml/vesting/Cargo.toml @@ -12,15 +12,15 @@ codec = { package = "parity-scale-codec", version = "3.0.0", default-features = scale-info = { version = "2.9.0", default-features = false, features = ["derive"] } serde = { version = "1.0.183", optional = true } -frame-support = { default-features = false , git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -frame-system = { default-features = false , git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-io = { default-features = false , git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-runtime = { default-features = false , git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-std = { default-features = false , git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +frame-support = { default-features = false , git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +frame-system = { default-features = false , git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-io = { default-features = false , git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-runtime = { default-features = false , git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-std = { default-features = false , git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } [dev-dependencies] -pallet-balances = { git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-core = { git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +pallet-balances = { git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-core = { git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } [features] default = ["std"] diff --git a/test/subspace-test-client/Cargo.toml b/test/subspace-test-client/Cargo.toml index 679bb26614..c10c884192 100644 --- a/test/subspace-test-client/Cargo.toml +++ b/test/subspace-test-client/Cargo.toml @@ -17,20 +17,20 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] codec = { package = "parity-scale-codec", version = "3.6.5", features = ["derive"] } evm-domain-test-runtime = { version = "0.1.0", path = "../../domains/test/runtime/evm" } -fp-evm = { version = "3.0.0-dev", git = "https://github.com/subspace/frontier", rev = "56086daa77802eaa285894bfe4b811be66629c89" } +fp-evm = { version = "3.0.0-dev", git = "https://github.com/subspace/frontier", rev = "37ee45323120b21adc1d69ae7348bd0f7282eeae" } futures = "0.3.29" schnorrkel = "0.9.1" -sc-chain-spec = { git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sc-client-api = { git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +sc-chain-spec = { git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sc-client-api = { git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } sc-consensus-subspace = { version = "0.1.0", path = "../../crates/sc-consensus-subspace" } -sc-executor = { git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sc-service = { git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1", default-features = false } -sp-api = { git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +sc-executor = { git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sc-service = { git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c", default-features = false } +sp-api = { git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } sp-consensus-subspace = { version = "0.1.0", path = "../../crates/sp-consensus-subspace" } -sp-core = { git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +sp-core = { git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } sp-domains = { version = "0.1.0", path = "../../crates/sp-domains" } sp-domains-fraud-proof = { version = "0.1.0", path = "../../crates/sp-domains-fraud-proof" } -sp-runtime = { git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +sp-runtime = { git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } subspace-archiving = { path = "../../crates/subspace-archiving" } subspace-core-primitives = { path = "../../crates/subspace-core-primitives" } subspace-erasure-coding = { path = "../../crates/subspace-erasure-coding" } diff --git a/test/subspace-test-client/src/lib.rs b/test/subspace-test-client/src/lib.rs index 1dae44008a..071f62fdb7 100644 --- a/test/subspace-test-client/src/lib.rs +++ b/test/subspace-test-client/src/lib.rs @@ -26,7 +26,7 @@ use futures::StreamExt; use sc_client_api::{BlockBackend, HeaderBackend}; use sc_consensus_subspace::archiver::encode_block; use sc_consensus_subspace::notification::SubspaceNotificationStream; -use sc_consensus_subspace::{NewSlotNotification, RewardSigningNotification}; +use sc_consensus_subspace::slot_worker::{NewSlotNotification, RewardSigningNotification}; use sp_api::ProvideRuntimeApi; use sp_consensus_subspace::{FarmerPublicKey, FarmerSignature, SubspaceApi}; use sp_core::{Decode, Encode}; diff --git a/test/subspace-test-runtime/Cargo.toml b/test/subspace-test-runtime/Cargo.toml index bbbe709f01..9a37b9ba3d 100644 --- a/test/subspace-test-runtime/Cargo.toml +++ b/test/subspace-test-runtime/Cargo.toml @@ -18,49 +18,49 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] codec = { package = "parity-scale-codec", version = "3.6.5", default-features = false, features = ["derive"] } domain-runtime-primitives = { version = "0.1.0", default-features = false, path = "../../domains/primitives/runtime" } -frame-executive = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -frame-support = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -frame-system = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +frame-executive = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +frame-support = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +frame-system = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } orml-vesting = { version = "0.4.1-dev", default-features = false, path = "../../orml/vesting" } -pallet-balances = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +pallet-balances = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } pallet-domains = { version = "0.1.0", default-features = false, path = "../../crates/pallet-domains" } pallet-messenger = { version = "0.1.0", path = "../../domains/pallets/messenger", default-features = false } pallet-offences-subspace = { version = "0.1.0", default-features = false, path = "../../crates/pallet-offences-subspace" } pallet-rewards = { version = "0.1.0", default-features = false, path = "../../crates/pallet-rewards" } pallet-subspace = { version = "0.1.0", default-features = false, features = ["serde"], path = "../../crates/pallet-subspace" } -pallet-sudo = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -pallet-timestamp = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +pallet-sudo = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +pallet-timestamp = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } pallet-transaction-fees = { version = "0.1.0", default-features = false, path = "../../crates/pallet-transaction-fees" } -pallet-transaction-payment = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +pallet-transaction-payment = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } pallet-transporter = { version = "0.1.0", path = "../../domains/pallets/transporter", default-features = false } -pallet-utility = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +pallet-utility = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } scale-info = { version = "2.7.0", default-features = false, features = ["derive"] } -sp-api = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-block-builder = { git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1", default-features = false, version = "4.0.0-dev" } -sp-consensus-slots = { version = "0.10.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +sp-api = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-block-builder = { git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c", default-features = false, version = "4.0.0-dev" } +sp-consensus-slots = { version = "0.10.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } sp-consensus-subspace = { version = "0.1.0", default-features = false, path = "../../crates/sp-consensus-subspace" } -sp-core = { version = "21.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +sp-core = { version = "21.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } sp-domains = { version = "0.1.0", default-features = false, path = "../../crates/sp-domains" } sp-domains-fraud-proof = { version = "0.1.0", default-features = false, path = "../../crates/sp-domains-fraud-proof" } -sp-inherents = { git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1", default-features = false, version = "4.0.0-dev" } +sp-inherents = { git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c", default-features = false, version = "4.0.0-dev" } sp-messenger = { version = "0.1.0", default-features = false, path = "../../domains/primitives/messenger" } sp-objects = { version = "0.1.0", default-features = false, path = "../../crates/sp-objects" } -sp-offchain = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-runtime = { version = "24.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-session = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-std = { version = "8.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-transaction-pool = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-version = { version = "22.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +sp-offchain = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-runtime = { version = "24.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-session = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-std = { version = "8.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-transaction-pool = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-version = { version = "22.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } static_assertions = "1.1.0" subspace-core-primitives = { version = "0.1.0", default-features = false, path = "../../crates/subspace-core-primitives" } subspace-runtime-primitives = { version = "0.1.0", default-features = false, path = "../../crates/subspace-runtime-primitives" } # Used for the node template's RPCs -frame-system-rpc-runtime-api = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -pallet-transaction-payment-rpc-runtime-api = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +frame-system-rpc-runtime-api = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +pallet-transaction-payment-rpc-runtime-api = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } [build-dependencies] -substrate-wasm-builder = { version = "5.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1", optional = true } +substrate-wasm-builder = { version = "5.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c", optional = true } [features] default = ["std"] diff --git a/test/subspace-test-runtime/src/lib.rs b/test/subspace-test-runtime/src/lib.rs index 4068aa673d..172137f47a 100644 --- a/test/subspace-test-runtime/src/lib.rs +++ b/test/subspace-test-runtime/src/lib.rs @@ -44,7 +44,7 @@ pub use pallet_subspace::AllowAuthoringBy; use pallet_transporter::EndpointHandler; use scale_info::TypeInfo; use sp_api::{impl_runtime_apis, BlockT}; -use sp_consensus_slots::SlotDuration; +use sp_consensus_slots::{Slot, SlotDuration}; use sp_consensus_subspace::{ ChainConstants, EquivocationProof, FarmerPublicKey, PotParameters, SignedVote, SolutionRanges, Vote, @@ -266,6 +266,7 @@ parameter_types! { pub const PotEntropyInjectionInterval: BlockNumber = POT_ENTROPY_INJECTION_INTERVAL; pub const PotEntropyInjectionLookbackDepth: u8 = POT_ENTROPY_INJECTION_LOOKBACK_DEPTH; pub const PotEntropyInjectionDelay: SlotNumber = POT_ENTROPY_INJECTION_DELAY; + pub const EraDuration: BlockNumber = ERA_DURATION_IN_BLOCKS; pub const SlotProbability: (u64, u64) = SLOT_PROBABILITY; pub const ShouldAdjustSolutionRange: bool = false; pub const ExpectedVotesPerBlock: u32 = 9; @@ -284,7 +285,7 @@ impl pallet_subspace::Config for Runtime { type PotEntropyInjectionInterval = PotEntropyInjectionInterval; type PotEntropyInjectionLookbackDepth = PotEntropyInjectionLookbackDepth; type PotEntropyInjectionDelay = PotEntropyInjectionDelay; - type EraDuration = ConstU32; + type EraDuration = EraDuration; type InitialSolutionRange = ConstU64; type SlotProbability = SlotProbability; type ConfirmationDepthK = ConfirmationDepthK; @@ -1150,11 +1151,19 @@ impl_runtime_apis! { } fn chain_constants() -> ChainConstants { - Subspace::chain_constants() + ChainConstants::V1 { + confirmation_depth_k: ConfirmationDepthK::get(), + block_authoring_delay: Slot::from(BlockAuthoringDelay::get()), + era_duration: EraDuration::get(), + slot_probability: SlotProbability::get(), + slot_duration: SlotDuration::from_millis(SLOT_DURATION), + recent_segments: RecentSegments::get(), + recent_history_fraction: RecentHistoryFraction::get(), + min_sector_lifetime: MinSectorLifetime::get(), + } } } - #[api_version(2)] impl sp_domains::DomainsApi for Runtime { fn submit_bundle_unsigned( opaque_bundle: OpaqueBundle, ::Hash, DomainHeader, Balance>, diff --git a/test/subspace-test-service/Cargo.toml b/test/subspace-test-service/Cargo.toml index 85add1de0b..10e09e8f1a 100644 --- a/test/subspace-test-service/Cargo.toml +++ b/test/subspace-test-service/Cargo.toml @@ -25,31 +25,31 @@ jsonrpsee = { version = "0.16.3", features = ["server"] } rand = "0.8.5" pallet-domains = { version = "0.1.0", path = "../../crates/pallet-domains" } parking_lot = "0.12.1" -sc-block-builder = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sc-client-api = { git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sc-consensus = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sc-executor = { git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sc-network = { git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sc-network-sync = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sc-service = { git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1", default-features = false } -sc-tracing = { git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sc-transaction-pool = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sc-transaction-pool-api = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sc-utils = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-api = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-application-crypto = { git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-blockchain = { git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-core = { version = "21.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-consensus = { git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +sc-block-builder = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sc-client-api = { git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sc-consensus = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sc-executor = { git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sc-network = { git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sc-network-sync = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sc-service = { git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c", default-features = false } +sc-tracing = { git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sc-transaction-pool = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sc-transaction-pool-api = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sc-utils = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-api = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-application-crypto = { git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-blockchain = { git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-core = { version = "21.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-consensus = { git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } sp-consensus-subspace = { version = "0.1.0", path = "../../crates/sp-consensus-subspace" } -sp-consensus-slots = { version = "0.10.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +sp-consensus-slots = { version = "0.10.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } sp-domains = { version = "0.1.0", path = "../../crates/sp-domains" } sp-domains-fraud-proof = { version = "0.1.0", path = "../../crates/sp-domains-fraud-proof" } -sp-externalities = { version = "0.19.0", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-keyring = { git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-timestamp = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-inherents = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } -sp-runtime = { git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +sp-externalities = { version = "0.19.0", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-keyring = { git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-timestamp = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-inherents = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } +sp-runtime = { git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } subspace-core-primitives = { version = "0.1.0", default-features = false, path = "../../crates/subspace-core-primitives" } subspace-runtime-primitives = { path = "../../crates/subspace-runtime-primitives" } subspace-service = { path = "../../crates/subspace-service" } @@ -59,7 +59,7 @@ tokio = "1.34.0" tracing = "0.1.37" [dev-dependencies] -sp-keyring = { git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } +sp-keyring = { git = "https://github.com/subspace/polkadot-sdk", rev = "c63a8b28a9fd26d42116b0dcef1f2a5cefb9cd1c" } [features] do-not-enforce-cost-of-storage = [ diff --git a/test/subspace-test-service/src/lib.rs b/test/subspace-test-service/src/lib.rs index aaa5faa8cd..c89190e81f 100644 --- a/test/subspace-test-service/src/lib.rs +++ b/test/subspace-test-service/src/lib.rs @@ -605,7 +605,7 @@ impl MockConsensusNode { >::into(slot) * SLOT_DURATION, )); let subspace_inherents = - sp_consensus_subspace::inherents::InherentDataProvider::new(slot, vec![]); + sp_consensus_subspace::inherents::InherentDataProvider::new(vec![]); let inherent_data = (subspace_inherents, timestamp) .create_inherent_data()