From ff291d602c37481edbf55280b755bb1d9584c34f Mon Sep 17 00:00:00 2001 From: Robert Gabriel Jakabosky Date: Thu, 23 May 2024 22:23:44 +0800 Subject: [PATCH] Remove bridge staking (#23) * Add node rpc code. * Remove staking. * Remove bridge. * Remove broken session benchmark. * Babe PoA (#24) * Only use babe's secondary selector. * Use babe secondary VRF. * Add PoA ValidatorSet support. * Use public url for Confidential asset repo. * Enable primary selection in BABE again. * Fixup comment. --- Cargo.lock | 227 ++---- Cargo.toml | 34 +- pallets/confidential-asset/Cargo.toml | 1 - pallets/weights/Cargo.toml | 2 - pallets/weights/src/lib.rs | 1 - pallets/weights/src/pallet_staking.rs | 747 ------------------ runtime/common/Cargo.toml | 2 - runtime/common/src/fee_details.rs | 17 +- runtime/common/src/impls.rs | 34 - runtime/common/src/lib.rs | 2 +- runtime/common/src/runtime.rs | 77 +- runtime/develop/Cargo.toml | 15 +- runtime/develop/src/benchmarks/mod.rs | 1 - .../develop/src/benchmarks/pallet_session.rs | 113 --- runtime/develop/src/lib.rs | 12 +- runtime/develop/src/runtime.rs | 55 +- runtime/production/Cargo.toml | 13 +- runtime/production/src/lib.rs | 6 +- runtime/production/src/runtime.rs | 50 +- runtime/tests/Cargo.toml | 15 +- runtime/tests/src/test_runtime/ext_builder.rs | 57 +- runtime/tests/src/test_runtime/mod.rs | 44 +- src/chain_spec.rs | 381 +++------ src/command.rs | 4 +- src/main.rs | 1 + src/rpc.rs | 199 +++++ src/service.rs | 41 +- 27 files changed, 454 insertions(+), 1697 deletions(-) delete mode 100644 pallets/weights/src/pallet_staking.rs delete mode 100644 runtime/develop/src/benchmarks/mod.rs delete mode 100644 runtime/develop/src/benchmarks/pallet_session.rs create mode 100644 src/rpc.rs diff --git a/Cargo.lock b/Cargo.lock index 86acd97..0c8c1f7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1013,7 +1013,7 @@ dependencies = [ [[package]] name = "confidential_assets" version = "1.0.0" -source = "git+ssh://git@github.com/PolymeshAssociation/confidential_assets.git?branch=main#a05c3822dbfa21634f19ea6901852d4f5acb7efc" +source = "git+https://github.com/PolymeshAssociation/confidential_assets?branch=main#752f70b4b8223832158061bcdb2ded540a7ddbb1" dependencies = [ "bulletproofs", "byteorder", @@ -2115,34 +2115,6 @@ dependencies = [ "thousands", ] -[[package]] -name = "frame-election-provider-solution-type" -version = "4.0.0-dev" -source = "git+https://github.com/PolymeshAssociation/polkadot-sdk?branch=polymesh-v6-monthly-2023-03#74ef745933703849d756dc16d41d938157d6943a" -dependencies = [ - "proc-macro-crate 1.1.3", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "frame-election-provider-support" -version = "4.0.0-dev" -source = "git+https://github.com/PolymeshAssociation/polkadot-sdk?branch=polymesh-v6-monthly-2023-03#74ef745933703849d756dc16d41d938157d6943a" -dependencies = [ - "frame-election-provider-solution-type", - "frame-support", - "frame-system", - "parity-scale-codec", - "scale-info", - "sp-arithmetic", - "sp-core", - "sp-npos-elections", - "sp-runtime", - "sp-std", -] - [[package]] name = "frame-executive" version = "4.0.0-dev" @@ -2844,7 +2816,7 @@ dependencies = [ "iana-time-zone-haiku", "js-sys", "wasm-bindgen", - "windows-core 0.52.0", + "windows-core", ] [[package]] @@ -4698,7 +4670,6 @@ name = "pallet-bridge" version = "1.0.0" source = "git+https://github.com/PolymeshAssociation/Polymesh.git?tag=v6.3.0#ad9c8a12689bcb4a34c47d572cf76a34ecc8454b" dependencies = [ - "frame-benchmarking", "frame-support", "frame-system", "log", @@ -5361,77 +5332,6 @@ dependencies = [ "sp-version", ] -[[package]] -name = "pallet-staking" -version = "2.0.0" -source = "git+https://github.com/PolymeshAssociation/Polymesh.git?tag=v6.3.0#ad9c8a12689bcb4a34c47d572cf76a34ecc8454b" -dependencies = [ - "frame-benchmarking", - "frame-election-provider-support", - "frame-support", - "frame-system", - "log", - "pallet-authorship", - "pallet-babe", - "pallet-identity", - "pallet-session", - "parity-scale-codec", - "polymesh-common-utilities", - "polymesh-primitives", - "rand_chacha 0.2.2", - "scale-info", - "serde", - "sp-arithmetic", - "sp-core", - "sp-io", - "sp-npos-elections", - "sp-runtime", - "sp-staking", - "sp-std", - "static_assertions", -] - -[[package]] -name = "pallet-staking-reward-curve" -version = "4.0.0-dev" -source = "git+https://github.com/PolymeshAssociation/polkadot-sdk?branch=polymesh-v6-monthly-2023-03#74ef745933703849d756dc16d41d938157d6943a" -dependencies = [ - "proc-macro-crate 1.1.3", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "pallet-staking-rpc" -version = "2.0.0" -source = "git+https://github.com/PolymeshAssociation/Polymesh.git?tag=v6.3.0#ad9c8a12689bcb4a34c47d572cf76a34ecc8454b" -dependencies = [ - "frame-support", - "frame-system", - "jsonrpsee", - "node-rpc", - "pallet-staking-rpc-runtime-api", - "parity-scale-codec", - "serde", - "sp-api", - "sp-blockchain", - "sp-core", - "sp-rpc", - "sp-runtime", - "sp-std", -] - -[[package]] -name = "pallet-staking-rpc-runtime-api" -version = "2.0.0" -source = "git+https://github.com/PolymeshAssociation/Polymesh.git?tag=v6.3.0#ad9c8a12689bcb4a34c47d572cf76a34ecc8454b" -dependencies = [ - "frame-support", - "sp-api", - "sp-runtime", -] - [[package]] name = "pallet-statistics" version = "0.1.0" @@ -6019,40 +5919,6 @@ dependencies = [ "sp-std", ] -[[package]] -name = "polymesh-node-rpc" -version = "0.1.0" -source = "git+https://github.com/PolymeshAssociation/Polymesh.git?tag=v6.3.0#ad9c8a12689bcb4a34c47d572cf76a34ecc8454b" -dependencies = [ - "jsonrpsee", - "node-rpc", - "pallet-group-rpc", - "pallet-protocol-fee-rpc", - "pallet-staking-rpc", - "polymesh-primitives", - "sc-chain-spec", - "sc-client-api", - "sc-consensus-babe", - "sc-consensus-babe-rpc", - "sc-consensus-epochs", - "sc-consensus-grandpa", - "sc-consensus-grandpa-rpc", - "sc-rpc", - "sc-rpc-api", - "sc-rpc-spec-v2", - "sc-sync-state-rpc", - "sc-transaction-pool-api", - "sp-api", - "sp-block-builder", - "sp-blockchain", - "sp-consensus", - "sp-consensus-babe", - "sp-keystore", - "sp-runtime", - "substrate-frame-rpc-system", - "substrate-state-trie-migration-rpc", -] - [[package]] name = "polymesh-primitives" version = "5.0.0" @@ -6112,7 +5978,6 @@ dependencies = [ "pallet-babe", "pallet-balances 0.1.0", "pallet-base", - "pallet-bridge", "pallet-committee", "pallet-compliance-manager", "pallet-confidential-asset", @@ -6135,9 +6000,6 @@ dependencies = [ "pallet-relayer", "pallet-session", "pallet-settlement", - "pallet-staking", - "pallet-staking-reward-curve", - "pallet-staking-rpc-runtime-api", "pallet-statistics", "pallet-sto", "pallet-sudo", @@ -6150,7 +6012,6 @@ dependencies = [ "polymesh-contracts", "polymesh-extensions", "polymesh-host-functions", - "polymesh-node-rpc", "polymesh-primitives", "polymesh-private-runtime-develop", "polymesh-private-runtime-production", @@ -6164,16 +6025,22 @@ dependencies = [ "sc-client-api", "sc-consensus", "sc-consensus-babe", + "sc-consensus-babe-rpc", + "sc-consensus-epochs", "sc-consensus-grandpa", + "sc-consensus-grandpa-rpc", "sc-consensus-slots", "sc-executor", "sc-network", "sc-network-common", "sc-rpc", + "sc-rpc-api", + "sc-rpc-spec-v2", "sc-service", "sc-sync-state-rpc", "sc-telemetry", "sc-transaction-pool", + "sc-transaction-pool-api", "serde", "serde_json", "sp-api", @@ -6186,6 +6053,7 @@ dependencies = [ "sp-core", "sp-inherents", "sp-keyring", + "sp-keystore", "sp-offchain", "sp-runtime", "sp-session", @@ -6193,7 +6061,10 @@ dependencies = [ "sp-transaction-pool", "sp-transaction-storage-proof", "substrate-build-script-utils", + "substrate-frame-rpc-system", "substrate-prometheus-endpoint", + "substrate-state-trie-migration-rpc", + "substrate-validator-set", ] [[package]] @@ -6216,7 +6087,6 @@ dependencies = [ "pallet-babe", "pallet-balances 0.1.0", "pallet-base", - "pallet-bridge", "pallet-committee", "pallet-compliance-manager", "pallet-confidential-asset", @@ -6244,9 +6114,6 @@ dependencies = [ "pallet-scheduler", "pallet-session", "pallet-settlement", - "pallet-staking", - "pallet-staking-reward-curve", - "pallet-staking-rpc-runtime-api", "pallet-statistics", "pallet-sto", "pallet-sudo", @@ -6276,10 +6143,10 @@ dependencies = [ "sp-offchain", "sp-runtime", "sp-session", - "sp-staking", "sp-std", "sp-transaction-pool", "sp-version", + "substrate-validator-set", ] [[package]] @@ -6298,7 +6165,6 @@ dependencies = [ "pallet-babe", "pallet-balances 0.1.0", "pallet-base", - "pallet-bridge", "pallet-committee", "pallet-compliance-manager", "pallet-confidential-asset", @@ -6326,9 +6192,6 @@ dependencies = [ "pallet-scheduler", "pallet-session", "pallet-settlement", - "pallet-staking", - "pallet-staking-reward-curve", - "pallet-staking-rpc-runtime-api", "pallet-statistics", "pallet-sto", "pallet-sudo", @@ -6357,10 +6220,10 @@ dependencies = [ "sp-offchain", "sp-runtime", "sp-session", - "sp-staking", "sp-std", "sp-transaction-pool", "sp-version", + "substrate-validator-set", ] [[package]] @@ -6380,7 +6243,6 @@ dependencies = [ "pallet-babe", "pallet-balances 0.1.0", "pallet-base", - "pallet-bridge", "pallet-committee", "pallet-compliance-manager", "pallet-confidential-asset", @@ -6408,9 +6270,6 @@ dependencies = [ "pallet-scheduler", "pallet-session", "pallet-settlement", - "pallet-staking", - "pallet-staking-reward-curve", - "pallet-staking-rpc-runtime-api", "pallet-statistics", "pallet-sto", "pallet-sudo", @@ -6444,10 +6303,10 @@ dependencies = [ "sp-offchain", "sp-runtime", "sp-session", - "sp-staking", "sp-std", "sp-transaction-pool", "sp-version", + "substrate-validator-set", ] [[package]] @@ -6458,7 +6317,6 @@ dependencies = [ "frame-system", "pallet-authorship", "pallet-balances 0.1.0", - "pallet-bridge", "pallet-committee", "pallet-group-rpc-runtime-api", "pallet-identity", @@ -6527,7 +6385,6 @@ dependencies = [ "pallet-scheduler", "pallet-session", "pallet-settlement", - "pallet-staking", "pallet-statistics", "pallet-sto", "pallet-test-utils", @@ -9287,20 +9144,6 @@ dependencies = [ "zstd", ] -[[package]] -name = "sp-npos-elections" -version = "4.0.0-dev" -source = "git+https://github.com/PolymeshAssociation/polkadot-sdk?branch=polymesh-v6-monthly-2023-03#74ef745933703849d756dc16d41d938157d6943a" -dependencies = [ - "parity-scale-codec", - "scale-info", - "serde", - "sp-arithmetic", - "sp-core", - "sp-runtime", - "sp-std", -] - [[package]] name = "sp-offchain" version = "4.0.0-dev" @@ -9784,6 +9627,25 @@ dependencies = [ "trie-db", ] +[[package]] +name = "substrate-validator-set" +version = "0.9.42" +source = "git+https://github.com/PolymeshAssociation/substrate-validator-set?branch=polymesh-v6-monthly-2023-03#b6badb3e9cdc79ddc0a272a8dcbf800a38ade243" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "log", + "pallet-session", + "parity-scale-codec", + "scale-info", + "sp-core", + "sp-io", + "sp-runtime", + "sp-staking", + "sp-std", +] + [[package]] name = "substrate-wasm-builder" version = "5.0.0-dev" @@ -11282,7 +11144,7 @@ version = "0.51.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ca229916c5ee38c2f2bc1e9d8f04df975b4bd93f9955dc69fabb5d91270045c9" dependencies = [ - "windows-core 0.51.1", + "windows-core", "windows-targets 0.48.5", ] @@ -11295,15 +11157,6 @@ dependencies = [ "windows-targets 0.48.5", ] -[[package]] -name = "windows-core" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" -dependencies = [ - "windows-targets 0.52.0", -] - [[package]] name = "windows-sys" version = "0.42.0" @@ -11696,3 +11549,13 @@ dependencies = [ "cc", "pkg-config", ] + +[[patch.unused]] +name = "frame-election-provider-support" +version = "4.0.0-dev" +source = "git+https://github.com/PolymeshAssociation/polkadot-sdk?branch=polymesh-v6-monthly-2023-03#74ef745933703849d756dc16d41d938157d6943a" + +[[patch.unused]] +name = "sp-npos-elections" +version = "4.0.0-dev" +source = "git+https://github.com/PolymeshAssociation/polkadot-sdk?branch=polymesh-v6-monthly-2023-03#74ef745933703849d756dc16d41d938157d6943a" diff --git a/Cargo.toml b/Cargo.toml index d7321bd..9fe1f2c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -33,7 +33,6 @@ pallet-preimage = { git = "https://github.com/PolymeshAssociation/polkadot-sdk", pallet-insecure-randomness-collective-flip = { git = "https://github.com/PolymeshAssociation/polkadot-sdk", branch = "polymesh-v6-monthly-2023-03" } pallet-scheduler = { git = "https://github.com/PolymeshAssociation/polkadot-sdk", branch = "polymesh-v6-monthly-2023-03" } pallet-session = { git = "https://github.com/PolymeshAssociation/polkadot-sdk", branch = "polymesh-v6-monthly-2023-03" } -pallet-staking-reward-curve = { git = "https://github.com/PolymeshAssociation/polkadot-sdk", branch = "polymesh-v6-monthly-2023-03" } pallet-timestamp = { git = "https://github.com/PolymeshAssociation/polkadot-sdk", branch = "polymesh-v6-monthly-2023-03" } sc-authority-discovery = { git = "https://github.com/PolymeshAssociation/polkadot-sdk", branch = "polymesh-v6-monthly-2023-03" } sc-basic-authorship = { git = "https://github.com/PolymeshAssociation/polkadot-sdk", branch = "polymesh-v6-monthly-2023-03" } @@ -84,7 +83,6 @@ sp-runtime = { git = "https://github.com/PolymeshAssociation/polkadot-sdk", bran sp-weights = { git = "https://github.com/PolymeshAssociation/polkadot-sdk", branch = "polymesh-v6-monthly-2023-03" } sp-runtime-interface = { git = "https://github.com/PolymeshAssociation/polkadot-sdk", branch = "polymesh-v6-monthly-2023-03" } sp-session = { git = "https://github.com/PolymeshAssociation/polkadot-sdk", branch = "polymesh-v6-monthly-2023-03" } -sp-staking = { git = "https://github.com/PolymeshAssociation/polkadot-sdk", branch = "polymesh-v6-monthly-2023-03" } sp-state-machine = { git = "https://github.com/PolymeshAssociation/polkadot-sdk", branch = "polymesh-v6-monthly-2023-03" } sp-std = { git = "https://github.com/PolymeshAssociation/polkadot-sdk", branch = "polymesh-v6-monthly-2023-03" } sp-storage = { git = "https://github.com/PolymeshAssociation/polkadot-sdk", branch = "polymesh-v6-monthly-2023-03" } @@ -101,10 +99,12 @@ substrate-build-script-utils = { git = "https://github.com/PolymeshAssociation/p substrate-wasm-builder = { git = "https://github.com/PolymeshAssociation/polkadot-sdk", branch = "polymesh-v6-monthly-2023-03" } bulletproofs = { version = "4.0.0", git = "https://github.com/PolymeshAssociation/bulletproofs", branch = "polymesh" } -confidential_assets = { git = "ssh://git@github.com/PolymeshAssociation/confidential_assets.git", branch = "main" } +confidential_assets = { git = "https://github.com/PolymeshAssociation/confidential_assets", branch = "main" } #confidential_assets = { path = "../confidential_assets" } curve25519-dalek-ng = { git = "https://github.com/atouchet/curve25519-dalek-ng.git", branch = "simd" } +substrate-validator-set = { git = "https://github.com/PolymeshAssociation/substrate-validator-set", branch = "polymesh-v6-monthly-2023-03" } + [workspace] members = [ "pallets/confidential-asset", @@ -124,7 +124,6 @@ exclude = [ pallet-asset = { git = "https://github.com/PolymeshAssociation/Polymesh.git", tag = "v6.3.0", default-features = false } pallet-balances = { git = "https://github.com/PolymeshAssociation/Polymesh.git", tag = "v6.3.0", default-features = false } pallet-base = { git = "https://github.com/PolymeshAssociation/Polymesh.git", tag = "v6.3.0", default-features = false } -pallet-bridge = { git = "https://github.com/PolymeshAssociation/Polymesh.git", tag = "v6.3.0", default-features = false } pallet-committee = { git = "https://github.com/PolymeshAssociation/Polymesh.git", tag = "v6.3.0", default-features = false } pallet-compliance-manager = { git = "https://github.com/PolymeshAssociation/Polymesh.git", tag = "v6.3.0", default-features = false } pallet-confidential-asset = { path = "pallets/confidential-asset/", default-features = false } @@ -142,7 +141,6 @@ pallet-protocol-fee = { git = "https://github.com/PolymeshAssociation/Polymesh.g pallet-relayer = { git = "https://github.com/PolymeshAssociation/Polymesh.git", tag = "v6.3.0", default-features = false } pallet-sto = { git = "https://github.com/PolymeshAssociation/Polymesh.git", tag = "v6.3.0", default-features = false } pallet-settlement = { git = "https://github.com/PolymeshAssociation/Polymesh.git", tag = "v6.3.0", default-features = false } -pallet-staking = { git = "https://github.com/PolymeshAssociation/Polymesh.git", tag = "v6.3.0", default-features = false } pallet-statistics = { git = "https://github.com/PolymeshAssociation/Polymesh.git", tag = "v6.3.0", default-features = false } pallet-test-utils = { git = "https://github.com/PolymeshAssociation/Polymesh.git", tag = "v6.3.0", default-features = false } pallet-transaction-payment = { git = "https://github.com/PolymeshAssociation/Polymesh.git", tag = "v6.3.0", default-features = false } @@ -165,8 +163,6 @@ pallet-group-rpc = { git = "https://github.com/PolymeshAssociation/Polymesh.git" pallet-group-rpc-runtime-api = { git = "https://github.com/PolymeshAssociation/Polymesh.git", tag = "v6.3.0", default-features = false } pallet-protocol-fee-rpc = { git = "https://github.com/PolymeshAssociation/Polymesh.git", tag = "v6.3.0", default-features = false } pallet-protocol-fee-rpc-runtime-api = { git = "https://github.com/PolymeshAssociation/Polymesh.git", tag = "v6.3.0", default-features = false } -pallet-staking-rpc-runtime-api = { git = "https://github.com/PolymeshAssociation/Polymesh.git", tag = "v6.3.0", default-features = false } -polymesh-node-rpc = { git = "https://github.com/PolymeshAssociation/Polymesh.git", tag = "v6.3.0", default-features = false } # Build tool polymesh-build-tool = { git = "https://github.com/PolymeshAssociation/Polymesh.git", tag = "v6.3.0", default-features = false } @@ -190,7 +186,6 @@ pallet-preimage = { version = "4.0.0-dev", default-features = false } pallet-insecure-randomness-collective-flip = { version = "4.0.0-dev", default-features = false } pallet-scheduler = { version = "4.0.0-dev", default-features = false } pallet-session = { version = "4.0.0-dev", default-features = false } -pallet-staking-reward-curve = { version = "4.0.0-dev", default-features = false } pallet-timestamp = { version = "4.0.0-dev", default-features = false } scale-info = { version = "2.0", default-features = false, features = ["derive"] } sp-api = { version = "4.0.0-dev", default-features = false } @@ -212,7 +207,6 @@ sp-runtime = { version = "7.0.0", default-features = false } sp-runtime-interface = { version = "7.0.0", default-features = false } sp-timestamp = { version = "4.0.0-dev", default-features = false } sp-session = { version = "4.0.0-dev", default-features = false } -sp-staking = { version = "4.0.0-dev", default-features = false } sp-std = { version = "5.0.0", default-features = false } sp-transaction-pool = { version = "4.0.0-dev", default-features = false } sp-version = { version = "5.0.0", default-features = false } @@ -223,12 +217,14 @@ rand_core = { version = "0.6", default-features = false } rand_chacha = { version = "0.3", default-features = false } confidential_assets = { version = "1.0.0", default-features = false } +# Validator set (PoA) +validator-set = { version = "0.9.42", package = "substrate-validator-set", default-features = false } + [dependencies] # Our pallets pallet-asset = { workspace = true, default-features = false } pallet-balances = { workspace = true, default-features = false } pallet-base = { workspace = true, default-features = false } -pallet-bridge = { workspace = true, default-features = false } pallet-committee = { workspace = true, default-features = false } pallet-compliance-manager = { workspace = true, default-features = false } pallet-confidential-asset = { workspace = true, default-features = false } @@ -246,8 +242,6 @@ pallet-protocol-fee = { workspace = true, default-features = false } pallet-relayer = { workspace = true, default-features = false } pallet-sto = { workspace = true, default-features = false } pallet-settlement = { workspace = true, default-features = false } -pallet-staking = { workspace = true, default-features = false } -pallet-staking-reward-curve = { workspace = true, default-features = false } pallet-statistics = { workspace = true, default-features = false } pallet-test-utils = { workspace = true, default-features = false } pallet-transaction-payment = { workspace = true, default-features = false } @@ -263,6 +257,9 @@ polymesh-primitives = { workspace = true, default-features = false } polymesh-weights = { workspace = true, default-features = false } polymesh-extensions = { workspace = true, default-features = false } +# PoA +validator-set = { workspace = true, default-features = false } + # RPC node-rpc = { workspace = true } node-rpc-runtime-api = { workspace = true } @@ -270,8 +267,6 @@ pallet-group-rpc = { workspace = true } pallet-group-rpc-runtime-api = { workspace = true } pallet-protocol-fee-rpc = { workspace = true } pallet-protocol-fee-rpc-runtime-api = { workspace = true } -pallet-staking-rpc-runtime-api = { workspace = true } -polymesh-node-rpc = { workspace = true } # Runtimes polymesh-private-runtime-develop = { path = "runtime/develop" } @@ -294,16 +289,24 @@ sc-cli = { version = "0.10.0-dev" } sc-client-api = "4.0.0-dev" sc-consensus = "0.10.0-dev" sc-consensus-babe = "0.10.0-dev" +sc-consensus-babe-rpc = "0.10.0-dev" +sc-consensus-epochs = { version = "0.10.0-dev" } sc-consensus-slots = "0.10.0-dev" +sc-consensus-grandpa = "0.10.0-dev" +sc-consensus-grandpa-rpc = "0.10.0-dev" sc-executor = { version = "0.10.0-dev" } sc-network = "0.10.0-dev" sc-network-common = { version = "0.10.0-dev" } sc-rpc = "4.0.0-dev" +sc-rpc-api = "0.10.0-dev" +sc-rpc-spec-v2 = "0.10.0-dev" sc-service = { version = "0.10.0-dev" } sc-telemetry = "4.0.0-dev" sc-transaction-pool = "4.0.0-dev" sc-sync-state-rpc = { version = "0.10.0-dev" } -grandpa = { package = "sc-consensus-grandpa", version = "0.10.0-dev" } +sc-transaction-pool-api = { version = "4.0.0-dev" } +substrate-frame-rpc-system = { version = "4.0.0-dev" } +substrate-state-trie-migration-rpc = { version = "4.0.0-dev" } # Substrate codec = { workspace = true, package = "parity-scale-codec" } @@ -323,6 +326,7 @@ sp-consensus = { workspace = true } sp-consensus-babe = { workspace = true } sp-consensus-slots = { workspace = true } sp-keyring = { workspace = true } +sp-keystore = { version = "0.13.0" } sp-core = { workspace = true } sp-inherents = { workspace = true } sp-transaction-storage-proof = { workspace = true } diff --git a/pallets/confidential-asset/Cargo.toml b/pallets/confidential-asset/Cargo.toml index 0235e90..2f4765c 100644 --- a/pallets/confidential-asset/Cargo.toml +++ b/pallets/confidential-asset/Cargo.toml @@ -56,7 +56,6 @@ avx2_backend = [ ] no_std = ["confidential_assets/no_std", "polymesh-host-functions/no_std", "u64_backend"] -only-staking = [] std = [ "rand_core/std", "rand_chacha/std", diff --git a/pallets/weights/Cargo.toml b/pallets/weights/Cargo.toml index 8665a32..4be6add 100644 --- a/pallets/weights/Cargo.toml +++ b/pallets/weights/Cargo.toml @@ -22,7 +22,6 @@ sp-std = { workspace = true, default-features = false } # our pallets pallet-asset = { workspace = true, default-features = false } pallet-balances = { workspace = true, default-features = false } -pallet-staking = { workspace = true, default-features = false } pallet-committee = { workspace = true, default-features = false } pallet-compliance-manager = { workspace = true, default-features = false } pallet-corporate-actions = { workspace = true, default-features = false } @@ -52,7 +51,6 @@ std = [ "frame-system/std", "pallet-asset/std", "pallet-babe/std", - "pallet-staking/std", "pallet-balances/std", "pallet-compliance-manager/std", "pallet-corporate-actions/std", diff --git a/pallets/weights/src/lib.rs b/pallets/weights/src/lib.rs index 66726e7..5565532 100644 --- a/pallets/weights/src/lib.rs +++ b/pallets/weights/src/lib.rs @@ -44,7 +44,6 @@ pub mod pallet_relayer; pub mod pallet_scheduler; pub mod pallet_session; pub mod pallet_settlement; -pub mod pallet_staking; pub mod pallet_statistics; pub mod pallet_sto; pub mod pallet_test_utils; diff --git a/pallets/weights/src/pallet_staking.rs b/pallets/weights/src/pallet_staking.rs deleted file mode 100644 index 43f2791..0000000 --- a/pallets/weights/src/pallet_staking.rs +++ /dev/null @@ -1,747 +0,0 @@ -// This file is part of Substrate. - -// Copyright (C) 2021 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. - -//! Autogenerated weights for pallet_staking -//! -//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-11-25, STEPS: `100`, REPEAT: 5, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: None, DB CACHE: 512 -//! HOSTNAME: `Ubuntu-2204-jammy-amd64-base`, CPU: `AMD Ryzen 9 7950X3D 16-Core Processor` - -// Executed Command: -// ./target/release/polymesh-private -// benchmark -// pallet -// -s -// 100 -// -r -// 5 -// -p=pallet_staking -// -e=* -// --heap-pages -// 4096 -// --db-cache -// 512 -// --execution -// wasm -// --wasm-execution -// compiled -// --output -// ./pallets/weights/src/ -// --template -// ./.maintain/frame-weight-template.hbs - -#![allow(unused_parens)] -#![allow(unused_imports)] - -use polymesh_runtime_common::{RocksDbWeight as DbWeight, Weight}; - -/// Weights for pallet_staking using the Substrate node and recommended hardware. -pub struct SubstrateWeight; -impl pallet_staking::WeightInfo for SubstrateWeight { - // Storage: Staking Bonded (r:1 w:1) - // Proof Skipped: Staking Bonded (max_values: None, max_size: None, mode: Measured) - // Storage: Staking Ledger (r:1 w:1) - // Proof Skipped: Staking Ledger (max_values: None, max_size: None, mode: Measured) - // Storage: Staking CurrentEra (r:1 w:0) - // Proof Skipped: Staking CurrentEra (max_values: Some(1), max_size: None, mode: Measured) - // Storage: Staking HistoryDepth (r:1 w:0) - // Proof Skipped: Staking HistoryDepth (max_values: Some(1), max_size: None, mode: Measured) - // Storage: Identity CurrentDid (r:1 w:0) - // Proof Skipped: Identity CurrentDid (max_values: Some(1), max_size: None, mode: Measured) - // Storage: Balances Locks (r:1 w:1) - // Proof Skipped: Balances Locks (max_values: None, max_size: None, mode: Measured) - // Storage: Staking Payee (r:0 w:1) - // Proof Skipped: Staking Payee (max_values: None, max_size: None, mode: Measured) - fn bond() -> Weight { - // Minimum execution time: 52_559 nanoseconds. - Weight::from_ref_time(52_819_000) - .saturating_add(DbWeight::get().reads(6)) - .saturating_add(DbWeight::get().writes(4)) - } - // Storage: Staking EraElectionStatus (r:1 w:0) - // Proof Skipped: Staking EraElectionStatus (max_values: Some(1), max_size: None, mode: Measured) - // Storage: Staking Bonded (r:1 w:0) - // Proof Skipped: Staking Bonded (max_values: None, max_size: None, mode: Measured) - // Storage: Staking Ledger (r:1 w:1) - // Proof Skipped: Staking Ledger (max_values: None, max_size: None, mode: Measured) - // Storage: Identity CurrentDid (r:1 w:0) - // Proof Skipped: Identity CurrentDid (max_values: Some(1), max_size: None, mode: Measured) - // Storage: Balances Locks (r:1 w:1) - // Proof Skipped: Balances Locks (max_values: None, max_size: None, mode: Measured) - fn bond_extra() -> Weight { - // Minimum execution time: 49_483 nanoseconds. - Weight::from_ref_time(50_845_000) - .saturating_add(DbWeight::get().reads(5)) - .saturating_add(DbWeight::get().writes(2)) - } - // Storage: Staking EraElectionStatus (r:1 w:0) - // Proof Skipped: Staking EraElectionStatus (max_values: Some(1), max_size: None, mode: Measured) - // Storage: Staking Ledger (r:1 w:1) - // Proof Skipped: Staking Ledger (max_values: None, max_size: None, mode: Measured) - // Storage: Staking Validators (r:1 w:0) - // Proof Skipped: Staking Validators (max_values: None, max_size: None, mode: Measured) - // Storage: Staking CurrentEra (r:1 w:0) - // Proof Skipped: Staking CurrentEra (max_values: Some(1), max_size: None, mode: Measured) - // Storage: Balances Locks (r:1 w:1) - // Proof Skipped: Balances Locks (max_values: None, max_size: None, mode: Measured) - // Storage: System Account (r:1 w:1) - // Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) - // Storage: Identity CurrentDid (r:1 w:0) - // Proof Skipped: Identity CurrentDid (max_values: Some(1), max_size: None, mode: Measured) - fn unbond() -> Weight { - // Minimum execution time: 47_108 nanoseconds. - Weight::from_ref_time(47_719_000) - .saturating_add(DbWeight::get().reads(7)) - .saturating_add(DbWeight::get().writes(3)) - } - // Storage: Staking EraElectionStatus (r:1 w:0) - // Proof Skipped: Staking EraElectionStatus (max_values: Some(1), max_size: None, mode: Measured) - // Storage: Staking Ledger (r:1 w:1) - // Proof Skipped: Staking Ledger (max_values: None, max_size: None, mode: Measured) - // Storage: Staking CurrentEra (r:1 w:0) - // Proof Skipped: Staking CurrentEra (max_values: Some(1), max_size: None, mode: Measured) - // Storage: Balances Locks (r:1 w:1) - // Proof Skipped: Balances Locks (max_values: None, max_size: None, mode: Measured) - // 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 { - // Minimum execution time: 37_841 nanoseconds. - Weight::from_ref_time(39_790_759) - // Standard Error: 11_688 - .saturating_add(Weight::from_ref_time(25_211).saturating_mul(s.into())) - .saturating_add(DbWeight::get().reads(5)) - .saturating_add(DbWeight::get().writes(3)) - } - // Storage: Staking EraElectionStatus (r:1 w:0) - // Proof Skipped: Staking EraElectionStatus (max_values: Some(1), max_size: None, mode: Measured) - // Storage: Staking Ledger (r:1 w:1) - // Proof Skipped: Staking Ledger (max_values: None, max_size: None, mode: Measured) - // Storage: Staking CurrentEra (r:1 w:0) - // Proof Skipped: Staking CurrentEra (max_values: Some(1), max_size: None, mode: Measured) - // Storage: Staking Bonded (r:1 w:1) - // Proof Skipped: Staking Bonded (max_values: None, max_size: None, mode: Measured) - // Storage: Staking SlashingSpans (r:1 w:1) - // Proof Skipped: Staking SlashingSpans (max_values: None, max_size: None, mode: Measured) - // 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 Skipped: Balances Locks (max_values: None, max_size: None, mode: Measured) - // Storage: Staking Validators (r:0 w:1) - // Proof Skipped: Staking Validators (max_values: None, max_size: None, mode: Measured) - // Storage: Staking Payee (r:0 w:1) - // Proof Skipped: Staking Payee (max_values: None, max_size: None, mode: Measured) - // Storage: Staking Nominators (r:0 w:1) - // Proof Skipped: Staking Nominators (max_values: None, max_size: None, mode: Measured) - // Storage: Staking SpanSlash (r:0 w:99) - // Proof Skipped: Staking SpanSlash (max_values: None, max_size: None, mode: Measured) - /// The range of component `s` is `[0, 100]`. - fn withdraw_unbonded_kill(s: u32) -> Weight { - // Minimum execution time: 56_887 nanoseconds. - Weight::from_ref_time(57_876_346) - // Standard Error: 65_411 - .saturating_add(Weight::from_ref_time(1_715_284).saturating_mul(s.into())) - .saturating_add(DbWeight::get().reads(7)) - .saturating_add(DbWeight::get().writes(8)) - .saturating_add(DbWeight::get().writes((1_u64).saturating_mul(s.into()))) - } - // Storage: Staking EraElectionStatus (r:1 w:0) - // Proof Skipped: Staking EraElectionStatus (max_values: Some(1), max_size: None, mode: Measured) - // Storage: Staking Ledger (r:1 w:0) - // Proof Skipped: Staking Ledger (max_values: None, max_size: None, mode: Measured) - // Storage: Identity KeyRecords (r:1 w:0) - // Proof Skipped: Identity KeyRecords (max_values: None, max_size: None, mode: Measured) - // Storage: Staking PermissionedIdentity (r:1 w:1) - // Proof Skipped: Staking PermissionedIdentity (max_values: None, max_size: None, mode: Measured) - // Storage: Staking MinimumBondThreshold (r:1 w:0) - // Proof Skipped: Staking MinimumBondThreshold (max_values: Some(1), max_size: None, mode: Measured) - // Storage: Staking ValidatorCommissionCap (r:1 w:0) - // Proof Skipped: Staking ValidatorCommissionCap (max_values: Some(1), max_size: None, mode: Measured) - // Storage: Staking Validators (r:1 w:1) - // Proof Skipped: Staking Validators (max_values: None, max_size: None, mode: Measured) - // Storage: Identity AccountKeyRefCount (r:1 w:1) - // Proof Skipped: Identity AccountKeyRefCount (max_values: None, max_size: None, mode: Measured) - // Storage: Staking Nominators (r:0 w:1) - // Proof Skipped: Staking Nominators (max_values: None, max_size: None, mode: Measured) - fn validate() -> Weight { - // Minimum execution time: 45_415 nanoseconds. - Weight::from_ref_time(46_036_000) - .saturating_add(DbWeight::get().reads(8)) - .saturating_add(DbWeight::get().writes(4)) - } - // Storage: Staking MinimumBondThreshold (r:0 w:1) - // Proof Skipped: Staking MinimumBondThreshold (max_values: Some(1), max_size: None, mode: Measured) - fn set_min_bond_threshold() -> Weight { - // Minimum execution time: 8_206 nanoseconds. - Weight::from_ref_time(8_346_000).saturating_add(DbWeight::get().writes(1)) - } - // Storage: Staking PermissionedIdentity (r:1 w:1) - // Proof Skipped: Staking PermissionedIdentity (max_values: None, max_size: None, mode: Measured) - // Storage: Timestamp Now (r:1 w:0) - // Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) - // Storage: Instance2Group ActiveMembers (r:1 w:0) - // Proof Skipped: Instance2Group ActiveMembers (max_values: Some(1), max_size: None, mode: Measured) - // Storage: Identity Claims (r:2 w:0) - // Proof Skipped: Identity Claims (max_values: None, max_size: None, mode: Measured) - // Storage: Staking ValidatorCount (r:1 w:0) - // Proof Skipped: Staking ValidatorCount (max_values: Some(1), max_size: None, mode: Measured) - fn add_permissioned_validator() -> Weight { - // Minimum execution time: 35_677 nanoseconds. - Weight::from_ref_time(35_837_000) - .saturating_add(DbWeight::get().reads(6)) - .saturating_add(DbWeight::get().writes(1)) - } - // Storage: Staking PermissionedIdentity (r:1 w:1) - // Proof Skipped: Staking PermissionedIdentity (max_values: None, max_size: None, mode: Measured) - fn remove_permissioned_validator() -> Weight { - // Minimum execution time: 18_816 nanoseconds. - Weight::from_ref_time(19_717_000) - .saturating_add(DbWeight::get().reads(1)) - .saturating_add(DbWeight::get().writes(1)) - } - // Storage: Staking ValidatorCommissionCap (r:1 w:1) - // Proof Skipped: Staking ValidatorCommissionCap (max_values: Some(1), max_size: None, mode: Measured) - // Storage: Staking Validators (r:152 w:151) - // Proof Skipped: Staking Validators (max_values: None, max_size: None, mode: Measured) - /// The range of component `m` is `[0, 150]`. - fn set_commission_cap(m: u32) -> Weight { - // Minimum execution time: 22_072 nanoseconds. - Weight::from_ref_time(23_338_011) - // Standard Error: 23_481 - .saturating_add(Weight::from_ref_time(3_807_937).saturating_mul(m.into())) - .saturating_add(DbWeight::get().reads(3)) - .saturating_add(DbWeight::get().reads((1_u64).saturating_mul(m.into()))) - .saturating_add(DbWeight::get().writes(2)) - .saturating_add(DbWeight::get().writes((1_u64).saturating_mul(m.into()))) - } - // Storage: Staking EraElectionStatus (r:1 w:0) - // Proof Skipped: Staking EraElectionStatus (max_values: Some(1), max_size: None, mode: Measured) - // Storage: Staking Ledger (r:1 w:0) - // Proof Skipped: Staking Ledger (max_values: None, max_size: None, mode: Measured) - // Storage: Staking Nominators (r:1 w:1) - // Proof Skipped: Staking Nominators (max_values: None, max_size: None, mode: Measured) - // Storage: Identity KeyRecords (r:1 w:0) - // Proof Skipped: Identity KeyRecords (max_values: None, max_size: None, mode: Measured) - // Storage: Timestamp Now (r:1 w:0) - // Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) - // Storage: Instance2Group ActiveMembers (r:1 w:0) - // Proof Skipped: Instance2Group ActiveMembers (max_values: Some(1), max_size: None, mode: Measured) - // Storage: Identity Claims (r:2 w:0) - // Proof Skipped: Identity Claims (max_values: None, max_size: None, mode: Measured) - // Storage: Staking Validators (r:17 w:1) - // Proof Skipped: Staking Validators (max_values: None, max_size: None, mode: Measured) - // Storage: Staking CurrentEra (r:1 w:0) - // Proof Skipped: Staking CurrentEra (max_values: Some(1), max_size: None, mode: Measured) - /// The range of component `n` is `[1, 16]`. - fn nominate(n: u32) -> Weight { - // Minimum execution time: 59_642 nanoseconds. - Weight::from_ref_time(55_291_662) - // Standard Error: 26_306 - .saturating_add(Weight::from_ref_time(3_136_120).saturating_mul(n.into())) - .saturating_add(DbWeight::get().reads(10)) - .saturating_add(DbWeight::get().reads((1_u64).saturating_mul(n.into()))) - .saturating_add(DbWeight::get().writes(2)) - } - // Storage: Staking EraElectionStatus (r:1 w:0) - // Proof Skipped: Staking EraElectionStatus (max_values: Some(1), max_size: None, mode: Measured) - // Storage: Staking Ledger (r:1 w:0) - // Proof Skipped: Staking Ledger (max_values: None, max_size: None, mode: Measured) - // Storage: Staking Validators (r:1 w:1) - // Proof Skipped: Staking Validators (max_values: None, max_size: None, mode: Measured) - // Storage: Staking Nominators (r:0 w:1) - // Proof Skipped: Staking Nominators (max_values: None, max_size: None, mode: Measured) - fn chill() -> Weight { - // Minimum execution time: 20_929 nanoseconds. - Weight::from_ref_time(21_270_000) - .saturating_add(DbWeight::get().reads(3)) - .saturating_add(DbWeight::get().writes(2)) - } - // Storage: Staking Ledger (r:1 w:0) - // Proof Skipped: Staking Ledger (max_values: None, max_size: None, mode: Measured) - // Storage: Staking Payee (r:0 w:1) - // Proof Skipped: Staking Payee (max_values: None, max_size: None, mode: Measured) - fn set_payee() -> Weight { - // Minimum execution time: 14_538 nanoseconds. - Weight::from_ref_time(14_848_000) - .saturating_add(DbWeight::get().reads(1)) - .saturating_add(DbWeight::get().writes(1)) - } - // Storage: Staking Bonded (r:1 w:1) - // Proof Skipped: Staking Bonded (max_values: None, max_size: None, mode: Measured) - // Storage: Staking Ledger (r:2 w:2) - // Proof Skipped: Staking Ledger (max_values: None, max_size: None, mode: Measured) - fn set_controller() -> Weight { - // Minimum execution time: 22_882 nanoseconds. - Weight::from_ref_time(23_224_000) - .saturating_add(DbWeight::get().reads(3)) - .saturating_add(DbWeight::get().writes(3)) - } - // Storage: Staking ValidatorCount (r:0 w:1) - // Proof Skipped: Staking ValidatorCount (max_values: Some(1), max_size: None, mode: Measured) - /// The range of component `c` is `[0, 1000]`. - fn set_validator_count(c: u32) -> Weight { - // Minimum execution time: 3_276 nanoseconds. - Weight::from_ref_time(3_780_246) - // Standard Error: 266 - .saturating_add(Weight::from_ref_time(867).saturating_mul(c.into())) - .saturating_add(DbWeight::get().writes(1)) - } - // Storage: Staking ForceEra (r:0 w:1) - // Proof Skipped: Staking ForceEra (max_values: Some(1), max_size: None, mode: Measured) - fn force_no_eras() -> Weight { - // Minimum execution time: 3_447 nanoseconds. - Weight::from_ref_time(3_597_000).saturating_add(DbWeight::get().writes(1)) - } - // Storage: Staking ForceEra (r:0 w:1) - // Proof Skipped: Staking ForceEra (max_values: Some(1), max_size: None, mode: Measured) - fn force_new_era() -> Weight { - // Minimum execution time: 3_336 nanoseconds. - Weight::from_ref_time(3_417_000).saturating_add(DbWeight::get().writes(1)) - } - // Storage: Staking ForceEra (r:0 w:1) - // Proof Skipped: Staking ForceEra (max_values: Some(1), max_size: None, mode: Measured) - fn force_new_era_always() -> Weight { - // Minimum execution time: 3_316 nanoseconds. - Weight::from_ref_time(3_436_000).saturating_add(DbWeight::get().writes(1)) - } - // Storage: Staking Invulnerables (r:0 w:1) - // Proof Skipped: Staking Invulnerables (max_values: Some(1), max_size: None, mode: Measured) - /// The range of component `v` is `[0, 1000]`. - fn set_invulnerables(v: u32) -> Weight { - // Minimum execution time: 3_617 nanoseconds. - Weight::from_ref_time(4_296_839) - // Standard Error: 262 - .saturating_add(Weight::from_ref_time(5_710).saturating_mul(v.into())) - .saturating_add(DbWeight::get().writes(1)) - } - // Storage: Staking Bonded (r:1 w:1) - // Proof Skipped: Staking Bonded (max_values: None, max_size: None, mode: Measured) - // Storage: Staking SlashingSpans (r:1 w:1) - // Proof Skipped: Staking SlashingSpans (max_values: None, max_size: None, mode: Measured) - // 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 Skipped: Balances Locks (max_values: None, max_size: None, mode: Measured) - // Storage: Staking Ledger (r:0 w:1) - // Proof Skipped: Staking Ledger (max_values: None, max_size: None, mode: Measured) - // Storage: Staking Validators (r:0 w:1) - // Proof Skipped: Staking Validators (max_values: None, max_size: None, mode: Measured) - // Storage: Staking Payee (r:0 w:1) - // Proof Skipped: Staking Payee (max_values: None, max_size: None, mode: Measured) - // Storage: Staking Nominators (r:0 w:1) - // Proof Skipped: Staking Nominators (max_values: None, max_size: None, mode: Measured) - // Storage: Staking SpanSlash (r:0 w:99) - // Proof Skipped: Staking SpanSlash (max_values: None, max_size: None, mode: Measured) - /// The range of component `s` is `[0, 100]`. - fn force_unstake(s: u32) -> Weight { - // Minimum execution time: 35_276 nanoseconds. - Weight::from_ref_time(40_307_207) - // Standard Error: 63_386 - .saturating_add(Weight::from_ref_time(1_548_611).saturating_mul(s.into())) - .saturating_add(DbWeight::get().reads(4)) - .saturating_add(DbWeight::get().writes(8)) - .saturating_add(DbWeight::get().writes((1_u64).saturating_mul(s.into()))) - } - // Storage: Staking UnappliedSlashes (r:1 w:1) - // Proof Skipped: Staking UnappliedSlashes (max_values: None, max_size: None, mode: Measured) - /// The range of component `s` is `[1, 1000]`. - fn cancel_deferred_slash(s: u32) -> Weight { - // Minimum execution time: 131_447 nanoseconds. - Weight::from_ref_time(723_008_002) - // Standard Error: 84_074 - .saturating_add(Weight::from_ref_time(2_626_167).saturating_mul(s.into())) - .saturating_add(DbWeight::get().reads(1)) - .saturating_add(DbWeight::get().writes(1)) - } - // Storage: Staking EraElectionStatus (r:1 w:0) - // Proof Skipped: Staking EraElectionStatus (max_values: Some(1), max_size: None, mode: Measured) - // Storage: Staking CurrentEra (r:1 w:0) - // Proof Skipped: Staking CurrentEra (max_values: Some(1), max_size: None, mode: Measured) - // Storage: Staking HistoryDepth (r:1 w:0) - // Proof Skipped: Staking HistoryDepth (max_values: Some(1), max_size: None, mode: Measured) - // Storage: Staking ErasValidatorReward (r:1 w:0) - // Proof Skipped: Staking ErasValidatorReward (max_values: None, max_size: None, mode: Measured) - // Storage: Staking Bonded (r:2049 w:0) - // Proof Skipped: Staking Bonded (max_values: None, max_size: None, mode: Measured) - // Storage: Staking Ledger (r:1 w:1) - // Proof Skipped: Staking Ledger (max_values: None, max_size: None, mode: Measured) - // Storage: Staking ErasStakersClipped (r:1 w:0) - // Proof Skipped: Staking ErasStakersClipped (max_values: None, max_size: None, mode: Measured) - // Storage: Staking ErasRewardPoints (r:1 w:0) - // Proof Skipped: Staking ErasRewardPoints (max_values: None, max_size: None, mode: Measured) - // Storage: Staking ErasValidatorPrefs (r:1 w:0) - // Proof Skipped: Staking ErasValidatorPrefs (max_values: None, max_size: None, mode: Measured) - // Storage: Staking Payee (r:2049 w:0) - // Proof Skipped: Staking Payee (max_values: None, max_size: None, mode: Measured) - // Storage: System Account (r:2050 w:2050) - // Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) - // Storage: Balances Locks (r:1 w:1) - // Proof Skipped: Balances Locks (max_values: None, max_size: None, mode: Measured) - // Storage: Identity KeyRecords (r:4098 w:0) - // Proof Skipped: Identity KeyRecords (max_values: None, max_size: None, mode: Measured) - // Storage: Identity IsDidFrozen (r:2048 w:0) - // Proof Skipped: Identity IsDidFrozen (max_values: None, max_size: None, mode: Measured) - /// The range of component `n` is `[1, 2048]`. - fn payout_stakers(n: u32) -> Weight { - // Minimum execution time: 232_406 nanoseconds. - Weight::from_ref_time(637_731_367) - // Standard Error: 50_873 - .saturating_add(Weight::from_ref_time(44_899_232).saturating_mul(n.into())) - .saturating_add(DbWeight::get().reads(15)) - .saturating_add(DbWeight::get().reads((6_u64).saturating_mul(n.into()))) - .saturating_add(DbWeight::get().writes(4)) - .saturating_add(DbWeight::get().writes((1_u64).saturating_mul(n.into()))) - } - // Storage: Staking EraElectionStatus (r:1 w:0) - // Proof Skipped: Staking EraElectionStatus (max_values: Some(1), max_size: None, mode: Measured) - // Storage: Staking CurrentEra (r:1 w:0) - // Proof Skipped: Staking CurrentEra (max_values: Some(1), max_size: None, mode: Measured) - // Storage: Staking HistoryDepth (r:1 w:0) - // Proof Skipped: Staking HistoryDepth (max_values: Some(1), max_size: None, mode: Measured) - // Storage: Staking ErasValidatorReward (r:1 w:0) - // Proof Skipped: Staking ErasValidatorReward (max_values: None, max_size: None, mode: Measured) - // Storage: Staking Bonded (r:2049 w:0) - // Proof Skipped: Staking Bonded (max_values: None, max_size: None, mode: Measured) - // Storage: Staking Ledger (r:2049 w:2049) - // Proof Skipped: Staking Ledger (max_values: None, max_size: None, mode: Measured) - // Storage: Staking ErasStakersClipped (r:1 w:0) - // Proof Skipped: Staking ErasStakersClipped (max_values: None, max_size: None, mode: Measured) - // Storage: Staking ErasRewardPoints (r:1 w:0) - // Proof Skipped: Staking ErasRewardPoints (max_values: None, max_size: None, mode: Measured) - // Storage: Staking ErasValidatorPrefs (r:1 w:0) - // Proof Skipped: Staking ErasValidatorPrefs (max_values: None, max_size: None, mode: Measured) - // Storage: Staking Payee (r:2049 w:0) - // Proof Skipped: Staking Payee (max_values: None, max_size: None, mode: Measured) - // Storage: System Account (r:2050 w:2050) - // Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) - // Storage: Balances Locks (r:2049 w:2049) - // Proof Skipped: Balances Locks (max_values: None, max_size: None, mode: Measured) - // Storage: Identity KeyRecords (r:2050 w:0) - // Proof Skipped: Identity KeyRecords (max_values: None, max_size: None, mode: Measured) - /// The range of component `n` is `[1, 2048]`. - fn payout_stakers_alive_controller(n: u32) -> Weight { - // Minimum execution time: 241_764 nanoseconds. - Weight::from_ref_time(735_065_515) - // Standard Error: 64_047 - .saturating_add(Weight::from_ref_time(49_953_875).saturating_mul(n.into())) - .saturating_add(DbWeight::get().reads(15)) - .saturating_add(DbWeight::get().reads((6_u64).saturating_mul(n.into()))) - .saturating_add(DbWeight::get().writes(4)) - .saturating_add(DbWeight::get().writes((3_u64).saturating_mul(n.into()))) - } - // Storage: Staking EraElectionStatus (r:1 w:0) - // Proof Skipped: Staking EraElectionStatus (max_values: Some(1), max_size: None, mode: Measured) - // Storage: Staking Ledger (r:1 w:1) - // Proof Skipped: Staking Ledger (max_values: None, max_size: None, mode: Measured) - // Storage: Balances Locks (r:1 w:1) - // Proof Skipped: Balances Locks (max_values: None, max_size: None, mode: Measured) - // 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 `u` is `[0, 1000]`. - /// The range of component `l` is `[1, 32]`. - fn rebond(u: u32) -> Weight { - // Minimum execution time: 29_204 nanoseconds. - Weight::from_ref_time(27_604_248) - // Standard Error: 1_123 - .saturating_add(Weight::from_ref_time(1_659).saturating_mul(u.into())) - .saturating_add(DbWeight::get().reads(4)) - .saturating_add(DbWeight::get().writes(3)) - } - // Storage: Staking CurrentEra (r:1 w:0) - // Proof Skipped: Staking CurrentEra (max_values: Some(1), max_size: None, mode: Measured) - // Storage: Staking HistoryDepth (r:1 w:1) - // Proof Skipped: Staking HistoryDepth (max_values: Some(1), max_size: None, mode: Measured) - // Storage: Staking ErasStakers (r:101 w:101) - // Proof Skipped: Staking ErasStakers (max_values: None, max_size: None, mode: Measured) - // Storage: Staking ErasStakersClipped (r:101 w:101) - // Proof Skipped: Staking ErasStakersClipped (max_values: None, max_size: None, mode: Measured) - // Storage: Staking ErasValidatorPrefs (r:101 w:101) - // Proof Skipped: Staking ErasValidatorPrefs (max_values: None, max_size: None, mode: Measured) - // Storage: Staking ErasValidatorReward (r:0 w:100) - // Proof Skipped: Staking ErasValidatorReward (max_values: None, max_size: None, mode: Measured) - // Storage: Staking ErasRewardPoints (r:0 w:100) - // Proof Skipped: Staking ErasRewardPoints (max_values: None, max_size: None, mode: Measured) - // Storage: Staking ErasTotalStake (r:0 w:100) - // Proof Skipped: Staking ErasTotalStake (max_values: None, max_size: None, mode: Measured) - // Storage: Staking ErasStartSessionIndex (r:0 w:100) - // Proof Skipped: Staking ErasStartSessionIndex (max_values: None, max_size: None, mode: Measured) - /// The range of component `e` is `[1, 100]`. - fn set_history_depth(e: u32) -> Weight { - // Minimum execution time: 31_699 nanoseconds. - Weight::from_ref_time(32_401_000) - // Standard Error: 81_497 - .saturating_add(Weight::from_ref_time(21_241_794).saturating_mul(e.into())) - .saturating_add(DbWeight::get().reads(5)) - .saturating_add(DbWeight::get().reads((3_u64).saturating_mul(e.into()))) - .saturating_add(DbWeight::get().writes(4)) - .saturating_add(DbWeight::get().writes((7_u64).saturating_mul(e.into()))) - } - // 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 Skipped: Staking Bonded (max_values: None, max_size: None, mode: Measured) - // Storage: Staking SlashingSpans (r:1 w:1) - // Proof Skipped: Staking SlashingSpans (max_values: None, max_size: None, mode: Measured) - // Storage: Balances Locks (r:1 w:1) - // Proof Skipped: Balances Locks (max_values: None, max_size: None, mode: Measured) - // Storage: Staking Ledger (r:0 w:1) - // Proof Skipped: Staking Ledger (max_values: None, max_size: None, mode: Measured) - // Storage: Staking Validators (r:0 w:1) - // Proof Skipped: Staking Validators (max_values: None, max_size: None, mode: Measured) - // Storage: Staking Payee (r:0 w:1) - // Proof Skipped: Staking Payee (max_values: None, max_size: None, mode: Measured) - // Storage: Staking Nominators (r:0 w:1) - // Proof Skipped: Staking Nominators (max_values: None, max_size: None, mode: Measured) - // Storage: Staking SpanSlash (r:0 w:100) - // Proof Skipped: Staking SpanSlash (max_values: None, max_size: None, mode: Measured) - /// The range of component `s` is `[1, 100]`. - fn reap_stash(s: u32) -> Weight { - // Minimum execution time: 41_367 nanoseconds. - Weight::from_ref_time(44_791_825) - // Standard Error: 61_322 - .saturating_add(Weight::from_ref_time(1_465_690).saturating_mul(s.into())) - .saturating_add(DbWeight::get().reads(4)) - .saturating_add(DbWeight::get().writes(8)) - .saturating_add(DbWeight::get().writes((1_u64).saturating_mul(s.into()))) - } - // Storage: Staking CurrentEra (r:1 w:1) - // Proof Skipped: Staking CurrentEra (max_values: Some(1), max_size: None, mode: Measured) - // Storage: Staking HistoryDepth (r:1 w:0) - // Proof Skipped: Staking HistoryDepth (max_values: Some(1), max_size: None, mode: Measured) - // Storage: Staking QueuedElected (r:1 w:0) - // Proof Skipped: Staking QueuedElected (max_values: Some(1), max_size: None, mode: Measured) - // Storage: Staking Validators (r:11 w:0) - // Proof Skipped: Staking Validators (max_values: None, max_size: None, mode: Measured) - // Storage: Staking Bonded (r:110 w:0) - // Proof Skipped: Staking Bonded (max_values: None, max_size: None, mode: Measured) - // Storage: Staking Ledger (r:110 w:0) - // Proof Skipped: Staking Ledger (max_values: None, max_size: None, mode: Measured) - // Storage: Staking MinimumBondThreshold (r:1 w:0) - // Proof Skipped: Staking MinimumBondThreshold (max_values: Some(1), max_size: None, mode: Measured) - // Storage: Identity KeyRecords (r:110 w:0) - // Proof Skipped: Identity KeyRecords (max_values: None, max_size: None, mode: Measured) - // Storage: Timestamp Now (r:1 w:0) - // Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) - // Storage: Instance2Group ActiveMembers (r:1 w:0) - // Proof Skipped: Instance2Group ActiveMembers (max_values: Some(1), max_size: None, mode: Measured) - // Storage: Identity Claims (r:220 w:0) - // Proof Skipped: Identity Claims (max_values: None, max_size: None, mode: Measured) - // Storage: Staking PermissionedIdentity (r:10 w:0) - // Proof Skipped: Staking PermissionedIdentity (max_values: None, max_size: None, mode: Measured) - // Storage: Staking Nominators (r:101 w:0) - // Proof Skipped: Staking Nominators (max_values: None, max_size: None, mode: Measured) - // Storage: Staking SlashingSpans (r:10 w:0) - // Proof Skipped: Staking SlashingSpans (max_values: None, max_size: None, mode: Measured) - // Storage: Staking MinimumValidatorCount (r:1 w:0) - // Proof Skipped: Staking MinimumValidatorCount (max_values: Some(1), max_size: None, mode: Measured) - // Storage: Staking ValidatorCount (r:1 w:0) - // Proof Skipped: Staking ValidatorCount (max_values: Some(1), max_size: None, mode: Measured) - // Storage: Staking ErasStakersClipped (r:0 w:10) - // Proof Skipped: Staking ErasStakersClipped (max_values: None, max_size: None, mode: Measured) - // Storage: Staking ErasValidatorPrefs (r:0 w:10) - // Proof Skipped: Staking ErasValidatorPrefs (max_values: None, max_size: None, mode: Measured) - // Storage: Staking SnapshotValidators (r:0 w:1) - // Proof Skipped: Staking SnapshotValidators (max_values: Some(1), max_size: None, mode: Measured) - // Storage: Staking ErasStakers (r:0 w:10) - // Proof Skipped: Staking ErasStakers (max_values: None, max_size: None, mode: Measured) - // Storage: Staking ErasTotalStake (r:0 w:1) - // Proof Skipped: Staking ErasTotalStake (max_values: None, max_size: None, mode: Measured) - // Storage: Staking IsCurrentSessionFinal (r:0 w:1) - // Proof Skipped: Staking IsCurrentSessionFinal (max_values: Some(1), max_size: None, mode: Measured) - // Storage: Staking ErasStartSessionIndex (r:0 w:1) - // Proof Skipped: Staking ErasStartSessionIndex (max_values: None, max_size: None, mode: Measured) - // Storage: Staking QueuedScore (r:0 w:1) - // Proof Skipped: Staking QueuedScore (max_values: Some(1), max_size: None, mode: Measured) - // Storage: Staking EraElectionStatus (r:0 w:1) - // Proof Skipped: Staking EraElectionStatus (max_values: Some(1), max_size: None, mode: Measured) - // Storage: Staking SnapshotNominators (r:0 w:1) - // Proof Skipped: Staking SnapshotNominators (max_values: Some(1), max_size: None, mode: Measured) - /// The range of component `v` is `[1, 10]`. - /// The range of component `n` is `[1, 100]`. - fn new_era(v: u32, n: u32) -> Weight { - // Minimum execution time: 575_084 nanoseconds. - Weight::from_ref_time(575_906_000) - // Standard Error: 4_697_659 - .saturating_add(Weight::from_ref_time(89_461_564).saturating_mul(v.into())) - // Standard Error: 482_537 - .saturating_add(Weight::from_ref_time(36_987_298).saturating_mul(n.into())) - .saturating_add(DbWeight::get().reads(10)) - .saturating_add(DbWeight::get().reads((8_u64).saturating_mul(v.into()))) - .saturating_add(DbWeight::get().reads((6_u64).saturating_mul(n.into()))) - .saturating_add(DbWeight::get().writes(8)) - .saturating_add(DbWeight::get().writes((3_u64).saturating_mul(v.into()))) - } - // Storage: Staking EraElectionStatus (r:1 w:0) - // Proof Skipped: Staking EraElectionStatus (max_values: Some(1), max_size: None, mode: Measured) - // Storage: Staking CurrentEra (r:1 w:0) - // Proof Skipped: Staking CurrentEra (max_values: Some(1), max_size: None, mode: Measured) - // Storage: Staking HistoryDepth (r:1 w:0) - // Proof Skipped: Staking HistoryDepth (max_values: Some(1), max_size: None, mode: Measured) - // Storage: Staking ErasValidatorReward (r:1 w:0) - // Proof Skipped: Staking ErasValidatorReward (max_values: None, max_size: None, mode: Measured) - // Storage: Staking Bonded (r:110 w:0) - // Proof Skipped: Staking Bonded (max_values: None, max_size: None, mode: Measured) - // Storage: Staking Ledger (r:110 w:110) - // Proof Skipped: Staking Ledger (max_values: None, max_size: None, mode: Measured) - // Storage: Staking ErasStakersClipped (r:10 w:0) - // Proof Skipped: Staking ErasStakersClipped (max_values: None, max_size: None, mode: Measured) - // Storage: Staking ErasRewardPoints (r:1 w:0) - // Proof Skipped: Staking ErasRewardPoints (max_values: None, max_size: None, mode: Measured) - // Storage: Staking ErasValidatorPrefs (r:10 w:0) - // Proof Skipped: Staking ErasValidatorPrefs (max_values: None, max_size: None, mode: Measured) - // Storage: Staking Payee (r:110 w:0) - // Proof Skipped: Staking Payee (max_values: None, max_size: None, mode: Measured) - // Storage: System Account (r:111 w:111) - // Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) - // Storage: Balances Locks (r:110 w:110) - // Proof Skipped: Balances Locks (max_values: None, max_size: None, mode: Measured) - // Storage: Identity KeyRecords (r:111 w:0) - // Proof Skipped: Identity KeyRecords (max_values: None, max_size: None, mode: Measured) - /// The range of component `v` is `[1, 10]`. - /// The range of component `n` is `[1, 100]`. - fn payout_all(v: u32, n: u32) -> Weight { - // Minimum execution time: 898_459 nanoseconds. - Weight::from_ref_time(899_731_000) - // Standard Error: 51_247_510 - .saturating_add(Weight::from_ref_time(1_005_447_166).saturating_mul(v.into())) - // Standard Error: 5_264_083 - .saturating_add(Weight::from_ref_time(154_675_046).saturating_mul(n.into())) - .saturating_add(DbWeight::get().reads(7)) - .saturating_add(DbWeight::get().reads((8_u64).saturating_mul(v.into()))) - .saturating_add(DbWeight::get().reads((6_u64).saturating_mul(n.into()))) - .saturating_add(DbWeight::get().writes(1)) - .saturating_add(DbWeight::get().writes((3_u64).saturating_mul(v.into()))) - .saturating_add(DbWeight::get().writes((3_u64).saturating_mul(n.into()))) - } - // Storage: Staking Bonded (r:1 w:0) - // Proof Skipped: Staking Bonded (max_values: None, max_size: None, mode: Measured) - // Storage: Staking Ledger (r:1 w:1) - // Proof Skipped: Staking Ledger (max_values: None, max_size: None, mode: Measured) - // 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 Skipped: Balances Locks (max_values: None, max_size: None, mode: Measured) - /// The range of component `l` is `[1, 32]`. - fn do_slash(l: u32) -> Weight { - // Minimum execution time: 36_849 nanoseconds. - Weight::from_ref_time(40_663_382) - // Standard Error: 38_394 - .saturating_add(Weight::from_ref_time(7_643).saturating_mul(l.into())) - .saturating_add(DbWeight::get().reads(4)) - .saturating_add(DbWeight::get().writes(3)) - } - // Storage: Staking EraElectionStatus (r:1 w:0) - // Proof Skipped: Staking EraElectionStatus (max_values: Some(1), max_size: None, mode: Measured) - // Storage: Staking CurrentEra (r:1 w:0) - // Proof Skipped: Staking CurrentEra (max_values: Some(1), max_size: None, mode: Measured) - // Storage: Staking QueuedScore (r:1 w:1) - // Proof Skipped: Staking QueuedScore (max_values: Some(1), max_size: None, mode: Measured) - // Storage: Staking SnapshotValidators (r:1 w:0) - // Proof Skipped: Staking SnapshotValidators (max_values: Some(1), max_size: None, mode: Measured) - // Storage: Staking ValidatorCount (r:1 w:0) - // Proof Skipped: Staking ValidatorCount (max_values: Some(1), max_size: None, mode: Measured) - // Storage: Staking SnapshotNominators (r:1 w:0) - // Proof Skipped: Staking SnapshotNominators (max_values: Some(1), max_size: None, mode: Measured) - // Storage: Staking Validators (r:500 w:0) - // Proof Skipped: Staking Validators (max_values: None, max_size: None, mode: Measured) - // Storage: Staking Nominators (r:500 w:0) - // Proof Skipped: Staking Nominators (max_values: None, max_size: None, mode: Measured) - // Storage: Staking SlashingSpans (r:100 w:0) - // Proof Skipped: Staking SlashingSpans (max_values: None, max_size: None, mode: Measured) - // Storage: Staking Bonded (r:500 w:0) - // Proof Skipped: Staking Bonded (max_values: None, max_size: None, mode: Measured) - // Storage: Staking Ledger (r:500 w:0) - // Proof Skipped: Staking Ledger (max_values: None, max_size: None, mode: Measured) - // Storage: Staking QueuedElected (r:0 w:1) - // Proof Skipped: Staking QueuedElected (max_values: Some(1), max_size: None, mode: Measured) - /// The range of component `v` is `[1000, 2000]`. - /// The range of component `n` is `[1000, 2000]`. - /// The range of component `a` is `[200, 500]`. - /// The range of component `w` is `[16, 100]`. - fn submit_solution_better(v: u32, n: u32, a: u32, w: u32) -> Weight { - // Minimum execution time: 8_156_707 nanoseconds. - Weight::from_ref_time(8_209_156_000) - // Standard Error: 93_923 - .saturating_add(Weight::from_ref_time(355_707).saturating_mul(v.into())) - // Standard Error: 624_649 - .saturating_add(Weight::from_ref_time(1_817_605).saturating_mul(n.into())) - // Standard Error: 172_840 - .saturating_add(Weight::from_ref_time(33_039_291).saturating_mul(a.into())) - .saturating_add(DbWeight::get().reads(6)) - .saturating_add(DbWeight::get().reads((4_u64).saturating_mul(a.into()))) - .saturating_add(DbWeight::get().reads((1_u64).saturating_mul(w.into()))) - .saturating_add(DbWeight::get().writes(2)) - } - // Storage: Staking SlashingAllowedFor (r:0 w:1) - // Proof Skipped: Staking SlashingAllowedFor (max_values: Some(1), max_size: None, mode: Measured) - fn change_slashing_allowed_for() -> Weight { - // Minimum execution time: 7_494 nanoseconds. - Weight::from_ref_time(7_865_000).saturating_add(DbWeight::get().writes(1)) - } - // Storage: Staking ValidatorCount (r:1 w:0) - // Proof Skipped: Staking ValidatorCount (max_values: Some(1), max_size: None, mode: Measured) - // Storage: Staking PermissionedIdentity (r:1 w:1) - // Proof Skipped: Staking PermissionedIdentity (max_values: None, max_size: None, mode: Measured) - fn update_permissioned_validator_intended_count() -> Weight { - // Minimum execution time: 13_626 nanoseconds. - Weight::from_ref_time(13_756_000) - .saturating_add(DbWeight::get().reads(2)) - .saturating_add(DbWeight::get().writes(1)) - } - // Storage: Staking ValidatorCount (r:1 w:1) - // Proof Skipped: Staking ValidatorCount (max_values: Some(1), max_size: None, mode: Measured) - fn increase_validator_count() -> Weight { - // Minimum execution time: 9_919 nanoseconds. - Weight::from_ref_time(10_219_000) - .saturating_add(DbWeight::get().reads(1)) - .saturating_add(DbWeight::get().writes(1)) - } - // Storage: Staking ValidatorCount (r:1 w:1) - // Proof Skipped: Staking ValidatorCount (max_values: Some(1), max_size: None, mode: Measured) - fn scale_validator_count() -> Weight { - // Minimum execution time: 9_948 nanoseconds. - Weight::from_ref_time(10_069_000) - .saturating_add(DbWeight::get().reads(1)) - .saturating_add(DbWeight::get().writes(1)) - } - // Storage: Staking EraElectionStatus (r:1 w:0) - // Proof Skipped: Staking EraElectionStatus (max_values: Some(1), max_size: None, mode: Measured) - // Storage: Staking PermissionedIdentity (r:1 w:1) - // Proof Skipped: Staking PermissionedIdentity (max_values: None, max_size: None, mode: Measured) - // Storage: Identity KeyRecords (r:100 w:0) - // Proof Skipped: Identity KeyRecords (max_values: None, max_size: None, mode: Measured) - // Storage: Identity IsDidFrozen (r:1 w:0) - // Proof Skipped: Identity IsDidFrozen (max_values: None, max_size: None, mode: Measured) - // Storage: Staking Validators (r:100 w:100) - // Proof Skipped: Staking Validators (max_values: None, max_size: None, mode: Measured) - // Storage: Identity AccountKeyRefCount (r:100 w:100) - // Proof Skipped: Identity AccountKeyRefCount (max_values: None, max_size: None, mode: Measured) - // Storage: Staking Nominators (r:0 w:100) - // Proof Skipped: Staking Nominators (max_values: None, max_size: None, mode: Measured) - /// The range of component `s` is `[1, 100]`. - fn chill_from_governance(s: u32) -> Weight { - // Minimum execution time: 42_960 nanoseconds. - Weight::from_ref_time(43_351_000) - // Standard Error: 42_572 - .saturating_add(Weight::from_ref_time(18_717_542).saturating_mul(s.into())) - .saturating_add(DbWeight::get().reads(3)) - .saturating_add(DbWeight::get().reads((3_u64).saturating_mul(s.into()))) - .saturating_add(DbWeight::get().writes(1)) - .saturating_add(DbWeight::get().writes((3_u64).saturating_mul(s.into()))) - } -} diff --git a/runtime/common/Cargo.toml b/runtime/common/Cargo.toml index ff63cf4..e8ddac1 100644 --- a/runtime/common/Cargo.toml +++ b/runtime/common/Cargo.toml @@ -9,7 +9,6 @@ polymesh-common-utilities = { workspace = true, default-features = false } polymesh-primitives = { workspace = true, default-features = false } pallet-balances = { workspace = true, default-features = false } -pallet-bridge = { workspace = true, default-features = false } pallet-committee = { workspace = true, default-features = false } pallet-identity = { workspace = true, default-features = false } pallet-multisig = { workspace = true, default-features = false } @@ -34,7 +33,6 @@ pallet-authorship = { workspace = true, default-features = false } [features] equalize = [] -only-staking = [] default = ["std", "equalize"] runtime-benchmarks = [] testing = [] diff --git a/runtime/common/src/fee_details.rs b/runtime/common/src/fee_details.rs index 99a8f1e..bc115a9 100644 --- a/runtime/common/src/fee_details.rs +++ b/runtime/common/src/fee_details.rs @@ -47,12 +47,11 @@ impl GetValidPayerHook for Noop { /// The set of `Call`s from pallets that `CddHandler` recognizes specially. pub enum Call<'a, R> where - R: Config + pallet_multisig::Config + pallet_relayer::Config + pallet_bridge::Config, + R: Config + pallet_multisig::Config + pallet_relayer::Config, { MultiSig(&'a pallet_multisig::Call), Identity(&'a pallet_identity::Call), Relayer(&'a pallet_relayer::Call), - Bridge(&'a pallet_bridge::Call), } /// The implementation of `CddAndFeeDetails` for the chain. @@ -63,10 +62,7 @@ impl CddAndFeeDetails for CddHandler where H: GetValidPayerHook, for<'a> Call<'a, A>: TryFrom<&'a C>, - A: Config - + pallet_multisig::Config - + pallet_relayer::Config - + pallet_bridge::Config, + A: Config + pallet_multisig::Config + pallet_relayer::Config, { /// Check if there's an eligible payer with valid CDD. /// Return the payer if found or else an error. @@ -171,15 +167,6 @@ where | pallet_multisig::Call::approve_as_key { multisig, .. } | pallet_multisig::Call::reject_as_key { multisig, .. }, )) => handle_multisig(multisig, caller), - // Call made by an Account key to propose or approve a multisig transaction via the bridge helper - // The multisig must have valid CDD and the caller must be a signer of the multisig. - Ok(Call::Bridge( - pallet_bridge::Call::propose_bridge_tx { .. } - | pallet_bridge::Call::batch_propose_bridge_tx { .. }, - )) => match pallet_bridge::Module::::controller() { - Some(controller) => handle_multisig(&controller, caller), - None => MISSING_ID, - }, // All other calls. // // The external account must directly be linked to an identity with valid CDD. diff --git a/runtime/common/src/impls.rs b/runtime/common/src/impls.rs index a16cd45..f02dc81 100644 --- a/runtime/common/src/impls.rs +++ b/runtime/common/src/impls.rs @@ -38,8 +38,6 @@ use frame_support::traits::{Currency, OnUnbalanced}; use frame_system as system; use pallet_authorship as authorship; use pallet_balances as balances; -use polymesh_primitives::Balance; -use sp_runtime::traits::Convert; pub struct Author(sp_std::marker::PhantomData); @@ -55,35 +53,3 @@ where } } } - -/// Struct that handles the conversion of Balance -> `u128`. This is used for staking's election -/// calculation. -pub struct CurrencyToVoteHandler(sp_std::marker::PhantomData); - -impl CurrencyToVoteHandler -where - R: balances::Config, -{ - fn factor() -> Balance { - let issuance: Balance = >::total_issuance(); - (issuance / u64::max_value() as Balance).max(1) - } -} - -impl Convert for CurrencyToVoteHandler -where - R: balances::Config, -{ - fn convert(x: Balance) -> u64 { - (x / Self::factor()) as u64 - } -} - -impl Convert for CurrencyToVoteHandler -where - R: balances::Config, -{ - fn convert(x: u128) -> Balance { - x * Self::factor() - } -} diff --git a/runtime/common/src/lib.rs b/runtime/common/src/lib.rs index ca19a4d..8858c18 100644 --- a/runtime/common/src/lib.rs +++ b/runtime/common/src/lib.rs @@ -43,7 +43,7 @@ use polymesh_common_utilities::constants::currency::*; use polymesh_primitives::{Balance, BlockNumber, IdentityId, Moment}; use smallvec::smallvec; -pub use impls::{Author, CurrencyToVoteHandler}; +pub use impls::Author; pub type NegativeImbalance = as Currency<::AccountId>>::NegativeImbalance; diff --git a/runtime/common/src/runtime.rs b/runtime/common/src/runtime.rs index 05be1a2..df606dc 100644 --- a/runtime/common/src/runtime.rs +++ b/runtime/common/src/runtime.rs @@ -21,7 +21,7 @@ macro_rules! misc_pallet_impls { pub const BABE_GENESIS_EPOCH_CONFIG: sp_consensus_babe::BabeEpochConfiguration = sp_consensus_babe::BabeEpochConfiguration { c: PRIMARY_PROBABILITY, - allowed_slots: sp_consensus_babe::AllowedSlots::PrimaryAndSecondaryPlainSlots, + allowed_slots: sp_consensus_babe::AllowedSlots::PrimaryAndSecondaryVRFSlots, }; /// Native version. @@ -145,7 +145,6 @@ macro_rules! misc_pallet_impls { use polymesh_runtime_common::fee_details::Call::*; Ok(match call { RuntimeCall::Identity(x) => Identity(x), - RuntimeCall::Bridge(x) => Bridge(x), RuntimeCall::MultiSig(x) => MultiSig(x), RuntimeCall::Relayer(x) => Relayer(x), _ => return Err(()), @@ -208,7 +207,7 @@ macro_rules! misc_pallet_impls { impl pallet_authorship::Config for Runtime { type FindAuthor = pallet_session::FindAccountFromAuthorIndex; - type EventHandler = (Staking, ImOnline); + type EventHandler = (ImOnline); } impl_opaque_keys! { @@ -220,13 +219,20 @@ macro_rules! misc_pallet_impls { } } + impl validator_set::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type AddRemoveOrigin = polymesh_primitives::EnsureRoot; + type MinAuthorities = MinAuthorities; + type WeightInfo = validator_set::weights::SubstrateWeight; + } + impl pallet_session::Config for Runtime { type RuntimeEvent = RuntimeEvent; type ValidatorId = polymesh_primitives::AccountId; - type ValidatorIdOf = pallet_staking::StashOf; + type ValidatorIdOf = validator_set::ValidatorOf; type ShouldEndSession = Babe; type NextSessionRotation = Babe; - type SessionManager = pallet_session::historical::NoteHistoricalRoot; + type SessionManager = ValidatorSet; //pallet_session::historical::NoteHistoricalRoot; type SessionHandler = ::KeyTypeIdProviders; type Keys = SessionKeys; @@ -234,48 +240,11 @@ macro_rules! misc_pallet_impls { } impl pallet_session::historical::Config for Runtime { - type FullIdentification = pallet_staking::Exposure< - polymesh_primitives::AccountId, - polymesh_primitives::Balance, - >; - type FullIdentificationOf = pallet_staking::ExposureOf; - } - - impl pallet_staking::Config for Runtime { - type Currency = Balances; - type UnixTime = Timestamp; - type CurrencyToVote = frame_support::traits::U128CurrencyToVote; - type RewardRemainder = (); - type RuntimeEvent = RuntimeEvent; - type Slash = Treasury; // send the slashed funds to the treasury. - type Reward = (); // rewards are minted from the void - type SessionsPerEra = SessionsPerEra; - type BondingDuration = BondingDuration; - type SlashDeferDuration = SlashDeferDuration; - type SlashCancelOrigin = polymesh_primitives::EnsureRoot; - type SessionInterface = Self; - type RewardCurve = RewardCurve; - type NextNewSession = Session; - type ElectionLookahead = ElectionLookahead; - type Call = RuntimeCall; - type MaxIterations = MaxIterations; - type MinSolutionScoreBump = MinSolutionScoreBump; - type MaxNominatorRewardedPerValidator = MaxNominatorRewardedPerValidator; - type OffendingValidatorsThreshold = OffendingValidatorsThreshold; - type UnsignedPriority = StakingUnsignedPriority; - type RequiredAddOrigin = Self::SlashCancelOrigin; - type RequiredRemoveOrigin = Self::SlashCancelOrigin; - type RequiredCommissionOrigin = Self::SlashCancelOrigin; - type RewardScheduler = Scheduler; - type MaxValidatorPerIdentity = MaxValidatorPerIdentity; - type MaxVariableInflationTotalIssuance = MaxVariableInflationTotalIssuance; - type FixedYearlyReward = FixedYearlyReward; - type PalletsOrigin = OriginCaller; - type MinimumBond = MinimumBond; - type OffchainSolutionWeightLimit = polymesh_runtime_common::OffchainSolutionWeightLimit; - type WeightInfo = polymesh_weights::pallet_staking::SubstrateWeight; - type MaxNominations = pallet_staking::MaxNominations; - type MaxUnlockingChunks = pallet_staking::MaxUnlockingChunks; + type FullIdentification = (); /*pallet_staking::Exposure< + polymesh_primitives::AccountId, + polymesh_primitives::Balance, + >;*/ + type FullIdentificationOf = (); //pallet_staking::ExposureOf; } impl pallet_authority_discovery::Config for Runtime { @@ -289,12 +258,6 @@ macro_rules! misc_pallet_impls { type WeightInfo = polymesh_weights::pallet_multisig::SubstrateWeight; } - impl pallet_bridge::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type Proposal = RuntimeCall; - type Scheduler = Scheduler; - } - impl pallet_portfolio::Config for Runtime { type RuntimeEvent = RuntimeEvent; type Asset = Asset; @@ -431,7 +394,7 @@ macro_rules! misc_pallet_impls { impl pallet_offences::Config for Runtime { type RuntimeEvent = RuntimeEvent; type IdentificationTuple = pallet_session::historical::IdentificationTuple; - type OnOffenceHandler = Staking; + type OnOffenceHandler = (); //Staking; } type GrandpaKey = (sp_core::crypto::KeyTypeId, pallet_grandpa::AuthorityId); @@ -872,12 +835,6 @@ macro_rules! runtime_apis { } } - impl pallet_staking_rpc_runtime_api::StakingApi for Runtime { - fn get_curve() -> Vec<(Perbill, Perbill)> { - RewardCurve::get().points.to_vec() - } - } - impl node_rpc_runtime_api::pips::PipsApi for Runtime { diff --git a/runtime/develop/Cargo.toml b/runtime/develop/Cargo.toml index a4179a7..be58b7a 100644 --- a/runtime/develop/Cargo.toml +++ b/runtime/develop/Cargo.toml @@ -17,7 +17,6 @@ polymesh-extensions = { workspace = true, default-features = false } pallet-asset = { workspace = true, default-features = false } pallet-balances = { workspace = true, default-features = false } pallet-base = { workspace = true, default-features = false } -pallet-bridge = { workspace = true, default-features = false } pallet-committee = { workspace = true, default-features = false } pallet-compliance-manager = { workspace = true, default-features = false } pallet-confidential-asset = { workspace = true, default-features = false } @@ -34,7 +33,6 @@ pallet-protocol-fee = { workspace = true, default-features = false } pallet-relayer = { workspace = true, default-features = false } pallet-sto = { workspace = true, default-features = false } pallet-settlement = { workspace = true, default-features = false } -pallet-staking = { workspace = true, default-features = false } pallet-statistics = { workspace = true, default-features = false } pallet-test-utils = { workspace = true, default-features = false } pallet-transaction-payment = { workspace = true, default-features = false } @@ -57,7 +55,6 @@ sp-version = { workspace = true, default-features = false } sp-api = { workspace = true, default-features = false } sp-inherents = { workspace = true, default-features = false } sp-offchain = { workspace = true, default-features = false } -sp-staking = { workspace = true, default-features = false } sp-consensus-babe = { workspace = true, default-features = false } sp-consensus-grandpa = { workspace = true, default-features = false } sp-session = { workspace = true, default-features = false } @@ -79,10 +76,12 @@ pallet-session = { workspace = true, default-features = false } pallet-timestamp = { workspace = true, default-features = false } pallet-babe = { workspace = true, default-features = false } pallet-authority-discovery = { workspace = true, default-features = false } -pallet-staking-reward-curve = { workspace = true, default-features = false } pallet-insecure-randomness-collective-flip = { workspace = true, default-features = false } pallet-scheduler = { workspace = true, default-features = false } +# PoA +validator-set = { workspace = true, default-features = false } + frame-system = { workspace = true, default-features = false } frame-support = { workspace = true, default-features = false } @@ -90,7 +89,6 @@ frame-support = { workspace = true, default-features = false } frame-system-rpc-runtime-api = { workspace = true, default-features = false } pallet-group-rpc-runtime-api = { workspace = true, default-features = false } pallet-protocol-fee-rpc-runtime-api = { workspace = true, default-features = false } -pallet-staking-rpc-runtime-api = { workspace = true, default-features = false } node-rpc-runtime-api = { workspace = true, default-features = false } # Used for runtime benchmarking @@ -145,7 +143,6 @@ std = [ "pallet-babe/std", "pallet-balances/std", "pallet-sto/std", - "pallet-bridge/std", "pallet-committee/std", "pallet-compliance-manager/std", "pallet-confidential-asset/std", @@ -172,9 +169,8 @@ std = [ "pallet-insecure-randomness-collective-flip/std", "pallet-scheduler/std", "pallet-session/std", + "validator-set/std", "pallet-settlement/std", - "pallet-staking-rpc-runtime-api/std", - "pallet-staking/std", "pallet-statistics/std", "pallet-sudo/std", "pallet-test-utils/std", @@ -198,7 +194,6 @@ std = [ "sp-offchain/std", "sp-runtime/std", "sp-session/std", - "sp-staking/std", "sp-std/std", "sp-transaction-pool/std", "sp-version/std", @@ -236,13 +231,11 @@ runtime-benchmarks = [ "pallet-relayer/runtime-benchmarks", "pallet-settlement/runtime-benchmarks", "pallet-sto/runtime-benchmarks", - "pallet-staking/runtime-benchmarks", "pallet-statistics/runtime-benchmarks", "pallet-timestamp/runtime-benchmarks", "pallet-treasury/runtime-benchmarks", "pallet-utility/runtime-benchmarks", "pallet-test-utils/runtime-benchmarks", - "pallet-staking/runtime-benchmarks", "polymesh-common-utilities/runtime-benchmarks", "polymesh-contracts/runtime-benchmarks", "polymesh-primitives/runtime-benchmarks", diff --git a/runtime/develop/src/benchmarks/mod.rs b/runtime/develop/src/benchmarks/mod.rs deleted file mode 100644 index b19bb6d..0000000 --- a/runtime/develop/src/benchmarks/mod.rs +++ /dev/null @@ -1 +0,0 @@ -pub mod pallet_session; diff --git a/runtime/develop/src/benchmarks/pallet_session.rs b/runtime/develop/src/benchmarks/pallet_session.rs deleted file mode 100644 index 82fcb6e..0000000 --- a/runtime/develop/src/benchmarks/pallet_session.rs +++ /dev/null @@ -1,113 +0,0 @@ -// This file is part of Substrate. - -// Copyright (C) 2020 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. - -//! Benchmarks for the Session Pallet. -// This is separated into its own crate due to cyclic dependency issues. - -// Modified by Polymesh Association - 4th January 2021 -// - It uses our Staking pallet. - -use codec::Decode; -use core::convert::TryInto; -use frame_benchmarking::benchmarks; -use frame_support::traits::{Currency, Get, OnInitialize}; -use frame_system::RawOrigin; -use pallet_session::{Call, Pallet as Session}; -use pallet_staking::benchmarking::create_validator_with_nominators_with_balance; -use polymesh_common_utilities::{benchs::AccountIdOf, TestUtilsFn}; -use sp_runtime::traits::TrailingZeroInput; -use sp_std::prelude::*; -use sp_std::vec; - -use polymesh_common_utilities::constants::currency::POLY; - -pub struct Pallet(Session); -pub trait Config: - pallet_session::Config + pallet_session::historical::Config + pallet_staking::Config -{ -} - -impl OnInitialize for Pallet { - fn on_initialize(n: T::BlockNumber) -> frame_support::weights::Weight { - Session::::on_initialize(n) - } -} - -struct ValidatorInfo { - controller: T::AccountId, - keys: T::Keys, - proof: Vec, -} - -impl>> ValidatorInfo { - pub fn build(nominators: u32) -> Result, &'static str> - where - <::Currency as Currency< - ::AccountId, - >>::Balance: From, - { - let balance: u32 = (4_000 * POLY).try_into().unwrap(); - let stash = create_validator_with_nominators_with_balance::( - nominators, - ::MaxNominations::get(), - balance, - false, - ) - .unwrap() - .0 - .account(); - let controller = pallet_staking::Pallet::::bonded(&stash).expect("not stash"); - - let keys = T::Keys::decode(&mut TrailingZeroInput::zeroes()).unwrap(); - let proof: Vec = vec![0, 1, 2, 3]; - - // Whitelist controller account from further DB operations. - let controller_key = frame_system::Account::::hashed_key_for(&controller); - frame_benchmarking::benchmarking::add_to_whitelist(controller_key.into()); - - Ok(Self { - controller, - keys, - proof, - }) - } -} - -benchmarks! { - where_clause { - where - T: TestUtilsFn>, - <::Currency as Currency<::AccountId>>::Balance: From, - } - - set_keys { - let n = ::MaxNominations::get() as u32; - let validator = ValidatorInfo::::build(n).unwrap(); - let proof = validator.proof.clone(); - let keys = validator.keys.clone(); - - }: _(RawOrigin::Signed(validator.controller), keys, proof) - - purge_keys { - let n = ::MaxNominations::get() as u32; - let validator = ValidatorInfo::::build(n).unwrap(); - let controller = RawOrigin::Signed(validator.controller.clone()); - - Session::::set_keys(controller.clone().into(), validator.keys, validator.proof).unwrap(); - - }: _(controller) -} diff --git a/runtime/develop/src/lib.rs b/runtime/develop/src/lib.rs index d99bc60..02e943a 100644 --- a/runtime/develop/src/lib.rs +++ b/runtime/develop/src/lib.rs @@ -9,19 +9,13 @@ extern crate frame_benchmarking; pub mod constants; pub mod runtime; -#[cfg(feature = "runtime-benchmarks")] -pub mod benchmarks; - -#[cfg(feature = "std")] -pub use pallet_staking::StakerStatus; - #[cfg(feature = "std")] pub use runtime::{native_version, WASM_BINARY}; pub use runtime::{ - api, Asset, Authorship, Balances, BalancesCall, Bridge, CheckedExtrinsic, MinimumPeriod, - ProtocolFee, Runtime, RuntimeApi, RuntimeCall, SessionKeys, System, SystemCall, - TransactionPayment, UncheckedExtrinsic, + api, Asset, Authorship, Balances, BalancesCall, CheckedExtrinsic, MinimumPeriod, ProtocolFee, + Runtime, RuntimeApi, RuntimeCall, SessionKeys, System, SystemCall, TransactionPayment, + UncheckedExtrinsic, }; pub use sp_runtime::{Perbill, Permill}; diff --git a/runtime/develop/src/runtime.rs b/runtime/develop/src/runtime.rs index f8f32fb..316ec78 100644 --- a/runtime/develop/src/runtime.rs +++ b/runtime/develop/src/runtime.rs @@ -26,9 +26,8 @@ use polymesh_runtime_common::{ use sp_runtime::transaction_validity::TransactionPriority; use sp_runtime::{ create_runtime_str, - curve::PiecewiseLinear, traits::{BlakeTwo256, Block as BlockT, Extrinsic, NumberFor, StaticLookup, Verify}, - Perbill, Permill, + Perbill, }; use sp_std::prelude::*; #[cfg(feature = "std")] @@ -38,7 +37,6 @@ use sp_version::RuntimeVersion; pub use frame_support::StorageValue; pub use frame_system::Call as SystemCall; pub use pallet_balances::Call as BalancesCall; -pub use pallet_staking::StakerStatus; pub use pallet_timestamp::Call as TimestampCall; #[cfg(any(feature = "std", test))] pub use sp_runtime::BuildStorage; @@ -96,8 +94,10 @@ parameter_types! { // I'm online: pub const ImOnlineUnsignedPriority: TransactionPriority = TransactionPriority::max_value(); - pub const MaxSetIdSessionEntries: u32 = BondingDuration::get() * SessionsPerEra::get(); - pub const MaxAuthorities: u32 = 100_000; + pub const MaxSetIdSessionEntries: u32 = 0; + pub const ReportLongevity: u64 = 1_000; + pub const MinAuthorities: u32 = 1; + pub const MaxAuthorities: u32 = 10_000; pub const MaxKeys: u32 = 10_000; pub const MaxPeerInHeartbeats: u32 = 10_000; pub const MaxPeerDataEncodingSize: u32 = 1_000; @@ -167,39 +167,6 @@ type ConfidentialAssetMaxAssetDataLength = ConstSize<8192>; /// 100% goes to the block author. pub type DealWithFees = Author; -// Staking: -pallet_staking_reward_curve::build! { - const REWARD_CURVE: PiecewiseLinear<'_> = curve!( - min_inflation: 0_025_000, - max_inflation: 0_140_000, - ideal_stake: 0_700_000, - falloff: 0_050_000, - max_piece_count: 40, - test_precision: 0_005_000, - ); -} -parameter_types! { - pub const SessionsPerEra: sp_staking::SessionIndex = 3; - pub const BondingDuration: pallet_staking::EraIndex = 7; - pub const SlashDeferDuration: pallet_staking::EraIndex = 4; - pub const RewardCurve: &'static PiecewiseLinear<'static> = &REWARD_CURVE; - pub const MaxNominatorRewardedPerValidator: u32 = 2048; - pub const OffendingValidatorsThreshold: Perbill = Perbill::from_percent(17); - pub const ElectionLookahead: BlockNumber = EPOCH_DURATION_IN_BLOCKS / 4; - pub const MaxIterations: u32 = 10; - pub const MaxValidatorPerIdentity: Permill = Permill::from_percent(33); - // 0.05%. The higher the value, the more strict solution acceptance becomes. - pub MinSolutionScoreBump: Perbill = Perbill::from_rational(5u32, 10_000); - pub const MaxVariableInflationTotalIssuance: Balance = 1_000_000_000 * ONE_POLY; - pub const FixedYearlyReward: Balance = 140_000_000 * ONE_POLY; - pub const MinimumBond: Balance = ONE_POLY; - /// We prioritize im-online heartbeats over election solution submission. - pub const StakingUnsignedPriority: TransactionPriority = TransactionPriority::max_value() / 2; - - pub const ReportLongevity: u64 = - BondingDuration::get() as u64 * SessionsPerEra::get() as u64 * EpochDuration::get(); -} - polymesh_runtime_common::misc_pallet_impls!(); pub type CddHandler = polymesh_runtime_common::fee_details::DevCddHandler; @@ -385,10 +352,8 @@ mod benches { [pallet_preimage, Preimage] [pallet_babe, Babe] [pallet_indices, Indices] - [pallet_session, SessionBench::] [pallet_grandpa, Grandpa] [pallet_scheduler, Scheduler] - [pallet_staking, Staking] [pallet_test_utils, TestUtils] [polymesh_contracts, PolymeshContracts] [pallet_nft, Nft] @@ -437,11 +402,10 @@ construct_runtime!( UpgradeCommitteeMembership: pallet_group::::{Pallet, Call, Storage, Event, Config}, MultiSig: pallet_multisig::{Pallet, Call, Config, Storage, Event}, - // Bridge: Genesis config deps: Multisig, Identity, Committees - Bridge: pallet_bridge::{Pallet, Call, Storage, Config, Event}, - // Staking: Genesis config deps: Bridge, Balances, Indices, Identity, Babe, Timestamp, Committees - Staking: pallet_staking::{Pallet, Call, Config, Storage, Event, ValidateUnsigned}, + // PoA + ValidatorSet: validator_set, + Offences: pallet_offences::{Pallet, Storage, Event}, // Session: Genesis config deps: System. @@ -501,13 +465,11 @@ polymesh_runtime_common::runtime_apis! { ) -> Result, sp_runtime::RuntimeString> { use frame_benchmarking::{baseline, Benchmarking, BenchmarkBatch, TrackedStorageKey}; - use crate::benchmarks::pallet_session::Pallet as SessionBench; use frame_system_benchmarking::Pallet as SystemBench; use baseline::Pallet as BaselineBench; impl frame_system_benchmarking::Config for Runtime {} impl baseline::Config for Runtime {} - impl crate::benchmarks::pallet_session::Config for Runtime {} let whitelist: Vec = vec![ // Block Number @@ -537,7 +499,6 @@ polymesh_runtime_common::runtime_apis! { use frame_benchmarking::{baseline, Benchmarking, BenchmarkList}; use frame_support::traits::StorageInfoTrait; - use crate::benchmarks::pallet_session::Pallet as SessionBench; use frame_system_benchmarking::Pallet as SystemBench; use baseline::Pallet as BaselineBench; diff --git a/runtime/production/Cargo.toml b/runtime/production/Cargo.toml index 8c8a322..33a6b10 100644 --- a/runtime/production/Cargo.toml +++ b/runtime/production/Cargo.toml @@ -17,7 +17,6 @@ polymesh-weights = { workspace = true, default-features = false } pallet-asset = { workspace = true, default-features = false } pallet-balances = { workspace = true, default-features = false } pallet-base = { workspace = true, default-features = false } -pallet-bridge = { workspace = true, default-features = false } pallet-committee = { workspace = true, default-features = false } pallet-compliance-manager = { workspace = true, default-features = false } pallet-confidential-asset = { workspace = true, default-features = false } @@ -34,7 +33,6 @@ pallet-portfolio = { workspace = true, default-features = false } pallet-protocol-fee = { workspace = true, default-features = false } pallet-relayer = { workspace = true, default-features = false } pallet-settlement = { workspace = true, default-features = false } -pallet-staking = { workspace = true, default-features = false } pallet-statistics = { workspace = true, default-features = false } pallet-sto = { workspace = true, default-features = false } pallet-sudo = { workspace = true, default-features = false } @@ -45,7 +43,6 @@ polymesh-contracts = { workspace = true, default-features = false } # RPC node-rpc-runtime-api = { workspace = true, default-features = false } -pallet-staking-rpc-runtime-api = { workspace = true, default-features = false } pallet-protocol-fee-rpc-runtime-api = { workspace = true, default-features = false } # Others @@ -70,7 +67,6 @@ pallet-preimage = { workspace = true, default-features = false } pallet-insecure-randomness-collective-flip = { workspace = true, default-features = false } pallet-scheduler = { workspace = true, default-features = false } pallet-session = { workspace = true, default-features = false } -pallet-staking-reward-curve = { workspace = true, default-features = false } pallet-timestamp = { workspace = true, default-features = false } scale-info = { workspace = true, default-features = false, features = ["derive"] } sp-api = { workspace = true, default-features = false } @@ -85,11 +81,13 @@ sp-io = { workspace = true, default-features = false } sp-offchain = { workspace = true, default-features = false } sp-runtime = { workspace = true, default-features = false } sp-session = { workspace = true, default-features = false } -sp-staking = { workspace = true, default-features = false } sp-std = { workspace = true, default-features = false } sp-transaction-pool = { workspace = true, default-features = false } sp-version = { workspace = true, default-features = false } +# PoA +validator-set = { workspace = true, default-features = false } + [build-dependencies] polymesh-build-tool = { workspace = true, default-features = false } @@ -129,7 +127,6 @@ std = [ "pallet-base/std", "pallet-babe/std", "pallet-balances/std", - "pallet-bridge/std", "pallet-committee/std", "pallet-compliance-manager/std", "pallet-confidential-asset/std", @@ -154,9 +151,8 @@ std = [ "pallet-insecure-randomness-collective-flip/std", "pallet-scheduler/std", "pallet-session/std", + "validator-set/std", "pallet-settlement/std", - "pallet-staking-rpc-runtime-api/std", - "pallet-staking/std", "pallet-statistics/std", "pallet-sto/std", "pallet-sudo/std", @@ -181,7 +177,6 @@ std = [ "sp-offchain/std", "sp-runtime/std", "sp-session/std", - "sp-staking/std", "sp-std/std", "sp-transaction-pool/std", "sp-version/std", diff --git a/runtime/production/src/lib.rs b/runtime/production/src/lib.rs index 10e1162..152a2e2 100644 --- a/runtime/production/src/lib.rs +++ b/runtime/production/src/lib.rs @@ -4,15 +4,13 @@ pub mod constants; pub mod runtime; -#[cfg(feature = "std")] -pub use pallet_staking::StakerStatus; #[cfg(feature = "std")] pub use runtime::{native_version, WASM_BINARY}; pub use runtime::{ - api, Asset, Authorship, Balances, BalancesCall, Bridge, CheckedExtrinsic, MinimumPeriod, - ProtocolFee, Runtime, RuntimeApi, RuntimeCall, SessionKeys, SignedExtra, System, SystemCall, + api, Asset, Authorship, Balances, BalancesCall, CheckedExtrinsic, MinimumPeriod, ProtocolFee, + Runtime, RuntimeApi, RuntimeCall, SessionKeys, SignedExtra, System, SystemCall, TransactionPayment, UncheckedExtrinsic, }; diff --git a/runtime/production/src/runtime.rs b/runtime/production/src/runtime.rs index 3718e0e..98ae401 100644 --- a/runtime/production/src/runtime.rs +++ b/runtime/production/src/runtime.rs @@ -23,9 +23,8 @@ use polymesh_runtime_common::{ use sp_runtime::transaction_validity::TransactionPriority; use sp_runtime::{ create_runtime_str, - curve::PiecewiseLinear, traits::{BlakeTwo256, Block as BlockT, Extrinsic, NumberFor, StaticLookup, Verify}, - Perbill, Permill, + Perbill, }; use sp_std::prelude::*; #[cfg(feature = "std")] @@ -35,7 +34,6 @@ use sp_version::RuntimeVersion; pub use frame_support::StorageValue; pub use frame_system::Call as SystemCall; pub use pallet_balances::Call as BalancesCall; -pub use pallet_staking::StakerStatus; pub use pallet_timestamp::Call as TimestampCall; #[cfg(any(feature = "std", test))] pub use sp_runtime::BuildStorage; @@ -93,8 +91,10 @@ parameter_types! { // I'm online: pub const ImOnlineUnsignedPriority: TransactionPriority = TransactionPriority::max_value(); - pub const MaxSetIdSessionEntries: u32 = BondingDuration::get() * SessionsPerEra::get(); - pub const MaxAuthorities: u32 = 100_000; + pub const MaxSetIdSessionEntries: u32 = 0; + pub const ReportLongevity: u64 = 1_000; + pub const MinAuthorities: u32 = 2; + pub const MaxAuthorities: u32 = 10_000; pub const MaxKeys: u32 = 10_000; pub const MaxPeerInHeartbeats: u32 = 10_000; pub const MaxPeerDataEncodingSize: u32 = 1_000; @@ -158,39 +158,6 @@ type ConfidentialAssetMaxAssetDataLength = ConstSize<8192>; /// 100% goes to the block author. pub type DealWithFees = Author; -// Staking: -pallet_staking_reward_curve::build! { - const REWARD_CURVE: PiecewiseLinear<'_> = curve!( - min_inflation: 0_025_000, - max_inflation: 0_140_000, - ideal_stake: 0_700_000, - falloff: 0_050_000, - max_piece_count: 40, - test_precision: 0_005_000, - ); -} -parameter_types! { - pub const SessionsPerEra: sp_staking::SessionIndex = 6; - pub const BondingDuration: pallet_staking::EraIndex = 28; - pub const SlashDeferDuration: pallet_staking::EraIndex = 14; // 1/2 the bonding duration. - pub const RewardCurve: &'static PiecewiseLinear<'static> = &REWARD_CURVE; - pub const MaxNominatorRewardedPerValidator: u32 = 2048; - pub const OffendingValidatorsThreshold: Perbill = Perbill::from_percent(17); - pub const ElectionLookahead: BlockNumber = EPOCH_DURATION_IN_BLOCKS / 4; - pub const MaxIterations: u32 = 10; - pub const MaxValidatorPerIdentity: Permill = Permill::from_percent(33); - // 0.05%. The higher the value, the more strict solution acceptance becomes. - pub MinSolutionScoreBump: Perbill = Perbill::from_rational(5u32, 10_000); - pub const MaxVariableInflationTotalIssuance: Balance = 1_000_000_000 * ONE_POLY; - pub const FixedYearlyReward: Balance = 140_000_000 * ONE_POLY; - pub const MinimumBond: Balance = ONE_POLY; - /// We prioritize im-online heartbeats over election solution submission. - pub const StakingUnsignedPriority: TransactionPriority = TransactionPriority::max_value() / 2; - - pub const ReportLongevity: u64 = - BondingDuration::get() as u64 * SessionsPerEra::get() as u64 * EpochDuration::get(); -} - polymesh_runtime_common::misc_pallet_impls!(); type CddHandler = polymesh_runtime_common::fee_details::CddHandler< @@ -356,11 +323,10 @@ construct_runtime!( UpgradeCommitteeMembership: pallet_group::::{Pallet, Call, Storage, Event, Config}, MultiSig: pallet_multisig::{Pallet, Call, Config, Storage, Event}, - // Bridge: Genesis config deps: Multisig, Identity, Committees - Bridge: pallet_bridge::{Pallet, Call, Storage, Config, Event}, - // Staking: Genesis config deps: Bridge, Balances, Indices, Identity, Babe, Timestamp, Committees - Staking: pallet_staking::{Pallet, Call, Config, Storage, Event, ValidateUnsigned}, + // PoA + ValidatorSet: validator_set, + Offences: pallet_offences::{Pallet, Storage, Event}, // Session: Genesis config deps: System. diff --git a/runtime/tests/Cargo.toml b/runtime/tests/Cargo.toml index 4081cbe..6357d72 100644 --- a/runtime/tests/Cargo.toml +++ b/runtime/tests/Cargo.toml @@ -16,7 +16,6 @@ polymesh-extensions = { workspace = true, default-features = false } pallet-asset = { workspace = true, default-features = false } pallet-balances = { workspace = true, default-features = false } pallet-base = { workspace = true, default-features = false } -pallet-bridge = { workspace = true, default-features = false } pallet-committee = { workspace = true, default-features = false } pallet-compliance-manager = { workspace = true, default-features = false } pallet-corporate-actions = { workspace = true, default-features = false } @@ -32,7 +31,6 @@ pallet-protocol-fee = { workspace = true, default-features = false } pallet-relayer = { workspace = true, default-features = false } pallet-sto = { workspace = true, default-features = false } pallet-settlement = { workspace = true, default-features = false } -pallet-staking = { workspace = true, default-features = false } pallet-statistics = { workspace = true, default-features = false } pallet-test-utils = { workspace = true, default-features = false } pallet-transaction-payment = { workspace = true, default-features = false } @@ -58,7 +56,6 @@ sp-keyring = { workspace = true, default-features = false } sp-api = { workspace = true, default-features = false } sp-inherents = { workspace = true, default-features = false } sp-offchain = { workspace = true, default-features = false } -sp-staking = { workspace = true, default-features = false } sp-consensus-babe = { workspace = true, default-features = false } sp-consensus-grandpa = { workspace = true, default-features = false } sp-session = { workspace = true, default-features = false } @@ -80,10 +77,12 @@ pallet-session = { workspace = true, default-features = false } pallet-timestamp = { workspace = true, default-features = false } pallet-babe = { workspace = true, default-features = false } pallet-authority-discovery = { workspace = true, default-features = false } -pallet-staking-reward-curve = { workspace = true, default-features = false } pallet-insecure-randomness-collective-flip = { workspace = true, default-features = false } pallet-scheduler = { workspace = true, default-features = false } +# PoA +validator-set = { workspace = true, default-features = false } + frame-system = { workspace = true, default-features = false } frame-support = { workspace = true, default-features = false } @@ -91,7 +90,6 @@ frame-support = { workspace = true, default-features = false } frame-system-rpc-runtime-api = { workspace = true, default-features = false } pallet-group-rpc-runtime-api = { workspace = true, default-features = false } pallet-protocol-fee-rpc-runtime-api = { workspace = true, default-features = false } -pallet-staking-rpc-runtime-api = { workspace = true, default-features = false } node-rpc-runtime-api = { workspace = true, default-features = false } # Crypto @@ -116,7 +114,6 @@ std = [ "pallet-babe/std", "pallet-balances/std", "pallet-sto/std", - "pallet-bridge/std", "pallet-committee/std", "pallet-compliance-manager/std", "pallet-confidential-asset/std", @@ -143,9 +140,8 @@ std = [ "pallet-insecure-randomness-collective-flip/std", "pallet-scheduler/std", "pallet-session/std", + "validator-set/std", "pallet-settlement/std", - "pallet-staking-rpc-runtime-api/std", - "pallet-staking/std", "pallet-statistics/std", "pallet-sudo/std", "pallet-test-utils/std", @@ -169,7 +165,6 @@ std = [ "sp-offchain/std", "sp-runtime/std", "sp-session/std", - "sp-staking/std", "sp-std/std", "sp-transaction-pool/std", "sp-version/std", @@ -204,13 +199,11 @@ runtime-benchmarks = [ "pallet-relayer/runtime-benchmarks", "pallet-settlement/runtime-benchmarks", "pallet-sto/runtime-benchmarks", - "pallet-staking/runtime-benchmarks", "pallet-statistics/runtime-benchmarks", "pallet-timestamp/runtime-benchmarks", "pallet-treasury/runtime-benchmarks", "pallet-utility/runtime-benchmarks", "pallet-test-utils/runtime-benchmarks", - "pallet-staking/runtime-benchmarks", "polymesh-common-utilities/runtime-benchmarks", "polymesh-contracts/runtime-benchmarks", "polymesh-primitives/runtime-benchmarks", diff --git a/runtime/tests/src/test_runtime/ext_builder.rs b/runtime/tests/src/test_runtime/ext_builder.rs index 90be0e0..d31a57d 100644 --- a/runtime/tests/src/test_runtime/ext_builder.rs +++ b/runtime/tests/src/test_runtime/ext_builder.rs @@ -7,7 +7,6 @@ use sp_std::{cell::RefCell, convert::From, iter}; use pallet_asset::{self as asset, TickerRegistrationConfig}; use pallet_balances as balances; -use pallet_bridge::BridgeTx; use pallet_committee as committee; use pallet_group as group; use pallet_identity as identity; @@ -16,7 +15,7 @@ use polymesh_common_utilities::{ constants::currency::POLY, protocol_fee::ProtocolOp, SystematicIssuers, GC_DID, }; use polymesh_primitives::{ - identity_id::GenesisIdentityRecord, AccountId, IdentityId, PosRatio, SecondaryKey, Signatory, + identity_id::GenesisIdentityRecord, AccountId, IdentityId, PosRatio, SecondaryKey, }; use crate::test_runtime::TestRuntime; @@ -31,9 +30,6 @@ pub struct IdentityRecord { /// A prime number fee to test the split between multiple recipients. pub const PROTOCOL_OP_BASE_FEE: u128 = 41; -const DEFAULT_BRIGDE_LIMIT: u128 = 1_000_000_000_000_000; -const DEFAULT_BRIDGE_TIMELOCK: u32 = 3; - struct BuilderVoteThreshold { pub numerator: u32, pub denominator: u32, @@ -76,22 +72,6 @@ impl Default for MockProtocolBaseFees { } } -#[derive(Default)] -struct BridgeConfig { - /// Complete TXs - pub complete_txs: Vec>, - /// Bridge admin key. See `Bridge` documentation for details. - pub admin: Option, - /// signers of the controller multisig account. - pub signers: Vec>, - /// # of signers required for controller multisig account. - pub signatures_required: u64, - /// Bridge limit. - pub limit: Option, - /// Bridge timelock. - pub timelock: Option, -} - #[derive(Default)] pub struct ExtBuilder { /// Minimum weight for the extrinsic (see `weight_to_fee` below). @@ -118,8 +98,6 @@ pub struct ExtBuilder { protocol_base_fees: MockProtocolBaseFees, protocol_coefficient: PosRatio, adjust: Option>, - /// Bridge configuration - bridge: BridgeConfig, } thread_local! { @@ -194,26 +172,6 @@ impl ExtBuilder { .collect() } - fn build_bridge(&self, storage: &mut Storage) { - if let Some(creator) = &self.bridge.admin { - pallet_bridge::GenesisConfig:: { - creator: Some(creator.clone()), - admin: Some(creator.clone()), - signers: self.bridge.signers.clone(), - signatures_required: self.bridge.signatures_required, - bridge_limit: (self.bridge.limit.unwrap_or(DEFAULT_BRIGDE_LIMIT), 1), - timelock: self - .bridge - .timelock - .unwrap_or(DEFAULT_BRIDGE_TIMELOCK) - .into(), - ..Default::default() - } - .assimilate_storage(storage) - .unwrap(); - } - } - fn build_identity_genesis( &self, storage: &mut Storage, @@ -329,15 +287,6 @@ impl ExtBuilder { .unwrap(); } - fn build_bridge_genesis(&self, storage: &mut Storage) { - pallet_bridge::GenesisConfig:: { - complete_txs: self.bridge.complete_txs.clone(), - ..Default::default() - } - .assimilate_storage(storage) - .unwrap() - } - /// Create externalities. pub fn build(self) -> TestExternalities { self.set_associated_consts(); @@ -413,10 +362,6 @@ impl ExtBuilder { self.build_committee_genesis(&mut storage, gc_full_identities.as_slice()); self.build_protocol_fee_genesis(&mut storage); self.build_pips_genesis(&mut storage); - //self.build_contracts_genesis(&mut storage); - self.build_bridge_genesis(&mut storage); - - self.build_bridge(&mut storage); if let Some(adjust) = self.adjust { adjust(&mut storage); diff --git a/runtime/tests/src/test_runtime/mod.rs b/runtime/tests/src/test_runtime/mod.rs index cdfc88f..2644a98 100644 --- a/runtime/tests/src/test_runtime/mod.rs +++ b/runtime/tests/src/test_runtime/mod.rs @@ -14,14 +14,13 @@ use sp_core::crypto::Pair as PairTrait; use sp_core::sr25519::Pair; use sp_keyring::AccountKeyring; use sp_runtime::create_runtime_str; -use sp_runtime::curve::PiecewiseLinear; use sp_runtime::traits::{ BlakeTwo256, Block as BlockT, Extrinsic, NumberFor, StaticLookup, Verify, }; use sp_runtime::transaction_validity::{ InvalidTransaction, TransactionPriority, TransactionValidity, ValidTransaction, }; -use sp_runtime::{Perbill, Permill}; +use sp_runtime::Perbill; use sp_version::RuntimeVersion; use std::cell::RefCell; use std::convert::From; @@ -40,7 +39,7 @@ use pallet_protocol_fee as protocol_fee; use pallet_session::historical as pallet_session_historical; use pallet_transaction_payment::RuntimeDispatchInfo; use pallet_utility; -use polymesh_common_utilities::constants::currency::{DOLLARS, POLY}; +use polymesh_common_utilities::constants::currency::DOLLARS; use polymesh_common_utilities::protocol_fee::ProtocolOp; use polymesh_common_utilities::traits::group::GroupTrait; use polymesh_common_utilities::traits::transaction_payment::{CddAndFeeDetails, ChargeTxFee}; @@ -73,47 +72,22 @@ const VERSION: RuntimeVersion = RuntimeVersion { state_version: 1, }; -pallet_staking_reward_curve::build! { - const REWARD_CURVE: PiecewiseLinear<'_> = curve!( - min_inflation: 0_025_000, - max_inflation: 0_140_000, - ideal_stake: 0_700_000, - falloff: 0_050_000, - max_piece_count: 40, - test_precision: 0_005_000, - ); -} - parameter_types! { pub const EpochDuration: u64 = EPOCH_DURATION_IN_BLOCKS as u64; pub const Version: RuntimeVersion = VERSION; pub const ExpectedBlockTime: Moment = MILLISECS_PER_BLOCK; - pub const SessionsPerEra: sp_staking::SessionIndex = 3; - pub const BondingDuration: pallet_staking::EraIndex = 7; - pub const SlashDeferDuration: pallet_staking::EraIndex = 4; - pub const ElectionLookahead: BlockNumber = EPOCH_DURATION_IN_BLOCKS / 4; - pub const MaxIterations: u32 = 10; - pub MinSolutionScoreBump: Perbill = Perbill::from_rational(5u32, 10_000); - pub const MaxNominatorRewardedPerValidator: u32 = 2048; - pub const OffendingValidatorsThreshold: Perbill = Perbill::from_percent(17); pub const IndexDeposit: Balance = DOLLARS; - pub const RewardCurve: &'static PiecewiseLinear<'static> = &REWARD_CURVE; - pub const StakingUnsignedPriority: TransactionPriority = TransactionPriority::max_value() / 2; - pub const MaxValidatorPerIdentity: Permill = Permill::from_percent(33); - pub const MaxVariableInflationTotalIssuance: Balance = 1_000_000_000 * POLY; - pub const FixedYearlyReward: Balance = 140_000_000 * POLY; - pub const MinimumBond: Balance = 1 * POLY; pub const MaxNumberOfFungibleAssets: u32 = 100; pub const MaxNumberOfNFTsPerLeg: u32 = 10; pub const MaxNumberOfNFTs: u32 = 100; pub const ImOnlineUnsignedPriority: TransactionPriority = TransactionPriority::max_value(); - pub const MaxSetIdSessionEntries: u32 = BondingDuration::get() * SessionsPerEra::get(); - pub const MaxAuthorities: u32 = 100_000; + pub const MaxSetIdSessionEntries: u32 = 0; + pub const ReportLongevity: u64 = 1_000; + pub const MinAuthorities: u32 = 2; + pub const MaxAuthorities: u32 = 10_000; pub const MaxKeys: u32 = 10_000; pub const MaxPeerInHeartbeats: u32 = 10_000; pub const MaxPeerDataEncodingSize: u32 = 1_000; - pub const ReportLongevity: u64 = - BondingDuration::get() as u64 * SessionsPerEra::get() as u64 * EpochDuration::get(); pub const MaxNumberOfCollectionKeys: u8 = u8::MAX; pub const MaxNumberOfFungibleMoves: u32 = 10; pub const MaxNumberOfNFTsMoves: u32 = 100; @@ -168,8 +142,10 @@ frame_support::construct_runtime!( UpgradeCommittee: pallet_committee::::{Pallet, Call, Storage, Origin, Event, Config} = 13, UpgradeCommitteeMembership: pallet_group::::{Pallet, Call, Storage, Event, Config} = 14, MultiSig: pallet_multisig::{Pallet, Call, Config, Storage, Event} = 15, - Bridge: pallet_bridge::{Pallet, Call, Storage, Config, Event} = 16, - Staking: pallet_staking::{Pallet, Call, Config, Storage, Event, ValidateUnsigned} = 17, + + // PoA + ValidatorSet: validator_set = 17, + Offences: pallet_offences::{Pallet, Storage, Event} = 18, Session: pallet_session::{Pallet, Call, Storage, Event, Config} = 19, AuthorityDiscovery: pallet_authority_discovery::{Pallet, Config} = 20, diff --git a/src/chain_spec.rs b/src/chain_spec.rs index 0662a56..3f3859b 100644 --- a/src/chain_spec.rs +++ b/src/chain_spec.rs @@ -1,9 +1,6 @@ use codec::{Decode, Encode}; -use grandpa::AuthorityId as GrandpaId; use pallet_asset::TickerRegistrationConfig; -use pallet_bridge::BridgeTx; use pallet_im_online::sr25519::AuthorityId as ImOnlineId; -use pallet_staking::StakerStatus; use polymesh_common_utilities::{ constants::{currency::ONE_POLY, TREASURY_PALLET_ID}, protocol_fee::ProtocolOp, @@ -12,19 +9,17 @@ use polymesh_common_utilities::{ use polymesh_primitives::{ asset_metadata::{AssetMetadataName, AssetMetadataSpec}, identity_id::GenesisIdentityRecord, - AccountId, IdentityId, Moment, PosRatio, SecondaryKey, Signatory, Signature, Ticker, + AccountId, IdentityId, Moment, PosRatio, SecondaryKey, Signature, Ticker, }; use sc_chain_spec::{ChainSpecExtension, ChainType}; +use sc_consensus_grandpa::AuthorityId as GrandpaId; use sc_service::Properties; use sc_telemetry::TelemetryEndpoints; use serde_json::json; use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId; use sp_consensus_babe::AuthorityId as BabeId; -use sp_core::{sr25519, Pair, Public, H256}; -use sp_runtime::{ - traits::{AccountIdConversion, IdentifyAccount, Verify}, - PerThing, -}; +use sp_core::{sr25519, Pair, Public}; +use sp_runtime::traits::{AccountIdConversion, IdentifyAccount, Verify}; #[cfg(feature = "std")] use sp_runtime::{Deserialize, Serialize}; use std::convert::TryInto; @@ -32,19 +27,12 @@ use std::convert::TryInto; // The URL for the telemetry server. const STAGING_TELEMETRY_URL: &str = "wss://telemetry.polymesh.network/submit/"; -// Genesis POLYX distribution via bridge -const TREASURY_LOCK_HASH: &str = - "0x1000000000000000000000000000000000000000000000000000000000000001"; -const KEY_LOCK_HASH: &str = "0x1000000000000000000000000000000000000000000000000000000000000003"; - const BOOTSTRAP_KEYS: u128 = 6_000 * ONE_POLY; const BOOTSTRAP_TREASURY: u128 = 17_500_000 * ONE_POLY; const DEV_KEYS: u128 = 30_000_000 * ONE_POLY; const DEV_TREASURY: u128 = 50_000_000 * ONE_POLY; -const INITIAL_BOND: u128 = 500 * ONE_POLY; - /// Node `ChainSpec` extensions. /// /// Additional parameters for some Substrate core modules, @@ -112,7 +100,7 @@ pub fn get_authority_keys_from_seed(s: &str, uniq: bool) -> InitialAuth { ) } -fn polymath_props(ss58: u8) -> Properties { +fn polymesh_props(ss58: u8) -> Properties { json!({ "ss58Format": ss58, "tokenDecimals": 6, "tokenSymbol": "POLYX" }) .as_object() .unwrap() @@ -202,14 +190,7 @@ type InitialAuth = ( // alias type to make clippy happy. type GenesisProcessedData = ( Vec>, - Vec<( - IdentityId, - AccountId, - AccountId, - u128, - StakerStatus, - )>, - Vec>, + Vec<(AccountId, u128)>, ); fn adjust_last(bytes: &mut [u8], n: u8) -> &str { @@ -217,229 +198,122 @@ fn adjust_last(bytes: &mut [u8], n: u8) -> &str { core::str::from_utf8(bytes).unwrap() } -#[derive(Clone)] -struct BridgeLockId { - nonce: u32, - amount: u128, - tx_hash: H256, -} - -impl BridgeLockId { - fn new(nonce: u32, amount: u128, hash: &'static str) -> Self { - let offset = if hash.starts_with("0x") { 2 } else { 0 }; - let stripped_hash = &hash[offset..]; - let hash_vec: Vec = rustc_hex::FromHex::from_hex(stripped_hash) - .expect("Failed to decode transaction hash (Invalid hex Value)"); - let hash_array: [u8; 32] = hash_vec - .try_into() - .expect("Failed to decode transaction hash (Invalid hash length)"); - Self { - nonce, - amount, - tx_hash: hash_array.into(), - } - } - - fn generate_bridge_locks( - starting_nonce: u32, - count: u32, - amount: u128, - hash: &'static str, - ) -> Vec { - (0..count) - .map(|x| Self::new(starting_nonce + x, amount, hash)) - .collect() - } -} - fn genesis_processed_data( - initial_authorities: &Vec, //Alice, Bob, Charlie - root_key: AccountId, //polymath_5 - treasury_bridge_lock: BridgeLockId, - key_bridge_locks: Vec, + initial_authorities: &Vec, + root_key: AccountId, //polymesh_5 + treasury_amount: u128, + key_amount: u128, ) -> GenesisProcessedData { // Identities and their roles - // 1 = [Polymath] GenesisCouncil (1 of 3) + UpgradeCommittee (1 of 1) + TechnicalCommittee (1 of 1) + GCReleaseCoordinator + // 1 = [Polymesh] GenesisCouncil (1 of 3) + UpgradeCommittee (1 of 1) + TechnicalCommittee (1 of 1) + GCReleaseCoordinator // 2 = GenesisCouncil (2 of 3) // 3 = GenesisCouncil (3 of 3) // 4 = Operator - // 5 = Bridge + Sudo + // 5 = Sudo // Identity_01 - // Primary Key: polymath_1 + // Primary Key: polymesh_1 // Identity_02 - // Primary Key: polymath_2 + // Primary Key: polymesh_2 // Identity_03 - // Primary Key: polymath_3 + // Primary Key: polymesh_3 // Identity_04 - // Primary Key: polymath_4 + // Primary Key: polymesh_4 // Secondary Keys: Alice, Alice//stash, Bob, Bob//stash, Charlie, Charlie//stash // Identity_05 - // Primary Key: polymath_5 - // Secondary Keys: bridge multisig (controller) + // Primary Key: polymesh_5 - let mut identities = Vec::with_capacity(5); - let mut keys = Vec::with_capacity(5 + 2 * initial_authorities.len()); //11 + let mut identities = Vec::new(); + let mut balances = Vec::new(); + let mut keys = Vec::new(); let mut create_id = |nonce: u8, primary_key: AccountId| { keys.push(primary_key.clone()); + balances.push((primary_key.clone(), key_amount)); identities.push(GenesisIdentityRecord::new(nonce, primary_key)); }; // Creating Identities 1-4 (GC + Operators) for i in 1..5u8 { - create_id(i, seeded_acc_id(adjust_last(&mut { *b"polymath_0" }, i))); + create_id(i, seeded_acc_id(adjust_last(&mut { *b"polymesh_0" }, i))); } - // Creating identity for sudo + bridge admin + // Creating identity for sudo create_id(5u8, root_key); - // 3 operators, all self staking at genesis - let mut stakers = Vec::with_capacity(initial_authorities.len()); - for (stash, controller, ..) in initial_authorities { - stakers.push(( - IdentityId::from(4), // All operators have the same Identity - stash.clone(), - controller.clone(), - INITIAL_BOND, - pallet_staking::StakerStatus::Validator, - )); + for (account, stash, _, _, _, _) in initial_authorities { // Make stash and controller 4th Identity's secondary keys. let mut push_key = |key: &AccountId| { + balances.push((key.clone(), key_amount)); identities[3] .secondary_keys - .push(SecondaryKey::from_account_id_with_full_perms(key.clone())); - keys.push(key.clone()); + .push(SecondaryKey::from_account_id_with_full_perms(key.clone())) }; + push_key(account); push_key(stash); - push_key(controller); } - // Give CDD issuer to operator and bridge admin / sudo since it won't receive CDD from the group automatically + // Give CDD issuer to operator and sudo since it won't receive CDD from the group automatically identities[3] .issuers .push(SystematicIssuers::CDDProvider.as_id()); - // Give CDD issuer to operator and bridge admin / sudo since it won't receive CDD from the group automatically + // Give CDD issuer to operator and sudo since it won't receive CDD from the group automatically identities[4] .issuers .push(SystematicIssuers::CDDProvider.as_id()); - // Accumulate bridge transactions - let mut complete_txs: Vec<_> = key_bridge_locks - .iter() - .cloned() - .zip(keys.iter().cloned()) - .map( - |( - BridgeLockId { - nonce, - amount, - tx_hash, - }, - recipient, - )| BridgeTx { - nonce, - recipient, - amount, - tx_hash, - }, - ) - .collect(); + // Treasury + balances.push(( + TREASURY_PALLET_ID.into_account_truncating(), + treasury_amount, + )); - complete_txs.push(BridgeTx { - nonce: treasury_bridge_lock.nonce, - recipient: TREASURY_PALLET_ID.into_account_truncating(), - amount: treasury_bridge_lock.amount, - tx_hash: treasury_bridge_lock.tx_hash, - }); - - (identities, stakers, complete_txs) + (identities, balances) } #[cfg(not(feature = "ci-runtime"))] fn dev_genesis_processed_data( initial_authorities: &Vec, - treasury_bridge_lock: BridgeLockId, - key_bridge_locks: Vec, other_funded_accounts: Vec, + treasury_amount: u128, + key_amount: u128, ) -> GenesisProcessedData { let mut identity = GenesisIdentityRecord::new(1u8, initial_authorities[0].0.clone()); + let mut balances = Vec::new(); - let mut stakers = Vec::with_capacity(initial_authorities.len()); identity .secondary_keys .reserve(initial_authorities.len() * 2 + other_funded_accounts.len()); - let mut add_sk = |acc| { + let mut add_sk = |acc: AccountId| { + balances.push((acc.clone(), key_amount)); identity .secondary_keys .push(SecondaryKey::from_account_id_with_full_perms(acc)) }; - for (stash, controller, ..) in initial_authorities { - stakers.push(( - IdentityId::from(1), - stash.clone(), - controller.clone(), - INITIAL_BOND, - pallet_staking::StakerStatus::Validator, - )); + for (account, stash, _, _, _, _) in initial_authorities { + add_sk(account.clone()); add_sk(stash.clone()); - add_sk(controller.clone()); } for account in other_funded_accounts { add_sk(account); } - // Accumulate bridge transactions - let mut complete_txs: Vec<_> = key_bridge_locks - .iter() - .cloned() - .zip(identity.secondary_keys.iter().map(|sk| sk.key.clone())) - .map( - |( - BridgeLockId { - nonce, - amount, - tx_hash, - }, - recipient, - )| BridgeTx { - nonce, - recipient, - amount, - tx_hash, - }, - ) - .collect(); - - complete_txs.push(BridgeTx { - nonce: treasury_bridge_lock.nonce, - recipient: TREASURY_PALLET_ID.into_account_truncating(), - amount: BOOTSTRAP_TREASURY, - tx_hash: treasury_bridge_lock.tx_hash, - }); - // The 0th key is the primary key identity.secondary_keys.remove(0); - (vec![identity], stakers, complete_txs) -} + // Treasury + balances.push(( + TREASURY_PALLET_ID.into_account_truncating(), + treasury_amount, + )); -fn bridge_signers() -> Vec> { - let signer = - |seed| Signatory::Account(AccountId::from(get_from_seed::(seed).0)); - vec![ - signer("relay_1"), - signer("relay_2"), - signer("relay_3"), - signer("relay_4"), - signer("relay_5"), - ] + (vec![identity], balances) } fn frame(wasm_binary: Option<&[u8]>) -> frame_system::GenesisConfig { @@ -462,21 +336,6 @@ macro_rules! session { }; } -macro_rules! staking { - ($auths:expr, $stakers:expr, $cap:expr) => { - pallet_staking::GenesisConfig { - minimum_validator_count: 1, - validator_count: 40, - validator_commission_cap: $cap, - stakers: $stakers, - invulnerables: vec![], - slash_reward_fraction: sp_runtime::Perbill::from_percent(10), - min_bond_threshold: 0, // Will be updated to 50,000 POLYX once network has stabalised, before external operators join - ..Default::default() - } - }; -} - macro_rules! pips { ($period:expr, $expiry:expr, $limit:expr) => { pallet_pips::GenesisConfig { @@ -578,16 +437,15 @@ pub mod develop { fn genesis( initial_authorities: Vec, root_key: AccountId, - _enable_println: bool, - treasury_bridge_lock: BridgeLockId, - key_bridge_locks: Vec, other_funded_accounts: Vec, + treasury_amount: u128, + key_amount: u128, ) -> rt::runtime::GenesisConfig { - let (identities, stakers, complete_txs) = dev_genesis_processed_data( + let (identities, balances) = dev_genesis_processed_data( &initial_authorities, - treasury_bridge_lock, - key_bridge_locks, other_funded_accounts, + treasury_amount, + key_amount, ); rt::runtime::GenesisConfig { @@ -598,29 +456,21 @@ pub mod develop { identities, ..Default::default() }, - balances: Default::default(), - bridge: pallet_bridge::GenesisConfig { - admin: Some(initial_authorities[0].1.clone()), - creator: Some(initial_authorities[0].1.clone()), - signatures_required: 1, - signers: bridge_signers(), - timelock: 10, - bridge_limit: (100_000_000 * ONE_POLY, 1000), - complete_txs, - }, + balances: rt::runtime::BalancesConfig { balances }, indices: pallet_indices::GenesisConfig { indices: vec![] }, sudo: pallet_sudo::GenesisConfig { key: Some(root_key.clone()), }, session: session!(initial_authorities, session_keys), - staking: staking!( - initial_authorities, - stakers, - PerThing::from_rational(1u64, 4u64) - ), pips: pips!(time::MINUTES, MaybeBlock::None, 25), im_online: Default::default(), authority_discovery: Default::default(), + validator_set: validator_set::GenesisConfig { + initial_validators: initial_authorities + .iter() + .map(|x| x.0.clone()) + .collect::>(), + }, babe: pallet_babe::GenesisConfig { authorities: vec![], epoch_config: Some(rt::runtime::BABE_GENESIS_EPOCH_CONFIG), @@ -654,15 +504,14 @@ pub mod develop { genesis( vec![get_authority_keys_from_seed("Alice", false)], seeded_acc_id("Alice"), - true, - BridgeLockId::new(1, DEV_TREASURY, TREASURY_LOCK_HASH), - BridgeLockId::generate_bridge_locks(2, 20, DEV_KEYS, KEY_LOCK_HASH), vec![ seeded_acc_id("Bob"), seeded_acc_id("Charlie"), seeded_acc_id("Dave"), seeded_acc_id("Eve"), ], + DEV_TREASURY, + DEV_KEYS, ) } @@ -672,7 +521,7 @@ pub mod develop { ctype: ChainType, genesis: impl 'static + Sync + Send + Fn() -> rt::runtime::GenesisConfig, ) -> ChainSpec { - let props = Some(polymath_props(42)); + let props = Some(polymesh_props(42)); ChainSpec::from_genesis( name, id, @@ -704,10 +553,9 @@ pub mod develop { get_authority_keys_from_seed("Charlie", false), ], seeded_acc_id("Alice"), - true, - BridgeLockId::new(1, DEV_TREASURY, TREASURY_LOCK_HASH), - BridgeLockId::generate_bridge_locks(2, 20, DEV_KEYS, KEY_LOCK_HASH), vec![seeded_acc_id("Dave"), seeded_acc_id("Eve")], + DEV_TREASURY, + DEV_KEYS, ) } @@ -732,15 +580,14 @@ pub mod production { fn genesis( initial_authorities: Vec, root_key: AccountId, - _enable_println: bool, - treasury_bridge_lock: BridgeLockId, - key_bridge_locks: Vec, + treasury_amount: u128, + key_amount: u128, ) -> rt::runtime::GenesisConfig { - let (identities, stakers, complete_txs) = genesis_processed_data( + let (identities, balances) = genesis_processed_data( &initial_authorities, root_key.clone(), - treasury_bridge_lock, - key_bridge_locks, + treasury_amount, + key_amount, ); rt::runtime::GenesisConfig { @@ -751,26 +598,18 @@ pub mod production { identities, ..Default::default() }, - balances: Default::default(), - bridge: pallet_bridge::GenesisConfig { - admin: Some(root_key.clone()), - creator: Some(root_key.clone()), - signatures_required: 4, - signers: bridge_signers(), - timelock: time::HOURS * 24, - bridge_limit: (1_000_000_000 * ONE_POLY, 365 * time::DAYS), - complete_txs, - }, + balances: rt::runtime::BalancesConfig { balances }, indices: pallet_indices::GenesisConfig { indices: vec![] }, session: session!(initial_authorities, session_keys), - staking: staking!( - initial_authorities, - stakers, - PerThing::from_rational(1u64, 10u64) - ), pips: pips!(time::DAYS * 30, MaybeBlock::Some(time::DAYS * 90), 1000), im_online: Default::default(), authority_discovery: Default::default(), + validator_set: validator_set::GenesisConfig { + initial_validators: initial_authorities + .iter() + .map(|x| x.0.clone()) + .collect::>(), + }, babe: pallet_babe::GenesisConfig { authorities: vec![], epoch_config: Some(rt::runtime::BABE_GENESIS_EPOCH_CONFIG), @@ -807,10 +646,9 @@ pub mod production { get_authority_keys_from_seed("Bob", false), get_authority_keys_from_seed("Charlie", false), ], - seeded_acc_id("polymath_5"), - false, - BridgeLockId::new(1, BOOTSTRAP_TREASURY, TREASURY_LOCK_HASH), - BridgeLockId::generate_bridge_locks(2, 20, BOOTSTRAP_KEYS, KEY_LOCK_HASH), + seeded_acc_id("polymesh_5"), + BOOTSTRAP_TREASURY, + BOOTSTRAP_KEYS, ) } @@ -844,7 +682,7 @@ pub mod production { ), Some(&*"/polymesh/production"), None, - Some(polymath_props(12)), + Some(polymesh_props(12)), Default::default(), ) } @@ -853,9 +691,8 @@ pub mod production { genesis( vec![get_authority_keys_from_seed("Alice", false)], seeded_acc_id("Eve"), - true, - BridgeLockId::new(1, BOOTSTRAP_TREASURY, TREASURY_LOCK_HASH), - BridgeLockId::generate_bridge_locks(2, 20, BOOTSTRAP_KEYS, KEY_LOCK_HASH), + BOOTSTRAP_TREASURY, + BOOTSTRAP_KEYS, ) } @@ -871,7 +708,7 @@ pub mod production { None, None, None, - Some(polymath_props(12)), + Some(polymesh_props(12)), Default::default(), ) } @@ -884,9 +721,8 @@ pub mod production { get_authority_keys_from_seed("Charlie", false), ], seeded_acc_id("Eve"), - true, - BridgeLockId::new(1, BOOTSTRAP_TREASURY, TREASURY_LOCK_HASH), - BridgeLockId::generate_bridge_locks(2, 20, BOOTSTRAP_KEYS, KEY_LOCK_HASH), + BOOTSTRAP_TREASURY, + BOOTSTRAP_KEYS, ) } @@ -902,7 +738,7 @@ pub mod production { None, None, None, - Some(polymath_props(12)), + Some(polymesh_props(12)), Default::default(), ) } @@ -920,15 +756,14 @@ pub mod develop { fn genesis( initial_authorities: Vec, root_key: AccountId, - _enable_println: bool, - treasury_bridge_lock: BridgeLockId, - key_bridge_locks: Vec, + treasury_amount: u128, + key_amount: u128, ) -> rt::runtime::GenesisConfig { - let (identities, stakers, complete_txs) = genesis_processed_data( + let (identities, balances) = genesis_processed_data( &initial_authorities, root_key.clone(), - treasury_bridge_lock, - key_bridge_locks, + treasury_amount, + key_amount, ); rt::runtime::GenesisConfig { @@ -939,25 +774,21 @@ pub mod develop { identities, ..Default::default() }, - balances: Default::default(), - bridge: pallet_bridge::GenesisConfig { - admin: Some(seeded_acc_id("polymath_1")), - creator: Some(seeded_acc_id("polymath_1")), - signatures_required: 3, - signers: bridge_signers(), - timelock: time::MINUTES * 15, - bridge_limit: (30_000_000_000, time::DAYS), - complete_txs, - }, + balances: rt::runtime::BalancesConfig { balances }, indices: pallet_indices::GenesisConfig { indices: vec![] }, sudo: pallet_sudo::GenesisConfig { key: Some(root_key.clone()), }, session: session!(initial_authorities, session_keys), - staking: staking!(initial_authorities, stakers, PerThing::zero()), pips: pips!(time::DAYS * 7, MaybeBlock::None, 1000), im_online: Default::default(), authority_discovery: Default::default(), + validator_set: validator_set::GenesisConfig { + initial_validators: initial_authorities + .iter() + .map(|x| x.0.clone()) + .collect::>(), + }, babe: pallet_babe::GenesisConfig { authorities: vec![], epoch_config: Some(rt::runtime::BABE_GENESIS_EPOCH_CONFIG), @@ -991,9 +822,8 @@ pub mod develop { genesis( vec![get_authority_keys_from_seed("Bob", false)], seeded_acc_id("Alice"), - true, - BridgeLockId::new(1, DEV_TREASURY, TREASURY_LOCK_HASH), - BridgeLockId::generate_bridge_locks(2, 20, DEV_KEYS, KEY_LOCK_HASH), + DEV_TREASURY, + DEV_KEYS, ) } @@ -1009,7 +839,7 @@ pub mod develop { None, None, None, - Some(polymath_props(42)), + Some(polymesh_props(42)), Default::default(), ) } @@ -1022,9 +852,8 @@ pub mod develop { get_authority_keys_from_seed("Charlie", false), ], seeded_acc_id("Alice"), - true, - BridgeLockId::new(1, DEV_TREASURY, TREASURY_LOCK_HASH), - BridgeLockId::generate_bridge_locks(2, 20, DEV_KEYS, KEY_LOCK_HASH), + DEV_TREASURY, + DEV_KEYS, ) } @@ -1040,7 +869,7 @@ pub mod develop { None, None, None, - Some(polymath_props(42)), + Some(polymesh_props(42)), Default::default(), ) } diff --git a/src/command.rs b/src/command.rs index f9aee5b..40eda9c 100644 --- a/src/command.rs +++ b/src/command.rs @@ -149,7 +149,7 @@ pub fn run() -> Result<()> { |(c, b, _, tm), _| { let aux_revert = Box::new(|client: Arc>, backend, blocks| { sc_consensus_babe::revert(client.clone(), backend, blocks)?; - grandpa::revert(client, blocks)?; + sc_consensus_grandpa::revert(client, blocks)?; Ok(()) }); Ok((cmd.run(c, b, Some(aux_revert)), tm)) @@ -157,7 +157,7 @@ pub fn run() -> Result<()> { |(c, b, _, tm), _| { let aux_revert = Box::new(|client: Arc>, backend, blocks| { sc_consensus_babe::revert(client.clone(), backend, blocks)?; - grandpa::revert(client, blocks)?; + sc_consensus_grandpa::revert(client, blocks)?; Ok(()) }); Ok((cmd.run(c, b, Some(aux_revert)), tm)) diff --git a/src/main.rs b/src/main.rs index 056cd50..cb9e5bd 100644 --- a/src/main.rs +++ b/src/main.rs @@ -7,6 +7,7 @@ mod chain_spec; mod service; mod cli; mod command; +mod rpc; fn main() -> Result<(), sc_cli::Error> { command::run() diff --git a/src/rpc.rs b/src/rpc.rs new file mode 100644 index 0000000..7428e37 --- /dev/null +++ b/src/rpc.rs @@ -0,0 +1,199 @@ +//! 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 jsonrpsee::RpcModule; +use polymesh_primitives::{AccountId, Block, BlockNumber, Hash, IdentityId, Index, Moment, Ticker}; +use sc_client_api::AuxStore; +use sc_consensus_babe::{BabeConfiguration, Epoch}; +use sc_consensus_epochs::SharedEpochChanges; +use sc_consensus_grandpa::{ + FinalityProofProvider, GrandpaJustificationStream, SharedAuthoritySet, SharedVoterState, +}; +use sc_rpc::SubscriptionTaskExecutor; +pub use sc_rpc_api::DenyUnsafe; +use sc_transaction_pool_api::TransactionPool; +use sp_api::ProvideRuntimeApi; +use sp_block_builder::BlockBuilder; +use sp_blockchain::{Error as BlockChainError, HeaderBackend, HeaderMetadata}; +use sp_consensus::SelectChain; + +use sp_consensus_babe::BabeApi; +use sp_keystore::SyncCryptoStorePtr; + +/// Extra dependencies for BABE. +pub struct BabeDeps { + /// BABE protocol config. + pub babe_config: BabeConfiguration, + /// BABE pending epoch changes. + pub shared_epoch_changes: SharedEpochChanges, + /// The keystore that manages the keys of the node. + pub keystore: SyncCryptoStorePtr, +} + +/// Extra dependencies for GRANDPA +pub struct GrandpaDeps { + /// Voting round info. + pub shared_voter_state: SharedVoterState, + /// Authority set info. + pub shared_authority_set: SharedAuthoritySet, + /// Receives notifications about justification events from Grandpa. + pub justification_stream: GrandpaJustificationStream, + /// Executor to drive the subscription manager in the Grandpa RPC handler. + pub subscription_executor: SubscriptionTaskExecutor, + /// Finality proof provider. + pub finality_provider: Arc>, +} + +/// Full client dependencies. +pub struct FullDeps { + /// The client instance to use. + pub client: Arc, + /// Transaction pool instance. + pub pool: Arc

, + /// 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, + /// BABE specific dependencies. + pub babe: BabeDeps, + /// GRANDPA specific dependencies. + pub grandpa: GrandpaDeps, +} + +/// Instantiate all Full RPC extensions. +pub fn create_full( + deps: FullDeps, + backend: Arc, +) -> Result, Box> +where + C: ProvideRuntimeApi + + sc_client_api::BlockBackend + + HeaderBackend + + AuxStore + + HeaderMetadata + + Sync + + Send + + 'static, + C::Api: substrate_frame_rpc_system::AccountNonceApi, + C::Api: node_rpc::transaction_payment::TransactionPaymentRuntimeApi, + C::Api: node_rpc::pips::PipsRuntimeApi, + C::Api: node_rpc::identity::IdentityRuntimeApi, + C::Api: pallet_protocol_fee_rpc::ProtocolFeeRuntimeApi, + C::Api: node_rpc::asset::AssetRuntimeApi, + C::Api: pallet_group_rpc::GroupRuntimeApi, + C::Api: BabeApi, + C::Api: BlockBuilder, + C::Api: node_rpc::nft::NFTRuntimeApi, + C::Api: node_rpc::settlement::SettlementRuntimeApi, + P: TransactionPool + 'static, + SC: SelectChain + 'static, + B: sc_client_api::Backend + Send + Sync + 'static, + B::State: sc_client_api::backend::StateBackend>, +{ + use node_rpc::{ + asset::{Asset, AssetApiServer}, + identity::{Identity, IdentityApiServer}, + nft::{NFTApiServer, NFT}, + pips::{Pips, PipsApiServer}, + settlement::{Settlement, SettlementApiServer}, + transaction_payment::{TransactionPayment, TransactionPaymentApiServer}, + }; + use pallet_group_rpc::{Group, GroupApiServer}; + use pallet_protocol_fee_rpc::{ProtocolFee, ProtocolFeeApiServer}; + use sc_consensus_babe_rpc::{Babe, BabeApiServer}; + use sc_consensus_grandpa_rpc::{Grandpa, GrandpaApiServer}; + use sc_rpc::dev::{Dev, DevApiServer}; + use sc_rpc_spec_v2::chain_spec::{ChainSpec, ChainSpecApiServer}; + use sc_sync_state_rpc::{SyncState, SyncStateApiServer}; + use substrate_frame_rpc_system::{System, SystemApiServer}; + use substrate_state_trie_migration_rpc::{StateMigration, StateMigrationApiServer}; + + let mut io = RpcModule::new(()); + let FullDeps { + client, + pool, + select_chain, + chain_spec, + deny_unsafe, + babe, + grandpa, + } = deps; + + let BabeDeps { + keystore, + babe_config, + shared_epoch_changes, + } = babe; + let GrandpaDeps { + shared_voter_state, + shared_authority_set, + justification_stream, + subscription_executor, + finality_provider, + } = grandpa; + + let chain_name = chain_spec.name().to_string(); + let genesis_hash = client + .block_hash(0) + .ok() + .flatten() + .expect("Genesis block exists; qed"); + let properties = chain_spec.properties(); + io.merge(ChainSpec::new(chain_name, genesis_hash, properties).into_rpc())?; + + io.merge(System::new(client.clone(), pool, deny_unsafe).into_rpc())?; + io.merge(TransactionPayment::new(client.clone()).into_rpc())?; + io.merge( + Babe::new( + client.clone(), + shared_epoch_changes.clone(), + keystore, + babe_config, + select_chain, + deny_unsafe, + ) + .into_rpc(), + )?; + io.merge( + Grandpa::new( + subscription_executor, + shared_authority_set.clone(), + shared_voter_state, + justification_stream, + finality_provider, + ) + .into_rpc(), + )?; + + io.merge( + SyncState::new( + chain_spec, + client.clone(), + shared_authority_set, + shared_epoch_changes, + )? + .into_rpc(), + )?; + + io.merge(StateMigration::new(client.clone(), backend, deny_unsafe).into_rpc())?; + io.merge(Dev::new(client.clone(), deny_unsafe).into_rpc())?; + + io.merge(Pips::new(client.clone()).into_rpc())?; + io.merge(Identity::new(client.clone()).into_rpc())?; + io.merge(ProtocolFee::new(client.clone()).into_rpc())?; + io.merge(Asset::new(client.clone()).into_rpc())?; + io.merge(Group::from(client.clone()).into_rpc())?; + io.merge(NFT::new(client.clone()).into_rpc())?; + io.merge(Settlement::new(client).into_rpc())?; + + Ok(io) +} diff --git a/src/service.rs b/src/service.rs index 317125a..bcd0a4b 100644 --- a/src/service.rs +++ b/src/service.rs @@ -1,7 +1,6 @@ //! Service and ServiceFactory implementation. Specialized wrapper over substrate service. use futures::stream::StreamExt; -use polymesh_node_rpc as node_rpc; pub use polymesh_primitives::{ crypto::native_schnorrkel, AccountId, Block, IdentityId, Index as Nonce, Moment, Ticker, }; @@ -79,7 +78,7 @@ pub trait RuntimeApiCollection: sp_transaction_pool::runtime_api::TaggedTransactionQueue + sp_api::ApiExt + sp_consensus_babe::BabeApi - + grandpa::GrandpaApi + + sc_consensus_grandpa::GrandpaApi + sp_block_builder::BlockBuilder + frame_system_rpc_runtime_api::AccountNonceApi + node_rpc_runtime_api::transaction_payment::TransactionPaymentApi @@ -87,7 +86,6 @@ pub trait RuntimeApiCollection: + sp_offchain::OffchainWorkerApi + sp_session::SessionKeys + sp_authority_discovery::AuthorityDiscoveryApi - + pallet_staking_rpc_runtime_api::StakingApi + node_rpc_runtime_api::pips::PipsApi + node_rpc_runtime_api::identity::IdentityApi + pallet_protocol_fee_rpc_runtime_api::ProtocolFeeApi @@ -105,7 +103,7 @@ where Api: sp_transaction_pool::runtime_api::TaggedTransactionQueue + sp_api::ApiExt + sp_consensus_babe::BabeApi - + grandpa::GrandpaApi + + sc_consensus_grandpa::GrandpaApi + sp_block_builder::BlockBuilder + frame_system_rpc_runtime_api::AccountNonceApi + node_rpc_runtime_api::transaction_payment::TransactionPaymentApi @@ -113,7 +111,6 @@ where + sp_offchain::OffchainWorkerApi + sp_session::SessionKeys + sp_authority_discovery::AuthorityDiscoveryApi - + pallet_staking_rpc_runtime_api::StakingApi + node_rpc_runtime_api::pips::PipsApi + node_rpc_runtime_api::identity::IdentityApi + pallet_protocol_fee_rpc_runtime_api::ProtocolFeeApi @@ -136,12 +133,12 @@ fn set_prometheus_registry(config: &mut Configuration) -> Result<(), ServiceErro type BabeLink = sc_consensus_babe::BabeLink; -type FullLinkHalf = grandpa::LinkHalf, FullSelectChain>; +type FullLinkHalf = sc_consensus_grandpa::LinkHalf, FullSelectChain>; pub type FullClient = sc_service::TFullClient>; type FullBackend = sc_service::TFullBackend; type FullSelectChain = sc_consensus::LongestChain; type FullGrandpaBlockImport = - grandpa::GrandpaBlockImport, FullSelectChain>; + sc_consensus_grandpa::GrandpaBlockImport, FullSelectChain>; type FullBabeImportQueue = sc_consensus::DefaultImportQueue>; type FullStateBackend = sc_client_api::StateBackendFor; type FullPool = sc_transaction_pool::FullPool>; @@ -154,7 +151,7 @@ pub type FullServiceComponents = sc_service::PartialComponents< ( F, (FullBabeBlockImport, FullLinkHalf, BabeLink), - grandpa::SharedVoterState, + sc_consensus_grandpa::SharedVoterState, Option, ), >; @@ -224,7 +221,7 @@ where client.clone(), ); - let (grandpa_block_import, grandpa_link) = grandpa::block_import( + let (grandpa_block_import, grandpa_link) = sc_consensus_grandpa::block_import( client.clone(), &(client.clone() as Arc<_>), select_chain.clone(), @@ -268,10 +265,10 @@ where let justification_stream = grandpa_link.justification_stream(); let shared_authority_set = grandpa_link.shared_authority_set().clone(); - let shared_voter_state = grandpa::SharedVoterState::empty(); + let shared_voter_state = sc_consensus_grandpa::SharedVoterState::empty(); let rpc_setup = shared_voter_state.clone(); - let finality_proof_provider = grandpa::FinalityProofProvider::new_for_service( + let finality_proof_provider = sc_consensus_grandpa::FinalityProofProvider::new_for_service( backend.clone(), Some(shared_authority_set.clone()), ); @@ -287,18 +284,18 @@ where let rpc_backend = backend.clone(); let rpc_extensions_builder = move |deny_unsafe, subscription_executor| { - let deps = node_rpc::FullDeps { + let deps = crate::rpc::FullDeps { client: client.clone(), pool: pool.clone(), select_chain: select_chain.clone(), chain_spec: chain_spec.cloned_box(), deny_unsafe, - babe: node_rpc::BabeDeps { + babe: crate::rpc::BabeDeps { babe_config: babe_config.clone(), shared_epoch_changes: shared_epoch_changes.clone(), keystore: keystore.clone(), }, - grandpa: node_rpc::GrandpaDeps { + grandpa: crate::rpc::GrandpaDeps { shared_voter_state: shared_voter_state.clone(), shared_authority_set: shared_authority_set.clone(), justification_stream: justification_stream.clone(), @@ -307,7 +304,7 @@ where }, }; - node_rpc::create_full(deps, rpc_backend.clone()).map_err(Into::into) + crate::rpc::create_full(deps, rpc_backend.clone()).map_err(Into::into) }; (rpc_extensions_builder, rpc_setup) @@ -367,7 +364,7 @@ where let shared_voter_state = rpc_setup; let auth_disc_publish_non_global_ips = config.network.allow_non_globals_in_dht; - let grandpa_protocol_name = grandpa::protocol_standard_name( + let grandpa_protocol_name = sc_consensus_grandpa::protocol_standard_name( &client .block_hash(0) .ok() @@ -379,10 +376,10 @@ where config .network .extra_sets - .push(grandpa::grandpa_peers_set_config( + .push(sc_consensus_grandpa::grandpa_peers_set_config( grandpa_protocol_name.clone(), )); - let warp_sync = Arc::new(grandpa::warp_proof::NetworkProvider::new( + let warp_sync = Arc::new(sc_consensus_grandpa::warp_proof::NetworkProvider::new( backend.clone(), import_setup.1.shared_authority_set().clone(), Vec::default(), @@ -539,7 +536,7 @@ where None }; - let config = grandpa::Config { + let config = sc_consensus_grandpa::Config { // FIXME #1578 make this available through chainspec gossip_duration: std::time::Duration::from_millis(333), justification_period: 512, @@ -558,12 +555,12 @@ where // and vote data availability than the observer. The observer has not // been tested extensively yet and having most nodes in a network run it // could lead to finality stalls. - let grandpa_config = grandpa::GrandpaParams { + let grandpa_config = sc_consensus_grandpa::GrandpaParams { config, link: grandpa_link, network: network.clone(), telemetry: telemetry.as_ref().map(|x| x.handle()), - voting_rule: grandpa::VotingRulesBuilder::default().build(), + voting_rule: sc_consensus_grandpa::VotingRulesBuilder::default().build(), prometheus_registry, shared_voter_state, }; @@ -573,7 +570,7 @@ where task_manager.spawn_essential_handle().spawn_blocking( "grandpa-voter", None, - grandpa::run_grandpa_voter(grandpa_config)?, + sc_consensus_grandpa::run_grandpa_voter(grandpa_config)?, ); }