From 0794d83d24fb5515e177e1739d7654910aa506f1 Mon Sep 17 00:00:00 2001 From: "Bill.W" <0xbillw@gmail.com> Date: Tue, 28 Nov 2023 15:11:04 +0800 Subject: [PATCH] upgrade to polkadot-v1.1.0 --- Cargo.lock | 1990 ++++++++++-------- Cargo.toml | 320 +-- crates/bloom-filter/Cargo.toml | 11 +- crates/bloom-filter/src/lib.rs | 7 +- crates/common/Cargo.toml | 2 +- crates/common/src/lib.rs | 2 +- crates/rrsc/Cargo.toml | 25 +- crates/rrsc/pallet/Cargo.toml | 26 +- crates/rrsc/pallet/src/benchmarking.rs | 2 +- crates/rrsc/pallet/src/default_weights.rs | 12 +- crates/rrsc/pallet/src/equivocation.rs | 11 +- crates/rrsc/pallet/src/lib.rs | 79 +- crates/rrsc/pallet/src/mock.rs | 55 +- crates/rrsc/pallet/src/randomness.rs | 17 +- crates/rrsc/pallet/src/tests.rs | 13 +- crates/rrsc/primitives/Cargo.toml | 24 +- crates/rrsc/primitives/src/lib.rs | 21 +- crates/rrsc/rpc/Cargo.toml | 1 + crates/rrsc/rpc/src/lib.rs | 31 +- crates/rrsc/src/authorship.rs | 14 +- crates/rrsc/src/lib.rs | 129 +- crates/rrsc/src/tests.rs | 145 +- crates/rrsc/src/verification.rs | 16 +- crates/rrsc/sync-state/Cargo.toml | 2 +- crates/scheduler-credit/Cargo.toml | 10 - pallets/audit/Cargo.toml | 2 +- pallets/audit/src/lib.rs | 37 +- pallets/audit/src/types.rs | 9 +- pallets/cacher/Cargo.toml | 2 +- pallets/cess-treasury/Cargo.toml | 2 +- pallets/file-bank/Cargo.toml | 48 +- pallets/file-bank/src/lib.rs | 23 +- pallets/file-bank/src/types.rs | 7 +- pallets/oss/Cargo.toml | 2 +- pallets/oss/src/mock.rs | 17 +- pallets/scheduler-credit/Cargo.toml | 2 +- pallets/scheduler-credit/src/lib.rs | 9 +- pallets/scheduler-credit/src/mock.rs | 23 +- pallets/scheduler-credit/src/tests.rs | 2 +- pallets/sminer/Cargo.toml | 3 +- pallets/sminer/src/functions.rs | 3 +- pallets/sminer/src/lib.rs | 51 +- pallets/staking/Cargo.toml | 56 +- pallets/staking/src/benchmarking.rs | 74 +- pallets/staking/src/election_size_tracker.rs | 259 +++ pallets/staking/src/lib.rs | 67 +- pallets/staking/src/migrations.rs | 36 +- pallets/staking/src/mock.rs | 122 +- pallets/staking/src/pallet/impls.rs | 215 +- pallets/staking/src/pallet/mod.rs | 155 +- pallets/staking/src/testing_utils.rs | 71 +- pallets/staking/src/tests.rs | 1394 +++++++----- pallets/staking/src/weights.rs | 458 ++-- pallets/storage-handler/Cargo.toml | 2 +- pallets/storage-handler/src/lib.rs | 26 +- pallets/storage-handler/src/types.rs | 6 +- pallets/tee-worker/Cargo.toml | 2 +- rustfmt.toml | 1 + standalone/chain/node/Cargo.toml | 71 +- standalone/chain/node/src/chain_spec.rs | 33 +- standalone/chain/node/src/cli.rs | 12 +- standalone/chain/node/src/client.rs | 29 +- standalone/chain/node/src/command.rs | 227 +- standalone/chain/node/src/eth.rs | 26 +- standalone/chain/node/src/executor.rs | 21 - standalone/chain/node/src/main.rs | 2 - standalone/chain/node/src/primitives.rs | 29 - standalone/chain/node/src/rpc/eth.rs | 47 +- standalone/chain/node/src/rpc/mod.rs | 119 +- standalone/chain/node/src/service.rs | 211 +- standalone/chain/runtime/Cargo.toml | 338 ++- standalone/chain/runtime/src/lib.rs | 254 +-- 72 files changed, 4176 insertions(+), 3394 deletions(-) create mode 100644 pallets/staking/src/election_size_tracker.rs delete mode 100755 standalone/chain/node/src/executor.rs delete mode 100755 standalone/chain/node/src/primitives.rs diff --git a/Cargo.lock b/Cargo.lock index 2e201857..0bfdd4e9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -14,11 +14,11 @@ dependencies = [ [[package]] name = "addr2line" -version = "0.17.0" +version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9ecd88a8c8378ca913a680cd98f0f13ac67383d35993f86c90a70e3f137816b" +checksum = "a76fd60b23679b7d19bd066031410fb7e458ccc5e958eb5c325888ce4baedc97" dependencies = [ - "gimli 0.26.2", + "gimli 0.27.3", ] [[package]] @@ -273,18 +273,223 @@ dependencies = [ "num-traits", ] +[[package]] +name = "aquamarine" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df752953c49ce90719c7bf1fc587bc8227aed04732ea0c0f85e5397d7fdbd1a1" +dependencies = [ + "include_dir", + "itertools 0.10.5", + "proc-macro-error", + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "arc-swap" version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bddcadddf5e9015d310179a59bb28c4d4b9920ad0f11e8e14dbadf654890c9a6" +[[package]] +name = "ark-bls12-381" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c775f0d12169cba7aae4caeb547bb6a50781c7449a8aa53793827c9ec4abf488" +dependencies = [ + "ark-ec", + "ark-ff", + "ark-serialize", + "ark-std", +] + +[[package]] +name = "ark-ec" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "defd9a439d56ac24968cca0571f598a61bc8c55f71d50a89cda591cb750670ba" +dependencies = [ + "ark-ff", + "ark-poly", + "ark-serialize", + "ark-std", + "derivative", + "hashbrown 0.13.2", + "itertools 0.10.5", + "num-traits", + "zeroize", +] + +[[package]] +name = "ark-ed-on-bls12-381-bandersnatch" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9cde0f2aa063a2a5c28d39b47761aa102bda7c13c84fc118a61b87c7b2f785c" +dependencies = [ + "ark-bls12-381", + "ark-ec", + "ark-ff", + "ark-std", +] + +[[package]] +name = "ark-ff" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec847af850f44ad29048935519032c33da8aa03340876d351dfab5660d2966ba" +dependencies = [ + "ark-ff-asm", + "ark-ff-macros", + "ark-serialize", + "ark-std", + "derivative", + "digest 0.10.7", + "itertools 0.10.5", + "num-bigint", + "num-traits", + "paste", + "rustc_version 0.4.0", + "zeroize", +] + +[[package]] +name = "ark-ff-asm" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ed4aa4fe255d0bc6d79373f7e31d2ea147bcf486cba1be5ba7ea85abdb92348" +dependencies = [ + "quote", + "syn 1.0.109", +] + +[[package]] +name = "ark-ff-macros" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7abe79b0e4288889c4574159ab790824d0033b9fdcb2a112a3182fac2e514565" +dependencies = [ + "num-bigint", + "num-traits", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "ark-poly" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d320bfc44ee185d899ccbadfa8bc31aab923ce1558716e1997a1e74057fe86bf" +dependencies = [ + "ark-ff", + "ark-serialize", + "ark-std", + "derivative", + "hashbrown 0.13.2", +] + +[[package]] +name = "ark-scale" +version = "0.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49b08346a3e38e2be792ef53ee168623c9244d968ff00cd70fb9932f6fe36393" +dependencies = [ + "ark-ec", + "ark-ff", + "ark-serialize", + "ark-std", + "parity-scale-codec", +] + +[[package]] +name = "ark-scale" +version = "0.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51bd73bb6ddb72630987d37fa963e99196896c0d0ea81b7c894567e74a2f83af" +dependencies = [ + "ark-ec", + "ark-ff", + "ark-serialize", + "ark-std", + "parity-scale-codec", + "scale-info", +] + +[[package]] +name = "ark-secret-scalar" +version = "0.0.2" +source = "git+https://github.com/w3f/ring-vrf?rev=3119f51#3119f51b54b69308abfb0671f6176cb125ae1bf1" +dependencies = [ + "ark-ec", + "ark-ff", + "ark-serialize", + "ark-std", + "ark-transcript", + "digest 0.10.7", + "rand_core 0.6.4", + "zeroize", +] + +[[package]] +name = "ark-serialize" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "adb7b85a02b83d2f22f89bd5cac66c9c89474240cb6207cb1efc16d098e822a5" +dependencies = [ + "ark-serialize-derive", + "ark-std", + "digest 0.10.7", + "num-bigint", +] + +[[package]] +name = "ark-serialize-derive" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae3281bc6d0fd7e549af32b52511e1302185bd688fd3359fa36423346ff682ea" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "ark-std" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94893f1e0c6eeab764ade8dc4c0db24caf4fe7cbbaafc0eba0a9030f447b5185" +dependencies = [ + "num-traits", + "rand 0.8.5", +] + +[[package]] +name = "ark-transcript" +version = "0.0.2" +source = "git+https://github.com/w3f/ring-vrf?rev=3119f51#3119f51b54b69308abfb0671f6176cb125ae1bf1" +dependencies = [ + "ark-ff", + "ark-serialize", + "ark-std", + "digest 0.10.7", + "rand_core 0.6.4", + "sha3", +] + [[package]] name = "array-bytes" version = "4.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f52f63c5c1316a16a4b35eaac8b76a98248961a533f061684cb2a7cb0eafb6c6" +[[package]] +name = "array-bytes" +version = "6.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de17a919934ad8c5cc99a1a74de4e2dab95d6121a8f27f94755ff525b630382c" + [[package]] name = "arrayref" version = "0.3.7" @@ -370,12 +575,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "asn1_der" -version = "0.7.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "155a5a185e42c6b77ac7b88a15143d930a9e9727a5b7b77eed417404ab15c247" - [[package]] name = "assert_matches" version = "1.5.0" @@ -516,6 +715,28 @@ dependencies = [ "rustc-demangle", ] +[[package]] +name = "bandersnatch_vrfs" +version = "0.0.1" +source = "git+https://github.com/w3f/ring-vrf?rev=3119f51#3119f51b54b69308abfb0671f6176cb125ae1bf1" +dependencies = [ + "ark-bls12-381", + "ark-ec", + "ark-ed-on-bls12-381-bandersnatch", + "ark-ff", + "ark-scale 0.0.11", + "ark-serialize", + "ark-std", + "dleq_vrf", + "fflonk", + "merlin 3.0.0", + "rand_chacha 0.3.1", + "rand_core 0.6.4", + "ring 0.1.0", + "sha2 0.10.8", + "zeroize", +] + [[package]] name = "base-x" version = "0.2.11" @@ -576,15 +797,6 @@ dependencies = [ "serde", ] -[[package]] -name = "binary-merkle-tree" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" -dependencies = [ - "hash-db 0.16.0", - "log", -] - [[package]] name = "bincode" version = "1.3.3" @@ -596,9 +808,9 @@ dependencies = [ [[package]] name = "bindgen" -version = "0.64.0" +version = "0.65.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4243e6031260db77ede97ad86c27e501d646a27ab57b59a574f725d98ab1fb4" +checksum = "cfdf7b466f9a4903edc73f95d6d2bcd5baf8ae620638762244d3f60143643cc5" dependencies = [ "bitflags 1.3.2", "cexpr", @@ -606,12 +818,13 @@ dependencies = [ "lazy_static", "lazycell", "peeking_take_while", + "prettyplease 0.2.15", "proc-macro2", "quote", "regex", "rustc-hash", "shlex", - "syn 1.0.109", + "syn 2.0.39", ] [[package]] @@ -755,6 +968,15 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "771fe0050b883fcc3ea2359b1a96bcfbc090b7116eae7c3c512c7a083fdf23d3" +[[package]] +name = "bs58" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f5353f36341f7451062466f0b755b96ac3a9547e4d7f6b70d603fc721a7d7896" +dependencies = [ + "tinyvec", +] + [[package]] name = "bstr" version = "1.8.0" @@ -878,7 +1100,7 @@ dependencies = [ name = "cess-node" version = "0.7.4" dependencies = [ - "array-bytes", + "array-bytes 4.2.0", "async-trait", "cess-node-runtime", "cessc-consensus-rrsc", @@ -886,6 +1108,7 @@ dependencies = [ "cessc-sync-state-rpc", "cessp-consensus-rrsc", "clap", + "fc-api", "fc-cli", "fc-consensus", "fc-db", @@ -929,6 +1152,7 @@ dependencies = [ "sc-network", "sc-network-common", "sc-network-sync", + "sc-offchain", "sc-rpc", "sc-rpc-api", "sc-rpc-spec-v2", @@ -1074,6 +1298,7 @@ dependencies = [ "sc-network", "sc-network-test", "sc-telemetry", + "sc-transaction-pool-api", "scale-info", "sp-api", "sp-application-crypto", @@ -1106,6 +1331,7 @@ dependencies = [ "sc-consensus-epochs", "sc-keystore", "sc-rpc-api", + "sc-transaction-pool-api", "serde", "serde_json", "sp-api", @@ -1149,11 +1375,9 @@ dependencies = [ "serde", "sp-api", "sp-application-crypto", - "sp-consensus", "sp-consensus-slots", "sp-core", "sp-inherents", - "sp-keystore", "sp-runtime", "sp-std", "sp-timestamp", @@ -1170,9 +1394,9 @@ dependencies = [ [[package]] name = "cfg-expr" -version = "0.10.3" +version = "0.15.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0aacacf4d96c24b2ad6eb8ee6df040e4f27b0d0b39a5710c30091baa830485db" +checksum = "03915af431787e6ffdcc74c645077518c6b6e01f80b761e0fbbfa288536311b3" dependencies = [ "smallvec", ] @@ -1229,13 +1453,13 @@ dependencies = [ [[package]] name = "cid" -version = "0.8.6" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6ed9c8b2d17acb8110c46f1da5bf4a696d745e1474a16db0cd2b49cd0249bf2" +checksum = "b9b68e3193982cd54187d71afdb2a271ad4cf8af157858e9cb911b91321de143" dependencies = [ "core2", "multibase", - "multihash 0.16.3", + "multihash", "serde", "unsigned-varint", ] @@ -1347,15 +1571,35 @@ checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" [[package]] name = "comfy-table" -version = "6.2.0" +version = "7.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e959d788268e3bf9d35ace83e81b124190378e4c91c9067524675e33394b8ba" +checksum = "7c64043d6c7b7a4c58e39e7efccfdea7b93d885a795d0c054a69dbbf4dd52686" dependencies = [ - "strum", - "strum_macros", + "strum 0.25.0", + "strum_macros 0.25.3", "unicode-width", ] +[[package]] +name = "common" +version = "0.1.0" +source = "git+https://github.com/w3f/ring-proof?rev=0e948f3#0e948f3c28cbacecdd3020403c4841c0eb339213" +dependencies = [ + "ark-ec", + "ark-ff", + "ark-poly", + "ark-serialize", + "ark-std", + "fflonk", + "merlin 3.0.0", +] + +[[package]] +name = "common-path" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2382f75942f4b3be3690fe4f86365e9c853c1587d6ee58212cebf6e2a9ccd101" + [[package]] name = "concurrent-queue" version = "2.3.0" @@ -1384,6 +1628,26 @@ version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "28c122c3980598d243d63d9a704629a2d748d101f278052ff068be5a4423ab6f" +[[package]] +name = "const-random" +version = "0.1.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5aaf16c9c2c612020bcfd042e170f6e32de9b9d75adb5277cdbbd2e2c8c8299a" +dependencies = [ + "const-random-macro", +] + +[[package]] +name = "const-random-macro" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9d839f2a20b0aee515dc581a6172f2321f96cab76c1a38a4c584a194955390e" +dependencies = [ + "getrandom 0.2.11", + "once_cell", + "tiny-keccak", +] + [[package]] name = "constant_time_eq" version = "0.3.0" @@ -1419,12 +1683,9 @@ dependencies = [ name = "cp-bloom-filter" version = "0.1.0" dependencies = [ - "cp-cess-common", - "frame-support", - "log", "parity-scale-codec", "scale-info", - "sp-std", + "sp-core", ] [[package]] @@ -1452,11 +1713,6 @@ name = "cp-scheduler-credit" version = "0.1.0" dependencies = [ "frame-support", - "parity-scale-codec", - "scale-info", - "sp-api", - "sp-core", - "sp-std", ] [[package]] @@ -1479,28 +1735,27 @@ dependencies = [ [[package]] name = "cranelift-bforest" -version = "0.93.2" +version = "0.95.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bc42ba2e232e5b20ff7dc299a812d53337dadce9a7e39a238e6a5cb82d2e57b" +checksum = "1277fbfa94bc82c8ec4af2ded3e639d49ca5f7f3c7eeab2c66accd135ece4e70" dependencies = [ "cranelift-entity", ] [[package]] name = "cranelift-codegen" -version = "0.93.2" +version = "0.95.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "253531aca9b6f56103c9420369db3263e784df39aa1c90685a1f69cfbba0623e" +checksum = "c6e8c31ad3b2270e9aeec38723888fe1b0ace3bea2b06b3f749ccf46661d3220" dependencies = [ - "arrayvec 0.7.4", "bumpalo", "cranelift-bforest", "cranelift-codegen-meta", "cranelift-codegen-shared", "cranelift-entity", "cranelift-isle", - "gimli 0.26.2", - "hashbrown 0.12.3", + "gimli 0.27.3", + "hashbrown 0.13.2", "log", "regalloc2", "smallvec", @@ -1509,33 +1764,33 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" -version = "0.93.2" +version = "0.95.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72f2154365e2bff1b1b8537a7181591fdff50d8e27fa6e40d5c69c3bad0ca7c8" +checksum = "c8ac5ac30d62b2d66f12651f6b606dbdfd9c2cfd0908de6b387560a277c5c9da" dependencies = [ "cranelift-codegen-shared", ] [[package]] name = "cranelift-codegen-shared" -version = "0.93.2" +version = "0.95.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "687e14e3f5775248930e0d5a84195abef8b829958e9794bf8d525104993612b4" +checksum = "dd82b8b376247834b59ed9bdc0ddeb50f517452827d4a11bccf5937b213748b8" [[package]] name = "cranelift-entity" -version = "0.93.2" +version = "0.95.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f42ea692c7b450ad18b8c9889661505d51c09ec4380cf1c2d278dbb2da22cae1" +checksum = "40099d38061b37e505e63f89bab52199037a72b931ad4868d9089ff7268660b0" dependencies = [ "serde", ] [[package]] name = "cranelift-frontend" -version = "0.93.2" +version = "0.95.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8483c2db6f45fe9ace984e5adc5d058102227e4c62e5aa2054e16b0275fd3a6e" +checksum = "64a25d9d0a0ae3079c463c34115ec59507b4707175454f0eee0891e83e30e82d" dependencies = [ "cranelift-codegen", "log", @@ -1545,15 +1800,15 @@ dependencies = [ [[package]] name = "cranelift-isle" -version = "0.93.2" +version = "0.95.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9793158837678902446c411741d87b43f57dadfb944f2440db4287cda8cbd59" +checksum = "80de6a7d0486e4acbd5f9f87ec49912bf4c8fb6aea00087b989685460d4469ba" [[package]] name = "cranelift-native" -version = "0.93.2" +version = "0.95.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72668c7755f2b880665cb422c8ad2d56db58a88b9bebfef0b73edc2277c13c49" +checksum = "bb6b03e0e03801c4b3fd8ce0758a94750c07a44e7944cc0ffbf0d3f2e7c79b00" dependencies = [ "cranelift-codegen", "libc", @@ -1562,9 +1817,9 @@ dependencies = [ [[package]] name = "cranelift-wasm" -version = "0.93.2" +version = "0.95.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3852ce4b088b44ac4e29459573943009a70d1b192c8d77ef949b4e814f656fc1" +checksum = "ff3220489a3d928ad91e59dd7aeaa8b3de18afb554a6211213673a71c90737ac" dependencies = [ "cranelift-codegen", "cranelift-entity", @@ -1759,7 +2014,7 @@ dependencies = [ "curve25519-dalek-derive", "digest 0.10.7", "fiat-crypto", - "platforms 3.2.0", + "platforms", "rustc_version 0.4.0", "subtle", "zeroize", @@ -1939,6 +2194,17 @@ dependencies = [ "powerfmt", ] +[[package]] +name = "derivative" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "derive-syn-parse" version = "0.1.5" @@ -2092,6 +2358,50 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "86e3bdc80eee6e16b2b6b0f87fbc98c04bee3455e35174c0de1a125d0688c632" +[[package]] +name = "dleq_vrf" +version = "0.0.2" +source = "git+https://github.com/w3f/ring-vrf?rev=3119f51#3119f51b54b69308abfb0671f6176cb125ae1bf1" +dependencies = [ + "ark-ec", + "ark-ff", + "ark-scale 0.0.10", + "ark-secret-scalar", + "ark-serialize", + "ark-std", + "ark-transcript", + "arrayvec 0.7.4", + "rand_core 0.6.4", + "zeroize", +] + +[[package]] +name = "docify" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4235e9b248e2ba4b92007fe9c646f3adf0ffde16dc74713eacc92b8bc58d8d2f" +dependencies = [ + "docify_macros", +] + +[[package]] +name = "docify_macros" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47020e12d7c7505670d1363dd53d6c23724f71a90a3ae32ff8eba40de8404626" +dependencies = [ + "common-path", + "derive-syn-parse", + "once_cell", + "proc-macro2", + "quote", + "regex", + "syn 2.0.39", + "termcolor", + "toml 0.7.8", + "walkdir", +] + [[package]] name = "dotenvy" version = "0.15.7" @@ -2169,15 +2479,6 @@ dependencies = [ "spki 0.7.2", ] -[[package]] -name = "ed25519" -version = "1.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91cff35c70bba8a626e3185d8cd48cc11b5437e1a5bcd15b9b5fa3c64b6dfee7" -dependencies = [ - "signature 1.6.4", -] - [[package]] name = "ed25519" version = "2.2.3" @@ -2188,20 +2489,6 @@ dependencies = [ "signature 2.1.0", ] -[[package]] -name = "ed25519-dalek" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c762bae6dcaf24c4c84667b8579785430908723d5c889f469d76a41d59cc7a9d" -dependencies = [ - "curve25519-dalek 3.2.0", - "ed25519 1.5.3", - "rand 0.7.3", - "serde", - "sha2 0.9.9", - "zeroize", -] - [[package]] name = "ed25519-dalek" version = "2.0.0" @@ -2209,7 +2496,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7277392b266383ef8396db7fdeb1e77b6c52fed775f5df15bb24f35b72156980" dependencies = [ "curve25519-dalek 4.1.1", - "ed25519 2.2.3", + "ed25519", "rand_core 0.6.4", "serde", "sha2 0.10.8", @@ -2453,15 +2740,15 @@ dependencies = [ [[package]] name = "expander" -version = "1.0.0" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f360349150728553f92e4c997a16af8915f418d3a0f21b440d34c5632f16ed84" +checksum = "5f86a749cf851891866c10515ef6c299b5c69661465e9c3bbe7e07a2b77fb0f7" dependencies = [ "blake2", "fs-err", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.39", ] [[package]] @@ -2491,10 +2778,22 @@ version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5" +[[package]] +name = "fc-api" +version = "1.0.0-dev" +source = "git+https://github.com/paritytech/frontier?branch=polkadot-v1.1.0#de5a3df59d3ada67c8cacdb79e607ad0b229ec5b" +dependencies = [ + "async-trait", + "fp-storage", + "parity-scale-codec", + "sp-core", + "sp-runtime", +] + [[package]] name = "fc-cli" version = "1.0.0-dev" -source = "git+https://github.com/paritytech/frontier?branch=polkadot-v0.9.42#2499d18c936edbcb7fcb711827db7abb9b4f4da4" +source = "git+https://github.com/paritytech/frontier?branch=polkadot-v1.1.0#de5a3df59d3ada67c8cacdb79e607ad0b229ec5b" dependencies = [ "clap", "ethereum-types", @@ -2512,7 +2811,7 @@ dependencies = [ [[package]] name = "fc-consensus" version = "2.0.0-dev" -source = "git+https://github.com/paritytech/frontier?branch=polkadot-v0.9.42#2499d18c936edbcb7fcb711827db7abb9b4f4da4" +source = "git+https://github.com/paritytech/frontier?branch=polkadot-v1.1.0#de5a3df59d3ada67c8cacdb79e607ad0b229ec5b" dependencies = [ "async-trait", "fp-consensus", @@ -2528,10 +2827,11 @@ dependencies = [ [[package]] name = "fc-db" version = "2.0.0-dev" -source = "git+https://github.com/paritytech/frontier?branch=polkadot-v0.9.42#2499d18c936edbcb7fcb711827db7abb9b4f4da4" +source = "git+https://github.com/paritytech/frontier?branch=polkadot-v1.1.0#de5a3df59d3ada67c8cacdb79e607ad0b229ec5b" dependencies = [ "async-trait", "ethereum", + "fc-api", "fc-storage", "fp-consensus", "fp-rpc", @@ -2558,7 +2858,7 @@ dependencies = [ [[package]] name = "fc-mapping-sync" version = "2.0.0-dev" -source = "git+https://github.com/paritytech/frontier?branch=polkadot-v0.9.42#2499d18c936edbcb7fcb711827db7abb9b4f4da4" +source = "git+https://github.com/paritytech/frontier?branch=polkadot-v1.1.0#de5a3df59d3ada67c8cacdb79e607ad0b229ec5b" dependencies = [ "fc-db", "fc-storage", @@ -2581,16 +2881,15 @@ dependencies = [ [[package]] name = "fc-rpc" version = "2.0.0-dev" -source = "git+https://github.com/paritytech/frontier?branch=polkadot-v0.9.42#2499d18c936edbcb7fcb711827db7abb9b4f4da4" +source = "git+https://github.com/paritytech/frontier?branch=polkadot-v1.1.0#de5a3df59d3ada67c8cacdb79e607ad0b229ec5b" dependencies = [ "ethereum", "ethereum-types", "evm", - "fc-db", + "fc-api", "fc-mapping-sync", "fc-rpc-core", "fc-storage", - "fp-ethereum", "fp-evm", "fp-rpc", "fp-storage", @@ -2599,13 +2898,13 @@ dependencies = [ "jsonrpsee", "libsecp256k1", "log", - "lru", "pallet-evm", "parity-scale-codec", "prometheus", "rand 0.8.5", "rlp", "sc-client-api", + "sc-consensus-aura", "sc-network", "sc-network-common", "sc-network-sync", @@ -2614,24 +2913,29 @@ dependencies = [ "sc-transaction-pool", "sc-transaction-pool-api", "sc-utils", + "schnellru", "serde", "sp-api", "sp-block-builder", "sp-blockchain", "sp-consensus", + "sp-consensus-aura", "sp-core", + "sp-inherents", "sp-io", "sp-runtime", "sp-state-machine", "sp-storage", + "sp-timestamp", "substrate-prometheus-endpoint", + "thiserror", "tokio", ] [[package]] name = "fc-rpc-core" version = "1.1.0-dev" -source = "git+https://github.com/paritytech/frontier?branch=polkadot-v0.9.42#2499d18c936edbcb7fcb711827db7abb9b4f4da4" +source = "git+https://github.com/paritytech/frontier?branch=polkadot-v1.1.0#de5a3df59d3ada67c8cacdb79e607ad0b229ec5b" dependencies = [ "ethereum", "ethereum-types", @@ -2644,7 +2948,7 @@ dependencies = [ [[package]] name = "fc-storage" version = "1.0.0-dev" -source = "git+https://github.com/paritytech/frontier?branch=polkadot-v0.9.42#2499d18c936edbcb7fcb711827db7abb9b4f4da4" +source = "git+https://github.com/paritytech/frontier?branch=polkadot-v1.1.0#de5a3df59d3ada67c8cacdb79e607ad0b229ec5b" dependencies = [ "ethereum", "ethereum-types", @@ -2688,6 +2992,19 @@ dependencies = [ "subtle", ] +[[package]] +name = "fflonk" +version = "0.1.0" +source = "git+https://github.com/w3f/fflonk#1beb0585e1c8488956fac7f05da061f9b41e8948" +dependencies = [ + "ark-ec", + "ark-ff", + "ark-poly", + "ark-serialize", + "ark-std", + "merlin 3.0.0", +] + [[package]] name = "fiat-crypto" version = "0.2.4" @@ -2805,7 +3122,7 @@ checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" [[package]] name = "fork-tree" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "parity-scale-codec", ] @@ -2822,7 +3139,7 @@ dependencies = [ [[package]] name = "fp-account" version = "1.0.0-dev" -source = "git+https://github.com/paritytech/frontier?branch=polkadot-v0.9.42#2499d18c936edbcb7fcb711827db7abb9b4f4da4" +source = "git+https://github.com/paritytech/frontier?branch=polkadot-v1.1.0#de5a3df59d3ada67c8cacdb79e607ad0b229ec5b" dependencies = [ "hex", "impl-serde", @@ -2841,7 +3158,7 @@ dependencies = [ [[package]] name = "fp-consensus" version = "2.0.0-dev" -source = "git+https://github.com/paritytech/frontier?branch=polkadot-v0.9.42#2499d18c936edbcb7fcb711827db7abb9b4f4da4" +source = "git+https://github.com/paritytech/frontier?branch=polkadot-v1.1.0#de5a3df59d3ada67c8cacdb79e607ad0b229ec5b" dependencies = [ "ethereum", "parity-scale-codec", @@ -2853,7 +3170,7 @@ dependencies = [ [[package]] name = "fp-dynamic-fee" version = "1.0.0" -source = "git+https://github.com/paritytech/frontier?branch=polkadot-v0.9.42#2499d18c936edbcb7fcb711827db7abb9b4f4da4" +source = "git+https://github.com/paritytech/frontier?branch=polkadot-v1.1.0#de5a3df59d3ada67c8cacdb79e607ad0b229ec5b" dependencies = [ "async-trait", "sp-core", @@ -2863,13 +3180,12 @@ dependencies = [ [[package]] name = "fp-ethereum" version = "1.0.0-dev" -source = "git+https://github.com/paritytech/frontier?branch=polkadot-v0.9.42#2499d18c936edbcb7fcb711827db7abb9b4f4da4" +source = "git+https://github.com/paritytech/frontier?branch=polkadot-v1.1.0#de5a3df59d3ada67c8cacdb79e607ad0b229ec5b" dependencies = [ "ethereum", "ethereum-types", "fp-evm", "frame-support", - "num_enum", "parity-scale-codec", "sp-std", ] @@ -2877,10 +3193,11 @@ dependencies = [ [[package]] name = "fp-evm" version = "3.0.0-dev" -source = "git+https://github.com/paritytech/frontier?branch=polkadot-v0.9.42#2499d18c936edbcb7fcb711827db7abb9b4f4da4" +source = "git+https://github.com/paritytech/frontier?branch=polkadot-v1.1.0#de5a3df59d3ada67c8cacdb79e607ad0b229ec5b" dependencies = [ "evm", "frame-support", + "num_enum", "parity-scale-codec", "scale-info", "serde", @@ -2892,7 +3209,7 @@ dependencies = [ [[package]] name = "fp-rpc" version = "3.0.0-dev" -source = "git+https://github.com/paritytech/frontier?branch=polkadot-v0.9.42#2499d18c936edbcb7fcb711827db7abb9b4f4da4" +source = "git+https://github.com/paritytech/frontier?branch=polkadot-v1.1.0#de5a3df59d3ada67c8cacdb79e607ad0b229ec5b" dependencies = [ "ethereum", "ethereum-types", @@ -2909,7 +3226,7 @@ dependencies = [ [[package]] name = "fp-self-contained" version = "1.0.0-dev" -source = "git+https://github.com/paritytech/frontier?branch=polkadot-v0.9.42#2499d18c936edbcb7fcb711827db7abb9b4f4da4" +source = "git+https://github.com/paritytech/frontier?branch=polkadot-v1.1.0#de5a3df59d3ada67c8cacdb79e607ad0b229ec5b" dependencies = [ "frame-support", "parity-scale-codec", @@ -2921,7 +3238,7 @@ dependencies = [ [[package]] name = "fp-storage" version = "2.0.0" -source = "git+https://github.com/paritytech/frontier?branch=polkadot-v0.9.42#2499d18c936edbcb7fcb711827db7abb9b4f4da4" +source = "git+https://github.com/paritytech/frontier?branch=polkadot-v1.1.0#de5a3df59d3ada67c8cacdb79e607ad0b229ec5b" dependencies = [ "parity-scale-codec", "serde", @@ -2936,7 +3253,7 @@ checksum = "6c2141d6d6c8512188a7891b4b01590a45f6dac67afb4f255c4124dbb86d4eaa" [[package]] name = "frame-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "frame-support", "frame-support-procedural", @@ -2961,10 +3278,10 @@ dependencies = [ [[package]] name = "frame-benchmarking-cli" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "Inflector", - "array-bytes", + "array-bytes 6.2.0", "chrono", "clap", "comfy-table", @@ -2995,12 +3312,13 @@ dependencies = [ "sp-database", "sp-externalities", "sp-inherents", + "sp-io", "sp-keystore", "sp-runtime", "sp-state-machine", - "sp-std", "sp-storage", "sp-trie", + "sp-wasm-interface", "thiserror", "thousands", ] @@ -3008,7 +3326,7 @@ dependencies = [ [[package]] name = "frame-election-provider-solution-type" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -3019,7 +3337,7 @@ dependencies = [ [[package]] name = "frame-election-provider-support" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "frame-election-provider-solution-type", "frame-support", @@ -3036,11 +3354,12 @@ dependencies = [ [[package]] name = "frame-executive" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "frame-support", "frame-system", "frame-try-runtime", + "log", "parity-scale-codec", "scale-info", "sp-core", @@ -3052,9 +3371,9 @@ dependencies = [ [[package]] name = "frame-metadata" -version = "15.1.0" +version = "16.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "878babb0b136e731cc77ec2fd883ff02745ff21e6fb662729953d44923df009c" +checksum = "87cf1549fba25a6fcac22785b61698317d958e96cac72a59102ea45b9ae64692" dependencies = [ "cfg-if", "parity-scale-codec", @@ -3065,7 +3384,7 @@ dependencies = [ [[package]] name = "frame-remote-externalities" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "async-recursion", "futures", @@ -3077,54 +3396,65 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", + "sp-state-machine", "spinners", "substrate-rpc-client", "tokio", + "tokio-retry", ] [[package]] name = "frame-support" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ + "aquamarine", "bitflags 1.3.2", + "docify", "environmental", "frame-metadata", "frame-support-procedural", "impl-trait-for-tuples", "k256", "log", - "once_cell", + "macro_magic", "parity-scale-codec", "paste", "scale-info", "serde", + "serde_json", "smallvec", "sp-api", "sp-arithmetic", "sp-core", "sp-core-hashing-proc-macro", + "sp-debug-derive", + "sp-genesis-builder", "sp-inherents", "sp-io", + "sp-metadata-ir", "sp-runtime", "sp-staking", "sp-state-machine", "sp-std", "sp-tracing", "sp-weights", + "static_assertions", "tt-call", ] [[package]] name = "frame-support-procedural" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "Inflector", "cfg-expr", "derive-syn-parse", + "expander", "frame-support-procedural-tools", "itertools 0.10.5", + "macro_magic", "proc-macro-warning", "proc-macro2", "quote", @@ -3134,7 +3464,7 @@ dependencies = [ [[package]] name = "frame-support-procedural-tools" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "frame-support-procedural-tools-derive", "proc-macro-crate", @@ -3146,7 +3476,7 @@ dependencies = [ [[package]] name = "frame-support-procedural-tools-derive" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "proc-macro2", "quote", @@ -3156,9 +3486,11 @@ dependencies = [ [[package]] name = "frame-support-test" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "frame-benchmarking", + "frame-executive", + "frame-metadata", "frame-support", "frame-support-test-pallet", "frame-system", @@ -3171,29 +3503,34 @@ dependencies = [ "sp-arithmetic", "sp-core", "sp-io", + "sp-metadata-ir", "sp-runtime", "sp-state-machine", "sp-std", "sp-version", + "static_assertions", "trybuild", ] [[package]] name = "frame-support-test-pallet" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "frame-support", "frame-system", "parity-scale-codec", "scale-info", + "serde", + "sp-runtime", ] [[package]] name = "frame-system" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ + "cfg-if", "frame-support", "log", "parity-scale-codec", @@ -3210,7 +3547,7 @@ dependencies = [ [[package]] name = "frame-system-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "frame-benchmarking", "frame-support", @@ -3225,7 +3562,7 @@ dependencies = [ [[package]] name = "frame-system-rpc-runtime-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "parity-scale-codec", "sp-api", @@ -3234,7 +3571,7 @@ dependencies = [ [[package]] name = "frame-try-runtime" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "frame-support", "parity-scale-codec", @@ -3262,16 +3599,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "fs4" -version = "0.6.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2eeb4ed9e12f43b7fa0baae3f9cdda28352770132ef2e09a23760c29cae8bd47" -dependencies = [ - "rustix 0.38.24", - "windows-sys 0.48.0", -] - [[package]] name = "funty" version = "2.0.0" @@ -3494,9 +3821,9 @@ dependencies = [ [[package]] name = "gimli" -version = "0.26.2" +version = "0.27.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22030e2c5a68ec659fde1e949a745124b48e6fa8b045b7ed5bd1fe4ccc5c4e5d" +checksum = "b6c80984affa11d98d1b88b66ac8853f143217b399d3c74116778ff8fdb4ed2e" dependencies = [ "fallible-iterator", "indexmap 1.9.3", @@ -3816,21 +4143,6 @@ dependencies = [ "want", ] -[[package]] -name = "hyper-rustls" -version = "0.23.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1788965e61b367cd03a62950836d5cd41560c3577d90e40e0819373194d1661c" -dependencies = [ - "http", - "hyper", - "log", - "rustls 0.20.9", - "rustls-native-certs", - "tokio", - "tokio-rustls 0.23.4", -] - [[package]] name = "hyper-rustls" version = "0.24.2" @@ -3844,7 +4156,7 @@ dependencies = [ "rustls 0.21.8", "rustls-native-certs", "tokio", - "tokio-rustls 0.24.1", + "tokio-rustls", "webpki-roots 0.25.2", ] @@ -3965,6 +4277,25 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "include_dir" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "18762faeff7122e89e0857b02f7ce6fcc0d101d5e9ad2ad7846cc01d61b7f19e" +dependencies = [ + "include_dir_macros", +] + +[[package]] +name = "include_dir_macros" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b139284b5cf57ecfa712bcc66950bb635b31aff41c188e8a4cfc758eca374a3f" +dependencies = [ + "proc-macro2", + "quote", +] + [[package]] name = "indexmap" version = "1.9.3" @@ -4182,7 +4513,7 @@ dependencies = [ "soketto", "thiserror", "tokio", - "tokio-rustls 0.24.1", + "tokio-rustls", "tokio-util", "tracing", "webpki-roots 0.25.2", @@ -4224,7 +4555,7 @@ checksum = "7e5f9fabdd5d79344728521bb65e3106b49ec405a78b66fbff073b72b389fa43" dependencies = [ "async-trait", "hyper", - "hyper-rustls 0.24.2", + "hyper-rustls", "jsonrpsee-core", "jsonrpsee-types", "rustc-hash", @@ -4339,9 +4670,9 @@ dependencies = [ [[package]] name = "kvdb-rocksdb" -version = "0.18.0" +version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe7a749456510c45f795e8b04a6a3e0976d0139213ecbf465843830ad55e2217" +checksum = "b644c70b92285f66bfc2032922a79000ea30af7bc2ab31902992a5dcb9b434f6" dependencies = [ "kvdb", "num_cpus", @@ -4390,22 +4721,24 @@ checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" [[package]] name = "libp2p" -version = "0.50.1" +version = "0.51.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c7b0104790be871edcf97db9bd2356604984e623a08d825c3f27852290266b8" +checksum = "f210d259724eae82005b5c48078619b7745edb7b76de370b03f8ba59ea103097" dependencies = [ "bytes", "futures", "futures-timer", "getrandom 0.2.11", "instant", - "libp2p-core 0.38.0", + "libp2p-allow-block-list", + "libp2p-connection-limits", + "libp2p-core", "libp2p-dns", "libp2p-identify", + "libp2p-identity", "libp2p-kad", "libp2p-mdns", "libp2p-metrics", - "libp2p-mplex", "libp2p-noise", "libp2p-ping", "libp2p-quic", @@ -4416,44 +4749,32 @@ dependencies = [ "libp2p-webrtc", "libp2p-websocket", "libp2p-yamux", - "multiaddr 0.16.0", - "parking_lot 0.12.1", + "multiaddr", "pin-project", - "smallvec", ] [[package]] -name = "libp2p-core" -version = "0.38.0" +name = "libp2p-allow-block-list" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6a8fcd392ff67af6cc3f03b1426c41f7f26b6b9aff2dc632c1c56dd649e571f" +checksum = "510daa05efbc25184458db837f6f9a5143888f1caa742426d92e1833ddd38a50" dependencies = [ - "asn1_der", - "bs58", - "ed25519-dalek 1.0.1", - "either", - "fnv", - "futures", - "futures-timer", - "instant", - "log", - "multiaddr 0.16.0", - "multihash 0.16.3", - "multistream-select", - "once_cell", - "parking_lot 0.12.1", - "pin-project", - "prost", - "prost-build", - "rand 0.8.5", - "rw-stream-sink", - "sec1 0.3.0", - "sha2 0.10.8", - "smallvec", - "thiserror", - "unsigned-varint", + "libp2p-core", + "libp2p-identity", + "libp2p-swarm", + "void", +] + +[[package]] +name = "libp2p-connection-limits" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4caa33f1d26ed664c4fe2cca81a08c8e07d4c1c04f2f4ac7655c2dd85467fda0" +dependencies = [ + "libp2p-core", + "libp2p-identity", + "libp2p-swarm", "void", - "zeroize", ] [[package]] @@ -4469,8 +4790,8 @@ dependencies = [ "instant", "libp2p-identity", "log", - "multiaddr 0.17.1", - "multihash 0.17.0", + "multiaddr", + "multihash", "multistream-select", "once_cell", "parking_lot 0.12.1", @@ -4486,12 +4807,12 @@ dependencies = [ [[package]] name = "libp2p-dns" -version = "0.38.0" +version = "0.39.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e42a271c1b49f789b92f7fc87749fa79ce5c7bdc88cbdfacb818a4bca47fec5" +checksum = "146ff7034daae62077c415c2376b8057368042df6ab95f5432ad5e88568b1554" dependencies = [ "futures", - "libp2p-core 0.38.0", + "libp2p-core", "log", "parking_lot 0.12.1", "smallvec", @@ -4500,20 +4821,21 @@ dependencies = [ [[package]] name = "libp2p-identify" -version = "0.41.1" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c052d0026f4817b44869bfb6810f4e1112f43aec8553f2cb38881c524b563abf" +checksum = "5455f472243e63b9c497ff320ded0314254a9eb751799a39c283c6f20b793f3c" dependencies = [ "asynchronous-codec", + "either", "futures", "futures-timer", - "libp2p-core 0.38.0", + "libp2p-core", + "libp2p-identity", "libp2p-swarm", "log", "lru", - "prost", - "prost-build", - "prost-codec", + "quick-protobuf", + "quick-protobuf-codec", "smallvec", "thiserror", "void", @@ -4525,11 +4847,11 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "276bb57e7af15d8f100d3c11cbdd32c6752b7eef4ba7a18ecf464972c07abcce" dependencies = [ - "bs58", - "ed25519-dalek 2.0.0", + "bs58 0.4.0", + "ed25519-dalek", "log", - "multiaddr 0.17.1", - "multihash 0.17.0", + "multiaddr", + "multihash", "quick-protobuf", "rand 0.8.5", "sha2 0.10.8", @@ -4539,9 +4861,9 @@ dependencies = [ [[package]] name = "libp2p-kad" -version = "0.42.1" +version = "0.43.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2766dcd2be8c87d5e1f35487deb22d765f49c6ae1251b3633efe3b25698bd3d2" +checksum = "39d5ef876a2b2323d63c258e63c2f8e36f205fe5a11f0b3095d59635650790ff" dependencies = [ "arrayvec 0.7.4", "asynchronous-codec", @@ -4551,11 +4873,11 @@ dependencies = [ "futures", "futures-timer", "instant", - "libp2p-core 0.38.0", + "libp2p-core", + "libp2p-identity", "libp2p-swarm", "log", - "prost", - "prost-build", + "quick-protobuf", "rand 0.8.5", "sha2 0.10.8", "smallvec", @@ -4567,14 +4889,15 @@ dependencies = [ [[package]] name = "libp2p-mdns" -version = "0.42.0" +version = "0.43.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04f378264aade9872d6ccd315c0accc18be3a35d15fc1b9c36e5b6f983b62b5b" +checksum = "19983e1f949f979a928f2c603de1cf180cc0dc23e4ac93a62651ccb18341460b" dependencies = [ "data-encoding", "futures", "if-watch", - "libp2p-core 0.38.0", + "libp2p-core", + "libp2p-identity", "libp2p-swarm", "log", "rand 0.8.5", @@ -4587,11 +4910,11 @@ dependencies = [ [[package]] name = "libp2p-metrics" -version = "0.11.0" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ad8a64f29da86005c86a4d2728b8a0719e9b192f4092b609fd8790acb9dec55" +checksum = "a42ec91e227d7d0dafa4ce88b333cdf5f277253873ab087555c92798db2ddd46" dependencies = [ - "libp2p-core 0.38.0", + "libp2p-core", "libp2p-identify", "libp2p-kad", "libp2p-ping", @@ -4599,38 +4922,20 @@ dependencies = [ "prometheus-client", ] -[[package]] -name = "libp2p-mplex" -version = "0.38.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03805b44107aa013e7cbbfa5627b31c36cbedfdfb00603c0311998882bc4bace" -dependencies = [ - "asynchronous-codec", - "bytes", - "futures", - "libp2p-core 0.38.0", - "log", - "nohash-hasher", - "parking_lot 0.12.1", - "rand 0.8.5", - "smallvec", - "unsigned-varint", -] - [[package]] name = "libp2p-noise" -version = "0.41.0" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a978cb57efe82e892ec6f348a536bfbd9fee677adbe5689d7a93ad3a9bffbf2e" +checksum = "9c3673da89d29936bc6435bafc638e2f184180d554ce844db65915113f86ec5e" dependencies = [ "bytes", "curve25519-dalek 3.2.0", "futures", - "libp2p-core 0.38.0", + "libp2p-core", + "libp2p-identity", "log", "once_cell", - "prost", - "prost-build", + "quick-protobuf", "rand 0.8.5", "sha2 0.10.8", "snow", @@ -4642,14 +4947,15 @@ dependencies = [ [[package]] name = "libp2p-ping" -version = "0.41.0" +version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "929fcace45a112536e22b3dcfd4db538723ef9c3cb79f672b98be2cc8e25f37f" +checksum = "3e57759c19c28a73ef1eb3585ca410cefb72c1a709fcf6de1612a378e4219202" dependencies = [ + "either", "futures", "futures-timer", "instant", - "libp2p-core 0.38.0", + "libp2p-core", "libp2p-swarm", "log", "rand 0.8.5", @@ -4658,15 +4964,16 @@ dependencies = [ [[package]] name = "libp2p-quic" -version = "0.7.0-alpha" +version = "0.7.0-alpha.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01e7c867e95c8130667b24409d236d37598270e6da69b3baf54213ba31ffca59" +checksum = "c6b26abd81cd2398382a1edfe739b539775be8a90fa6914f39b2ab49571ec735" dependencies = [ "bytes", "futures", "futures-timer", "if-watch", - "libp2p-core 0.38.0", + "libp2p-core", + "libp2p-identity", "libp2p-tls", "log", "parking_lot 0.12.1", @@ -4679,49 +4986,46 @@ dependencies = [ [[package]] name = "libp2p-request-response" -version = "0.23.0" +version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3236168796727bfcf4927f766393415361e2c644b08bedb6a6b13d957c9a4884" +checksum = "7ffdb374267d42dc5ed5bc53f6e601d4a64ac5964779c6e40bb9e4f14c1e30d5" dependencies = [ "async-trait", - "bytes", "futures", "instant", - "libp2p-core 0.38.0", + "libp2p-core", + "libp2p-identity", "libp2p-swarm", - "log", "rand 0.8.5", "smallvec", - "unsigned-varint", ] [[package]] name = "libp2p-swarm" -version = "0.41.1" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2a35472fe3276b3855c00f1c032ea8413615e030256429ad5349cdf67c6e1a0" +checksum = "903b3d592d7694e56204d211f29d31bc004be99386644ba8731fc3e3ef27b296" dependencies = [ "either", "fnv", "futures", "futures-timer", "instant", - "libp2p-core 0.38.0", + "libp2p-core", + "libp2p-identity", "libp2p-swarm-derive", "log", - "pin-project", "rand 0.8.5", "smallvec", - "thiserror", "tokio", "void", ] [[package]] name = "libp2p-swarm-derive" -version = "0.31.0" +version = "0.32.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d527d5827582abd44a6d80c07ff8b50b4ee238a8979e05998474179e79dc400" +checksum = "0fba456131824ab6acd4c7bf61e9c0f0a3014b5fc9868ccb8e10d344594cdc4f" dependencies = [ "heck", "quote", @@ -4730,15 +5034,15 @@ dependencies = [ [[package]] name = "libp2p-tcp" -version = "0.38.0" +version = "0.39.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4b257baf6df8f2df39678b86c578961d48cc8b68642a12f0f763f56c8e5858d" +checksum = "33d33698596d7722d85d3ab0c86c2c322254fce1241e91208e3679b4eb3026cf" dependencies = [ "futures", "futures-timer", "if-watch", "libc", - "libp2p-core 0.38.0", + "libp2p-core", "log", "socket2 0.4.10", "tokio", @@ -4752,7 +5056,7 @@ checksum = "ff08d13d0dc66e5e9ba6279c1de417b84fa0d0adc3b03e5732928c180ec02781" dependencies = [ "futures", "futures-rustls", - "libp2p-core 0.39.2", + "libp2p-core", "libp2p-identity", "rcgen 0.10.0", "ring 0.16.20", @@ -4765,13 +5069,13 @@ dependencies = [ [[package]] name = "libp2p-wasm-ext" -version = "0.38.0" +version = "0.39.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bb1a35299860e0d4b3c02a3e74e3b293ad35ae0cee8a056363b0c862d082069" +checksum = "77dff9d32353a5887adb86c8afc1de1a94d9e8c3bc6df8b2201d7cdf5c848f43" dependencies = [ "futures", "js-sys", - "libp2p-core 0.38.0", + "libp2p-core", "parity-send-wrapper", "wasm-bindgen", "wasm-bindgen-futures", @@ -4779,9 +5083,9 @@ dependencies = [ [[package]] name = "libp2p-webrtc" -version = "0.4.0-alpha" +version = "0.4.0-alpha.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdb6cd86dd68cba72308ea05de1cebf3ba0ae6e187c40548167955d4e3970f6a" +checksum = "dba48592edbc2f60b4bc7c10d65445b0c3964c07df26fdf493b6880d33be36f8" dependencies = [ "async-trait", "asynchronous-codec", @@ -4790,13 +5094,13 @@ dependencies = [ "futures-timer", "hex", "if-watch", - "libp2p-core 0.38.0", + "libp2p-core", + "libp2p-identity", "libp2p-noise", "log", - "multihash 0.16.3", - "prost", - "prost-build", - "prost-codec", + "multihash", + "quick-protobuf", + "quick-protobuf-codec", "rand 0.8.5", "rcgen 0.9.3", "serde", @@ -4810,14 +5114,14 @@ dependencies = [ [[package]] name = "libp2p-websocket" -version = "0.40.0" +version = "0.41.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d705506030d5c0aaf2882437c70dab437605f21c5f9811978f694e6917a3b54" +checksum = "111273f7b3d3510524c752e8b7a5314b7f7a1fee7e68161c01a7d72cbb06db9f" dependencies = [ "either", "futures", "futures-rustls", - "libp2p-core 0.38.0", + "libp2p-core", "log", "parking_lot 0.12.1", "quicksink", @@ -4829,14 +5133,13 @@ dependencies = [ [[package]] name = "libp2p-yamux" -version = "0.42.0" +version = "0.43.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f63594a0aa818642d9d4915c791945053877253f08a3626f13416b5cd928a29" +checksum = "4dcd21d950662700a385d4c6d68e2f5f54d778e97068cdd718522222ef513bda" dependencies = [ "futures", - "libp2p-core 0.38.0", + "libp2p-core", "log", - "parking_lot 0.12.1", "thiserror", "yamux", ] @@ -4854,9 +5157,9 @@ dependencies = [ [[package]] name = "librocksdb-sys" -version = "0.10.0+7.9.2" +version = "0.11.0+8.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fe4d5874f5ff2bc616e55e8c6086d478fcda13faf9495768a4aa1c22042d30b" +checksum = "d3386f101bcb4bd252d8e9d2fb41ec3b0862a15a62b478c355b2982efa469e3e" dependencies = [ "bindgen", "bzip2-sys", @@ -5006,11 +5309,11 @@ checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" [[package]] name = "lru" -version = "0.8.1" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6e8aaa3f231bb4bd57b84b2d5dc3ae7f350265df8aa96492e0bc394a1571909" +checksum = "718e8fae447df0c7e1ba7f5189829e63fd536945c8988d61444c19039f16b670" dependencies = [ - "hashbrown 0.12.3", + "hashbrown 0.13.2", ] [[package]] @@ -5051,6 +5354,54 @@ dependencies = [ "libc", ] +[[package]] +name = "macro_magic" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aee866bfee30d2d7e83835a4574aad5b45adba4cc807f2a3bbba974e5d4383c9" +dependencies = [ + "macro_magic_core", + "macro_magic_macros", + "quote", + "syn 2.0.39", +] + +[[package]] +name = "macro_magic_core" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e766a20fd9c72bab3e1e64ed63f36bd08410e75803813df210d1ce297d7ad00" +dependencies = [ + "const-random", + "derive-syn-parse", + "macro_magic_core_macros", + "proc-macro2", + "quote", + "syn 2.0.39", +] + +[[package]] +name = "macro_magic_core_macros" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d710e1214dffbab3b5dacb21475dde7d6ed84c69ff722b3a47a782668d44fbac" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.39", +] + +[[package]] +name = "macro_magic_macros" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8fb85ec1620619edf2984a7693497d4ec88a9665d8b87e942856884c92dbf2a" +dependencies = [ + "macro_magic_core", + "quote", + "syn 2.0.39", +] + [[package]] name = "maplit" version = "1.0.2" @@ -5131,6 +5482,15 @@ dependencies = [ "autocfg", ] +[[package]] +name = "memoffset" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d61c719bcfbcf5d62b3a09efa6088de8c54bc0bfcd3ea7ae39fcc186108b8de1" +dependencies = [ + "autocfg", +] + [[package]] name = "memoffset" version = "0.9.0" @@ -5149,12 +5509,6 @@ dependencies = [ "hash-db 0.16.0", ] -[[package]] -name = "memory_units" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8452105ba047068f40ff7093dd1d9da90898e63dd61736462e9cdda6a90ad3c3" - [[package]] name = "merlin" version = "2.0.1" @@ -5167,6 +5521,18 @@ dependencies = [ "zeroize", ] +[[package]] +name = "merlin" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "58c38e2799fc0978b65dfff8023ec7843e2330bb462f19198840b34b6582397d" +dependencies = [ + "byteorder", + "keccak", + "rand_core 0.6.4", + "zeroize", +] + [[package]] name = "minimal-lexical" version = "0.2.1" @@ -5196,7 +5562,7 @@ dependencies = [ [[package]] name = "mmr-rpc" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "anyhow", "jsonrpsee", @@ -5236,24 +5602,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "multiaddr" -version = "0.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4aebdb21e90f81d13ed01dc84123320838e53963c2ca94b60b305d3fa64f31e" -dependencies = [ - "arrayref", - "byteorder", - "data-encoding", - "multibase", - "multihash 0.16.3", - "percent-encoding", - "serde", - "static_assertions", - "unsigned-varint", - "url", -] - [[package]] name = "multiaddr" version = "0.17.1" @@ -5265,7 +5613,7 @@ dependencies = [ "data-encoding", "log", "multibase", - "multihash 0.17.0", + "multihash", "percent-encoding", "serde", "static_assertions", @@ -5286,9 +5634,9 @@ dependencies = [ [[package]] name = "multihash" -version = "0.16.3" +version = "0.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c346cf9999c631f002d8f977c4eaeaa0e6386f16007202308d0b3757522c2cc" +checksum = "835d6ff01d610179fbce3de1694d007e500bf33a7f29689838941d6bf783ae40" dependencies = [ "blake2b_simd", "blake2s_simd", @@ -5301,17 +5649,6 @@ dependencies = [ "unsigned-varint", ] -[[package]] -name = "multihash" -version = "0.17.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "835d6ff01d610179fbce3de1694d007e500bf33a7f29689838941d6bf783ae40" -dependencies = [ - "core2", - "multihash-derive", - "unsigned-varint", -] - [[package]] name = "multihash-derive" version = "0.8.1" @@ -5627,18 +5964,18 @@ dependencies = [ [[package]] name = "num_enum" -version = "0.6.1" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a015b430d3c108a207fd776d2e2196aaf8b1cf8cf93253e3a097ff3085076a1" +checksum = "683751d591e6d81200c39fb0d1032608b77724f34114db54f571ff1317b337c0" dependencies = [ "num_enum_derive", ] [[package]] name = "num_enum_derive" -version = "0.6.1" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96667db765a921f7b295ffee8b60472b686a51d4f21c2ee4ffdb94c7013b65a6" +checksum = "6c11e44798ad209ccdd91fc192f0526a369a01234f7373e1b141c96d7cee4f0e" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -5654,12 +5991,12 @@ checksum = "830b246a0e5f20af87141b25c173cd1b609bd7779a4617d6ec582abaf90870f3" [[package]] name = "object" -version = "0.29.0" +version = "0.30.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21158b2c33aa6d4561f1c0a6ea283ca92bc54802a93b263e910746d679a7eb53" +checksum = "03b4680b86d9cfafba8fc491dc9b6df26b68cf40e9e6cd73909194759a63c385" dependencies = [ "crc32fast", - "hashbrown 0.12.3", + "hashbrown 0.13.2", "indexmap 1.9.3", "memchr", ] @@ -5778,7 +6115,7 @@ dependencies = [ [[package]] name = "pallet-asset-tx-payment" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "frame-benchmarking", "frame-support", @@ -5796,11 +6133,12 @@ dependencies = [ [[package]] name = "pallet-assets" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "frame-benchmarking", "frame-support", "frame-system", + "log", "parity-scale-codec", "scale-info", "sp-core", @@ -5849,7 +6187,7 @@ dependencies = [ [[package]] name = "pallet-authority-discovery" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "frame-support", "frame-system", @@ -5865,7 +6203,7 @@ dependencies = [ [[package]] name = "pallet-authorship" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "frame-support", "frame-system", @@ -5879,7 +6217,7 @@ dependencies = [ [[package]] name = "pallet-babe" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "frame-benchmarking", "frame-support", @@ -5903,8 +6241,10 @@ dependencies = [ [[package]] name = "pallet-bags-list" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ + "aquamarine", + "docify", "frame-benchmarking", "frame-election-provider-support", "frame-support", @@ -5923,7 +6263,7 @@ dependencies = [ [[package]] name = "pallet-balances" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "frame-benchmarking", "frame-support", @@ -5938,7 +6278,7 @@ dependencies = [ [[package]] name = "pallet-base-fee" version = "1.0.0" -source = "git+https://github.com/paritytech/frontier?branch=polkadot-v0.9.42#2499d18c936edbcb7fcb711827db7abb9b4f4da4" +source = "git+https://github.com/paritytech/frontier?branch=polkadot-v1.1.0#de5a3df59d3ada67c8cacdb79e607ad0b229ec5b" dependencies = [ "fp-evm", "frame-support", @@ -5949,53 +6289,10 @@ dependencies = [ "sp-runtime", ] -[[package]] -name = "pallet-beefy" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" -dependencies = [ - "frame-support", - "frame-system", - "pallet-authorship", - "pallet-session", - "parity-scale-codec", - "scale-info", - "serde", - "sp-consensus-beefy", - "sp-runtime", - "sp-session", - "sp-staking", - "sp-std", -] - -[[package]] -name = "pallet-beefy-mmr" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" -dependencies = [ - "array-bytes", - "binary-merkle-tree", - "frame-support", - "frame-system", - "log", - "pallet-beefy", - "pallet-mmr", - "pallet-session", - "parity-scale-codec", - "scale-info", - "serde", - "sp-api", - "sp-consensus-beefy", - "sp-core", - "sp-io", - "sp-runtime", - "sp-std", -] - [[package]] name = "pallet-bounties" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "frame-benchmarking", "frame-support", @@ -6073,7 +6370,7 @@ dependencies = [ [[package]] name = "pallet-child-bounties" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "frame-benchmarking", "frame-support", @@ -6092,7 +6389,7 @@ dependencies = [ [[package]] name = "pallet-collective" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "frame-benchmarking", "frame-support", @@ -6109,7 +6406,7 @@ dependencies = [ [[package]] name = "pallet-contracts" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "bitflags 1.3.2", "environmental", @@ -6118,6 +6415,7 @@ dependencies = [ "frame-system", "impl-trait-for-tuples", "log", + "pallet-balances", "pallet-contracts-primitives", "pallet-contracts-proc-macro", "parity-scale-codec", @@ -6132,14 +6430,13 @@ dependencies = [ "sp-runtime", "sp-std", "wasm-instrument 0.4.0", - "wasmi 0.28.0", - "wasmparser-nostd", + "wasmi", ] [[package]] name = "pallet-contracts-primitives" -version = "7.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +version = "24.0.0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "bitflags 1.3.2", "parity-scale-codec", @@ -6152,7 +6449,7 @@ dependencies = [ [[package]] name = "pallet-contracts-proc-macro" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "proc-macro2", "quote", @@ -6162,7 +6459,7 @@ dependencies = [ [[package]] name = "pallet-dynamic-fee" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/frontier?branch=polkadot-v0.9.42#2499d18c936edbcb7fcb711827db7abb9b4f4da4" +source = "git+https://github.com/paritytech/frontier?branch=polkadot-v1.1.0#de5a3df59d3ada67c8cacdb79e607ad0b229ec5b" dependencies = [ "fp-dynamic-fee", "fp-evm", @@ -6172,13 +6469,14 @@ dependencies = [ "scale-info", "sp-core", "sp-inherents", + "sp-runtime", "sp-std", ] [[package]] name = "pallet-election-provider-multi-phase" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -6195,13 +6493,13 @@ dependencies = [ "sp-npos-elections", "sp-runtime", "sp-std", - "strum", + "strum 0.24.1", ] [[package]] name = "pallet-election-provider-support-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -6209,12 +6507,13 @@ dependencies = [ "parity-scale-codec", "sp-npos-elections", "sp-runtime", + "sp-std", ] [[package]] name = "pallet-ethereum" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/frontier?branch=polkadot-v0.9.42#2499d18c936edbcb7fcb711827db7abb9b4f4da4" +source = "git+https://github.com/paritytech/frontier?branch=polkadot-v1.1.0#de5a3df59d3ada67c8cacdb79e607ad0b229ec5b" dependencies = [ "ethereum", "ethereum-types", @@ -6237,7 +6536,7 @@ dependencies = [ [[package]] name = "pallet-evm" version = "6.0.0-dev" -source = "git+https://github.com/paritytech/frontier?branch=polkadot-v0.9.42#2499d18c936edbcb7fcb711827db7abb9b4f4da4" +source = "git+https://github.com/paritytech/frontier?branch=polkadot-v1.1.0#de5a3df59d3ada67c8cacdb79e607ad0b229ec5b" dependencies = [ "environmental", "evm", @@ -6246,6 +6545,7 @@ dependencies = [ "frame-benchmarking", "frame-support", "frame-system", + "hash-db 0.16.0", "hex", "hex-literal", "impl-trait-for-tuples", @@ -6262,18 +6562,19 @@ dependencies = [ [[package]] name = "pallet-evm-chain-id" version = "1.0.0-dev" -source = "git+https://github.com/paritytech/frontier?branch=polkadot-v0.9.42#2499d18c936edbcb7fcb711827db7abb9b4f4da4" +source = "git+https://github.com/paritytech/frontier?branch=polkadot-v1.1.0#de5a3df59d3ada67c8cacdb79e607ad0b229ec5b" dependencies = [ "frame-support", "frame-system", "parity-scale-codec", "scale-info", + "sp-runtime", ] [[package]] name = "pallet-evm-precompile-modexp" version = "2.0.0-dev" -source = "git+https://github.com/paritytech/frontier?branch=polkadot-v0.9.42#2499d18c936edbcb7fcb711827db7abb9b4f4da4" +source = "git+https://github.com/paritytech/frontier?branch=polkadot-v1.1.0#de5a3df59d3ada67c8cacdb79e607ad0b229ec5b" dependencies = [ "fp-evm", "num", @@ -6282,7 +6583,7 @@ dependencies = [ [[package]] name = "pallet-evm-precompile-sha3fips" version = "2.0.0-dev" -source = "git+https://github.com/paritytech/frontier?branch=polkadot-v0.9.42#2499d18c936edbcb7fcb711827db7abb9b4f4da4" +source = "git+https://github.com/paritytech/frontier?branch=polkadot-v1.1.0#de5a3df59d3ada67c8cacdb79e607ad0b229ec5b" dependencies = [ "fp-evm", "tiny-keccak", @@ -6291,7 +6592,7 @@ dependencies = [ [[package]] name = "pallet-evm-precompile-simple" version = "2.0.0-dev" -source = "git+https://github.com/paritytech/frontier?branch=polkadot-v0.9.42#2499d18c936edbcb7fcb711827db7abb9b4f4da4" +source = "git+https://github.com/paritytech/frontier?branch=polkadot-v1.1.0#de5a3df59d3ada67c8cacdb79e607ad0b229ec5b" dependencies = [ "fp-evm", "ripemd", @@ -6341,7 +6642,7 @@ dependencies = [ [[package]] name = "pallet-grandpa" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "frame-benchmarking", "frame-support", @@ -6364,7 +6665,7 @@ dependencies = [ [[package]] name = "pallet-im-online" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "frame-benchmarking", "frame-support", @@ -6384,7 +6685,7 @@ dependencies = [ [[package]] name = "pallet-indices" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "frame-benchmarking", "frame-support", @@ -6401,7 +6702,7 @@ dependencies = [ [[package]] name = "pallet-insecure-randomness-collective-flip" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "frame-support", "frame-system", @@ -6415,7 +6716,7 @@ dependencies = [ [[package]] name = "pallet-membership" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "frame-benchmarking", "frame-support", @@ -6432,11 +6733,12 @@ dependencies = [ [[package]] name = "pallet-mmr" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "frame-benchmarking", "frame-support", "frame-system", + "log", "parity-scale-codec", "scale-info", "sp-core", @@ -6449,7 +6751,7 @@ dependencies = [ [[package]] name = "pallet-multisig" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "frame-benchmarking", "frame-support", @@ -6465,7 +6767,7 @@ dependencies = [ [[package]] name = "pallet-offences" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "frame-support", "frame-system", @@ -6500,7 +6802,7 @@ dependencies = [ [[package]] name = "pallet-preimage" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "frame-benchmarking", "frame-support", @@ -6517,7 +6819,7 @@ dependencies = [ [[package]] name = "pallet-proxy" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "frame-benchmarking", "frame-support", @@ -6561,8 +6863,9 @@ dependencies = [ [[package]] name = "pallet-scheduler" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ + "docify", "frame-benchmarking", "frame-support", "frame-system", @@ -6595,7 +6898,7 @@ dependencies = [ [[package]] name = "pallet-session" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "frame-support", "frame-system", @@ -6609,6 +6912,7 @@ dependencies = [ "sp-runtime", "sp-session", "sp-staking", + "sp-state-machine", "sp-std", "sp-trie", ] @@ -6645,8 +6949,9 @@ dependencies = [ [[package]] name = "pallet-staking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ + "frame-benchmarking", "frame-election-provider-support", "frame-support", "frame-system", @@ -6655,6 +6960,7 @@ dependencies = [ "pallet-session", "parity-scale-codec", "scale-info", + "serde", "sp-application-crypto", "sp-io", "sp-runtime", @@ -6665,7 +6971,7 @@ dependencies = [ [[package]] name = "pallet-staking-reward-curve" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -6695,8 +7001,9 @@ dependencies = [ [[package]] name = "pallet-sudo" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ + "frame-benchmarking", "frame-support", "frame-system", "parity-scale-codec", @@ -6741,7 +7048,7 @@ dependencies = [ [[package]] name = "pallet-timestamp" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "frame-benchmarking", "frame-support", @@ -6753,13 +7060,14 @@ dependencies = [ "sp-io", "sp-runtime", "sp-std", + "sp-storage", "sp-timestamp", ] [[package]] name = "pallet-transaction-payment" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "frame-support", "frame-system", @@ -6775,7 +7083,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment-rpc" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "jsonrpsee", "pallet-transaction-payment-rpc-runtime-api", @@ -6791,7 +7099,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment-rpc-runtime-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "pallet-transaction-payment", "parity-scale-codec", @@ -6803,7 +7111,7 @@ dependencies = [ [[package]] name = "pallet-treasury" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "frame-benchmarking", "frame-support", @@ -6930,6 +7238,12 @@ dependencies = [ "windows-targets 0.48.5", ] +[[package]] +name = "partial_sort" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7924d1d0ad836f665c9065e26d016c673ece3993f30d340068b16f282afc1156" + [[package]] name = "paste" version = "1.0.14" @@ -7115,12 +7429,6 @@ version = "0.3.27" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964" -[[package]] -name = "platforms" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8d0eef3571242013a0d5dc84861c3ae4a652e56e12adf8bdc26ff5f8cb34c94" - [[package]] name = "platforms" version = "3.2.0" @@ -7246,6 +7554,16 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "prettyplease" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae005bd773ab59b4725093fd7df83fd7892f7d8eafb48dbd7de6e024e4215f9d" +dependencies = [ + "proc-macro2", + "syn 2.0.39", +] + [[package]] name = "primitive-types" version = "0.12.2" @@ -7296,9 +7614,9 @@ dependencies = [ [[package]] name = "proc-macro-warning" -version = "0.3.1" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e99670bafb56b9a106419397343bdbc8b8742c3cc449fec6345f86173f47cd4" +checksum = "3d1eaa7fa0aa1929ffdf7eeb6eac234dde6268914a14ad44d23521ab6a9b258e" dependencies = [ "proc-macro2", "quote", @@ -7330,25 +7648,25 @@ dependencies = [ [[package]] name = "prometheus-client" -version = "0.18.1" +version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83cd1b99916654a69008fd66b4f9397fbe08e6e51dfe23d4417acf5d3b8cb87c" +checksum = "5d6fa99d535dd930d1249e6c79cb3c2915f9172a540fe2b02a4c8f9ca954721e" dependencies = [ "dtoa", "itoa", "parking_lot 0.12.1", - "prometheus-client-derive-text-encode", + "prometheus-client-derive-encode", ] [[package]] -name = "prometheus-client-derive-text-encode" -version = "0.3.0" +name = "prometheus-client-derive-encode" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66a455fbcb954c1a7decf3c586e860fd7889cddf4b8e164be736dbac95a953cd" +checksum = "440f724eba9f6996b75d63681b0a92b06947f1457076d503a4d2e2c8f56442b8" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.39", ] [[package]] @@ -7374,7 +7692,7 @@ dependencies = [ "log", "multimap", "petgraph", - "prettyplease", + "prettyplease 0.1.25", "prost", "prost-types", "regex", @@ -7383,19 +7701,6 @@ dependencies = [ "which", ] -[[package]] -name = "prost-codec" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dc34979ff898b6e141106178981ce2596c387ea6e62533facfc61a37fc879c0" -dependencies = [ - "asynchronous-codec", - "bytes", - "prost", - "thiserror", - "unsigned-varint", -] - [[package]] name = "prost-derive" version = "0.11.9" @@ -7462,6 +7767,19 @@ dependencies = [ "byteorder", ] +[[package]] +name = "quick-protobuf-codec" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1693116345026436eb2f10b677806169c1a1260c1c60eaaffe3fb5a29ae23d8b" +dependencies = [ + "asynchronous-codec", + "bytes", + "quick-protobuf", + "thiserror", + "unsigned-varint", +] + [[package]] name = "quicksink" version = "0.1.2" @@ -7697,9 +8015,9 @@ dependencies = [ [[package]] name = "regalloc2" -version = "0.5.1" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "300d4fbfb40c1c66a78ba3ddd41c1110247cf52f97b87d0f2fc9209bd49b030c" +checksum = "80535183cae11b149d618fbd3c37e38d7cda589d82d7769e196ca9a9042d7621" dependencies = [ "fxhash", "log", @@ -7751,18 +8069,6 @@ version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" -[[package]] -name = "region" -version = "3.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76e189c2369884dce920945e2ddf79b3dff49e071a167dd1817fa9c4c00d512e" -dependencies = [ - "bitflags 1.3.2", - "libc", - "mach", - "winapi", -] - [[package]] name = "resolv-conf" version = "0.7.0" @@ -7794,6 +8100,21 @@ dependencies = [ "subtle", ] +[[package]] +name = "ring" +version = "0.1.0" +source = "git+https://github.com/w3f/ring-proof?rev=0e948f3#0e948f3c28cbacecdd3020403c4841c0eb339213" +dependencies = [ + "ark-ec", + "ark-ff", + "ark-poly", + "ark-serialize", + "ark-std", + "common", + "fflonk", + "merlin 3.0.0", +] + [[package]] name = "ring" version = "0.16.20" @@ -7881,9 +8202,9 @@ dependencies = [ [[package]] name = "rocksdb" -version = "0.20.1" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "015439787fce1e75d55f279078d33ff14b4af5d93d995e8838ee4631301c8a99" +checksum = "bb6f170a4041d50a0ce04b0d2e14916d6ca863ea2e422689a5b694395d299ffe" dependencies = [ "libc", "librocksdb-sys", @@ -8193,7 +8514,7 @@ dependencies = [ [[package]] name = "sc-allocator" version = "4.1.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "log", "sp-core", @@ -8204,7 +8525,7 @@ dependencies = [ [[package]] name = "sc-authority-discovery" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "async-trait", "futures", @@ -8212,13 +8533,13 @@ dependencies = [ "ip_network", "libp2p", "log", + "multihash", "parity-scale-codec", "prost", "prost-build", "rand 0.8.5", "sc-client-api", "sc-network", - "sc-network-common", "sp-api", "sp-authority-discovery", "sp-blockchain", @@ -8232,7 +8553,7 @@ dependencies = [ [[package]] name = "sc-basic-authorship" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "futures", "futures-timer", @@ -8255,7 +8576,7 @@ dependencies = [ [[package]] name = "sc-block-builder" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "parity-scale-codec", "sc-client-api", @@ -8270,7 +8591,7 @@ dependencies = [ [[package]] name = "sc-chain-spec" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "memmap2", "sc-chain-spec-derive", @@ -8289,7 +8610,7 @@ dependencies = [ [[package]] name = "sc-chain-spec-derive" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -8300,14 +8621,14 @@ dependencies = [ [[package]] name = "sc-cli" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ - "array-bytes", + "array-bytes 6.2.0", "chrono", "clap", "fdlimit", "futures", - "libp2p", + "libp2p-identity", "log", "names", "parity-scale-codec", @@ -8318,7 +8639,6 @@ dependencies = [ "sc-client-db", "sc-keystore", "sc-network", - "sc-network-common", "sc-service", "sc-telemetry", "sc-tracing", @@ -8340,7 +8660,7 @@ dependencies = [ [[package]] name = "sc-client-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "fnv", "futures", @@ -8356,9 +8676,9 @@ dependencies = [ "sp-core", "sp-database", "sp-externalities", - "sp-keystore", "sp-runtime", "sp-state-machine", + "sp-statement-store", "sp-storage", "substrate-prometheus-endpoint", ] @@ -8366,7 +8686,7 @@ dependencies = [ [[package]] name = "sc-client-db" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "hash-db 0.16.0", "kvdb", @@ -8392,12 +8712,12 @@ dependencies = [ [[package]] name = "sc-consensus" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "async-trait", "futures", "futures-timer", - "libp2p", + "libp2p-identity", "log", "mockall", "parking_lot 0.12.1", @@ -8417,7 +8737,7 @@ dependencies = [ [[package]] name = "sc-consensus-aura" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "async-trait", "futures", @@ -8446,7 +8766,7 @@ dependencies = [ [[package]] name = "sc-consensus-babe" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "async-trait", "fork-tree", @@ -8461,8 +8781,8 @@ dependencies = [ "sc-consensus", "sc-consensus-epochs", "sc-consensus-slots", - "sc-keystore", "sc-telemetry", + "sc-transaction-pool-api", "scale-info", "sp-api", "sp-application-crypto", @@ -8482,7 +8802,7 @@ dependencies = [ [[package]] name = "sc-consensus-epochs" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "fork-tree", "parity-scale-codec", @@ -8495,10 +8815,10 @@ dependencies = [ [[package]] name = "sc-consensus-grandpa" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "ahash 0.8.6", - "array-bytes", + "array-bytes 6.2.0", "async-trait", "dyn-clone", "finality-grandpa", @@ -8517,6 +8837,7 @@ dependencies = [ "sc-network-common", "sc-network-gossip", "sc-telemetry", + "sc-transaction-pool-api", "sc-utils", "serde_json", "sp-api", @@ -8535,7 +8856,7 @@ dependencies = [ [[package]] name = "sc-consensus-grandpa-rpc" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "finality-grandpa", "futures", @@ -8555,11 +8876,12 @@ dependencies = [ [[package]] name = "sc-consensus-manual-seal" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "assert_matches", "async-trait", "futures", + "futures-timer", "jsonrpsee", "log", "parity-scale-codec", @@ -8589,7 +8911,7 @@ dependencies = [ [[package]] name = "sc-consensus-slots" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "async-trait", "futures", @@ -8612,14 +8934,13 @@ dependencies = [ [[package]] name = "sc-executor" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ - "lru", "parity-scale-codec", "parking_lot 0.12.1", "sc-executor-common", - "sc-executor-wasmi", "sc-executor-wasmtime", + "schnellru", "sp-api", "sp-core", "sp-externalities", @@ -8630,45 +8951,29 @@ dependencies = [ "sp-version", "sp-wasm-interface", "tracing", - "wasmi 0.13.2", ] [[package]] name = "sc-executor-common" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "sc-allocator", "sp-maybe-compressed-blob", "sp-wasm-interface", "thiserror", "wasm-instrument 0.3.0", - "wasmi 0.13.2", -] - -[[package]] -name = "sc-executor-wasmi" -version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" -dependencies = [ - "log", - "sc-allocator", - "sc-executor-common", - "sp-runtime-interface", - "sp-wasm-interface", - "wasmi 0.13.2", ] [[package]] name = "sc-executor-wasmtime" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "anyhow", "cfg-if", "libc", "log", - "once_cell", "rustix 0.36.17", "sc-allocator", "sc-executor-common", @@ -8680,7 +8985,7 @@ dependencies = [ [[package]] name = "sc-informant" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "ansi_term", "futures", @@ -8696,10 +9001,9 @@ dependencies = [ [[package]] name = "sc-keystore" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ - "array-bytes", - "async-trait", + "array-bytes 6.2.0", "parking_lot 0.12.1", "serde_json", "sp-application-crypto", @@ -8711,9 +9015,9 @@ dependencies = [ [[package]] name = "sc-network" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ - "array-bytes", + "array-bytes 6.2.0", "async-channel", "async-trait", "asynchronous-codec", @@ -8726,47 +9030,43 @@ dependencies = [ "libp2p", "linked_hash_set", "log", - "lru", "mockall", "parity-scale-codec", "parking_lot 0.12.1", + "partial_sort", "pin-project", "rand 0.8.5", - "sc-block-builder", "sc-client-api", - "sc-consensus", "sc-network-common", - "sc-peerset", "sc-utils", "serde", "serde_json", "smallvec", - "snow", "sp-arithmetic", "sp-blockchain", - "sp-consensus", "sp-core", "sp-runtime", "substrate-prometheus-endpoint", "thiserror", "unsigned-varint", + "wasm-timer", "zeroize", ] [[package]] name = "sc-network-bitswap" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ + "async-channel", "cid", "futures", - "libp2p", + "libp2p-identity", "log", "prost", "prost-build", "sc-client-api", "sc-network", - "sc-network-common", "sp-blockchain", "sp-runtime", "thiserror", @@ -8776,45 +9076,33 @@ dependencies = [ [[package]] name = "sc-network-common" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ - "array-bytes", "async-trait", "bitflags 1.3.2", - "bytes", "futures", - "futures-timer", - "libp2p", + "libp2p-identity", "parity-scale-codec", "prost-build", "sc-consensus", - "sc-peerset", - "sc-utils", - "serde", - "smallvec", - "sp-blockchain", "sp-consensus", "sp-consensus-grandpa", "sp-runtime", - "substrate-prometheus-endpoint", - "thiserror", - "zeroize", ] [[package]] name = "sc-network-gossip" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "ahash 0.8.6", "futures", "futures-timer", "libp2p", "log", - "lru", "sc-network", "sc-network-common", - "sc-peerset", + "schnellru", "sp-runtime", "substrate-prometheus-endpoint", "tracing", @@ -8823,19 +9111,18 @@ dependencies = [ [[package]] name = "sc-network-light" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ - "array-bytes", + "array-bytes 6.2.0", + "async-channel", "futures", - "libp2p", + "libp2p-identity", "log", "parity-scale-codec", "prost", "prost-build", "sc-client-api", "sc-network", - "sc-network-common", - "sc-peerset", "sp-blockchain", "sp-core", "sp-runtime", @@ -8845,16 +9132,16 @@ dependencies = [ [[package]] name = "sc-network-sync" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ - "array-bytes", + "array-bytes 6.2.0", + "async-channel", "async-trait", "fork-tree", "futures", "futures-timer", "libp2p", "log", - "lru", "mockall", "parity-scale-codec", "prost", @@ -8863,8 +9150,8 @@ dependencies = [ "sc-consensus", "sc-network", "sc-network-common", - "sc-peerset", "sc-utils", + "schnellru", "smallvec", "sp-arithmetic", "sp-blockchain", @@ -8879,7 +9166,7 @@ dependencies = [ [[package]] name = "sc-network-test" version = "0.8.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "async-trait", "futures", @@ -8899,7 +9186,6 @@ dependencies = [ "sc-utils", "sp-blockchain", "sp-consensus", - "sp-consensus-babe", "sp-core", "sp-runtime", "sp-tracing", @@ -8911,17 +9197,15 @@ dependencies = [ [[package]] name = "sc-network-transactions" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ - "array-bytes", + "array-bytes 6.2.0", "futures", "libp2p", "log", "parity-scale-codec", - "pin-project", "sc-network", "sc-network-common", - "sc-peerset", "sc-utils", "sp-consensus", "sp-runtime", @@ -8931,16 +9215,17 @@ dependencies = [ [[package]] name = "sc-offchain" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ - "array-bytes", + "array-bytes 6.2.0", "bytes", "fnv", "futures", "futures-timer", "hyper", - "hyper-rustls 0.23.2", + "hyper-rustls", "libp2p", + "log", "num_cpus", "once_cell", "parity-scale-codec", @@ -8949,33 +9234,22 @@ dependencies = [ "sc-client-api", "sc-network", "sc-network-common", - "sc-peerset", + "sc-transaction-pool-api", "sc-utils", "sp-api", "sp-core", + "sp-externalities", + "sp-keystore", "sp-offchain", "sp-runtime", "threadpool", "tracing", ] -[[package]] -name = "sc-peerset" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" -dependencies = [ - "futures", - "libp2p", - "log", - "sc-utils", - "serde_json", - "wasm-timer", -] - [[package]] name = "sc-proposer-metrics" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "log", "substrate-prometheus-endpoint", @@ -8984,7 +9258,7 @@ dependencies = [ [[package]] name = "sc-rpc" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "futures", "jsonrpsee", @@ -9007,6 +9281,7 @@ dependencies = [ "sp-rpc", "sp-runtime", "sp-session", + "sp-statement-store", "sp-version", "tokio", ] @@ -9014,7 +9289,7 @@ dependencies = [ [[package]] name = "sc-rpc-api" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "jsonrpsee", "parity-scale-codec", @@ -9033,7 +9308,7 @@ dependencies = [ [[package]] name = "sc-rpc-server" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "http", "jsonrpsee", @@ -9048,9 +9323,9 @@ dependencies = [ [[package]] name = "sc-rpc-spec-v2" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ - "array-bytes", + "array-bytes 6.2.0", "futures", "futures-util", "hex", @@ -9061,6 +9336,7 @@ dependencies = [ "sc-chain-spec", "sc-client-api", "sc-transaction-pool-api", + "sc-utils", "serde", "sp-api", "sp-blockchain", @@ -9068,13 +9344,14 @@ dependencies = [ "sp-runtime", "sp-version", "thiserror", + "tokio", "tokio-stream", ] [[package]] name = "sc-service" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "async-trait", "directories", @@ -9101,11 +9378,9 @@ dependencies = [ "sc-network-light", "sc-network-sync", "sc-network-transactions", - "sc-offchain", "sc-rpc", "sc-rpc-server", "sc-rpc-spec-v2", - "sc-storage-monitor", "sc-sysinfo", "sc-telemetry", "sc-tracing", @@ -9140,7 +9415,7 @@ dependencies = [ [[package]] name = "sc-state-db" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "log", "parity-scale-codec", @@ -9148,26 +9423,10 @@ dependencies = [ "sp-core", ] -[[package]] -name = "sc-storage-monitor" -version = "0.1.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" -dependencies = [ - "clap", - "fs4", - "futures", - "log", - "sc-client-db", - "sc-utils", - "sp-core", - "thiserror", - "tokio", -] - [[package]] name = "sc-sysinfo" version = "6.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "futures", "libc", @@ -9186,7 +9445,7 @@ dependencies = [ [[package]] name = "sc-telemetry" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "chrono", "futures", @@ -9205,7 +9464,7 @@ dependencies = [ [[package]] name = "sc-tracing" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "ansi_term", "atty", @@ -9213,12 +9472,10 @@ dependencies = [ "lazy_static", "libc", "log", - "once_cell", "parking_lot 0.12.1", "regex", "rustc-hash", "sc-client-api", - "sc-rpc-server", "sc-tracing-proc-macro", "serde", "sp-api", @@ -9236,7 +9493,7 @@ dependencies = [ [[package]] name = "sc-tracing-proc-macro" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -9247,14 +9504,13 @@ dependencies = [ [[package]] name = "sc-transaction-pool" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "async-trait", "futures", "futures-timer", "linked-hash-map", "log", - "num-traits", "parity-scale-codec", "parking_lot 0.12.1", "sc-client-api", @@ -9274,13 +9530,15 @@ dependencies = [ [[package]] name = "sc-transaction-pool-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "async-trait", "futures", "log", + "parity-scale-codec", "serde", "sp-blockchain", + "sp-core", "sp-runtime", "thiserror", ] @@ -9288,7 +9546,7 @@ dependencies = [ [[package]] name = "sc-utils" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "async-channel", "futures", @@ -9356,7 +9614,7 @@ dependencies = [ "arrayvec 0.5.2", "curve25519-dalek 2.1.3", "getrandom 0.1.16", - "merlin", + "merlin 2.0.1", "rand 0.7.3", "rand_core 0.5.1", "sha2 0.8.2", @@ -9795,7 +10053,7 @@ dependencies = [ [[package]] name = "sp-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "hash-db 0.16.0", "log", @@ -9803,6 +10061,7 @@ dependencies = [ "scale-info", "sp-api-proc-macro", "sp-core", + "sp-externalities", "sp-metadata-ir", "sp-runtime", "sp-state-machine", @@ -9815,7 +10074,7 @@ dependencies = [ [[package]] name = "sp-api-proc-macro" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "Inflector", "blake2", @@ -9828,8 +10087,8 @@ dependencies = [ [[package]] name = "sp-application-crypto" -version = "7.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +version = "23.0.0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "parity-scale-codec", "scale-info", @@ -9841,8 +10100,8 @@ dependencies = [ [[package]] name = "sp-arithmetic" -version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +version = "16.0.0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "integer-sqrt", "num-traits", @@ -9856,7 +10115,7 @@ dependencies = [ [[package]] name = "sp-authority-discovery" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "parity-scale-codec", "scale-info", @@ -9869,9 +10128,8 @@ dependencies = [ [[package]] name = "sp-block-builder" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ - "parity-scale-codec", "sp-api", "sp-inherents", "sp-runtime", @@ -9881,13 +10139,13 @@ dependencies = [ [[package]] name = "sp-blockchain" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "futures", "log", - "lru", "parity-scale-codec", "parking_lot 0.12.1", + "schnellru", "sp-api", "sp-consensus", "sp-database", @@ -9899,7 +10157,7 @@ dependencies = [ [[package]] name = "sp-consensus" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "async-trait", "futures", @@ -9914,14 +10172,13 @@ dependencies = [ [[package]] name = "sp-consensus-aura" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "async-trait", "parity-scale-codec", "scale-info", "sp-api", "sp-application-crypto", - "sp-consensus", "sp-consensus-slots", "sp-inherents", "sp-runtime", @@ -9932,7 +10189,7 @@ dependencies = [ [[package]] name = "sp-consensus-babe" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "async-trait", "parity-scale-codec", @@ -9940,39 +10197,18 @@ dependencies = [ "serde", "sp-api", "sp-application-crypto", - "sp-consensus", "sp-consensus-slots", "sp-core", "sp-inherents", - "sp-keystore", "sp-runtime", "sp-std", "sp-timestamp", ] -[[package]] -name = "sp-consensus-beefy" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" -dependencies = [ - "lazy_static", - "parity-scale-codec", - "scale-info", - "serde", - "sp-api", - "sp-application-crypto", - "sp-core", - "sp-io", - "sp-mmr-primitives", - "sp-runtime", - "sp-std", - "strum", -] - [[package]] name = "sp-consensus-grandpa" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "finality-grandpa", "log", @@ -9990,7 +10226,7 @@ dependencies = [ [[package]] name = "sp-consensus-slots" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "parity-scale-codec", "scale-info", @@ -10001,14 +10237,16 @@ dependencies = [ [[package]] name = "sp-core" -version = "7.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +version = "21.0.0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ - "array-bytes", + "array-bytes 6.2.0", + "arrayvec 0.7.4", + "bandersnatch_vrfs", "bitflags 1.3.2", "blake2", "bounded-collections", - "bs58", + "bs58 0.5.0", "dyn-clonable", "ed25519-zebra", "futures", @@ -10018,7 +10256,7 @@ dependencies = [ "lazy_static", "libsecp256k1", "log", - "merlin", + "merlin 2.0.1", "parity-scale-codec", "parking_lot 0.12.1", "paste", @@ -10040,29 +10278,28 @@ dependencies = [ "substrate-bip39", "thiserror", "tiny-bip39", + "tracing", "zeroize", ] [[package]] name = "sp-core-hashing" -version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +version = "9.0.0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "blake2b_simd", "byteorder", "digest 0.10.7", "sha2 0.10.8", "sha3", - "sp-std", "twox-hash", ] [[package]] name = "sp-core-hashing-proc-macro" -version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +version = "9.0.0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ - "proc-macro2", "quote", "sp-core-hashing", "syn 2.0.39", @@ -10071,7 +10308,7 @@ dependencies = [ [[package]] name = "sp-database" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "kvdb", "parking_lot 0.12.1", @@ -10079,8 +10316,8 @@ dependencies = [ [[package]] name = "sp-debug-derive" -version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +version = "8.0.0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "proc-macro2", "quote", @@ -10089,8 +10326,8 @@ dependencies = [ [[package]] name = "sp-externalities" -version = "0.13.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +version = "0.19.0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "environmental", "parity-scale-codec", @@ -10098,16 +10335,26 @@ dependencies = [ "sp-storage", ] +[[package]] +name = "sp-genesis-builder" +version = "0.1.0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +dependencies = [ + "serde_json", + "sp-api", + "sp-runtime", + "sp-std", +] + [[package]] name = "sp-inherents" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "async-trait", "impl-trait-for-tuples", "parity-scale-codec", "scale-info", - "sp-core", "sp-runtime", "sp-std", "thiserror", @@ -10115,13 +10362,11 @@ dependencies = [ [[package]] name = "sp-io" -version = "7.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +version = "23.0.0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "bytes", - "ed25519 1.5.3", - "ed25519-dalek 1.0.1", - "futures", + "ed25519-dalek", "libsecp256k1", "log", "parity-scale-codec", @@ -10141,24 +10386,22 @@ dependencies = [ [[package]] name = "sp-keyring" -version = "7.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +version = "24.0.0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "lazy_static", "sp-core", "sp-runtime", - "strum", + "strum 0.24.1", ] [[package]] name = "sp-keystore" -version = "0.13.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +version = "0.27.0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ - "futures", "parity-scale-codec", "parking_lot 0.12.1", - "serde", "sp-core", "sp-externalities", "thiserror", @@ -10167,7 +10410,7 @@ dependencies = [ [[package]] name = "sp-maybe-compressed-blob" version = "4.1.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "thiserror", "zstd 0.12.4", @@ -10176,7 +10419,7 @@ dependencies = [ [[package]] name = "sp-metadata-ir" version = "0.1.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "frame-metadata", "parity-scale-codec", @@ -10187,7 +10430,7 @@ dependencies = [ [[package]] name = "sp-mmr-primitives" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "ckb-merkle-mountain-range", "log", @@ -10205,7 +10448,7 @@ dependencies = [ [[package]] name = "sp-npos-elections" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "parity-scale-codec", "scale-info", @@ -10219,7 +10462,7 @@ dependencies = [ [[package]] name = "sp-offchain" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "sp-api", "sp-core", @@ -10228,8 +10471,8 @@ dependencies = [ [[package]] name = "sp-panic-handler" -version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +version = "8.0.0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "backtrace", "lazy_static", @@ -10239,7 +10482,7 @@ dependencies = [ [[package]] name = "sp-rpc" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "rustc-hash", "serde", @@ -10248,8 +10491,8 @@ dependencies = [ [[package]] name = "sp-runtime" -version = "7.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +version = "24.0.0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "either", "hash256-std-hasher", @@ -10270,8 +10513,8 @@ dependencies = [ [[package]] name = "sp-runtime-interface" -version = "7.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +version = "17.0.0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "bytes", "impl-trait-for-tuples", @@ -10288,8 +10531,8 @@ dependencies = [ [[package]] name = "sp-runtime-interface-proc-macro" -version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +version = "11.0.0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "Inflector", "proc-macro-crate", @@ -10301,12 +10544,13 @@ dependencies = [ [[package]] name = "sp-session" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "parity-scale-codec", "scale-info", "sp-api", "sp-core", + "sp-keystore", "sp-runtime", "sp-staking", "sp-std", @@ -10315,8 +10559,9 @@ dependencies = [ [[package]] name = "sp-staking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ + "impl-trait-for-tuples", "parity-scale-codec", "scale-info", "serde", @@ -10327,8 +10572,8 @@ dependencies = [ [[package]] name = "sp-state-machine" -version = "0.13.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +version = "0.28.0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "hash-db 0.16.0", "log", @@ -10343,17 +10588,42 @@ dependencies = [ "sp-trie", "thiserror", "tracing", + "trie-db", +] + +[[package]] +name = "sp-statement-store" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +dependencies = [ + "aes-gcm 0.10.3", + "curve25519-dalek 4.1.1", + "ed25519-dalek", + "hkdf", + "parity-scale-codec", + "rand 0.8.5", + "scale-info", + "sha2 0.10.8", + "sp-api", + "sp-application-crypto", + "sp-core", + "sp-externalities", + "sp-runtime", + "sp-runtime-interface", + "sp-std", + "thiserror", + "x25519-dalek 2.0.0", ] [[package]] name = "sp-std" -version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +version = "8.0.0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" [[package]] name = "sp-storage" -version = "7.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +version = "13.0.0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "impl-serde", "parity-scale-codec", @@ -10366,11 +10636,9 @@ dependencies = [ [[package]] name = "sp-timestamp" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "async-trait", - "futures-timer", - "log", "parity-scale-codec", "sp-inherents", "sp-runtime", @@ -10380,8 +10648,8 @@ dependencies = [ [[package]] name = "sp-tracing" -version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +version = "10.0.0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "parity-scale-codec", "sp-std", @@ -10393,7 +10661,7 @@ dependencies = [ [[package]] name = "sp-transaction-pool" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "sp-api", "sp-runtime", @@ -10402,10 +10670,9 @@ dependencies = [ [[package]] name = "sp-transaction-storage-proof" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "async-trait", - "log", "parity-scale-codec", "scale-info", "sp-core", @@ -10417,8 +10684,8 @@ dependencies = [ [[package]] name = "sp-trie" -version = "7.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +version = "22.0.0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "ahash 0.8.6", "hash-db 0.16.0", @@ -10440,8 +10707,8 @@ dependencies = [ [[package]] name = "sp-version" -version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +version = "22.0.0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "impl-serde", "parity-scale-codec", @@ -10457,8 +10724,8 @@ dependencies = [ [[package]] name = "sp-version-proc-macro" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +version = "8.0.0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "parity-scale-codec", "proc-macro2", @@ -10468,22 +10735,21 @@ dependencies = [ [[package]] name = "sp-wasm-interface" -version = "7.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +version = "14.0.0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "anyhow", "impl-trait-for-tuples", "log", "parity-scale-codec", "sp-std", - "wasmi 0.13.2", "wasmtime", ] [[package]] name = "sp-weights" -version = "4.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +version = "20.0.0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "parity-scale-codec", "scale-info", @@ -10518,7 +10784,7 @@ checksum = "08615eea740067d9899969bc2891c68a19c315cb1f66640af9a9ecb91b13bcab" dependencies = [ "lazy_static", "maplit", - "strum", + "strum 0.24.1", ] [[package]] @@ -10729,9 +10995,15 @@ version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "063e6045c0e62079840579a7e47a355ae92f60eb74daaf156fb1e84ba164e63f" dependencies = [ - "strum_macros", + "strum_macros 0.24.3", ] +[[package]] +name = "strum" +version = "0.25.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "290d54ea6f91c969195bdbcd7442c8c2a2ba87da8bf60a7ee86a235d4bc1e125" + [[package]] name = "strum_macros" version = "0.24.3" @@ -10745,6 +11017,19 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "strum_macros" +version = "0.25.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23dc1fa9ac9c169a78ba62f0b841814b7abae11bdd047b9c58f893439e309ea0" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "rustversion", + "syn 2.0.39", +] + [[package]] name = "stun" version = "0.4.4" @@ -10780,15 +11065,12 @@ dependencies = [ [[package]] name = "substrate-build-script-utils" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" -dependencies = [ - "platforms 2.0.0", -] +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" [[package]] name = "substrate-frame-rpc-system" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "frame-system-rpc-runtime-api", "futures", @@ -10807,7 +11089,7 @@ dependencies = [ [[package]] name = "substrate-prometheus-endpoint" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "hyper", "log", @@ -10819,7 +11101,7 @@ dependencies = [ [[package]] name = "substrate-rpc-client" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "async-trait", "jsonrpsee", @@ -10832,14 +11114,12 @@ dependencies = [ [[package]] name = "substrate-state-trie-migration-rpc" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "jsonrpsee", - "log", "parity-scale-codec", "sc-client-api", "sc-rpc-api", - "scale-info", "serde", "sp-core", "sp-runtime", @@ -10851,9 +11131,9 @@ dependencies = [ [[package]] name = "substrate-test-client" version = "2.0.1" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ - "array-bytes", + "array-bytes 6.2.0", "async-trait", "futures", "parity-scale-codec", @@ -10877,36 +11157,36 @@ dependencies = [ [[package]] name = "substrate-test-runtime" version = "2.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ - "cfg-if", + "array-bytes 6.2.0", + "frame-executive", "frame-support", "frame-system", "frame-system-rpc-runtime-api", "log", - "memory-db", "pallet-babe", - "pallet-beefy-mmr", + "pallet-balances", "pallet-timestamp", "parity-scale-codec", "sc-service", "scale-info", "serde", + "serde_json", "sp-api", "sp-application-crypto", "sp-block-builder", "sp-consensus-aura", "sp-consensus-babe", - "sp-consensus-beefy", "sp-consensus-grandpa", "sp-core", "sp-externalities", + "sp-genesis-builder", "sp-inherents", "sp-io", "sp-keyring", "sp-offchain", "sp-runtime", - "sp-runtime-interface", "sp-session", "sp-state-machine", "sp-std", @@ -10920,12 +11200,10 @@ dependencies = [ [[package]] name = "substrate-test-runtime-client" version = "2.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "futures", - "parity-scale-codec", "sc-block-builder", - "sc-chain-spec", "sc-client-api", "sc-consensus", "sp-api", @@ -10940,35 +11218,24 @@ dependencies = [ [[package]] name = "substrate-test-utils" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "futures", - "substrate-test-utils-derive", "tokio", ] -[[package]] -name = "substrate-test-utils-derive" -version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" -dependencies = [ - "proc-macro-crate", - "proc-macro2", - "quote", - "syn 2.0.39", -] - [[package]] name = "substrate-wasm-builder" version = "5.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "ansi_term", "build-helper", "cargo_metadata", "filetime", + "parity-wasm", "sp-maybe-compressed-blob", - "strum", + "strum 0.24.1", "tempfile", "toml 0.7.8", "walkdir", @@ -11253,14 +11520,14 @@ dependencies = [ ] [[package]] -name = "tokio-rustls" -version = "0.23.4" +name = "tokio-retry" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c43ee83903113e03984cb9e5cebe6c04a5116269e900e3ddba8f068a62adda59" +checksum = "7f57eb36ecbe0fc510036adff84824dd3c24bb781e21bfa67b69d556aa85214f" dependencies = [ - "rustls 0.20.9", + "pin-project", + "rand 0.8.5", "tokio", - "webpki 0.22.4", ] [[package]] @@ -11356,11 +11623,11 @@ dependencies = [ [[package]] name = "tower-http" -version = "0.3.5" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f873044bf02dd1e8239e9c1293ea39dad76dc594ec16185d0a1bf31d8dc8d858" +checksum = "61c5bb1d698276a2443e5ecfabc1008bf15a36c12e6a7176e7bf089ea9131140" dependencies = [ - "bitflags 1.3.2", + "bitflags 2.4.1", "bytes", "futures-core", "futures-util", @@ -11558,17 +11825,17 @@ checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed" [[package]] name = "try-runtime-cli" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +source = "git+https://github.com/paritytech/polkadot-sdk.git?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" dependencies = [ "async-trait", "clap", "frame-remote-externalities", + "frame-try-runtime", "hex", "log", "parity-scale-codec", "sc-cli", "sc-executor", - "sc-service", "serde", "serde_json", "sp-api", @@ -11939,14 +12206,14 @@ dependencies = [ [[package]] name = "wasm-opt" -version = "0.111.0" +version = "0.114.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84a303793cbc01fb96551badfc7367db6007396bba6bac97936b3c8b6f7fdb41" +checksum = "effbef3bd1dde18acb401f73e740a6f3d4a1bc651e9773bddc512fe4d8d68f67" dependencies = [ "anyhow", "libc", - "strum", - "strum_macros", + "strum 0.24.1", + "strum_macros 0.24.3", "tempfile", "thiserror", "wasm-opt-cxx-sys", @@ -11955,9 +12222,9 @@ dependencies = [ [[package]] name = "wasm-opt-cxx-sys" -version = "0.111.0" +version = "0.114.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9c9deb56f8a9f2ec177b3bd642a8205621835944ed5da55f2388ef216aca5a4" +checksum = "c09e24eb283919ace2ed5733bda4842a59ce4c8de110ef5c6d98859513d17047" dependencies = [ "anyhow", "cxx", @@ -11967,15 +12234,14 @@ dependencies = [ [[package]] name = "wasm-opt-sys" -version = "0.111.0" +version = "0.114.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4432e28b542738a9776cedf92e8a99d8991c7b4667ee2c7ccddfb479dd2856a7" +checksum = "36f2f817bed2e8d65eb779fa37317e74de15585751f903c9118342d1970703a4" dependencies = [ "anyhow", "cc", "cxx", "cxx-build", - "regex", ] [[package]] @@ -11995,36 +12261,17 @@ dependencies = [ [[package]] name = "wasmi" -version = "0.13.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06c326c93fbf86419608361a2c925a31754cf109da1b8b55737070b4d6669422" -dependencies = [ - "parity-wasm", - "wasmi-validation", - "wasmi_core 0.2.1", -] - -[[package]] -name = "wasmi" -version = "0.28.0" +version = "0.31.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e61a7006b0fdf24f6bbe8dcfdad5ca1b350de80061fb2827f31c82fbbb9565a" +checksum = "1f341edb80021141d4ae6468cbeefc50798716a347d4085c3811900049ea8945" dependencies = [ + "smallvec", "spin 0.9.8", "wasmi_arena", - "wasmi_core 0.12.0", + "wasmi_core", "wasmparser-nostd", ] -[[package]] -name = "wasmi-validation" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91ff416ad1ff0c42e5a926ed5d5fab74c0f098749aa0ad8b2a34b982ce0e867b" -dependencies = [ - "parity-wasm", -] - [[package]] name = "wasmi_arena" version = "0.4.0" @@ -12033,23 +12280,9 @@ checksum = "401c1f35e413fac1846d4843745589d9ec678977ab35a384db8ae7830525d468" [[package]] name = "wasmi_core" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57d20cb3c59b788653d99541c646c561c9dd26506f25c0cebfe810659c54c6d7" -dependencies = [ - "downcast-rs", - "libm", - "memory_units", - "num-rational", - "num-traits", - "region", -] - -[[package]] -name = "wasmi_core" -version = "0.12.0" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "624e6333e861ef49095d2d678b76ebf30b06bf37effca845be7e5b87c90071b7" +checksum = "dcf1a7db34bff95b85c261002720c00c3a6168256dcb93041d3fa2054d19856a" dependencies = [ "downcast-rs", "libm", @@ -12059,9 +12292,9 @@ dependencies = [ [[package]] name = "wasmparser" -version = "0.100.0" +version = "0.102.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64b20236ab624147dfbb62cf12a19aaf66af0e41b8398838b66e997d07d269d4" +checksum = "48134de3d7598219ab9eaf6b91b15d8e50d31da76b8519fe4ecfcec2cf35104b" dependencies = [ "indexmap 1.9.3", "url", @@ -12078,9 +12311,9 @@ dependencies = [ [[package]] name = "wasmtime" -version = "6.0.2" +version = "8.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76a222f5fa1e14b2cefc286f1b68494d7a965f4bf57ec04c59bb62673d639af6" +checksum = "f907fdead3153cb9bfb7a93bbd5b62629472dc06dee83605358c64c52ed3dda9" dependencies = [ "anyhow", "bincode", @@ -12088,7 +12321,7 @@ dependencies = [ "indexmap 1.9.3", "libc", "log", - "object 0.29.0", + "object 0.30.4", "once_cell", "paste", "psm", @@ -12101,26 +12334,26 @@ dependencies = [ "wasmtime-environ", "wasmtime-jit", "wasmtime-runtime", - "windows-sys 0.42.0", + "windows-sys 0.45.0", ] [[package]] name = "wasmtime-asm-macros" -version = "6.0.2" +version = "8.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4407a7246e7d2f3d8fb1cf0c72fda8dbafdb6dd34d555ae8bea0e5ae031089cc" +checksum = "d3b9daa7c14cd4fa3edbf69de994408d5f4b7b0959ac13fa69d465f6597f810d" dependencies = [ "cfg-if", ] [[package]] name = "wasmtime-cache" -version = "6.0.2" +version = "8.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ceb3adf61d654be0be67fffdce42447b0880481348785be5fe40b5dd7663a4c" +checksum = "c86437fa68626fe896e5afc69234bb2b5894949083586535f200385adfd71213" dependencies = [ "anyhow", - "base64 0.13.1", + "base64 0.21.5", "bincode", "directories-next", "file-per-thread-logger", @@ -12129,15 +12362,15 @@ dependencies = [ "serde", "sha2 0.10.8", "toml 0.5.11", - "windows-sys 0.42.0", + "windows-sys 0.45.0", "zstd 0.11.2+zstd.1.5.2", ] [[package]] name = "wasmtime-cranelift" -version = "6.0.2" +version = "8.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c366bb8647e01fd08cb5589976284b00abfded5529b33d7e7f3f086c68304a4" +checksum = "b1cefde0cce8cb700b1b21b6298a3837dba46521affd7b8c38a9ee2c869eee04" dependencies = [ "anyhow", "cranelift-codegen", @@ -12145,27 +12378,43 @@ dependencies = [ "cranelift-frontend", "cranelift-native", "cranelift-wasm", - "gimli 0.26.2", + "gimli 0.27.3", "log", - "object 0.29.0", + "object 0.30.4", "target-lexicon", "thiserror", "wasmparser", + "wasmtime-cranelift-shared", + "wasmtime-environ", +] + +[[package]] +name = "wasmtime-cranelift-shared" +version = "8.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd041e382ef5aea1b9fc78442394f1a4f6d676ce457e7076ca4cb3f397882f8b" +dependencies = [ + "anyhow", + "cranelift-codegen", + "cranelift-native", + "gimli 0.27.3", + "object 0.30.4", + "target-lexicon", "wasmtime-environ", ] [[package]] name = "wasmtime-environ" -version = "6.0.2" +version = "8.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47b8b50962eae38ee319f7b24900b7cf371f03eebdc17400c1dc8575fc10c9a7" +checksum = "a990198cee4197423045235bf89d3359e69bd2ea031005f4c2d901125955c949" dependencies = [ "anyhow", "cranelift-entity", - "gimli 0.26.2", + "gimli 0.27.3", "indexmap 1.9.3", "log", - "object 0.29.0", + "object 0.30.4", "serde", "target-lexicon", "thiserror", @@ -12175,18 +12424,18 @@ dependencies = [ [[package]] name = "wasmtime-jit" -version = "6.0.2" +version = "8.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffaed4f9a234ba5225d8e64eac7b4a5d13b994aeb37353cde2cbeb3febda9eaa" +checksum = "0de48df552cfca1c9b750002d3e07b45772dd033b0b206d5c0968496abf31244" dependencies = [ - "addr2line 0.17.0", + "addr2line 0.19.0", "anyhow", "bincode", "cfg-if", "cpp_demangle", - "gimli 0.26.2", + "gimli 0.27.3", "log", - "object 0.29.0", + "object 0.30.4", "rustc-demangle", "serde", "target-lexicon", @@ -12194,36 +12443,36 @@ dependencies = [ "wasmtime-jit-debug", "wasmtime-jit-icache-coherence", "wasmtime-runtime", - "windows-sys 0.42.0", + "windows-sys 0.45.0", ] [[package]] name = "wasmtime-jit-debug" -version = "6.0.2" +version = "8.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eed41cbcbf74ce3ff6f1d07d1b707888166dc408d1a880f651268f4f7c9194b2" +checksum = "6e0554b84c15a27d76281d06838aed94e13a77d7bf604bbbaf548aa20eb93846" dependencies = [ - "object 0.29.0", + "object 0.30.4", "once_cell", "rustix 0.36.17", ] [[package]] name = "wasmtime-jit-icache-coherence" -version = "6.0.2" +version = "8.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43a28ae1e648461bfdbb79db3efdaee1bca5b940872e4175390f465593a2e54c" +checksum = "aecae978b13f7f67efb23bd827373ace4578f2137ec110bbf6a4a7cde4121bbd" dependencies = [ "cfg-if", "libc", - "windows-sys 0.42.0", + "windows-sys 0.45.0", ] [[package]] name = "wasmtime-runtime" -version = "6.0.2" +version = "8.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e704b126e4252788ccfc3526d4d4511d4b23c521bf123e447ac726c14545217b" +checksum = "658cf6f325232b6760e202e5255d823da5e348fdea827eff0a2a22319000b441" dependencies = [ "anyhow", "cc", @@ -12233,21 +12482,21 @@ dependencies = [ "log", "mach", "memfd", - "memoffset 0.6.5", + "memoffset 0.8.0", "paste", "rand 0.8.5", "rustix 0.36.17", "wasmtime-asm-macros", "wasmtime-environ", "wasmtime-jit-debug", - "windows-sys 0.42.0", + "windows-sys 0.45.0", ] [[package]] name = "wasmtime-types" -version = "6.0.2" +version = "8.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83e5572c5727c1ee7e8f28717aaa8400e4d22dcbd714ea5457d85b5005206568" +checksum = "a4f6fffd2a1011887d57f07654dd112791e872e3ff4a2e626aee8059ee17f06f" dependencies = [ "cranelift-entity", "serde", @@ -12586,21 +12835,6 @@ dependencies = [ "windows-targets 0.48.5", ] -[[package]] -name = "windows-sys" -version = "0.42.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" -dependencies = [ - "windows_aarch64_gnullvm 0.42.2", - "windows_aarch64_msvc 0.42.2", - "windows_i686_gnu 0.42.2", - "windows_i686_msvc 0.42.2", - "windows_x86_64_gnu 0.42.2", - "windows_x86_64_gnullvm 0.42.2", - "windows_x86_64_msvc 0.42.2", -] - [[package]] name = "windows-sys" version = "0.45.0" diff --git a/Cargo.toml b/Cargo.toml index 0eb25fed..cccb9dc7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -88,175 +88,177 @@ codegen-units = 1 [workspace.dependencies] # ---- Substrate crates begin ---- # primitives -sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } -# sp-core-hashing = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } -sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } -sp-runtime-interface = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } -sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } -sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } -sp-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } -sp-std = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } -sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } -sp-application-crypto = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } -# sp-consensus-babe = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } -sp-externalities = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } -sp-consensus-grandpa = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } -sp-authority-discovery = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } -sp-timestamp = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } -sp-inherents = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } -sp-consensus = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } -sp-consensus-slots = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } -sp-transaction-storage-proof = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } -sp-keystore = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } -sp-state-machine = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } -sp-tracing = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } -sp-trie = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } -sp-block-builder = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } -sp-offchain = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } -sp-staking = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } -sp-session = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } -sp-transaction-pool = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } -sp-version = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } -sp-rpc = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } -sp-npos-elections = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } -node-primitives = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } +sp-core = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0", default-features = false } +sp-runtime = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0", default-features = false } +sp-runtime-interface = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0", default-features = false } +sp-keyring = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0" } +sp-blockchain = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0" } +sp-api = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0", default-features = false } +sp-std = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0", default-features = false } +sp-io = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0", default-features = false } +sp-application-crypto = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0", default-features = false } +# sp-consensus-babe = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0", default-features = false } +sp-externalities = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0", default-features = false } +sp-consensus-grandpa = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0", default-features = false } +sp-authority-discovery = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0", default-features = false } +sp-timestamp = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0", default-features = false } +sp-inherents = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0", default-features = false } +sp-consensus = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0", default-features = false } +sp-consensus-slots = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0", default-features = false } +sp-transaction-storage-proof = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0", default-features = false } +sp-keystore = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0", default-features = false } +sp-state-machine = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0", default-features = false } +sp-tracing = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0", default-features = false } +sp-trie = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0", default-features = false } +sp-block-builder = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0", default-features = false } +sp-offchain = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0", default-features = false } +sp-staking = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0", default-features = false } +sp-session = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0", default-features = false } +sp-statement-store = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0", default-features = false } +sp-transaction-pool = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0", default-features = false } +sp-version = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0", default-features = false } +sp-rpc = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0", default-features = false } +sp-npos-elections = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0", default-features = false } +node-primitives = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0", default-features = false } # frames -frame-support = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } -frame-system = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } -frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } -frame-executive = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } -frame-election-provider-support = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } -frame-system-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } -frame-try-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } -frame-system-rpc-runtime-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } -frame-benchmarking-cli = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" } -frame-support-test = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" } +frame-support = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0", default-features = false } +frame-system = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0", default-features = false } +frame-benchmarking = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0", default-features = false } +frame-executive = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0", default-features = false } +frame-election-provider-support = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0", default-features = false } +frame-system-benchmarking = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0", default-features = false } +frame-try-runtime = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0", default-features = false } +frame-system-rpc-runtime-api = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0", default-features = false } +frame-benchmarking-cli = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0" } +frame-support-test = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0" } # pallets -pallet-assets = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } -pallet-asset-tx-payment = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } -pallet-contracts-primitives = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } -pallet-democracy = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } -pallet-uniques = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } -pallet-preimage = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } -pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } -pallet-insecure-randomness-collective-flip = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } -pallet-timestamp = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } -pallet-scheduler = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } -pallet-collective = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } -pallet-contracts = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } -pallet-im-online = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } -pallet-sudo = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } -pallet-treasury = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } -pallet-transaction-payment = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } -pallet-transaction-payment-rpc = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } -pallet-authority-discovery = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } -pallet-authorship = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } -# pallet-babe = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } -pallet-bags-list = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } -pallet-bounties = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } -pallet-child-bounties = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } -pallet-elections-phragmen = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } -pallet-election-provider-multi-phase = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } -pallet-fast-unstake = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } -pallet-grandpa = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } -pallet-indices = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } -pallet-identity = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } -pallet-lottery = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } -pallet-membership = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } -pallet-multisig = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } -pallet-mmr = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } -pallet-nomination-pools = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } -pallet-nomination-pools-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } -pallet-nomination-pools-runtime-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } -pallet-offences = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } -pallet-offences-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } -pallet-proxy = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } -pallet-recovery = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } -pallet-session = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false, features = ["historical"] } -pallet-session-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } -pallet-staking = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } -pallet-staking-reward-curve = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } -pallet-society = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } -pallet-tips = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } -pallet-utility = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } -pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } -pallet-vesting = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } +pallet-assets = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0", default-features = false } +pallet-asset-tx-payment = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0", default-features = false } +pallet-contracts-primitives = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0", default-features = false } +pallet-democracy = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0", default-features = false } +pallet-uniques = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0", default-features = false } +pallet-preimage = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0", default-features = false } +pallet-balances = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0", default-features = false } +pallet-insecure-randomness-collective-flip = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0", default-features = false } +pallet-timestamp = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0", default-features = false } +pallet-scheduler = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0", default-features = false } +pallet-collective = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0", default-features = false } +pallet-contracts = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0", default-features = false } +pallet-im-online = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0", default-features = false } +pallet-sudo = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0", default-features = false } +pallet-treasury = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0", default-features = false } +pallet-transaction-payment = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0", default-features = false } +pallet-transaction-payment-rpc = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0" } +pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0", default-features = false } +pallet-authority-discovery = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0", default-features = false } +pallet-authorship = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0", default-features = false } +# pallet-babe = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0", default-features = false } +pallet-bags-list = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0", default-features = false } +pallet-bounties = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0", default-features = false } +pallet-child-bounties = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0", default-features = false } +pallet-elections-phragmen = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0", default-features = false } +pallet-election-provider-multi-phase = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0", default-features = false } +pallet-fast-unstake = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0", default-features = false } +pallet-grandpa = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0", default-features = false } +pallet-indices = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0", default-features = false } +pallet-identity = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0", default-features = false } +pallet-lottery = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0", default-features = false } +pallet-membership = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0", default-features = false } +pallet-multisig = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0", default-features = false } +pallet-mmr = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0", default-features = false } +pallet-nomination-pools = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0", default-features = false } +pallet-nomination-pools-benchmarking = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0", default-features = false } +pallet-nomination-pools-runtime-api = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0", default-features = false } +pallet-offences = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0", default-features = false } +pallet-offences-benchmarking = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0", default-features = false } +pallet-proxy = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0", default-features = false } +pallet-recovery = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0", default-features = false } +pallet-session = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0", default-features = false, features = ["historical"] } +pallet-session-benchmarking = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0", default-features = false } +pallet-staking = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0", default-features = false } +pallet-staking-reward-curve = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0", default-features = false } +pallet-society = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0", default-features = false } +pallet-tips = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0", default-features = false } +pallet-utility = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0", default-features = false } +pallet-vesting = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0", default-features = false } # client dependencies -sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" } -sc-transaction-pool-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" } -sc-rpc = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" } -sc-network-common = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" } -sc-chain-spec = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" } -sc-consensus = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" } -sc-transaction-pool = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" } -sc-offchain = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" } -sc-network = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" } -sc-network-sync = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" } -sc-consensus-slots = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" } -sc-consensus-babe = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" } -sc-basic-authorship = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" } -sc-service = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" } -sc-telemetry = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" } -sc-authority-discovery = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" } -sc-sync-state-rpc = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" } -sc-sysinfo = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" } -sc-block-builder = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" } -sc-client-db = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" } -sc-consensus-epochs = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" } -sc-service-test = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" } -sc-keystore = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" } -sc-cli = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" } -sc-executor = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" } -sc-consensus-babe-rpc = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" } -sc-consensus-grandpa = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" } -grandpa = { package = "sc-consensus-grandpa", git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" } -sc-consensus-grandpa-rpc = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" } -sc-rpc-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" } -sc-consensus-manual-seal = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" } -sc-rpc-spec-v2 = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" } -sc-network-test = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" } +sc-client-api = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0" } +sc-transaction-pool-api = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0" } +sc-rpc = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0" } +sc-network-common = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0" } +sc-chain-spec = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0" } +sc-consensus = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0" } +sc-transaction-pool = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0" } +sc-offchain = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0" } +sc-network = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0" } +sc-network-sync = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0" } +sc-consensus-slots = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0" } +sc-consensus-babe = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0" } +sc-basic-authorship = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0" } +sc-statement-store = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0" } +sc-service = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0" } +sc-telemetry = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0" } +sc-authority-discovery = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0" } +sc-sync-state-rpc = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0" } +sc-sysinfo = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0" } +sc-block-builder = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0" } +sc-client-db = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0" } +sc-consensus-epochs = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0" } +sc-service-test = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0" } +sc-keystore = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0" } +sc-cli = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0" } +sc-executor = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0" } +sc-consensus-babe-rpc = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0" } +sc-consensus-grandpa = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0" } +grandpa = { package = "sc-consensus-grandpa", git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0" } +sc-consensus-grandpa-rpc = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0" } +sc-rpc-api = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0" } +sc-consensus-manual-seal = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0" } +sc-rpc-spec-v2 = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0" } +sc-network-test = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0" } -substrate-state-trie-migration-rpc = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" } -substrate-wasm-builder = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" } -node-inspect = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" } -try-runtime-cli = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } -substrate-frame-cli = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" } -substrate-build-script-utils = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" } -substrate-rpc-client = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" } -substrate-frame-rpc-system = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" } -mmr-rpc = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" } -prometheus-endpoint = { package = "substrate-prometheus-endpoint", git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" } -substrate-test-utils = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" } -fork-tree = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" } -substrate-test-runtime-client = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" } +substrate-state-trie-migration-rpc = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0" } +substrate-wasm-builder = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0" } +node-inspect = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0" } +try-runtime-cli = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0", default-features = false } +substrate-frame-cli = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0" } +substrate-build-script-utils = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0" } +substrate-rpc-client = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0" } +substrate-frame-rpc-system = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0" } +mmr-rpc = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0" } +prometheus-endpoint = { package = "substrate-prometheus-endpoint", git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0" } +substrate-test-utils = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0" } +fork-tree = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0" } +substrate-test-runtime-client = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0" } # ---- Substrate crates end ---- # ---- Frontier crates begin ---- -fp-account = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v0.9.42", default-features = false } -fp-evm = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v0.9.42", default-features = false } -fp-rpc = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v0.9.42", default-features = false } -fp-self-contained = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v0.9.42", default-features = false } -fp-dynamic-fee = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v0.9.42", default-features = false } +fp-account = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v1.1.0", default-features = false } +fp-evm = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v1.1.0", default-features = false } +fp-rpc = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v1.1.0", default-features = false } +fp-self-contained = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v1.1.0", default-features = false } +fp-dynamic-fee = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v1.1.0", default-features = false } -pallet-base-fee = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v0.9.42", default-features = false } -pallet-dynamic-fee = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v0.9.42", default-features = false } -pallet-ethereum = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v0.9.42", default-features = false } -pallet-evm = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v0.9.42", default-features = false } -pallet-evm-chain-id = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v0.9.42", default-features = false } -pallet-evm-precompile-modexp = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v0.9.42", default-features = false } -pallet-evm-precompile-sha3fips = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v0.9.42", default-features = false } -pallet-evm-precompile-simple = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v0.9.42", default-features = false } +pallet-base-fee = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v1.1.0", default-features = false } +pallet-dynamic-fee = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v1.1.0", default-features = false } +pallet-ethereum = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v1.1.0", default-features = false } +pallet-evm = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v1.1.0", default-features = false } +pallet-evm-chain-id = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v1.1.0", default-features = false } +pallet-evm-precompile-modexp = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v1.1.0", default-features = false } +pallet-evm-precompile-sha3fips = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v1.1.0", default-features = false } +pallet-evm-precompile-simple = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v1.1.0", default-features = false } -fc-cli = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v0.9.42", default-features = false } -fc-consensus = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v0.9.42", default-features = false } -fc-db = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v0.9.42", default-features = false } -fc-mapping-sync = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v0.9.42", default-features = false } -fc-rpc = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v0.9.42", default-features = false } -fc-rpc-core = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v0.9.42", default-features = false } -fc-storage = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v0.9.42", default-features = false } +fc-api = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v1.1.0" } +fc-cli = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v1.1.0", default-features = false } +fc-consensus = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v1.1.0", default-features = false } +fc-db = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v1.1.0", default-features = false } +fc-mapping-sync = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v1.1.0", default-features = false } +fc-rpc = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v1.1.0", default-features = false } +fc-rpc-core = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v1.1.0", default-features = false } +fc-storage = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v1.1.0", default-features = false } # ---- Frontier crates end ---- array-bytes = "4.1" @@ -273,8 +275,8 @@ jsonrpsee = { version = "0.16" } # this version of jsonrpsee is used by Substra lazy_static = { version = "1", default-features = false } libc = "0.2" log = { version = "0.4", default-features = false } -parity-scale-codec = { version = "3.2.2", default-features = false } -codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false } +parity-scale-codec = { version = "3.6.1", default-features = false } +codec = { package = "parity-scale-codec", version = "3.6.1", default-features = false } pairing = { version = "0.22", default-features = false } rand = "0.8.5" rand_chacha = { version = "0.2", default-features = false } diff --git a/crates/bloom-filter/Cargo.toml b/crates/bloom-filter/Cargo.toml index bee90e2a..b4d22912 100755 --- a/crates/bloom-filter/Cargo.toml +++ b/crates/bloom-filter/Cargo.toml @@ -4,19 +4,14 @@ version = "0.1.0" edition = "2021" [dependencies] -log = { workspace = true } -codec = { version = "3.2.2", package = "parity-scale-codec", default-features = false, features = ["derive"] } +codec = { package = "parity-scale-codec", version = "3.6.1", default-features = false, features = ["derive", "max-encoded-len"] } scale-info = { workspace = true, features = ["derive"] } -frame-support = {workspace = true} -sp-std = { workspace = true} -cp-cess-common = { workspace = true } +sp-core = { workspace = true } [features] default = ["std"] std = [ "codec/std", "scale-info/std", - "frame-support/std", - "sp-std/std", - "cp-cess-common/std", + "sp-core/std", ] \ No newline at end of file diff --git a/crates/bloom-filter/src/lib.rs b/crates/bloom-filter/src/lib.rs index d4e258f4..51547807 100755 --- a/crates/bloom-filter/src/lib.rs +++ b/crates/bloom-filter/src/lib.rs @@ -1,11 +1,8 @@ #![cfg_attr(not(feature = "std"), no_std)] -use frame_support::{ - RuntimeDebug, - dispatch::{Decode, Encode}, -}; -use codec::{MaxEncodedLen}; +use codec::{Decode, Encode, MaxEncodedLen}; use scale_info::TypeInfo; +use sp_core::RuntimeDebug; #[derive(Copy, Clone, Eq, PartialEq, Encode, Decode, RuntimeDebug, MaxEncodedLen, TypeInfo)] pub struct BloomFilter(pub [u64; 256]); diff --git a/crates/common/Cargo.toml b/crates/common/Cargo.toml index 25f173a3..674d8f56 100644 --- a/crates/common/Cargo.toml +++ b/crates/common/Cargo.toml @@ -5,7 +5,7 @@ edition = "2021" [dependencies] log = { workspace = true } -codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = ["derive", "max-encoded-len"] } +codec = { package = "parity-scale-codec", version = "3.6.1", default-features = false, features = ["derive", "max-encoded-len"] } scale-info = { workspace = true, features = ["derive"] } frame-support = { workspace = true } diff --git a/crates/common/src/lib.rs b/crates/common/src/lib.rs index 2c969d48..b6c7a4aa 100644 --- a/crates/common/src/lib.rs +++ b/crates/common/src/lib.rs @@ -2,11 +2,11 @@ use frame_support::{ BoundedVec, - RuntimeDebug, pallet_prelude::ConstU32, }; use codec::{MaxEncodedLen, Decode, Encode}; use scale_info::TypeInfo; +use sp_core::RuntimeDebug; use sp_std::prelude::Box; #[derive(Copy, Clone, Eq, PartialEq, Encode, Decode, RuntimeDebug, MaxEncodedLen, TypeInfo, PartialOrd, Ord)] diff --git a/crates/rrsc/Cargo.toml b/crates/rrsc/Cargo.toml index 6f1fd6df..14468ce1 100644 --- a/crates/rrsc/Cargo.toml +++ b/crates/rrsc/Cargo.toml @@ -15,7 +15,7 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] async-trait = { workspace = true } scale-info = { workspace = true, features = ["derive"] } -codec = { package = "parity-scale-codec", version = "3.2.2", features = ["derive"] } +codec = { package = "parity-scale-codec", version = "3.6.1", features = ["derive"] } futures = { workspace = true } log = { workspace = true } num-bigint = { workspace = true } @@ -31,17 +31,18 @@ sc-consensus-epochs = { workspace = true } sc-consensus-slots = { workspace = true } sc-keystore = { workspace = true } sc-telemetry = { workspace = true } -sp-api = { workspace = true } -sp-application-crypto = { workspace = true } -sp-block-builder = { workspace = true, features = ["std"]} -sp-blockchain = { workspace = true } -sp-consensus = { workspace = true } -sp-consensus-slots = { workspace = true } -sp-core = { workspace = true } -sp-inherents = { workspace = true } -sp-keystore = { workspace = true } -sp-runtime = { workspace = true } -cessp-consensus-rrsc = { workspace = true, features = ["std"]} +sc-transaction-pool-api = { workspace = true } +sp-api = { workspace = true, default-features = true } +sp-application-crypto = { workspace = true, default-features = true } +sp-block-builder = { workspace = true, default-features = true } +sp-blockchain = { workspace = true, default-features = true } +sp-consensus = { workspace = true, default-features = true } +sp-consensus-slots = { workspace = true, default-features = true } +sp-core = { workspace = true, default-features = true } +sp-inherents = { workspace = true, default-features = true } +sp-keystore = { workspace = true, default-features = true } +sp-runtime = { workspace = true, default-features = true } +cessp-consensus-rrsc = { workspace = true, default-features = true } [dev-dependencies] rand_chacha = { workspace = true } diff --git a/crates/rrsc/pallet/Cargo.toml b/crates/rrsc/pallet/Cargo.toml index 50ae3683..e0f9e0f4 100644 --- a/crates/rrsc/pallet/Cargo.toml +++ b/crates/rrsc/pallet/Cargo.toml @@ -13,33 +13,33 @@ readme = "README.md" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = ["derive"] } +codec = { package = "parity-scale-codec", version = "3.6.1", default-features = false, features = ["derive"] } log = { workspace = true } -scale-info = { workspace = true, features = ["derive"] } +scale-info = { workspace = true, features = ["derive", "serde"] } frame-benchmarking = { workspace = true, optional = true } frame-support = { workspace = true } frame-system = { workspace = true } pallet-authorship = { workspace = true } pallet-session = { workspace = true } pallet-timestamp = { workspace = true } -sp-application-crypto = { workspace = true } -sp-core = { workspace = true } +sp-application-crypto = { workspace = true, features = ["serde"] } +sp-core = { workspace = true, features = ["serde"] } sp-io = { workspace = true } sp-npos-elections = { workspace = true } -sp-runtime = { workspace = true } +sp-runtime = { workspace = true, features = ["serde"] } sp-session = { workspace = true } -sp-staking = { workspace = true } +sp-staking = { workspace = true, features = ["serde"] } sp-std = { workspace = true } frame-election-provider-support = { workspace = true } -cessp-consensus-rrsc = { workspace = true } +cessp-consensus-rrsc = { workspace = true, features = ["serde"] } [dev-dependencies] -frame-election-provider-support = { workspace = true } -pallet-balances = { workspace = true } -pallet-offences = { workspace = true } -pallet-staking = { workspace = true } -pallet-staking-reward-curve = { workspace = true } -sp-core = { workspace = true } +frame-election-provider-support = { workspace = true, default-features = true } +pallet-balances = { workspace = true, default-features = true } +pallet-offences = { workspace = true, default-features = true } +pallet-staking = { workspace = true, default-features = true } +pallet-staking-reward-curve = { workspace = true, default-features = true } +sp-core = { workspace = true, default-features = true } [features] default = ["std"] diff --git a/crates/rrsc/pallet/src/benchmarking.rs b/crates/rrsc/pallet/src/benchmarking.rs index 9bbdc0db..cb0ae3e4 100644 --- a/crates/rrsc/pallet/src/benchmarking.rs +++ b/crates/rrsc/pallet/src/benchmarking.rs @@ -20,7 +20,7 @@ #![cfg(feature = "runtime-benchmarks")] use super::*; -use frame_benchmarking::benchmarks; +use frame_benchmarking::v1::benchmarks; type Header = sp_runtime::generic::Header; diff --git a/crates/rrsc/pallet/src/default_weights.rs b/crates/rrsc/pallet/src/default_weights.rs index a7137476..90afaabd 100644 --- a/crates/rrsc/pallet/src/default_weights.rs +++ b/crates/rrsc/pallet/src/default_weights.rs @@ -28,15 +28,11 @@ impl crate::WeightInfo for () { DbWeight::get().writes(1) } - fn report_equivocation(validator_count: u32) -> Weight { + fn report_equivocation(validator_count: u32, max_nominators_per_validator: u32) -> Weight { // we take the validator set count from the membership proof to // calculate the weight but we set a floor of 100 validators. let validator_count = validator_count.max(100) as u64; - // worst case we are considering is that the given offender - // is backed by 200 nominators - const MAX_NOMINATORS: u64 = 200; - // checking membership proof Weight::from_parts(35u64 * WEIGHT_REF_TIME_PER_MICROS, 0) .saturating_add( @@ -49,10 +45,10 @@ impl crate::WeightInfo for () { // report offence .saturating_add(Weight::from_parts(110u64 * WEIGHT_REF_TIME_PER_MICROS, 0)) .saturating_add(Weight::from_parts( - 25u64 * WEIGHT_REF_TIME_PER_MICROS * MAX_NOMINATORS, + 25u64 * WEIGHT_REF_TIME_PER_MICROS * max_nominators_per_validator as u64, 0, )) - .saturating_add(DbWeight::get().reads(14 + 3 * MAX_NOMINATORS)) - .saturating_add(DbWeight::get().writes(10 + 3 * MAX_NOMINATORS)) + .saturating_add(DbWeight::get().reads(14 + 3 * max_nominators_per_validator as u64)) + .saturating_add(DbWeight::get().writes(10 + 3 * max_nominators_per_validator as u64)) } } diff --git a/crates/rrsc/pallet/src/equivocation.rs b/crates/rrsc/pallet/src/equivocation.rs index 65d6f66d..5da5bebd 100644 --- a/crates/rrsc/pallet/src/equivocation.rs +++ b/crates/rrsc/pallet/src/equivocation.rs @@ -34,6 +34,7 @@ //! definition. use frame_support::traits::{Get, KeyOwnerProofSystem}; +use frame_system::pallet_prelude::HeaderFor; use log::{error, info}; use cessp_consensus_rrsc::{AuthorityId, EquivocationProof, Slot, KEY_TYPE}; @@ -99,14 +100,14 @@ impl Offence for EquivocationOffence { /// /// This type implements `OffenceReportSystem` such that: /// - Equivocation reports are published on-chain as unsigned extrinsic via -/// `offchain::SendTransactioinsTypes`. +/// `offchain::SendTransactionTypes`. /// - On-chain validity checks and processing are mostly delegated to the user provided generic /// types implementing `KeyOwnerProofSystem` and `ReportOffence` traits. /// - Offence reporter for unsigned transactions is fetched via the the authorship pallet. pub struct EquivocationReportSystem(sp_std::marker::PhantomData<(T, R, P, L)>); impl - OffenceReportSystem, (EquivocationProof, T::KeyOwnerProof)> + OffenceReportSystem, (EquivocationProof>, T::KeyOwnerProof)> for EquivocationReportSystem where T: Config + pallet_authorship::Config + frame_system::offchain::SendTransactionTypes>, @@ -122,7 +123,7 @@ where type Longevity = L; fn publish_evidence( - evidence: (EquivocationProof, T::KeyOwnerProof), + evidence: (EquivocationProof>, T::KeyOwnerProof), ) -> Result<(), ()> { use frame_system::offchain::SubmitTransaction; let (equivocation_proof, key_owner_proof) = evidence; @@ -140,7 +141,7 @@ where } fn check_evidence( - evidence: (EquivocationProof, T::KeyOwnerProof), + evidence: (EquivocationProof>, T::KeyOwnerProof), ) -> Result<(), TransactionValidityError> { let (equivocation_proof, key_owner_proof) = evidence; @@ -159,7 +160,7 @@ where fn process_evidence( reporter: Option, - evidence: (EquivocationProof, T::KeyOwnerProof), + evidence: (EquivocationProof>, T::KeyOwnerProof), ) -> Result<(), DispatchError> { let (equivocation_proof, key_owner_proof) = evidence; let reporter = reporter.or_else(|| >::author()); diff --git a/crates/rrsc/pallet/src/lib.rs b/crates/rrsc/pallet/src/lib.rs index 0aac14bc..78c6c461 100644 --- a/crates/rrsc/pallet/src/lib.rs +++ b/crates/rrsc/pallet/src/lib.rs @@ -29,6 +29,7 @@ use frame_support::{ weights::Weight, BoundedVec, WeakBoundedVec, }; +use frame_system::pallet_prelude::{BlockNumberFor, HeaderFor}; use cessp_consensus_rrsc::{ digests::{NextConfigDescriptor, NextEpochDescriptor, PreDigest}, AllowedSlots, RRSCAuthorityWeight, RRSCEpochConfiguration, ConsensusLog, Epoch, @@ -73,14 +74,14 @@ pub use pallet::*; pub trait WeightInfo { fn plan_config_change() -> Weight; - fn report_equivocation(validator_count: u32) -> Weight; + fn report_equivocation(validator_count: u32, max_nominators_per_validator: u32) -> Weight; } /// Trigger an epoch change, if any should take place. pub trait EpochChangeTrigger { /// Trigger an epoch change, if any should take place. This should be called /// during every block, after initialization is done. - fn trigger(now: T::BlockNumber); + fn trigger(now: BlockNumberFor); } /// A type signifying to RRSC that an external trigger @@ -88,7 +89,7 @@ pub trait EpochChangeTrigger { pub struct ExternalTrigger; impl EpochChangeTrigger for ExternalTrigger { - fn trigger(_: T::BlockNumber) {} // nothing - trigger is external. + fn trigger(_: BlockNumberFor) {} // nothing - trigger is external. } /// A type signifying to RRSC that it should perform epoch changes @@ -96,7 +97,7 @@ impl EpochChangeTrigger for ExternalTrigger { pub struct SameAuthoritiesForever; impl EpochChangeTrigger for SameAuthoritiesForever { - fn trigger(now: T::BlockNumber) { + fn trigger(now: BlockNumberFor) { if >::should_epoch_change(now) { let authorities = >::authorities(); let next_authorities = authorities.clone(); @@ -154,6 +155,10 @@ pub mod pallet { #[pallet::constant] type MaxAuthorities: Get; + /// The maximum number of nominators for each validator. + #[pallet::constant] + type MaxNominators: Get; + /// The proof of key ownership, used for validating equivocation reports. /// The proof must include the session index and validator count of the /// session at which the equivocation occurred. @@ -164,7 +169,7 @@ pub mod pallet { /// (from an offchain context). type EquivocationReportSystem: OffenceReportSystem< Option, - (EquivocationProof, Self::KeyOwnerProof), + (EquivocationProof>, Self::KeyOwnerProof), >; } @@ -281,7 +286,7 @@ pub mod pallet { /// slots, which may be skipped, the block numbers may not line up with the slot numbers. #[pallet::storage] pub(super) type EpochStart = - StorageValue<_, (T::BlockNumber, T::BlockNumber), ValueQuery>; + StorageValue<_, (BlockNumberFor, BlockNumberFor), ValueQuery>; /// How late the current block is compared to its parent. /// @@ -290,7 +295,7 @@ pub mod pallet { /// execution context should always yield zero. #[pallet::storage] #[pallet::getter(fn lateness)] - pub(super) type Lateness = StorageValue<_, T::BlockNumber, ValueQuery>; + pub(super) type Lateness = StorageValue<_, BlockNumberFor, ValueQuery>; /// The configuration for the current epoch. Should never be `None` as it is initialized in /// genesis. @@ -316,15 +321,17 @@ pub mod pallet { pub(super) type SkippedEpochs = StorageValue<_, BoundedVec<(u64, SessionIndex), ConstU32<100>>, ValueQuery>; - #[cfg_attr(feature = "std", derive(Default))] + #[derive(frame_support::DefaultNoBound)] #[pallet::genesis_config] - pub struct GenesisConfig { + pub struct GenesisConfig { pub authorities: Vec<(AuthorityId, RRSCAuthorityWeight)>, pub epoch_config: Option, + #[serde(skip)] + pub _config: sp_std::marker::PhantomData, } #[pallet::genesis_build] - impl GenesisBuild for GenesisConfig { + impl BuildGenesisConfig for GenesisConfig { fn build(&self) { SegmentIndex::::put(0); Pallet::::initialize_genesis_authorities(&self.authorities); @@ -359,12 +366,12 @@ pub mod pallet { ); } - if let Some(vrf_signature) = pre_digest.vrf_signature() { + if let Some(signature) = pre_digest.vrf_signature() { let randomness: Option = Authorities::::get() .get(authority_index as usize) .and_then(|(authority, _)| { let public = authority.as_inner_ref(); - let transcript = cessp_consensus_rrsc::make_transcript( + let transcript = cessp_consensus_rrsc::make_vrf_transcript( &Self::randomness(), CurrentSlot::::get(), EpochIndex::::get(), @@ -374,16 +381,12 @@ pub mod pallet { // execution. We don't run the verification again here to avoid slowing // down the runtime. debug_assert!({ - use sp_core::crypto::VrfVerifier; - public.vrf_verify(&transcript, &vrf_signature) + use sp_core::crypto::VrfPublic; + public.vrf_verify(&transcript.clone().into_sign_data(), &signature) }); public - .make_bytes( - RANDOMNESS_VRF_CONTEXT, - &transcript, - &vrf_signature.output, - ) + .make_bytes(RANDOMNESS_VRF_CONTEXT, &transcript, &signature.output) .ok() }); @@ -410,10 +413,11 @@ pub mod pallet { #[pallet::call_index(0)] #[pallet::weight(::WeightInfo::report_equivocation( key_owner_proof.validator_count(), + T::MaxNominators::get(), ))] pub fn report_equivocation( origin: OriginFor, - equivocation_proof: Box>, + equivocation_proof: Box>>, key_owner_proof: T::KeyOwnerProof, ) -> DispatchResultWithPostInfo { let reporter = ensure_signed(origin)?; @@ -436,10 +440,11 @@ pub mod pallet { #[pallet::call_index(1)] #[pallet::weight(::WeightInfo::report_equivocation( key_owner_proof.validator_count(), + T::MaxNominators::get(), ))] pub fn report_equivocation_unsigned( origin: OriginFor, - equivocation_proof: Box>, + equivocation_proof: Box>>, key_owner_proof: T::KeyOwnerProof, ) -> DispatchResultWithPostInfo { ensure_none(origin)?; @@ -509,8 +514,8 @@ impl IsMember for Pallet { } } -impl pallet_session::ShouldEndSession for Pallet { - fn should_end_session(now: T::BlockNumber) -> bool { +impl pallet_session::ShouldEndSession> for Pallet { + fn should_end_session(now: BlockNumberFor) -> bool { // it might be (and it is in current implementation) that session module is calling // `should_end_session` from it's own `on_initialize` handler, in which case it's // possible that rrsc's own `on_initialize` has not run yet, so let's ensure that we @@ -530,7 +535,7 @@ impl Pallet { /// Determine whether an epoch change should take place at this block. /// Assumes that initialization has already taken place. - pub fn should_epoch_change(now: T::BlockNumber) -> bool { + pub fn should_epoch_change(now: BlockNumberFor) -> bool { // The epoch has technically ended during the passage of time // between this block and the last, but we have to "end" the epoch now, // since there is no earlier possible block we could have done it. @@ -560,11 +565,11 @@ impl Pallet { // // WEIGHT NOTE: This function is tied to the weight of `EstimateNextSessionRotation`. If you // update this function, you must also update the corresponding weight. - pub fn next_expected_epoch_change(now: T::BlockNumber) -> Option { + pub fn next_expected_epoch_change(now: BlockNumberFor) -> Option> { let next_slot = Self::current_epoch_start().saturating_add(T::EpochDuration::get()); next_slot.checked_sub(*CurrentSlot::::get()).map(|slots_remaining| { // This is a best effort guess. Drifts in the slot/block ratio will cause errors here. - let blocks_remaining: T::BlockNumber = slots_remaining.saturated_into(); + let blocks_remaining: BlockNumberFor = slots_remaining.saturated_into(); now.saturating_add(blocks_remaining) }) } @@ -782,7 +787,7 @@ impl Pallet { Self::deposit_consensus(ConsensusLog::NextEpochData(next)); } - fn initialize(now: T::BlockNumber) { + fn initialize(now: BlockNumberFor) { // since `initialize` can be called twice (e.g. if session module is present) // let's ensure that we only do the initialization once per block let initialized = Self::initialized().is_some(); @@ -817,7 +822,7 @@ impl Pallet { // how many slots were skipped between current and last block let lateness = current_slot.saturating_sub(CurrentSlot::::get() + 1); - let lateness = T::BlockNumber::from(*lateness as u32); + let lateness = BlockNumberFor::::from(*lateness as u32); Lateness::::put(lateness); CurrentSlot::::put(current_slot); @@ -883,7 +888,7 @@ impl Pallet { /// will push the transaction to the pool. Only useful in an offchain /// context. pub fn submit_unsigned_equivocation_report( - equivocation_proof: EquivocationProof, + equivocation_proof: EquivocationProof>, key_owner_proof: T::KeyOwnerProof, ) -> Option<()> { T::EquivocationReportSystem::publish_evidence((equivocation_proof, key_owner_proof)).ok() @@ -905,12 +910,14 @@ impl OnTimestampSet for Pallet { } } -impl frame_support::traits::EstimateNextSessionRotation for Pallet { - fn average_session_length() -> T::BlockNumber { +impl frame_support::traits::EstimateNextSessionRotation> + for Pallet +{ + fn average_session_length() -> BlockNumberFor { T::EpochDuration::get().saturated_into() } - fn estimate_current_session_progress(_now: T::BlockNumber) -> (Option, Weight) { + fn estimate_current_session_progress(_now: BlockNumberFor) -> (Option, Weight) { let elapsed = CurrentSlot::::get().saturating_sub(Self::current_epoch_start()) + 1; ( @@ -920,7 +927,9 @@ impl frame_support::traits::EstimateNextSessionRotation (Option, Weight) { + fn estimate_next_session_rotation( + now: BlockNumberFor, + ) -> (Option>, Weight) { ( Self::next_expected_epoch_change(now), // Read: Current Slot, Epoch Index, Genesis Slot @@ -929,8 +938,8 @@ impl frame_support::traits::EstimateNextSessionRotation frame_support::traits::Lateness for Pallet { - fn lateness(&self) -> T::BlockNumber { +impl frame_support::traits::Lateness> for Pallet { + fn lateness(&self) -> BlockNumberFor { Self::lateness() } } diff --git a/crates/rrsc/pallet/src/mock.rs b/crates/rrsc/pallet/src/mock.rs index 62e2a2d6..1a2c1030 100644 --- a/crates/rrsc/pallet/src/mock.rs +++ b/crates/rrsc/pallet/src/mock.rs @@ -19,15 +19,19 @@ use crate::{self as pallet_rrsc, Config, CurrentSlot}; use codec::Encode; -use frame_election_provider_support::{onchain, SequentialPhragmen}; +use frame_election_provider_support::{ + bounds::{ElectionBounds, ElectionBoundsBuilder}, + onchain, SequentialPhragmen, +}; use frame_support::{ parameter_types, - traits::{ConstU128, ConstU32, ConstU64, GenesisBuild, KeyOwnerProofSystem, OnInitialize}, + traits::{ConstU128, ConstU32, ConstU64, KeyOwnerProofSystem, OnInitialize}, }; use pallet_session::historical as pallet_session_historical; +use pallet_staking::FixedNominationsQuota; use cessp_consensus_rrsc::{AuthorityId, AuthorityPair, Randomness, Slot, VrfSignature}; use sp_core::{ - crypto::{KeyTypeId, Pair, VrfSigner}, + crypto::{KeyTypeId, Pair, VrfSecret}, H256, U256, }; use sp_io; @@ -36,20 +40,16 @@ use sp_runtime::{ impl_opaque_keys, testing::{Digest, DigestItem, Header, TestXt}, traits::{Header as _, IdentityLookup, OpaqueKeys}, - Perbill, + BuildStorage, Perbill, }; use sp_staking::{EraIndex, SessionIndex}; type DummyValidatorId = u64; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system, Authorship: pallet_authorship, @@ -69,15 +69,14 @@ impl frame_system::Config for Test { type BlockLength = (); type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; - type Index = u64; - type BlockNumber = u64; + type Nonce = u64; type RuntimeCall = RuntimeCall; type Hash = H256; type Version = (); type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = DummyValidatorId; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type PalletInfo = PalletInfo; @@ -145,7 +144,7 @@ impl pallet_balances::Config for Test { type WeightInfo = (); type FreezeIdentifier = (); type MaxFreezes = (); - type HoldIdentifier = (); + type RuntimeHoldReason = (); type MaxHolds = (); } @@ -166,6 +165,7 @@ parameter_types! { pub const SlashDeferDuration: EraIndex = 0; pub const RewardCurve: &'static PiecewiseLinear<'static> = &REWARD_CURVE; pub const OffendingValidatorsThreshold: Perbill = Perbill::from_percent(16); + pub static ElectionsBounds: ElectionBounds = ElectionBoundsBuilder::default().build(); } pub struct OnChainSeqPhragmen; @@ -175,14 +175,12 @@ impl onchain::Config for OnChainSeqPhragmen { type DataProvider = Staking; type WeightInfo = (); type MaxWinners = ConstU32<100>; - type VotersBound = ConstU32<{ u32::MAX }>; - type TargetsBound = ConstU32<{ u32::MAX }>; + type Bounds = ElectionsBounds; } impl pallet_staking::Config for Test { - type MaxNominations = ConstU32<16>; type RewardRemainder = (); - type CurrencyToVote = frame_support::traits::SaturatingCurrencyToVote; + type CurrencyToVote = (); type RuntimeEvent = RuntimeEvent; type Currency = Balances; type CurrencyBalance = ::Balance; @@ -202,9 +200,10 @@ impl pallet_staking::Config for Test { type GenesisElectionProvider = Self::ElectionProvider; type VoterList = pallet_staking::UseNominatorsAndValidatorsMap; type TargetList = pallet_staking::UseValidatorsMap; + type NominationsQuota = FixedNominationsQuota<16>; type MaxUnlockingChunks = ConstU32<32>; type HistoryDepth = ConstU32<84>; - type OnStakerSlash = (); + type EventListeners = (); type BenchmarkingConfig = pallet_staking::TestBenchmarkingConfig; type WeightInfo = (); } @@ -228,6 +227,7 @@ impl Config for Test { type DisabledValidators = Session; type WeightInfo = (); type MaxAuthorities = ConstU32<10>; + type MaxNominators = ConstU32<100>; type KeyOwnerProof = >::Proof; type EquivocationReportSystem = super::EquivocationReportSystem; @@ -318,17 +318,16 @@ pub fn make_secondary_vrf_pre_digest( Digest { logs: vec![log] } } -pub fn make_vrf_output( +pub fn make_vrf_signature_and_randomness( slot: Slot, pair: &cessp_consensus_rrsc::AuthorityPair, ) -> (VrfSignature, Randomness) { - let transcript = cessp_consensus_rrsc::make_transcript(&RRSC::randomness(), slot, 0); + let transcript = cessp_consensus_rrsc::make_vrf_transcript(&RRSC::randomness(), slot, 0); - let signature = pair.as_ref().vrf_sign(&transcript); + let randomness = + pair.as_ref().make_bytes(cessp_consensus_rrsc::RANDOMNESS_VRF_CONTEXT, &transcript); - let randomness = pair - .as_ref() - .make_bytes::(cessp_consensus_rrsc::RANDOMNESS_VRF_CONTEXT, &transcript); + let signature = pair.as_ref().vrf_sign(&transcript.into()); (signature, randomness) } @@ -350,7 +349,7 @@ pub fn new_test_ext_with_pairs( } pub fn new_test_ext_raw_authorities(authorities: Vec) -> sp_io::TestExternalities { - let mut t = frame_system::GenesisConfig::default().build_storage::().unwrap(); + let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); let balances: Vec<_> = (0..authorities.len()).map(|i| (i as u64, 10_000_000)).collect(); @@ -373,11 +372,9 @@ pub fn new_test_ext_raw_authorities(authorities: Vec) -> sp_io::Tes .assimilate_storage(&mut t) .unwrap(); - // controllers are the index + 1000 + // controllers are same as stash let stakers: Vec<_> = (0..authorities.len()) - .map(|i| { - (i as u64, i as u64 + 1000, 10_000, pallet_staking::StakerStatus::::Validator) - }) + .map(|i| (i as u64, i as u64, 10_000, pallet_staking::StakerStatus::::Validator)) .collect(); let staking_config = pallet_staking::GenesisConfig:: { diff --git a/crates/rrsc/pallet/src/randomness.rs b/crates/rrsc/pallet/src/randomness.rs index cd38abfa..41a12a13 100644 --- a/crates/rrsc/pallet/src/randomness.rs +++ b/crates/rrsc/pallet/src/randomness.rs @@ -22,6 +22,7 @@ use super::{ AuthorVrfRandomness, Config, EpochStart, NextRandomness, Randomness, RANDOMNESS_LENGTH, }; use frame_support::traits::Randomness as RandomnessT; +use frame_system::pallet_prelude::BlockNumberFor; use sp_runtime::traits::{Hash, One, Saturating}; /// Randomness usable by consensus protocols that **depend** upon finality and take action @@ -129,8 +130,8 @@ pub struct ParentBlockRandomness(sp_std::marker::PhantomData); Please use `ParentBlockRandomness` instead.")] pub struct CurrentBlockRandomness(sp_std::marker::PhantomData); -impl RandomnessT for RandomnessFromTwoEpochsAgo { - fn random(subject: &[u8]) -> (T::Hash, T::BlockNumber) { +impl RandomnessT> for RandomnessFromTwoEpochsAgo { + fn random(subject: &[u8]) -> (T::Hash, BlockNumberFor) { let mut subject = subject.to_vec(); subject.reserve(RANDOMNESS_LENGTH); subject.extend_from_slice(&Randomness::::get()[..]); @@ -139,8 +140,8 @@ impl RandomnessT for RandomnessFromTwoEpochs } } -impl RandomnessT for RandomnessFromOneEpochAgo { - fn random(subject: &[u8]) -> (T::Hash, T::BlockNumber) { +impl RandomnessT> for RandomnessFromOneEpochAgo { + fn random(subject: &[u8]) -> (T::Hash, BlockNumberFor) { let mut subject = subject.to_vec(); subject.reserve(RANDOMNESS_LENGTH); subject.extend_from_slice(&NextRandomness::::get()[..]); @@ -149,8 +150,8 @@ impl RandomnessT for RandomnessFromOneEpochA } } -impl RandomnessT, T::BlockNumber> for ParentBlockRandomness { - fn random(subject: &[u8]) -> (Option, T::BlockNumber) { +impl RandomnessT, BlockNumberFor> for ParentBlockRandomness { + fn random(subject: &[u8]) -> (Option, BlockNumberFor) { let random = AuthorVrfRandomness::::get().map(|random| { let mut subject = subject.to_vec(); subject.reserve(RANDOMNESS_LENGTH); @@ -164,8 +165,8 @@ impl RandomnessT, T::BlockNumber> for ParentBlockRand } #[allow(deprecated)] -impl RandomnessT, T::BlockNumber> for CurrentBlockRandomness { - fn random(subject: &[u8]) -> (Option, T::BlockNumber) { +impl RandomnessT, BlockNumberFor> for CurrentBlockRandomness { + fn random(subject: &[u8]) -> (Option, BlockNumberFor) { let (random, _) = ParentBlockRandomness::::random(subject); (random, >::block_number()) } diff --git a/crates/rrsc/pallet/src/tests.rs b/crates/rrsc/pallet/src/tests.rs index 647eb380..6cadba2d 100644 --- a/crates/rrsc/pallet/src/tests.rs +++ b/crates/rrsc/pallet/src/tests.rs @@ -63,7 +63,8 @@ fn first_block_epoch_zero_start() { ext.execute_with(|| { let genesis_slot = Slot::from(100); - let (vrf_signature, vrf_randomness) = make_vrf_output(genesis_slot, &pairs[0]); + let (vrf_signature, vrf_randomness) = + make_vrf_signature_and_randomness(genesis_slot, &pairs[0]); let pre_digest = make_primary_pre_digest(0, genesis_slot, vrf_signature); @@ -111,7 +112,8 @@ fn current_slot_is_processed_on_initialization() { ext.execute_with(|| { let genesis_slot = Slot::from(10); - let (vrf_signature, vrf_randomness) = make_vrf_output(genesis_slot, &pairs[0]); + let (vrf_signature, vrf_randomness) = + make_vrf_signature_and_randomness(genesis_slot, &pairs[0]); let pre_digest = make_primary_pre_digest(0, genesis_slot, vrf_signature); System::reset_events(); @@ -140,7 +142,8 @@ where ext.execute_with(|| { let genesis_slot = Slot::from(10); - let (vrf_signature, vrf_randomness) = make_vrf_output(genesis_slot, &pairs[0]); + let (vrf_signature, vrf_randomness) = + make_vrf_signature_and_randomness(genesis_slot, &pairs[0]); let pre_digest = make_pre_digest(0, genesis_slot, vrf_signature); System::reset_events(); @@ -812,7 +815,7 @@ fn report_equivocation_has_valid_weight() { // the weight depends on the size of the validator set, // but there's a lower bound of 100 validators. assert!((1..=100) - .map(::WeightInfo::report_equivocation) + .map(|validators| ::WeightInfo::report_equivocation(validators, 1000)) .collect::>() .windows(2) .all(|w| w[0] == w[1])); @@ -820,7 +823,7 @@ fn report_equivocation_has_valid_weight() { // after 100 validators the weight should keep increasing // with every extra validator. assert!((100..=1000) - .map(::WeightInfo::report_equivocation) + .map(|validators| ::WeightInfo::report_equivocation(validators, 1000)) .collect::>() .windows(2) .all(|w| w[0].ref_time() < w[1].ref_time())); diff --git a/crates/rrsc/primitives/Cargo.toml b/crates/rrsc/primitives/Cargo.toml index 57541485..d4707c69 100644 --- a/crates/rrsc/primitives/Cargo.toml +++ b/crates/rrsc/primitives/Cargo.toml @@ -14,35 +14,41 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] async-trait = { workspace = true, optional = true } -codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false } +codec = { package = "parity-scale-codec", version = "3.6.1", default-features = false } scale-info = { workspace = true, features = ["derive"] } -serde = { workspace = true, features = ["derive"], optional = true } +serde = { workspace = true, features = ["derive", "alloc"], optional = true } sp-api = { workspace = true } sp-application-crypto = { workspace = true } -sp-consensus = { workspace = true, optional = true } sp-consensus-slots = { workspace = true } sp-core = { workspace = true } sp-inherents = { workspace = true } -sp-keystore = { workspace = true, optional = true } sp-runtime = { workspace = true } sp-std = { workspace = true } sp-timestamp = { workspace = true, optional = true } [features] -default = ["std"] +default = [ "std" ] std = [ "async-trait", "codec/std", "scale-info/std", - "serde", + "serde/std", "sp-api/std", "sp-application-crypto/std", - "sp-consensus", "sp-consensus-slots/std", "sp-core/std", "sp-inherents/std", - "sp-keystore", "sp-runtime/std", "sp-std/std", - "sp-timestamp", + "sp-timestamp/std", +] + +# Serde support without relying on std features. +serde = [ + "dep:serde", + "scale-info/serde", + "sp-application-crypto/serde", + "sp-consensus-slots/serde", + "sp-core/serde", + "sp-runtime/serde", ] diff --git a/crates/rrsc/primitives/src/lib.rs b/crates/rrsc/primitives/src/lib.rs index c083c412..5ef8013b 100644 --- a/crates/rrsc/primitives/src/lib.rs +++ b/crates/rrsc/primitives/src/lib.rs @@ -26,14 +26,16 @@ pub mod traits; use codec::{Decode, Encode, MaxEncodedLen}; use scale_info::TypeInfo; -#[cfg(feature = "std")] +#[cfg(feature = "serde")] use serde::{Deserialize, Serialize}; use sp_runtime::{traits::Header, ConsensusEngineId, RuntimeDebug}; use sp_std::vec::Vec; use sp_core::crypto::KeyTypeId; use crate::digests::{NextConfigDescriptor, NextEpochDescriptor}; -pub use sp_core::sr25519::vrf::{VrfOutput, VrfProof, VrfSignature, VrfTranscript}; +pub use sp_core::sr25519::vrf::{ + VrfInput, VrfOutput, VrfProof, VrfSignData, VrfSignature, VrfTranscript, +}; /// Key type for RRSC module. pub const KEY_TYPE: KeyTypeId = KeyTypeId(*b"rrsc"); @@ -95,9 +97,9 @@ pub type RRSCAuthorityWeight = u64; /// of 0 (regardless of whether they are plain or vrf secondary blocks). pub type RRSCBlockWeight = u32; -/// Make a VRF transcript data container -pub fn make_transcript(randomness: &Randomness, slot: Slot, epoch: u64) -> VrfTranscript { - VrfTranscript::new( +/// Make VRF input suitable for BABE's randomness generation. +pub fn make_vrf_transcript(randomness: &Randomness, slot: Slot, epoch: u64) -> VrfInput { + VrfInput::new( &RRSC_ENGINE_ID, &[ (b"slot number", &slot.to_le_bytes()), @@ -107,6 +109,11 @@ pub fn make_transcript(randomness: &Randomness, slot: Slot, epoch: u64) -> VrfTr ) } +/// Make VRF signing data suitable for BABE's protocol. +pub fn make_vrf_sign_data(randomness: &Randomness, slot: Slot, epoch: u64) -> VrfSignData { + make_vrf_transcript(randomness, slot, epoch).into() +} + /// An consensus log item for RRSC. #[derive(Decode, Encode, Clone, PartialEq, Eq)] pub enum ConsensusLog { @@ -211,7 +218,7 @@ impl RRSCConfiguration { /// Types of allowed slots. #[derive(Clone, Copy, PartialEq, Eq, Encode, Decode, RuntimeDebug, MaxEncodedLen, TypeInfo)] -#[cfg_attr(feature = "std", derive(Serialize, Deserialize))] +#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] pub enum AllowedSlots { /// Only allow primary slots. PrimarySlots, @@ -235,7 +242,7 @@ impl AllowedSlots { /// Configuration data used by the RRSC consensus engine that may change with epochs. #[derive(Clone, PartialEq, Eq, Encode, Decode, RuntimeDebug, MaxEncodedLen, TypeInfo)] -#[cfg_attr(feature = "std", derive(Serialize, Deserialize))] +#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] pub struct RRSCEpochConfiguration { /// A constant value that is used in the threshold calculation formula. /// Expressed as a rational where the first member of the tuple is the diff --git a/crates/rrsc/rpc/Cargo.toml b/crates/rrsc/rpc/Cargo.toml index 4170711b..689dbe49 100644 --- a/crates/rrsc/rpc/Cargo.toml +++ b/crates/rrsc/rpc/Cargo.toml @@ -34,5 +34,6 @@ serde_json = { workspace = true } tokio = { workspace = true } sc-consensus = { workspace = true } sc-keystore = { workspace = true } +sc-transaction-pool-api = { workspace = true } sp-keyring = { workspace = true } substrate-test-runtime-client = { workspace = true } diff --git a/crates/rrsc/rpc/src/lib.rs b/crates/rrsc/rpc/src/lib.rs index ba733d96..edaa41f7 100644 --- a/crates/rrsc/rpc/src/lib.rs +++ b/crates/rrsc/rpc/src/lib.rs @@ -186,8 +186,10 @@ impl From for JsonRpseeError { #[cfg(test)] mod tests { use super::*; - use cessp_consensus_rrsc::inherents::InherentDataProvider; - use sp_core::{crypto::key_types::RRSC, testing::TaskExecutor}; + use cessc_consensus_rrsc::ImportQueueParams; + use sc_transaction_pool_api::{OffchainTransactionPoolFactory, RejectAllTxPool}; + use cessp_consensus_rrsc::{inherents::InherentDataProvider, KEY_TYPE as RRSC}; + use sp_core::{testing::TaskExecutor}; use sp_keyring::Sr25519Keyring; use sp_keystore::{testing::MemoryKeystore, Keystore}; use substrate_test_runtime_client::{ @@ -219,22 +221,25 @@ mod tests { sc_consensus_rrsc::block_import(config.clone(), client.clone(), client.clone()) .expect("can initialize block-import"); - let (_, rrsc_worker_handle) = sc_consensus_rrsc::import_queue( - link.clone(), - block_import.clone(), - None, - client.clone(), - longest_chain.clone(), - move |_, _| async move { + let (_, rrsc_worker_handle) = cessc_consensus_rrsc::import_queue(ImportQueueParams { + link: link.clone(), + block_import: block_import.clone(), + justification_import: None, + client: client.clone(), + select_chain: longest_chain.clone(), + create_inherent_data_providers: move |_, _| async move { Ok((InherentDataProvider::from_timestamp_and_slot_duration( 0.into(), slot_duration, ),)) }, - &task_executor, - None, - None, - ) + spawner: &task_executor, + registry: None, + telemetry: None, + offchain_tx_pool_factory: OffchainTransactionPoolFactory::new( + RejectAllTxPool::default(), + ), + }) .unwrap(); RRSC::new(client.clone(), rrsc_worker_handle, keystore, longest_chain, deny_unsafe) diff --git a/crates/rrsc/src/authorship.rs b/crates/rrsc/src/authorship.rs index 7fefa1a7..3f82eb6f 100644 --- a/crates/rrsc/src/authorship.rs +++ b/crates/rrsc/src/authorship.rs @@ -24,7 +24,7 @@ use sc_consensus_epochs::Epoch as EpochT; use sp_application_crypto::AppCrypto; use cessp_consensus_rrsc::{ digests::{PreDigest, PrimaryPreDigest, SecondaryPlainPreDigest, SecondaryVRFPreDigest}, - make_transcript, AuthorityId, RRSCAuthorityWeight, Randomness, Slot, + make_vrf_sign_data, AuthorityId, RRSCAuthorityWeight, Randomness, Slot, }; use sp_core::{ blake2_256, @@ -148,9 +148,9 @@ fn claim_secondary_slot( for (authority_id, authority_index) in keys { if authority_id == expected_author { let pre_digest = if author_secondary_vrf { - let transcript = make_transcript(randomness, slot, epoch_index); + let data = make_vrf_sign_data(randomness, slot, epoch_index); let result = - keystore.sr25519_vrf_sign(AuthorityId::ID, authority_id.as_ref(), &transcript); + keystore.sr25519_vrf_sign(AuthorityId::ID, authority_id.as_ref(), &data); if let Ok(Some(vrf_signature)) = result { Some(PreDigest::SecondaryVRF(SecondaryVRFPreDigest { slot, @@ -239,18 +239,18 @@ fn claim_primary_slot( epoch_index = epoch.clone_for_slot(slot).epoch_index; } - let transcript = make_transcript(randomness, slot, epoch_index); + let data = make_vrf_sign_data(randomness, slot, epoch_index); for (authority_id, authority_index) in keys { - let result = keystore.sr25519_vrf_sign(AuthorityId::ID, authority_id.as_ref(), &transcript); + let result = keystore.sr25519_vrf_sign(AuthorityId::ID, authority_id.as_ref(), &data); if let Ok(Some(vrf_signature)) = result { let threshold = calculate_primary_threshold(c, authorities, *authority_index); let can_claim = authority_id .as_inner_ref() - .make_bytes::<[u8; AUTHORING_SCORE_LENGTH]>( + .make_bytes::( AUTHORING_SCORE_VRF_CONTEXT, - &transcript, + &data.as_ref(), &vrf_signature.output, ) .map(|bytes| u128::from_le_bytes(bytes) < threshold) diff --git a/crates/rrsc/src/lib.rs b/crates/rrsc/src/lib.rs index 737c1062..842d65b0 100644 --- a/crates/rrsc/src/lib.rs +++ b/crates/rrsc/src/lib.rs @@ -106,6 +106,7 @@ use sc_consensus_slots::{ SlotInfo, StorageChanges, }; use sc_telemetry::{telemetry, TelemetryHandle, CONSENSUS_DEBUG, CONSENSUS_TRACE}; +use sc_transaction_pool_api::OffchainTransactionPoolFactory; use sp_api::{ApiExt, ProvideRuntimeApi}; use sp_application_crypto::AppCrypto; use sp_block_builder::BlockBuilder as BlockBuilderApi; @@ -116,7 +117,7 @@ use sp_blockchain::{ use sp_consensus::{BlockOrigin, Environment, Error as ConsensusError, Proposer, SelectChain}; use cessp_consensus_rrsc::inherents::RRSCInherentData; use sp_consensus_slots::Slot; -use sp_core::ExecutionContext; +use sp_core::traits::SpawnEssentialNamed; use sp_inherents::{CreateInherentDataProviders, InherentData, InherentDataProvider}; use sp_keystore::KeystorePtr; use sp_runtime::{ @@ -491,11 +492,8 @@ where C::Api: RRSCApi, SC: SelectChain + 'static, E: Environment + Send + Sync + 'static, - E::Proposer: Proposer>, - I: BlockImport> - + Send - + Sync - + 'static, + E::Proposer: Proposer, + I: BlockImport + Send + Sync + 'static, SO: SyncOracle + Send + Sync + Clone + 'static, L: sc_consensus::JustificationSyncLink + 'static, CIDP: CreateInherentDataProviders + Send + Sync + 'static, @@ -725,12 +723,12 @@ where B: BlockT, C: ProvideRuntimeApi + HeaderBackend + HeaderMetadata, C::Api: RRSCApi, - E: Environment + Sync, - E::Proposer: Proposer>, - I: BlockImport> + Send + Sync + 'static, + E: Environment + Send + Sync, + E::Proposer: Proposer, + I: BlockImport + Send + Sync + 'static, SO: SyncOracle + Send + Clone + Sync, L: sc_consensus::JustificationSyncLink, - BS: BackoffAuthoringBlocksStrategy> + Sync, + BS: BackoffAuthoringBlocksStrategy> + Send + Sync, Error: std::error::Error + Send + From + From + 'static, { type Claim = (PreDigest, AuthorityId); @@ -771,7 +769,7 @@ where } async fn claim_slot( - &self, + &mut self, _parent_header: &B::Header, slot: Slot, epoch_descriptor: &ViableEpochDescriptor, Epoch>, @@ -821,13 +819,10 @@ where header: B::Header, header_hash: &B::Hash, body: Vec, - storage_changes: StorageChanges<>::Transaction, B>, + storage_changes: StorageChanges, (_, public): Self::Claim, epoch_descriptor: Self::AuxData, - ) -> Result< - BlockImportParams>::Transaction>, - ConsensusError, - > { + ) -> Result, ConsensusError> { let signature = self .keystore .sr25519_sign(::ID, public.as_ref(), header_hash.as_ref()) @@ -992,6 +987,7 @@ pub struct RRSCVerifier { config: RRSCConfiguration, epoch_changes: SharedEpochChanges, telemetry: Option, + offchain_tx_pool_factory: OffchainTransactionPoolFactory, } impl RRSCVerifier @@ -1008,12 +1004,11 @@ where at_hash: Block::Hash, inherent_data: InherentData, create_inherent_data_providers: CIDP::InherentDataProviders, - execution_context: ExecutionContext, ) -> Result<(), Error> { let inherent_res = self .client .runtime_api() - .check_inherents_with_context(at_hash, execution_context, block, inherent_data) + .check_inherents(at_hash, block, inherent_data) .map_err(Error::RuntimeApi)?; if !inherent_res.ok() { @@ -1098,8 +1093,13 @@ where }; // submit equivocation report at best block. - self.client - .runtime_api() + let mut runtime_api = self.client.runtime_api(); + + // Register the offchain tx pool to be able to use it from the runtime. + runtime_api + .register_extension(self.offchain_tx_pool_factory.offchain_transaction_pool(best_hash)); + + runtime_api .submit_report_equivocation_unsigned_extrinsic( best_hash, equivocation_proof, @@ -1131,8 +1131,8 @@ where { async fn verify( &mut self, - mut block: BlockImportParams, - ) -> Result, String> { + mut block: BlockImportParams, + ) -> Result, String> { trace!( target: LOG_TARGET, "Verifying origin: {:?} header: {:?} justification(s): {:?} body: {:?}", @@ -1152,10 +1152,10 @@ where // Verification for imported blocks is skipped in two cases: // 1. When importing blocks below the last finalized block during network initial // synchronization. - // 2. When importing whole state we don't calculate epoch descriptor, but rather - // read it from the state after import. We also skip all verifications - // because there's no parent state and we trust the sync module to verify - // that the state is correct and finalized. + // 2. When importing whole state we don't calculate epoch descriptor, but rather read it + // from the state after import. We also skip all verifications because there's no + // parent state and we trust the sync module to verify that the state is correct and + // finalized. return Ok(block) } @@ -1250,7 +1250,6 @@ where parent_hash, inherent_data, create_inherent_data_providers, - block.origin.into(), ) .await?; } @@ -1331,7 +1330,7 @@ impl RRSCBlockImport { impl RRSCBlockImport where Block: BlockT, - Inner: BlockImport> + Send + Sync, + Inner: BlockImport + Send + Sync, Inner::Error: Into, Client: HeaderBackend + HeaderMetadata @@ -1346,7 +1345,7 @@ where // end up in an inconsistent state and have to resync. async fn import_state( &mut self, - mut block: BlockImportParams>, + mut block: BlockImportParams, ) -> Result { let hash = block.post_hash(); let parent_hash = *block.header.parent_hash(); @@ -1395,7 +1394,7 @@ where impl BlockImport for RRSCBlockImport where Block: BlockT, - Inner: BlockImport> + Send + Sync, + Inner: BlockImport + Send + Sync, Inner::Error: Into, Client: HeaderBackend + HeaderMetadata @@ -1406,11 +1405,10 @@ where Client::Api: RRSCApi + ApiExt, { type Error = ConsensusError; - type Transaction = sp_api::TransactionFor; async fn import_block( &mut self, - mut block: BlockImportParams, + mut block: BlockImportParams, ) -> Result { let hash = block.post_hash(); let number = *block.header.number(); @@ -1768,6 +1766,38 @@ where Ok((import, link)) } +/// Parameters passed to [`import_queue`]. +pub struct ImportQueueParams<'a, Block: BlockT, BI, Client, CIDP, SelectChain, Spawn> { + /// The RRSC link that is created by [`block_import`]. + pub link: RRSCLink, + /// The block import that should be wrapped. + pub block_import: BI, + /// Optional justification import. + pub justification_import: Option>, + /// The client to interact with the internals of the node. + pub client: Arc, + /// A [`SelectChain`] implementation. + /// + /// Used to determine the best block that should be used as basis when sending an equivocation + /// report. + pub select_chain: SelectChain, + /// Used to crate the inherent data providers. + /// + /// These inherent data providers are then used to create the inherent data that is + /// passed to the `check_inherents` runtime call. + pub create_inherent_data_providers: CIDP, + /// Spawner for spawning futures. + pub spawner: &'a Spawn, + /// Registry for prometheus metrics. + pub registry: Option<&'a Registry>, + /// Optional telemetry handle to report telemetry events. + pub telemetry: Option, + /// The offchain transaction pool factory. + /// + /// Will be used when sending equivocation reports. + pub offchain_tx_pool_factory: OffchainTransactionPoolFactory, +} + /// Start an import queue for the RRSC consensus algorithm. /// /// This method returns the import queue, some data that needs to be passed to the block authoring @@ -1777,25 +1807,22 @@ where /// /// The block import object provided must be the `RRSCBlockImport` or a wrapper /// of it, otherwise crucial import logic will be omitted. -pub fn import_queue( - rrsc_link: RRSCLink, - block_import: Inner, - justification_import: Option>, - client: Arc, - select_chain: SelectChain, - create_inherent_data_providers: CIDP, - spawner: &impl sp_core::traits::SpawnEssentialNamed, - registry: Option<&Registry>, - telemetry: Option, -) -> ClientResult<(DefaultImportQueue, RRSCWorkerHandle)> +pub fn import_queue( + ImportQueueParams { + link: rrsc_link, + block_import, + justification_import, + client, + select_chain, + create_inherent_data_providers, + spawner, + registry, + telemetry, + offchain_tx_pool_factory, + }: ImportQueueParams<'_, Block, BI, Client, CIDP, SelectChain, Spawn>, +) -> ClientResult<(DefaultImportQueue, RRSCWorkerHandle)> where - Inner: BlockImport< - Block, - Error = ConsensusError, - Transaction = sp_api::TransactionFor, - > + Send - + Sync - + 'static, + BI: BlockImport + Send + Sync + 'static, Client: ProvideRuntimeApi + HeaderBackend + HeaderMetadata @@ -1807,6 +1834,7 @@ where SelectChain: sp_consensus::SelectChain + 'static, CIDP: CreateInherentDataProviders + Send + Sync + 'static, CIDP::InherentDataProviders: InherentDataProviderExt + Send + Sync, + Spawn: SpawnEssentialNamed, { const HANDLE_BUFFER_SIZE: usize = 1024; @@ -1817,6 +1845,7 @@ where epoch_changes: rrsc_link.epoch_changes.clone(), telemetry, client: client.clone(), + offchain_tx_pool_factory, }; let (worker_tx, worker_rx) = channel(HANDLE_BUFFER_SIZE); diff --git a/crates/rrsc/src/tests.rs b/crates/rrsc/src/tests.rs index 4a739037..1075382a 100644 --- a/crates/rrsc/src/tests.rs +++ b/crates/rrsc/src/tests.rs @@ -21,15 +21,16 @@ use super::*; use authorship::claim_slot; use sc_block_builder::{BlockBuilder, BlockBuilderProvider}; -use sc_client_api::{backend::TransactionFor, BlockchainEvents, Finalizer}; +use sc_client_api::{BlockchainEvents, Finalizer}; use sc_consensus::{BoxBlockImport, BoxJustificationImport}; use sc_consensus_epochs::{EpochIdentifier, EpochIdentifierPosition}; use sc_consensus_slots::BackoffAuthoringOnFinalizedHeadLagging; use sc_network_test::{Block as TestBlock, *}; -use sp_application_crypto::key_types::RRSC; +use sc_transaction_pool_api::RejectAllTxPool; +use cessp_consensus_rrsc::KEY_TYPE as RRSC; use sp_consensus::{DisableProofRecording, NoNetwork as DummyOracle, Proposal}; use cessp_consensus_rrsc::{ - inherents::InherentDataProvider, make_transcript, AllowedSlots, AuthorityId, AuthorityPair, + inherents::InherentDataProvider, make_vrf_sign_data, AllowedSlots, AuthorityId, AuthorityPair, Slot, }; use sp_consensus_slots::SlotDuration; @@ -71,15 +72,12 @@ const SLOT_DURATION_MS: u64 = 1000; struct DummyFactory { client: Arc, epoch_changes: SharedEpochChanges, - config: RRSCConfiguration, mutator: Mutator, } struct DummyProposer { factory: DummyFactory, parent_hash: Hash, - parent_number: u64, - parent_slot: Slot, } impl Environment for DummyFactory { @@ -88,15 +86,9 @@ impl Environment for DummyFactory { type Error = Error; fn init(&mut self, parent_header: &::Header) -> Self::CreateProposer { - let parent_slot = crate::find_pre_digest::(parent_header) - .expect("parent header has a pre-digest") - .slot(); - future::ready(Ok(DummyProposer { factory: self.clone(), parent_hash: parent_header.hash(), - parent_number: *parent_header.number(), - parent_slot, })) } } @@ -105,16 +97,7 @@ impl DummyProposer { fn propose_with( &mut self, pre_digests: Digest, - ) -> future::Ready< - Result< - Proposal< - TestBlock, - sc_client_api::TransactionFor, - (), - >, - Error, - >, - > { + ) -> future::Ready, Error>> { let block_builder = self.factory.client.new_block_at(self.parent_hash, pre_digests, false).unwrap(); @@ -123,39 +106,6 @@ impl DummyProposer { Err(e) => return future::ready(Err(e)), }; - let this_slot = crate::find_pre_digest::(block.header()) - .expect("baked block has valid pre-digest") - .slot(); - - // figure out if we should add a consensus digest, since the test runtime - // doesn't. - let epoch_changes = self.factory.epoch_changes.shared_data(); - let epoch = epoch_changes - .epoch_data_for_child_of( - descendent_query(&*self.factory.client), - &self.parent_hash, - self.parent_number, - this_slot, - |slot| Epoch::genesis(&self.factory.config, slot), - ) - .expect("client has data to find epoch") - .expect("can compute epoch for baked block"); - - let first_in_epoch = self.parent_slot < epoch.start_slot; - if first_in_epoch { - // push a `Consensus` digest signalling next change. - // we just reuse the same randomness and authorities as the prior - // epoch. this will break when we add light client support, since - // that will re-check the randomness logic off-chain. - let digest_data = ConsensusLog::NextEpochData(NextEpochDescriptor { - authorities: epoch.authorities.clone(), - randomness: epoch.randomness, - }) - .encode(); - let digest = DigestItem::Consensus(RRSC_ENGINE_ID, digest_data); - block.header.digest_mut().push(digest) - } - // mutate the block header according to the mutator. (self.factory.mutator)(&mut block.header, Stage::PreSeal); @@ -165,9 +115,7 @@ impl DummyProposer { impl Proposer for DummyProposer { type Error = Error; - type Transaction = - sc_client_api::TransactionFor; - type Proposal = future::Ready, Error>>; + type Proposal = future::Ready, Error>>; type ProofRecording = DisableProofRecording; type Proof = (); @@ -192,15 +140,13 @@ pub struct PanickingBlockImport(B); #[async_trait::async_trait] impl> BlockImport for PanickingBlockImport where - B::Transaction: Send, B: Send, { type Error = B::Error; - type Transaction = B::Transaction; async fn import_block( &mut self, - block: BlockImportParams, + block: BlockImportParams, ) -> Result { Ok(self.0.import_block(block).await.expect("importing block failed")) } @@ -248,8 +194,8 @@ impl Verifier for TestVerifier { /// presented to the User in the logs. async fn verify( &mut self, - mut block: BlockImportParams, - ) -> Result, String> { + mut block: BlockImportParams, + ) -> Result, String> { // apply post-sealing mutations (i.e. stripping seal, if desired). (self.mutator)(&mut block.header, Stage::PostSeal); self.inner.verify(block).await @@ -258,14 +204,7 @@ impl Verifier for TestVerifier { pub struct PeerData { link: RRSCLink, - block_import: Mutex< - Option< - BoxBlockImport< - TestBlock, - TransactionFor, - >, - >, - >, + block_import: Mutex>>, } impl TestNetFactory for RRSCTestNet { @@ -290,7 +229,7 @@ impl TestNetFactory for RRSCTestNet { let block_import = PanickingBlockImport(block_import); let data_block_import = - Mutex::new(Some(Box::new(block_import.clone()) as BoxBlockImport<_, _>)); + Mutex::new(Some(Box::new(block_import.clone()) as BoxBlockImport<_>)); ( BlockImportAdapter::new(block_import), None, @@ -325,6 +264,9 @@ impl TestNetFactory for RRSCTestNet { config: data.link.config.clone(), epoch_changes: data.link.epoch_changes.clone(), telemetry: None, + offchain_tx_pool_factory: OffchainTransactionPoolFactory::new( + RejectAllTxPool::default(), + ), }, mutator: MUTATOR.with(|m| m.borrow().clone()), } @@ -351,7 +293,7 @@ impl TestNetFactory for RRSCTestNet { } #[tokio::test] -#[should_panic] +#[should_panic(expected = "No BABE pre-runtime digest found")] async fn rejects_empty_block() { sp_tracing::try_init_simple(); let mut net = RRSCTestNet::new(3); @@ -398,7 +340,6 @@ async fn run_one_test(mutator: impl Fn(&mut TestHeader, Stage) + Send + Sync + ' let environ = DummyFactory { client: client.clone(), - config: data.link.config.clone(), epoch_changes: data.link.epoch_changes.clone(), mutator: mutator.clone(), }; @@ -483,7 +424,7 @@ async fn authoring_blocks() { } #[tokio::test] -#[should_panic] +#[should_panic(expected = "valid babe headers must contain a predigest")] async fn rejects_missing_inherent_digest() { run_one_test(|header: &mut TestHeader, stage| { let v = std::mem::take(&mut header.digest_mut().logs); @@ -496,7 +437,7 @@ async fn rejects_missing_inherent_digest() { } #[tokio::test] -#[should_panic] +#[should_panic(expected = "has a bad seal")] async fn rejects_missing_seals() { run_one_test(|header: &mut TestHeader, stage| { let v = std::mem::take(&mut header.digest_mut().logs); @@ -509,7 +450,7 @@ async fn rejects_missing_seals() { } #[tokio::test] -#[should_panic] +#[should_panic(expected = "Expected epoch change to happen")] async fn rejects_missing_consensus_digests() { run_one_test(|header: &mut TestHeader, stage| { let v = std::mem::take(&mut header.digest_mut().logs); @@ -630,11 +571,8 @@ fn claim_vrf_check() { PreDigest::Primary(d) => d, v => panic!("Unexpected pre-digest variant {:?}", v), }; - let transcript = make_transcript(&epoch.randomness.clone(), 0.into(), epoch.epoch_index); - let sign = keystore - .sr25519_vrf_sign(AuthorityId::ID, &public, &transcript) - .unwrap() - .unwrap(); + let data = make_vrf_sign_data(&epoch.randomness.clone(), 0.into(), epoch.epoch_index); + let sign = keystore.sr25519_vrf_sign(AuthorityId::ID, &public, &data).unwrap().unwrap(); assert_eq!(pre_digest.vrf_signature.output, sign.output); // We expect a SecondaryVRF claim for slot 1 @@ -642,11 +580,8 @@ fn claim_vrf_check() { PreDigest::SecondaryVRF(d) => d, v => panic!("Unexpected pre-digest variant {:?}", v), }; - let transcript = make_transcript(&epoch.randomness.clone(), 1.into(), epoch.epoch_index); - let sign = keystore - .sr25519_vrf_sign(AuthorityId::ID, &public, &transcript) - .unwrap() - .unwrap(); + let data = make_vrf_sign_data(&epoch.randomness.clone(), 1.into(), epoch.epoch_index); + let sign = keystore.sr25519_vrf_sign(AuthorityId::ID, &public, &data).unwrap().unwrap(); assert_eq!(pre_digest.vrf_signature.output, sign.output); // Check that correct epoch index has been used if epochs are skipped (primary VRF) @@ -656,11 +591,8 @@ fn claim_vrf_check() { v => panic!("Unexpected claim variant {:?}", v), }; let fixed_epoch = epoch.clone_for_slot(slot); - let transcript = make_transcript(&epoch.randomness.clone(), slot, fixed_epoch.epoch_index); - let sign = keystore - .sr25519_vrf_sign(AuthorityId::ID, &public, &transcript) - .unwrap() - .unwrap(); + let data = make_vrf_sign_data(&epoch.randomness.clone(), slot, fixed_epoch.epoch_index); + let sign = keystore.sr25519_vrf_sign(AuthorityId::ID, &public, &data).unwrap().unwrap(); assert_eq!(fixed_epoch.epoch_index, 11); assert_eq!(claim.vrf_signature.output, sign.output); @@ -671,21 +603,18 @@ fn claim_vrf_check() { v => panic!("Unexpected claim variant {:?}", v), }; let fixed_epoch = epoch.clone_for_slot(slot); - let transcript = make_transcript(&epoch.randomness.clone(), slot, fixed_epoch.epoch_index); - let sign = keystore - .sr25519_vrf_sign(AuthorityId::ID, &public, &transcript) - .unwrap() - .unwrap(); + let data = make_vrf_sign_data(&epoch.randomness.clone(), slot, fixed_epoch.epoch_index); + let sign = keystore.sr25519_vrf_sign(AuthorityId::ID, &public, &data).unwrap().unwrap(); assert_eq!(fixed_epoch.epoch_index, 11); assert_eq!(pre_digest.vrf_signature.output, sign.output); } -// Propose and import a new RRSC block on top of the given parent. -async fn propose_and_import_block( +// Propose and import a new BABE block on top of the given parent. +async fn propose_and_import_block( parent: &TestHeader, slot: Option, proposer_factory: &mut DummyFactory, - block_import: &mut BoxBlockImport, + block_import: &mut BoxBlockImport, ) -> Hash { let mut proposer = proposer_factory.init(parent).await.unwrap(); @@ -752,10 +681,10 @@ async fn propose_and_import_block( // Propose and import n valid RRSC blocks that are built on top of the given parent. // The proposer takes care of producing epoch change digests according to the epoch // duration (which is set to 6 slots in the test runtime). -async fn propose_and_import_blocks( +async fn propose_and_import_blocks( client: &PeersFullClient, proposer_factory: &mut DummyFactory, - block_import: &mut BoxBlockImport, + block_import: &mut BoxBlockImport, parent_hash: Hash, n: usize, ) -> Vec { @@ -782,7 +711,6 @@ async fn importing_block_one_sets_genesis_epoch() { let mut proposer_factory = DummyFactory { client: client.clone(), - config: data.link.config.clone(), epoch_changes: data.link.epoch_changes.clone(), mutator: Arc::new(|_, _| ()), }; @@ -826,7 +754,6 @@ async fn revert_prunes_epoch_changes_and_removes_weights() { let mut proposer_factory = DummyFactory { client: client.clone(), - config: data.link.config.clone(), epoch_changes: data.link.epoch_changes.clone(), mutator: Arc::new(|_, _| ()), }; @@ -914,7 +841,6 @@ async fn revert_not_allowed_for_finalized() { let mut proposer_factory = DummyFactory { client: client.clone(), - config: data.link.config.clone(), epoch_changes: data.link.epoch_changes.clone(), mutator: Arc::new(|_, _| ()), }; @@ -955,7 +881,6 @@ async fn importing_epoch_change_block_prunes_tree() { let mut proposer_factory = DummyFactory { client: client.clone(), - config: data.link.config.clone(), epoch_changes: data.link.epoch_changes.clone(), mutator: Arc::new(|_, _| ()), }; @@ -1042,7 +967,7 @@ async fn importing_epoch_change_block_prunes_tree() { } #[tokio::test] -#[should_panic] +#[should_panic(expected = "Slot number must increase: parent slot: 999, this slot: 999")] async fn verify_slots_are_strictly_increasing() { let mut net = RRSCTestNet::new(1); @@ -1054,7 +979,6 @@ async fn verify_slots_are_strictly_increasing() { let mut proposer_factory = DummyFactory { client: client.clone(), - config: data.link.config.clone(), epoch_changes: data.link.epoch_changes.clone(), mutator: Arc::new(|_, _| ()), }; @@ -1082,7 +1006,7 @@ async fn obsolete_blocks_aux_data_cleanup() { let mut net = RRSCTestNet::new(1); let peer = net.peer(0); - let data = peer.data.as_ref().expect("rrsc link set up during initialization"); + let data = peer.data.as_ref().expect("babe link set up during initialization"); let client = peer.client().as_client(); // Register the handler (as done by `rrsc_start`) @@ -1094,7 +1018,6 @@ async fn obsolete_blocks_aux_data_cleanup() { let mut proposer_factory = DummyFactory { client: client.clone(), - config: data.link.config.clone(), epoch_changes: data.link.epoch_changes.clone(), mutator: Arc::new(|_, _| ()), }; @@ -1180,7 +1103,6 @@ async fn allows_skipping_epochs() { let mut proposer_factory = DummyFactory { client: client.clone(), - config: data.link.config.clone(), epoch_changes: data.link.epoch_changes.clone(), mutator: Arc::new(|_, _| ()), }; @@ -1310,7 +1232,6 @@ async fn allows_skipping_epochs_on_some_forks() { let mut proposer_factory = DummyFactory { client: client.clone(), - config: data.link.config.clone(), epoch_changes: data.link.epoch_changes.clone(), mutator: Arc::new(|_, _| ()), }; diff --git a/crates/rrsc/src/verification.rs b/crates/rrsc/src/verification.rs index b5462e0d..32df5d2f 100644 --- a/crates/rrsc/src/verification.rs +++ b/crates/rrsc/src/verification.rs @@ -30,11 +30,11 @@ use cessp_consensus_rrsc::{ CompatibleDigestItem, PreDigest, PrimaryPreDigest, SecondaryPlainPreDigest, SecondaryVRFPreDigest, }, - make_transcript, AuthorityId, AuthorityPair, AuthoritySignature, + make_vrf_sign_data, AuthorityId, AuthorityPair, AuthoritySignature, }; use sp_consensus_slots::Slot; use sp_core::{ - crypto::{VrfVerifier, Wraps}, + crypto::{VrfPublic, Wraps}, Pair, }; use sp_runtime::{traits::Header, DigestItem}; @@ -171,9 +171,9 @@ fn check_primary_header( return Err(rrsc_err(Error::BadSignature(pre_hash))) } - let transcript = make_transcript(&epoch.randomness, pre_digest.slot, epoch_index); + let data = make_vrf_sign_data(&epoch.randomness, pre_digest.slot, epoch_index); - if !authority_id.as_inner_ref().vrf_verify(&transcript, &pre_digest.vrf_signature) { + if !authority_id.as_inner_ref().vrf_verify(&data, &pre_digest.vrf_signature) { return Err(rrsc_err(Error::VrfVerificationFailed)) } @@ -182,9 +182,9 @@ fn check_primary_header( let score = authority_id .as_inner_ref() - .make_bytes::<[u8; AUTHORING_SCORE_LENGTH]>( + .make_bytes::( AUTHORING_SCORE_VRF_CONTEXT, - &transcript, + &data.as_ref(), &pre_digest.vrf_signature.output, ) .map(u128::from_le_bytes) @@ -253,9 +253,9 @@ fn check_secondary_vrf_header( return Err(Error::BadSignature(pre_hash)) } - let transcript = make_transcript(&epoch.randomness, pre_digest.slot, epoch_index); + let data = make_vrf_sign_data(&epoch.randomness, pre_digest.slot, epoch_index); - if !author.as_inner_ref().vrf_verify(&transcript, &pre_digest.vrf_signature) { + if !author.as_inner_ref().vrf_verify(&data, &pre_digest.vrf_signature) { return Err(Error::VrfVerificationFailed) } diff --git a/crates/rrsc/sync-state/Cargo.toml b/crates/rrsc/sync-state/Cargo.toml index 9eef36b0..735fa0e8 100644 --- a/crates/rrsc/sync-state/Cargo.toml +++ b/crates/rrsc/sync-state/Cargo.toml @@ -12,7 +12,7 @@ repository = "https://github.com/paritytech/substrate/" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -codec = { package = "parity-scale-codec", version = "3.2.2" } +codec = { package = "parity-scale-codec", version = "3.6.1" } jsonrpsee = { workspace = true, features = ["client-core", "server", "macros"] } serde = { workspace = true, features = ["derive"] } serde_json = { workspace = true } diff --git a/crates/scheduler-credit/Cargo.toml b/crates/scheduler-credit/Cargo.toml index 330a7ef6..f584a487 100644 --- a/crates/scheduler-credit/Cargo.toml +++ b/crates/scheduler-credit/Cargo.toml @@ -6,20 +6,10 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -codec = { version = "3.2.2", package = "parity-scale-codec", default-features = false } -scale-info = { workspace = true, features = ["derive"] } -sp-api = { workspace = true } -sp-core = { workspace = true } -sp-std = { workspace = true } frame-support = { workspace = true } [features] default = ["std"] std = [ - "codec/std", - "scale-info/std", - "sp-api/std", - "sp-core/std", - "sp-std/std", "frame-support/std", ] diff --git a/pallets/audit/Cargo.toml b/pallets/audit/Cargo.toml index 575c3283..b675e98b 100644 --- a/pallets/audit/Cargo.toml +++ b/pallets/audit/Cargo.toml @@ -12,7 +12,7 @@ readme = "README.md" [dependencies] # serde = { workspace = true, optional = true } -codec = { version = "3.2.2", package = "parity-scale-codec", default-features = false, features = ["derive", "max-encoded-len"] } +codec = { package = "parity-scale-codec", version = "3.6.1", default-features = false, features = ["derive", "max-encoded-len"] } scale-info = { workspace = true, features = ["derive"] } log = { workspace = true } pallet-cess-staking = { workspace = true } diff --git a/pallets/audit/src/lib.rs b/pallets/audit/src/lib.rs index d2a7e63b..efbe545e 100644 --- a/pallets/audit/src/lib.rs +++ b/pallets/audit/src/lib.rs @@ -89,7 +89,6 @@ use sp_std::{ pub use weights::WeightInfo; type AccountOf = ::AccountId; -type BlockNumberOf = ::BlockNumber; pub const AUDIT: KeyTypeId = KeyTypeId(*b"cess"); // type FailureRate = u32; @@ -171,12 +170,12 @@ pub mod pallet { type IdleTotalHashLength: Get + Clone + Eq + PartialEq; // one day block #[pallet::constant] - type OneDay: Get>; + type OneDay: Get>; // one hours block #[pallet::constant] - type OneHours: Get>; + type OneHours: Get>; // randomness for seeds. - type MyRandomness: Randomness, Self::BlockNumber>; + type MyRandomness: Randomness, BlockNumberFor>; //Find the consensus of the current block type FindAuthor: FindAuthor; //Random files used to obtain this batch of challenges @@ -185,7 +184,7 @@ pub mod pallet { type TeeWorkerHandler: TeeWorkerHandler; //It is used to increase or decrease the miners' computing power, space, and execute // punishment - type MinerControl: MinerControl; + type MinerControl: MinerControl>; type StorageHandle: StorageHandle; //Configuration to be used for offchain worker @@ -198,7 +197,7 @@ pub mod pallet { //Verifier of this round type ValidatorSet: ValidatorSetWithIdentification; //Information for the next session - type NextSessionRotation: EstimateNextSessionRotation; + type NextSessionRotation: EstimateNextSessionRotation>; /// A configuration for base priority of unsigned transactions. /// /// This is exposed so that it can be tuned for particular runtime, when @@ -207,7 +206,7 @@ pub mod pallet { type UnsignedPriority: Get; #[pallet::constant] - type LockTime: Get>; + type LockTime: Get>; #[pallet::constant] type ReassignCeiling: Get + Clone + Eq + PartialEq; @@ -285,7 +284,7 @@ pub mod pallet { //Relevant time nodes for storage challenges #[pallet::storage] #[pallet::getter(fn verify_duration)] - pub(super) type VerifyDuration = StorageValue<_, BlockNumberOf, ValueQuery>; + pub(super) type VerifyDuration = StorageValue<_, BlockNumberFor, ValueQuery>; #[pallet::storage] #[pallet::getter(fn cur_authority_index)] @@ -334,7 +333,7 @@ pub mod pallet { pub(super) type ChallengeSlip = StorageDoubleMap< _, Blake2_128Concat, - BlockNumberOf, + BlockNumberFor, Blake2_128Concat, AccountOf, bool, @@ -345,7 +344,7 @@ pub mod pallet { pub(super) type VerifySlip = StorageDoubleMap< _, Blake2_128Concat, - BlockNumberOf, + BlockNumberFor, Blake2_128Concat, AccountOf, bool, @@ -356,8 +355,8 @@ pub mod pallet { pub struct Pallet(_); #[pallet::hooks] - impl Hooks> for Pallet { - fn on_initialize(now: BlockNumberOf) -> Weight { + impl Hooks> for Pallet { + fn on_initialize(now: BlockNumberFor) -> Weight { let weight: Weight = Weight::zero(); weight .saturating_add(Self::generate_challenge(now)) @@ -736,8 +735,8 @@ pub mod pallet { #[pallet::weight(Weight::zero())] pub fn test_update_clear_slip( origin: OriginFor, - old: BlockNumberOf, - new: BlockNumberOf, + old: BlockNumberFor, + new: BlockNumberFor, miner: AccountOf, ) -> DispatchResult { let _ = ensure_root(origin)?; @@ -753,8 +752,8 @@ pub mod pallet { #[pallet::weight(Weight::zero())] pub fn test_update_verify_slip( origin: OriginFor, - old: BlockNumberOf, - new: BlockNumberOf, + old: BlockNumberFor, + new: BlockNumberFor, miner: AccountOf, ) -> DispatchResult { let _ = ensure_root(origin)?; @@ -780,7 +779,7 @@ pub mod pallet { /// # Returns /// /// The total weight consumed by the operation. - fn clear_challenge(now: BlockNumberOf) -> Weight { + fn clear_challenge(now: BlockNumberFor) -> Weight { let mut weight: Weight = Weight::zero(); for (miner, _) in >::iter_prefix(&now) { @@ -833,7 +832,7 @@ pub mod pallet { /// /// Returns: /// - A `Weight` value representing the computational cost of the operation. - fn clear_verify_mission(now: BlockNumberOf) -> Weight { + fn clear_verify_mission(now: BlockNumberFor) -> Weight { let mut weight: Weight = Weight::zero(); for (miner, _) in >::iter_prefix(&now) { @@ -930,7 +929,7 @@ pub mod pallet { /// /// Returns: /// - A `Weight` value representing the computational cost of the operation. - fn generate_challenge(now: BlockNumberOf) -> Weight { + fn generate_challenge(now: BlockNumberFor) -> Weight { let mut weight: Weight = Weight::zero(); weight = weight.saturating_add(T::DbWeight::get().reads(1)); diff --git a/pallets/audit/src/types.rs b/pallets/audit/src/types.rs index 024f9361..f2cf7969 100644 --- a/pallets/audit/src/types.rs +++ b/pallets/audit/src/types.rs @@ -1,4 +1,5 @@ use super::*; +use frame_system::pallet_prelude::BlockNumberFor; #[derive(PartialEq, Eq, Encode, Decode, Clone, RuntimeDebug, MaxEncodedLen, TypeInfo)] #[scale_info(skip_type_params(T))] @@ -31,10 +32,10 @@ pub struct ProveInfoV2 { #[scale_info(skip_type_params(T))] #[codec(mel_bound())] pub struct ChallengeElement { - pub(super) start: BlockNumberOf, - pub(super) idle_slip: BlockNumberOf, - pub(super) service_slip: BlockNumberOf, - pub(super) verify_slip: BlockNumberOf, + pub(super) start: BlockNumberFor, + pub(super) idle_slip: BlockNumberFor, + pub(super) service_slip: BlockNumberFor, + pub(super) verify_slip: BlockNumberFor, pub(super) space_param: SpaceChallengeParam, pub(super) service_param: QElement, } diff --git a/pallets/cacher/Cargo.toml b/pallets/cacher/Cargo.toml index b6679547..9e9d9daf 100644 --- a/pallets/cacher/Cargo.toml +++ b/pallets/cacher/Cargo.toml @@ -5,7 +5,7 @@ edition = "2021" [dependencies] log = { workspace = true } -codec = { version = "3.2.2", package = "parity-scale-codec", default-features = false, features = ["derive", "max-encoded-len"] } +codec = { package = "parity-scale-codec", version = "3.6.1", default-features = false, features = ["derive", "max-encoded-len"] } scale-info = { workspace = true, features = ["derive"] } sp-std = { workspace = true } sp-runtime = { workspace = true } diff --git a/pallets/cess-treasury/Cargo.toml b/pallets/cess-treasury/Cargo.toml index 034b0e9e..1f5bdf7a 100644 --- a/pallets/cess-treasury/Cargo.toml +++ b/pallets/cess-treasury/Cargo.toml @@ -10,7 +10,7 @@ readme = "README.md" [dependencies] scale-info = { workspace = true, features = ["derive"] } -codec = { version = "3.2.2", package = "parity-scale-codec", default-features = false, features = ["derive"] } +codec = { package = "parity-scale-codec", version = "3.6.1", default-features = false, features = ["derive"] } #substrate pallet frame-support = { workspace = true } diff --git a/pallets/file-bank/Cargo.toml b/pallets/file-bank/Cargo.toml index dcd763f0..07239954 100755 --- a/pallets/file-bank/Cargo.toml +++ b/pallets/file-bank/Cargo.toml @@ -11,44 +11,35 @@ readme = "README.md" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -# parking_lot = "0.11" serde = { workspace = true, optional = true } -codec = { version = "3.2.2", package = "parity-scale-codec", default-features = false, features = ["derive"] } +codec = { package = "parity-scale-codec", version = "3.6.1", default-features = false, features = ["derive"] } scale-info = { workspace = true, features = ["derive"] } serde_json = { workspace = true, features = ['alloc'] } log = { workspace = true } rand_chacha = { workspace = true, optional = true } -pallet-rrsc = { workspace = true } -pallet-grandpa = { workspace = true } -pallet-cess-staking = { workspace = true } +sp-io = { workspace = true } +sp-std = { workspace = true } +sp-core = { workspace = true } +sp-runtime = { workspace = true } +pallet-balances = { workspace = true } +pallet-grandpa = { workspace = true, optional = true } +# pallet-scheduler = { workspace = true } +frame-benchmarking = { workspace = true, optional = true } +frame-support = { workspace = true } +frame-system = { workspace = true } + +# local dependencies cp-scheduler-credit = { workspace = true } cp-cess-common = { workspace = true } cp-enclave-verify = { workspace = true } +pallet-cess-staking = { workspace = true } pallet-oss = { workspace = true } - -# substrate pallet -pallet-scheduler = { workspace = true } -# sc-network = { workspace = true } - -# local dependencies +pallet-rrsc = { workspace = true, optional = true } pallet-sminer = { workspace = true } -pallet-tee-worker = { workspace = true } pallet-storage-handler = { workspace = true } +pallet-tee-worker = { workspace = true } -frame-benchmarking = { workspace = true, optional = true } -frame-support = { workspace = true } -frame-system = { workspace = true } - -sp-io = { workspace = true } - -sp-std = { workspace = true } - -pallet-balances = { workspace = true } - -sp-core = { workspace = true } - -sp-runtime = { workspace = true } # dev dependencies [dev-dependencies] @@ -75,8 +66,13 @@ std = [ "sp-runtime/std", "frame-support/std", "frame-system/std", - "pallet-balances/std", "frame-benchmarking/std", + "pallet-balances/std", + "pallet-cess-staking/std", + "pallet-sminer/std", + "pallet-oss/std", + "pallet-scheduler/std", + "pallet-storage-handler/std", "pallet-tee-worker/std", "cp-scheduler-credit/std", "cp-cess-common/std", diff --git a/pallets/file-bank/src/lib.rs b/pallets/file-bank/src/lib.rs index 397f1fa6..15886d20 100755 --- a/pallets/file-bank/src/lib.rs +++ b/pallets/file-bank/src/lib.rs @@ -53,7 +53,7 @@ use frame_support::{ // bounded_vec, transactional, PalletId, - dispatch::{Dispatchable, DispatchResult}, + dispatch::DispatchResult, pallet_prelude::*, weights::Weight, traits::schedule, @@ -65,7 +65,7 @@ use pallet_storage_handler::StorageHandle; use cp_scheduler_credit::SchedulerCreditCounter; use sp_runtime::{ traits::{ - BlockNumberProvider, CheckedAdd, + BlockNumberProvider, CheckedAdd, Dispatchable }, RuntimeDebug, SaturatedConversion, }; @@ -84,7 +84,6 @@ use cp_enclave_verify::verify_rsa; pub use weights::WeightInfo; type AccountOf = ::AccountId; -type BlockNumberOf = ::BlockNumber; const STORAGE_VERSION: StorageVersion = StorageVersion::new(2); @@ -108,9 +107,9 @@ pub mod pallet { type RuntimeCall: From>; - type FScheduler: ScheduleNamed; + type FScheduler: ScheduleNamed, Self::SProposal, Self::SPalletsOrigin>; - type AScheduler: ScheduleAnon; + type AScheduler: ScheduleAnon, Self::SProposal, Self::SPalletsOrigin>; /// Overarching type of all pallets origins. type SPalletsOrigin: From>; /// The SProposal. @@ -120,9 +119,9 @@ pub mod pallet { //Used to find out whether the schedule exists type TeeWorkerHandler: TeeWorkerHandler; //It is used to control the computing power and space of miners - type MinerControl: MinerControl; + type MinerControl: MinerControl>; //Interface that can generate random seeds - type MyRandomness: Randomness, Self::BlockNumber>; + type MyRandomness: Randomness, BlockNumberFor>; type StorageHandle: StorageHandle; /// pallet address. @@ -133,7 +132,7 @@ pub mod pallet { type UserFileLimit: Get + Clone + Eq + PartialEq; #[pallet::constant] - type OneDay: Get>; + type OneDay: Get>; // User defined name length limit #[pallet::constant] @@ -292,7 +291,7 @@ pub mod pallet { #[pallet::storage] #[pallet::getter(fn miner_lock)] pub(super) type MinerLock = - StorageMap<_, Blake2_128Concat, AccountOf, BlockNumberOf>; + StorageMap<_, Blake2_128Concat, AccountOf, BlockNumberFor>; #[pallet::storage] #[pallet::getter(fn bucket)] @@ -337,8 +336,8 @@ pub mod pallet { pub struct Pallet(PhantomData); #[pallet::hooks] - impl Hooks> for Pallet { - fn on_initialize(now: BlockNumberOf) -> Weight { + impl Hooks> for Pallet { + fn on_initialize(now: BlockNumberFor) -> Weight { let days = T::OneDay::get(); let mut weight: Weight = Weight::zero(); // FOR TESTING @@ -1126,7 +1125,7 @@ impl RandomFileList<::AccountId> for Palle } impl BlockNumberProvider for Pallet { - type BlockNumber = T::BlockNumber; + type BlockNumber = BlockNumberFor; fn current_block_number() -> Self::BlockNumber { >::block_number() diff --git a/pallets/file-bank/src/types.rs b/pallets/file-bank/src/types.rs index 320ab863..48570f66 100755 --- a/pallets/file-bank/src/types.rs +++ b/pallets/file-bank/src/types.rs @@ -1,7 +1,6 @@ use super::*; // Substrate type type AccountOf = ::AccountId; -type BlockNumberOf = ::BlockNumber; // Cess type // pub(super) type SegmentList = BoundedVec<(Hash, BoundedVec::FragmentCount>), ::SegmentCount>; // pub(super) type MinerTaskList = BoundedVec<(AccountOf, BoundedVec::FragmentCount>), ::FragmentCount>; @@ -62,7 +61,7 @@ pub struct FileInfo { pub(super) segment_list: BoundedVec, T::SegmentCount>, pub(super) owner: BoundedVec, T::OwnerLimit>, pub(super) file_size: u128, - pub(super) completion: BlockNumberOf, + pub(super) completion: BlockNumberFor, pub(super) stat: FileState, } @@ -123,7 +122,7 @@ pub struct RestoralOrderInfo { pub(super) origin_miner: AccountOf, pub(super) fragment_hash: Hash, pub(super) file_hash: Hash, - pub(super) gen_block: BlockNumberOf, - pub(super) deadline: BlockNumberOf, + pub(super) gen_block: BlockNumberFor, + pub(super) deadline: BlockNumberFor, } diff --git a/pallets/oss/Cargo.toml b/pallets/oss/Cargo.toml index ef890abb..86bf1184 100644 --- a/pallets/oss/Cargo.toml +++ b/pallets/oss/Cargo.toml @@ -5,7 +5,7 @@ edition = "2021" [dependencies] log = { workspace = true } -codec = { version = "3.2.2", package = "parity-scale-codec", default-features = false, features = ["derive", "max-encoded-len"] } +codec = { package = "parity-scale-codec", version = "3.6.1", default-features = false, features = ["derive", "max-encoded-len"] } scale-info = { workspace = true, features = ["derive"] } sp-std = { workspace = true } sp-runtime = { workspace = true } diff --git a/pallets/oss/src/mock.rs b/pallets/oss/src/mock.rs index 5f1ed3cf..22f7e9e1 100644 --- a/pallets/oss/src/mock.rs +++ b/pallets/oss/src/mock.rs @@ -2,11 +2,10 @@ use crate as pallet_oss; use frame_benchmarking::account; use frame_support:: { parameter_types, - pallet_prelude::*, traits::ConstU32, }; use sp_runtime::{ - testing::Header, + BuildStorage, traits::{BlakeTwo256, IdentityLookup}, }; use sp_core::H256; @@ -15,15 +14,10 @@ pub(crate) type AccountId = u32; // type BlockNumber = u64; // type Balance = u64; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, - { + pub enum Test { System: frame_system, Oss: pallet_oss, // Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, @@ -60,13 +54,12 @@ impl frame_system::Config for Test { type BlockLength = (); type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; - type Index = u64; - type BlockNumber = u64; + type Block = Block; + type Nonce = u64; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = AccountId; type Lookup = IdentityLookup; - type Header = Header; type RuntimeEvent = RuntimeEvent; type BlockHashCount = BlockHashCount; type DbWeight = (); @@ -118,7 +111,7 @@ impl Default for ExtBuilder { impl ExtBuilder { fn build(self) -> sp_io::TestExternalities { - let storage = frame_system::GenesisConfig::default().build_storage::().unwrap(); + let storage = frame_system::GenesisConfig::::default().build_storage().unwrap(); let ext = sp_io::TestExternalities::from(storage); ext } diff --git a/pallets/scheduler-credit/Cargo.toml b/pallets/scheduler-credit/Cargo.toml index ab4e3fe3..329dd600 100644 --- a/pallets/scheduler-credit/Cargo.toml +++ b/pallets/scheduler-credit/Cargo.toml @@ -7,7 +7,7 @@ edition = "2021" [dependencies] log = { workspace = true } -codec = { version = "3.2.2", package = "parity-scale-codec", default-features = false, features = ["derive", "max-encoded-len"] } +codec = { package = "parity-scale-codec", version = "3.6.1", default-features = false, features = ["derive", "max-encoded-len"] } scale-info = { workspace = true, features = ["derive"] } sp-std = { workspace = true } sp-runtime = { workspace = true } diff --git a/pallets/scheduler-credit/src/lib.rs b/pallets/scheduler-credit/src/lib.rs index f46a1f14..65a84dff 100644 --- a/pallets/scheduler-credit/src/lib.rs +++ b/pallets/scheduler-credit/src/lib.rs @@ -12,6 +12,7 @@ use frame_support::{ storage::child::KillStorageResult, weights::Weight, }; +use frame_system::pallet_prelude::BlockNumberFor; use log::{debug, warn}; use scale_info::TypeInfo; use sp_runtime::{ @@ -91,7 +92,7 @@ pub mod pallet { pub trait Config: frame_system::Config { #[pallet::constant] - type PeriodDuration: Get; + type PeriodDuration: Get>; type StashAccountFinder: SchedulerStashAccountFinder; } @@ -111,10 +112,10 @@ pub mod pallet { StorageDoubleMap<_, Twox64Concat, u32, Blake2_128Concat, T::AccountId, u32, ValueQuery>; #[pallet::hooks] - impl Hooks for Pallet { - fn on_initialize(now: T::BlockNumber) -> Weight { + impl Hooks> for Pallet { + fn on_initialize(now: BlockNumberFor) -> Weight { let period_duration = T::PeriodDuration::get(); - if now % period_duration == T::BlockNumber::zero() { + if now % period_duration == Zero::zero() { let period: u32 = (now / period_duration).saturated_into(); Self::figure_credit_values(period.saturating_sub(1)) } else { diff --git a/pallets/scheduler-credit/src/mock.rs b/pallets/scheduler-credit/src/mock.rs index 11351926..dbfa87eb 100644 --- a/pallets/scheduler-credit/src/mock.rs +++ b/pallets/scheduler-credit/src/mock.rs @@ -5,13 +5,12 @@ use crate as scheduler_credit; use frame_support::{parameter_types, traits::ConstU32}; use sp_core::H256; use sp_runtime::{ - testing::Header, - traits::{BlakeTwo256, IdentityLookup}, + BuildStorage, + traits::{BlakeTwo256, IdentityLookup}, }; use std::marker::PhantomData; pub(crate) type AccountId = u32; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; type BlockNumber = u64; parameter_types! { @@ -24,13 +23,12 @@ impl frame_system::Config for Test { type BlockLength = (); type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; - type Index = u64; - type BlockNumber = u64; + type Block = Block; + type Nonce = u64; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = AccountId; type Lookup = IdentityLookup; - type Header = Header; type RuntimeEvent = RuntimeEvent; type BlockHashCount = BlockHashCount; type DbWeight = (); @@ -66,12 +64,8 @@ impl Config for Test { } frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, - { - System: frame_system::{Pallet, Call, Config, Storage, Event}, + pub enum Test { + System: frame_system::{Pallet, Call, Config, Storage, Event}, SchedulerCredit: scheduler_credit::{Pallet, Storage}, } ); @@ -86,9 +80,8 @@ impl Default for ExtBuilder { impl ExtBuilder { fn build(self) -> sp_io::TestExternalities { - let storage = frame_system::GenesisConfig::default().build_storage::().unwrap(); - let ext = sp_io::TestExternalities::from(storage); - ext + let storage = frame_system::GenesisConfig::::default().build_storage().unwrap(); + sp_io::TestExternalities::from(storage) } pub fn build_and_execute(self, test: impl FnOnce() -> ()) { diff --git a/pallets/scheduler-credit/src/tests.rs b/pallets/scheduler-credit/src/tests.rs index c25f136f..bf5417a9 100644 --- a/pallets/scheduler-credit/src/tests.rs +++ b/pallets/scheduler-credit/src/tests.rs @@ -1,7 +1,7 @@ use super::*; use crate::mock::*; use cp_scheduler_credit::SchedulerCreditCounter; -use frame_support::traits::ValidatorCredits; +use cessp_consensus_rrsc::traits::ValidatorCredits; #[test] fn figure_credit_scores_works() { diff --git a/pallets/sminer/Cargo.toml b/pallets/sminer/Cargo.toml index bc3e8780..d32b7be5 100644 --- a/pallets/sminer/Cargo.toml +++ b/pallets/sminer/Cargo.toml @@ -13,7 +13,7 @@ readme = "README.md" [dependencies] log = { workspace = true } serde = { workspace = true, optional = true } -codec = { version = "3.2.2", package = "parity-scale-codec", default-features = false, features = ["derive"] } +codec = { package = "parity-scale-codec", version = "3.6.1", default-features = false, features = ["derive"] } scale-info = { workspace = true, features = ["derive"] } rand_chacha = { workspace = true, optional = true } pallet-preimage = { workspace = true } @@ -67,6 +67,7 @@ std = [ "frame-benchmarking/std", "cp-cess-common/std", "pallet-cess-treasury/std", + "pallet-tee-worker/std", ] runtime-benchmarks = [ diff --git a/pallets/sminer/src/functions.rs b/pallets/sminer/src/functions.rs index ca6aeb25..fee466b8 100644 --- a/pallets/sminer/src/functions.rs +++ b/pallets/sminer/src/functions.rs @@ -1,4 +1,5 @@ use super::*; +use frame_system::pallet_prelude::BlockNumberFor; impl Pallet { /// Sub computing power to corresponding miners. @@ -112,7 +113,7 @@ impl Pallet { let now = >::block_number(); let block = now.checked_add(&block.saturated_into()).ok_or(Error::::Overflow)?; - let restoral_info = RestoralTargetInfo::, BlockNumberOf>{ + let restoral_info = RestoralTargetInfo::, BlockNumberFor>{ miner: miner.clone(), service_space, restored_space: u128::MIN, diff --git a/pallets/sminer/src/lib.rs b/pallets/sminer/src/lib.rs index e1887159..7c3d95e3 100644 --- a/pallets/sminer/src/lib.rs +++ b/pallets/sminer/src/lib.rs @@ -26,18 +26,19 @@ use frame_support::{ Get, ReservableCurrency, schedule::{self, Anon as ScheduleAnon, DispatchTime, Named as ScheduleNamed}, }, - dispatch::{Dispatchable, DispatchResult}, + dispatch::DispatchResult, pallet_prelude::DispatchError, }; +use frame_system::pallet_prelude::BlockNumberFor; use cp_cess_common::*; use sp_runtime::traits::Zero; use codec::{Decode, Encode}; use scale_info::TypeInfo; use sp_runtime::{ - traits::{AccountIdConversion, CheckedAdd, CheckedSub, CheckedDiv, SaturatedConversion}, - RuntimeDebug, Perbill, + traits::{AccountIdConversion, CheckedAdd, CheckedSub, CheckedDiv, Dispatchable, SaturatedConversion}, + RuntimeDebug, Perbill }; -use sp_std::{convert::TryInto, prelude::*}; +use sp_std::{convert::TryInto, prelude::*, marker::PhantomData}; use sp_core::ConstU32; use cp_enclave_verify::verify_rsa; use pallet_tee_worker::TeeWorkerHandler; @@ -71,7 +72,6 @@ pub use weights::WeightInfo; type AccountOf = ::AccountId; type BalanceOf = <::Currency as Currency<::AccountId>>::Balance; -type BlockNumberOf = ::BlockNumber; #[frame_support::pallet] pub mod pallet { @@ -98,7 +98,7 @@ pub mod pallet { type ItemLimit: Get; #[pallet::constant] - type OneDayBlock: Get>; + type OneDayBlock: Get>; /// The WeightInfo. type WeightInfo: WeightInfo; @@ -106,9 +106,9 @@ pub mod pallet { type CessTreasuryHandle: TreasuryHandle, BalanceOf>; - type FScheduler: ScheduleNamed; + type FScheduler: ScheduleNamed, Self::SProposal, Self::SPalletsOrigin>; - type AScheduler: ScheduleAnon; + type AScheduler: ScheduleAnon, Self::SProposal, Self::SPalletsOrigin>; /// Overarching type of all pallets origins. type SPalletsOrigin: From>; /// The SProposal. @@ -133,8 +133,8 @@ pub mod pallet { }, /// Prompt time LessThan24Hours { - last: BlockNumberOf, - now: BlockNumberOf, + last: BlockNumberFor, + now: BlockNumberFor, }, //The miners have been frozen AlreadyFrozen { @@ -245,7 +245,7 @@ pub mod pallet { #[pallet::storage] #[pallet::getter(fn faucet_record)] pub(super) type FaucetRecordMap = - StorageMap<_, Blake2_128Concat, T::AccountId, FaucetRecord>>; + StorageMap<_, Blake2_128Concat, T::AccountId, FaucetRecord>>; #[pallet::storage] #[pallet::getter(fn miner_public_key)] @@ -258,33 +258,34 @@ pub mod pallet { #[pallet::storage] #[pallet::getter(fn miner_lock)] pub(super) type MinerLock = - StorageMap<_, Blake2_128Concat, AccountOf, BlockNumberOf>; + StorageMap<_, Blake2_128Concat, AccountOf, BlockNumberFor>; #[pallet::storage] #[pallet::getter(fn restoral_target)] pub(super) type RestoralTarget = - StorageMap< _, Blake2_128Concat, AccountOf, RestoralTargetInfo, BlockNumberOf>>; + StorageMap< _, Blake2_128Concat, AccountOf, RestoralTargetInfo, BlockNumberFor>>; #[pallet::pallet] pub struct Pallet(_); #[pallet::genesis_config] - pub struct GenesisConfig{ + pub struct GenesisConfig{ pub expenders: (u64, u64, u64), + _marker: PhantomData, } - #[cfg(feature = "std")] - impl Default for GenesisConfig { + impl Default for GenesisConfig { fn default() -> Self { Self { // FOR TESTING expenders: (8, 1024*1024, 64), + _marker: PhantomData, } } } #[pallet::genesis_build] - impl GenesisBuild for GenesisConfig { + impl BuildGenesisConfig for GenesisConfig { fn build(&self) { Expenders::::put(self.expenders); } @@ -718,8 +719,8 @@ pub mod pallet { if !>::contains_key(&to) { >::insert( &to, - FaucetRecord::> { - last_claim_time: BlockNumberOf::::from(0u32), + FaucetRecord::> { + last_claim_time: BlockNumberFor::::from(0u32), }, ); @@ -734,7 +735,7 @@ pub mod pallet { )?; >::insert( &to, - FaucetRecord::> { last_claim_time: now }, + FaucetRecord::> { last_claim_time: now }, ); } else { let one_day: u32 = T::OneDayBlock::get().saturated_into(); @@ -745,10 +746,10 @@ pub mod pallet { let now = >::block_number(); let mut flag: bool = true; - if now >= BlockNumberOf::::from(one_day) { + if now >= BlockNumberFor::::from(one_day) { if !(faucet_record.last_claim_time <= now - .checked_sub(&BlockNumberOf::::from(one_day)) + .checked_sub(&BlockNumberFor::::from(one_day)) .ok_or(Error::::Overflow)?) { Self::deposit_event(Event::::LessThan24Hours { @@ -758,7 +759,7 @@ pub mod pallet { flag = false; } } else { - if !(faucet_record.last_claim_time <= BlockNumberOf::::from(0u32)) { + if !(faucet_record.last_claim_time <= BlockNumberFor::::from(0u32)) { Self::deposit_event(Event::::LessThan24Hours { last: faucet_record.last_claim_time, now, @@ -777,7 +778,7 @@ pub mod pallet { )?; >::insert( &to, - FaucetRecord::> { last_claim_time: now }, + FaucetRecord::> { last_claim_time: now }, ); } @@ -849,7 +850,7 @@ pub trait MinerControl { fn get_miner_snapshot(miner: &AccountId) -> Result<(u128, u128, BloomFilter, SpaceProofInfo, TeeRsaSignature), DispatchError>; } -impl MinerControl<::AccountId, BlockNumberOf> for Pallet { +impl MinerControl<::AccountId, BlockNumberFor> for Pallet { fn add_miner_idle_space( acc: &::AccountId, accumulator: Accumulator, diff --git a/pallets/staking/Cargo.toml b/pallets/staking/Cargo.toml index 4e2bd973..f4007a3b 100644 --- a/pallets/staking/Cargo.toml +++ b/pallets/staking/Cargo.toml @@ -13,18 +13,18 @@ readme = "README.md" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -serde = { workspace = true, optional = true } -codec = { version = "3.2.2", package = "parity-scale-codec", default-features = false, features = ["derive"] } -scale-info = { workspace = true, features = ["derive"] } +serde = { workspace = true, features = ["alloc", "derive"] } +codec = { package = "parity-scale-codec", version = "3.6.1", default-features = false, features = ["derive"] } +scale-info = { workspace = true, features = ["derive", "serde"] } sp-std = { workspace = true } sp-io = { workspace = true } -sp-runtime = { workspace = true } -sp-staking = { workspace = true } +sp-runtime = { workspace = true, features = ["serde"] } +sp-staking = { workspace = true, features = ["serde"] } frame-support = { workspace = true } frame-system = { workspace = true } pallet-session = { workspace = true, features = [ "historical" ] } pallet-authorship = { workspace = true } -sp-application-crypto = { workspace = true } +sp-application-crypto = { workspace = true, features = ["serde"] } frame-election-provider-support = { workspace = true } log = { workspace = true } @@ -48,24 +48,48 @@ rand_chacha = { workspace = true } [features] default = ["std"] std = [ - "serde", "codec/std", - "scale-info/std", - "sp-std/std", - "sp-io/std", + "frame-benchmarking?/std", + "frame-election-provider-support/std", "frame-support/std", - "sp-runtime/std", - "sp-staking/std", - "pallet-session/std", "frame-system/std", + "log/std", "pallet-authorship/std", + "pallet-bags-list/std", + "pallet-balances/std", + "pallet-session/std", + "pallet-timestamp/std", + "scale-info/std", + "serde/std", "sp-application-crypto/std", - "log/std", - "frame-election-provider-support/std", + "sp-core/std", + "sp-io/std", + "sp-npos-elections/std", + "sp-runtime/std", + "sp-staking/std", + "sp-std/std", + "sp-tracing/std", ] runtime-benchmarks = [ "frame-benchmarking/runtime-benchmarks", "frame-election-provider-support/runtime-benchmarks", + "frame-support/runtime-benchmarks", + "frame-system/runtime-benchmarks", + "pallet-bags-list/runtime-benchmarks", + "pallet-balances/runtime-benchmarks", + "pallet-timestamp/runtime-benchmarks", "rand_chacha", + "sp-runtime/runtime-benchmarks", + "sp-staking/runtime-benchmarks", +] +try-runtime = [ + "frame-election-provider-support/try-runtime", + "frame-support/try-runtime", + "frame-system/try-runtime", + "pallet-authorship/try-runtime", + "pallet-bags-list/try-runtime", + "pallet-balances/try-runtime", + "pallet-session/try-runtime", + "pallet-timestamp/try-runtime", + "sp-runtime/try-runtime", ] -try-runtime = ["frame-support/try-runtime"] diff --git a/pallets/staking/src/benchmarking.rs b/pallets/staking/src/benchmarking.rs index ad7aab98..ce5c3552 100755 --- a/pallets/staking/src/benchmarking.rs +++ b/pallets/staking/src/benchmarking.rs @@ -22,17 +22,16 @@ use crate::{ConfigOp, Pallet as Staking}; use testing_utils::*; use codec::Decode; -use frame_election_provider_support::SortedListProvider; +use frame_election_provider_support::{bounds::DataProviderBounds, SortedListProvider}; use frame_support::{ - dispatch::UnfilteredDispatchable, pallet_prelude::*, - traits::{Currency, CurrencyToVote, Get, Imbalance}, + traits::{Currency, Get, Imbalance, UnfilteredDispatchable}, }; use sp_runtime::{ traits::{Bounded, One, StaticLookup, TrailingZeroInput, Zero}, Perbill, Percent, }; -use sp_staking::SessionIndex; +use sp_staking::{currency_to_vote::CurrencyToVote, SessionIndex}; use sp_std::prelude::*; pub use frame_benchmarking::v1::{ @@ -71,7 +70,8 @@ pub fn add_slashing_spans(who: &T::AccountId, spans: u32) { pub fn create_validator_with_nominators( n: u32, upper_bound: u32, - dead: bool, + dead_controller: bool, + unique_controller: bool, destination: RewardDestination, ) -> Result<(T::AccountId, Vec<(T::AccountId, T::AccountId)>), &'static str> { // Clean up any existing state. @@ -79,7 +79,12 @@ pub fn create_validator_with_nominators( let mut points_total = 0; let mut points_individual = Vec::new(); - let (v_stash, v_controller) = create_stash_controller::(0, 100, destination.clone())?; + let (v_stash, v_controller) = if unique_controller { + create_unique_stash_controller::(0, 100, destination.clone(), false)? + } else { + create_stash_controller::(0, 100, destination.clone())? + }; + let validator_prefs = ValidatorPrefs { commission: Perbill::from_percent(50), ..Default::default() }; Staking::::validate(RawOrigin::Signed(v_controller).into(), validator_prefs)?; @@ -93,10 +98,10 @@ pub fn create_validator_with_nominators( // Give the validator n nominators, but keep total users in the system the same. for i in 0..upper_bound { - let (n_stash, n_controller) = if !dead { + let (n_stash, n_controller) = if !dead_controller { create_stash_controller::(u32::MAX - i, 100, destination.clone())? } else { - create_stash_and_dead_controller::(u32::MAX - i, 100, destination.clone())? + create_unique_stash_controller::(u32::MAX - i, 100, destination.clone(), true)? }; if i < n { Staking::::nominate( @@ -217,15 +222,13 @@ const USER_SEED: u32 = 999666; benchmarks! { bond { let stash = create_funded_user::("stash", USER_SEED, 100); - let controller = create_funded_user::("controller", USER_SEED, 100); - let controller_lookup = T::Lookup::unlookup(controller.clone()); let reward_destination = RewardDestination::Staked; let amount = T::Currency::minimum_balance() * 10u32.into(); whitelist_account!(stash); - }: _(RawOrigin::Signed(stash.clone()), controller_lookup, amount, reward_destination) + }: _(RawOrigin::Signed(stash.clone()), amount, reward_destination) verify { - assert!(Bonded::::contains_key(stash)); - assert!(Ledger::::contains_key(controller)); + assert!(Bonded::::contains_key(stash.clone())); + assert!(Ledger::::contains_key(stash)); } bond_extra { @@ -334,7 +337,7 @@ benchmarks! { validate { let (stash, controller) = create_stash_controller::( - T::MaxNominations::get() - 1, + MaxNominationsOf::::get() - 1, 100, Default::default(), )?; @@ -358,11 +361,11 @@ benchmarks! { // these are the other validators; there are `T::MaxNominations::get() - 1` of them, so // there are a total of `T::MaxNominations::get()` validators in the system. - let rest_of_validators = create_validators_with_seed::(T::MaxNominations::get() - 1, 100, 415)?; + let rest_of_validators = create_validators_with_seed::(MaxNominationsOf::::get() - 1, 100, 415)?; // this is the validator that will be kicking. let (stash, controller) = create_stash_controller::( - T::MaxNominations::get() - 1, + MaxNominationsOf::::get() - 1, 100, Default::default(), )?; @@ -377,7 +380,7 @@ benchmarks! { for i in 0 .. k { // create a nominator stash. let (n_stash, n_controller) = create_stash_controller::( - T::MaxNominations::get() + i, + MaxNominationsOf::::get() + i, 100, Default::default(), )?; @@ -414,7 +417,7 @@ benchmarks! { // Worst case scenario, T::MaxNominations::get() nominate { - let n in 1 .. T::MaxNominations::get(); + let n in 1 .. MaxNominationsOf::::get(); // clean up any existing state. clear_validators_and_nominators::(); @@ -425,7 +428,7 @@ benchmarks! { // we are just doing an insert into the origin position. let scenario = ListScenario::::new(origin_weight, true)?; let (stash, controller) = create_stash_controller_with_balance::( - SEED + T::MaxNominations::get() + 1, // make sure the account does not conflict with others + SEED + MaxNominationsOf::::get() + 1, // make sure the account does not conflict with others origin_weight, Default::default(), ).unwrap(); @@ -470,13 +473,16 @@ benchmarks! { } set_controller { - let (stash, _) = create_stash_controller::(USER_SEED, 100, Default::default())?; - let new_controller = create_funded_user::("new_controller", USER_SEED, 100); - let new_controller_lookup = T::Lookup::unlookup(new_controller.clone()); + let (stash, ctlr) = create_unique_stash_controller::(9000, 100, Default::default(), false)?; + // ensure `ctlr` is the currently stored controller. + assert!(!Ledger::::contains_key(&stash)); + assert!(Ledger::::contains_key(&ctlr)); + assert_eq!(Bonded::::get(&stash), Some(ctlr.clone())); + whitelist_account!(stash); - }: _(RawOrigin::Signed(stash), new_controller_lookup) + }: _(RawOrigin::Signed(stash.clone())) verify { - assert!(Ledger::::contains_key(&new_controller)); + assert!(Ledger::::contains_key(&stash)); } set_validator_count { @@ -551,6 +557,7 @@ benchmarks! { n, T::MaxNominatorRewardedPerValidator::get() as u32, true, + true, RewardDestination::Controller, )?; @@ -584,6 +591,7 @@ benchmarks! { n, T::MaxNominatorRewardedPerValidator::get() as u32, false, + true, RewardDestination::Staked, )?; @@ -702,7 +710,7 @@ benchmarks! { create_validators_with_nominators_for_era::( v, n, - ::MaxNominations::get() as usize, + MaxNominationsOf::::get() as usize, false, None, )?; @@ -720,7 +728,7 @@ benchmarks! { create_validators_with_nominators_for_era::( v, n, - ::MaxNominations::get() as usize, + MaxNominationsOf::::get() as usize, false, None, )?; @@ -799,7 +807,7 @@ benchmarks! { let n in (MaxNominators::::get() / 2) .. MaxNominators::::get(); let validators = create_validators_with_nominators_for_era::( - v, n, T::MaxNominations::get() as usize, false, None + v, n, MaxNominationsOf::::get() as usize, false, None )? .into_iter() .map(|v| T::Lookup::lookup(v).unwrap()) @@ -810,7 +818,8 @@ benchmarks! { let num_voters = (v + n) as usize; }: { - let voters = >::get_npos_voters(None); + // default bounds are unbounded. + let voters = >::get_npos_voters(DataProviderBounds::default()); assert_eq!(voters.len(), num_voters); } @@ -821,10 +830,11 @@ benchmarks! { let n = MaxNominators::::get(); let _ = create_validators_with_nominators_for_era::( - v, n, T::MaxNominations::get() as usize, false, None + v, n, MaxNominationsOf::::get() as usize, false, None )?; }: { - let targets = >::get_npos_targets(None); + // default bounds are unbounded. + let targets = >::get_npos_targets(DataProviderBounds::default()); assert_eq!(targets.len() as u32, v); } @@ -952,7 +962,7 @@ mod tests { create_validators_with_nominators_for_era::( v, n, - ::MaxNominations::get() as usize, + MaxNominationsOf::::get() as usize, false, None, ) @@ -978,6 +988,7 @@ mod tests { n, <::MaxNominatorRewardedPerValidator as Get<_>>::get(), false, + false, RewardDestination::Staked, ) .unwrap(); @@ -1007,6 +1018,7 @@ mod tests { n, <::MaxNominatorRewardedPerValidator as Get<_>>::get(), false, + false, RewardDestination::Staked, ) .unwrap(); diff --git a/pallets/staking/src/election_size_tracker.rs b/pallets/staking/src/election_size_tracker.rs new file mode 100644 index 00000000..283ae014 --- /dev/null +++ b/pallets/staking/src/election_size_tracker.rs @@ -0,0 +1,259 @@ +// This file is part of Substrate. + +// Copyright (C) Parity Technologies (UK) Ltd. +// SPDX-License-Identifier: Apache-2.0 + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//! ## A static size tracker for the election snapshot data. +//! +//! ### Overview +//! +//! The goal of the size tracker is to provide a static, no-allocation byte tracker to be +//! used by the election data provider when preparing the results of +//! [`ElectionDataProvider::electing_voters`]. The [`StaticTracker`] implementation uses +//! [`codec::Encode::size_hint`] to estimate the SCALE encoded size of the snapshot voters struct +//! as it is being constructed without requiring extra stack allocations. +//! +//! The [`StaticTracker::try_register_voter`] is called to update the static tracker internal +//! state, if It will return an error if the resulting SCALE encoded size (in bytes) is larger than +//! the provided `DataProviderBounds`. +//! +//! ### Example +//! +//! ```ignore +//! use pallet_staking::election_size_tracker::*; +//! +//! // instantiates a new tracker. +//! let mut size_tracker = StaticTracker::::default(); +//! +//! let voter_bounds = ElectionBoundsBuilder::default().voter_size(1_00.into()).build().voters; +//! +//! let mut sorted_voters = T::VoterList.iter(); +//! let mut selected_voters = vec![]; +//! +//! // fit as many voters in the vec as the bounds permit. +//! for v in sorted_voters { +//! let voter = (v, weight_of(&v), targets_of(&v)); +//! if size_tracker.try_register_voter(&voter, &voter_bounds).is_err() { +//! // voter bounds size exhausted +//! break; +//! } +//! selected_voters.push(voter); +//! } +//! +//! // The SCALE encoded size in bytes of `selected_voters` is guaranteed to be below +//! // `voter_bounds`. +//! debug_assert!( +//! selected_voters.encoded_size() <= +//! SizeTracker::::final_byte_size_of(size_tracker.num_voters, size_tracker.size) +//! ); +//! ``` +//! +//! ### Implementation Details +//! +//! The current implementation of the static tracker is tightly coupled with the staking pallet +//! implementation, namely the representation of a voter ([`VoterOf`]). The SCALE encoded byte size +//! is calculated using [`Encode::size_hint`] of each type in the voter tuple. Each voter's byte +//! size is the sum of: +//! - 1 * [`Encode::size_hint`] of the `AccountId` type; +//! - 1 * [`Encode::size_hint`] of the `VoteWeight` type; +//! - `num_votes` * [`Encode::size_hint`] of the `AccountId` type. + +use codec::Encode; +use frame_election_provider_support::{ + bounds::{DataProviderBounds, SizeBound}, + ElectionDataProvider, VoterOf, +}; + +/// Keeps track of the SCALE encoded byte length of the snapshot's voters or targets. +/// +/// The tracker calculates the bytes used based on static rules, without requiring any actual +/// encoding or extra allocations. +#[derive(Clone, Copy, Debug)] +pub struct StaticTracker { + pub size: usize, + pub counter: usize, + _marker: sp_std::marker::PhantomData, +} + +impl Default for StaticTracker { + fn default() -> Self { + Self { size: 0, counter: 0, _marker: Default::default() } + } +} + +impl StaticTracker +where + DataProvider: ElectionDataProvider, +{ + /// Tries to register a new voter. + /// + /// If the new voter exhausts the provided bounds, return an error. Otherwise, the internal + /// state of the tracker is updated with the new registered voter. + pub fn try_register_voter( + &mut self, + voter: &VoterOf, + bounds: &DataProviderBounds, + ) -> Result<(), ()> { + let tracker_size_after = { + let voter_hint = Self::voter_size_hint(voter); + Self::final_byte_size_of(self.counter + 1, self.size.saturating_add(voter_hint)) + }; + + match bounds.size_exhausted(SizeBound(tracker_size_after as u32)) { + true => Err(()), + false => { + self.size = tracker_size_after; + self.counter += 1; + Ok(()) + }, + } + } + + /// Calculates the size of the voter to register based on [`Encode::size_hint`]. + fn voter_size_hint(voter: &VoterOf) -> usize { + let (voter_account, vote_weight, targets) = voter; + + voter_account + .size_hint() + .saturating_add(vote_weight.size_hint()) + .saturating_add(voter_account.size_hint().saturating_mul(targets.len())) + } + + /// Tries to register a new target. + /// + /// If the new target exhausts the provided bounds, return an error. Otherwise, the internal + /// state of the tracker is updated with the new registered target. + pub fn try_register_target( + &mut self, + target: DataProvider::AccountId, + bounds: &DataProviderBounds, + ) -> Result<(), ()> { + let tracker_size_after = Self::final_byte_size_of( + self.counter + 1, + self.size.saturating_add(target.size_hint()), + ); + + match bounds.size_exhausted(SizeBound(tracker_size_after as u32)) { + true => Err(()), + false => { + self.size = tracker_size_after; + self.counter += 1; + Ok(()) + }, + } + } + + /// Size of the SCALE encoded prefix with a given length. + #[inline] + fn length_prefix(len: usize) -> usize { + use codec::{Compact, CompactLen}; + Compact::::compact_len(&(len as u32)) + } + + /// Calculates the final size in bytes of the SCALE encoded snapshot voter struct. + fn final_byte_size_of(num_voters: usize, size: usize) -> usize { + Self::length_prefix(num_voters).saturating_add(size) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::{ + mock::{AccountId, Staking, Test}, + BoundedVec, MaxNominationsOf, + }; + use frame_election_provider_support::bounds::ElectionBoundsBuilder; + use sp_core::bounded_vec; + + type Voters = BoundedVec>; + + #[test] + pub fn election_size_tracker_works() { + let mut voters: Vec<(u64, u64, Voters)> = vec![]; + let mut size_tracker = StaticTracker::::default(); + let voter_bounds = ElectionBoundsBuilder::default().voters_size(1_50.into()).build().voters; + + // register 1 voter with 1 vote. + let voter = (1, 10, bounded_vec![2]); + assert!(size_tracker.try_register_voter(&voter, &voter_bounds).is_ok()); + voters.push(voter); + + assert_eq!( + StaticTracker::::final_byte_size_of(size_tracker.counter, size_tracker.size), + voters.encoded_size() + ); + + // register another voter, now with 3 votes. + let voter = (2, 20, bounded_vec![3, 4, 5]); + assert!(size_tracker.try_register_voter(&voter, &voter_bounds).is_ok()); + voters.push(voter); + + assert_eq!( + StaticTracker::::final_byte_size_of(size_tracker.counter, size_tracker.size), + voters.encoded_size() + ); + + // register noop vote (unlikely to happen). + let voter = (3, 30, bounded_vec![]); + assert!(size_tracker.try_register_voter(&voter, &voter_bounds).is_ok()); + voters.push(voter); + + assert_eq!( + StaticTracker::::final_byte_size_of(size_tracker.counter, size_tracker.size), + voters.encoded_size() + ); + } + + #[test] + pub fn election_size_tracker_bounds_works() { + let mut voters: Vec<(u64, u64, Voters)> = vec![]; + let mut size_tracker = StaticTracker::::default(); + let voter_bounds = ElectionBoundsBuilder::default().voters_size(1_00.into()).build().voters; + + let voter = (1, 10, bounded_vec![2]); + assert!(size_tracker.try_register_voter(&voter, &voter_bounds).is_ok()); + voters.push(voter); + + assert_eq!( + StaticTracker::::final_byte_size_of(size_tracker.counter, size_tracker.size), + voters.encoded_size() + ); + + assert!(size_tracker.size > 0 && size_tracker.size < 1_00); + let size_before_overflow = size_tracker.size; + + // try many voters that will overflow the tracker's buffer. + let voter = (2, 10, bounded_vec![2, 3, 4, 5, 6, 7, 8, 9]); + voters.push(voter.clone()); + + assert!(size_tracker.try_register_voter(&voter, &voter_bounds).is_err()); + assert!(size_tracker.size > 0 && size_tracker.size < 1_00); + + // size of the tracker did not update when trying to register votes failed. + assert_eq!(size_tracker.size, size_before_overflow); + } + + #[test] + fn len_prefix_works() { + let length_samples = + vec![0usize, 1, 62, 63, 64, 16383, 16384, 16385, 1073741822, 1073741823, 1073741824]; + + for s in length_samples { + // the encoded size of a vector of n bytes should be n + the length prefix + assert_eq!(vec![1u8; s].encoded_size(), StaticTracker::::length_prefix(s) + s); + } + } +} diff --git a/pallets/staking/src/lib.rs b/pallets/staking/src/lib.rs index d5920987..32c9a851 100755 --- a/pallets/staking/src/lib.rs +++ b/pallets/staking/src/lib.rs @@ -67,7 +67,7 @@ //! //! An account pair can become bonded using the [`bond`](Call::bond) call. //! -//! Stash accounts can change their associated controller using the +//! Stash accounts can update their associated controller back to the stash account using the //! [`set_controller`](Call::set_controller) call. //! //! There are three possible roles that any staked account pair can be in: `Validator`, `Nominator` @@ -159,7 +159,7 @@ //! ``` //! use pallet_staking::{self as staking}; //! -//! #[frame_support::pallet] +//! #[frame_support::pallet(dev_mode)] //! pub mod pallet { //! use super::*; //! use frame_support::pallet_prelude::*; @@ -292,6 +292,7 @@ pub(crate) mod mock; #[cfg(test)] mod tests; +pub mod election_size_tracker; pub mod inflation; pub mod migrations; pub mod slashing; @@ -301,7 +302,7 @@ pub mod pallet; use codec::{Decode, Encode, HasCompact, MaxEncodedLen}; use frame_support::{ - traits::{Currency, Defensive, Get}, + traits::{ConstU32, Currency, Defensive, Get}, weights::Weight, BoundedVec, CloneNoBound, EqNoBound, PartialEqNoBound, RuntimeDebugNoBound, }; @@ -314,12 +315,12 @@ use sp_runtime::{ pub use sp_staking::StakerStatus; use sp_staking::{ offence::{Offence, OffenceError, ReportOffence}, - EraIndex, SessionIndex, + EraIndex, OnStakingUpdate, SessionIndex, }; use sp_std::{collections::btree_map::BTreeMap, prelude::*}; pub use weights::WeightInfo; -pub use pallet::{pallet::*, *}; +pub use pallet::{pallet::*, UseNominatorsAndValidatorsMap, UseValidatorsMap}; pub(crate) const LOG_TARGET: &str = "runtime::staking"; @@ -338,6 +339,10 @@ macro_rules! log { /// pallet. pub type MaxWinnersOf = <::ElectionProvider as frame_election_provider_support::ElectionProviderBase>::MaxWinners; +/// Maximum number of nominations per nominator. +pub type MaxNominationsOf = + <::NominationsQuota as NominationsQuota>>::MaxNominations; + /// Counter for the number of "reward" points earned by a given validator. pub type RewardPoint = u32; @@ -549,7 +554,7 @@ impl StakingLedger { /// /// `slash_era` is the era in which the slash (which is being enacted now) actually happened. /// - /// This calls `Config::OnStakerSlash::on_slash` with information as to how the slash was + /// This calls `Config::OnStakingUpdate::on_slash` with information as to how the slash was /// applied. pub fn slash( &mut self, @@ -562,7 +567,6 @@ impl StakingLedger { } use sp_runtime::PerThing as _; - use sp_staking::OnStakerSlash as _; let mut remaining_slash = slash_amount; let pre_slash_total = self.total; @@ -667,7 +671,7 @@ impl StakingLedger { // clean unlocking chunks that are set to zero. self.unlocking.retain(|c| !c.value.is_zero()); - T::OnStakerSlash::on_slash(&self.stash, self.active, &slashed_unlocking); + T::EventListeners::on_slash(&self.stash, self.active, &slashed_unlocking); pre_slash_total.saturating_sub(self.total) } } @@ -680,7 +684,7 @@ impl StakingLedger { #[scale_info(skip_type_params(T))] pub struct Nominations { /// The targets of nomination. - pub targets: BoundedVec, + pub targets: BoundedVec>, /// The era the nominations were submitted. /// /// Except for initial nominations which are considered submitted at era 0. @@ -750,6 +754,36 @@ impl UnappliedSlash { } } +/// Something that defines the maximum number of nominations per nominator based on a curve. +/// +/// The method `curve` implements the nomination quota curve and should not be used directly. +/// However, `get_quota` returns the bounded maximum number of nominations based on `fn curve` and +/// the nominator's balance. +pub trait NominationsQuota { + /// Strict maximum number of nominations that caps the nominations curve. This value can be + /// used as the upper bound of the number of votes per nominator. + type MaxNominations: Get; + + /// Returns the voter's nomination quota within reasonable bounds [`min`, `max`], where `min` + /// is 1 and `max` is `Self::MaxNominations`. + fn get_quota(balance: Balance) -> u32 { + Self::curve(balance).clamp(1, Self::MaxNominations::get()) + } + + /// Returns the voter's nomination quota based on its balance and a curve. + fn curve(balance: Balance) -> u32; +} + +/// A nomination quota that allows up to MAX nominations for all validators. +pub struct FixedNominationsQuota; +impl NominationsQuota for FixedNominationsQuota { + type MaxNominations = ConstU32; + + fn curve(_: Balance) -> u32 { + MAX + } +} + /// Means for interacting with a specialized version of the `session` trait. /// /// This is needed because `Staking` sets the `ValidatorIdOf` of the `pallet_session::Config` @@ -849,8 +883,19 @@ impl(sp_std::marker::PhantomData); impl OnRuntimeUpgrade for MigrateToV13 { #[cfg(feature = "try-runtime")] - fn pre_upgrade() -> Result, &'static str> { + fn pre_upgrade() -> Result, TryRuntimeError> { frame_support::ensure!( StorageVersion::::get() == ObsoleteReleases::V12_0_0, "Required v12 before upgrading to v13" @@ -84,7 +90,7 @@ pub mod v13 { } #[cfg(feature = "try-runtime")] - fn post_upgrade(_state: Vec) -> Result<(), &'static str> { + fn post_upgrade(_state: Vec) -> Result<(), TryRuntimeError> { frame_support::ensure!( Pallet::::on_chain_storage_version() == 13, "v13 not applied" @@ -114,7 +120,7 @@ pub mod v12 { pub struct MigrateToV12(sp_std::marker::PhantomData); impl OnRuntimeUpgrade for MigrateToV12 { #[cfg(feature = "try-runtime")] - fn pre_upgrade() -> Result, &'static str> { + fn pre_upgrade() -> Result, TryRuntimeError> { frame_support::ensure!( StorageVersion::::get() == ObsoleteReleases::V11_0_0, "Expected v11 before upgrading to v12" @@ -146,7 +152,7 @@ pub mod v12 { } #[cfg(feature = "try-runtime")] - fn post_upgrade(_state: Vec) -> Result<(), &'static str> { + fn post_upgrade(_state: Vec) -> Result<(), TryRuntimeError> { frame_support::ensure!( StorageVersion::::get() == ObsoleteReleases::V12_0_0, "v12 not applied" @@ -170,7 +176,7 @@ pub mod v11 { for MigrateToV11 { #[cfg(feature = "try-runtime")] - fn pre_upgrade() -> Result, &'static str> { + fn pre_upgrade() -> Result, TryRuntimeError> { frame_support::ensure!( StorageVersion::::get() == ObsoleteReleases::V10_0_0, "must upgrade linearly" @@ -217,7 +223,7 @@ pub mod v11 { } #[cfg(feature = "try-runtime")] - fn post_upgrade(_state: Vec) -> Result<(), &'static str> { + fn post_upgrade(_state: Vec) -> Result<(), TryRuntimeError> { frame_support::ensure!( StorageVersion::::get() == ObsoleteReleases::V11_0_0, "wrong version after the upgrade" @@ -291,7 +297,7 @@ pub mod v10 { pub mod v9 { use super::*; #[cfg(feature = "try-runtime")] - use frame_support::codec::{Decode, Encode}; + use codec::{Decode, Encode}; #[cfg(feature = "try-runtime")] use sp_std::vec::Vec; @@ -332,7 +338,7 @@ pub mod v9 { } #[cfg(feature = "try-runtime")] - fn pre_upgrade() -> Result, &'static str> { + fn pre_upgrade() -> Result, TryRuntimeError> { frame_support::ensure!( StorageVersion::::get() == ObsoleteReleases::V8_0_0, "must upgrade linearly" @@ -343,17 +349,21 @@ pub mod v9 { } #[cfg(feature = "try-runtime")] - fn post_upgrade(prev_count: Vec) -> Result<(), &'static str> { + fn post_upgrade(prev_count: Vec) -> Result<(), TryRuntimeError> { let prev_count: u32 = Decode::decode(&mut prev_count.as_slice()).expect( "the state parameter should be something that was generated by pre_upgrade", ); let post_count = T::VoterList::count(); let validators = Validators::::count(); - assert!(post_count == prev_count + validators); + ensure!( + post_count == prev_count + validators, + "`VoterList` count after the migration must equal to the sum of \ + previous count and the current number of validators" + ); frame_support::ensure!( StorageVersion::::get() == ObsoleteReleases::V9_0_0, - "must upgrade " + "must upgrade" ); Ok(()) } diff --git a/pallets/staking/src/mock.rs b/pallets/staking/src/mock.rs index c2f559a9..56d6eb00 100755 --- a/pallets/staking/src/mock.rs +++ b/pallets/staking/src/mock.rs @@ -18,12 +18,15 @@ //! Test utilities use crate::{self as pallet_staking, *}; -use frame_election_provider_support::{onchain, SequentialPhragmen, VoteWeight}; +use frame_election_provider_support::{ + bounds::{ElectionBounds, ElectionBoundsBuilder}, + onchain, SequentialPhragmen, VoteWeight, +}; use frame_support::{ assert_ok, ord_parameter_types, parameter_types, traits::{ - ConstU32, ConstU64, Currency, EitherOfDiverse, FindAuthor, GenesisBuild, Get, Hooks, - Imbalance, OnUnbalanced, OneSessionHandler, + ConstU32, ConstU64, Currency, EitherOfDiverse, FindAuthor, Get, Hooks, Imbalance, + OnUnbalanced, OneSessionHandler, }, weights::constants::RocksDbWeight, }; @@ -32,8 +35,9 @@ use sp_core::H256; use sp_io; use sp_runtime::{ curve::PiecewiseLinear, - testing::{Header, UintAuthorityId}, + testing::UintAuthorityId, traits::{IdentityLookup, Zero}, + BuildStorage, }; use sp_staking::offence::{DisableStrategy, OffenceDetails, OnOffenceHandler}; @@ -42,7 +46,7 @@ pub const BLOCK_TIME: u64 = 1000; /// The AccountId alias in this test module. pub(crate) type AccountId = u64; -pub(crate) type AccountIndex = u64; +pub(crate) type Nonce = u64; pub(crate) type BlockNumber = u64; pub(crate) type Balance = u128; @@ -82,14 +86,10 @@ pub fn is_disabled(controller: AccountId) -> bool { Session::disabled_validators().contains(&validator_index) } -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system, Authorship: pallet_authorship, @@ -127,14 +127,13 @@ impl frame_system::Config for Test { type BlockLength = (); type DbWeight = RocksDbWeight; type RuntimeOrigin = RuntimeOrigin; - type Index = AccountIndex; - type BlockNumber = BlockNumber; + type Nonce = Nonce; type RuntimeCall = RuntimeCall; type Hash = H256; type Hashing = ::sp_runtime::traits::BlakeTwo256; type AccountId = AccountId; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = frame_support::traits::ConstU64<250>; type Version = (); @@ -159,7 +158,7 @@ impl pallet_balances::Config for Test { type WeightInfo = (); type FreezeIdentifier = (); type MaxFreezes = (); - type HoldIdentifier = (); + type RuntimeHoldReason = (); type MaxHolds = (); } @@ -232,12 +231,12 @@ const THRESHOLDS: [sp_npos_elections::VoteWeight; 9] = parameter_types! { pub static BagThresholds: &'static [sp_npos_elections::VoteWeight] = &THRESHOLDS; - pub static MaxNominations: u32 = 16; pub static HistoryDepth: u32 = 80; pub static MaxUnlockingChunks: u32 = 32; pub static RewardOnUnbalanceWasCalled: bool = false; - pub static LedgerSlashPerEra: (BalanceOf, BTreeMap>) = (Zero::zero(), BTreeMap::new()); pub static MaxWinners: u32 = 100; + pub static ElectionsBounds: ElectionBounds = ElectionBoundsBuilder::default().build(); + pub static AbsoluteMaxNominations: u32 = 16; } type VoterBagsListInstance = pallet_bags_list::Instance1; @@ -257,8 +256,7 @@ impl onchain::Config for OnChainSeqPhragmen { type DataProvider = Staking; type WeightInfo = (); type MaxWinners = MaxWinners; - type VotersBound = ConstU32<{ u32::MAX }>; - type TargetsBound = ConstU32<{ u32::MAX }>; + type Bounds = ElectionsBounds; } pub struct MockReward {} @@ -268,8 +266,14 @@ impl OnUnbalanced> for MockReward { } } -pub struct OnStakerSlashMock(core::marker::PhantomData); -impl sp_staking::OnStakerSlash for OnStakerSlashMock { +parameter_types! { + pub static LedgerSlashPerEra: + (BalanceOf, BTreeMap>) = + (Zero::zero(), BTreeMap::new()); +} + +pub struct EventListenerMock; +impl OnStakingUpdate for EventListenerMock { fn on_slash( _pool_account: &AccountId, slashed_bonded: Balance, @@ -280,11 +284,16 @@ impl sp_staking::OnStakerSlash for OnStakerSlashM } impl crate::pallet::pallet::Config for Test { - type MaxNominations = MaxNominations; + const ERAS_PER_YEAR: u64 = 0; + const FIRST_YEAR_VALIDATOR_REWARDS: Balance = 0; + const FIRST_YEAR_SMINER_REWARDS: Balance = 0; + const REWARD_DECREASE_RATIO: Perbill = Perbill::from_perthousand(841); + const REWARD_DECREASE_YEARS: u64 = 30; + type SminerRewardPool = (); type Currency = Balances; type CurrencyBalance = ::Balance; type UnixTime = Timestamp; - type CurrencyToVote = frame_support::traits::SaturatingCurrencyToVote; + type CurrencyToVote = (); type RewardRemainder = RewardRemainderMock; type RuntimeEvent = RuntimeEvent; type Slash = (); @@ -303,13 +312,33 @@ impl crate::pallet::pallet::Config for Test { // NOTE: consider a macro and use `UseNominatorsAndValidatorsMap` as well. type VoterList = VoterBagsList; type TargetList = UseValidatorsMap; + type NominationsQuota = WeightedNominationsQuota<16>; type MaxUnlockingChunks = MaxUnlockingChunks; type HistoryDepth = HistoryDepth; - type OnStakerSlash = OnStakerSlashMock; + type EventListeners = EventListenerMock; type BenchmarkingConfig = TestBenchmarkingConfig; type WeightInfo = (); } +pub struct WeightedNominationsQuota; +impl NominationsQuota for WeightedNominationsQuota +where + u128: From, +{ + type MaxNominations = AbsoluteMaxNominations; + + fn curve(balance: Balance) -> u32 { + match balance.into() { + // random curve for testing. + 0..=110 => MAX, + 111 => 0, + 222 => 2, + 333 => MAX + 10, + _ => MAX, + } + } +} + pub(crate) type StakingCall = crate::Call; pub(crate) type TestCall = ::RuntimeCall; @@ -424,7 +453,7 @@ impl ExtBuilder { } fn build(self) -> sp_io::TestExternalities { sp_tracing::try_init_simple(); - let mut storage = frame_system::GenesisConfig::default().build_storage::().unwrap(); + let mut storage = frame_system::GenesisConfig::::default().build_storage().unwrap(); let _ = pallet_balances::GenesisConfig:: { balances: vec![ @@ -432,7 +461,7 @@ impl ExtBuilder { (2, 20 * self.balance_factor), (3, 300 * self.balance_factor), (4, 400 * self.balance_factor), - // controllers + // controllers (still used in some tests. Soon to be deprecated). (10, self.balance_factor), (20, self.balance_factor), (30, self.balance_factor), @@ -465,18 +494,18 @@ impl ExtBuilder { stakers = vec![ // (stash, ctrl, stake, status) // these two will be elected in the default test where we elect 2. - (11, 10, self.balance_factor * 1000, StakerStatus::::Validator), - (21, 20, self.balance_factor * 1000, StakerStatus::::Validator), + (11, 11, self.balance_factor * 1000, StakerStatus::::Validator), + (21, 21, self.balance_factor * 1000, StakerStatus::::Validator), // a loser validator - (31, 30, self.balance_factor * 500, StakerStatus::::Validator), + (31, 31, self.balance_factor * 500, StakerStatus::::Validator), // an idle validator - (41, 40, self.balance_factor * 1000, StakerStatus::::Idle), + (41, 41, self.balance_factor * 1000, StakerStatus::::Idle), ]; // optionally add a nominator if self.nominate { stakers.push(( 101, - 100, + 101, self.balance_factor * 500, StakerStatus::::Nominator(vec![11, 21]), )) @@ -563,35 +592,24 @@ pub(crate) fn current_era() -> EraIndex { Staking::current_era().unwrap() } -pub(crate) fn bond(stash: AccountId, ctrl: AccountId, val: Balance) { - let _ = Balances::make_free_balance_be(&stash, val); - let _ = Balances::make_free_balance_be(&ctrl, val); - assert_ok!(Staking::bond( - RuntimeOrigin::signed(stash), - ctrl, - val, - RewardDestination::Controller - )); +pub(crate) fn bond(who: AccountId, val: Balance) { + let _ = Balances::make_free_balance_be(&who, val); + assert_ok!(Staking::bond(RuntimeOrigin::signed(who), val, RewardDestination::Controller)); } -pub(crate) fn bond_validator(stash: AccountId, ctrl: AccountId, val: Balance) { - bond(stash, ctrl, val); - assert_ok!(Staking::validate(RuntimeOrigin::signed(ctrl), ValidatorPrefs::default())); +pub(crate) fn bond_validator(who: AccountId, val: Balance) { + bond(who, val); + assert_ok!(Staking::validate(RuntimeOrigin::signed(who), ValidatorPrefs::default())); assert_ok!(Session::set_keys( - RuntimeOrigin::signed(ctrl), - SessionKeys { other: ctrl.into() }, + RuntimeOrigin::signed(who), + SessionKeys { other: who.into() }, vec![] )); } -pub(crate) fn bond_nominator( - stash: AccountId, - ctrl: AccountId, - val: Balance, - target: Vec, -) { - bond(stash, ctrl, val); - assert_ok!(Staking::nominate(RuntimeOrigin::signed(ctrl), target)); +pub(crate) fn bond_nominator(who: AccountId, val: Balance, target: Vec) { + bond(who, val); + assert_ok!(Staking::nominate(RuntimeOrigin::signed(who), target)); } /// Progress to the given block, triggering session and era changes as we progress. diff --git a/pallets/staking/src/pallet/impls.rs b/pallets/staking/src/pallet/impls.rs index 678c7bce..9611701a 100755 --- a/pallets/staking/src/pallet/impls.rs +++ b/pallets/staking/src/pallet/impls.rs @@ -18,16 +18,17 @@ //! Implementations for the Staking FRAME Pallet. use frame_election_provider_support::{ - data_provider, BoundedSupportsOf, ElectionDataProvider, ElectionProvider, ScoreProvider, - SortedListProvider, VoteWeight, VoterOf, + bounds::{CountBound, SizeBound}, + data_provider, BoundedSupportsOf, DataProviderBounds, ElectionDataProvider, ElectionProvider, + ScoreProvider, SortedListProvider, VoteWeight, VoterOf, }; use frame_support::{ defensive, dispatch::WithPostDispatchInfo, pallet_prelude::*, traits::{ - Currency, CurrencyToVote, Defensive, DefensiveResult, EstimateNextNewSession, Get, - Imbalance, LockableCurrency, OnUnbalanced, TryCollect, WithdrawReasons, + Currency, Defensive, DefensiveResult, EstimateNextNewSession, Get, Imbalance, + LockableCurrency, OnUnbalanced, TryCollect, WithdrawReasons, }, weights::Weight, }; @@ -38,19 +39,26 @@ use sp_runtime::{ Perbill, }; use sp_staking::{ + currency_to_vote::CurrencyToVote, offence::{DisableStrategy, OffenceDetails, OnOffenceHandler}, EraIndex, SessionIndex, Stake, StakingInterface, }; -use sp_std::{convert::TryInto, prelude::*}; +use sp_std::prelude::*; use crate::{ - log, slashing, weights::WeightInfo, ActiveEraInfo, BalanceOf, Exposure, ExposureOf, - Forcing, IndividualExposure, MaxWinnersOf, Nominations, PositiveImbalanceOf, RewardDestination, + election_size_tracker::StaticTracker, log, slashing, weights::WeightInfo, ActiveEraInfo, + BalanceOf, Exposure, ExposureOf, Forcing, IndividualExposure, MaxNominationsOf, + MaxWinnersOf, Nominations, NominationsQuota, PositiveImbalanceOf, RewardDestination, SessionInterface, StakingLedger, ValidatorPrefs, }; use super::{pallet::*, STAKING_ID}; +#[cfg(feature = "try-runtime")] +use frame_support::ensure; +#[cfg(any(test, feature = "try-runtime"))] +use sp_runtime::TryRuntimeError; + /// The maximum number of iterations that we do whilst iterating over `T::VoterList` in /// `get_npos_voters`. /// @@ -689,12 +697,12 @@ impl Pallet { /// Clear all era information for given era. pub(crate) fn clear_era_information(era_index: EraIndex) { - #[allow(deprecated)] - >::remove_prefix(era_index, None); - #[allow(deprecated)] - >::remove_prefix(era_index, None); - #[allow(deprecated)] - >::remove_prefix(era_index, None); + let mut cursor = >::clear_prefix(era_index, u32::MAX, None); + debug_assert!(cursor.maybe_cursor.is_none()); + cursor = >::clear_prefix(era_index, u32::MAX, None); + debug_assert!(cursor.maybe_cursor.is_none()); + cursor = >::clear_prefix(era_index, u32::MAX, None); + debug_assert!(cursor.maybe_cursor.is_none()); >::remove(era_index); >::remove(era_index); >::remove(era_index); @@ -775,13 +783,15 @@ impl Pallet { /// nominators. /// /// This function is self-weighing as [`DispatchClass::Mandatory`]. - pub fn get_npos_voters(maybe_max_len: Option) -> Vec> { - let max_allowed_len = { - let all_voter_count = T::VoterList::count() as usize; - maybe_max_len.unwrap_or(all_voter_count).min(all_voter_count) + pub fn get_npos_voters(bounds: DataProviderBounds) -> Vec> { + let mut voters_size_tracker: StaticTracker = StaticTracker::default(); + + let final_predicted_len = { + let all_voter_count = T::VoterList::count(); + bounds.count.unwrap_or(all_voter_count.into()).min(all_voter_count.into()).0 }; - let mut all_voters = Vec::<_>::with_capacity(max_allowed_len); + let mut all_voters = Vec::<_>::with_capacity(final_predicted_len as usize); // cache a few things. let weight_of = Self::weight_of_fn(); @@ -792,8 +802,8 @@ impl Pallet { let mut min_active_stake = u64::MAX; let mut sorted_voters = T::VoterList::iter(); - while all_voters.len() < max_allowed_len && - voters_seen < (NPOS_MAX_ITERATIONS_COEFFICIENT * max_allowed_len as u32) + while all_voters.len() < final_predicted_len as usize && + voters_seen < (NPOS_MAX_ITERATIONS_COEFFICIENT * final_predicted_len as u32) { let voter = match sorted_voters.next() { Some(voter) => { @@ -803,13 +813,32 @@ impl Pallet { None => break, }; + let voter_weight = weight_of(&voter); + // if voter weight is zero, do not consider this voter for the snapshot. + if voter_weight.is_zero() { + log!(debug, "voter's active balance is 0. skip this voter."); + continue + } + if let Some(Nominations { targets, .. }) = >::get(&voter) { - let voter_weight = weight_of(&voter); if !targets.is_empty() { - all_voters.push((voter.clone(), voter_weight, targets)); + // Note on lazy nomination quota: we do not check the nomination quota of the + // voter at this point and accept all the current nominations. The nomination + // quota is only enforced at `nominate` time. + + let voter = (voter, voter_weight, targets); + if voters_size_tracker.try_register_voter(&voter, &bounds).is_err() { + // no more space left for the election result, stop iterating. + Self::deposit_event(Event::::SnapshotVotersSizeExceeded { + size: voters_size_tracker.size as u32, + }); + break + } + + all_voters.push(voter); nominators_taken.saturating_inc(); } else { - // Technically should never happen, but not much we can do about it. + // technically should never happen, but not much we can do about it. } min_active_stake = if voter_weight < min_active_stake { voter_weight } else { min_active_stake }; @@ -817,34 +846,41 @@ impl Pallet { // if this voter is a validator: let self_vote = ( voter.clone(), - weight_of(&voter), + voter_weight, vec![voter.clone()] .try_into() .expect("`MaxVotesPerVoter` must be greater than or equal to 1"), ); + + if voters_size_tracker.try_register_voter(&self_vote, &bounds).is_err() { + // no more space left for the election snapshot, stop iterating. + Self::deposit_event(Event::::SnapshotVotersSizeExceeded { + size: voters_size_tracker.size as u32, + }); + break + } all_voters.push(self_vote); validators_taken.saturating_inc(); } else { // this can only happen if: 1. there a bug in the bags-list (or whatever is the // sorted list) logic and the state of the two pallets is no longer compatible, or // because the nominators is not decodable since they have more nomination than - // `T::MaxNominations`. The latter can rarely happen, and is not really an emergency - // or bug if it does. - log!( - warn, - "DEFENSIVE: invalid item in `VoterList`: {:?}, this nominator probably has too many nominations now", - voter - ); + // `T::NominationsQuota::get_quota`. The latter can rarely happen, and is not + // really an emergency or bug if it does. + defensive!( + "DEFENSIVE: invalid item in `VoterList`: {:?}, this nominator probably has too many nominations now", + voter, + ); } } // all_voters should have not re-allocated. - debug_assert!(all_voters.capacity() == max_allowed_len); + debug_assert!(all_voters.capacity() == final_predicted_len as usize); Self::register_weight(T::WeightInfo::get_npos_voters(validators_taken, nominators_taken)); let min_active_stake: T::CurrencyBalance = - if all_voters.len() == 0 { 0u64.into() } else { min_active_stake.into() }; + if all_voters.is_empty() { Zero::zero() } else { min_active_stake.into() }; MinimumActiveStake::::put(min_active_stake); @@ -862,14 +898,20 @@ impl Pallet { /// Get the targets for an upcoming npos election. /// /// This function is self-weighing as [`DispatchClass::Mandatory`]. - pub fn get_npos_targets(maybe_max_len: Option) -> Vec { - let max_allowed_len = maybe_max_len.unwrap_or_else(|| T::TargetList::count() as usize); - let mut all_targets = Vec::::with_capacity(max_allowed_len); + pub fn get_npos_targets(bounds: DataProviderBounds) -> Vec { + let mut targets_size_tracker: StaticTracker = StaticTracker::default(); + + let final_predicted_len = { + let all_target_count = T::TargetList::count(); + bounds.count.unwrap_or(all_target_count.into()).min(all_target_count.into()).0 + }; + + let mut all_targets = Vec::::with_capacity(final_predicted_len as usize); let mut targets_seen = 0; let mut targets_iter = T::TargetList::iter(); - while all_targets.len() < max_allowed_len && - targets_seen < (NPOS_MAX_ITERATIONS_COEFFICIENT * max_allowed_len as u32) + while all_targets.len() < final_predicted_len as usize && + targets_seen < (NPOS_MAX_ITERATIONS_COEFFICIENT * final_predicted_len as u32) { let target = match targets_iter.next() { Some(target) => { @@ -879,6 +921,14 @@ impl Pallet { None => break, }; + if targets_size_tracker.try_register_target(target.clone(), &bounds).is_err() { + // no more space left for the election snapshot, stop iterating. + Self::deposit_event(Event::::SnapshotTargetsSizeExceeded { + size: targets_size_tracker.size as u32, + }); + break + } + if Validators::::contains_key(&target) { all_targets.push(target); } @@ -997,46 +1047,51 @@ impl Pallet { /// Returns the current nominations quota for nominators. /// /// Used by the runtime API. - /// Note: for now, this api runtime will always return value of `T::MaxNominations` and thus it - /// is redundant. However, with the upcoming changes in - /// , the nominations quota will change - /// depending on the nominators balance. We're introducing this runtime API now to prepare the - /// community to use it before rolling out PR#12970. - pub fn api_nominations_quota(_balance: BalanceOf) -> u32 { - T::MaxNominations::get() + pub fn api_nominations_quota(balance: BalanceOf) -> u32 { + T::NominationsQuota::get_quota(balance) } } impl ElectionDataProvider for Pallet { type AccountId = T::AccountId; type BlockNumber = BlockNumberFor; - type MaxVotesPerVoter = T::MaxNominations; + type MaxVotesPerVoter = MaxNominationsOf; fn desired_targets() -> data_provider::Result { Self::register_weight(T::DbWeight::get().reads(1)); Ok(Self::validator_count()) } - fn electing_voters(maybe_max_len: Option) -> data_provider::Result>> { + fn electing_voters(bounds: DataProviderBounds) -> data_provider::Result>> { // This can never fail -- if `maybe_max_len` is `Some(_)` we handle it. - let voters = Self::get_npos_voters(maybe_max_len); - debug_assert!(maybe_max_len.map_or(true, |max| voters.len() <= max)); + let voters = Self::get_npos_voters(bounds); + + debug_assert!(!bounds.exhausted( + SizeBound(voters.encoded_size() as u32).into(), + CountBound(voters.len() as u32).into() + )); Ok(voters) } - fn electable_targets(maybe_max_len: Option) -> data_provider::Result> { - let target_count = T::TargetList::count(); + fn electable_targets(bounds: DataProviderBounds) -> data_provider::Result> { + let targets = Self::get_npos_targets(bounds); - // We can't handle this case yet -- return an error. - if maybe_max_len.map_or(false, |max_len| target_count > max_len as u32) { + // We can't handle this case yet -- return an error. WIP to improve handling this case in + // . + if bounds.exhausted(None, CountBound(T::TargetList::count() as u32).into()) { return Err("Target snapshot too big") } - Ok(Self::get_npos_targets(None)) + debug_assert!(!bounds.exhausted( + SizeBound(targets.encoded_size() as u32).into(), + CountBound(targets.len() as u32).into() + )); + + Ok(targets) } - fn next_election_prediction(now: T::BlockNumber) -> T::BlockNumber { + fn next_election_prediction(now: BlockNumberFor) -> BlockNumberFor { let current_era = Self::current_era().unwrap_or(0); let current_session = Self::current_planned_session(); let current_era_start_session_index = @@ -1053,7 +1108,7 @@ impl ElectionDataProvider for Pallet { let session_length = T::NextNewSession::average_session_length(); - let sessions_left: T::BlockNumber = match ForceEra::::get() { + let sessions_left: BlockNumberFor = match ForceEra::::get() { Forcing::ForceNone => Bounded::max_value(), Forcing::ForceNew | Forcing::ForceAlways => Zero::zero(), Forcing::NotForcing if era_progress >= T::SessionsPerEra::get() => Zero::zero(), @@ -1252,7 +1307,7 @@ impl historical::SessionManager pallet_authorship::EventHandler for Pallet +impl pallet_authorship::EventHandler> for Pallet where T: Config + pallet_authorship::Config + pallet_session::Config, { @@ -1487,7 +1542,7 @@ impl SortedListProvider for UseValidatorsMap { 0 } #[cfg(feature = "try-runtime")] - fn try_state() -> Result<(), &'static str> { + fn try_state() -> Result<(), TryRuntimeError> { Ok(()) } @@ -1564,7 +1619,7 @@ impl SortedListProvider for UseNominatorsAndValidatorsM } #[cfg(feature = "try-runtime")] - fn try_state() -> Result<(), &'static str> { + fn try_state() -> Result<(), TryRuntimeError> { Ok(()) } @@ -1583,10 +1638,10 @@ impl SortedListProvider for UseNominatorsAndValidatorsM } } -// NOTE: in this entire impl block, the assumption is that `who` is a stash account. impl StakingInterface for Pallet { type AccountId = T::AccountId; type Balance = BalanceOf; + type CurrencyToVote = T::CurrencyToVote; fn minimum_nominator_bond() -> Self::Balance { MinNominatorBond::::get() @@ -1671,7 +1726,6 @@ impl StakingInterface for Pallet { ) -> DispatchResult { Self::bond( RawOrigin::Signed(who.clone()).into(), - T::Lookup::unlookup(who.clone()), value, RewardDestination::Account(payee.clone()), ) @@ -1734,7 +1788,7 @@ impl StakingInterface for Pallet { #[cfg(any(test, feature = "try-runtime"))] impl Pallet { - pub(crate) fn do_try_state(_: BlockNumberFor) -> Result<(), &'static str> { + pub(crate) fn do_try_state(_: BlockNumberFor) -> Result<(), TryRuntimeError> { ensure!( T::VoterList::iter() .all(|x| >::contains_key(&x) || >::contains_key(&x)), @@ -1747,7 +1801,7 @@ impl Pallet { Self::check_count() } - fn check_count() -> Result<(), &'static str> { + fn check_count() -> Result<(), TryRuntimeError> { ensure!( ::VoterList::count() == Nominators::::count() + Validators::::count(), @@ -1760,18 +1814,19 @@ impl Pallet { ensure!( ValidatorCount::::get() <= ::MaxWinners::get(), - "validator count exceeded election max winners" + Error::::TooManyValidators ); Ok(()) } - fn check_ledgers() -> Result<(), &'static str> { + fn check_ledgers() -> Result<(), TryRuntimeError> { Bonded::::iter() .map(|(_, ctrl)| Self::ensure_ledger_consistent(ctrl)) - .collect::>() + .collect::, _>>()?; + Ok(()) } - fn check_exposures() -> Result<(), &'static str> { + fn check_exposures() -> Result<(), TryRuntimeError> { // a check per validator to ensure the exposure struct is always sane. let era = Self::active_era().unwrap().index; ErasStakers::::iter_prefix_values(era) @@ -1787,10 +1842,10 @@ impl Pallet { ); Ok(()) }) - .collect::>() + .collect::>() } - fn check_nominators() -> Result<(), &'static str> { + fn check_nominators() -> Result<(), TryRuntimeError> { // a check per nominator to ensure their entire stake is correctly distributed. Will only // kick-in if the nomination was submitted before the current era. let era = Self::active_era().unwrap().index; @@ -1804,27 +1859,33 @@ impl Pallet { } }, ) - .map(|nominator| { + .map(|nominator| -> Result<(), TryRuntimeError> { // must be bonded. Self::ensure_is_stash(&nominator)?; let mut sum = BalanceOf::::zero(); T::SessionInterface::validators() .iter() .map(|v| Self::eras_stakers(era, v)) - .map(|e| { + .map(|e| -> Result<(), TryRuntimeError> { let individual = e.others.iter().filter(|e| e.who == nominator).collect::>(); let len = individual.len(); match len { 0 => { /* not supporting this validator at all. */ }, 1 => sum += individual[0].value, - _ => return Err("nominator cannot back a validator more than once."), + _ => + return Err( + "nominator cannot back a validator more than once.".into() + ), }; Ok(()) }) - .collect::>() + .collect::, _>>()?; + Ok(()) }) - .collect::>() + .collect::, _>>()?; + + Ok(()) } fn ensure_is_stash(who: &T::AccountId) -> Result<(), &'static str> { @@ -1832,17 +1893,13 @@ impl Pallet { Ok(()) } - fn ensure_ledger_consistent(ctrl: T::AccountId) -> Result<(), &'static str> { + fn ensure_ledger_consistent(ctrl: T::AccountId) -> Result<(), TryRuntimeError> { // ensures ledger.total == ledger.active + sum(ledger.unlocking). let ledger = Self::ledger(ctrl.clone()).ok_or("Not a controller.")?; let real_total: BalanceOf = ledger.unlocking.iter().fold(ledger.active, |a, c| a + c.value); ensure!(real_total == ledger.total, "ledger.total corrupt"); - if !(ledger.active >= T::Currency::minimum_balance() || ledger.active.is_zero()) { - log!(warn, "ledger.active less than ED: {:?}, {:?}", ctrl, ledger) - } - Ok(()) } } diff --git a/pallets/staking/src/pallet/mod.rs b/pallets/staking/src/pallet/mod.rs index ba2f6ffd..65fdd52c 100755 --- a/pallets/staking/src/pallet/mod.rs +++ b/pallets/staking/src/pallet/mod.rs @@ -17,14 +17,14 @@ //! Staking FRAME Pallet. +use codec::Codec; use frame_election_provider_support::{ ElectionProvider, ElectionProviderBase, SortedListProvider, VoteWeight, }; use frame_support::{ - dispatch::Codec, pallet_prelude::*, traits::{ - Currency, CurrencyToVote, Defensive, DefensiveResult, DefensiveSaturating, EnsureOrigin, + Currency, Defensive, DefensiveResult, DefensiveSaturating, EnsureOrigin, EstimateNextNewSession, Get, LockIdentifier, LockableCurrency, OnUnbalanced, TryCollect, UnixTime, }, @@ -45,9 +45,9 @@ pub use impls::*; use crate::{ slashing, weights::WeightInfo, AccountIdLookupOf, ActiveEraInfo, BalanceOf, EraPayout, - EraRewardPoints, Exposure, Forcing, NegativeImbalanceOf, Nominations, PositiveImbalanceOf, - RewardDestination, SessionInterface, StakingLedger, UnappliedSlash, UnlockChunk, - ValidatorPrefs, + EraRewardPoints, Exposure, Forcing, MaxNominationsOf, NegativeImbalanceOf, Nominations, + NominationsQuota, PositiveImbalanceOf, RewardDestination, SessionInterface, StakingLedger, + UnappliedSlash, UnlockChunk, ValidatorPrefs, }; const STAKING_ID: LockIdentifier = *b"staking "; @@ -105,7 +105,7 @@ pub mod pallet { /// The staking balance. type Currency: LockableCurrency< Self::AccountId, - Moment = Self::BlockNumber, + Moment = BlockNumberFor, Balance = Self::CurrencyBalance, >; /// Just the `Currency::Balance` type; we have this item to allow us to constrain it to @@ -131,25 +131,24 @@ pub mod pallet { /// in 128. /// Consequently, the backward convert is used convert the u128s from sp-elections back to a /// [`BalanceOf`]. - type CurrencyToVote: CurrencyToVote>; + type CurrencyToVote: sp_staking::currency_to_vote::CurrencyToVote>; /// Something that provides the election functionality. type ElectionProvider: ElectionProvider< AccountId = Self::AccountId, - BlockNumber = Self::BlockNumber, + BlockNumber = BlockNumberFor, // we only accept an election provider that has staking as data provider. DataProvider = Pallet, >; /// Something that provides the election functionality at genesis. type GenesisElectionProvider: ElectionProvider< AccountId = Self::AccountId, - BlockNumber = Self::BlockNumber, + BlockNumber = BlockNumberFor, DataProvider = Pallet, >; - /// Maximum number of nominations per nominator. - #[pallet::constant] - type MaxNominations: Get; + /// Something that defines the maximum number of nominations per nominator. + type NominationsQuota: NominationsQuota>; /// Number of eras to keep in history. /// @@ -218,7 +217,7 @@ pub mod pallet { /// Something that can estimate the next session change, accurately or as a best effort /// guess. - type NextNewSession: EstimateNextNewSession; + type NextNewSession: EstimateNextNewSession>; /// The maximum number of nominators rewarded for each validator. /// @@ -279,9 +278,11 @@ pub mod pallet { #[pallet::constant] type MaxUnlockingChunks: Get; - /// A hook called when any staker is slashed. Mostly likely this can be a no-op unless - /// other pallets exist that are affected by slashing per-staker. - type OnStakerSlash: sp_staking::OnStakerSlash>; + /// Something that listens to staking updates and performs actions based on the data it + /// receives. + /// + /// WARNING: this only reports slashing events for the time being. + type EventListeners: sp_staking::OnStakingUpdate>; /// Some parameters of the benchmarking. type BenchmarkingConfig: BenchmarkingConfig; @@ -364,7 +365,8 @@ pub mod pallet { /// they wish to support. /// /// Note that the keys of this storage map might become non-decodable in case the - /// [`Config::MaxNominations`] configuration is decreased. In this rare case, these nominators + /// account's [`NominationsQuota::MaxNominations`] configuration is decreased. + /// In this rare case, these nominators /// are still existent in storage, their key is correct and retrievable (i.e. `contains_key` /// indicates that they exist), but their value cannot be decoded. Therefore, the non-decodable /// nominators will effectively not-exist, until they re-submit their preferences such that it @@ -597,6 +599,7 @@ pub mod pallet { pub(crate) type ChillThreshold = StorageValue<_, Percent, OptionQuery>; #[pallet::genesis_config] + #[derive(frame_support::DefaultNoBound)] pub struct GenesisConfig { pub validator_count: u32, pub minimum_validator_count: u32, @@ -612,27 +615,8 @@ pub mod pallet { pub max_nominator_count: Option, } - #[cfg(feature = "std")] - impl Default for GenesisConfig { - fn default() -> Self { - GenesisConfig { - validator_count: Default::default(), - minimum_validator_count: Default::default(), - invulnerables: Default::default(), - force_era: Default::default(), - slash_reward_fraction: Default::default(), - canceled_payout: Default::default(), - stakers: Default::default(), - min_nominator_bond: Default::default(), - min_validator_bond: Default::default(), - max_validator_count: None, - max_nominator_count: None, - } - } - } - #[pallet::genesis_build] - impl GenesisBuild for GenesisConfig { + impl BuildGenesisConfig for GenesisConfig { fn build(&self) { ValidatorCount::::put(self.validator_count); MinimumValidatorCount::::put(self.minimum_validator_count); @@ -649,7 +633,7 @@ pub mod pallet { MaxNominatorsCount::::put(x); } - for &(ref stash, ref controller, balance, ref status) in &self.stakers { + for &(ref stash, _, balance, ref status) in &self.stakers { crate::log!( trace, "inserting genesis staker: {:?} => {:?} => {:?}", @@ -663,17 +647,16 @@ pub mod pallet { ); frame_support::assert_ok!(>::bond( T::RuntimeOrigin::from(Some(stash.clone()).into()), - T::Lookup::unlookup(controller.clone()), balance, RewardDestination::Staked, )); frame_support::assert_ok!(match status { crate::StakerStatus::Validator => >::validate( - T::RuntimeOrigin::from(Some(controller.clone()).into()), + T::RuntimeOrigin::from(Some(stash.clone()).into()), Default::default(), ), crate::StakerStatus::Nominator(votes) => >::nominate( - T::RuntimeOrigin::from(Some(controller.clone()).into()), + T::RuntimeOrigin::from(Some(stash.clone()).into()), votes.iter().map(|l| T::Lookup::unlookup(l.clone())).collect(), ), _ => Ok(()), @@ -731,6 +714,10 @@ pub mod pallet { PayoutStarted { era_index: EraIndex, validator_stash: T::AccountId }, /// A validator has set their preferences. ValidatorPrefsSet { stash: T::AccountId, prefs: ValidatorPrefs }, + /// Voters size limit reached. + SnapshotVotersSizeExceeded { size: u32 }, + /// Targets size limit reached. + SnapshotTargetsSizeExceeded { size: u32 }, /// A new force era mode was set. ForceEra { mode: Forcing }, } @@ -817,11 +804,11 @@ pub mod pallet { fn integrity_test() { // ensure that we funnel the correct value to the `DataProvider::MaxVotesPerVoter`; assert_eq!( - T::MaxNominations::get(), + MaxNominationsOf::::get(), ::MaxVotesPerVoter::get() ); // and that MaxNominations is always greater than 1, since we count on this. - assert!(!T::MaxNominations::get().is_zero()); + assert!(!MaxNominationsOf::::get().is_zero()); // ensure election results are always bounded with the same value assert!( @@ -829,20 +816,16 @@ pub mod pallet { ::MaxWinners::get() ); - sp_std::if_std! { - sp_io::TestExternalities::new_empty().execute_with(|| - assert!( - T::SlashDeferDuration::get() < T::BondingDuration::get() || T::BondingDuration::get() == 0, - "As per documentation, slash defer duration ({}) should be less than bonding duration ({}).", - T::SlashDeferDuration::get(), - T::BondingDuration::get(), - ) - ); - } + assert!( + T::SlashDeferDuration::get() < T::BondingDuration::get() || T::BondingDuration::get() == 0, + "As per documentation, slash defer duration ({}) should be less than bonding duration ({}).", + T::SlashDeferDuration::get(), + T::BondingDuration::get(), + ) } #[cfg(feature = "try-runtime")] - fn try_state(n: BlockNumberFor) -> Result<(), &'static str> { + fn try_state(n: BlockNumberFor) -> Result<(), sp_runtime::TryRuntimeError> { Self::do_try_state(n) } } @@ -868,19 +851,17 @@ pub mod pallet { #[pallet::weight(T::WeightInfo::bond())] pub fn bond( origin: OriginFor, - controller: AccountIdLookupOf, #[pallet::compact] value: BalanceOf, payee: RewardDestination, ) -> DispatchResult { let stash = ensure_signed(origin)?; + let controller_to_be_deprecated = stash.clone(); if >::contains_key(&stash) { return Err(Error::::AlreadyBonded.into()) } - let controller = T::Lookup::lookup(controller)?; - - if >::contains_key(&controller) { + if >::contains_key(&controller_to_be_deprecated) { return Err(Error::::AlreadyPaired.into()) } @@ -893,7 +874,7 @@ pub mod pallet { // You're auto-bonded forever, here. We might improve this by only bonding when // you actually validate/nominate and remove once you unbond __everything__. - >::insert(&stash, &controller); + >::insert(&stash, &stash); >::insert(&stash, payee); let current_era = CurrentEra::::get().unwrap_or(0); @@ -904,7 +885,7 @@ pub mod pallet { let value = value.min(stash_balance); Self::deposit_event(Event::::Bonded { stash: stash.clone(), amount: value }); let item = StakingLedger { - stash, + stash: stash.clone(), total: value, active: value, unlocking: Default::default(), @@ -915,7 +896,7 @@ pub mod pallet { // satisfied. .defensive_map_err(|_| Error::::BoundNotMet)?, }; - Self::update_ledger(&controller, &item); + Self::update_ledger(&controller_to_be_deprecated, &item); Ok(()) } @@ -1045,9 +1026,7 @@ pub mod pallet { // Note: in case there is no current era it is fine to bond one era more. let era = Self::current_era().unwrap_or(0) + T::BondingDuration::get(); - if let Some(chunk) = - ledger.unlocking.last_mut().filter(|chunk| chunk.era == era) - { + if let Some(chunk) = ledger.unlocking.last_mut().filter(|chunk| chunk.era == era) { // To keep the chunk count down, we only keep one chunk per era. Since // `unlocking` is a FiFo queue, if a chunk exists for `era` we know that it will // be the last one. @@ -1081,8 +1060,8 @@ pub mod pallet { /// Remove any unlocked chunks from the `unlocking` queue from our management. /// - /// This essentially frees up that balance to be used by the stash account to do - /// whatever it wants. + /// This essentially frees up that balance to be used by the stash account to do whatever + /// it wants. /// /// The dispatch origin for this call must be _Signed_ by the controller. /// @@ -1090,6 +1069,15 @@ pub mod pallet { /// /// See also [`Call::unbond`]. /// + /// ## Parameters + /// + /// - `num_slashing_spans` indicates the number of metadata slashing spans to clear when + /// this call results in a complete removal of all the data related to the stash account. + /// In this case, the `num_slashing_spans` must be larger or equal to the number of + /// slashing spans associated with the stash account in the [`SlashingSpans`] storage type, + /// otherwise the call will fail. The call weight is directly propotional to + /// `num_slashing_spans`. + /// /// ## Complexity /// O(S) where S is the number of slashing spans to remove /// NOTE: Weight annotation is the kill scenario, we refund otherwise. @@ -1179,7 +1167,10 @@ pub mod pallet { } ensure!(!targets.is_empty(), Error::::EmptyTargets); - ensure!(targets.len() <= T::MaxNominations::get() as usize, Error::::TooManyTargets); + ensure!( + targets.len() <= T::NominationsQuota::get_quota(ledger.active) as usize, + Error::::TooManyTargets + ); let old = Nominators::::get(stash).map_or_else(Vec::new, |x| x.targets.into_inner()); @@ -1255,7 +1246,10 @@ pub mod pallet { Ok(()) } - /// (Re-)set the controller of a stash. + /// (Re-)sets the controller of a stash to the stash itself. This function previously + /// accepted a `controller` argument to set the controller to an account other than the + /// stash itself. This functionality has now been removed, now only setting the controller + /// to the stash, if it is not already. /// /// Effects will be felt instantly (as soon as this function is completed successfully). /// @@ -1268,20 +1262,17 @@ pub mod pallet { /// - Writes are limited to the `origin` account key. #[pallet::call_index(8)] #[pallet::weight(T::WeightInfo::set_controller())] - pub fn set_controller( - origin: OriginFor, - controller: AccountIdLookupOf, - ) -> DispatchResult { + pub fn set_controller(origin: OriginFor) -> DispatchResult { let stash = ensure_signed(origin)?; let old_controller = Self::bonded(&stash).ok_or(Error::::NotStash)?; - let controller = T::Lookup::lookup(controller)?; - if >::contains_key(&controller) { + + if >::contains_key(&stash) { return Err(Error::::AlreadyPaired.into()) } - if controller != old_controller { - >::insert(&stash, &controller); + if old_controller != stash { + >::insert(&stash, &stash); if let Some(l) = >::take(&old_controller) { - >::insert(&controller, l); + >::insert(&stash, l); } } Ok(()) @@ -1418,6 +1409,11 @@ pub mod pallet { /// Force a current staker to become completely unstaked, immediately. /// /// The dispatch origin must be Root. + /// + /// ## Parameters + /// + /// - `num_slashing_spans`: Refer to comments on [`Call::withdraw_unbonded`] for more + /// details. #[pallet::call_index(15)] #[pallet::weight(T::WeightInfo::force_unstake(*num_slashing_spans))] pub fn force_unstake( @@ -1558,6 +1554,11 @@ pub mod pallet { /// It can be called by anyone, as long as `stash` meets the above requirements. /// /// Refunds the transaction fees upon successful execution. + /// + /// ## Parameters + /// + /// - `num_slashing_spans`: Refer to comments on [`Call::withdraw_unbonded`] for more + /// details. #[pallet::call_index(20)] #[pallet::weight(T::WeightInfo::reap_stash(*num_slashing_spans))] pub fn reap_stash( diff --git a/pallets/staking/src/testing_utils.rs b/pallets/staking/src/testing_utils.rs index 9bd231cc..28e08230 100755 --- a/pallets/staking/src/testing_utils.rs +++ b/pallets/staking/src/testing_utils.rs @@ -75,17 +75,37 @@ pub fn create_stash_controller( n: u32, balance_factor: u32, destination: RewardDestination, +) -> Result<(T::AccountId, T::AccountId), &'static str> { + let staker = create_funded_user::("stash", n, balance_factor); + let amount = T::Currency::minimum_balance() * (balance_factor / 10).max(1).into(); + Staking::::bond(RawOrigin::Signed(staker.clone()).into(), amount, destination)?; + Ok((staker.clone(), staker)) +} + +/// Create a unique stash and controller pair. +pub fn create_unique_stash_controller( + n: u32, + balance_factor: u32, + destination: RewardDestination, + dead_controller: bool, ) -> Result<(T::AccountId, T::AccountId), &'static str> { let stash = create_funded_user::("stash", n, balance_factor); - let controller = create_funded_user::("controller", n, balance_factor); - let controller_lookup = T::Lookup::unlookup(controller.clone()); + + let controller = if dead_controller { + create_funded_user::("controller", n, 0) + } else { + create_funded_user::("controller", n, balance_factor) + }; let amount = T::Currency::minimum_balance() * (balance_factor / 10).max(1).into(); - Staking::::bond( - RawOrigin::Signed(stash.clone()).into(), - controller_lookup, - amount, - destination, - )?; + Staking::::bond(RawOrigin::Signed(stash.clone()).into(), amount, destination)?; + + // update ledger to be a *different* controller to stash + if let Some(l) = Ledger::::take(&stash) { + >::insert(&controller, l); + } + // update bonded account to be unique controller + >::insert(&stash, &controller); + Ok((stash, controller)) } @@ -95,38 +115,27 @@ pub fn create_stash_controller_with_balance( balance: crate::BalanceOf, destination: RewardDestination, ) -> Result<(T::AccountId, T::AccountId), &'static str> { - let stash = create_funded_user_with_balance::("stash", n, balance); - let controller = create_funded_user_with_balance::("controller", n, balance); - let controller_lookup = T::Lookup::unlookup(controller.clone()); - - Staking::::bond( - RawOrigin::Signed(stash.clone()).into(), - controller_lookup, - balance, - destination, - )?; - Ok((stash, controller)) + let staker = create_funded_user_with_balance::("stash", n, balance); + Staking::::bond(RawOrigin::Signed(staker.clone()).into(), balance, destination)?; + Ok((staker.clone(), staker)) } -/// Create a stash and controller pair, where the controller is dead, and payouts go to controller. -/// This is used to test worst case payout scenarios. -pub fn create_stash_and_dead_controller( +/// Create a stash and controller pair, where payouts go to a dead payee account. This is used to +/// test worst case payout scenarios. +pub fn create_stash_and_dead_payee( n: u32, balance_factor: u32, - destination: RewardDestination, ) -> Result<(T::AccountId, T::AccountId), &'static str> { - let stash = create_funded_user::("stash", n, balance_factor); - // controller has no funds - let controller = create_funded_user::("controller", n, 0); - let controller_lookup = T::Lookup::unlookup(controller.clone()); + let staker = create_funded_user::("stash", n, 0); + // payee has no funds + let payee = create_funded_user::("payee", n, 0); let amount = T::Currency::minimum_balance() * (balance_factor / 10).max(1).into(); Staking::::bond( - RawOrigin::Signed(stash.clone()).into(), - controller_lookup, + RawOrigin::Signed(staker.clone()).into(), amount, - destination, + RewardDestination::Account(payee), )?; - Ok((stash, controller)) + Ok((staker.clone(), staker)) } /// create `max` validators. diff --git a/pallets/staking/src/tests.rs b/pallets/staking/src/tests.rs index affee600..fd7dabac 100755 --- a/pallets/staking/src/tests.rs +++ b/pallets/staking/src/tests.rs @@ -18,9 +18,12 @@ //! Tests for the module. use super::{ConfigOp, Event, *}; -use frame_election_provider_support::{ElectionProvider, SortedListProvider, Support}; +use frame_election_provider_support::{ + bounds::{DataProviderBounds, ElectionBoundsBuilder}, + ElectionProvider, SortedListProvider, Support, +}; use frame_support::{ - assert_noop, assert_ok, assert_storage_noop, bounded_vec, + assert_noop, assert_ok, assert_storage_noop, dispatch::{extract_actual_weight, GetDispatchInfo, WithPostDispatchInfo}, pallet_prelude::*, traits::{Currency, Get, ReservableCurrency}, @@ -28,7 +31,7 @@ use frame_support::{ use mock::*; use pallet_balances::Error as BalancesError; use sp_runtime::{ - assert_eq_error_rate, + assert_eq_error_rate, bounded_vec, traits::{BadOrigin, Dispatchable}, Perbill, Percent, Rounding, TokenError, }; @@ -92,8 +95,8 @@ fn set_staking_configs_works() { #[test] fn force_unstake_works() { ExtBuilder::default().build_and_execute(|| { - // Account 11 is stashed and locked, and account 10 is the controller - assert_eq!(Staking::bonded(&11), Some(10)); + // Account 11 (also controller) is stashed and locked + assert_eq!(Staking::bonded(&11), Some(11)); // Adds 2 slashing spans add_slash(&11); // Cant transfer @@ -120,8 +123,8 @@ fn force_unstake_works() { #[test] fn kill_stash_works() { ExtBuilder::default().build_and_execute(|| { - // Account 11 is stashed and locked, and account 10 is the controller - assert_eq!(Staking::bonded(&11), Some(10)); + // Account 11 (also controller) is stashed and locked + assert_eq!(Staking::bonded(&11), Some(11)); // Adds 2 slashing spans add_slash(&11); // Only can kill a stash account @@ -139,16 +142,16 @@ fn kill_stash_works() { fn basic_setup_works() { // Verifies initial conditions of mock ExtBuilder::default().build_and_execute(|| { - // Account 11 is stashed and locked, and account 10 is the controller - assert_eq!(Staking::bonded(&11), Some(10)); - // Account 21 is stashed and locked, and account 20 is the controller - assert_eq!(Staking::bonded(&21), Some(20)); + // Account 11 is stashed and locked, and is the controller + assert_eq!(Staking::bonded(&11), Some(11)); + // Account 21 is stashed and locked and is the controller + assert_eq!(Staking::bonded(&21), Some(21)); // Account 1 is not a stashed assert_eq!(Staking::bonded(&1), None); - // Account 10 controls the stash from account 11, which is 100 * balance_factor units + // Account 11 controls its own stash, which is 100 * balance_factor units assert_eq!( - Staking::ledger(&10).unwrap(), + Staking::ledger(&11).unwrap(), StakingLedger { stash: 11, total: 1000, @@ -157,9 +160,9 @@ fn basic_setup_works() { claimed_rewards: bounded_vec![], } ); - // Account 20 controls the stash from account 21, which is 200 * balance_factor units + // Account 21 controls its own stash, which is 200 * balance_factor units assert_eq!( - Staking::ledger(&20), + Staking::ledger(&21), Some(StakingLedger { stash: 21, total: 1000, @@ -182,7 +185,7 @@ fn basic_setup_works() { ); assert_eq!( - Staking::ledger(100), + Staking::ledger(101), Some(StakingLedger { stash: 101, total: 500, @@ -231,15 +234,49 @@ fn basic_setup_works() { #[test] fn change_controller_works() { ExtBuilder::default().build_and_execute(|| { - // 10 and 11 are bonded as stash controller. - assert_eq!(Staking::bonded(&11), Some(10)); + let (stash, controller) = testing_utils::create_unique_stash_controller::( + 0, + 100, + RewardDestination::Staked, + false, + ) + .unwrap(); + + // ensure `stash` and `controller` are bonded as stash controller pair. + assert_eq!(Staking::bonded(&stash), Some(controller)); + + // `controller` can control `stash` who is initially a validator. + assert_ok!(Staking::chill(RuntimeOrigin::signed(controller))); + + // sets controller back to `stash`. + assert_ok!(Staking::set_controller(RuntimeOrigin::signed(stash))); + assert_eq!(Staking::bonded(&stash), Some(stash)); + mock::start_active_era(1); + + // `controller` is no longer in control. `stash` is now controller. + assert_noop!( + Staking::validate(RuntimeOrigin::signed(controller), ValidatorPrefs::default()), + Error::::NotController, + ); + assert_ok!(Staking::validate(RuntimeOrigin::signed(stash), ValidatorPrefs::default())); + }) +} + +#[test] +fn change_controller_already_paired_once_stash() { + ExtBuilder::default().build_and_execute(|| { + // 10 and 11 are bonded as controller and stash respectively. + assert_eq!(Staking::bonded(&11), Some(11)); - // 10 can control 11 who is initially a validator. - assert_ok!(Staking::chill(RuntimeOrigin::signed(10))); + // 11 is initially a validator. + assert_ok!(Staking::chill(RuntimeOrigin::signed(11))); - // change controller - assert_ok!(Staking::set_controller(RuntimeOrigin::signed(11), 5)); - assert_eq!(Staking::bonded(&11), Some(5)); + // Controller cannot change once matching with stash. + assert_noop!( + Staking::set_controller(RuntimeOrigin::signed(11)), + Error::::AlreadyPaired + ); + assert_eq!(Staking::bonded(&11), Some(11)); mock::start_active_era(1); // 10 is no longer in control. @@ -247,18 +284,15 @@ fn change_controller_works() { Staking::validate(RuntimeOrigin::signed(10), ValidatorPrefs::default()), Error::::NotController, ); - assert_ok!(Staking::validate(RuntimeOrigin::signed(5), ValidatorPrefs::default())); + assert_ok!(Staking::validate(RuntimeOrigin::signed(11), ValidatorPrefs::default())); }) } #[test] fn rewards_should_work() { ExtBuilder::default().nominate(true).session_per_era(3).build_and_execute(|| { - let init_balance_10 = Balances::total_balance(&10); let init_balance_11 = Balances::total_balance(&11); - let init_balance_20 = Balances::total_balance(&20); let init_balance_21 = Balances::total_balance(&21); - let init_balance_100 = Balances::total_balance(&100); let init_balance_101 = Balances::total_balance(&101); // Set payees @@ -278,11 +312,8 @@ fn rewards_should_work() { start_session(1); assert_eq_uvec!(Session::validators(), vec![11, 21]); - assert_eq!(Balances::total_balance(&10), init_balance_10); assert_eq!(Balances::total_balance(&11), init_balance_11); - assert_eq!(Balances::total_balance(&20), init_balance_20); assert_eq!(Balances::total_balance(&21), init_balance_21); - assert_eq!(Balances::total_balance(&100), init_balance_100); assert_eq!(Balances::total_balance(&101), init_balance_101); assert_eq!( Staking::eras_reward_points(active_era()), @@ -291,10 +322,10 @@ fn rewards_should_work() { individual: vec![(11, 100), (21, 50)].into_iter().collect(), } ); - let part_for_10 = Perbill::from_rational::(1000, 1125); - let part_for_20 = Perbill::from_rational::(1000, 1375); - let part_for_100_from_10 = Perbill::from_rational::(125, 1125); - let part_for_100_from_20 = Perbill::from_rational::(375, 1375); + let part_for_11 = Perbill::from_rational::(1000, 1125); + let part_for_21 = Perbill::from_rational::(1000, 1375); + let part_for_101_from_11 = Perbill::from_rational::(125, 1125); + let part_for_101_from_21 = Perbill::from_rational::(375, 1375); start_session(2); start_session(3); @@ -312,25 +343,22 @@ fn rewards_should_work() { mock::make_all_reward_payment(0); assert_eq_error_rate!( - Balances::total_balance(&10), - init_balance_10 + part_for_10 * total_payout_0 * 2 / 3, + Balances::total_balance(&11), + init_balance_11 + part_for_11 * total_payout_0 * 2 / 3, 2, ); - assert_eq_error_rate!(Balances::total_balance(&11), init_balance_11, 2); assert_eq_error_rate!( - Balances::total_balance(&20), - init_balance_20 + part_for_20 * total_payout_0 * 1 / 3, + Balances::total_balance(&21), + init_balance_21 + part_for_21 * total_payout_0 * 1 / 3, 2, ); - assert_eq_error_rate!(Balances::total_balance(&21), init_balance_21, 2); assert_eq_error_rate!( - Balances::total_balance(&100), - init_balance_100 + - part_for_100_from_10 * total_payout_0 * 2 / 3 + - part_for_100_from_20 * total_payout_0 * 1 / 3, + Balances::total_balance(&101), + init_balance_101 + + part_for_101_from_11 * total_payout_0 * 2 / 3 + + part_for_101_from_21 * total_payout_0 * 1 / 3, 2 ); - assert_eq_error_rate!(Balances::total_balance(&101), init_balance_101, 2); assert_eq_uvec!(Session::validators(), vec![11, 21]); Pallet::::reward_by_ids(vec![(11, 1)]); @@ -354,25 +382,22 @@ fn rewards_should_work() { mock::make_all_reward_payment(1); assert_eq_error_rate!( - Balances::total_balance(&10), - init_balance_10 + part_for_10 * (total_payout_0 * 2 / 3 + total_payout_1), + Balances::total_balance(&11), + init_balance_11 + part_for_11 * (total_payout_0 * 2 / 3 + total_payout_1), 2, ); - assert_eq_error_rate!(Balances::total_balance(&11), init_balance_11, 2); assert_eq_error_rate!( - Balances::total_balance(&20), - init_balance_20 + part_for_20 * total_payout_0 * 1 / 3, + Balances::total_balance(&21), + init_balance_21 + part_for_21 * total_payout_0 * 1 / 3, 2, ); - assert_eq_error_rate!(Balances::total_balance(&21), init_balance_21, 2); assert_eq_error_rate!( - Balances::total_balance(&100), - init_balance_100 + - part_for_100_from_10 * (total_payout_0 * 2 / 3 + total_payout_1) + - part_for_100_from_20 * total_payout_0 * 1 / 3, + Balances::total_balance(&101), + init_balance_101 + + part_for_101_from_11 * (total_payout_0 * 2 / 3 + total_payout_1) + + part_for_101_from_21 * total_payout_0 * 1 / 3, 2 ); - assert_eq_error_rate!(Balances::total_balance(&101), init_balance_101, 2); }); } @@ -380,7 +405,7 @@ fn rewards_should_work() { fn staking_should_work() { ExtBuilder::default().nominate(false).build_and_execute(|| { // remember + compare this along with the test. - assert_eq_uvec!(validator_controllers(), vec![20, 10]); + assert_eq_uvec!(validator_controllers(), vec![21, 11]); // put some money in account that we'll use. for i in 1..5 { @@ -390,22 +415,22 @@ fn staking_should_work() { // --- Block 2: start_session(2); // add a new candidate for being a validator. account 3 controlled by 4. - assert_ok!(Staking::bond(RuntimeOrigin::signed(3), 4, 1500, RewardDestination::Controller)); - assert_ok!(Staking::validate(RuntimeOrigin::signed(4), ValidatorPrefs::default())); + assert_ok!(Staking::bond(RuntimeOrigin::signed(3), 1500, RewardDestination::Controller)); + assert_ok!(Staking::validate(RuntimeOrigin::signed(3), ValidatorPrefs::default())); assert_ok!(Session::set_keys( - RuntimeOrigin::signed(4), + RuntimeOrigin::signed(3), SessionKeys { other: 4.into() }, vec![] )); // No effects will be seen so far. - assert_eq_uvec!(validator_controllers(), vec![20, 10]); + assert_eq_uvec!(validator_controllers(), vec![21, 11]); // --- Block 3: start_session(3); // No effects will be seen so far. Era has not been yet triggered. - assert_eq_uvec!(validator_controllers(), vec![20, 10]); + assert_eq_uvec!(validator_controllers(), vec![21, 11]); // --- Block 4: the validators will now be queued. start_session(4); @@ -417,25 +442,25 @@ fn staking_should_work() { // --- Block 6: the validators will now be changed. start_session(6); - assert_eq_uvec!(validator_controllers(), vec![20, 4]); + assert_eq_uvec!(validator_controllers(), vec![21, 3]); // --- Block 6: Unstake 4 as a validator, freeing up the balance stashed in 3 // 4 will chill - Staking::chill(RuntimeOrigin::signed(4)).unwrap(); + Staking::chill(RuntimeOrigin::signed(3)).unwrap(); - // --- Block 7: nothing. 4 is still there. + // --- Block 7: nothing. 3 is still there. start_session(7); - assert_eq_uvec!(validator_controllers(), vec![20, 4]); + assert_eq_uvec!(validator_controllers(), vec![21, 3]); // --- Block 8: start_session(8); // --- Block 9: 4 will not be a validator. start_session(9); - assert_eq_uvec!(validator_controllers(), vec![20, 10]); + assert_eq_uvec!(validator_controllers(), vec![21, 11]); // Note: the stashed value of 4 is still lock assert_eq!( - Staking::ledger(&4), + Staking::ledger(&3), Some(StakingLedger { stash: 3, total: 1500, @@ -459,20 +484,20 @@ fn blocking_and_kicking_works() { .build_and_execute(|| { // block validator 10/11 assert_ok!(Staking::validate( - RuntimeOrigin::signed(10), + RuntimeOrigin::signed(11), ValidatorPrefs { blocked: true, ..Default::default() } )); // attempt to nominate from 100/101... - assert_ok!(Staking::nominate(RuntimeOrigin::signed(100), vec![11])); + assert_ok!(Staking::nominate(RuntimeOrigin::signed(101), vec![11])); // should have worked since we're already nominated them assert_eq!(Nominators::::get(&101).unwrap().targets, vec![11]); // kick the nominator - assert_ok!(Staking::kick(RuntimeOrigin::signed(10), vec![101])); + assert_ok!(Staking::kick(RuntimeOrigin::signed(11), vec![101])); // should have been kicked now assert!(Nominators::::get(&101).unwrap().targets.is_empty()); // attempt to nominate from 100/101... assert_noop!( - Staking::nominate(RuntimeOrigin::signed(100), vec![11]), + Staking::nominate(RuntimeOrigin::signed(101), vec![11]), Error::::BadTarget ); }); @@ -487,12 +512,12 @@ fn less_than_needed_candidates_works() { .build_and_execute(|| { assert_eq!(Staking::validator_count(), 4); assert_eq!(Staking::minimum_validator_count(), 1); - assert_eq_uvec!(validator_controllers(), vec![30, 20, 10]); + assert_eq_uvec!(validator_controllers(), vec![31, 21, 11]); mock::start_active_era(1); // Previous set is selected. NO election algorithm is even executed. - assert_eq_uvec!(validator_controllers(), vec![30, 20, 10]); + assert_eq_uvec!(validator_controllers(), vec![31, 21, 11]); // But the exposure is updated in a simple way. No external votes exists. // This is purely self-vote. @@ -510,21 +535,21 @@ fn no_candidate_emergency_condition() { .nominate(false) .build_and_execute(|| { // initial validators - assert_eq_uvec!(validator_controllers(), vec![10, 20, 30, 40]); + assert_eq_uvec!(validator_controllers(), vec![11, 21, 31, 41]); let prefs = ValidatorPrefs { commission: Perbill::one(), ..Default::default() }; Validators::::insert(11, prefs.clone()); // set the minimum validator count. - MinimumValidatorCount::::put(10); + MinimumValidatorCount::::put(11); // try to chill - let res = Staking::chill(RuntimeOrigin::signed(10)); + let res = Staking::chill(RuntimeOrigin::signed(11)); assert_ok!(res); let current_era = CurrentEra::::get(); // try trigger new era - mock::run_to_block(20); + mock::run_to_block(21); assert_eq!(*staking_events().last().unwrap(), Event::StakingElectionFailed); // No new era is created assert_eq!(current_era, CurrentEra::::get()); @@ -534,7 +559,7 @@ fn no_candidate_emergency_condition() { // Previous ones are elected. chill is not effective in active era (as era hasn't // changed) - assert_eq_uvec!(validator_controllers(), vec![10, 20, 30, 40]); + assert_eq_uvec!(validator_controllers(), vec![11, 21, 31, 41]); // The chill is still pending. assert!(!Validators::::contains_key(11)); // No new era is created. @@ -551,52 +576,50 @@ fn nominating_and_rewards_should_work() { .set_status(31, StakerStatus::Idle) .build_and_execute(|| { // initial validators. - assert_eq_uvec!(validator_controllers(), vec![40, 20]); + assert_eq_uvec!(validator_controllers(), vec![41, 21]); // re-validate with 11 and 31. - assert_ok!(Staking::validate(RuntimeOrigin::signed(10), Default::default())); - assert_ok!(Staking::validate(RuntimeOrigin::signed(30), Default::default())); + assert_ok!(Staking::validate(RuntimeOrigin::signed(11), Default::default())); + assert_ok!(Staking::validate(RuntimeOrigin::signed(31), Default::default())); // Set payee to controller. assert_ok!(Staking::set_payee( - RuntimeOrigin::signed(10), + RuntimeOrigin::signed(11), RewardDestination::Controller )); assert_ok!(Staking::set_payee( - RuntimeOrigin::signed(20), + RuntimeOrigin::signed(21), RewardDestination::Controller )); assert_ok!(Staking::set_payee( - RuntimeOrigin::signed(30), + RuntimeOrigin::signed(31), RewardDestination::Controller )); assert_ok!(Staking::set_payee( - RuntimeOrigin::signed(40), + RuntimeOrigin::signed(41), RewardDestination::Controller )); // give the man some money let initial_balance = 1000; - for i in [1, 2, 3, 4, 5, 10, 11, 20, 21].iter() { + for i in [1, 3, 5, 11, 21].iter() { let _ = Balances::make_free_balance_be(i, initial_balance); } // bond two account pairs and state interest in nomination. assert_ok!(Staking::bond( RuntimeOrigin::signed(1), - 2, 1000, RewardDestination::Controller )); - assert_ok!(Staking::nominate(RuntimeOrigin::signed(2), vec![11, 21, 31])); + assert_ok!(Staking::nominate(RuntimeOrigin::signed(1), vec![11, 21, 31])); assert_ok!(Staking::bond( RuntimeOrigin::signed(3), - 4, 1000, RewardDestination::Controller )); - assert_ok!(Staking::nominate(RuntimeOrigin::signed(4), vec![11, 21, 41])); + assert_ok!(Staking::nominate(RuntimeOrigin::signed(3), vec![11, 21, 41])); // the total reward for era 0 let total_payout_0 = current_total_payout_for_duration(reward_time_per_era()); @@ -606,15 +629,15 @@ fn nominating_and_rewards_should_work() { mock::start_active_era(1); // 10 and 20 have more votes, they will be chosen. - assert_eq_uvec!(validator_controllers(), vec![20, 10]); + assert_eq_uvec!(validator_controllers(), vec![21, 11]); // old validators must have already received some rewards. - let initial_balance_40 = Balances::total_balance(&40); - let mut initial_balance_20 = Balances::total_balance(&20); + let initial_balance_41 = Balances::total_balance(&41); + let mut initial_balance_21 = Balances::total_balance(&21); mock::make_all_reward_payment(0); - assert_eq!(Balances::total_balance(&40), initial_balance_40 + total_payout_0 / 2); - assert_eq!(Balances::total_balance(&20), initial_balance_20 + total_payout_0 / 2); - initial_balance_20 = Balances::total_balance(&20); + assert_eq!(Balances::total_balance(&41), initial_balance_41 + total_payout_0 / 2); + assert_eq!(Balances::total_balance(&21), initial_balance_21 + total_payout_0 / 2); + initial_balance_21 = Balances::total_balance(&21); assert_eq!(ErasStakers::::iter_prefix_values(active_era()).count(), 2); assert_eq!( @@ -651,34 +674,34 @@ fn nominating_and_rewards_should_work() { // nominators will also be paid. See below mock::make_all_reward_payment(1); - let payout_for_10 = total_payout_1 / 3; - let payout_for_20 = 2 * total_payout_1 / 3; - // Nominator 2: has [400/1800 ~ 2/9 from 10] + [600/2200 ~ 3/11 from 20]'s reward. ==> + let payout_for_11 = total_payout_1 / 3; + let payout_for_21 = 2 * total_payout_1 / 3; + // Nominator 2: has [400/1800 ~ 2/9 from 10] + [600/2200 ~ 3/11 from 21]'s reward. ==> // 2/9 + 3/11 assert_eq_error_rate!( - Balances::total_balance(&2), - initial_balance + (2 * payout_for_10 / 9 + 3 * payout_for_20 / 11), + Balances::total_balance(&1), + initial_balance + (2 * payout_for_11 / 9 + 3 * payout_for_21 / 11), 2, ); - // Nominator 4: has [400/1800 ~ 2/9 from 10] + [600/2200 ~ 3/11 from 20]'s reward. ==> + // Nominator 3: has [400/1800 ~ 2/9 from 10] + [600/2200 ~ 3/11 from 21]'s reward. ==> // 2/9 + 3/11 assert_eq_error_rate!( - Balances::total_balance(&4), - initial_balance + (2 * payout_for_10 / 9 + 3 * payout_for_20 / 11), + Balances::total_balance(&3), + initial_balance + (2 * payout_for_11 / 9 + 3 * payout_for_21 / 11), 2, ); - // Validator 10: got 800 / 1800 external stake => 8/18 =? 4/9 => Validator's share = 5/9 + // Validator 11: got 800 / 1800 external stake => 8/18 =? 4/9 => Validator's share = 5/9 assert_eq_error_rate!( - Balances::total_balance(&10), - initial_balance + 5 * payout_for_10 / 9, + Balances::total_balance(&11), + initial_balance + 5 * payout_for_11 / 9, 2, ); - // Validator 20: got 1200 / 2200 external stake => 12/22 =? 6/11 => Validator's share = + // Validator 21: got 1200 / 2200 external stake => 12/22 =? 6/11 => Validator's share = // 5/11 assert_eq_error_rate!( - Balances::total_balance(&20), - initial_balance_20 + 5 * payout_for_20 / 11, + Balances::total_balance(&21), + initial_balance_21 + 5 * payout_for_21 / 11, 2, ); }); @@ -694,9 +717,9 @@ fn nominators_also_get_slashed_pro_rata() { assert_eq!(initial_exposure.others.first().unwrap().who, 101); // staked values; - let nominator_stake = Staking::ledger(100).unwrap().active; + let nominator_stake = Staking::ledger(101).unwrap().active; let nominator_balance = balances(&101).0; - let validator_stake = Staking::ledger(10).unwrap().active; + let validator_stake = Staking::ledger(11).unwrap().active; let validator_balance = balances(&11).0; let exposed_stake = initial_exposure.total; let exposed_validator = initial_exposure.own; @@ -709,8 +732,8 @@ fn nominators_also_get_slashed_pro_rata() { ); // both stakes must have been decreased. - assert!(Staking::ledger(100).unwrap().active < nominator_stake); - assert!(Staking::ledger(10).unwrap().active < validator_stake); + assert!(Staking::ledger(101).unwrap().active < nominator_stake); + assert!(Staking::ledger(11).unwrap().active < validator_stake); let slash_amount = slash_percent * exposed_stake; let validator_share = @@ -723,8 +746,8 @@ fn nominators_also_get_slashed_pro_rata() { assert!(nominator_share > 0); // both stakes must have been decreased pro-rata. - assert_eq!(Staking::ledger(100).unwrap().active, nominator_stake - nominator_share); - assert_eq!(Staking::ledger(10).unwrap().active, validator_stake - validator_share); + assert_eq!(Staking::ledger(101).unwrap().active, nominator_stake - nominator_share); + assert_eq!(Staking::ledger(11).unwrap().active, validator_stake - validator_share); assert_eq!( balances(&101).0, // free balance nominator_balance - nominator_share, @@ -734,7 +757,7 @@ fn nominators_also_get_slashed_pro_rata() { validator_balance - validator_share, ); // Because slashing happened. - assert!(is_disabled(10)); + assert!(is_disabled(11)); }); } @@ -746,56 +769,56 @@ fn double_staking_should_fail() { // * an account already bonded as controller can nominate. ExtBuilder::default().build_and_execute(|| { let arbitrary_value = 5; - // 2 = controller, 1 stashed => ok - assert_ok!(Staking::bond( - RuntimeOrigin::signed(1), - 2, + let (stash, controller) = testing_utils::create_unique_stash_controller::( + 0, arbitrary_value, - RewardDestination::default() - )); - // 4 = not used so far, 1 stashed => not allowed. + RewardDestination::default(), + false, + ) + .unwrap(); + + // 4 = not used so far, stash => not allowed. assert_noop!( Staking::bond( - RuntimeOrigin::signed(1), - 4, - arbitrary_value, + RuntimeOrigin::signed(stash), + arbitrary_value.into(), RewardDestination::default() ), Error::::AlreadyBonded, ); - // 1 = stashed => attempting to nominate should fail. + // stash => attempting to nominate should fail. assert_noop!( - Staking::nominate(RuntimeOrigin::signed(1), vec![1]), + Staking::nominate(RuntimeOrigin::signed(stash), vec![1]), Error::::NotController ); - // 2 = controller => nominating should work. - assert_ok!(Staking::nominate(RuntimeOrigin::signed(2), vec![1])); + // controller => nominating should work. + assert_ok!(Staking::nominate(RuntimeOrigin::signed(controller), vec![1])); }); } #[test] -fn double_controlling_should_fail() { +fn double_controlling_attempt_should_fail() { // should test (in the same order): // * an account already bonded as controller CANNOT be reused as the controller of another // account. ExtBuilder::default().build_and_execute(|| { let arbitrary_value = 5; - // 2 = controller, 1 stashed => ok - assert_ok!(Staking::bond( - RuntimeOrigin::signed(1), - 2, + let (stash, _) = testing_utils::create_unique_stash_controller::( + 0, arbitrary_value, RewardDestination::default(), - )); - // 2 = controller, 3 stashed (Note that 2 is reused.) => no-op + false, + ) + .unwrap(); + + // Note that controller (same as stash) is reused => no-op. assert_noop!( Staking::bond( - RuntimeOrigin::signed(3), - 2, - arbitrary_value, + RuntimeOrigin::signed(stash), + arbitrary_value.into(), RewardDestination::default() ), - Error::::AlreadyPaired, + Error::::AlreadyBonded, ); }); } @@ -953,21 +976,21 @@ fn cannot_transfer_staked_balance() { // Tests that a stash account cannot transfer funds ExtBuilder::default().nominate(false).build_and_execute(|| { // Confirm account 11 is stashed - assert_eq!(Staking::bonded(&11), Some(10)); + assert_eq!(Staking::bonded(&11), Some(11)); // Confirm account 11 has some free balance assert_eq!(Balances::free_balance(11), 1000); - // Confirm account 11 (via controller 10) is totally staked + // Confirm account 11 (via controller) is totally staked assert_eq!(Staking::eras_stakers(active_era(), 11).total, 1000); // Confirm account 11 cannot transfer as a result assert_noop!( - Balances::transfer_allow_death(RuntimeOrigin::signed(11), 20, 1), + Balances::transfer_allow_death(RuntimeOrigin::signed(11), 21, 1), TokenError::Frozen, ); // Give account 11 extra free balance let _ = Balances::make_free_balance_be(&11, 10000); // Confirm that account 11 can now transfer some balance - assert_ok!(Balances::transfer_allow_death(RuntimeOrigin::signed(11), 20, 1)); + assert_ok!(Balances::transfer_allow_death(RuntimeOrigin::signed(11), 21, 1)); }); } @@ -978,17 +1001,17 @@ fn cannot_transfer_staked_balance_2() { // 21 has 2000 free balance but 1000 at stake ExtBuilder::default().nominate(false).build_and_execute(|| { // Confirm account 21 is stashed - assert_eq!(Staking::bonded(&21), Some(20)); + assert_eq!(Staking::bonded(&21), Some(21)); // Confirm account 21 has some free balance assert_eq!(Balances::free_balance(21), 2000); - // Confirm account 21 (via controller 20) is totally staked + // Confirm account 21 (via controller) is totally staked assert_eq!(Staking::eras_stakers(active_era(), 21).total, 1000); // Confirm account 21 can transfer at most 1000 assert_noop!( - Balances::transfer_allow_death(RuntimeOrigin::signed(21), 20, 1001), + Balances::transfer_allow_death(RuntimeOrigin::signed(21), 21, 1001), TokenError::Frozen, ); - assert_ok!(Balances::transfer_allow_death(RuntimeOrigin::signed(21), 20, 1000)); + assert_ok!(Balances::transfer_allow_death(RuntimeOrigin::signed(21), 21, 1000)); }); } @@ -997,7 +1020,7 @@ fn cannot_reserve_staked_balance() { // Checks that a bonded account cannot reserve balance from free balance ExtBuilder::default().build_and_execute(|| { // Confirm account 11 is stashed - assert_eq!(Staking::bonded(&11), Some(10)); + assert_eq!(Staking::bonded(&11), Some(11)); // Confirm account 11 has some free balance assert_eq!(Balances::free_balance(11), 1000); // Confirm account 11 (via controller 10) is totally staked @@ -1024,7 +1047,7 @@ fn reward_destination_works() { assert_eq!(Balances::free_balance(11), 1000); // Check how much is at stake assert_eq!( - Staking::ledger(&10), + Staking::ledger(&11), Some(StakingLedger { stash: 11, total: 1000, @@ -1047,7 +1070,7 @@ fn reward_destination_works() { assert_eq!(Balances::free_balance(11), 1000 + total_payout_0); // Check that amount at stake increased accordingly assert_eq!( - Staking::ledger(&10), + Staking::ledger(&11), Some(StakingLedger { stash: 11, total: 1000 + total_payout_0, @@ -1071,11 +1094,9 @@ fn reward_destination_works() { assert_eq!(Staking::payee(&11), RewardDestination::Stash); // Check that reward went to the stash account assert_eq!(Balances::free_balance(11), 1000 + total_payout_0 + total_payout_1); - // Record this value - let recorded_stash_balance = 1000 + total_payout_0 + total_payout_1; // Check that amount at stake is NOT increased assert_eq!( - Staking::ledger(&10), + Staking::ledger(&11), Some(StakingLedger { stash: 11, total: 1000 + total_payout_0, @@ -1089,7 +1110,7 @@ fn reward_destination_works() { >::insert(&11, RewardDestination::Controller); // Check controller balance - assert_eq!(Balances::free_balance(10), 1); + assert_eq!(Balances::free_balance(11), 23150); // Compute total payout now for whole duration as other parameter won't change let total_payout_2 = current_total_payout_for_duration(reward_time_per_era()); @@ -1101,10 +1122,10 @@ fn reward_destination_works() { // Check that RewardDestination is Controller assert_eq!(Staking::payee(&11), RewardDestination::Controller); // Check that reward went to the controller account - assert_eq!(Balances::free_balance(10), 1 + total_payout_2); + assert_eq!(Balances::free_balance(11), 23150 + total_payout_2); // Check that amount at stake is NOT increased assert_eq!( - Staking::ledger(&10), + Staking::ledger(&11), Some(StakingLedger { stash: 11, total: 1000 + total_payout_0, @@ -1113,8 +1134,6 @@ fn reward_destination_works() { claimed_rewards: bounded_vec![0, 1, 2], }) ); - // Check that amount in staked account is NOT increased. - assert_eq!(Balances::free_balance(11), recorded_stash_balance); }); } @@ -1134,8 +1153,8 @@ fn validator_payment_prefs_work() { mock::start_active_era(1); mock::make_all_reward_payment(0); - let balance_era_1_10 = Balances::total_balance(&10); - let balance_era_1_100 = Balances::total_balance(&100); + let balance_era_1_11 = Balances::total_balance(&11); + let balance_era_1_101 = Balances::total_balance(&101); // Compute total payout now for whole duration as other parameter won't change let total_payout_1 = current_total_payout_for_duration(reward_time_per_era()); @@ -1149,8 +1168,8 @@ fn validator_payment_prefs_work() { let shared_cut = total_payout_1 - taken_cut; let reward_of_10 = shared_cut * exposure_1.own / exposure_1.total + taken_cut; let reward_of_100 = shared_cut * exposure_1.others[0].value / exposure_1.total; - assert_eq_error_rate!(Balances::total_balance(&10), balance_era_1_10 + reward_of_10, 2); - assert_eq_error_rate!(Balances::total_balance(&100), balance_era_1_100 + reward_of_100, 2); + assert_eq_error_rate!(Balances::total_balance(&11), balance_era_1_11 + reward_of_10, 2); + assert_eq_error_rate!(Balances::total_balance(&101), balance_era_1_101 + reward_of_100, 2); }); } @@ -1163,10 +1182,10 @@ fn bond_extra_works() { // Check that account 10 is a validator assert!(>::contains_key(11)); // Check that account 10 is bonded to account 11 - assert_eq!(Staking::bonded(&11), Some(10)); + assert_eq!(Staking::bonded(&11), Some(11)); // Check how much is at stake assert_eq!( - Staking::ledger(&10), + Staking::ledger(&11), Some(StakingLedger { stash: 11, total: 1000, @@ -1183,7 +1202,7 @@ fn bond_extra_works() { assert_ok!(Staking::bond_extra(RuntimeOrigin::signed(11), 100)); // There should be 100 more `total` and `active` in the ledger assert_eq!( - Staking::ledger(&10), + Staking::ledger(&11), Some(StakingLedger { stash: 11, total: 1000 + 100, @@ -1197,7 +1216,7 @@ fn bond_extra_works() { assert_ok!(Staking::bond_extra(RuntimeOrigin::signed(11), Balance::max_value())); // The full amount of the funds should now be in the total and active assert_eq!( - Staking::ledger(&10), + Staking::ledger(&11), Some(StakingLedger { stash: 11, total: 1000000, @@ -1219,7 +1238,7 @@ fn bond_extra_and_withdraw_unbonded_works() { // * Once the unbonding period is done, it can actually take the funds out of the stash. ExtBuilder::default().nominate(false).build_and_execute(|| { // Set payee to controller. avoids confusion - assert_ok!(Staking::set_payee(RuntimeOrigin::signed(10), RewardDestination::Controller)); + assert_ok!(Staking::set_payee(RuntimeOrigin::signed(11), RewardDestination::Controller)); // Give account 11 some large free balance greater than total let _ = Balances::make_free_balance_be(&11, 1000000); @@ -1228,14 +1247,14 @@ fn bond_extra_and_withdraw_unbonded_works() { assert_eq!(active_era(), 0); // check the balance of a validator accounts. - assert_eq!(Balances::total_balance(&10), 1); + assert_eq!(Balances::total_balance(&11), 1000000); // confirm that 10 is a normal validator and gets paid at the end of the era. mock::start_active_era(1); - // Initial state of 10 + // Initial state of 11 assert_eq!( - Staking::ledger(&10), + Staking::ledger(&11), Some(StakingLedger { stash: 11, total: 1000, @@ -1253,7 +1272,7 @@ fn bond_extra_and_withdraw_unbonded_works() { Staking::bond_extra(RuntimeOrigin::signed(11), 100).unwrap(); assert_eq!( - Staking::ledger(&10), + Staking::ledger(&11), Some(StakingLedger { stash: 11, total: 1000 + 100, @@ -1274,7 +1293,7 @@ fn bond_extra_and_withdraw_unbonded_works() { // ledger should be the same. assert_eq!( - Staking::ledger(&10), + Staking::ledger(&11), Some(StakingLedger { stash: 11, total: 1000 + 100, @@ -1290,9 +1309,9 @@ fn bond_extra_and_withdraw_unbonded_works() { ); // Unbond almost all of the funds in stash. - Staking::unbond(RuntimeOrigin::signed(10), 1000).unwrap(); + Staking::unbond(RuntimeOrigin::signed(11), 1000).unwrap(); assert_eq!( - Staking::ledger(&10), + Staking::ledger(&11), Some(StakingLedger { stash: 11, total: 1000 + 100, @@ -1303,9 +1322,9 @@ fn bond_extra_and_withdraw_unbonded_works() { ); // Attempting to free the balances now will fail. 2 eras need to pass. - assert_ok!(Staking::withdraw_unbonded(RuntimeOrigin::signed(10), 0)); + assert_ok!(Staking::withdraw_unbonded(RuntimeOrigin::signed(11), 0)); assert_eq!( - Staking::ledger(&10), + Staking::ledger(&11), Some(StakingLedger { stash: 11, total: 1000 + 100, @@ -1319,9 +1338,9 @@ fn bond_extra_and_withdraw_unbonded_works() { mock::start_active_era(3); // nothing yet - assert_ok!(Staking::withdraw_unbonded(RuntimeOrigin::signed(10), 0)); + assert_ok!(Staking::withdraw_unbonded(RuntimeOrigin::signed(11), 0)); assert_eq!( - Staking::ledger(&10), + Staking::ledger(&11), Some(StakingLedger { stash: 11, total: 1000 + 100, @@ -1334,10 +1353,10 @@ fn bond_extra_and_withdraw_unbonded_works() { // trigger next era. mock::start_active_era(5); - assert_ok!(Staking::withdraw_unbonded(RuntimeOrigin::signed(10), 0)); + assert_ok!(Staking::withdraw_unbonded(RuntimeOrigin::signed(11), 0)); // Now the value is free and the staking ledger is updated. assert_eq!( - Staking::ledger(&10), + Staking::ledger(&11), Some(StakingLedger { stash: 11, total: 100, @@ -1361,7 +1380,7 @@ fn many_unbond_calls_should_work() { // There is only 1 chunk per era, so we need to be in a new era to create a chunk. current_era = i as u32; mock::start_active_era(current_era); - assert_ok!(Staking::unbond(RuntimeOrigin::signed(10), 1)); + assert_ok!(Staking::unbond(RuntimeOrigin::signed(11), 1)); } current_era += 1; @@ -1369,9 +1388,9 @@ fn many_unbond_calls_should_work() { // This chunk is locked at `current_era` through `current_era + 2` (because // `BondingDuration` == 3). - assert_ok!(Staking::unbond(RuntimeOrigin::signed(10), 1)); + assert_ok!(Staking::unbond(RuntimeOrigin::signed(11), 1)); assert_eq!( - Staking::ledger(&10).map(|l| l.unlocking.len()).unwrap(), + Staking::ledger(&11).map(|l| l.unlocking.len()).unwrap(), <::MaxUnlockingChunks as Get>::get() as usize ); @@ -1381,12 +1400,12 @@ fn many_unbond_calls_should_work() { // There is only 1 chunk per era, so we need to be in a new era to create a chunk. current_era = i as u32; mock::start_active_era(current_era); - assert_ok!(Staking::unbond(RuntimeOrigin::signed(10), 1)); + assert_ok!(Staking::unbond(RuntimeOrigin::signed(11), 1)); } // only slots within last `BondingDuration` are filled. assert_eq!( - Staking::ledger(&10).map(|l| l.unlocking.len()).unwrap(), + Staking::ledger(&11).map(|l| l.unlocking.len()).unwrap(), <::BondingDuration>::get() as usize ); }) @@ -1404,7 +1423,7 @@ fn auto_withdraw_may_not_unlock_all_chunks() { // fills the chunking slots for account mock::start_active_era(current_era); - assert_ok!(Staking::unbond(RuntimeOrigin::signed(10), 1)); + assert_ok!(Staking::unbond(RuntimeOrigin::signed(11), 1)); current_era += 1; mock::start_active_era(current_era); @@ -1412,12 +1431,12 @@ fn auto_withdraw_may_not_unlock_all_chunks() { // unbonding will fail because i) there are no remaining chunks and ii) no filled chunks // can be released because current chunk hasn't stay in the queue for at least // `BondingDuration` - assert_noop!(Staking::unbond(RuntimeOrigin::signed(10), 1), Error::::NoMoreChunks); + assert_noop!(Staking::unbond(RuntimeOrigin::signed(11), 1), Error::::NoMoreChunks); // fast-forward a few eras for unbond to be successful with implicit withdraw current_era += 10; mock::start_active_era(current_era); - assert_ok!(Staking::unbond(RuntimeOrigin::signed(10), 1)); + assert_ok!(Staking::unbond(RuntimeOrigin::signed(11), 1)); }) } @@ -1430,7 +1449,7 @@ fn rebond_works() { // * it can re-bond a portion of the funds scheduled to unlock. ExtBuilder::default().nominate(false).build_and_execute(|| { // Set payee to controller. avoids confusion - assert_ok!(Staking::set_payee(RuntimeOrigin::signed(10), RewardDestination::Controller)); + assert_ok!(Staking::set_payee(RuntimeOrigin::signed(11), RewardDestination::Controller)); // Give account 11 some large free balance greater than total let _ = Balances::make_free_balance_be(&11, 1000000); @@ -1438,9 +1457,9 @@ fn rebond_works() { // confirm that 10 is a normal validator and gets paid at the end of the era. mock::start_active_era(1); - // Initial state of 10 + // Initial state of 11 assert_eq!( - Staking::ledger(&10), + Staking::ledger(&11), Some(StakingLedger { stash: 11, total: 1000, @@ -1454,12 +1473,12 @@ fn rebond_works() { assert_eq!(active_era(), 2); // Try to rebond some funds. We get an error since no fund is unbonded. - assert_noop!(Staking::rebond(RuntimeOrigin::signed(10), 500), Error::::NoUnlockChunk); + assert_noop!(Staking::rebond(RuntimeOrigin::signed(11), 500), Error::::NoUnlockChunk); // Unbond almost all of the funds in stash. - Staking::unbond(RuntimeOrigin::signed(10), 900).unwrap(); + Staking::unbond(RuntimeOrigin::signed(11), 900).unwrap(); assert_eq!( - Staking::ledger(&10), + Staking::ledger(&11), Some(StakingLedger { stash: 11, total: 1000, @@ -1470,9 +1489,9 @@ fn rebond_works() { ); // Re-bond all the funds unbonded. - Staking::rebond(RuntimeOrigin::signed(10), 900).unwrap(); + Staking::rebond(RuntimeOrigin::signed(11), 900).unwrap(); assert_eq!( - Staking::ledger(&10), + Staking::ledger(&11), Some(StakingLedger { stash: 11, total: 1000, @@ -1483,9 +1502,9 @@ fn rebond_works() { ); // Unbond almost all of the funds in stash. - Staking::unbond(RuntimeOrigin::signed(10), 900).unwrap(); + Staking::unbond(RuntimeOrigin::signed(11), 900).unwrap(); assert_eq!( - Staking::ledger(&10), + Staking::ledger(&11), Some(StakingLedger { stash: 11, total: 1000, @@ -1496,9 +1515,9 @@ fn rebond_works() { ); // Re-bond part of the funds unbonded. - Staking::rebond(RuntimeOrigin::signed(10), 500).unwrap(); + Staking::rebond(RuntimeOrigin::signed(11), 500).unwrap(); assert_eq!( - Staking::ledger(&10), + Staking::ledger(&11), Some(StakingLedger { stash: 11, total: 1000, @@ -1509,9 +1528,9 @@ fn rebond_works() { ); // Re-bond the remainder of the funds unbonded. - Staking::rebond(RuntimeOrigin::signed(10), 500).unwrap(); + Staking::rebond(RuntimeOrigin::signed(11), 500).unwrap(); assert_eq!( - Staking::ledger(&10), + Staking::ledger(&11), Some(StakingLedger { stash: 11, total: 1000, @@ -1522,11 +1541,11 @@ fn rebond_works() { ); // Unbond parts of the funds in stash. - Staking::unbond(RuntimeOrigin::signed(10), 300).unwrap(); - Staking::unbond(RuntimeOrigin::signed(10), 300).unwrap(); - Staking::unbond(RuntimeOrigin::signed(10), 300).unwrap(); + Staking::unbond(RuntimeOrigin::signed(11), 300).unwrap(); + Staking::unbond(RuntimeOrigin::signed(11), 300).unwrap(); + Staking::unbond(RuntimeOrigin::signed(11), 300).unwrap(); assert_eq!( - Staking::ledger(&10), + Staking::ledger(&11), Some(StakingLedger { stash: 11, total: 1000, @@ -1537,9 +1556,9 @@ fn rebond_works() { ); // Re-bond part of the funds unbonded. - Staking::rebond(RuntimeOrigin::signed(10), 500).unwrap(); + Staking::rebond(RuntimeOrigin::signed(11), 500).unwrap(); assert_eq!( - Staking::ledger(&10), + Staking::ledger(&11), Some(StakingLedger { stash: 11, total: 1000, @@ -1556,7 +1575,7 @@ fn rebond_is_fifo() { // Rebond should proceed by reversing the most recent bond operations. ExtBuilder::default().nominate(false).build_and_execute(|| { // Set payee to controller. avoids confusion - assert_ok!(Staking::set_payee(RuntimeOrigin::signed(10), RewardDestination::Controller)); + assert_ok!(Staking::set_payee(RuntimeOrigin::signed(11), RewardDestination::Controller)); // Give account 11 some large free balance greater than total let _ = Balances::make_free_balance_be(&11, 1000000); @@ -1566,7 +1585,7 @@ fn rebond_is_fifo() { // Initial state of 10 assert_eq!( - Staking::ledger(&10), + Staking::ledger(&11), Some(StakingLedger { stash: 11, total: 1000, @@ -1579,9 +1598,9 @@ fn rebond_is_fifo() { mock::start_active_era(2); // Unbond some of the funds in stash. - Staking::unbond(RuntimeOrigin::signed(10), 400).unwrap(); + Staking::unbond(RuntimeOrigin::signed(11), 400).unwrap(); assert_eq!( - Staking::ledger(&10), + Staking::ledger(&11), Some(StakingLedger { stash: 11, total: 1000, @@ -1594,9 +1613,9 @@ fn rebond_is_fifo() { mock::start_active_era(3); // Unbond more of the funds in stash. - Staking::unbond(RuntimeOrigin::signed(10), 300).unwrap(); + Staking::unbond(RuntimeOrigin::signed(11), 300).unwrap(); assert_eq!( - Staking::ledger(&10), + Staking::ledger(&11), Some(StakingLedger { stash: 11, total: 1000, @@ -1612,9 +1631,9 @@ fn rebond_is_fifo() { mock::start_active_era(4); // Unbond yet more of the funds in stash. - Staking::unbond(RuntimeOrigin::signed(10), 200).unwrap(); + Staking::unbond(RuntimeOrigin::signed(11), 200).unwrap(); assert_eq!( - Staking::ledger(&10), + Staking::ledger(&11), Some(StakingLedger { stash: 11, total: 1000, @@ -1629,9 +1648,9 @@ fn rebond_is_fifo() { ); // Re-bond half of the unbonding funds. - Staking::rebond(RuntimeOrigin::signed(10), 400).unwrap(); + Staking::rebond(RuntimeOrigin::signed(11), 400).unwrap(); assert_eq!( - Staking::ledger(&10), + Staking::ledger(&11), Some(StakingLedger { stash: 11, total: 1000, @@ -1652,7 +1671,7 @@ fn rebond_emits_right_value_in_event() { // and the rebond event emits the actual value rebonded. ExtBuilder::default().nominate(false).build_and_execute(|| { // Set payee to controller. avoids confusion - assert_ok!(Staking::set_payee(RuntimeOrigin::signed(10), RewardDestination::Controller)); + assert_ok!(Staking::set_payee(RuntimeOrigin::signed(11), RewardDestination::Controller)); // Give account 11 some large free balance greater than total let _ = Balances::make_free_balance_be(&11, 1000000); @@ -1661,9 +1680,9 @@ fn rebond_emits_right_value_in_event() { mock::start_active_era(1); // Unbond almost all of the funds in stash. - Staking::unbond(RuntimeOrigin::signed(10), 900).unwrap(); + Staking::unbond(RuntimeOrigin::signed(11), 900).unwrap(); assert_eq!( - Staking::ledger(&10), + Staking::ledger(&11), Some(StakingLedger { stash: 11, total: 1000, @@ -1674,9 +1693,9 @@ fn rebond_emits_right_value_in_event() { ); // Re-bond less than the total - Staking::rebond(RuntimeOrigin::signed(10), 100).unwrap(); + Staking::rebond(RuntimeOrigin::signed(11), 100).unwrap(); assert_eq!( - Staking::ledger(&10), + Staking::ledger(&11), Some(StakingLedger { stash: 11, total: 1000, @@ -1689,9 +1708,9 @@ fn rebond_emits_right_value_in_event() { assert_eq!(*staking_events().last().unwrap(), Event::Bonded { stash: 11, amount: 100 }); // Re-bond way more than available - Staking::rebond(RuntimeOrigin::signed(10), 100_000).unwrap(); + Staking::rebond(RuntimeOrigin::signed(11), 100_000).unwrap(); assert_eq!( - Staking::ledger(&10), + Staking::ledger(&11), Some(StakingLedger { stash: 11, total: 1000, @@ -1747,17 +1766,20 @@ fn reward_to_stake_works() { mock::make_all_reward_payment(0); assert_eq!(Staking::eras_stakers(active_era(), 11).total, 1000); - assert_eq!(Staking::eras_stakers(active_era(), 21).total, 69); + assert_eq!(Staking::eras_stakers(active_era(), 21).total, 2000); let _11_balance = Balances::free_balance(&11); + let _21_balance = Balances::free_balance(&21); + assert_eq!(_11_balance, 1000 + total_payout_0 / 2); + assert_eq!(_21_balance, 2000 + total_payout_0 / 2); // Trigger another new era as the info are frozen before the era start. mock::start_active_era(2); // -- new infos - assert_eq!(Staking::eras_stakers(active_era(), 11).total, 1000 + total_payout_0 / 2); - assert_eq!(Staking::eras_stakers(active_era(), 21).total, 69 + total_payout_0 / 2); + assert_eq!(Staking::eras_stakers(active_era(), 11).total, _11_balance); + assert_eq!(Staking::eras_stakers(active_era(), 21).total, _21_balance); }); } @@ -1768,11 +1790,10 @@ fn reap_stash_works() { .balance_factor(10) .build_and_execute(|| { // given - assert_eq!(Balances::free_balance(10), 10); assert_eq!(Balances::free_balance(11), 10 * 1000); - assert_eq!(Staking::bonded(&11), Some(10)); + assert_eq!(Staking::bonded(&11), Some(11)); - assert!(>::contains_key(&10)); + assert!(>::contains_key(&11)); assert!(>::contains_key(&11)); assert!(>::contains_key(&11)); assert!(>::contains_key(&11)); @@ -1782,16 +1803,11 @@ fn reap_stash_works() { Staking::reap_stash(RuntimeOrigin::signed(20), 11, 0), Error::::FundedTarget ); - // controller or any other account is not reapable - assert_noop!( - Staking::reap_stash(RuntimeOrigin::signed(20), 10, 0), - Error::::NotStash - ); // no easy way to cause an account to go below ED, we tweak their staking ledger // instead. Ledger::::insert( - 10, + 11, StakingLedger { stash: 11, total: 5, @@ -1805,7 +1821,7 @@ fn reap_stash_works() { assert_ok!(Staking::reap_stash(RuntimeOrigin::signed(20), 11, 0)); // then - assert!(!>::contains_key(&10)); + assert!(!>::contains_key(&11)); assert!(!>::contains_key(&11)); assert!(!>::contains_key(&11)); assert!(!>::contains_key(&11)); @@ -1818,14 +1834,14 @@ fn switching_roles() { // minimal overhead. ExtBuilder::default().nominate(false).build_and_execute(|| { // Reset reward destination - for i in &[10, 20] { + for i in &[11, 21] { assert_ok!(Staking::set_payee( RuntimeOrigin::signed(*i), RewardDestination::Controller )); } - assert_eq_uvec!(validator_controllers(), vec![20, 10]); + assert_eq_uvec!(validator_controllers(), vec![21, 11]); // put some money in account that we'll use. for i in 1..7 { @@ -1833,43 +1849,43 @@ fn switching_roles() { } // add 2 nominators - assert_ok!(Staking::bond(RuntimeOrigin::signed(1), 2, 2000, RewardDestination::Controller)); - assert_ok!(Staking::nominate(RuntimeOrigin::signed(2), vec![11, 5])); + assert_ok!(Staking::bond(RuntimeOrigin::signed(1), 2000, RewardDestination::Controller)); + assert_ok!(Staking::nominate(RuntimeOrigin::signed(1), vec![11, 5])); - assert_ok!(Staking::bond(RuntimeOrigin::signed(3), 4, 500, RewardDestination::Controller)); - assert_ok!(Staking::nominate(RuntimeOrigin::signed(4), vec![21, 1])); + assert_ok!(Staking::bond(RuntimeOrigin::signed(3), 500, RewardDestination::Controller)); + assert_ok!(Staking::nominate(RuntimeOrigin::signed(3), vec![21, 1])); // add a new validator candidate - assert_ok!(Staking::bond(RuntimeOrigin::signed(5), 6, 1000, RewardDestination::Controller)); - assert_ok!(Staking::validate(RuntimeOrigin::signed(6), ValidatorPrefs::default())); + assert_ok!(Staking::bond(RuntimeOrigin::signed(5), 1000, RewardDestination::Controller)); + assert_ok!(Staking::validate(RuntimeOrigin::signed(5), ValidatorPrefs::default())); assert_ok!(Session::set_keys( - RuntimeOrigin::signed(6), + RuntimeOrigin::signed(5), SessionKeys { other: 6.into() }, vec![] )); mock::start_active_era(1); - // with current nominators 10 and 5 have the most stake - assert_eq_uvec!(validator_controllers(), vec![6, 10]); + // with current nominators 11 and 5 have the most stake + assert_eq_uvec!(validator_controllers(), vec![5, 11]); // 2 decides to be a validator. Consequences: - assert_ok!(Staking::validate(RuntimeOrigin::signed(2), ValidatorPrefs::default())); + assert_ok!(Staking::validate(RuntimeOrigin::signed(1), ValidatorPrefs::default())); assert_ok!(Session::set_keys( - RuntimeOrigin::signed(2), + RuntimeOrigin::signed(1), SessionKeys { other: 2.into() }, vec![] )); // new stakes: - // 10: 1000 self vote - // 20: 1000 self vote + 250 vote - // 6 : 1000 self vote - // 2 : 2000 self vote + 250 vote. - // Winners: 20 and 2 + // 11: 1000 self vote + // 21: 1000 self vote + 250 vote + // 5 : 1000 self vote + // 1 : 2000 self vote + 250 vote. + // Winners: 21 and 1 mock::start_active_era(2); - assert_eq_uvec!(validator_controllers(), vec![2, 20]); + assert_eq_uvec!(validator_controllers(), vec![1, 21]); }); } @@ -1878,7 +1894,7 @@ fn wrong_vote_is_moot() { ExtBuilder::default() .add_staker( 61, - 60, + 61, 500, StakerStatus::Nominator(vec![ 11, 21, // good votes @@ -1890,7 +1906,7 @@ fn wrong_vote_is_moot() { mock::start_active_era(1); // new validators - assert_eq_uvec!(validator_controllers(), vec![20, 10]); + assert_eq_uvec!(validator_controllers(), vec![21, 11]); // our new voter is taken into account assert!(Staking::eras_stakers(active_era(), 11).others.iter().any(|i| i.who == 61)); @@ -1911,22 +1927,17 @@ fn bond_with_no_staked_value() { .build_and_execute(|| { // Can't bond with 1 assert_noop!( - Staking::bond(RuntimeOrigin::signed(1), 2, 1, RewardDestination::Controller), + Staking::bond(RuntimeOrigin::signed(1), 1, RewardDestination::Controller), Error::::InsufficientBond, ); // bonded with absolute minimum value possible. - assert_ok!(Staking::bond( - RuntimeOrigin::signed(1), - 2, - 5, - RewardDestination::Controller - )); + assert_ok!(Staking::bond(RuntimeOrigin::signed(1), 5, RewardDestination::Controller)); assert_eq!(Balances::locks(&1)[0].amount, 5); // unbonding even 1 will cause all to be unbonded. - assert_ok!(Staking::unbond(RuntimeOrigin::signed(2), 1)); + assert_ok!(Staking::unbond(RuntimeOrigin::signed(1), 1)); assert_eq!( - Staking::ledger(2), + Staking::ledger(1), Some(StakingLedger { stash: 1, active: 0, @@ -1940,15 +1951,15 @@ fn bond_with_no_staked_value() { mock::start_active_era(2); // not yet removed. - assert_ok!(Staking::withdraw_unbonded(RuntimeOrigin::signed(2), 0)); - assert!(Staking::ledger(2).is_some()); + assert_ok!(Staking::withdraw_unbonded(RuntimeOrigin::signed(1), 0)); + assert!(Staking::ledger(1).is_some()); assert_eq!(Balances::locks(&1)[0].amount, 5); mock::start_active_era(3); // poof. Account 1 is removed from the staking system. - assert_ok!(Staking::withdraw_unbonded(RuntimeOrigin::signed(2), 0)); - assert!(Staking::ledger(2).is_none()); + assert_ok!(Staking::withdraw_unbonded(RuntimeOrigin::signed(1), 0)); + assert!(Staking::ledger(1).is_none()); assert_eq!(Balances::locks(&1).len(), 0); }); } @@ -1961,25 +1972,20 @@ fn bond_with_little_staked_value_bounded() { .minimum_validator_count(1) .build_and_execute(|| { // setup - assert_ok!(Staking::chill(RuntimeOrigin::signed(30))); + assert_ok!(Staking::chill(RuntimeOrigin::signed(31))); assert_ok!(Staking::set_payee( - RuntimeOrigin::signed(10), + RuntimeOrigin::signed(11), RewardDestination::Controller )); - let init_balance_2 = Balances::free_balance(&2); - let init_balance_10 = Balances::free_balance(&10); + let init_balance_1 = Balances::free_balance(&1); + let init_balance_11 = Balances::free_balance(&11); // Stingy validator. - assert_ok!(Staking::bond( - RuntimeOrigin::signed(1), - 2, - 1, - RewardDestination::Controller - )); - assert_ok!(Staking::validate(RuntimeOrigin::signed(2), ValidatorPrefs::default())); + assert_ok!(Staking::bond(RuntimeOrigin::signed(1), 1, RewardDestination::Controller)); + assert_ok!(Staking::validate(RuntimeOrigin::signed(1), ValidatorPrefs::default())); assert_ok!(Session::set_keys( - RuntimeOrigin::signed(2), - SessionKeys { other: 2.into() }, + RuntimeOrigin::signed(1), + SessionKeys { other: 1.into() }, vec![] )); @@ -1992,17 +1998,17 @@ fn bond_with_little_staked_value_bounded() { mock::make_all_reward_payment(0); // 2 is elected. - assert_eq_uvec!(validator_controllers(), vec![20, 10, 2]); + assert_eq_uvec!(validator_controllers(), vec![21, 11, 1]); assert_eq!(Staking::eras_stakers(active_era(), 2).total, 0); // Old ones are rewarded. assert_eq_error_rate!( - Balances::free_balance(10), - init_balance_10 + total_payout_0 / 3, + Balances::free_balance(11), + init_balance_11 + total_payout_0 / 3, 1 ); // no rewards paid to 2. This was initial election. - assert_eq!(Balances::free_balance(2), init_balance_2); + assert_eq!(Balances::free_balance(1), init_balance_1); // reward era 2 let total_payout_1 = current_total_payout_for_duration(reward_time_per_era()); @@ -2010,18 +2016,18 @@ fn bond_with_little_staked_value_bounded() { mock::start_active_era(2); mock::make_all_reward_payment(1); - assert_eq_uvec!(validator_controllers(), vec![20, 10, 2]); + assert_eq_uvec!(validator_controllers(), vec![21, 11, 1]); assert_eq!(Staking::eras_stakers(active_era(), 2).total, 0); // 2 is now rewarded. assert_eq_error_rate!( - Balances::free_balance(2), - init_balance_2 + total_payout_1 / 3, + Balances::free_balance(1), + init_balance_1 + total_payout_1 / 3, 1 ); assert_eq_error_rate!( - Balances::free_balance(&10), - init_balance_10 + total_payout_0 / 3 + total_payout_1 / 3, + Balances::free_balance(&11), + init_balance_11 + total_payout_0 / 3 + total_payout_1 / 3, 2, ); }); @@ -2038,7 +2044,7 @@ fn bond_with_duplicate_vote_should_be_ignored_by_election_provider() { // ensure all have equal stake. assert_eq!( >::iter() - .map(|(v, _)| (v, Staking::ledger(v - 1).unwrap().total)) + .map(|(v, _)| (v, Staking::ledger(v).unwrap().total)) .collect::>(), vec![(31, 1000), (21, 1000), (11, 1000)], ); @@ -2053,19 +2059,17 @@ fn bond_with_duplicate_vote_should_be_ignored_by_election_provider() { assert_ok!(Staking::bond( RuntimeOrigin::signed(1), - 2, 1000, RewardDestination::Controller )); - assert_ok!(Staking::nominate(RuntimeOrigin::signed(2), vec![11, 11, 11, 21, 31])); + assert_ok!(Staking::nominate(RuntimeOrigin::signed(1), vec![11, 11, 11, 21, 31])); assert_ok!(Staking::bond( RuntimeOrigin::signed(3), - 4, 1000, RewardDestination::Controller )); - assert_ok!(Staking::nominate(RuntimeOrigin::signed(4), vec![21, 31])); + assert_ok!(Staking::nominate(RuntimeOrigin::signed(3), vec![21, 31])); // winners should be 21 and 31. Otherwise this election is taking duplicates into // account. @@ -2092,7 +2096,7 @@ fn bond_with_duplicate_vote_should_be_ignored_by_election_provider_elected() { // ensure all have equal stake. assert_eq!( >::iter() - .map(|(v, _)| (v, Staking::ledger(v - 1).unwrap().total)) + .map(|(v, _)| (v, Staking::ledger(v).unwrap().total)) .collect::>(), vec![(31, 1000), (21, 1000), (11, 1000)], ); @@ -2108,19 +2112,17 @@ fn bond_with_duplicate_vote_should_be_ignored_by_election_provider_elected() { assert_ok!(Staking::bond( RuntimeOrigin::signed(1), - 2, 1000, RewardDestination::Controller )); - assert_ok!(Staking::nominate(RuntimeOrigin::signed(2), vec![11, 11, 11, 21])); + assert_ok!(Staking::nominate(RuntimeOrigin::signed(1), vec![11, 11, 11, 21])); assert_ok!(Staking::bond( RuntimeOrigin::signed(3), - 4, 1000, RewardDestination::Controller )); - assert_ok!(Staking::nominate(RuntimeOrigin::signed(4), vec![21])); + assert_ok!(Staking::nominate(RuntimeOrigin::signed(3), vec![21])); // winners should be 21 and 11. let supports = ::ElectionProvider::elect().unwrap(); @@ -2155,15 +2157,15 @@ fn phragmen_should_not_overflow() { let _ = Staking::chill(RuntimeOrigin::signed(10)); let _ = Staking::chill(RuntimeOrigin::signed(20)); - bond_validator(3, 2, Votes::max_value() as Balance); - bond_validator(5, 4, Votes::max_value() as Balance); + bond_validator(3, Votes::max_value() as Balance); + bond_validator(5, Votes::max_value() as Balance); - bond_nominator(7, 6, Votes::max_value() as Balance, vec![3, 5]); - bond_nominator(9, 8, Votes::max_value() as Balance, vec![3, 5]); + bond_nominator(7, Votes::max_value() as Balance, vec![3, 5]); + bond_nominator(9, Votes::max_value() as Balance, vec![3, 5]); mock::start_active_era(1); - assert_eq_uvec!(validator_controllers(), vec![4, 2]); + assert_eq_uvec!(validator_controllers(), vec![3, 5]); // We can safely convert back to values within [u64, u128]. assert!(Staking::eras_stakers(active_era(), 3).total > Votes::max_value() as Balance); @@ -2202,8 +2204,7 @@ fn reward_validator_slashing_validator_does_not_overflow() { let _ = Balances::make_free_balance_be(&2, stake); // only slashes out of bonded stake are applied. without this line, it is 0. - Staking::bond(RuntimeOrigin::signed(2), 20000, stake - 1, RewardDestination::default()) - .unwrap(); + Staking::bond(RuntimeOrigin::signed(2), stake - 1, RewardDestination::default()).unwrap(); // Override exposure of 11 ErasStakers::::insert( 0, @@ -2274,7 +2275,7 @@ fn unbonded_balance_is_not_slashable() { // total amount staked is slashable. assert_eq!(Staking::slashable_balance_of(&11), 1000); - assert_ok!(Staking::unbond(RuntimeOrigin::signed(10), 800)); + assert_ok!(Staking::unbond(RuntimeOrigin::signed(11), 800)); // only the active portion. assert_eq!(Staking::slashable_balance_of(&11), 200); @@ -2411,7 +2412,7 @@ fn slash_in_old_span_does_not_deselect() { mock::start_active_era(2); - Staking::validate(RuntimeOrigin::signed(10), Default::default()).unwrap(); + Staking::validate(RuntimeOrigin::signed(11), Default::default()).unwrap(); assert_eq!(Staking::force_era(), Forcing::NotForcing); assert!(>::contains_key(11)); assert!(!Session::validators().contains(&11)); @@ -2452,7 +2453,7 @@ fn slash_in_old_span_does_not_deselect() { assert!(Validators::::iter().any(|(stash, _)| stash == 11)); // but it's disabled - assert!(is_disabled(10)); + assert!(is_disabled(11)); // and we are still forcing a new era assert_eq!(Staking::force_era(), Forcing::ForceNew); }); @@ -2836,7 +2837,7 @@ fn slashes_are_summed_across_spans() { assert_eq!(Balances::free_balance(21), 1900); // 21 has been force-chilled. re-signal intent to validate. - Staking::validate(RuntimeOrigin::signed(20), Default::default()).unwrap(); + Staking::validate(RuntimeOrigin::signed(21), Default::default()).unwrap(); mock::start_active_era(4); @@ -2967,8 +2968,8 @@ fn retroactive_deferred_slashes_one_before() { // unbond at slash era. mock::start_active_era(2); - assert_ok!(Staking::chill(RuntimeOrigin::signed(10))); - assert_ok!(Staking::unbond(RuntimeOrigin::signed(10), 100)); + assert_ok!(Staking::chill(RuntimeOrigin::signed(11))); + assert_ok!(Staking::unbond(RuntimeOrigin::signed(11), 100)); mock::start_active_era(3); System::reset_events(); @@ -2981,7 +2982,7 @@ fn retroactive_deferred_slashes_one_before() { mock::start_active_era(4); - assert_eq!(Staking::ledger(10).unwrap().total, 1000); + assert_eq!(Staking::ledger(11).unwrap().total, 1000); // slash happens after the next line. mock::start_active_era(5); @@ -2996,9 +2997,9 @@ fn retroactive_deferred_slashes_one_before() { )); // their ledger has already been slashed. - assert_eq!(Staking::ledger(10).unwrap().total, 900); - assert_ok!(Staking::unbond(RuntimeOrigin::signed(10), 1000)); - assert_eq!(Staking::ledger(10).unwrap().total, 900); + assert_eq!(Staking::ledger(11).unwrap().total, 900); + assert_ok!(Staking::unbond(RuntimeOrigin::signed(11), 1000)); + assert_eq!(Staking::ledger(11).unwrap().total, 900); }) } @@ -3023,14 +3024,14 @@ fn staker_cannot_bail_deferred_slash() { ); // now we chill - assert_ok!(Staking::chill(RuntimeOrigin::signed(100))); - assert_ok!(Staking::unbond(RuntimeOrigin::signed(100), 500)); + assert_ok!(Staking::chill(RuntimeOrigin::signed(101))); + assert_ok!(Staking::unbond(RuntimeOrigin::signed(101), 500)); assert_eq!(Staking::current_era().unwrap(), 1); assert_eq!(active_era(), 1); assert_eq!( - Ledger::::get(100).unwrap(), + Ledger::::get(101).unwrap(), StakingLedger { active: 0, total: 500, @@ -3060,10 +3061,10 @@ fn staker_cannot_bail_deferred_slash() { // and cannot yet unbond: assert_storage_noop!(assert!( - Staking::withdraw_unbonded(RuntimeOrigin::signed(100), 0).is_ok() + Staking::withdraw_unbonded(RuntimeOrigin::signed(101), 0).is_ok() )); assert_eq!( - Ledger::::get(100).unwrap().unlocking.into_inner(), + Ledger::::get(101).unwrap().unlocking.into_inner(), vec![UnlockChunk { era: 4u32, value: 500 as Balance }], ); @@ -3270,7 +3271,7 @@ fn slash_kicks_validators_not_nominators_and_disables_nominator_for_kicked_valid assert!(Validators::::iter().all(|(stash, _)| stash != 11)); // actually re-bond the slashed validator - assert_ok!(Staking::validate(RuntimeOrigin::signed(10), Default::default())); + assert_ok!(Staking::validate(RuntimeOrigin::signed(11), Default::default())); mock::start_active_era(2); let exposure_11 = Staking::eras_stakers(active_era(), &11); @@ -3336,9 +3337,9 @@ fn non_slashable_offence_doesnt_disable_validator() { ); // the offence for validator 10 wasn't slashable so it wasn't disabled - assert!(!is_disabled(10)); + assert!(!is_disabled(11)); // whereas validator 20 gets disabled - assert!(is_disabled(20)); + assert!(is_disabled(21)); }); } @@ -3399,9 +3400,9 @@ fn slashing_independent_of_disabling_validator() { ); // the offence for validator 10 was explicitly disabled - assert!(is_disabled(10)); - // whereas validator 20 is explicitly not disabled - assert!(!is_disabled(20)); + assert!(is_disabled(11)); + // whereas validator 21 is explicitly not disabled + assert!(!is_disabled(21)); }); } @@ -3475,18 +3476,18 @@ fn disabled_validators_are_kept_disabled_for_whole_era() { // nominations are not updated. assert_eq!(Staking::nominators(101).unwrap().targets, vec![11, 21]); - // validator 10 should not be disabled since the offence wasn't slashable - assert!(!is_disabled(10)); - // validator 20 gets disabled since it got slashed - assert!(is_disabled(20)); + // validator 11 should not be disabled since the offence wasn't slashable + assert!(!is_disabled(11)); + // validator 21 gets disabled since it got slashed + assert!(is_disabled(21)); advance_session(); // disabled validators should carry-on through all sessions in the era - assert!(!is_disabled(10)); - assert!(is_disabled(20)); + assert!(!is_disabled(11)); + assert!(is_disabled(21)); - // validator 10 should now get disabled + // validator 11 should now get disabled on_offence_now( &[OffenceDetails { offender: (11, exposure_11.clone()), reporters: vec![] }], &[Perbill::from_percent(25)], @@ -3498,14 +3499,14 @@ fn disabled_validators_are_kept_disabled_for_whole_era() { advance_session(); // and both are disabled in the last session of the era - assert!(is_disabled(10)); - assert!(is_disabled(20)); + assert!(is_disabled(11)); + assert!(is_disabled(21)); mock::start_active_era(2); // when a new era starts disabled validators get cleared - assert!(!is_disabled(10)); - assert!(!is_disabled(20)); + assert!(!is_disabled(11)); + assert!(!is_disabled(21)); }); } @@ -3519,11 +3520,11 @@ fn claim_reward_at_the_last_era_and_no_double_claim_and_invalid_claim() { // Consumed weight for all payout_stakers dispatches that fail let err_weight = ::WeightInfo::payout_stakers_alive_staked(0); - let init_balance_10 = Balances::total_balance(&10); - let init_balance_100 = Balances::total_balance(&100); + let init_balance_11 = Balances::total_balance(&11); + let init_balance_101 = Balances::total_balance(&101); - let part_for_10 = Perbill::from_rational::(1000, 1125); - let part_for_100 = Perbill::from_rational::(125, 1125); + let part_for_11 = Perbill::from_rational::(1000, 1125); + let part_for_101 = Perbill::from_rational::(125, 1125); // Check state Payee::::insert(11, RewardDestination::Controller); @@ -3583,12 +3584,12 @@ fn claim_reward_at_the_last_era_and_no_double_claim_and_invalid_claim() { // only era 1 and 2 can be rewarded. assert_eq!( - Balances::total_balance(&10), - init_balance_10 + part_for_10 * (total_payout_1 + total_payout_2), + Balances::total_balance(&11), + init_balance_11 + part_for_11 * (total_payout_1 + total_payout_2), ); assert_eq!( - Balances::total_balance(&100), - init_balance_100 + part_for_100 * (total_payout_1 + total_payout_2), + Balances::total_balance(&101), + init_balance_101 + part_for_101 * (total_payout_1 + total_payout_2), ); }); } @@ -3683,16 +3684,14 @@ fn test_max_nominator_rewarded_per_validator_and_cant_steal_someone_else_reward( ExtBuilder::default().build_and_execute(|| { for i in 0..=<::MaxNominatorRewardedPerValidator as Get<_>>::get() { let stash = 10_000 + i as AccountId; - let controller = 20_000 + i as AccountId; let balance = 10_000 + i as Balance; Balances::make_free_balance_be(&stash, balance); assert_ok!(Staking::bond( RuntimeOrigin::signed(stash), - controller, balance, RewardDestination::Stash )); - assert_ok!(Staking::nominate(RuntimeOrigin::signed(controller), vec![11])); + assert_ok!(Staking::nominate(RuntimeOrigin::signed(stash), vec![11])); } mock::start_active_era(1); @@ -3727,13 +3726,13 @@ fn test_payout_stakers() { // Track the exposure of the validator and the nominators that will get paid out. let mut payout_exposure = balance; // Create a validator: - bond_validator(11, 10, balance); // Default(64) + bond_validator(11, balance); // Default(64) assert_eq!(Validators::::count(), 1); // Create nominators, targeting stash of validators for i in 0..100 { let bond_amount = balance + i as Balance; - bond_nominator(1000 + i, 100 + i, bond_amount, vec![11]); + bond_nominator(1000 + i, bond_amount, vec![11]); total_exposure += bond_amount; if i >= 36 { payout_exposure += bond_amount; @@ -3762,18 +3761,18 @@ fn test_payout_stakers() { // Top 64 nominators of validator 11 automatically paid out, including the validator // Validator payout goes to controller. - assert!(Balances::free_balance(&10) > balance); + assert!(Balances::free_balance(&11) > balance); for i in 36..100 { - assert!(Balances::free_balance(&(100 + i)) > balance + i as Balance); + assert!(Balances::free_balance(&(1000 + i)) > balance + i as Balance); } // The bottom 36 do not for i in 0..36 { - assert_eq!(Balances::free_balance(&(100 + i)), balance + i as Balance); + assert_eq!(Balances::free_balance(&(1000 + i)), balance + i as Balance); } // We track rewards in `claimed_rewards` vec assert_eq!( - Staking::ledger(&10), + Staking::ledger(&11), Some(StakingLedger { stash: 11, total: 1000, @@ -3804,7 +3803,7 @@ fn test_payout_stakers() { // We track rewards in `claimed_rewards` vec assert_eq!( - Staking::ledger(&10), + Staking::ledger(&11), Some(StakingLedger { stash: 11, total: 1000, @@ -3837,7 +3836,7 @@ fn test_payout_stakers() { expected_last_reward_era )); assert_eq!( - Staking::ledger(&10), + Staking::ledger(&11), Some(StakingLedger { stash: 11, total: 1000, @@ -3852,7 +3851,7 @@ fn test_payout_stakers() { assert_ok!(Staking::payout_stakers(RuntimeOrigin::signed(1337), 11, 23)); assert_ok!(Staking::payout_stakers(RuntimeOrigin::signed(1337), 11, 42)); assert_eq!( - Staking::ledger(&10), + Staking::ledger(&11), Some(StakingLedger { stash: 11, total: 1000, @@ -3879,11 +3878,11 @@ fn payout_stakers_handles_basic_errors() { // Same setup as the test above let balance = 1000; - bond_validator(11, 10, balance); // Default(64) + bond_validator(11, balance); // Default(64) // Create nominators, targeting stash for i in 0..100 { - bond_nominator(1000 + i, 100 + i, balance + i as Balance, vec![11]); + bond_nominator(1000 + i, balance + i as Balance, vec![11]); } mock::start_active_era(1); @@ -3975,7 +3974,7 @@ fn payout_stakers_handles_weight_refund() { assert!(max_nom_rewarded_weight.any_gt(half_max_nom_rewarded_weight)); let balance = 1000; - bond_validator(11, 10, balance); + bond_validator(11, balance); // Era 1 start_active_era(1); @@ -3986,7 +3985,7 @@ fn payout_stakers_handles_weight_refund() { // Add some `half_max_nom_rewarded` nominators who will start backing the validator in the // next era. for i in 0..half_max_nom_rewarded { - bond_nominator((1000 + i).into(), (100 + i).into(), balance + i as Balance, vec![11]); + bond_nominator((1000 + i).into(), balance + i as Balance, vec![11]); } // Era 2 @@ -4028,7 +4027,7 @@ fn payout_stakers_handles_weight_refund() { // Add enough nominators so that we are at the limit. They will be active nominators // in the next era. for i in half_max_nom_rewarded..max_nom_rewarded { - bond_nominator((1000 + i).into(), (100 + i).into(), balance + i as Balance, vec![11]); + bond_nominator((1000 + i).into(), balance + i as Balance, vec![11]); } // Era 5 @@ -4062,9 +4061,9 @@ fn payout_stakers_handles_weight_refund() { fn bond_during_era_correctly_populates_claimed_rewards() { ExtBuilder::default().has_stakers(false).build_and_execute(|| { // Era = None - bond_validator(9, 8, 1000); + bond_validator(9, 1000); assert_eq!( - Staking::ledger(&8), + Staking::ledger(&9), Some(StakingLedger { stash: 9, total: 1000, @@ -4074,9 +4073,9 @@ fn bond_during_era_correctly_populates_claimed_rewards() { }) ); mock::start_active_era(5); - bond_validator(11, 10, 1000); + bond_validator(11, 1000); assert_eq!( - Staking::ledger(&10), + Staking::ledger(&11), Some(StakingLedger { stash: 11, total: 1000, @@ -4090,9 +4089,9 @@ fn bond_during_era_correctly_populates_claimed_rewards() { let current_era = 99; let last_reward_era = 99 - HistoryDepth::get(); mock::start_active_era(current_era); - bond_validator(13, 12, 1000); + bond_validator(13, 1000); assert_eq!( - Staking::ledger(&12), + Staking::ledger(&13), Some(StakingLedger { stash: 13, total: 1000, @@ -4181,24 +4180,31 @@ fn payout_creates_controller() { ExtBuilder::default().has_stakers(false).build_and_execute(|| { let balance = 1000; // Create a validator: - bond_validator(11, 10, balance); + bond_validator(11, balance); - // Create a stash/controller pair - bond_nominator(1234, 1337, 100, vec![11]); + // create a stash/controller pair and nominate + let (stash, controller) = testing_utils::create_unique_stash_controller::( + 0, + 100, + RewardDestination::Controller, + false, + ) + .unwrap(); + assert_ok!(Staking::nominate(RuntimeOrigin::signed(controller), vec![11])); // kill controller - assert_ok!(Balances::transfer_allow_death(RuntimeOrigin::signed(1337), 1234, 100)); - assert_eq!(Balances::free_balance(1337), 0); + assert_ok!(Balances::transfer_allow_death(RuntimeOrigin::signed(controller), stash, 100)); + assert_eq!(Balances::free_balance(controller), 0); mock::start_active_era(1); Staking::reward_by_ids(vec![(11, 1)]); // compute and ensure the reward amount is greater than zero. let _ = current_total_payout_for_duration(reward_time_per_era()); mock::start_active_era(2); - assert_ok!(Staking::payout_stakers(RuntimeOrigin::signed(1337), 11, 1)); + assert_ok!(Staking::payout_stakers(RuntimeOrigin::signed(controller), 11, 1)); // Controller is created - assert!(Balances::free_balance(1337) > 0); + assert!(Balances::free_balance(controller) > 0); }) } @@ -4207,13 +4213,13 @@ fn payout_to_any_account_works() { ExtBuilder::default().has_stakers(false).build_and_execute(|| { let balance = 1000; // Create a validator: - bond_validator(11, 10, balance); // Default(64) + bond_validator(11, balance); // Default(64) // Create a stash/controller pair - bond_nominator(1234, 1337, 100, vec![11]); + bond_nominator(1234, 100, vec![11]); // Update payout location - assert_ok!(Staking::set_payee(RuntimeOrigin::signed(1337), RewardDestination::Account(42))); + assert_ok!(Staking::set_payee(RuntimeOrigin::signed(1234), RewardDestination::Account(42))); // Reward Destination account doesn't exist assert_eq!(Balances::free_balance(42), 0); @@ -4335,38 +4341,38 @@ fn session_buffering_no_offset() { #[test] fn cannot_rebond_to_lower_than_ed() { ExtBuilder::default() - .existential_deposit(10) - .balance_factor(10) + .existential_deposit(11) + .balance_factor(11) .build_and_execute(|| { // initial stuff. assert_eq!( - Staking::ledger(&20).unwrap(), + Staking::ledger(&21).unwrap(), StakingLedger { stash: 21, - total: 10 * 1000, - active: 10 * 1000, + total: 11 * 1000, + active: 11 * 1000, unlocking: Default::default(), claimed_rewards: bounded_vec![], } ); // unbond all of it. must be chilled first. - assert_ok!(Staking::chill(RuntimeOrigin::signed(20))); - assert_ok!(Staking::unbond(RuntimeOrigin::signed(20), 10 * 1000)); + assert_ok!(Staking::chill(RuntimeOrigin::signed(21))); + assert_ok!(Staking::unbond(RuntimeOrigin::signed(21), 11 * 1000)); assert_eq!( - Staking::ledger(&20).unwrap(), + Staking::ledger(&21).unwrap(), StakingLedger { stash: 21, - total: 10 * 1000, + total: 11 * 1000, active: 0, - unlocking: bounded_vec![UnlockChunk { value: 10 * 1000, era: 3 }], + unlocking: bounded_vec![UnlockChunk { value: 11 * 1000, era: 3 }], claimed_rewards: bounded_vec![], } ); // now bond a wee bit more assert_noop!( - Staking::rebond(RuntimeOrigin::signed(20), 5), + Staking::rebond(RuntimeOrigin::signed(21), 5), Error::::InsufficientBond ); }) @@ -4375,31 +4381,31 @@ fn cannot_rebond_to_lower_than_ed() { #[test] fn cannot_bond_extra_to_lower_than_ed() { ExtBuilder::default() - .existential_deposit(10) - .balance_factor(10) + .existential_deposit(11) + .balance_factor(11) .build_and_execute(|| { // initial stuff. assert_eq!( - Staking::ledger(&20).unwrap(), + Staking::ledger(&21).unwrap(), StakingLedger { stash: 21, - total: 10 * 1000, - active: 10 * 1000, + total: 11 * 1000, + active: 11 * 1000, unlocking: Default::default(), claimed_rewards: bounded_vec![], } ); // unbond all of it. must be chilled first. - assert_ok!(Staking::chill(RuntimeOrigin::signed(20))); - assert_ok!(Staking::unbond(RuntimeOrigin::signed(20), 10 * 1000)); + assert_ok!(Staking::chill(RuntimeOrigin::signed(21))); + assert_ok!(Staking::unbond(RuntimeOrigin::signed(21), 11 * 1000)); assert_eq!( - Staking::ledger(&20).unwrap(), + Staking::ledger(&21).unwrap(), StakingLedger { stash: 21, - total: 10 * 1000, + total: 11 * 1000, active: 0, - unlocking: bounded_vec![UnlockChunk { value: 10 * 1000, era: 3 }], + unlocking: bounded_vec![UnlockChunk { value: 11 * 1000, era: 3 }], claimed_rewards: bounded_vec![], } ); @@ -4421,7 +4427,7 @@ fn do_not_die_when_active_is_ed() { .build_and_execute(|| { // given assert_eq!( - Staking::ledger(&20).unwrap(), + Staking::ledger(&21).unwrap(), StakingLedger { stash: 21, total: 1000 * ed, @@ -4432,13 +4438,13 @@ fn do_not_die_when_active_is_ed() { ); // when unbond all of it except ed. - assert_ok!(Staking::unbond(RuntimeOrigin::signed(20), 999 * ed)); + assert_ok!(Staking::unbond(RuntimeOrigin::signed(21), 999 * ed)); start_active_era(3); - assert_ok!(Staking::withdraw_unbonded(RuntimeOrigin::signed(20), 100)); + assert_ok!(Staking::withdraw_unbonded(RuntimeOrigin::signed(21), 100)); // then assert_eq!( - Staking::ledger(&20).unwrap(), + Staking::ledger(&21).unwrap(), StakingLedger { stash: 21, total: ed, @@ -4501,33 +4507,115 @@ mod election_data_provider { fn set_minimum_active_stake_is_correct() { ExtBuilder::default() .nominate(false) - .add_staker(61, 60, 2_000, StakerStatus::::Nominator(vec![21])) - .add_staker(71, 70, 10, StakerStatus::::Nominator(vec![21])) - .add_staker(81, 80, 50, StakerStatus::::Nominator(vec![21])) + .add_staker(61, 61, 2_000, StakerStatus::::Nominator(vec![21])) + .add_staker(71, 71, 10, StakerStatus::::Nominator(vec![21])) + .add_staker(81, 81, 50, StakerStatus::::Nominator(vec![21])) .build_and_execute(|| { - assert_ok!(::electing_voters(None)); + // default bounds are unbounded. + assert_ok!(::electing_voters( + DataProviderBounds::default() + )); assert_eq!(MinimumActiveStake::::get(), 10); // remove staker with lower bond by limiting the number of voters and check // `MinimumActiveStake` again after electing voters. - assert_ok!(::electing_voters(Some(5))); + let bounds = ElectionBoundsBuilder::default().voters_count(5.into()).build(); + assert_ok!(::electing_voters(bounds.voters)); assert_eq!(MinimumActiveStake::::get(), 50); }); } #[test] - fn set_minimum_active_stake_zero_correct() { + fn set_minimum_active_stake_lower_bond_works() { + // if there are no voters, minimum active stake is zero (should not happen). ExtBuilder::default().has_stakers(false).build_and_execute(|| { - assert_ok!(::electing_voters(None)); + // default bounds are unbounded. + assert_ok!(::electing_voters( + DataProviderBounds::default() + )); + assert_eq!(::VoterList::count(), 0); assert_eq!(MinimumActiveStake::::get(), 0); }); + + // lower non-zero active stake below `MinNominatorBond` is the minimum active stake if + // it is selected as part of the npos voters. + ExtBuilder::default().has_stakers(true).nominate(true).build_and_execute(|| { + assert_eq!(MinNominatorBond::::get(), 1); + assert_eq!(::VoterList::count(), 4); + + assert_ok!(Staking::bond(RuntimeOrigin::signed(4), 5, Default::default(),)); + assert_ok!(Staking::nominate(RuntimeOrigin::signed(4), vec![1])); + assert_eq!(::VoterList::count(), 5); + + let voters_before = + ::electing_voters(DataProviderBounds::default()) + .unwrap(); + assert_eq!(MinimumActiveStake::::get(), 5); + + // update minimum nominator bond. + MinNominatorBond::::set(10); + assert_eq!(MinNominatorBond::::get(), 10); + // voter list still considers nominator 4 for voting, even though its active stake is + // lower than `MinNominatorBond`. + assert_eq!(::VoterList::count(), 5); + + let voters = + ::electing_voters(DataProviderBounds::default()) + .unwrap(); + assert_eq!(voters_before, voters); + + // minimum active stake is lower than `MinNominatorBond`. + assert_eq!(MinimumActiveStake::::get(), 5); + }); + } + + #[test] + fn set_minimum_active_bond_corrupt_state() { + ExtBuilder::default() + .has_stakers(true) + .nominate(true) + .add_staker(61, 61, 2_000, StakerStatus::::Nominator(vec![21])) + .build_and_execute(|| { + assert_eq!(Staking::weight_of(&101), 500); + let voters = ::electing_voters( + DataProviderBounds::default(), + ) + .unwrap(); + assert_eq!(voters.len(), 5); + assert_eq!(MinimumActiveStake::::get(), 500); + + assert_ok!(Staking::unbond(RuntimeOrigin::signed(101), 200)); + start_active_era(10); + assert_ok!(Staking::unbond(RuntimeOrigin::signed(101), 100)); + start_active_era(20); + + // corrupt ledger state by lowering max unlocking chunks bounds. + MaxUnlockingChunks::set(1); + + let voters = ::electing_voters( + DataProviderBounds::default(), + ) + .unwrap(); + // number of returned voters decreases since ledger entry of stash 101 is now + // corrupt. + assert_eq!(voters.len(), 4); + // minimum active stake does not take into consideration the corrupt entry. + assert_eq!(MinimumActiveStake::::get(), 2_000); + + // voter weight of corrupted ledger entry is 0. + assert_eq!(Staking::weight_of(&101), 0); + + // reset max unlocking chunks for try_state to pass. + MaxUnlockingChunks::set(32); + }) } #[test] fn voters_include_self_vote() { ExtBuilder::default().nominate(false).build_and_execute(|| { + // default bounds are unbounded. assert!(>::iter().map(|(x, _)| x).all(|v| Staking::electing_voters( - None + DataProviderBounds::default() ) .unwrap() .into_iter() @@ -4535,39 +4623,11 @@ mod election_data_provider { }) } - #[test] - fn respects_snapshot_len_limits() { - ExtBuilder::default() - .set_status(41, StakerStatus::Validator) - .build_and_execute(|| { - // sum of all nominators who'd be voters (1), plus the self-votes (4). - assert_eq!(::VoterList::count(), 5); - - // if limits is less.. - assert_eq!(Staking::electing_voters(Some(1)).unwrap().len(), 1); - - // if limit is equal.. - assert_eq!(Staking::electing_voters(Some(5)).unwrap().len(), 5); - - // if limit is more. - assert_eq!(Staking::electing_voters(Some(55)).unwrap().len(), 5); - - // if target limit is more.. - assert_eq!(Staking::electable_targets(Some(6)).unwrap().len(), 4); - assert_eq!(Staking::electable_targets(Some(4)).unwrap().len(), 4); - - // if target limit is less, then we return an error. - assert_eq!( - Staking::electable_targets(Some(1)).unwrap_err(), - "Target snapshot too big" - ); - }); - } - // Tests the criteria that in `ElectionDataProvider::voters` function, we try to get at most // `maybe_max_len` voters, and if some of them end up being skipped, we iterate at most `2 * // maybe_max_len`. #[test] + #[should_panic] fn only_iterates_max_2_times_max_allowed_len() { ExtBuilder::default() .nominate(false) @@ -4575,30 +4635,31 @@ mod election_data_provider { // ppl, but then lower the MaxNomination limit. .add_staker( 61, - 60, + 61, 2_000, StakerStatus::::Nominator(vec![21, 22, 23, 24, 25]), ) .add_staker( 71, - 70, + 71, 2_000, StakerStatus::::Nominator(vec![21, 22, 23, 24, 25]), ) .add_staker( 81, - 80, + 81, 2_000, StakerStatus::::Nominator(vec![21, 22, 23, 24, 25]), ) .build_and_execute(|| { + let bounds_builder = ElectionBoundsBuilder::default(); // all voters ordered by stake, assert_eq!( ::VoterList::iter().collect::>(), vec![61, 71, 81, 11, 21, 31] ); - MaxNominations::set(2); + AbsoluteMaxNominations::set(2); // we want 2 voters now, and in maximum we allow 4 iterations. This is what happens: // 61 is pruned; @@ -4607,7 +4668,7 @@ mod election_data_provider { // 11 is taken; // we finish since the 2x limit is reached. assert_eq!( - Staking::electing_voters(Some(2)) + Staking::electing_voters(bounds_builder.voters_count(2.into()).build().voters) .unwrap() .iter() .map(|(stash, _, _)| stash) @@ -4618,6 +4679,189 @@ mod election_data_provider { }); } + #[test] + fn respects_snapshot_count_limits() { + ExtBuilder::default() + .set_status(41, StakerStatus::Validator) + .build_and_execute(|| { + // sum of all nominators who'd be voters (1), plus the self-votes (4). + assert_eq!(::VoterList::count(), 5); + + let bounds_builder = ElectionBoundsBuilder::default(); + + // if voter count limit is less.. + assert_eq!( + Staking::electing_voters(bounds_builder.voters_count(1.into()).build().voters) + .unwrap() + .len(), + 1 + ); + + // if voter count limit is equal.. + assert_eq!( + Staking::electing_voters(bounds_builder.voters_count(5.into()).build().voters) + .unwrap() + .len(), + 5 + ); + + // if voter count limit is more. + assert_eq!( + Staking::electing_voters(bounds_builder.voters_count(55.into()).build().voters) + .unwrap() + .len(), + 5 + ); + + // if target count limit is more.. + assert_eq!( + Staking::electable_targets( + bounds_builder.targets_count(6.into()).build().targets + ) + .unwrap() + .len(), + 4 + ); + + // if target count limit is equal.. + assert_eq!( + Staking::electable_targets( + bounds_builder.targets_count(4.into()).build().targets + ) + .unwrap() + .len(), + 4 + ); + + // if target limit count is less, then we return an error. + assert_eq!( + Staking::electable_targets( + bounds_builder.targets_count(1.into()).build().targets + ) + .unwrap_err(), + "Target snapshot too big" + ); + }); + } + + #[test] + fn respects_snapshot_size_limits() { + ExtBuilder::default().build_and_execute(|| { + // voters: set size bounds that allows only for 1 voter. + let bounds = ElectionBoundsBuilder::default().voters_size(26.into()).build(); + let elected = Staking::electing_voters(bounds.voters).unwrap(); + assert!(elected.encoded_size() == 26 as usize); + let prev_len = elected.len(); + + // larger size bounds means more quota for voters. + let bounds = ElectionBoundsBuilder::default().voters_size(100.into()).build(); + let elected = Staking::electing_voters(bounds.voters).unwrap(); + assert!(elected.encoded_size() <= 100 as usize); + assert!(elected.len() > 1 && elected.len() > prev_len); + + // targets: set size bounds that allows for only one target to fit in the snapshot. + let bounds = ElectionBoundsBuilder::default().targets_size(10.into()).build(); + let elected = Staking::electable_targets(bounds.targets).unwrap(); + assert!(elected.encoded_size() == 9 as usize); + let prev_len = elected.len(); + + // larger size bounds means more space for targets. + let bounds = ElectionBoundsBuilder::default().targets_size(100.into()).build(); + let elected = Staking::electable_targets(bounds.targets).unwrap(); + assert!(elected.encoded_size() <= 100 as usize); + assert!(elected.len() > 1 && elected.len() > prev_len); + }); + } + + #[test] + fn nomination_quota_checks_at_nominate_works() { + ExtBuilder::default().nominate(false).build_and_execute(|| { + // stash bond of 222 has a nomination quota of 2 targets. + bond(61, 222); + assert_eq!(Staking::api_nominations_quota(222), 2); + + // nominating with targets below the nomination quota works. + assert_ok!(Staking::nominate(RuntimeOrigin::signed(61), vec![11])); + assert_ok!(Staking::nominate(RuntimeOrigin::signed(61), vec![11, 12])); + + // nominating with targets above the nomination quota returns error. + assert_noop!( + Staking::nominate(RuntimeOrigin::signed(61), vec![11, 12, 13]), + Error::::TooManyTargets + ); + }); + } + + #[test] + fn lazy_quota_npos_voters_works_above_quota() { + ExtBuilder::default() + .nominate(false) + .add_staker( + 61, + 60, + 300, // 300 bond has 16 nomination quota. + StakerStatus::::Nominator(vec![21, 22, 23, 24, 25]), + ) + .build_and_execute(|| { + // unbond 78 from stash 60 so that it's bonded balance is 222, which has a lower + // nomination quota than at nomination time (max 2 targets). + assert_ok!(Staking::unbond(RuntimeOrigin::signed(61), 78)); + assert_eq!(Staking::api_nominations_quota(300 - 78), 2); + + // even through 61 has nomination quota of 2 at the time of the election, all the + // nominations (5) will be used. + assert_eq!( + Staking::electing_voters(DataProviderBounds::default()) + .unwrap() + .iter() + .map(|(stash, _, targets)| (*stash, targets.len())) + .collect::>(), + vec![(11, 1), (21, 1), (31, 1), (61, 5)], + ); + }); + } + + #[test] + fn nominations_quota_limits_size_work() { + ExtBuilder::default() + .nominate(false) + .add_staker( + 71, + 70, + 333, + StakerStatus::::Nominator(vec![16, 15, 14, 13, 12, 11, 10]), + ) + .build_and_execute(|| { + // nominations of controller 70 won't be added due to voter size limit exceeded. + let bounds = ElectionBoundsBuilder::default().voters_size(100.into()).build(); + assert_eq!( + Staking::electing_voters(bounds.voters) + .unwrap() + .iter() + .map(|(stash, _, targets)| (*stash, targets.len())) + .collect::>(), + vec![(11, 1), (21, 1), (31, 1)], + ); + + assert_eq!( + *staking_events().last().unwrap(), + Event::SnapshotVotersSizeExceeded { size: 75 } + ); + + // however, if the election voter size bounds were largers, the snapshot would + // include the electing voters of 70. + let bounds = ElectionBoundsBuilder::default().voters_size(1_000.into()).build(); + assert_eq!( + Staking::electing_voters(bounds.voters) + .unwrap() + .iter() + .map(|(stash, _, targets)| (*stash, targets.len())) + .collect::>(), + vec![(11, 1), (21, 1), (31, 1), (71, 7)], + ); + }); + } + #[test] fn estimate_next_election_works() { ExtBuilder::default().session_per_era(5).period(5).build_and_execute(|| { @@ -4707,51 +4951,46 @@ fn min_bond_checks_work() { .min_validator_bond(1_500) .build_and_execute(|| { // 500 is not enough for any role - assert_ok!(Staking::bond( - RuntimeOrigin::signed(3), - 4, - 500, - RewardDestination::Controller - )); + assert_ok!(Staking::bond(RuntimeOrigin::signed(3), 500, RewardDestination::Controller)); assert_noop!( - Staking::nominate(RuntimeOrigin::signed(4), vec![1]), + Staking::nominate(RuntimeOrigin::signed(3), vec![1]), Error::::InsufficientBond ); assert_noop!( - Staking::validate(RuntimeOrigin::signed(4), ValidatorPrefs::default()), + Staking::validate(RuntimeOrigin::signed(3), ValidatorPrefs::default()), Error::::InsufficientBond, ); // 1000 is enough for nominator assert_ok!(Staking::bond_extra(RuntimeOrigin::signed(3), 500)); - assert_ok!(Staking::nominate(RuntimeOrigin::signed(4), vec![1])); + assert_ok!(Staking::nominate(RuntimeOrigin::signed(3), vec![1])); assert_noop!( - Staking::validate(RuntimeOrigin::signed(4), ValidatorPrefs::default()), + Staking::validate(RuntimeOrigin::signed(3), ValidatorPrefs::default()), Error::::InsufficientBond, ); // 1500 is enough for validator assert_ok!(Staking::bond_extra(RuntimeOrigin::signed(3), 500)); - assert_ok!(Staking::nominate(RuntimeOrigin::signed(4), vec![1])); - assert_ok!(Staking::validate(RuntimeOrigin::signed(4), ValidatorPrefs::default())); + assert_ok!(Staking::nominate(RuntimeOrigin::signed(3), vec![1])); + assert_ok!(Staking::validate(RuntimeOrigin::signed(3), ValidatorPrefs::default())); // Can't unbond anything as validator assert_noop!( - Staking::unbond(RuntimeOrigin::signed(4), 500), + Staking::unbond(RuntimeOrigin::signed(3), 500), Error::::InsufficientBond ); // Once they are a nominator, they can unbond 500 - assert_ok!(Staking::nominate(RuntimeOrigin::signed(4), vec![1])); - assert_ok!(Staking::unbond(RuntimeOrigin::signed(4), 500)); + assert_ok!(Staking::nominate(RuntimeOrigin::signed(3), vec![1])); + assert_ok!(Staking::unbond(RuntimeOrigin::signed(3), 500)); assert_noop!( - Staking::unbond(RuntimeOrigin::signed(4), 500), + Staking::unbond(RuntimeOrigin::signed(3), 500), Error::::InsufficientBond ); // Once they are chilled they can unbond everything - assert_ok!(Staking::chill(RuntimeOrigin::signed(4))); - assert_ok!(Staking::unbond(RuntimeOrigin::signed(4), 1000)); + assert_ok!(Staking::chill(RuntimeOrigin::signed(3))); + assert_ok!(Staking::unbond(RuntimeOrigin::signed(3), 1000)); }) } @@ -4767,31 +5006,27 @@ fn chill_other_works() { let initial_nominators = Nominators::::count(); for i in 0..15 { let a = 4 * i; - let b = 4 * i + 1; - let c = 4 * i + 2; - let d = 4 * i + 3; + let b = 4 * i + 2; + let c = 4 * i + 3; Balances::make_free_balance_be(&a, 100_000); Balances::make_free_balance_be(&b, 100_000); Balances::make_free_balance_be(&c, 100_000); - Balances::make_free_balance_be(&d, 100_000); // Nominator assert_ok!(Staking::bond( RuntimeOrigin::signed(a), - b, 1000, RewardDestination::Controller )); - assert_ok!(Staking::nominate(RuntimeOrigin::signed(b), vec![1])); + assert_ok!(Staking::nominate(RuntimeOrigin::signed(a), vec![1])); // Validator assert_ok!(Staking::bond( - RuntimeOrigin::signed(c), - d, + RuntimeOrigin::signed(b), 1500, RewardDestination::Controller )); - assert_ok!(Staking::validate(RuntimeOrigin::signed(d), ValidatorPrefs::default())); + assert_ok!(Staking::validate(RuntimeOrigin::signed(b), ValidatorPrefs::default())); } // To chill other users, we need to: @@ -4804,11 +5039,11 @@ fn chill_other_works() { // Can't chill these users assert_noop!( - Staking::chill_other(RuntimeOrigin::signed(1337), 1), + Staking::chill_other(RuntimeOrigin::signed(1337), 0), Error::::CannotChillOther ); assert_noop!( - Staking::chill_other(RuntimeOrigin::signed(1337), 3), + Staking::chill_other(RuntimeOrigin::signed(1337), 2), Error::::CannotChillOther ); @@ -4825,11 +5060,11 @@ fn chill_other_works() { // Still can't chill these users assert_noop!( - Staking::chill_other(RuntimeOrigin::signed(1337), 1), + Staking::chill_other(RuntimeOrigin::signed(1337), 0), Error::::CannotChillOther ); assert_noop!( - Staking::chill_other(RuntimeOrigin::signed(1337), 3), + Staking::chill_other(RuntimeOrigin::signed(1337), 2), Error::::CannotChillOther ); @@ -4846,11 +5081,11 @@ fn chill_other_works() { // Still can't chill these users assert_noop!( - Staking::chill_other(RuntimeOrigin::signed(1337), 1), + Staking::chill_other(RuntimeOrigin::signed(1337), 0), Error::::CannotChillOther ); assert_noop!( - Staking::chill_other(RuntimeOrigin::signed(1337), 3), + Staking::chill_other(RuntimeOrigin::signed(1337), 2), Error::::CannotChillOther ); @@ -4867,11 +5102,11 @@ fn chill_other_works() { // Still can't chill these users assert_noop!( - Staking::chill_other(RuntimeOrigin::signed(1337), 1), + Staking::chill_other(RuntimeOrigin::signed(1337), 0), Error::::CannotChillOther ); assert_noop!( - Staking::chill_other(RuntimeOrigin::signed(1337), 3), + Staking::chill_other(RuntimeOrigin::signed(1337), 2), Error::::CannotChillOther ); @@ -4893,8 +5128,8 @@ fn chill_other_works() { // Users can now be chilled down to 7 people, so we try to remove 9 of them (starting // with 16) for i in 6..15 { - let b = 4 * i + 1; - let d = 4 * i + 3; + let b = 4 * i; + let d = 4 * i + 2; assert_ok!(Staking::chill_other(RuntimeOrigin::signed(1337), b)); assert_ok!(Staking::chill_other(RuntimeOrigin::signed(1337), d)); } @@ -4902,12 +5137,12 @@ fn chill_other_works() { // chill a nominator. Limit is not reached, not chill-able assert_eq!(Nominators::::count(), 7); assert_noop!( - Staking::chill_other(RuntimeOrigin::signed(1337), 1), + Staking::chill_other(RuntimeOrigin::signed(1337), 0), Error::::CannotChillOther ); // chill a validator. Limit is reached, chill-able. assert_eq!(Validators::::count(), 9); - assert_ok!(Staking::chill_other(RuntimeOrigin::signed(1337), 3)); + assert_ok!(Staking::chill_other(RuntimeOrigin::signed(1337), 2)); }) } @@ -4973,7 +5208,7 @@ fn capped_stakers_works() { some_existing_nominator = controller; } - // one more is too many + // one more is too many. let (_, last_nominator) = testing_utils::create_stash_controller::( 30_000_000, 100, @@ -5014,9 +5249,9 @@ fn capped_stakers_works() { #[test] fn min_commission_works() { ExtBuilder::default().build_and_execute(|| { - // account 10 controls the stash from account 11 + // account 11 controls the stash of itself. assert_ok!(Staking::validate( - RuntimeOrigin::signed(10), + RuntimeOrigin::signed(11), ValidatorPrefs { commission: Perbill::from_percent(5), blocked: false } )); @@ -5042,7 +5277,7 @@ fn min_commission_works() { // can't make it less than 10 now assert_noop!( Staking::validate( - RuntimeOrigin::signed(10), + RuntimeOrigin::signed(11), ValidatorPrefs { commission: Perbill::from_percent(5), blocked: false } ), Error::::CommissionTooLow @@ -5050,92 +5285,97 @@ fn min_commission_works() { // can only change to higher. assert_ok!(Staking::validate( - RuntimeOrigin::signed(10), + RuntimeOrigin::signed(11), ValidatorPrefs { commission: Perbill::from_percent(10), blocked: false } )); assert_ok!(Staking::validate( - RuntimeOrigin::signed(10), + RuntimeOrigin::signed(11), ValidatorPrefs { commission: Perbill::from_percent(15), blocked: false } )); }) } #[test] -fn change_of_max_nominations() { +#[should_panic] +fn change_of_absolute_max_nominations() { use frame_election_provider_support::ElectionDataProvider; ExtBuilder::default() - .add_staker(60, 61, 10, StakerStatus::Nominator(vec![1])) - .add_staker(70, 71, 10, StakerStatus::Nominator(vec![1, 2, 3])) + .add_staker(61, 61, 10, StakerStatus::Nominator(vec![1])) + .add_staker(71, 71, 10, StakerStatus::Nominator(vec![1, 2, 3])) .balance_factor(10) .build_and_execute(|| { // pre-condition - assert_eq!(MaxNominations::get(), 16); + assert_eq!(AbsoluteMaxNominations::get(), 16); assert_eq!( Nominators::::iter() .map(|(k, n)| (k, n.targets.len())) .collect::>(), - vec![(70, 3), (101, 2), (60, 1)] + vec![(101, 2), (71, 3), (61, 1)] ); + + // default bounds are unbounded. + let bounds = DataProviderBounds::default(); + // 3 validators and 3 nominators - assert_eq!(Staking::electing_voters(None).unwrap().len(), 3 + 3); + assert_eq!(Staking::electing_voters(bounds).unwrap().len(), 3 + 3); // abrupt change from 16 to 4, everyone should be fine. - MaxNominations::set(4); + AbsoluteMaxNominations::set(4); assert_eq!( Nominators::::iter() .map(|(k, n)| (k, n.targets.len())) .collect::>(), - vec![(70, 3), (101, 2), (60, 1)] + vec![(101, 2), (71, 3), (61, 1)] ); - assert_eq!(Staking::electing_voters(None).unwrap().len(), 3 + 3); + assert_eq!(Staking::electing_voters(bounds).unwrap().len(), 3 + 3); // abrupt change from 4 to 3, everyone should be fine. - MaxNominations::set(3); + AbsoluteMaxNominations::set(3); assert_eq!( Nominators::::iter() .map(|(k, n)| (k, n.targets.len())) .collect::>(), - vec![(70, 3), (101, 2), (60, 1)] + vec![(101, 2), (71, 3), (61, 1)] ); - assert_eq!(Staking::electing_voters(None).unwrap().len(), 3 + 3); + assert_eq!(Staking::electing_voters(bounds).unwrap().len(), 3 + 3); // abrupt change from 3 to 2, this should cause some nominators to be non-decodable, and // thus non-existent unless if they update. - MaxNominations::set(2); + AbsoluteMaxNominations::set(2); assert_eq!( Nominators::::iter() .map(|(k, n)| (k, n.targets.len())) .collect::>(), - vec![(101, 2), (60, 1)] + vec![(101, 2), (61, 1)] ); // 70 is still in storage.. - assert!(Nominators::::contains_key(70)); + assert!(Nominators::::contains_key(71)); // but its value cannot be decoded and default is returned. - assert!(Nominators::::get(70).is_none()); + assert!(Nominators::::get(71).is_none()); - assert_eq!(Staking::electing_voters(None).unwrap().len(), 3 + 2); + assert_eq!(Staking::electing_voters(bounds).unwrap().len(), 3 + 2); assert!(Nominators::::contains_key(101)); // abrupt change from 2 to 1, this should cause some nominators to be non-decodable, and // thus non-existent unless if they update. - MaxNominations::set(1); + AbsoluteMaxNominations::set(1); assert_eq!( Nominators::::iter() .map(|(k, n)| (k, n.targets.len())) .collect::>(), - vec![(60, 1)] + vec![(61, 1)] ); - assert!(Nominators::::contains_key(70)); - assert!(Nominators::::contains_key(60)); - assert!(Nominators::::get(70).is_none()); - assert!(Nominators::::get(60).is_some()); - assert_eq!(Staking::electing_voters(None).unwrap().len(), 3 + 1); + assert!(Nominators::::contains_key(71)); + assert!(Nominators::::contains_key(61)); + assert!(Nominators::::get(71).is_none()); + assert!(Nominators::::get(61).is_some()); + assert_eq!(Staking::electing_voters(bounds).unwrap().len(), 3 + 1); // now one of them can revive themselves by re-nominating to a proper value. assert_ok!(Staking::nominate(RuntimeOrigin::signed(71), vec![1])); @@ -5143,18 +5383,54 @@ fn change_of_max_nominations() { Nominators::::iter() .map(|(k, n)| (k, n.targets.len())) .collect::>(), - vec![(70, 1), (60, 1)] + vec![(71, 1), (61, 1)] ); // or they can be chilled by any account. assert!(Nominators::::contains_key(101)); assert!(Nominators::::get(101).is_none()); - assert_ok!(Staking::chill_other(RuntimeOrigin::signed(70), 100)); + assert_ok!(Staking::chill_other(RuntimeOrigin::signed(71), 101)); assert!(!Nominators::::contains_key(101)); assert!(Nominators::::get(101).is_none()); }) } +#[test] +fn nomination_quota_max_changes_decoding() { + use frame_election_provider_support::ElectionDataProvider; + ExtBuilder::default() + .add_staker(60, 61, 10, StakerStatus::Nominator(vec![1])) + .add_staker(70, 71, 10, StakerStatus::Nominator(vec![1, 2, 3])) + .add_staker(30, 330, 10, StakerStatus::Nominator(vec![1, 2, 3, 4])) + .add_staker(50, 550, 10, StakerStatus::Nominator(vec![1, 2, 3, 4])) + .balance_factor(10) + .build_and_execute(|| { + // pre-condition. + assert_eq!(MaxNominationsOf::::get(), 16); + + let unbonded_election = DataProviderBounds::default(); + + assert_eq!( + Nominators::::iter() + .map(|(k, n)| (k, n.targets.len())) + .collect::>(), + vec![(70, 3), (101, 2), (50, 4), (30, 4), (60, 1)] + ); + // 4 validators and 4 nominators + assert_eq!(Staking::electing_voters(unbonded_election).unwrap().len(), 4 + 4); + }); +} + +#[test] +fn api_nominations_quota_works() { + ExtBuilder::default().build_and_execute(|| { + assert_eq!(Staking::api_nominations_quota(10), MaxNominationsOf::::get()); + assert_eq!(Staking::api_nominations_quota(333), MaxNominationsOf::::get()); + assert_eq!(Staking::api_nominations_quota(222), 2); + assert_eq!(Staking::api_nominations_quota(111), 1); + }) +} + mod sorted_list_provider { use super::*; use frame_election_provider_support::SortedListProvider; @@ -5173,7 +5449,7 @@ mod sorted_list_provider { ); // when account 101 renominates - assert_ok!(Staking::nominate(RuntimeOrigin::signed(100), vec![41])); + assert_ok!(Staking::nominate(RuntimeOrigin::signed(101), vec![41])); // then counts don't change assert_eq!(::VoterList::count(), pre_insert_voter_count); @@ -5196,7 +5472,7 @@ mod sorted_list_provider { assert_eq!(::VoterList::iter().collect::>(), vec![11, 21, 31]); // when account 11 re-validates - assert_ok!(Staking::validate(RuntimeOrigin::signed(10), Default::default())); + assert_ok!(Staking::validate(RuntimeOrigin::signed(11), Default::default())); // then counts don't change assert_eq!(::VoterList::count(), pre_insert_voter_count); @@ -5211,8 +5487,8 @@ fn force_apply_min_commission_works() { let prefs = |c| ValidatorPrefs { commission: Perbill::from_percent(c), blocked: false }; let validators = || Validators::::iter().collect::>(); ExtBuilder::default().build_and_execute(|| { - assert_ok!(Staking::validate(RuntimeOrigin::signed(30), prefs(10))); - assert_ok!(Staking::validate(RuntimeOrigin::signed(20), prefs(5))); + assert_ok!(Staking::validate(RuntimeOrigin::signed(31), prefs(10))); + assert_ok!(Staking::validate(RuntimeOrigin::signed(21), prefs(5))); // Given assert_eq!(validators(), vec![(31, prefs(10)), (21, prefs(5)), (11, prefs(0))]); @@ -5504,12 +5780,12 @@ fn pre_bonding_era_cannot_be_claimed() { mock::start_active_era(current_era); // add a new candidate for being a validator. account 3 controlled by 4. - assert_ok!(Staking::bond(RuntimeOrigin::signed(3), 4, 1500, RewardDestination::Controller)); + assert_ok!(Staking::bond(RuntimeOrigin::signed(3), 1500, RewardDestination::Controller)); let claimed_rewards: BoundedVec<_, _> = (start_reward_era..=last_reward_era).collect::>().try_into().unwrap(); assert_eq!( - Staking::ledger(&4).unwrap(), + Staking::ledger(&3).unwrap(), StakingLedger { stash: 3, total: 1500, @@ -5524,14 +5800,14 @@ fn pre_bonding_era_cannot_be_claimed() { mock::start_active_era(current_era); // claiming reward for last era in which validator was active works - assert_ok!(Staking::payout_stakers(RuntimeOrigin::signed(4), 3, current_era - 1)); + assert_ok!(Staking::payout_stakers(RuntimeOrigin::signed(3), 3, current_era - 1)); // consumed weight for all payout_stakers dispatches that fail let err_weight = ::WeightInfo::payout_stakers_alive_staked(0); // cannot claim rewards for an era before bonding occured as it is // already marked as claimed. assert_noop!( - Staking::payout_stakers(RuntimeOrigin::signed(4), 3, current_era - 2), + Staking::payout_stakers(RuntimeOrigin::signed(3), 3, current_era - 2), Error::::AlreadyClaimed.with_weight(err_weight) ); @@ -5541,7 +5817,7 @@ fn pre_bonding_era_cannot_be_claimed() { // make sure stakers still cannot claim rewards that they are not meant to assert_noop!( - Staking::payout_stakers(RuntimeOrigin::signed(4), 3, current_era - 2), + Staking::payout_stakers(RuntimeOrigin::signed(3), 3, current_era - 2), Error::::NotController ); @@ -5559,7 +5835,7 @@ fn reducing_history_depth_abrupt() { let last_reward_era = current_era - 1; let start_reward_era = current_era - original_history_depth; - // put some money in (stash, controller)=(3,4),(5,6). + // put some money in (stash, controller)=(3,3),(5,5). for i in 3..7 { let _ = Balances::make_free_balance_be(&i, 2000); } @@ -5567,15 +5843,15 @@ fn reducing_history_depth_abrupt() { // start current era mock::start_active_era(current_era); - // add a new candidate for being a staker. account 3 controlled by 4. - assert_ok!(Staking::bond(RuntimeOrigin::signed(3), 4, 1500, RewardDestination::Controller)); + // add a new candidate for being a staker. account 3 controlled by 3. + assert_ok!(Staking::bond(RuntimeOrigin::signed(3), 1500, RewardDestination::Controller)); // all previous era before the bonding action should be marked as // claimed. let claimed_rewards: BoundedVec<_, _> = (start_reward_era..=last_reward_era).collect::>().try_into().unwrap(); assert_eq!( - Staking::ledger(&4).unwrap(), + Staking::ledger(&3).unwrap(), StakingLedger { stash: 3, total: 1500, @@ -5590,7 +5866,7 @@ fn reducing_history_depth_abrupt() { mock::start_active_era(current_era); // claiming reward for last era in which validator was active works - assert_ok!(Staking::payout_stakers(RuntimeOrigin::signed(4), 3, current_era - 1)); + assert_ok!(Staking::payout_stakers(RuntimeOrigin::signed(3), 3, current_era - 1)); // next era current_era = current_era + 1; @@ -5601,12 +5877,12 @@ fn reducing_history_depth_abrupt() { HistoryDepth::set(history_depth); // claiming reward does not work anymore assert_noop!( - Staking::payout_stakers(RuntimeOrigin::signed(4), 3, current_era - 1), + Staking::payout_stakers(RuntimeOrigin::signed(3), 3, current_era - 1), Error::::NotController ); // new stakers can still bond - assert_ok!(Staking::bond(RuntimeOrigin::signed(5), 6, 1200, RewardDestination::Controller)); + assert_ok!(Staking::bond(RuntimeOrigin::signed(5), 1200, RewardDestination::Controller)); // new staking ledgers created will be bounded by the current history depth let last_reward_era = current_era - 1; @@ -5614,7 +5890,7 @@ fn reducing_history_depth_abrupt() { let claimed_rewards: BoundedVec<_, _> = (start_reward_era..=last_reward_era).collect::>().try_into().unwrap(); assert_eq!( - Staking::ledger(&6).unwrap(), + Staking::ledger(&5).unwrap(), StakingLedger { stash: 5, total: 1200, @@ -5637,17 +5913,17 @@ fn reducing_max_unlocking_chunks_abrupt() { // given a staker at era=10 and MaxUnlockChunks set to 2 MaxUnlockingChunks::set(2); start_active_era(10); - assert_ok!(Staking::bond(RuntimeOrigin::signed(3), 4, 300, RewardDestination::Staked)); - assert!(matches!(Staking::ledger(4), Some(_))); + assert_ok!(Staking::bond(RuntimeOrigin::signed(3), 300, RewardDestination::Staked)); + assert!(matches!(Staking::ledger(3), Some(_))); // when staker unbonds - assert_ok!(Staking::unbond(RuntimeOrigin::signed(4), 20)); + assert_ok!(Staking::unbond(RuntimeOrigin::signed(3), 20)); // then an unlocking chunk is added at `current_era + bonding_duration` // => 10 + 3 = 13 let expected_unlocking: BoundedVec, MaxUnlockingChunks> = bounded_vec![UnlockChunk { value: 20 as Balance, era: 13 as EraIndex }]; - assert!(matches!(Staking::ledger(4), + assert!(matches!(Staking::ledger(3), Some(StakingLedger { unlocking, .. @@ -5655,11 +5931,11 @@ fn reducing_max_unlocking_chunks_abrupt() { // when staker unbonds at next era start_active_era(11); - assert_ok!(Staking::unbond(RuntimeOrigin::signed(4), 50)); + assert_ok!(Staking::unbond(RuntimeOrigin::signed(3), 50)); // then another unlock chunk is added let expected_unlocking: BoundedVec, MaxUnlockingChunks> = bounded_vec![UnlockChunk { value: 20, era: 13 }, UnlockChunk { value: 50, era: 14 }]; - assert!(matches!(Staking::ledger(4), + assert!(matches!(Staking::ledger(3), Some(StakingLedger { unlocking, .. @@ -5668,13 +5944,13 @@ fn reducing_max_unlocking_chunks_abrupt() { // when staker unbonds further start_active_era(12); // then further unbonding not possible - assert_noop!(Staking::unbond(RuntimeOrigin::signed(4), 20), Error::::NoMoreChunks); + assert_noop!(Staking::unbond(RuntimeOrigin::signed(3), 20), Error::::NoMoreChunks); // when max unlocking chunks is reduced abruptly to a low value MaxUnlockingChunks::set(1); // then unbond, rebond ops are blocked with ledger in corrupt state - assert_noop!(Staking::unbond(RuntimeOrigin::signed(4), 20), Error::::NotController); - assert_noop!(Staking::rebond(RuntimeOrigin::signed(4), 100), Error::::NotController); + assert_noop!(Staking::unbond(RuntimeOrigin::signed(3), 20), Error::::NotController); + assert_noop!(Staking::rebond(RuntimeOrigin::signed(3), 100), Error::::NotController); // reset the ledger corruption MaxUnlockingChunks::set(2); @@ -5761,7 +6037,7 @@ fn set_min_commission_works_with_admin_origin() { // setting commission below min_commission fails assert_noop!( Staking::validate( - RuntimeOrigin::signed(10), + RuntimeOrigin::signed(11), ValidatorPrefs { commission: Perbill::from_percent(14), blocked: false } ), Error::::CommissionTooLow @@ -5769,7 +6045,7 @@ fn set_min_commission_works_with_admin_origin() { // setting commission >= min_commission works assert_ok!(Staking::validate( - RuntimeOrigin::signed(10), + RuntimeOrigin::signed(11), ValidatorPrefs { commission: Perbill::from_percent(15), blocked: false } )); }) @@ -5787,13 +6063,13 @@ mod staking_interface { // without slash let _ = with_storage_layer::<(), _, _>(|| { // bond an account, can unstake - assert_eq!(Staking::bonded(&11), Some(10)); + assert_eq!(Staking::bonded(&11), Some(11)); assert_ok!(::force_unstake(11)); Err(DispatchError::from("revert")) }); // bond again and add a slash, still can unstake. - assert_eq!(Staking::bonded(&11), Some(10)); + assert_eq!(Staking::bonded(&11), Some(11)); add_slash(&11); assert_ok!(::force_unstake(11)); }); @@ -5810,16 +6086,16 @@ mod staking_interface { &[Perbill::from_percent(100)], ); - assert_eq!(Staking::bonded(&11), Some(10)); + assert_eq!(Staking::bonded(&11), Some(11)); assert_noop!( - Staking::withdraw_unbonded(RuntimeOrigin::signed(10), 0), + Staking::withdraw_unbonded(RuntimeOrigin::signed(11), 0), Error::::IncorrectSlashingSpans ); let num_slashing_spans = Staking::slashing_spans(&11).map_or(0, |s| s.iter().count()); assert_ok!(Staking::withdraw_unbonded( - RuntimeOrigin::signed(10), + RuntimeOrigin::signed(11), num_slashing_spans as u32 )); }); diff --git a/pallets/staking/src/weights.rs b/pallets/staking/src/weights.rs index 34b01445..f2c65e67 100755 --- a/pallets/staking/src/weights.rs +++ b/pallets/staking/src/weights.rs @@ -18,9 +18,9 @@ //! Autogenerated weights for pallet_staking //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-04-06, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-06-16, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `bm2`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! HOSTNAME: `runner-e8ezs4ez-project-145-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 // Executed Command: @@ -31,6 +31,9 @@ // --steps=50 // --repeat=20 // --pallet=pallet_staking +// --no-storage-info +// --no-median-slopes +// --no-min-squares // --extrinsic=* // --execution=wasm // --wasm-execution=compiled @@ -42,9 +45,10 @@ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] #![allow(unused_imports)] +#![allow(missing_docs)] use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; /// Weight functions needed for pallet_staking. pub trait WeightInfo { @@ -99,8 +103,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `1047` // Estimated: `4764` - // Minimum execution time: 54_907_000 picoseconds. - Weight::from_parts(55_685_000, 4764) + // Minimum execution time: 53_983_000 picoseconds. + Weight::from_parts(55_296_000, 4764) .saturating_add(T::DbWeight::get().reads(5_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) } @@ -120,8 +124,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `2028` // Estimated: `8877` - // Minimum execution time: 94_779_000 picoseconds. - Weight::from_parts(95_455_000, 8877) + // Minimum execution time: 96_590_000 picoseconds. + Weight::from_parts(98_921_000, 8877) .saturating_add(T::DbWeight::get().reads(9_u64)) .saturating_add(T::DbWeight::get().writes(7_u64)) } @@ -137,8 +141,6 @@ impl WeightInfo for SubstrateWeight { /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) /// Storage: Balances Freezes (r:1 w:0) /// Proof: Balances Freezes (max_values: None, max_size: Some(49), added: 2524, mode: MaxEncodedLen) - /// Storage: System Account (r:1 w:1) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) /// Storage: VoterList ListNodes (r:3 w:3) /// Proof: VoterList ListNodes (max_values: None, max_size: Some(154), added: 2629, mode: MaxEncodedLen) /// Storage: Staking Bonded (r:1 w:0) @@ -149,10 +151,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `2233` // Estimated: `8877` - // Minimum execution time: 98_004_000 picoseconds. - Weight::from_parts(98_730_000, 8877) - .saturating_add(T::DbWeight::get().reads(13_u64)) - .saturating_add(T::DbWeight::get().writes(8_u64)) + // Minimum execution time: 99_901_000 picoseconds. + Weight::from_parts(102_919_000, 8877) + .saturating_add(T::DbWeight::get().reads(12_u64)) + .saturating_add(T::DbWeight::get().writes(7_u64)) } /// Storage: Staking Ledger (r:1 w:1) /// Proof: Staking Ledger (max_values: None, max_size: Some(1091), added: 3566, mode: MaxEncodedLen) @@ -162,19 +164,17 @@ impl WeightInfo for SubstrateWeight { /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) /// Storage: Balances Freezes (r:1 w:0) /// Proof: Balances Freezes (max_values: None, max_size: Some(49), added: 2524, mode: MaxEncodedLen) - /// Storage: System Account (r:1 w:1) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) /// The range of component `s` is `[0, 100]`. fn withdraw_unbonded_update(s: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `1021` // Estimated: `4764` - // Minimum execution time: 45_888_000 picoseconds. - Weight::from_parts(47_568_327, 4764) - // Standard Error: 402 - .saturating_add(Weight::from_parts(7_520, 0).saturating_mul(s.into())) - .saturating_add(T::DbWeight::get().reads(5_u64)) - .saturating_add(T::DbWeight::get().writes(3_u64)) + // Minimum execution time: 45_230_000 picoseconds. + Weight::from_parts(47_052_829, 4764) + // Standard Error: 1_044 + .saturating_add(Weight::from_parts(43_887, 0).saturating_mul(s.into())) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) } /// Storage: Staking Ledger (r:1 w:1) /// Proof: Staking Ledger (max_values: None, max_size: Some(1091), added: 3566, mode: MaxEncodedLen) @@ -196,8 +196,6 @@ impl WeightInfo for SubstrateWeight { /// Proof: VoterList ListBags (max_values: None, max_size: Some(82), added: 2557, mode: MaxEncodedLen) /// Storage: VoterList CounterForListNodes (r:1 w:1) /// Proof: VoterList CounterForListNodes (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: System Account (r:1 w:1) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) /// Storage: Balances Locks (r:1 w:1) /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) /// Storage: Balances Freezes (r:1 w:0) @@ -211,12 +209,12 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `2294 + s * (4 ±0)` // Estimated: `6248 + s * (4 ±0)` - // Minimum execution time: 93_288_000 picoseconds. - Weight::from_parts(99_415_523, 6248) - // Standard Error: 3_291 - .saturating_add(Weight::from_parts(1_296_734, 0).saturating_mul(s.into())) - .saturating_add(T::DbWeight::get().reads(14_u64)) - .saturating_add(T::DbWeight::get().writes(12_u64)) + // Minimum execution time: 97_534_000 picoseconds. + Weight::from_parts(104_772_163, 6248) + // Standard Error: 3_674 + .saturating_add(Weight::from_parts(1_470_124, 0).saturating_mul(s.into())) + .saturating_add(T::DbWeight::get().reads(13_u64)) + .saturating_add(T::DbWeight::get().writes(11_u64)) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(s.into()))) .saturating_add(Weight::from_parts(0, 4).saturating_mul(s.into())) } @@ -246,8 +244,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `1414` // Estimated: `4556` - // Minimum execution time: 58_755_000 picoseconds. - Weight::from_parts(59_424_000, 4556) + // Minimum execution time: 57_467_000 picoseconds. + Weight::from_parts(59_437_000, 4556) .saturating_add(T::DbWeight::get().reads(11_u64)) .saturating_add(T::DbWeight::get().writes(5_u64)) } @@ -258,12 +256,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `k` is `[1, 128]`. fn kick(k: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1260 + k * (569 ±0)` + // Measured: `1285 + k * (569 ±0)` // Estimated: `4556 + k * (3033 ±0)` - // Minimum execution time: 29_399_000 picoseconds. - Weight::from_parts(30_443_621, 4556) - // Standard Error: 10_402 - .saturating_add(Weight::from_parts(7_890_220, 0).saturating_mul(k.into())) + // Minimum execution time: 32_857_000 picoseconds. + Weight::from_parts(37_116_967, 4556) + // Standard Error: 9_522 + .saturating_add(Weight::from_parts(8_796_167, 0).saturating_mul(k.into())) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(k.into()))) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(k.into()))) @@ -294,12 +292,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `n` is `[1, 16]`. fn nominate(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1888 + n * (105 ±0)` + // Measured: `1908 + n * (102 ±0)` // Estimated: `6248 + n * (2520 ±0)` - // Minimum execution time: 68_471_000 picoseconds. - Weight::from_parts(65_972_990, 6248) - // Standard Error: 13_983 - .saturating_add(Weight::from_parts(3_255_731, 0).saturating_mul(n.into())) + // Minimum execution time: 69_613_000 picoseconds. + Weight::from_parts(68_079_061, 6248) + // Standard Error: 18_554 + .saturating_add(Weight::from_parts(4_012_761, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(12_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(n.into()))) .saturating_add(T::DbWeight::get().writes(6_u64)) @@ -323,8 +321,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `1748` // Estimated: `6248` - // Minimum execution time: 59_537_000 picoseconds. - Weight::from_parts(60_446_000, 6248) + // Minimum execution time: 60_430_000 picoseconds. + Weight::from_parts(62_702_000, 6248) .saturating_add(T::DbWeight::get().reads(8_u64)) .saturating_add(T::DbWeight::get().writes(6_u64)) } @@ -336,8 +334,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `808` // Estimated: `4556` - // Minimum execution time: 15_403_000 picoseconds. - Weight::from_parts(15_676_000, 4556) + // Minimum execution time: 14_276_000 picoseconds. + Weight::from_parts(14_766_000, 4556) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -349,8 +347,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `907` // Estimated: `8122` - // Minimum execution time: 23_316_000 picoseconds. - Weight::from_parts(23_670_000, 8122) + // Minimum execution time: 21_710_000 picoseconds. + Weight::from_parts(22_430_000, 8122) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -360,8 +358,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_558_000 picoseconds. - Weight::from_parts(3_759_000, 0) + // Minimum execution time: 2_970_000 picoseconds. + Weight::from_parts(3_120_000, 0) .saturating_add(T::DbWeight::get().writes(1_u64)) } /// Storage: Staking ForceEra (r:0 w:1) @@ -370,8 +368,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 12_724_000 picoseconds. - Weight::from_parts(13_047_000, 0) + // Minimum execution time: 9_362_000 picoseconds. + Weight::from_parts(9_785_000, 0) .saturating_add(T::DbWeight::get().writes(1_u64)) } /// Storage: Staking ForceEra (r:0 w:1) @@ -380,8 +378,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 12_734_000 picoseconds. - Weight::from_parts(13_218_000, 0) + // Minimum execution time: 9_275_000 picoseconds. + Weight::from_parts(9_678_000, 0) .saturating_add(T::DbWeight::get().writes(1_u64)) } /// Storage: Staking ForceEra (r:0 w:1) @@ -390,8 +388,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 12_996_000 picoseconds. - Weight::from_parts(13_375_000, 0) + // Minimum execution time: 9_414_000 picoseconds. + Weight::from_parts(9_848_000, 0) .saturating_add(T::DbWeight::get().writes(1_u64)) } /// Storage: Staking Invulnerables (r:0 w:1) @@ -401,10 +399,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_920_000 picoseconds. - Weight::from_parts(4_619_469, 0) - // Standard Error: 22 - .saturating_add(Weight::from_parts(10_108, 0).saturating_mul(v.into())) + // Minimum execution time: 3_061_000 picoseconds. + Weight::from_parts(3_618_535, 0) + // Standard Error: 44 + .saturating_add(Weight::from_parts(10_774, 0).saturating_mul(v.into())) .saturating_add(T::DbWeight::get().writes(1_u64)) } /// Storage: Staking Bonded (r:1 w:1) @@ -440,10 +438,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `2018 + s * (4 ±0)` // Estimated: `6248 + s * (4 ±0)` - // Minimum execution time: 86_516_000 picoseconds. - Weight::from_parts(92_324_464, 6248) - // Standard Error: 2_925 - .saturating_add(Weight::from_parts(1_286_284, 0).saturating_mul(s.into())) + // Minimum execution time: 87_914_000 picoseconds. + Weight::from_parts(95_688_129, 6248) + // Standard Error: 5_030 + .saturating_add(Weight::from_parts(1_487_249, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(12_u64)) .saturating_add(T::DbWeight::get().writes(12_u64)) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(s.into()))) @@ -456,10 +454,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `66639` // Estimated: `70104` - // Minimum execution time: 90_193_000 picoseconds. - Weight::from_parts(821_522_318, 70104) - // Standard Error: 57_922 - .saturating_add(Weight::from_parts(4_554_659, 0).saturating_mul(s.into())) + // Minimum execution time: 99_269_000 picoseconds. + Weight::from_parts(1_154_264_637, 70104) + // Standard Error: 76_592 + .saturating_add(Weight::from_parts(6_490_888, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -486,10 +484,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `20217 + n * (143 ±0)` // Estimated: `19844 + n * (2603 ±1)` - // Minimum execution time: 80_329_000 picoseconds. - Weight::from_parts(97_340_643, 19844) - // Standard Error: 22_713 - .saturating_add(Weight::from_parts(29_087_425, 0).saturating_mul(n.into())) + // Minimum execution time: 91_767_000 picoseconds. + Weight::from_parts(146_781_264, 19844) + // Standard Error: 31_341 + .saturating_add(Weight::from_parts(30_553_008, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(9_u64)) .saturating_add(T::DbWeight::get().reads((3_u64).saturating_mul(n.into()))) .saturating_add(T::DbWeight::get().writes(2_u64)) @@ -521,12 +519,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `n` is `[0, 256]`. fn payout_stakers_alive_staked(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `34971 + n * (401 ±0)` - // Estimated: `32376 + n * (3774 ±0)` - // Minimum execution time: 105_591_000 picoseconds. - Weight::from_parts(111_587_915, 32376) - // Standard Error: 15_598 - .saturating_add(Weight::from_parts(48_948_195, 0).saturating_mul(n.into())) + // Measured: `33190 + n * (377 ±0)` + // Estimated: `30845 + n * (3774 ±0)` + // Minimum execution time: 121_303_000 picoseconds. + Weight::from_parts(151_046_907, 30845) + // Standard Error: 41_899 + .saturating_add(Weight::from_parts(49_837_804, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(11_u64)) .saturating_add(T::DbWeight::get().reads((6_u64).saturating_mul(n.into()))) .saturating_add(T::DbWeight::get().writes(3_u64)) @@ -539,8 +537,6 @@ impl WeightInfo for SubstrateWeight { /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) /// Storage: Balances Freezes (r:1 w:0) /// Proof: Balances Freezes (max_values: None, max_size: Some(49), added: 2524, mode: MaxEncodedLen) - /// Storage: System Account (r:1 w:1) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) /// Storage: VoterList ListNodes (r:3 w:3) /// Proof: VoterList ListNodes (max_values: None, max_size: Some(154), added: 2629, mode: MaxEncodedLen) /// Storage: Staking Bonded (r:1 w:0) @@ -552,15 +548,13 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `2029 + l * (7 ±0)` // Estimated: `8877` - // Minimum execution time: 89_420_000 picoseconds. - Weight::from_parts(90_743_615, 8877) - // Standard Error: 1_260 - .saturating_add(Weight::from_parts(50_832, 0).saturating_mul(l.into())) - .saturating_add(T::DbWeight::get().reads(10_u64)) - .saturating_add(T::DbWeight::get().writes(8_u64)) + // Minimum execution time: 90_068_000 picoseconds. + Weight::from_parts(93_137_456, 8877) + // Standard Error: 4_799 + .saturating_add(Weight::from_parts(54_421, 0).saturating_mul(l.into())) + .saturating_add(T::DbWeight::get().reads(9_u64)) + .saturating_add(T::DbWeight::get().writes(7_u64)) } - /// Storage: System Account (r:1 w:1) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) /// Storage: Staking Bonded (r:1 w:1) /// Proof: Staking Bonded (max_values: None, max_size: Some(72), added: 2547, mode: MaxEncodedLen) /// Storage: Staking Ledger (r:1 w:1) @@ -592,12 +586,12 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `2294 + s * (4 ±0)` // Estimated: `6248 + s * (4 ±0)` - // Minimum execution time: 100_911_000 picoseconds. - Weight::from_parts(102_678_006, 6248) - // Standard Error: 2_349 - .saturating_add(Weight::from_parts(1_262_431, 0).saturating_mul(s.into())) - .saturating_add(T::DbWeight::get().reads(13_u64)) - .saturating_add(T::DbWeight::get().writes(12_u64)) + // Minimum execution time: 103_139_000 picoseconds. + Weight::from_parts(107_036_296, 6248) + // Standard Error: 3_935 + .saturating_add(Weight::from_parts(1_465_860, 0).saturating_mul(s.into())) + .saturating_add(T::DbWeight::get().reads(12_u64)) + .saturating_add(T::DbWeight::get().writes(11_u64)) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(s.into()))) .saturating_add(Weight::from_parts(0, 4).saturating_mul(s.into())) } @@ -641,12 +635,12 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0 + n * (720 ±0) + v * (3598 ±0)` // Estimated: `512390 + n * (3566 ±0) + v * (3566 ±0)` - // Minimum execution time: 554_712_000 picoseconds. - Weight::from_parts(556_603_000, 512390) - // Standard Error: 1_925_251 - .saturating_add(Weight::from_parts(62_627_196, 0).saturating_mul(v.into())) - // Standard Error: 191_840 - .saturating_add(Weight::from_parts(16_681_790, 0).saturating_mul(n.into())) + // Minimum execution time: 587_156_000 picoseconds. + Weight::from_parts(590_176_000, 512390) + // Standard Error: 2_008_420 + .saturating_add(Weight::from_parts(64_526_052, 0).saturating_mul(v.into())) + // Standard Error: 200_128 + .saturating_add(Weight::from_parts(18_070_222, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(206_u64)) .saturating_add(T::DbWeight::get().reads((5_u64).saturating_mul(v.into()))) .saturating_add(T::DbWeight::get().reads((4_u64).saturating_mul(n.into()))) @@ -675,14 +669,14 @@ impl WeightInfo for SubstrateWeight { /// The range of component `n` is `[500, 1000]`. fn get_npos_voters(v: u32, n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `3135 + n * (911 ±0) + v * (395 ±0)` + // Measured: `3217 + n * (911 ±0) + v * (395 ±0)` // Estimated: `512390 + n * (3566 ±0) + v * (3566 ±0)` - // Minimum execution time: 31_770_670_000 picoseconds. - Weight::from_parts(31_839_042_000, 512390) - // Standard Error: 355_382 - .saturating_add(Weight::from_parts(5_044_540, 0).saturating_mul(v.into())) - // Standard Error: 355_382 - .saturating_add(Weight::from_parts(3_205_722, 0).saturating_mul(n.into())) + // Minimum execution time: 34_399_721_000 picoseconds. + Weight::from_parts(34_605_803_000, 512390) + // Standard Error: 380_106 + .saturating_add(Weight::from_parts(5_426_220, 0).saturating_mul(v.into())) + // Standard Error: 380_106 + .saturating_add(Weight::from_parts(3_318_197, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(201_u64)) .saturating_add(T::DbWeight::get().reads((5_u64).saturating_mul(v.into()))) .saturating_add(T::DbWeight::get().reads((4_u64).saturating_mul(n.into()))) @@ -699,10 +693,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `983 + v * (50 ±0)` // Estimated: `3510 + v * (2520 ±0)` - // Minimum execution time: 2_253_567_000 picoseconds. - Weight::from_parts(61_440_613, 3510) - // Standard Error: 5_276 - .saturating_add(Weight::from_parts(4_414_153, 0).saturating_mul(v.into())) + // Minimum execution time: 2_392_849_000 picoseconds. + Weight::from_parts(64_373_879, 3510) + // Standard Error: 8_995 + .saturating_add(Weight::from_parts(4_721_536, 0).saturating_mul(v.into())) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(v.into()))) .saturating_add(Weight::from_parts(0, 2520).saturating_mul(v.into())) @@ -723,8 +717,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 9_292_000 picoseconds. - Weight::from_parts(9_587_000, 0) + // Minimum execution time: 7_529_000 picoseconds. + Weight::from_parts(7_970_000, 0) .saturating_add(T::DbWeight::get().writes(6_u64)) } /// Storage: Staking MinCommission (r:0 w:1) @@ -743,8 +737,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 8_294_000 picoseconds. - Weight::from_parts(8_597_000, 0) + // Minimum execution time: 7_011_000 picoseconds. + Weight::from_parts(7_317_000, 0) .saturating_add(T::DbWeight::get().writes(6_u64)) } /// Storage: Staking Ledger (r:1 w:0) @@ -771,8 +765,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `1871` // Estimated: `6248` - // Minimum execution time: 75_742_000 picoseconds. - Weight::from_parts(76_252_000, 6248) + // Minimum execution time: 75_982_000 picoseconds. + Weight::from_parts(77_412_000, 6248) .saturating_add(T::DbWeight::get().reads(11_u64)) .saturating_add(T::DbWeight::get().writes(6_u64)) } @@ -784,8 +778,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `694` // Estimated: `3510` - // Minimum execution time: 16_407_000 picoseconds. - Weight::from_parts(16_726_000, 3510) + // Minimum execution time: 13_923_000 picoseconds. + Weight::from_parts(14_356_000, 3510) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -795,8 +789,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 4_977_000 picoseconds. - Weight::from_parts(5_224_000, 0) + // Minimum execution time: 3_415_000 picoseconds. + Weight::from_parts(3_679_000, 0) .saturating_add(T::DbWeight::get().writes(1_u64)) } } @@ -819,8 +813,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `1047` // Estimated: `4764` - // Minimum execution time: 54_907_000 picoseconds. - Weight::from_parts(55_685_000, 4764) + // Minimum execution time: 53_983_000 picoseconds. + Weight::from_parts(55_296_000, 4764) .saturating_add(RocksDbWeight::get().reads(5_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) } @@ -840,8 +834,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `2028` // Estimated: `8877` - // Minimum execution time: 94_779_000 picoseconds. - Weight::from_parts(95_455_000, 8877) + // Minimum execution time: 96_590_000 picoseconds. + Weight::from_parts(98_921_000, 8877) .saturating_add(RocksDbWeight::get().reads(9_u64)) .saturating_add(RocksDbWeight::get().writes(7_u64)) } @@ -857,8 +851,6 @@ impl WeightInfo for () { /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) /// Storage: Balances Freezes (r:1 w:0) /// Proof: Balances Freezes (max_values: None, max_size: Some(49), added: 2524, mode: MaxEncodedLen) - /// Storage: System Account (r:1 w:1) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) /// Storage: VoterList ListNodes (r:3 w:3) /// Proof: VoterList ListNodes (max_values: None, max_size: Some(154), added: 2629, mode: MaxEncodedLen) /// Storage: Staking Bonded (r:1 w:0) @@ -869,10 +861,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `2233` // Estimated: `8877` - // Minimum execution time: 98_004_000 picoseconds. - Weight::from_parts(98_730_000, 8877) - .saturating_add(RocksDbWeight::get().reads(13_u64)) - .saturating_add(RocksDbWeight::get().writes(8_u64)) + // Minimum execution time: 99_901_000 picoseconds. + Weight::from_parts(102_919_000, 8877) + .saturating_add(RocksDbWeight::get().reads(12_u64)) + .saturating_add(RocksDbWeight::get().writes(7_u64)) } /// Storage: Staking Ledger (r:1 w:1) /// Proof: Staking Ledger (max_values: None, max_size: Some(1091), added: 3566, mode: MaxEncodedLen) @@ -882,19 +874,17 @@ impl WeightInfo for () { /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) /// Storage: Balances Freezes (r:1 w:0) /// Proof: Balances Freezes (max_values: None, max_size: Some(49), added: 2524, mode: MaxEncodedLen) - /// Storage: System Account (r:1 w:1) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) /// The range of component `s` is `[0, 100]`. fn withdraw_unbonded_update(s: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `1021` // Estimated: `4764` - // Minimum execution time: 45_888_000 picoseconds. - Weight::from_parts(47_568_327, 4764) - // Standard Error: 402 - .saturating_add(Weight::from_parts(7_520, 0).saturating_mul(s.into())) - .saturating_add(RocksDbWeight::get().reads(5_u64)) - .saturating_add(RocksDbWeight::get().writes(3_u64)) + // Minimum execution time: 45_230_000 picoseconds. + Weight::from_parts(47_052_829, 4764) + // Standard Error: 1_044 + .saturating_add(Weight::from_parts(43_887, 0).saturating_mul(s.into())) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) } /// Storage: Staking Ledger (r:1 w:1) /// Proof: Staking Ledger (max_values: None, max_size: Some(1091), added: 3566, mode: MaxEncodedLen) @@ -916,8 +906,6 @@ impl WeightInfo for () { /// Proof: VoterList ListBags (max_values: None, max_size: Some(82), added: 2557, mode: MaxEncodedLen) /// Storage: VoterList CounterForListNodes (r:1 w:1) /// Proof: VoterList CounterForListNodes (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: System Account (r:1 w:1) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) /// Storage: Balances Locks (r:1 w:1) /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) /// Storage: Balances Freezes (r:1 w:0) @@ -931,12 +919,12 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `2294 + s * (4 ±0)` // Estimated: `6248 + s * (4 ±0)` - // Minimum execution time: 93_288_000 picoseconds. - Weight::from_parts(99_415_523, 6248) - // Standard Error: 3_291 - .saturating_add(Weight::from_parts(1_296_734, 0).saturating_mul(s.into())) - .saturating_add(RocksDbWeight::get().reads(14_u64)) - .saturating_add(RocksDbWeight::get().writes(12_u64)) + // Minimum execution time: 97_534_000 picoseconds. + Weight::from_parts(104_772_163, 6248) + // Standard Error: 3_674 + .saturating_add(Weight::from_parts(1_470_124, 0).saturating_mul(s.into())) + .saturating_add(RocksDbWeight::get().reads(13_u64)) + .saturating_add(RocksDbWeight::get().writes(11_u64)) .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(s.into()))) .saturating_add(Weight::from_parts(0, 4).saturating_mul(s.into())) } @@ -966,8 +954,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `1414` // Estimated: `4556` - // Minimum execution time: 58_755_000 picoseconds. - Weight::from_parts(59_424_000, 4556) + // Minimum execution time: 57_467_000 picoseconds. + Weight::from_parts(59_437_000, 4556) .saturating_add(RocksDbWeight::get().reads(11_u64)) .saturating_add(RocksDbWeight::get().writes(5_u64)) } @@ -978,12 +966,12 @@ impl WeightInfo for () { /// The range of component `k` is `[1, 128]`. fn kick(k: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1260 + k * (569 ±0)` + // Measured: `1285 + k * (569 ±0)` // Estimated: `4556 + k * (3033 ±0)` - // Minimum execution time: 29_399_000 picoseconds. - Weight::from_parts(30_443_621, 4556) - // Standard Error: 10_402 - .saturating_add(Weight::from_parts(7_890_220, 0).saturating_mul(k.into())) + // Minimum execution time: 32_857_000 picoseconds. + Weight::from_parts(37_116_967, 4556) + // Standard Error: 9_522 + .saturating_add(Weight::from_parts(8_796_167, 0).saturating_mul(k.into())) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(k.into()))) .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(k.into()))) @@ -1014,12 +1002,12 @@ impl WeightInfo for () { /// The range of component `n` is `[1, 16]`. fn nominate(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1888 + n * (105 ±0)` + // Measured: `1908 + n * (102 ±0)` // Estimated: `6248 + n * (2520 ±0)` - // Minimum execution time: 68_471_000 picoseconds. - Weight::from_parts(65_972_990, 6248) - // Standard Error: 13_983 - .saturating_add(Weight::from_parts(3_255_731, 0).saturating_mul(n.into())) + // Minimum execution time: 69_613_000 picoseconds. + Weight::from_parts(68_079_061, 6248) + // Standard Error: 18_554 + .saturating_add(Weight::from_parts(4_012_761, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(12_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(n.into()))) .saturating_add(RocksDbWeight::get().writes(6_u64)) @@ -1043,8 +1031,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `1748` // Estimated: `6248` - // Minimum execution time: 59_537_000 picoseconds. - Weight::from_parts(60_446_000, 6248) + // Minimum execution time: 60_430_000 picoseconds. + Weight::from_parts(62_702_000, 6248) .saturating_add(RocksDbWeight::get().reads(8_u64)) .saturating_add(RocksDbWeight::get().writes(6_u64)) } @@ -1056,8 +1044,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `808` // Estimated: `4556` - // Minimum execution time: 15_403_000 picoseconds. - Weight::from_parts(15_676_000, 4556) + // Minimum execution time: 14_276_000 picoseconds. + Weight::from_parts(14_766_000, 4556) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -1069,8 +1057,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `907` // Estimated: `8122` - // Minimum execution time: 23_316_000 picoseconds. - Weight::from_parts(23_670_000, 8122) + // Minimum execution time: 21_710_000 picoseconds. + Weight::from_parts(22_430_000, 8122) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -1080,8 +1068,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_558_000 picoseconds. - Weight::from_parts(3_759_000, 0) + // Minimum execution time: 2_970_000 picoseconds. + Weight::from_parts(3_120_000, 0) .saturating_add(RocksDbWeight::get().writes(1_u64)) } /// Storage: Staking ForceEra (r:0 w:1) @@ -1090,8 +1078,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 12_724_000 picoseconds. - Weight::from_parts(13_047_000, 0) + // Minimum execution time: 9_362_000 picoseconds. + Weight::from_parts(9_785_000, 0) .saturating_add(RocksDbWeight::get().writes(1_u64)) } /// Storage: Staking ForceEra (r:0 w:1) @@ -1100,8 +1088,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 12_734_000 picoseconds. - Weight::from_parts(13_218_000, 0) + // Minimum execution time: 9_275_000 picoseconds. + Weight::from_parts(9_678_000, 0) .saturating_add(RocksDbWeight::get().writes(1_u64)) } /// Storage: Staking ForceEra (r:0 w:1) @@ -1110,8 +1098,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 12_996_000 picoseconds. - Weight::from_parts(13_375_000, 0) + // Minimum execution time: 9_414_000 picoseconds. + Weight::from_parts(9_848_000, 0) .saturating_add(RocksDbWeight::get().writes(1_u64)) } /// Storage: Staking Invulnerables (r:0 w:1) @@ -1121,10 +1109,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_920_000 picoseconds. - Weight::from_parts(4_619_469, 0) - // Standard Error: 22 - .saturating_add(Weight::from_parts(10_108, 0).saturating_mul(v.into())) + // Minimum execution time: 3_061_000 picoseconds. + Weight::from_parts(3_618_535, 0) + // Standard Error: 44 + .saturating_add(Weight::from_parts(10_774, 0).saturating_mul(v.into())) .saturating_add(RocksDbWeight::get().writes(1_u64)) } /// Storage: Staking Bonded (r:1 w:1) @@ -1160,10 +1148,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `2018 + s * (4 ±0)` // Estimated: `6248 + s * (4 ±0)` - // Minimum execution time: 86_516_000 picoseconds. - Weight::from_parts(92_324_464, 6248) - // Standard Error: 2_925 - .saturating_add(Weight::from_parts(1_286_284, 0).saturating_mul(s.into())) + // Minimum execution time: 87_914_000 picoseconds. + Weight::from_parts(95_688_129, 6248) + // Standard Error: 5_030 + .saturating_add(Weight::from_parts(1_487_249, 0).saturating_mul(s.into())) .saturating_add(RocksDbWeight::get().reads(12_u64)) .saturating_add(RocksDbWeight::get().writes(12_u64)) .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(s.into()))) @@ -1176,10 +1164,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `66639` // Estimated: `70104` - // Minimum execution time: 90_193_000 picoseconds. - Weight::from_parts(821_522_318, 70104) - // Standard Error: 57_922 - .saturating_add(Weight::from_parts(4_554_659, 0).saturating_mul(s.into())) + // Minimum execution time: 99_269_000 picoseconds. + Weight::from_parts(1_154_264_637, 70104) + // Standard Error: 76_592 + .saturating_add(Weight::from_parts(6_490_888, 0).saturating_mul(s.into())) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -1206,10 +1194,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `20217 + n * (143 ±0)` // Estimated: `19844 + n * (2603 ±1)` - // Minimum execution time: 80_329_000 picoseconds. - Weight::from_parts(97_340_643, 19844) - // Standard Error: 22_713 - .saturating_add(Weight::from_parts(29_087_425, 0).saturating_mul(n.into())) + // Minimum execution time: 91_767_000 picoseconds. + Weight::from_parts(146_781_264, 19844) + // Standard Error: 31_341 + .saturating_add(Weight::from_parts(30_553_008, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(9_u64)) .saturating_add(RocksDbWeight::get().reads((3_u64).saturating_mul(n.into()))) .saturating_add(RocksDbWeight::get().writes(2_u64)) @@ -1241,12 +1229,12 @@ impl WeightInfo for () { /// The range of component `n` is `[0, 256]`. fn payout_stakers_alive_staked(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `34971 + n * (401 ±0)` - // Estimated: `32376 + n * (3774 ±0)` - // Minimum execution time: 105_591_000 picoseconds. - Weight::from_parts(111_587_915, 32376) - // Standard Error: 15_598 - .saturating_add(Weight::from_parts(48_948_195, 0).saturating_mul(n.into())) + // Measured: `33190 + n * (377 ±0)` + // Estimated: `30845 + n * (3774 ±0)` + // Minimum execution time: 121_303_000 picoseconds. + Weight::from_parts(151_046_907, 30845) + // Standard Error: 41_899 + .saturating_add(Weight::from_parts(49_837_804, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(11_u64)) .saturating_add(RocksDbWeight::get().reads((6_u64).saturating_mul(n.into()))) .saturating_add(RocksDbWeight::get().writes(3_u64)) @@ -1259,8 +1247,6 @@ impl WeightInfo for () { /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) /// Storage: Balances Freezes (r:1 w:0) /// Proof: Balances Freezes (max_values: None, max_size: Some(49), added: 2524, mode: MaxEncodedLen) - /// Storage: System Account (r:1 w:1) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) /// Storage: VoterList ListNodes (r:3 w:3) /// Proof: VoterList ListNodes (max_values: None, max_size: Some(154), added: 2629, mode: MaxEncodedLen) /// Storage: Staking Bonded (r:1 w:0) @@ -1272,15 +1258,13 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `2029 + l * (7 ±0)` // Estimated: `8877` - // Minimum execution time: 89_420_000 picoseconds. - Weight::from_parts(90_743_615, 8877) - // Standard Error: 1_260 - .saturating_add(Weight::from_parts(50_832, 0).saturating_mul(l.into())) - .saturating_add(RocksDbWeight::get().reads(10_u64)) - .saturating_add(RocksDbWeight::get().writes(8_u64)) + // Minimum execution time: 90_068_000 picoseconds. + Weight::from_parts(93_137_456, 8877) + // Standard Error: 4_799 + .saturating_add(Weight::from_parts(54_421, 0).saturating_mul(l.into())) + .saturating_add(RocksDbWeight::get().reads(9_u64)) + .saturating_add(RocksDbWeight::get().writes(7_u64)) } - /// Storage: System Account (r:1 w:1) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) /// Storage: Staking Bonded (r:1 w:1) /// Proof: Staking Bonded (max_values: None, max_size: Some(72), added: 2547, mode: MaxEncodedLen) /// Storage: Staking Ledger (r:1 w:1) @@ -1312,12 +1296,12 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `2294 + s * (4 ±0)` // Estimated: `6248 + s * (4 ±0)` - // Minimum execution time: 100_911_000 picoseconds. - Weight::from_parts(102_678_006, 6248) - // Standard Error: 2_349 - .saturating_add(Weight::from_parts(1_262_431, 0).saturating_mul(s.into())) - .saturating_add(RocksDbWeight::get().reads(13_u64)) - .saturating_add(RocksDbWeight::get().writes(12_u64)) + // Minimum execution time: 103_139_000 picoseconds. + Weight::from_parts(107_036_296, 6248) + // Standard Error: 3_935 + .saturating_add(Weight::from_parts(1_465_860, 0).saturating_mul(s.into())) + .saturating_add(RocksDbWeight::get().reads(12_u64)) + .saturating_add(RocksDbWeight::get().writes(11_u64)) .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(s.into()))) .saturating_add(Weight::from_parts(0, 4).saturating_mul(s.into())) } @@ -1361,12 +1345,12 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0 + n * (720 ±0) + v * (3598 ±0)` // Estimated: `512390 + n * (3566 ±0) + v * (3566 ±0)` - // Minimum execution time: 554_712_000 picoseconds. - Weight::from_parts(556_603_000, 512390) - // Standard Error: 1_925_251 - .saturating_add(Weight::from_parts(62_627_196, 0).saturating_mul(v.into())) - // Standard Error: 191_840 - .saturating_add(Weight::from_parts(16_681_790, 0).saturating_mul(n.into())) + // Minimum execution time: 587_156_000 picoseconds. + Weight::from_parts(590_176_000, 512390) + // Standard Error: 2_008_420 + .saturating_add(Weight::from_parts(64_526_052, 0).saturating_mul(v.into())) + // Standard Error: 200_128 + .saturating_add(Weight::from_parts(18_070_222, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(206_u64)) .saturating_add(RocksDbWeight::get().reads((5_u64).saturating_mul(v.into()))) .saturating_add(RocksDbWeight::get().reads((4_u64).saturating_mul(n.into()))) @@ -1395,14 +1379,14 @@ impl WeightInfo for () { /// The range of component `n` is `[500, 1000]`. fn get_npos_voters(v: u32, n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `3135 + n * (911 ±0) + v * (395 ±0)` + // Measured: `3217 + n * (911 ±0) + v * (395 ±0)` // Estimated: `512390 + n * (3566 ±0) + v * (3566 ±0)` - // Minimum execution time: 31_770_670_000 picoseconds. - Weight::from_parts(31_839_042_000, 512390) - // Standard Error: 355_382 - .saturating_add(Weight::from_parts(5_044_540, 0).saturating_mul(v.into())) - // Standard Error: 355_382 - .saturating_add(Weight::from_parts(3_205_722, 0).saturating_mul(n.into())) + // Minimum execution time: 34_399_721_000 picoseconds. + Weight::from_parts(34_605_803_000, 512390) + // Standard Error: 380_106 + .saturating_add(Weight::from_parts(5_426_220, 0).saturating_mul(v.into())) + // Standard Error: 380_106 + .saturating_add(Weight::from_parts(3_318_197, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(201_u64)) .saturating_add(RocksDbWeight::get().reads((5_u64).saturating_mul(v.into()))) .saturating_add(RocksDbWeight::get().reads((4_u64).saturating_mul(n.into()))) @@ -1419,10 +1403,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `983 + v * (50 ±0)` // Estimated: `3510 + v * (2520 ±0)` - // Minimum execution time: 2_253_567_000 picoseconds. - Weight::from_parts(61_440_613, 3510) - // Standard Error: 5_276 - .saturating_add(Weight::from_parts(4_414_153, 0).saturating_mul(v.into())) + // Minimum execution time: 2_392_849_000 picoseconds. + Weight::from_parts(64_373_879, 3510) + // Standard Error: 8_995 + .saturating_add(Weight::from_parts(4_721_536, 0).saturating_mul(v.into())) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(v.into()))) .saturating_add(Weight::from_parts(0, 2520).saturating_mul(v.into())) @@ -1443,8 +1427,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 9_292_000 picoseconds. - Weight::from_parts(9_587_000, 0) + // Minimum execution time: 7_529_000 picoseconds. + Weight::from_parts(7_970_000, 0) .saturating_add(RocksDbWeight::get().writes(6_u64)) } /// Storage: Staking MinCommission (r:0 w:1) @@ -1463,8 +1447,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 8_294_000 picoseconds. - Weight::from_parts(8_597_000, 0) + // Minimum execution time: 7_011_000 picoseconds. + Weight::from_parts(7_317_000, 0) .saturating_add(RocksDbWeight::get().writes(6_u64)) } /// Storage: Staking Ledger (r:1 w:0) @@ -1491,8 +1475,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `1871` // Estimated: `6248` - // Minimum execution time: 75_742_000 picoseconds. - Weight::from_parts(76_252_000, 6248) + // Minimum execution time: 75_982_000 picoseconds. + Weight::from_parts(77_412_000, 6248) .saturating_add(RocksDbWeight::get().reads(11_u64)) .saturating_add(RocksDbWeight::get().writes(6_u64)) } @@ -1504,8 +1488,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `694` // Estimated: `3510` - // Minimum execution time: 16_407_000 picoseconds. - Weight::from_parts(16_726_000, 3510) + // Minimum execution time: 13_923_000 picoseconds. + Weight::from_parts(14_356_000, 3510) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -1515,8 +1499,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 4_977_000 picoseconds. - Weight::from_parts(5_224_000, 0) + // Minimum execution time: 3_415_000 picoseconds. + Weight::from_parts(3_679_000, 0) .saturating_add(RocksDbWeight::get().writes(1_u64)) } } diff --git a/pallets/storage-handler/Cargo.toml b/pallets/storage-handler/Cargo.toml index f50b5abf..39f01802 100644 --- a/pallets/storage-handler/Cargo.toml +++ b/pallets/storage-handler/Cargo.toml @@ -10,7 +10,7 @@ readme = "README.md" [dependencies] log = { workspace = true } -codec = { version = "3.2.2", package = "parity-scale-codec", default-features = false, features = ["derive"] } +codec = { package = "parity-scale-codec", version = "3.6.1", default-features = false, features = ["derive"] } scale-info = { workspace = true, features = ["derive"] } serde = { workspace = true, optional = true } diff --git a/pallets/storage-handler/src/lib.rs b/pallets/storage-handler/src/lib.rs index acd81dac..e36d6f0d 100644 --- a/pallets/storage-handler/src/lib.rs +++ b/pallets/storage-handler/src/lib.rs @@ -45,7 +45,6 @@ pub const SPACE_DEAD: &str = "dead"; type AccountOf = ::AccountId; type BalanceOf = <::Currency as Currency<::AccountId>>::Balance; -type BlockNumberOf = ::BlockNumber; const STORAGE_VERSION: StorageVersion = StorageVersion::new(1); @@ -64,7 +63,7 @@ pub mod pallet { type WeightInfo: WeightInfo; #[pallet::constant] - type OneDay: Get>; + type OneDay: Get>; /// pallet address. #[pallet::constant] type RewardPalletId: Get; @@ -73,11 +72,11 @@ pub mod pallet { type StateStringMax: Get + Clone + Eq + PartialEq; #[pallet::constant] - type FrozenDays: Get> + Clone + Eq + PartialEq; + type FrozenDays: Get> + Clone + Eq + PartialEq; type CessTreasuryHandle: TreasuryHandle, BalanceOf>; - type MyRandomness: Randomness, Self::BlockNumber>; + type MyRandomness: Randomness, BlockNumberFor>; } #[pallet::event] @@ -165,7 +164,6 @@ pub mod pallet { pub price: BalanceOf, } - #[cfg(feature = "std")] impl Default for GenesisConfig { fn default() -> Self { Self { @@ -175,7 +173,7 @@ pub mod pallet { } #[pallet::genesis_build] - impl GenesisBuild for GenesisConfig { + impl BuildGenesisConfig for GenesisConfig { fn build(&self) { UnitPrice::::put(self.price); } @@ -247,7 +245,7 @@ pub mod pallet { .checked_div(&30u32.saturated_into()).ok_or(Error::::Overflow)?; let space = G_BYTE.checked_mul(gib_count as u128).ok_or(Error::::Overflow)?; //Calculate remaining days. - let block_oneday: BlockNumberOf = ::OneDay::get(); + let block_oneday: BlockNumberFor = ::OneDay::get(); let diff_block = cur_owned_space.deadline.checked_sub(&now).ok_or(Error::::Overflow)?; let mut remain_day: u32 = diff_block .checked_div(&block_oneday) @@ -352,7 +350,7 @@ pub mod pallet { #[pallet::call_index(5)] #[transactional] #[pallet::weight(Weight::zero())] - pub fn update_user_life(origin: OriginFor, user: AccountOf, deadline: BlockNumberOf) -> DispatchResult { + pub fn update_user_life(origin: OriginFor, user: AccountOf, deadline: BlockNumberFor) -> DispatchResult { let _ = ensure_root(origin)?; >::try_mutate(&user, |space_opt| -> DispatchResult { @@ -464,10 +462,10 @@ impl Pallet { Ok(price) } - fn calculate_remain_day(deadline: BlockNumberOf) -> Result, DispatchError>{ + fn calculate_remain_day(deadline: BlockNumberFor) -> Result, DispatchError>{ let now = >::block_number(); //Calculate remaining days. - let block_oneday: BlockNumberOf = ::OneDay::get(); + let block_oneday: BlockNumberFor = ::OneDay::get(); let diff_block = deadline.checked_sub(&now).ok_or(Error::::Overflow)?; let mut remain_day: u32 = diff_block .checked_div(&block_oneday) @@ -495,7 +493,7 @@ impl Pallet { let s = s_opt.as_mut().ok_or(Error::::NotPurchasedSpace)?; let one_day = ::OneDay::get(); let now = >::block_number(); - let sur_block: BlockNumberOf = + let sur_block: BlockNumberFor = one_day.checked_mul(&days.saturated_into()).ok_or(Error::::Overflow)?; if now > s.deadline { s.start = now; @@ -552,7 +550,7 @@ impl Pallet { ) -> DispatchResult { let now = >::block_number(); let one_day = ::OneDay::get(); - let sur_block: BlockNumberOf = one_day + let sur_block: BlockNumberFor = one_day .checked_mul(&days.saturated_into()) .ok_or(Error::::Overflow)?; let deadline = now.checked_add(&sur_block).ok_or(Error::::Overflow)?; @@ -614,7 +612,7 @@ impl Pallet { } fn frozen_task() -> (Weight, Vec>) { - let now: BlockNumberOf = >::block_number(); + let now: BlockNumberFor = >::block_number(); let number: u128 = now.saturated_into(); let mut weight: Weight = Weight::zero(); @@ -624,7 +622,7 @@ impl Pallet { for (acc, info) in >::iter() { weight = weight.saturating_add(T::DbWeight::get().reads(1 as u64)); if now > info.deadline { - let frozen_day: BlockNumberOf = ::FrozenDays::get(); + let frozen_day: BlockNumberFor = ::FrozenDays::get(); if now > info.deadline + frozen_day { log::info!("clear user:#{}'s files", number); let result = >::try_mutate( diff --git a/pallets/storage-handler/src/types.rs b/pallets/storage-handler/src/types.rs index 7d22c6eb..7b179777 100644 --- a/pallets/storage-handler/src/types.rs +++ b/pallets/storage-handler/src/types.rs @@ -8,8 +8,8 @@ pub struct OwnedSpaceDetails { pub(super) used_space: u128, pub(super) locked_space: u128, pub(super) remaining_space: u128, - pub(super) start: BlockNumberOf, - pub(super) deadline: BlockNumberOf, + pub(super) start: BlockNumberFor, + pub(super) deadline: BlockNumberFor, pub(super) state: BoundedVec, } @@ -20,7 +20,7 @@ pub struct OrderInfo { pub(super) pay: BalanceOf, pub(super) gib_count: u32, pub(super) days: u32, - pub(super) expired: BlockNumberOf, + pub(super) expired: BlockNumberFor, pub(super) pay_acc: AccountOf, pub(super) target_acc: AccountOf, pub(super) order_type: OrderType, diff --git a/pallets/tee-worker/Cargo.toml b/pallets/tee-worker/Cargo.toml index b775e39a..b5aa29fc 100644 --- a/pallets/tee-worker/Cargo.toml +++ b/pallets/tee-worker/Cargo.toml @@ -12,7 +12,7 @@ readme = "README.md" chrono = { workspace = true } hex ={ workspace = true } serde = { workspace = true, optional = true } -codec = { version = "3.2.2", package = "parity-scale-codec", default-features = false, features = ["derive", "max-encoded-len"] } +codec = { package = "parity-scale-codec", version = "3.6.1", default-features = false, features = ["derive", "max-encoded-len"] } scale-info = { workspace = true, features = ['derive'] } serde_json = { workspace = true, features = ['alloc'] } log = { workspace = true } diff --git a/rustfmt.toml b/rustfmt.toml index f4d7ad63..c678b97f 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -1,4 +1,5 @@ # Basic +edition = "2021" hard_tabs = true max_width = 100 use_small_heuristics = "Max" diff --git a/standalone/chain/node/Cargo.toml b/standalone/chain/node/Cargo.toml index 56d0c6c9..d4511845 100644 --- a/standalone/chain/node/Cargo.toml +++ b/standalone/chain/node/Cargo.toml @@ -18,8 +18,8 @@ name = "cess-node" # third-party dependencies array-bytes = { workspace = true } async-trait = { workspace = true } -clap = { workspace = true, features = ["derive"], optional = true } -codec = { version = "3.2.2", package = "parity-scale-codec", default-features = false } +clap = { workspace = true, features = ["derive"] } +codec = { package = "parity-scale-codec", version = "3.6.1", default-features = false } serde = { workspace = true, features = ["derive"] } jsonrpsee = { workspace = true, features = ["server"] } futures = { workspace = true, features = ["thread-pool"]} @@ -27,23 +27,22 @@ log = { workspace = true } rand = { workspace = true } # primitives -# sp-authorship = { workspace = true } -sp-api = { workspace = true } -sp-authority-discovery = { workspace = true } -sp-core = { workspace = true } -sp-consensus = { workspace = true } -cessp-consensus-rrsc = { workspace = true } -sp-consensus-grandpa = { workspace = true } -sp-runtime = { workspace = true } -sp-timestamp = { workspace = true } -sp-transaction-pool = { workspace = true } -sp-inherents = { workspace = true } +sp-api = { workspace = true, features = ["std", "frame-metadata"]} +sp-authority-discovery = { workspace = true, features = ["default"] } +sp-core = { workspace = true, features = ["default"] } +sp-consensus = { workspace = true, features = ["default"] } +cessp-consensus-rrsc = { workspace = true, features = ["default"] } +sp-consensus-grandpa = { workspace = true, features = ["default"] } +sp-runtime = { workspace = true, features = ["default"] } +sp-timestamp = { workspace = true, features = ["default"] } +sp-transaction-pool = { workspace = true, features = ["default"] } +sp-inherents = { workspace = true, features = ["default"] } sp-keyring = { workspace = true } -sp-keystore = { workspace = true } -sp-transaction-storage-proof = { workspace = true } -sp-offchain = { workspace = true } -sp-session = { workspace = true } -sp-trie = { workspace = true } +sp-keystore = { workspace = true, features = ["default"] } +sp-transaction-storage-proof = { workspace = true, features = ["default"] } +sp-offchain = { workspace = true, features = ["default"] } +sp-session = { workspace = true, features = ["default"] } +sp-trie = { workspace = true, features = ["default"] } # client dependencies sc-client-api = { workspace = true } @@ -55,9 +54,9 @@ sc-transaction-pool-api = { workspace = true } sc-network = { workspace = true } sc-network-common = { workspace = true } sc-network-sync = { workspace = true } +sc-offchain = { workspace = true } sc-consensus-slots = { workspace = true } cessc-consensus-rrsc = { workspace = true } -# sc-consensus-uncles = { workspace = true } grandpa = { workspace = true } sc-rpc = { workspace = true } sc-basic-authorship = { workspace = true } @@ -75,10 +74,10 @@ frame-system-rpc-runtime-api = { workspace = true } pallet-transaction-payment = { workspace = true } pallet-transaction-payment-rpc = { workspace = true } pallet-transaction-payment-rpc-runtime-api = { workspace = true } -pallet-im-online = { workspace = true } +pallet-im-online = { workspace = true, features = ["default"] } # node-specific dependencies -cess-node-runtime = { workspace = true } +cess-node-runtime = { workspace = true, features = ["std"] } # CLI-specific dependencies sc-cli = { workspace = true } @@ -93,17 +92,18 @@ mmr-rpc = { workspace = true } substrate-state-trie-migration-rpc = { workspace = true } sc-keystore = { workspace = true } sc-rpc-api = { workspace = true } -sp-block-builder = { workspace = true } +sp-block-builder = { workspace = true, features = ["default"] } sp-blockchain = { workspace = true } substrate-frame-rpc-system = { workspace = true } sc-rpc-spec-v2 = { workspace = true } -pallet-audit = { workspace = true } +pallet-audit = { workspace = true, features = ["default"] } sc-consensus-grandpa-rpc = { workspace = true } cessc-consensus-rrsc-rpc = { workspace = true } sc-consensus-epochs = { workspace = true } -pallet-contracts = { workspace = true } +pallet-contracts = { workspace = true, features = ["default"] } # Frontier +fc-api = { workspace = true } fc-cli = { workspace = true } fc-consensus = { workspace = true } fc-db = { workspace = true } @@ -112,9 +112,9 @@ fc-rpc = { workspace = true } fc-rpc-core = { workspace = true } fc-storage = { workspace = true } fp-account = { workspace = true } -fp-dynamic-fee = { workspace = true } -fp-evm = { workspace = true } -fp-rpc = { workspace = true } +fp-dynamic-fee = { workspace = true, features = ["default"] } +fp-evm = { workspace = true, features = ["default"] } +fp-rpc = { workspace = true, features = ["default"] } [build-dependencies] try-runtime-cli = { workspace = true, optional = true } @@ -122,10 +122,9 @@ substrate-build-script-utils = { workspace = true } [features] default = [ - "cli", - # "with-rocksdb-weights", "rocksdb", "sql", + "txpool" ] rocksdb = [ "sc-cli/rocksdb", @@ -139,17 +138,15 @@ sql = [ "fc-db/sql", "fc-mapping-sync/sql", ] -# with-rocksdb-weights = ["frontier-template-runtime/with-rocksdb-weights"] -# with-paritydb-weights = ["frontier-template-runtime/with-paritydb-weights"] -# rpc-binary-search-estimate = ["fc-rpc/rpc-binary-search-estimate"] +txpool = [ + "fc-rpc/txpool" +] runtime-benchmarks = [ 'cess-node-runtime/runtime-benchmarks', "frame-benchmarking/runtime-benchmarks", "frame-benchmarking-cli/runtime-benchmarks", ] -try-runtime = ["cess-node-runtime/try-runtime", "try-runtime-cli"] - -cli = [ - "clap", - "try-runtime-cli", +try-runtime = [ + "cess-node-runtime/try-runtime", + "try-runtime-cli/try-runtime" ] diff --git a/standalone/chain/node/src/chain_spec.rs b/standalone/chain/node/src/chain_spec.rs index fef9e579..4c61c924 100644 --- a/standalone/chain/node/src/chain_spec.rs +++ b/standalone/chain/node/src/chain_spec.rs @@ -3,11 +3,11 @@ use sp_consensus_grandpa::AuthorityId as GrandpaId; use cess_node_runtime::{ - opaque::SessionKeys, wasm_binary_unwrap, AccountId, AuthorityDiscoveryConfig, Balance, - BalancesConfig, Block, CouncilConfig, GenesisConfig, GrandpaConfig, ImOnlineConfig, + opaque::SessionKeys, wasm_binary_unwrap, AccountId, Balance, + BalancesConfig, Block, CouncilConfig, ImOnlineConfig, IndicesConfig, MaxNominations, BabeConfig, SessionConfig, Signature, StakerStatus, StakingConfig, SudoConfig, SystemConfig, TechnicalCommitteeConfig, DOLLARS, - StorageHandlerConfig, SminerConfig, EVMChainIdConfig, + StorageHandlerConfig, EVMChainIdConfig, }; use pallet_im_online::sr25519::AuthorityId as ImOnlineId; @@ -23,6 +23,8 @@ use sp_runtime::{ Perbill, }; +pub use cess_node_runtime::RuntimeGenesisConfig; + // The URL for the telemetry server. const STAGING_TELEMETRY_URL: &str = "wss://telemetry.polkadot.io/submit/"; @@ -47,7 +49,7 @@ pub struct Extensions { } /// Specialized `ChainSpec`. -pub type ChainSpec = sc_service::GenericChainSpec; +pub type ChainSpec = sc_service::GenericChainSpec; type AccountPublic = ::Signer; @@ -83,7 +85,7 @@ pub fn authority_keys_from_seed( ) } -fn cess_main_genesis() -> GenesisConfig { +fn cess_main_genesis() -> RuntimeGenesisConfig { #[rustfmt::skip] let initial_authorities: Vec<( AccountId, @@ -227,7 +229,7 @@ fn cess_main_genesis() -> GenesisConfig { testnet_genesis(initial_authorities, vec![], root_key, Some(endowed_accounts)) } -fn cess_testnet_config_genesis() -> GenesisConfig { +fn cess_testnet_config_genesis() -> RuntimeGenesisConfig { #[rustfmt::skip] // stash, controller, session-key // generated with secret: @@ -401,7 +403,7 @@ pub fn cess_main() -> ChainSpec { ) } -fn development_config_genesis() -> GenesisConfig { +fn development_config_genesis() -> RuntimeGenesisConfig { testnet_genesis( vec![authority_keys_from_seed("Alice")], vec![], @@ -438,7 +440,7 @@ pub fn development_config() -> ChainSpec { ) } -fn local_testnet_genesis() -> GenesisConfig { +fn local_testnet_genesis() -> RuntimeGenesisConfig { testnet_genesis( vec![authority_keys_from_seed("Alice"), authority_keys_from_seed("Bob")], vec![], @@ -483,7 +485,7 @@ fn testnet_genesis( initial_nominators: Vec, root_key: AccountId, endowed_accounts: Option>, -) -> GenesisConfig { +) -> RuntimeGenesisConfig { let mut endowed_accounts: Vec = endowed_accounts.unwrap_or_else(|| { vec![ get_account_id_from_seed::("Alice"), @@ -535,15 +537,15 @@ fn testnet_genesis( const ENDOWMENT: Balance = 100_000_000 * DOLLARS; const STASH: Balance = 3_000_000 * DOLLARS; - GenesisConfig { - system: SystemConfig { code: wasm_binary_unwrap().to_vec() }, + RuntimeGenesisConfig { + system: SystemConfig { code: wasm_binary_unwrap().to_vec(), ..Default::default() }, balances: BalancesConfig { // Configure endowed accounts with initial balance of ENDOWMENT. balances: endowed_accounts.iter().cloned().map(|k| (k, ENDOWMENT)).collect(), }, storage_handler: StorageHandlerConfig { price: 30 * DOLLARS }, // FOR TESTING - sminer: SminerConfig { expenders: (8, 1024 * 1024, 64) }, + sminer: Default::default(), indices: IndicesConfig { indices: vec![] }, session: SessionConfig { keys: initial_authorities @@ -582,10 +584,11 @@ fn testnet_genesis( babe: BabeConfig { authorities: vec![], epoch_config: Some(cess_node_runtime::RRSC_GENESIS_EPOCH_CONFIG), + ..Default::default() }, im_online: ImOnlineConfig { keys: vec![] }, - authority_discovery: AuthorityDiscoveryConfig { keys: vec![] }, - grandpa: GrandpaConfig { authorities: vec![] }, + authority_discovery: Default::default(), + grandpa: Default::default(), technical_membership: Default::default(), treasury: Default::default(), sudo: SudoConfig { @@ -598,6 +601,6 @@ fn testnet_genesis( ethereum: Default::default(), dynamic_fee: Default::default(), base_fee: Default::default(), - evm_chain_id: EVMChainIdConfig { chain_id: 11330 }, + evm_chain_id: EVMChainIdConfig { chain_id: 11330, ..Default::default() }, } } diff --git a/standalone/chain/node/src/cli.rs b/standalone/chain/node/src/cli.rs index c322c7e9..0e6f01a0 100644 --- a/standalone/chain/node/src/cli.rs +++ b/standalone/chain/node/src/cli.rs @@ -18,13 +18,13 @@ pub struct Cli { pub subcommand: Option, #[allow(missing_docs)] - #[clap(flatten)] + #[command(flatten)] pub run: sc_cli::RunCmd, /// Choose sealing method. #[arg(long, value_enum, ignore_case = true)] pub sealing: Option, - + #[command(flatten)] pub eth: EthConfiguration, /// Disable automatic hardware benchmarks. @@ -81,12 +81,20 @@ pub enum Subcommand { PurgeChain(sc_cli::PurgeChainCmd), /// Sub-commands concerned with benchmarking. + #[cfg(feature = "runtime-benchmarks")] #[command(subcommand)] Benchmark(frame_benchmarking_cli::BenchmarkCmd), + /// Sub-commands concerned with benchmarking. + #[cfg(not(feature = "runtime-benchmarks"))] + Benchmark, + /// Revert the chain to a previous state. Revert(sc_cli::RevertCmd), /// Db meta columns information. ChainInfo(sc_cli::ChainInfoCmd), + + /// Db meta columns information. + FrontierDb(fc_cli::FrontierDbCmd), } diff --git a/standalone/chain/node/src/client.rs b/standalone/chain/node/src/client.rs index 07cad999..c68d1f7a 100644 --- a/standalone/chain/node/src/client.rs +++ b/standalone/chain/node/src/client.rs @@ -1,8 +1,7 @@ - +// Substrate use sc_executor::{NativeElseWasmExecutor, NativeExecutionDispatch, NativeVersion}; -use sp_runtime::traits::BlakeTwo256; -use cess_node_runtime::{opaque::Block, AccountId, Balance, Index}; +use cess_node_runtime::{opaque::Block, AccountId, Balance, Nonce}; use crate::eth::EthCompatRuntimeApiCollection; @@ -12,7 +11,7 @@ pub type FullBackend = sc_service::TFullBackend; pub type FullClient = sc_service::TFullClient>; -// pub type Client = FullClient; +pub type Client = FullClient; /// Only enable the benchmarking host functions when we actually want to benchmark. #[cfg(feature = "runtime-benchmarks")] @@ -42,20 +41,16 @@ pub trait BaseRuntimeApiCollection: + sp_offchain::OffchainWorkerApi + sp_session::SessionKeys + sp_transaction_pool::runtime_api::TaggedTransactionQueue -where - >::StateBackend: sp_api::StateBackend, { } -impl BaseRuntimeApiCollection for Api -where +impl BaseRuntimeApiCollection for Api where Api: sp_api::ApiExt + sp_api::Metadata + sp_block_builder::BlockBuilder + sp_offchain::OffchainWorkerApi + sp_session::SessionKeys - + sp_transaction_pool::runtime_api::TaggedTransactionQueue, - >::StateBackend: sp_api::StateBackend, + + sp_transaction_pool::runtime_api::TaggedTransactionQueue { } @@ -66,22 +61,18 @@ pub trait RuntimeApiCollection: + cessc_consensus_rrsc::RRSCApi + sp_consensus_grandpa::GrandpaApi + sp_authority_discovery::AuthorityDiscoveryApi - + frame_system_rpc_runtime_api::AccountNonceApi + + frame_system_rpc_runtime_api::AccountNonceApi + pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi -where - >::StateBackend: sp_api::StateBackend, { } -impl RuntimeApiCollection for Api -where +impl RuntimeApiCollection for Api where Api: BaseRuntimeApiCollection + EthCompatRuntimeApiCollection + cessc_consensus_rrsc::RRSCApi + sp_consensus_grandpa::GrandpaApi - + sp_authority_discovery::AuthorityDiscoveryApi - + frame_system_rpc_runtime_api::AccountNonceApi - + pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi, - >::StateBackend: sp_api::StateBackend, + + sp_authority_discovery::AuthorityDiscoveryApi + + frame_system_rpc_runtime_api::AccountNonceApi + + pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi { } diff --git a/standalone/chain/node/src/command.rs b/standalone/chain/node/src/command.rs index 6e1c1856..4b6fe92e 100644 --- a/standalone/chain/node/src/command.rs +++ b/standalone/chain/node/src/command.rs @@ -1,33 +1,37 @@ // This file is part of Substrate. -// Copyright (C) 2017-2022 Parity Technologies (UK) Ltd. -// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0 +// Copyright (C) 2017-2021 Parity Technologies (UK) Ltd. +// SPDX-License-Identifier: Apache-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. +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. -// 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 . +use std::sync::Arc; use futures::TryFutureExt; -#[cfg(feature = "runtime-benchmarks")] -use crate::benchmarking::{inherent_benchmark_data, RemarkBuilder, TransferKeepAliveBuilder}; +// Substrate +use sc_cli::SubstrateCli; +use sc_service::DatabaseSource; +// Frontier +use fc_db::kv::frontier_database_dir; use crate::{ chain_spec, cli::{Cli, Subcommand}, - service::{ self, FullClient }, - client::CESSNodeRuntimeExecutor, + eth::db_config_dir, + service, }; -use cess_node_runtime::{Block}; -use sc_cli::{ChainSpec, Result, RuntimeVersion, SubstrateCli}; +use cess_node_runtime::Block; -use std::sync::Arc; +#[cfg(feature = "runtime-benchmarks")] +use crate::chain_spec::get_account_id_from_seed; impl SubstrateCli for Cli { fn impl_name() -> String { @@ -68,13 +72,10 @@ impl SubstrateCli for Cli { Ok(spec) } - fn native_runtime_version(_: &Box) -> &'static RuntimeVersion { - &cess_node_runtime::VERSION - } } -/// Parse command line arguments into service configuration. -pub fn run() -> Result<()> { +/// Parse and run command line arguments +pub fn run() -> sc_cli::Result<()> { let cli = Cli::from_args(); match &cli.subcommand { @@ -128,89 +129,133 @@ pub fn run() -> Result<()> { }, Some(Subcommand::PurgeChain(cmd)) => { let runner = cli.create_runner(cmd)?; - runner.sync_run(|config| cmd.run(config.database)) + runner.sync_run(|config| { + // Remove Frontier offchain db + let db_config_dir = db_config_dir(&config); + match cli.eth.frontier_backend_type { + crate::eth::BackendType::KeyValue => { + let frontier_database_config = match config.database { + DatabaseSource::RocksDb { .. } => DatabaseSource::RocksDb { + path: frontier_database_dir(&db_config_dir, "db"), + cache_size: 0, + }, + DatabaseSource::ParityDb { .. } => DatabaseSource::ParityDb { + path: frontier_database_dir(&db_config_dir, "paritydb"), + }, + _ => { + return Err(format!( + "Cannot purge `{:?}` database", + config.database + ) + .into()) + } + }; + cmd.run(frontier_database_config)?; + } + crate::eth::BackendType::Sql => { + let db_path = db_config_dir.join("sql"); + match std::fs::remove_dir_all(&db_path) { + Ok(_) => { + println!("{:?} removed.", &db_path); + } + Err(ref err) if err.kind() == std::io::ErrorKind::NotFound => { + eprintln!("{:?} did not exist.", &db_path); + } + Err(err) => { + return Err(format!( + "Cannot purge `{:?}` database: {:?}", + db_path, err, + ) + .into()) + } + }; + } + }; + cmd.run(config.database) + }) }, Some(Subcommand::Revert(cmd)) => { let runner = cli.create_runner(cmd)?; runner.async_run(|mut config| { let (client, backend, _, task_manager, _) = service::new_chain_ops(&mut config, &cli.eth)?; - let aux_revert = Box::new(|client: Arc>, backend, blocks| { - cessc_consensus_rrsc::revert(client.clone(), backend, blocks)?; - grandpa::revert(client, blocks)?; - Ok(()) - }); + let aux_revert = { + let backend = backend.clone(); + Box::new(move |client: Arc, _, blocks| { + cessc_consensus_rrsc::revert(client.clone(), backend, blocks)?; + grandpa::revert(client, blocks)?; + Ok(()) + }) + }; Ok((cmd.run(client, backend, Some(aux_revert)), task_manager)) }) }, - #[cfg(not(feature = "runtime-benchmarks"))] - Some(Subcommand::Benchmark(_)) => Err("Benchmarking wasn't enabled when building the node. \ + #[cfg(not(feature = "runtime-benchmarks"))] + Some(Subcommand::Benchmark) => Err("Benchmarking wasn't enabled when building the node. \ You can enable it with `--features runtime-benchmarks`." .into()), #[cfg(feature = "runtime-benchmarks")] Some(Subcommand::Benchmark(cmd)) => { + use crate::benchmarking::{ + inherent_benchmark_data, RemarkBuilder, TransferKeepAliveBuilder, + }; + use frame_benchmarking_cli::{ + BenchmarkCmd, ExtrinsicFactory, SUBSTRATE_REFERENCE_HARDWARE, + }; + let runner = cli.create_runner(cmd)?; + match cmd { + BenchmarkCmd::Pallet(cmd) => runner.sync_run(|config| cmd.run::(config)), + BenchmarkCmd::Block(cmd) => runner.sync_run(|mut config| { + let (client, _, _, _, _) = service::new_chain_ops(&mut config, &cli.eth)?; + cmd.run(client) + }), + BenchmarkCmd::Storage(cmd) => runner.sync_run(|mut config| { + let (client, backend, _, _, _) = service::new_chain_ops(&mut config, &cli.eth)?; + let db = backend.expose_db(); + let storage = backend.expose_storage(); + cmd.run(config, client, db, storage) + }), + BenchmarkCmd::Overhead(cmd) => runner.sync_run(|mut config| { + let (client, _, _, _, _) = service::new_chain_ops(&mut config, &cli.eth)?; + let ext_builder = RemarkBuilder::new(client.clone()); + cmd.run( + config, + client, + inherent_benchmark_data()?, + Vec::new(), + &ext_builder, + ) + }), + BenchmarkCmd::Extrinsic(cmd) => runner.sync_run(|mut config| { + let (client, _, _, _, _) = service::new_chain_ops(&mut config, &cli.eth)?; + // Register the *Remark* and *TKA* builders. + let ext_factory = ExtrinsicFactory(vec![ + Box::new(RemarkBuilder::new(client.clone())), + Box::new(TransferKeepAliveBuilder::new( + client.clone(), + get_account_id_from_seed::("Alice"), + ExistentialDeposit::get(), + )), + ]); - runner.sync_run(|config| { - // This switch needs to be in the client, since the client decides - // which sub-commands it wants to support. - match cmd { - BenchmarkCmd::Pallet(cmd) => { - if !cfg!(feature = "runtime-benchmarks") { - return Err( - "Runtime benchmarking wasn't enabled when building the node. \ - You can enable it with `--features runtime-benchmarks`." - .into(), - ) - } - - cmd.run::(config) - }, - BenchmarkCmd::Block(cmd) => { - let (client, _, _, _, _) = - service::new_chain_ops(&mut config, &cli.eth)?; - cmd.run(client) - }, - #[cfg(not(feature = "runtime-benchmarks"))] - BenchmarkCmd::Storage(_) => Err( - "Storage benchmarking can be enabled with `--features runtime-benchmarks`." - .into(), - ), - #[cfg(feature = "runtime-benchmarks")] - BenchmarkCmd::Storage(cmd) => { - let (client, backend, _, _, _) = service::new_chain_ops(&mut config, &cli.eth)?; - let db = backend.expose_db(); - let storage = backend.expose_storage(); - cmd.run(config, client, db, storage) - }, - BenchmarkCmd::Overhead(cmd) => { - let (client, _, _, _, _) = service::new_chain_ops(&mut config, &cli.eth)?; - let ext_builder = RemarkBuilder::new(client.clone()); - cmd.run( - config, - client, - inherent_benchmark_data()?, - Vec::new(), - &ext_builder, - ) - }, - BenchmarkCmd::Extrinsic(cmd) => { - let (client, _, _, _, _) = service::new_chain_ops(&mut config, &cli.eth)?; - // Register the *Remark* and *TKA* builders. - let ext_factory = ExtrinsicFactory(vec![ - Box::new(RemarkBuilder::new(client.clone())), - Box::new(TransferKeepAliveBuilder::new( - client.clone(), - get_account_id_from_seed::("Alice"), - ExistentialDeposit::get(), - )), - ]); - - cmd.run(client, inherent_benchmark_data()?, Vec::new(), &ext_factory) - }, - BenchmarkCmd::Machine(cmd) => + cmd.run(client, inherent_benchmark_data()?, Vec::new(), &ext_factory) + }), + BenchmarkCmd::Machine(cmd) => { runner.sync_run(|config| cmd.run(&config, SUBSTRATE_REFERENCE_HARDWARE.clone())) } + } + }, + Some(Subcommand::FrontierDb(cmd)) => { + let runner = cli.create_runner(cmd)?; + runner.sync_run(|mut config| { + let (client, _, _, _, frontier_backend) = + service::new_chain_ops(&mut config, &cli.eth)?; + let frontier_backend = match frontier_backend { + fc_db::Backend::KeyValue(kv) => std::sync::Arc::new(kv), + _ => panic!("Only fc_db::Backend::KeyValue supported"), + }; + cmd.run(client, frontier_backend) }) }, #[cfg(feature = "try-runtime")] diff --git a/standalone/chain/node/src/eth.rs b/standalone/chain/node/src/eth.rs index d5987e3d..00cf629c 100644 --- a/standalone/chain/node/src/eth.rs +++ b/standalone/chain/node/src/eth.rs @@ -7,12 +7,11 @@ use std::{ use futures::{future, prelude::*}; // Substrate -use sc_client_api::{BlockchainEvents, StateBackendFor}; +use sc_client_api::BlockchainEvents; use sc_executor::NativeExecutionDispatch; use sc_network_sync::SyncingService; -use sc_service::{error::Error as ServiceError, BasePath, Configuration, TaskManager}; +use sc_service::{error::Error as ServiceError, Configuration, TaskManager}; use sp_api::ConstructRuntimeApi; -use sp_runtime::traits::BlakeTwo256; // Frontier pub use fc_consensus::FrontierBlockImport; use fc_rpc::{EthTask, OverrideHandle}; @@ -26,14 +25,7 @@ use crate::client::{FullBackend, FullClient}; pub type FrontierBackend = fc_db::Backend; pub fn db_config_dir(config: &Configuration) -> PathBuf { - let application = &config.impl_name; - config - .base_path - .as_ref() - .map(|base_path| base_path.config_dir(config.chain_spec.id())) - .unwrap_or_else(|| { - BasePath::from_project("", "", application).config_dir(config.chain_spec.id()) - }) + config.base_path.config_dir(config.chain_spec.id()) } /// Avalailable frontier backend types. @@ -120,17 +112,14 @@ pub trait EthCompatRuntimeApiCollection: sp_api::ApiExt + fp_rpc::ConvertTransactionRuntimeApi + fp_rpc::EthereumRuntimeRPCApi -where - >::StateBackend: sp_api::StateBackend, { } -impl EthCompatRuntimeApiCollection for Api +impl EthCompatRuntimeApiCollection for Api where Api: sp_api::ApiExt + fp_rpc::ConvertTransactionRuntimeApi - + fp_rpc::EthereumRuntimeRPCApi, - >::StateBackend: sp_api::StateBackend, + + fp_rpc::EthereumRuntimeRPCApi { } @@ -152,8 +141,7 @@ pub async fn spawn_frontier_tasks( ) where RuntimeApi: ConstructRuntimeApi>, RuntimeApi: Send + Sync + 'static, - RuntimeApi::RuntimeApi: - EthCompatRuntimeApiCollection>, + RuntimeApi::RuntimeApi: EthCompatRuntimeApiCollection, Executor: NativeExecutionDispatch + 'static, { // Spawn main mapping sync worker background task. @@ -221,4 +209,4 @@ pub async fn spawn_frontier_tasks( fee_history_cache_limit, ), ); -} \ No newline at end of file +} diff --git a/standalone/chain/node/src/executor.rs b/standalone/chain/node/src/executor.rs deleted file mode 100755 index 795949af..00000000 --- a/standalone/chain/node/src/executor.rs +++ /dev/null @@ -1,21 +0,0 @@ -pub use sc_executor::NativeElseWasmExecutor; - -// Declare an instance of the native executor named `ExecutorDispatch`. Include the wasm binary as -// the equivalent wasm code. -pub struct ExecutorDispatch; - -impl sc_executor::NativeExecutionDispatch for ExecutorDispatch { - #[cfg(feature = "runtime-benchmarks")] - type ExtendHostFunctions = frame_benchmarking::benchmarking::HostFunctions; - - #[cfg(not(feature = "runtime-benchmarks"))] - type ExtendHostFunctions = (); - - fn dispatch(method: &str, data: &[u8]) -> Option> { - cess_node_runtime::api::dispatch(method, data) - } - - fn native_version() -> sc_executor::NativeVersion { - cess_node_runtime::native_version() - } -} diff --git a/standalone/chain/node/src/main.rs b/standalone/chain/node/src/main.rs index ae7f01e3..d082f361 100755 --- a/standalone/chain/node/src/main.rs +++ b/standalone/chain/node/src/main.rs @@ -14,8 +14,6 @@ mod chain_spec; mod service; mod cli; mod command; -mod executor; -mod primitives; mod rpc; mod eth; mod client; diff --git a/standalone/chain/node/src/primitives.rs b/standalone/chain/node/src/primitives.rs deleted file mode 100755 index 5b8146cc..00000000 --- a/standalone/chain/node/src/primitives.rs +++ /dev/null @@ -1,29 +0,0 @@ -use sp_runtime::{ - generic, - traits::{BlakeTwo256, IdentifyAccount, Verify}, - MultiSignature, OpaqueExtrinsic, -}; - -/// An index to a block. -pub type BlockNumber = u32; - -/// Alias to 512-bit hash when used in the context of a transaction signature on the chain. -pub type Signature = MultiSignature; - -/// Some way of identifying an account on the chain. We intentionally make it equivalent -/// to the public key of our transaction signing scheme. -pub type AccountId = <::Signer as IdentifyAccount>::AccountId; - -/// Balance of an account. -pub type Balance = u128; - -/// Index of a transaction in the chain. -pub type Index = u32; - -/// A hash of some data used by the chain. -pub type Hash = sp_core::H256; - -/// Header type. -pub type Header = generic::Header; -/// Block type. -pub type Block = generic::Block; diff --git a/standalone/chain/node/src/rpc/eth.rs b/standalone/chain/node/src/rpc/eth.rs index 2117cc6b..74c646c1 100644 --- a/standalone/chain/node/src/rpc/eth.rs +++ b/standalone/chain/node/src/rpc/eth.rs @@ -5,6 +5,7 @@ use jsonrpsee::RpcModule; use sc_client_api::{ backend::{Backend, StorageProvider}, client::BlockchainEvents, + AuxStore, UsageProvider, }; use sc_network::NetworkService; use sc_network_sync::SyncingService; @@ -15,15 +16,16 @@ use sp_api::{CallApiAt, ProvideRuntimeApi}; use sp_block_builder::BlockBuilder as BlockBuilderApi; use sp_blockchain::{Error as BlockChainError, HeaderBackend, HeaderMetadata}; use sp_core::H256; +use sp_inherents::CreateInherentDataProviders; use sp_runtime::traits::Block as BlockT; // Frontier -pub use fc_rpc::{EthBlockDataCacheTask, EthConfig, OverrideHandle, StorageOverride, TxPool}; +pub use fc_rpc::{EthBlockDataCacheTask, EthConfig, OverrideHandle, StorageOverride}; pub use fc_rpc_core::types::{FeeHistoryCache, FeeHistoryCacheLimit, FilterPool}; pub use fc_storage::overrides_handle; use fp_rpc::{ConvertTransaction, ConvertTransactionRuntimeApi, EthereumRuntimeRPCApi}; /// Extra dependencies for Ethereum compatibility. -pub struct EthDeps { +pub struct EthDeps { /// The client instance to use. pub client: Arc, /// Transaction pool instance. @@ -41,7 +43,7 @@ pub struct EthDeps { /// Chain syncing service pub sync: Arc>, /// Frontier Backend. - pub frontier_backend: Arc + Send + Sync>, + pub frontier_backend: Arc>, /// Ethereum data access overrides. pub overrides: Arc>, /// Cache for Ethereum block data. @@ -59,9 +61,11 @@ pub struct EthDeps { pub execute_gas_limit_multiplier: u64, /// Mandated parent hashes for a given block hash. pub forced_parent_hashes: Option>, + /// Something that can create the inherent data providers for pending state + pub pending_create_inherent_data_providers: CIDP, } -impl Clone for EthDeps { +impl Clone for EthDeps { fn clone(&self) -> Self { Self { client: self.client.clone(), @@ -81,14 +85,15 @@ impl Clone for EthDeps fee_history_cache_limit: self.fee_history_cache_limit, execute_gas_limit_multiplier: self.execute_gas_limit_multiplier, forced_parent_hashes: self.forced_parent_hashes.clone(), + pending_create_inherent_data_providers: self.pending_create_inherent_data_providers.clone(), } } } /// Instantiate Ethereum-compatible RPC extensions. -pub fn create_eth>( +pub fn create_eth( mut io: RpcModule<()>, - deps: EthDeps, + deps: EthDeps, subscription_task_executor: SubscriptionTaskExecutor, pubsub_notification_sinks: Arc< fc_mapping_sync::EthereumBlockNotificationSinks< @@ -97,20 +102,26 @@ pub fn create_eth>( >, ) -> Result, Box> where - B: BlockT, + B: BlockT, C: CallApiAt + ProvideRuntimeApi, - C::Api: BlockBuilderApi + ConvertTransactionRuntimeApi + EthereumRuntimeRPCApi, - C: BlockchainEvents + 'static, - C: HeaderBackend + HeaderMetadata + StorageProvider, + C::Api: BlockBuilderApi + + ConvertTransactionRuntimeApi + + EthereumRuntimeRPCApi, + C: HeaderBackend + HeaderMetadata, + C: BlockchainEvents + AuxStore + UsageProvider + StorageProvider + 'static, BE: Backend + 'static, P: TransactionPool + 'static, A: ChainApi + 'static, CT: ConvertTransaction<::Extrinsic> + Send + Sync + 'static, + CIDP: CreateInherentDataProviders + Send + 'static, + EC: EthConfig, { use fc_rpc::{ Eth, EthApiServer, EthDevSigner, EthFilter, EthFilterApiServer, EthPubSub, - EthPubSubApiServer, EthSigner, Net, NetApiServer, TxPoolApiServer, Web3, Web3ApiServer, + EthPubSubApiServer, EthSigner, Net, NetApiServer, Web3, Web3ApiServer, }; + #[cfg(feature = "txpool")] + use fc_rpc::{TxPool, TxPoolApiServer}; let EthDeps { client, @@ -130,6 +141,7 @@ where fee_history_cache_limit, execute_gas_limit_multiplier, forced_parent_hashes, + pending_create_inherent_data_providers, } = deps; let mut signers = Vec::new(); @@ -138,7 +150,7 @@ where } io.merge( - Eth::new( + Eth::::new( client.clone(), pool.clone(), graph.clone(), @@ -153,18 +165,19 @@ where fee_history_cache_limit, execute_gas_limit_multiplier, forced_parent_hashes, + pending_create_inherent_data_providers, + None, // Some(Box::new(AuraConsensusDataProvider::new(client.clone()))), ) .replace_config::() .into_rpc(), )?; - let tx_pool = TxPool::new(client.clone(), graph); if let Some(filter_pool) = filter_pool { io.merge( EthFilter::new( client.clone(), frontier_backend, - tx_pool.clone(), + graph.clone(), filter_pool, 500_usize, // max stored filters max_past_logs, @@ -196,8 +209,10 @@ where .into_rpc(), )?; - io.merge(Web3::new(client).into_rpc())?; - io.merge(tx_pool.into_rpc())?; + io.merge(Web3::new(client.clone()).into_rpc())?; + + #[cfg(feature = "txpool")] + io.merge(TxPool::new(client, graph).into_rpc())?; Ok(io) } diff --git a/standalone/chain/node/src/rpc/mod.rs b/standalone/chain/node/src/rpc/mod.rs index 51a4f833..6ccd7b94 100644 --- a/standalone/chain/node/src/rpc/mod.rs +++ b/standalone/chain/node/src/rpc/mod.rs @@ -1,37 +1,32 @@ //! A collection of node-specific RPC methods. -//! Substrate provides the `sc-rpc` crate, which defines the core RPC layer -//! used by Substrate nodes. This file extends those RPC definitions with -//! capabilities that are specific to this project's runtime configuration. -#![warn(missing_docs)] +use std::sync::Arc; -use crate::primitives as node_primitives; -use std::{sync::Arc}; -use futures::channel::mpsc; -use node_primitives::{AccountId, Balance, Block, BlockNumber, Hash, Index}; use jsonrpsee::RpcModule; - // Substrate -use sc_client_api::{ - backend::{AuxStore, Backend, StorageProvider}, - client::BlockchainEvents, -}; +use cessc_consensus_rrsc::RRSCWorkerHandle; +use cessc_consensus_rrsc_rpc::{RRSCApiServer, RRSC}; +use cessp_consensus_rrsc::RRSCApi; use grandpa::{ FinalityProofProvider, GrandpaJustificationStream, SharedAuthoritySet, SharedVoterState, }; -use sc_consensus_manual_seal::rpc::EngineCommand; +use sc_client_api::{ + backend::{Backend, StorageProvider}, + client::BlockchainEvents, + AuxStore, UsageProvider, +}; use sc_rpc::SubscriptionTaskExecutor; -use sc_transaction_pool::{ChainApi}; +use sc_rpc_api::DenyUnsafe; use sc_service::TransactionPool; +use sc_transaction_pool::ChainApi; use sp_api::{CallApiAt, ProvideRuntimeApi}; use sp_blockchain::{Error as BlockChainError, HeaderBackend, HeaderMetadata}; -use sp_runtime::traits::{Block as BlockT}; -use cessc_consensus_rrsc::{RRSCWorkerHandle}; -pub use sc_rpc_api::DenyUnsafe; use sp_consensus::SelectChain; -use cessp_consensus_rrsc::RRSCApi; -use cessc_consensus_rrsc_rpc::{RRSC, RRSCApiServer}; +use sp_inherents::CreateInherentDataProviders; use sp_keystore::KeystorePtr; +use sp_runtime::traits::Block as BlockT; +// Runtime +use cess_node_runtime::{opaque::Block, AccountId, Balance, BlockNumber, Hash, Nonce}; mod eth; pub use self::eth::{create_eth, overrides_handle, EthDeps}; @@ -59,32 +54,30 @@ pub struct GrandpaDeps { } /// Full client dependencies. -pub struct FullDeps { +pub struct FullDeps { /// The client instance to use. pub client: Arc, /// Transaction pool instance. pub pool: Arc

, - /// The SelectChain Strategy + /// The SelectChain Strategy pub select_chain: SC, /// A copy of the chain spec. pub chain_spec: Box, /// Whether to deny unsafe calls pub deny_unsafe: DenyUnsafe, - /// RRSC specific dependencies. + /// RRSC specific dependencies. pub rrsc: RRSCDeps, /// GRANDPA specific dependencies. - pub grandpa: GrandpaDeps, - /// Manual seal command sink - pub command_sink: Option>>, - /// Ethereum-compatibility specific dependencies. - pub eth: EthDeps, + pub grandpa: GrandpaDeps, + /// The backend used by the node. + pub backend: Arc, } pub struct DefaultEthConfig(std::marker::PhantomData<(C, BE)>); impl fc_rpc::EthConfig for DefaultEthConfig where - C: sc_client_api::StorageProvider + Sync + Send + 'static, + C: StorageProvider + Sync + Send + 'static, BE: Backend + 'static, { type EstimateGasAdapter = (); @@ -93,64 +86,54 @@ where } /// Instantiate all Full RPC extensions. -pub fn create_full( - deps: FullDeps, +pub fn create_full( + FullDeps { + client, + pool, + select_chain, + chain_spec, + deny_unsafe, + rrsc, + grandpa, + backend, + }: FullDeps, + eth_deps: EthDeps, subscription_task_executor: SubscriptionTaskExecutor, pubsub_notification_sinks: Arc< fc_mapping_sync::EthereumBlockNotificationSinks< fc_mapping_sync::EthereumBlockNotification, >, >, - backend: Arc, ) -> Result, Box> where C: CallApiAt + ProvideRuntimeApi, - C: ProvideRuntimeApi - + sc_client_api::BlockBackend - + AuxStore - + Sync - + Send, - C::Api: substrate_frame_rpc_system::AccountNonceApi, + C: ProvideRuntimeApi + sc_client_api::BlockBackend + AuxStore + Sync + Send, + C::Api: substrate_frame_rpc_system::AccountNonceApi, C::Api: sp_block_builder::BlockBuilder, C::Api: pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi, C::Api: fp_rpc::ConvertTransactionRuntimeApi, C::Api: fp_rpc::EthereumRuntimeRPCApi, - C::Api: RRSCApi, + C::Api: RRSCApi, C: BlockchainEvents + 'static, - C: HeaderBackend - + HeaderMetadata - + StorageProvider, - SC: SelectChain + 'static, + C: HeaderBackend + HeaderMetadata + 'static, + C: AuxStore + UsageProvider + StorageProvider, + SC: SelectChain + 'static, B: sc_client_api::Backend + Send + Sync + 'static, - B::State: sc_client_api::backend::StateBackend>, - BE: Backend + 'static, + B::State: sc_client_api::backend::StateBackend>, P: TransactionPool + 'static, A: ChainApi + 'static, + CIDP: CreateInherentDataProviders + Send + 'static, CT: fp_rpc::ConvertTransaction<::Extrinsic> + Send + Sync + 'static, { - use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApiServer}; + use cessc_sync_state_rpc::{SyncState, SyncStateApiServer}; + use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApiServer}; use sc_consensus_grandpa_rpc::{Grandpa, GrandpaApiServer}; use sc_rpc::dev::{Dev, DevApiServer}; use sc_rpc_spec_v2::chain_spec::{ChainSpec, ChainSpecApiServer}; - use cessc_sync_state_rpc::{SyncState, SyncStateApiServer}; use substrate_frame_rpc_system::{System, SystemApiServer}; use substrate_state_trie_migration_rpc::{StateMigration, StateMigrationApiServer}; - use sc_consensus_manual_seal::rpc::{ManualSeal, ManualSealApiServer}; - let mut io = RpcModule::new(()); - let FullDeps { - client, - pool, - select_chain, - chain_spec, - deny_unsafe, - rrsc, - grandpa, - command_sink, - eth, - } = deps; - let RRSCDeps { keystore, rrsc_worker_handle } = rrsc; let GrandpaDeps { shared_voter_state, @@ -193,21 +176,13 @@ where io.merge(StateMigration::new(client.clone(), backend, deny_unsafe).into_rpc())?; io.merge(Dev::new(client, deny_unsafe).into_rpc())?; - if let Some(command_sink) = command_sink { - io.merge( - // We provide the rpc handler with the sending end of the channel to allow the rpc - // send EngineCommands to the background block authorship task. - ManualSeal::new(command_sink).into_rpc(), - )?; - } - // Ethereum compatibility RPCs - let io = create_eth::<_, _, _, _, _, _, DefaultEthConfig>( + let io = create_eth::<_, _, _, _, _, _, _, DefaultEthConfig>( io, - eth, + eth_deps, subscription_task_executor, pubsub_notification_sinks, )?; Ok(io) -} \ No newline at end of file +} diff --git a/standalone/chain/node/src/service.rs b/standalone/chain/node/src/service.rs index 5d00910c..ce58ae91 100644 --- a/standalone/chain/node/src/service.rs +++ b/standalone/chain/node/src/service.rs @@ -1,55 +1,45 @@ -// This file is part of Substrate. -pub use crate::{ - executor::ExecutorDispatch, +//! Service and ServiceFactory implementation. Specialized wrapper over substrate service. + +use std::{path::Path, sync::Arc, time::Duration}; + +use futures::prelude::*; +// Substrate +use sc_client_api::{Backend, BlockBackend}; +use sc_consensus::BasicQueue; +use sc_executor::NativeExecutionDispatch; +use sc_network_sync::warp::WarpSyncParams; +use sc_service::{error::Error as ServiceError, Configuration, PartialComponents, TaskManager}; +use sc_telemetry::{Telemetry, TelemetryWorker}; +use sc_transaction_pool_api::OffchainTransactionPoolFactory; +use sp_api::ConstructRuntimeApi; +use sp_core::U256; +// Runtime +use cess_node_runtime::{opaque::Block, TransactionConverter}; + +use crate::{ eth::{ - db_config_dir, spawn_frontier_tasks, new_frontier_partial, - EthConfiguration, BackendType, FrontierBackend, FrontierBlockImport, FrontierPartialComponents, EthCompatRuntimeApiCollection + db_config_dir, new_frontier_partial, spawn_frontier_tasks, BackendType, + FrontierBackend, FrontierPartialComponents, EthConfiguration }, cli::Sealing, - client::{BaseRuntimeApiCollection, FullBackend, FullClient, RuntimeApiCollection, CESSNodeRuntimeExecutor}, -}; -use crate::{ - primitives as node_primitives, + client::{FullBackend, FullClient, RuntimeApiCollection, Client, CESSNodeRuntimeExecutor}, rpc as node_rpc }; use sc_rpc::SubscriptionTaskExecutor; -use futures::prelude::*; -use node_primitives::Block; -use sc_client_api::{BlockBackend, StateBackendFor}; + use cessc_consensus_rrsc::{self, SlotProportion}; -use sc_executor::{NativeExecutionDispatch}; use sc_network::{event::Event, NetworkEventStream}; -use sc_network_common::sync::warp::WarpSyncParams; -use sc_service::{ - Configuration, error::Error as ServiceError, - TaskManager, PartialComponents, -}; -use sc_telemetry::{Telemetry, TelemetryWorker}; -use sp_runtime::{ - traits::{BlakeTwo256}, -}; -use sp_api::{ConstructRuntimeApi}; -use std::{ - sync::{Arc}, - time::Duration, - path::Path, -}; -use cess_node_runtime::{TransactionConverter}; -use sc_consensus::BasicQueue; -use sp_trie::PrefixedMemoryDB; -type BasicImportQueue = sc_consensus::DefaultImportQueue; +type BasicImportQueue = sc_consensus::DefaultImportQueue; type FullPool = sc_transaction_pool::FullPool; type FullSelectChain = sc_consensus::LongestChain; +type GrandpaBlockImport = grandpa::GrandpaBlockImport; type GrandpaLinkHalf = grandpa::LinkHalf; -type GrandpaBlockImport = - grandpa::GrandpaBlockImport; -// type BoxBlockImport = sc_consensus::BoxBlockImport>; -/// The transaction pool type defintion. -// pub type TransactionPool = sc_transaction_pool::FullPool>; -pub type Client = FullClient; +/// The minimum period of blocks on which justifications will be +/// imported and generated. +const GRANDPA_JUSTIFICATION_PERIOD: u32 = 512; pub fn new_partial( config: &Configuration, @@ -59,7 +49,7 @@ pub fn new_partial( FullClient, FullBackend, FullSelectChain, - BasicImportQueue>, + BasicImportQueue, FullPool>, ( cessc_consensus_rrsc::RRSCLink, @@ -76,8 +66,7 @@ pub fn new_partial( where RuntimeApi: ConstructRuntimeApi>, RuntimeApi: Send + Sync + 'static, - RuntimeApi::RuntimeApi: RuntimeApiCollection> - + EthCompatRuntimeApiCollection>, + RuntimeApi::RuntimeApi: RuntimeApiCollection, Executor: NativeExecutionDispatch + 'static, { let telemetry = config @@ -111,6 +100,7 @@ where let select_chain = sc_consensus::LongestChain::new(backend.clone()); let (grandpa_block_import, grandpa_link) = grandpa::block_import( client.clone(), + GRANDPA_JUSTIFICATION_PERIOD, &client, select_chain.clone(), telemetry.as_ref().map(|x| x.handle()), @@ -125,28 +115,41 @@ where client.clone(), )?; - let slot_duration = rrsc_link.config().slot_duration(); - let (import_queue, rrsc_worker_handle) = cessc_consensus_rrsc::import_queue( - rrsc_link.clone(), - block_import.clone(), - Some(Box::new(justification_import)), + let transaction_pool = sc_transaction_pool::BasicPool::new_full( + config.transaction_pool.clone(), + config.role.is_authority().into(), + config.prometheus_registry(), + task_manager.spawn_essential_handle(), client.clone(), - select_chain.clone(), - move |_, ()| async move { - let timestamp = sp_timestamp::InherentDataProvider::from_system_time(); + ); - let slot = - cessp_consensus_rrsc::inherents::InherentDataProvider::from_timestamp_and_slot_duration( - *timestamp, - slot_duration, - ); + let slot_duration = rrsc_link.config().slot_duration(); + let (import_queue, rrsc_worker_handle) = { + let param = cessc_consensus_rrsc::ImportQueueParams { + link: rrsc_link.clone(), + block_import: block_import.clone(), + justification_import: Some(Box::new(justification_import)), + client: client.clone(), + select_chain: select_chain.clone(), + create_inherent_data_providers: move |_, ()| async move { + let timestamp = sp_timestamp::InherentDataProvider::from_system_time(); - Ok((slot, timestamp)) - }, - &task_manager.spawn_essential_handle(), - config.prometheus_registry(), - telemetry.as_ref().map(|x| x.handle()), - ).map_err::(Into::into)?; + let slot = + cessp_consensus_rrsc::inherents::InherentDataProvider::from_timestamp_and_slot_duration( + *timestamp, + slot_duration, + ); + + Ok((slot, timestamp)) + }, + spawner: &task_manager.spawn_essential_handle(), + registry: config.prometheus_registry(), + telemetry: telemetry.as_ref().map(|x| x.handle()), + offchain_tx_pool_factory: OffchainTransactionPoolFactory::new(transaction_pool.clone()), + }; + cessc_consensus_rrsc::import_queue(param).map_err::(Into::into)? + }; + let frontier_backend = match eth_config.frontier_backend_type { BackendType::KeyValue => FrontierBackend::KeyValue(fc_db::kv::Backend::open( @@ -177,14 +180,6 @@ where } }; - let transaction_pool = sc_transaction_pool::BasicPool::new_full( - config.transaction_pool.clone(), - config.role.is_authority().into(), - config.prometheus_registry(), - task_manager.spawn_essential_handle(), - client.clone(), - ); - Ok(PartialComponents { client, backend, @@ -210,16 +205,11 @@ pub async fn new_full( mut config: Configuration, eth_config: EthConfiguration, sealing: Option, - with_startup_data: impl FnOnce( - &cessc_consensus_rrsc::RRSCBlockImport, GrandpaBlockImport>>, - &cessc_consensus_rrsc::RRSCLink, - ), ) -> Result where RuntimeApi: ConstructRuntimeApi>, RuntimeApi: Send + Sync + 'static, - RuntimeApi::RuntimeApi: - RuntimeApiCollection>, + RuntimeApi::RuntimeApi: RuntimeApiCollection, Executor: NativeExecutionDispatch + 'static, { let PartialComponents { @@ -239,6 +229,7 @@ where fee_history_cache_limit, } = new_frontier_partial(ð_config)?; + let mut net_config = sc_network::config::FullNetworkConfiguration::new(&config.network); let grandpa_protocol_name = grandpa::protocol_standard_name( &client.block_hash(0)?.expect("Genesis block exists; qed"), &config.chain_spec, @@ -247,12 +238,9 @@ where let warp_sync_params = if sealing.is_some() { None } else { - config - .network - .extra_sets - .push(grandpa::grandpa_peers_set_config( - grandpa_protocol_name.clone(), - )); + net_config.add_notification_protocol(grandpa::grandpa_peers_set_config( + grandpa_protocol_name.clone(), + )); let warp_sync: Arc> = Arc::new(grandpa::warp_proof::NetworkProvider::new( backend.clone(), @@ -265,6 +253,7 @@ where let (network, system_rpc_tx, tx_handler_controller, network_starter, sync_service) = sc_service::build_network(sc_service::BuildNetworkParams { config: &config, + net_config, client: client.clone(), transaction_pool: transaction_pool.clone(), spawn_handle: task_manager.spawn_handle(), @@ -274,11 +263,23 @@ where })?; if config.offchain_worker.enabled { - sc_service::build_offchain_workers( - &config, - task_manager.spawn_handle(), - client.clone(), - network.clone(), + task_manager.spawn_handle().spawn( + "offchain-workers-runner", + "offchain-worker", + sc_offchain::OffchainWorkers::new(sc_offchain::OffchainWorkerOptions { + runtime_api_provider: client.clone(), + is_validator: config.role.is_authority(), + keystore: Some(keystore_container.keystore()), + offchain_db: backend.offchain_storage(), + transaction_pool: Some(OffchainTransactionPoolFactory::new( + transaction_pool.clone(), + )), + network_provider: network.clone(), + enable_http_requests: true, + custom_extensions: |_| vec![], + }) + .run(client.clone(), task_manager.spawn_handle()) + .boxed(), ); } @@ -289,8 +290,6 @@ where let prometheus_registry = config.prometheus_registry().cloned(); let auth_disc_publish_non_global_ips = config.network.allow_non_globals_in_dht; - // Channel for the rpc handler to communicate with the authorship task. - // let (command_sink, commands_stream) = mpsc::channel::(1000); // Sinks for pubsub notifications. // Everytime a new subscription is created, a new mpsc channel is added to the sink pool. @@ -303,6 +302,19 @@ where // for ethereum-compatibility rpc. config.rpc_id_provider = Some(Box::new(fc_rpc::EthereumSubIdProvider)); + let slot_duration = rrsc_link.config().slot_duration(); + let target_gas_price = eth_config.target_gas_price; + let pending_create_inherent_data_providers = move |_, ()| async move { + let current = sp_timestamp::InherentDataProvider::from_system_time(); + let next_slot = current.timestamp().as_millis() + slot_duration.as_millis(); + let timestamp = sp_timestamp::InherentDataProvider::new(next_slot.into()); + let slot = cessp_consensus_rrsc::inherents::InherentDataProvider::from_timestamp_and_slot_duration( + *timestamp, + slot_duration, + ); + let dynamic_fee = fp_dynamic_fee::InherentDataProvider(U256::from(target_gas_price)); + Ok((slot, timestamp, dynamic_fee)) + }; let eth_rpc_params = crate::rpc::EthDeps { client: client.clone(), pool: transaction_pool.clone(), @@ -330,6 +342,7 @@ where fee_history_cache_limit, execute_gas_limit_multiplier: eth_config.execute_gas_limit_multiplier, forced_parent_hashes: None, + pending_create_inherent_data_providers, }; let (rpc_extensions_builder, _rpc_setup) = { @@ -354,6 +367,7 @@ where let rpc_backend = backend.clone(); let rpc_extensions_builder = move |deny_unsafe, subscription_executor: SubscriptionTaskExecutor| { + let eths = eth_rpc_params.clone(); let deps = node_rpc::FullDeps { client: client.clone(), pool: pool.clone(), @@ -371,11 +385,10 @@ where subscription_executor: subscription_executor.clone(), finality_provider: finality_proof_provider.clone(), }, - command_sink: None, - eth: eth_rpc_params.clone(), + backend: rpc_backend.clone(), }; - node_rpc::create_full(deps, subscription_executor, pubsub_notification_sinks.clone(), rpc_backend.clone()).map_err(Into::into) + node_rpc::create_full(deps, eths, subscription_executor, pubsub_notification_sinks.clone()).map_err(Into::into) }; (rpc_extensions_builder, shared_voter_state2) @@ -413,8 +426,6 @@ where ) .await; - (with_startup_data)(&block_import, &rrsc_link); - if let sc_service::config::Role::Authority { .. } = &role { let proposer = sc_basic_authorship::ProposerFactory::new( task_manager.spawn_handle(), @@ -512,7 +523,7 @@ where let grandpa_config = grandpa::Config { // FIXME #1578 make this available through chainspec gossip_duration: Duration::from_millis(333), - justification_period: 512, + justification_generation_period: GRANDPA_JUSTIFICATION_PERIOD, name: Some(name), observer_enabled: false, keystore, @@ -537,6 +548,7 @@ where prometheus_registry, shared_voter_state: grandpa::SharedVoterState::empty(), telemetry: telemetry.as_ref().map(|x| x.handle()), + offchain_tx_pool_factory: OffchainTransactionPoolFactory::new(transaction_pool), })?; // the GRANDPA voter task is considered infallible, i.e. @@ -547,15 +559,6 @@ where } network_starter.start_network(); - - // let database_source = config.database.clone(); - // sc_storage_monitor::StorageMonitorService::try_spawn( - // cli.storage_monitor, - // database_source, - // &task_manager.spawn_essential_handle(), - // ) - // .map_err(|e| ServiceError::Application(e.into()))?; - Ok(task_manager) } @@ -565,7 +568,7 @@ pub async fn build_full( sealing: Option, ) -> Result { new_full::( - config, eth_config, sealing, |_, _| (), + config, eth_config, sealing, ) .await } @@ -577,7 +580,7 @@ pub fn new_chain_ops( ( Arc, Arc, - BasicQueue>, + BasicQueue, TaskManager, FrontierBackend, ), diff --git a/standalone/chain/runtime/Cargo.toml b/standalone/chain/runtime/Cargo.toml index 210f2928..156c51cd 100644 --- a/standalone/chain/runtime/Cargo.toml +++ b/standalone/chain/runtime/Cargo.toml @@ -10,106 +10,72 @@ version = "0.7.4" targets = ["x86_64-unknown-linux-gnu"] [dependencies] - -# third-party dependencies -codec = { version = "3.2.2", package = "parity-scale-codec", default-features = false, features = [ - "derive", - "max-encoded-len", -] } +codec = { package = "parity-scale-codec", version = "3.6.1", default-features = false, features = ["derive", "max-encoded-len"] } scale-info = { workspace = true, features = ["derive"] } -# static_assertions log = { workspace = true } -# hex-literal = { optional = true, version = "0.3.4" } # primitives -sp-authority-discovery = { workspace = true } cessp-consensus-rrsc = { workspace = true } +cp-cess-common = { workspace = true } +cp-enclave-verify = { workspace = true } +sp-api = { workspace = true } +sp-authority-discovery = { workspace = true } sp-block-builder = { workspace = true } +sp-core = { workspace = true } sp-inherents = { workspace = true } -# node-premitives +sp-io = { workspace = true } sp-offchain = { workspace = true } -sp-core = { workspace = true } -sp-std = { workspace = true } -sp-api = { workspace = true } sp-runtime = { workspace = true } -sp-staking = { workspace = true } sp-session = { workspace = true } +sp-staking = { workspace = true } +sp-std = { workspace = true } sp-transaction-pool = { workspace = true } sp-version = { workspace = true } -sp-io = { workspace = true } -cp-enclave-verify = { workspace = true } -cp-cess-common = { workspace = true } # frame dependencies -frame-executive = { workspace = true } frame-benchmarking = { workspace = true, optional = true } +frame-election-provider-support = { workspace = true } +frame-executive = { workspace = true } frame-support = { workspace = true } frame-system = { workspace = true } frame-system-benchmarking = { workspace = true, optional = true } -frame-election-provider-support = { workspace = true } frame-system-rpc-runtime-api = { workspace = true } frame-try-runtime = { workspace = true, optional = true } -# pallet-alliance +pallet-asset-tx-payment = { workspace = true } pallet-assets = { workspace = true } pallet-authority-discovery = { workspace = true } pallet-authorship = { workspace = true } -pallet-rrsc = { workspace = true } pallet-bags-list = { workspace = true } pallet-balances = { workspace = true } pallet-bounties = { workspace = true } +pallet-cess-staking = { workspace = true } pallet-child-bounties = { workspace = true } pallet-collective = { workspace = true } pallet-contracts = { workspace = true } pallet-contracts-primitives = { workspace = true } -# pallet-conviction-voting -# pallet-democracy pallet-election-provider-multi-phase = { workspace = true } -# pallet-election-provider-support-benchmarking -# pallet-elections-phragmen -# pallet-fast-unstake -# pallet-nis pallet-grandpa = { workspace = true } pallet-im-online = { workspace = true } pallet-indices = { workspace = true } -# pallet-identity -# pallet-lottery +pallet-insecure-randomness-collective-flip = { workspace = true } pallet-membership = { workspace = true } -# pallet-message-queue pallet-mmr = { workspace = true } pallet-multisig = { workspace = true } -# pallet-nomination-pools -# pallet-nomination-pools-benchmarking -# pallet-nomination-pools-runtime-api pallet-offences = { workspace = true } -# pallet-offences-benchmarking pallet-preimage = { workspace = true } pallet-proxy = { workspace = true } -pallet-insecure-randomness-collective-flip = { workspace = true } -# pallet-ranked-collective -# pallet-recovery -# pallet-referenda -# pallet-remark -# pallet-root-testing -pallet-session = { workspace = true, features = [ "historical" ] } -# pallet-session-benchmarking -pallet-cess-staking = { workspace = true } -# pallet-staking-reward-curve -# pallet-state-trie-migration +pallet-rrsc = { workspace = true } pallet-scheduler = { workspace = true } -# pallet-society +pallet-session = { workspace = true, features = [ "historical" ] } pallet-sudo = { workspace = true } pallet-timestamp = { workspace = true } -# pallet-tips -pallet-treasury = { workspace = true } -# pallet-utility pallet-transaction-payment = { workspace = true } pallet-transaction-payment-rpc-runtime-api = { workspace = true } -pallet-asset-tx-payment = { workspace = true } +pallet-treasury = { workspace = true } +# local dependencies cp-scheduler-credit = { workspace = true } pallet-scheduler-credit = { workspace = true } - -# local dependencies pallet-sminer = { workspace = true } pallet-cess-treasury = { workspace = true } pallet-audit = { workspace = true } @@ -120,11 +86,11 @@ pallet-oss = { workspace = true } pallet-cacher = { workspace = true } # Frontier -fp-account = { workspace = true } -fp-evm = { workspace = true } +fp-account = { workspace = true, features = ["serde"] } +fp-evm = { workspace = true, features = ["serde"] } fp-rpc = { workspace = true } -fp-self-contained = { workspace = true } -# Frontier +fp-self-contained = { workspace = true, features = ["serde"] } +# Frontier FRAME pallet-base-fee = { workspace = true } pallet-dynamic-fee = { workspace = true } pallet-ethereum = { workspace = true } @@ -141,143 +107,139 @@ substrate-wasm-builder = { workspace = true, optional = true } default = ["std"] with-tracing = ["frame-executive/with-tracing"] std = [ - "pallet-authority-discovery/std", - "pallet-authorship/std", - "pallet-asset-tx-payment/std", - "pallet-bounties/std", - "pallet-collective/std", - "pallet-cess-staking/std", - "pallet-election-provider-multi-phase/std", - "frame-election-provider-support/std", - "frame-system-benchmarking?/std", - "pallet-im-online/std", - "pallet-membership/std", - "pallet-multisig/std", - "pallet-offences/std", - "pallet-scheduler/std", - "pallet-session/std", - "pallet-treasury/std", - "pallet-file-bank/std", - "pallet-audit/std", - "pallet-sminer/std", - "pallet-tee-worker/std", - "pallet-storage-handler/std", - "pallet-oss/std", - "pallet-cacher/std", - "pallet-cess-treasury/std", - "pallet-preimage/std", - "pallet-proxy/std", - "pallet-assets/std", - "pallet-child-bounties/std", - "pallet-mmr/std", - "sp-io/std", - "pallet-indices/std", - "sp-authority-discovery/std", - "sp-staking/std", - "codec/std", - "frame-try-runtime?/std", - "frame-benchmarking/std", - "frame-executive/std", - "frame-support/std", - "frame-system-rpc-runtime-api/std", - "frame-system/std", - "pallet-rrsc/std", - "pallet-bags-list/std", - "pallet-balances/std", - "pallet-grandpa/std", - "pallet-insecure-randomness-collective-flip/std", - "pallet-sudo/std", - "pallet-timestamp/std", - "pallet-transaction-payment-rpc-runtime-api/std", - "pallet-transaction-payment/std", - "pallet-contracts/std", - "pallet-contracts-primitives/std", - "scale-info/std", - "sp-api/std", - "sp-block-builder/std", - "cessp-consensus-rrsc/std", - "sp-core/std", - "sp-inherents/std", - "sp-offchain/std", - "sp-runtime/std", - "sp-session/std", - "sp-std/std", - "sp-transaction-pool/std", - "sp-version/std", - # Frontier - "fp-account/std", - "fp-evm/std", - "fp-rpc/std", - "fp-self-contained/std", - # Frontier FRAME - "pallet-base-fee/std", - "pallet-dynamic-fee/std", - "pallet-ethereum/std", - "pallet-evm/std", - "pallet-evm-chain-id/std", - "pallet-evm-precompile-modexp/std", - "pallet-evm-precompile-sha3fips/std", - "pallet-evm-precompile-simple/std", - - "log/std", - "pallet-scheduler-credit/std", - "cp-scheduler-credit/std", - "cp-enclave-verify/std", - "substrate-wasm-builder", + "cessp-consensus-rrsc/std", + "codec/std", + "cp-enclave-verify/std", + "cp-scheduler-credit/std", + "fp-account/std", + "fp-evm/std", + "fp-rpc/std", + "fp-self-contained/std", + "frame-benchmarking/std", + "frame-election-provider-support/std", + "frame-executive/std", + "frame-support/std", + "frame-system-benchmarking?/std", + "frame-system-rpc-runtime-api/std", + "frame-system/std", + "frame-try-runtime?/std", + "log/std", + "pallet-asset-tx-payment/std", + "pallet-assets/std", + "pallet-audit/std", + "pallet-authority-discovery/std", + "pallet-authorship/std", + "pallet-bags-list/std", + "pallet-balances/std", + "pallet-base-fee/std", + "pallet-bounties/std", + "pallet-cacher/std", + "pallet-cess-staking/std", + "pallet-cess-treasury/std", + "pallet-child-bounties/std", + "pallet-collective/std", + "pallet-contracts-primitives/std", + "pallet-contracts/std", + "pallet-dynamic-fee/std", + "pallet-election-provider-multi-phase/std", + "pallet-ethereum/std", + "pallet-evm-chain-id/std", + "pallet-evm-precompile-modexp/std", + "pallet-evm-precompile-sha3fips/std", + "pallet-evm-precompile-simple/std", + "pallet-evm/std", + "pallet-file-bank/std", + "pallet-grandpa/std", + "pallet-im-online/std", + "pallet-indices/std", + "pallet-insecure-randomness-collective-flip/std", + "pallet-membership/std", + "pallet-mmr/std", + "pallet-multisig/std", + "pallet-offences/std", + "pallet-oss/std", + "pallet-preimage/std", + "pallet-proxy/std", + "pallet-rrsc/std", + "pallet-scheduler-credit/std", + "pallet-scheduler/std", + "pallet-session/std", + "pallet-sminer/std", + "pallet-storage-handler/std", + "pallet-sudo/std", + "pallet-tee-worker/std", + "pallet-timestamp/std", + "pallet-transaction-payment-rpc-runtime-api/std", + "pallet-transaction-payment/std", + "pallet-treasury/std", + "scale-info/std", + "sp-api/std", + "sp-authority-discovery/std", + "sp-block-builder/std", + "sp-core/std", + "sp-inherents/std", + "sp-io/std", + "sp-offchain/std", + "sp-runtime/std", + "sp-session/std", + "sp-staking/std", + "sp-std/std", + "sp-transaction-pool/std", + "sp-version/std", + "substrate-wasm-builder", ] runtime-benchmarks = [ - "frame-benchmarking/runtime-benchmarks", - "frame-system-benchmarking/runtime-benchmarks", - "frame-support/runtime-benchmarks", - "frame-system/runtime-benchmarks", - #"hex-literal", - "pallet-balances/runtime-benchmarks", - "pallet-timestamp/runtime-benchmarks", - "pallet-collective/runtime-benchmarks", - "pallet-file-bank/runtime-benchmarks", - "pallet-tee-worker/runtime-benchmarks", - "pallet-oss/runtime-benchmarks", - "pallet-cess-staking/runtime-benchmarks", - "pallet-cacher/runtime-benchmarks", - "pallet-storage-handler/runtime-benchmarks", - "pallet-audit/runtime-benchmarks", - "pallet-sminer/runtime-benchmarks", - "sp-runtime/runtime-benchmarks", - "pallet-contracts/runtime-benchmarks", - "pallet-ethereum/runtime-benchmarks", - "pallet-evm/runtime-benchmarks", + "frame-benchmarking/runtime-benchmarks", + "frame-support/runtime-benchmarks", + "frame-system-benchmarking/runtime-benchmarks", + "frame-system/runtime-benchmarks", + "pallet-audit/runtime-benchmarks", + "pallet-balances/runtime-benchmarks", + "pallet-cacher/runtime-benchmarks", + "pallet-cess-staking/runtime-benchmarks", + "pallet-collective/runtime-benchmarks", + "pallet-contracts/runtime-benchmarks", + "pallet-ethereum/runtime-benchmarks", + "pallet-evm/runtime-benchmarks", + "pallet-file-bank/runtime-benchmarks", + "pallet-oss/runtime-benchmarks", + "pallet-sminer/runtime-benchmarks", + "pallet-storage-handler/runtime-benchmarks", + "pallet-tee-worker/runtime-benchmarks", + "pallet-timestamp/runtime-benchmarks", + "sp-runtime/runtime-benchmarks", ] try-runtime = [ - "frame-executive/try-runtime", - "frame-try-runtime", - "frame-system/try-runtime", - "pallet-assets/try-runtime", - "pallet-authority-discovery/try-runtime", - "pallet-authorship/try-runtime", + "frame-executive/try-runtime", + "frame-system/try-runtime", + "frame-try-runtime", "pallet-asset-tx-payment/try-runtime", - "pallet-rrsc/try-runtime", - "pallet-balances/try-runtime", - "pallet-bounties/try-runtime", - "pallet-child-bounties/try-runtime", - "pallet-collective/try-runtime", - "pallet-contracts/try-runtime", - "pallet-election-provider-multi-phase/try-runtime", - "pallet-grandpa/try-runtime", - "pallet-im-online/try-runtime", - "pallet-indices/try-runtime", - "pallet-membership/try-runtime", - "pallet-mmr/try-runtime", + "pallet-assets/try-runtime", + "pallet-authority-discovery/try-runtime", + "pallet-authorship/try-runtime", + "pallet-balances/try-runtime", + "pallet-bounties/try-runtime", + "pallet-cess-staking/try-runtime", + "pallet-child-bounties/try-runtime", + "pallet-collective/try-runtime", + "pallet-contracts/try-runtime", + "pallet-election-provider-multi-phase/try-runtime", + "pallet-file-bank/try-runtime", + "pallet-grandpa/try-runtime", + "pallet-im-online/try-runtime", + "pallet-indices/try-runtime", + "pallet-insecure-randomness-collective-flip/try-runtime", + "pallet-membership/try-runtime", + "pallet-mmr/try-runtime", "pallet-multisig/try-runtime", - "pallet-offences/try-runtime", - "pallet-preimage/try-runtime", + "pallet-offences/try-runtime", + "pallet-preimage/try-runtime", "pallet-proxy/try-runtime", - "pallet-insecure-randomness-collective-flip/try-runtime", - "pallet-scheduler/try-runtime", - "pallet-session/try-runtime", - "pallet-cess-staking/try-runtime", - "pallet-sudo/try-runtime", - "pallet-timestamp/try-runtime", - "pallet-transaction-payment/try-runtime", - "pallet-treasury/try-runtime", - "pallet-file-bank/try-runtime", + "pallet-rrsc/try-runtime", + "pallet-scheduler/try-runtime", + "pallet-session/try-runtime", + "pallet-sudo/try-runtime", + "pallet-timestamp/try-runtime", + "pallet-transaction-payment/try-runtime", + "pallet-treasury/try-runtime", ] diff --git a/standalone/chain/runtime/src/lib.rs b/standalone/chain/runtime/src/lib.rs index bf133af5..3cbd3a4c 100644 --- a/standalone/chain/runtime/src/lib.rs +++ b/standalone/chain/runtime/src/lib.rs @@ -18,7 +18,10 @@ pub fn wasm_binary_unwrap() -> &'static [u8] { use codec::{Decode, Encode, MaxEncodedLen}; use cp_cess_common::FRAGMENT_COUNT; -use frame_election_provider_support::{onchain, ElectionDataProvider, ExtendedBalance, VoteWeight}; +use frame_election_provider_support::{ + bounds::{ElectionBounds, ElectionBoundsBuilder}, + onchain, ElectionDataProvider, ExtendedBalance, VoteWeight, +}; pub use frame_system::Call as SystemCall; pub use pallet_file_bank; use pallet_grandpa::{ @@ -35,7 +38,8 @@ use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId; use sp_core::{crypto::KeyTypeId, OpaqueMetadata, H160, H256, U256}; use sp_inherents::{CheckInherentsResult, InherentData}; use sp_runtime::{ - create_runtime_str, generic, impl_opaque_keys, + create_runtime_str, generic, + impl_opaque_keys, generic::Era, traits::{ BlakeTwo256, Block as BlockT, Bounded, ConvertInto, DispatchInfoOf, Dispatchable, @@ -46,9 +50,10 @@ use sp_runtime::{ TransactionPriority, TransactionSource, TransactionValidity, TransactionValidityError, }, ApplyExtrinsicResult, FixedPointNumber, MultiSignature, Perbill, Percent, Permill, Perquintill, - RuntimeAppPublic, ConsensusEngineId + RuntimeAppPublic, RuntimeDebug, ConsensusEngineId }; use sp_std::{marker::PhantomData, prelude::*}; +use sp_staking::currency_to_vote::{CurrencyToVote, U128CurrencyToVote}; #[cfg(feature = "std")] use sp_version::NativeVersion; use sp_version::RuntimeVersion; @@ -61,9 +66,9 @@ pub use frame_support::{ parameter_types, traits::{ AsEnsureOriginWithArg, ConstBool, ConstU128, ConstU16, ConstU32, ConstU8, Currency, - CurrencyToVote, EitherOfDiverse, EqualPrivilegeOnly, Everything, FindAuthor, Imbalance, + EitherOfDiverse, EqualPrivilegeOnly, Everything, FindAuthor, Imbalance, InstanceFilter, KeyOwnerProofSystem, Nothing, OnUnbalanced, Randomness, StorageInfo, - U128CurrencyToVote, OnFinalize, + OnFinalize, }, weights::{ constants::{ @@ -71,7 +76,7 @@ pub use frame_support::{ }, ConstantMultiplier, IdentityFee, Weight, }, - PalletId, StorageValue, RuntimeDebug, + PalletId, StorageValue, }; use frame_system::{ @@ -81,14 +86,18 @@ use frame_system::{ pub mod impls; use impls::{Author, CreditToBlockAuthor, SchedulerStashAccountFinder}; -use fp_rpc::TransactionStatus; pub use pallet_balances::Call as BalancesCall; -use pallet_ethereum::{Call::transact, PostLogContent, Transaction as EthereumTransaction}; +// Frontier +use fp_evm::weight_per_gas; +use fp_rpc::TransactionStatus; +use pallet_ethereum::{ + Call::transact, PostLogContent, Transaction as EthereumTransaction, TransactionAction, + TransactionData, +}; use pallet_evm::{ - Account as EVMAccount, EnsureAddressTruncated, FeeCalculator, GasWeightMapping, - HashedAddressMapping, Runner, + Account as EVMAccount, EnsureAddressTruncated, FeeCalculator, HashedAddressMapping, Runner, }; -use fp_evm::weight_per_gas; + pub use pallet_timestamp::Call as TimestampCall; //add contracts use pallet_election_provider_multi_phase::SolutionAccuracyOf; @@ -103,6 +112,7 @@ pub use sp_runtime::BuildStorage; mod voter_bags; +/// An index to a block. pub type BlockNumber = u32; /// Alias to 512-bit hash when used in the context of a transaction signature on the chain. @@ -112,6 +122,9 @@ pub type Signature = MultiSignature; /// to the public key of our transaction signing scheme. pub type AccountId = <::Signer as IdentifyAccount>::AccountId; +/// The type for looking up accounts. We don't expect more than 4 billion of them. +pub type AccountIndex = u32; + /// Balance of an account. pub type Balance = u128; @@ -119,17 +132,11 @@ pub type Balance = u128; pub type Moment = u64; /// Index of a transaction in the chain. -pub type Index = u32; +pub type Nonce = u32; /// A hash of some data used by the chain. pub type Hash = sp_core::H256; -/// A timestamp: milliseconds since the unix epoch. -/// `u64` is enough to represent a duration of half a billion years, when the -/// time scale is milliseconds. -/// Header type. -pub type NodeHeader = generic::Header; - /// Opaque types. These are used by the CLI to instantiate machinery that don't need to know /// the specifics of the runtime. They can then be made to be agnostic over specific formats /// of data like extrinsics, allowing for them to continue syncing the network through upgrades @@ -306,13 +313,12 @@ impl frame_system::Config for Runtime { type DbWeight = RocksDbWeight; type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; - type Index = Index; - type BlockNumber = BlockNumber; + type Block = Block; + type Nonce = Nonce; type Hash = Hash; type Hashing = BlakeTwo256; type AccountId = AccountId; type Lookup = Indices; - type Header = generic::Header; type RuntimeEvent = RuntimeEvent; type BlockHashCount = BlockHashCount; type Version = Version; @@ -369,13 +375,12 @@ frame_election_provider_support::generate_solution_type!( VoterIndex = u32, TargetIndex = u16, Accuracy = sp_runtime::PerU16, - MaxVoters = MaxElectingVoters, + MaxVoters = MaxElectingVotersSolution, >(16) ); parameter_types! { pub MaxNominations: u32 = 1; - pub MaxElectingVoters: u32 = 10_000; } parameter_types! { @@ -473,6 +478,7 @@ impl pallet_rrsc::Config for Runtime { type DisabledValidators = Session; type WeightInfo = (); type MaxAuthorities = MaxAuthorities; + type MaxNominators = MaxNominatorRewardedPerValidator; type KeyOwnerProof = >::Proof; type EquivocationReportSystem = @@ -493,7 +499,6 @@ parameter_types! { pub const StakingUnsignedPriority: TransactionPriority = TransactionPriority::max_value() / 2; pub const MaxKeys: u32 = 10_000; pub const MaxPeerInHeartbeats: u32 = 10_000; - pub const MaxPeerDataEncodingSize: u32 = 1_000; } impl pallet_im_online::Config for Runtime { @@ -506,7 +511,6 @@ impl pallet_im_online::Config for Runtime { type WeightInfo = pallet_im_online::weights::SubstrateWeight; type MaxKeys = MaxKeys; type MaxPeerInHeartbeats = MaxPeerInHeartbeats; - type MaxPeerDataEncodingSize = MaxPeerDataEncodingSize; } impl pallet_offences::Config for Runtime { @@ -558,6 +562,9 @@ pub const ERAS_PER_YEAR: u64 = { (EPOCH_DURATION_IN_BLOCKS * SessionsPerEra::get()) as u64 }; +/// Upper limit on the number of NPOS nominations. +const MAX_QUOTA_NOMINATIONS: u32 = 16; + pub struct StakingBenchmarkingConfig; impl pallet_cess_staking::BenchmarkingConfig for StakingBenchmarkingConfig { type MaxNominators = ConstU32<0>; @@ -571,7 +578,6 @@ impl pallet_cess_staking::Config for Runtime { const REWARD_DECREASE_RATIO: Perbill = Perbill::from_perthousand(841); const REWARD_DECREASE_YEARS: u64 = 30; type SminerRewardPool = CessTreasury; - type MaxNominations = MaxNominations; type Currency = Balances; type CurrencyBalance = Balance; type UnixTime = Timestamp; @@ -596,10 +602,12 @@ impl pallet_cess_staking::Config for Runtime { type ElectionProvider = ElectionProviderMultiPhase; type GenesisElectionProvider = onchain::OnChainExecution; type VoterList = VoterList; + type NominationsQuota = pallet_cess_staking::FixedNominationsQuota; + // This a placeholder, to be introduced in the next PR as an instance of bags-list type TargetList = pallet_cess_staking::UseValidatorsMap; type MaxUnlockingChunks = ConstU32<32>; type HistoryDepth = HistoryDepth; - type OnStakerSlash = (); + type EventListeners = (); type WeightInfo = pallet_cess_staking::weights::SubstrateWeight; type BenchmarkingConfig = StakingBenchmarkingConfig; } @@ -758,6 +766,16 @@ impl pallet_rrsc::VrfSloverConfig for OnChainVrfSloverConfig { } } +parameter_types! { + // Note: the EPM in this runtime runs the election on-chain. The election bounds must be + // carefully set so that an election round fits in one block. + pub ElectionBoundsMultiPhase: ElectionBounds = ElectionBoundsBuilder::default() + .voters_count(10_000.into()).targets_count(1_500.into()).build(); + pub ElectionBoundsOnChain: ElectionBounds = ElectionBoundsBuilder::default() + .voters_count(20_000.into()).targets_count(2_000.into()).build(); + pub MaxElectingVotersSolution: u32 = 10_000; +} + pub struct OnChainVrf; impl onchain::Config for OnChainVrf { type System = Runtime; @@ -771,8 +789,7 @@ impl onchain::Config for OnChainVrf { type DataProvider = ::DataProvider; type WeightInfo = frame_election_provider_support::weights::SubstrateWeight; type MaxWinners = ::MaxWinners; - type VotersBound = ConstU32<20_000>; - type TargetsBound = ConstU32<2_000>; + type Bounds = ElectionBoundsOnChain; } impl pallet_election_provider_multi_phase::MinerConfig for Runtime { @@ -803,10 +820,7 @@ impl pallet_election_provider_multi_phase::Config for Runtime { type UnsignedPhase = UnsignedPhase; type BetterUnsignedThreshold = BetterUnsignedThreshold; type BetterSignedThreshold = (); - // type SolutionImprovementThreshold = SolutionImprovementThreshold; type OffchainRepeat = OffchainRepeat; - // type MinerMaxWeight = MinerMaxWeight; - // type MinerMaxLength = MinerMaxLength; type MinerTxPriority = MultiPhaseUnsignedPriority; type MinerConfig = Self; type SignedMaxSubmissions = ConstU32<10>; @@ -819,7 +833,6 @@ impl pallet_election_provider_multi_phase::Config for Runtime { type SlashHandler = (); // burn slashes type RewardHandler = (); // nothing to do upon rewards type DataProvider = Staking; - // type Solution = NposSolution16; type Fallback = onchain::OnChainExecution; type GovernanceFallback = onchain::OnChainExecution; type Solver = pallet_rrsc::VrfSolver< @@ -831,9 +844,8 @@ impl pallet_election_provider_multi_phase::Config for Runtime { OffchainRandomBalancing, >; type ForceOrigin = EnsureRootOrHalfCouncil; - type MaxElectableTargets = ConstU16<{ u16::MAX }>; type MaxWinners = MaxActiveValidators; - type MaxElectingVoters = MaxElectingVoters; + type ElectionBounds = ElectionBoundsMultiPhase; type BenchmarkingConfig = ElectionProviderBenchmarkConfig; type WeightInfo = pallet_election_provider_multi_phase::weights::SubstrateWeight; } @@ -846,6 +858,7 @@ impl pallet_grandpa::Config for Runtime { type RuntimeEvent = RuntimeEvent; type WeightInfo = (); type MaxAuthorities = MaxAuthorities; + type MaxNominators = MaxNominatorRewardedPerValidator; type MaxSetIdSessionEntries = MaxSetIdSessionEntries; type KeyOwnerProof = >::Proof; type EquivocationReportSystem = @@ -897,7 +910,7 @@ impl pallet_balances::Config for Runtime { type WeightInfo = pallet_balances::weights::SubstrateWeight; type FreezeIdentifier = (); type MaxFreezes = (); - type HoldIdentifier = HoldReason; + type RuntimeHoldReason = RuntimeHoldReason; type MaxHolds = ConstU32<1>; } @@ -929,6 +942,7 @@ impl pallet_transaction_payment::Config for Runtime { impl pallet_sudo::Config for Runtime { type RuntimeEvent = RuntimeEvent; type RuntimeCall = RuntimeCall; + type WeightInfo = pallet_sudo::weights::SubstrateWeight; } impl pallet_evm_chain_id::Config for Runtime {} @@ -1224,7 +1238,7 @@ where call: RuntimeCall, public: ::Signer, account: AccountId, - nonce: Index, + nonce: Nonce, ) -> Option<( RuntimeCall, ::SignaturePayload, @@ -1259,7 +1273,7 @@ where let (call, extra, _) = raw_payload.deconstruct(); Some((call, (address, signature.into(), extra))) // let (call, extra, _) = raw_payload.deconstruct(); - // Some((call, (sp_runtime::MultiAddress::Index(()), signature.into(), extra))) + // Some((call, (sp_runtime::MultiAddress::Nonce(()), signature.into(), extra))) } } @@ -1272,11 +1286,12 @@ impl frame_system::offchain::SigningTypes for Runtime { * End This Block */ - parameter_types! { +parameter_types! { pub const DepositPerItem: Balance = deposit(1, 0); pub const DepositPerByte: Balance = deposit(0, 1); pub const DefaultDepositLimit: Balance = deposit(1024, 1024 * 1024); pub Schedule: pallet_contracts::Schedule = Default::default(); + pub CodeHashLockupDepositPercent: Perbill = Perbill::from_percent(30); } impl pallet_contracts::Config for Runtime { @@ -1305,6 +1320,15 @@ impl pallet_contracts::Config for Runtime { type MaxStorageKeyLen = ConstU32<128>; type UnsafeUnstableInterface = ConstBool; type MaxDebugBufferLen = ConstU32<{ 2 * 1024 * 1024 }>; + type RuntimeHoldReason = RuntimeHoldReason; + #[cfg(not(feature = "runtime-benchmarks"))] + type Migrations = (); + #[cfg(feature = "runtime-benchmarks")] + type Migrations = pallet_contracts::migration::codegen::BenchMigrations; + type MaxDelegateDependencies = ConstU32<32>; + type CodeHashLockupDepositPercent = CodeHashLockupDepositPercent; + type Debug = (); + type Environment = (); } parameter_types! { @@ -1319,7 +1343,6 @@ impl pallet_preimage::Config for Runtime { type RuntimeEvent = RuntimeEvent; type Currency = Balances; type ManagerOrigin = EnsureRoot; - // type MaxSize = PreimageMaxSize; type BaseDeposit = PreimageBaseDeposit; type ByteDeposit = PreimageByteDeposit; } @@ -1367,7 +1390,6 @@ impl pallet_assets::Config for Runtime { impl pallet_mmr::Config for Runtime { const INDEXING_PREFIX: &'static [u8] = b"mmr"; type Hashing = ::Hashing; - type Hash = ::Hash; type LeafData = pallet_mmr::ParentNumberAndHash; type OnNewRoot = (); type WeightInfo = (); @@ -1441,7 +1463,7 @@ impl pallet_evm::Config for Runtime { type FindAuthor = FindAuthorTruncated; type GasLimitPovSizeRatio = GasLimitPovSizeRatio; type Timestamp = Timestamp; - type WeightInfo = pallet_evm::weights::SubstrateWeight; + type WeightInfo = pallet_evm::weights::SubstrateWeight; } parameter_types! { @@ -1590,10 +1612,7 @@ impl pallet_cacher::Config for Runtime { // Create the runtime by composing the FRAME pallets that were previously configured. construct_runtime!( - pub enum Runtime where - Block = Block, - NodeBlock = opaque::Block, - UncheckedExtrinsic = UncheckedExtrinsic + pub enum Runtime { // Basic stuff System: frame_system = 0, @@ -1657,17 +1676,20 @@ construct_runtime!( } ); +type EventRecord = frame_system::EventRecord< + ::RuntimeEvent, + ::Hash, +>; + mod mmr { use super::Runtime; pub use pallet_mmr::primitives::*; pub type Leaf = <::LeafData as LeafDataProvider>::LeafData; - pub type Hash = ::Hash; + pub type Hash = ::Output; pub type Hashing = ::Hashing; } -pub type AccountIndex = u32; - /// The address format for describing accounts. pub type Address = sp_runtime::MultiAddress; /// Block header type as expected by this runtime. @@ -1889,13 +1911,13 @@ impl_runtime_apis! { } } - impl frame_system_rpc_runtime_api::AccountNonceApi for Runtime { - fn account_nonce(account: AccountId) -> Index { + impl frame_system_rpc_runtime_api::AccountNonceApi for Runtime { + fn account_nonce(account: AccountId) -> Nonce { System::account_nonce(account) } } - impl pallet_contracts::ContractsApi for Runtime { + impl pallet_contracts::ContractsApi for Runtime { fn call( origin: AccountId, dest: AccountId, @@ -1903,7 +1925,7 @@ impl_runtime_apis! { gas_limit: Option, storage_deposit_limit: Option, input_data: Vec, - ) -> pallet_contracts_primitives::ContractExecResult { + ) -> pallet_contracts_primitives::ContractExecResult { let gas_limit = gas_limit.unwrap_or(RuntimeBlockWeights::get().max_block); Contracts::bare_call( origin, @@ -1912,7 +1934,8 @@ impl_runtime_apis! { gas_limit, storage_deposit_limit, input_data, - true, + pallet_contracts::DebugInfo::UnsafeDebug, + pallet_contracts::CollectEvents::UnsafeCollect, pallet_contracts::Determinism::Enforced, ) } @@ -1925,7 +1948,7 @@ impl_runtime_apis! { code: pallet_contracts_primitives::Code, data: Vec, salt: Vec, - ) -> pallet_contracts_primitives::ContractInstantiateResult + ) -> pallet_contracts_primitives::ContractInstantiateResult { let gas_limit = gas_limit.unwrap_or(RuntimeBlockWeights::get().max_block); Contracts::bare_instantiate( @@ -1936,7 +1959,8 @@ impl_runtime_apis! { code, data, salt, - true + pallet_contracts::DebugInfo::UnsafeDebug, + pallet_contracts::CollectEvents::UnsafeCollect, ) } @@ -2102,43 +2126,20 @@ impl_runtime_apis! { None }; - let is_transactional = false; - let validate = true; - let evm_config = config.as_ref().unwrap_or(::config()); - - let mut estimated_transaction_len = data.len() + - 20 + // to - 20 + // from - 32 + // value - 32 + // gas_limit - 32 + // nonce - 1 + // TransactionAction - 8 + // chain id - 65; // signature - - if max_fee_per_gas.is_some() { - estimated_transaction_len += 32; - } - if max_priority_fee_per_gas.is_some() { - estimated_transaction_len += 32; - } - if access_list.is_some() { - estimated_transaction_len += access_list.encoded_size(); - } - - let gas_limit = gas_limit.min(u64::MAX.into()).low_u64(); - let without_base_extrinsic_weight = true; - - let (weight_limit, proof_size_base_cost) = - match ::GasWeightMapping::gas_to_weight( - gas_limit, - without_base_extrinsic_weight - ) { - weight_limit if weight_limit.proof_size() > 0 => { - (Some(weight_limit), Some(estimated_transaction_len as u64)) - } - _ => (None, None), - }; + let gas_limit = gas_limit.min(u64::MAX.into()); + let transaction_data = TransactionData::new( + TransactionAction::Call(to), + data.clone(), + nonce.unwrap_or_default(), + gas_limit, + None, + max_fee_per_gas, + max_priority_fee_per_gas, + value, + Some(::ChainId::get()), + access_list.clone().unwrap_or_default(), + ); + let (weight_limit, proof_size_base_cost) = pallet_ethereum::Pallet::::transaction_weight(&transaction_data); ::Runner::call( from, @@ -2150,11 +2151,11 @@ impl_runtime_apis! { max_priority_fee_per_gas, nonce, access_list.unwrap_or_default(), - is_transactional, - validate, + false, + true, weight_limit, proof_size_base_cost, - evm_config, + config.as_ref().unwrap_or(::config()), ).map_err(|err| err.error.into()) } @@ -2177,46 +2178,19 @@ impl_runtime_apis! { None }; - let is_transactional = false; - let validate = true; - let evm_config = config.as_ref().unwrap_or(::config()); - - let mut estimated_transaction_len = data.len() + - 20 + // from - 32 + // value - 32 + // gas_limit - 32 + // nonce - 1 + // TransactionAction - 8 + // chain id - 65; // signature - - if max_fee_per_gas.is_some() { - estimated_transaction_len += 32; - } - if max_priority_fee_per_gas.is_some() { - estimated_transaction_len += 32; - } - if access_list.is_some() { - estimated_transaction_len += access_list.encoded_size(); - } - - let gas_limit = if gas_limit > U256::from(u64::MAX) { - u64::MAX - } else { - gas_limit.low_u64() - }; - let without_base_extrinsic_weight = true; - - let (weight_limit, proof_size_base_cost) = - match ::GasWeightMapping::gas_to_weight( - gas_limit, - without_base_extrinsic_weight - ) { - weight_limit if weight_limit.proof_size() > 0 => { - (Some(weight_limit), Some(estimated_transaction_len as u64)) - } - _ => (None, None), - }; + let transaction_data = TransactionData::new( + TransactionAction::Create, + data.clone(), + nonce.unwrap_or_default(), + gas_limit, + None, + max_fee_per_gas, + max_priority_fee_per_gas, + value, + Some(::ChainId::get()), + access_list.clone().unwrap_or_default(), + ); + let (weight_limit, proof_size_base_cost) = pallet_ethereum::Pallet::::transaction_weight(&transaction_data); ::Runner::create( from, @@ -2227,11 +2201,11 @@ impl_runtime_apis! { max_priority_fee_per_gas, nonce, access_list.unwrap_or_default(), - is_transactional, - validate, + false, + true, weight_limit, proof_size_base_cost, - evm_config, + config.as_ref().unwrap_or(::config()), ).map_err(|err| err.error.into()) } @@ -2296,7 +2270,7 @@ impl_runtime_apis! { pallet_ethereum::Call::::transact { transaction }.into(), ) } - } + } #[cfg(feature = "try-runtime")] impl frame_try_runtime::TryRuntime for Runtime {