From 597b1d213d41e6a54f72d2387b3d671ba4811f7a Mon Sep 17 00:00:00 2001 From: moh-eulith <101080211+moh-eulith@users.noreply.github.com> Date: Thu, 10 Nov 2022 08:40:45 -0500 Subject: [PATCH 1/2] Add a few staking params to fast-runtime build (#5424) Co-authored-by: Squirrel --- runtime/kusama/src/lib.rs | 13 +++++++++++-- runtime/polkadot/src/lib.rs | 13 +++++++++++-- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/runtime/kusama/src/lib.rs b/runtime/kusama/src/lib.rs index 3f77ece6c86a..e399d7a0b35e 100644 --- a/runtime/kusama/src/lib.rs +++ b/runtime/kusama/src/lib.rs @@ -548,10 +548,19 @@ impl pallet_staking::EraPayout for EraPayout { parameter_types! { // Six sessions in an era (6 hours). pub const SessionsPerEra: SessionIndex = prod_or_fast!(6, 1); + // 28 eras for unbonding (7 days). - pub const BondingDuration: sp_staking::EraIndex = 28; + pub BondingDuration: sp_staking::EraIndex = prod_or_fast!( + 28, + 28, + "DOT_BONDING_DURATION" + ); // 27 eras in which slashes can be cancelled (slightly less than 7 days). - pub const SlashDeferDuration: sp_staking::EraIndex = 27; + pub SlashDeferDuration: sp_staking::EraIndex = prod_or_fast!( + 27, + 27, + "DOT_SLASH_DEFER_DURATION" + ); pub const MaxNominatorRewardedPerValidator: u32 = 512; pub const OffendingValidatorsThreshold: Perbill = Perbill::from_percent(17); // 24 diff --git a/runtime/polkadot/src/lib.rs b/runtime/polkadot/src/lib.rs index 0f71a37f425f..8beb551db376 100644 --- a/runtime/polkadot/src/lib.rs +++ b/runtime/polkadot/src/lib.rs @@ -534,9 +534,18 @@ pallet_staking_reward_curve::build! { parameter_types! { // Six sessions in an era (24 hours). pub const SessionsPerEra: SessionIndex = prod_or_fast!(6, 1); + // 28 eras for unbonding (28 days). - pub const BondingDuration: sp_staking::EraIndex = 28; - pub const SlashDeferDuration: sp_staking::EraIndex = 27; + pub BondingDuration: sp_staking::EraIndex = prod_or_fast!( + 28, + 28, + "DOT_BONDING_DURATION" + ); + pub SlashDeferDuration: sp_staking::EraIndex = prod_or_fast!( + 27, + 27, + "DOT_SLASH_DEFER_DURATION" + ); pub const RewardCurve: &'static PiecewiseLinear<'static> = &REWARD_CURVE; pub const MaxNominatorRewardedPerValidator: u32 = 512; pub const OffendingValidatorsThreshold: Perbill = Perbill::from_percent(17); From 0f9244b432cb7b3d22453133e3eaa2bb5214c311 Mon Sep 17 00:00:00 2001 From: cheme Date: Fri, 11 Nov 2022 12:06:44 +0100 Subject: [PATCH 2/2] State trie migration rococo runtime changes. (#6127) * add state-trie-migration (warn key need to be changed) * rococo root * restore master benchs (weights from substrate are used). * use ord_parameter macro. * do not upgrade runtime version yet * apply review changes * to test ci * Revert "to test ci" This reverts commit 5df6c5c74c5d172f254579cbb76caeb44af80ec2. * test ci * Revert "test ci" This reverts commit 0747761644ba566f9756e195e5304758370dc52c. Co-authored-by: parity-processbot <> --- Cargo.lock | 18 ++++++++++++++++++ runtime/rococo/Cargo.toml | 6 +++--- runtime/rococo/src/lib.rs | 30 +++++++++++++++++++++++++++++- 3 files changed, 50 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f01b5b365f99..765c025ff027 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5370,6 +5370,23 @@ dependencies = [ "sp-arithmetic", ] +[[package]] +name = "pallet-state-trie-migration" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#4a5a9dea00c9b4e4d34ff56368451aa4dac09d77" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "log", + "parity-scale-codec", + "scale-info", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std", +] + [[package]] name = "pallet-sudo" version = "4.0.0-dev" @@ -8137,6 +8154,7 @@ dependencies = [ "pallet-session", "pallet-society", "pallet-staking", + "pallet-state-trie-migration", "pallet-sudo", "pallet-timestamp", "pallet-tips", diff --git a/runtime/rococo/Cargo.toml b/runtime/rococo/Cargo.toml index 9adf0d5caae3..b79b2cf444be 100644 --- a/runtime/rococo/Cargo.toml +++ b/runtime/rococo/Cargo.toml @@ -41,6 +41,7 @@ pallet-beefy = { git = "https://github.com/paritytech/substrate", branch = "mast pallet-beefy-mmr = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } pallet-bounties = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } pallet-child-bounties = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } +pallet-state-trie-migration = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } pallet-transaction-payment = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } pallet-collective = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } @@ -77,7 +78,7 @@ pallet-xcm-benchmarks = { path = "../../xcm/pallet-xcm-benchmarks", default-feat frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false, optional = true } frame-system-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false, optional = true } -hex-literal = { version = "0.3.4", optional = true } +hex-literal = { version = "0.3.4" } runtime-common = { package = "polkadot-runtime-common", path = "../common", default-features = false } runtime-parachains = { package = "polkadot-runtime-parachains", path = "../parachains", default-features = false } @@ -89,7 +90,6 @@ xcm-executor = { package = "xcm-executor", path = "../../xcm/xcm-executor", defa xcm-builder = { package = "xcm-builder", path = "../../xcm/xcm-builder", default-features = false } [dev-dependencies] -hex-literal = "0.3.4" tiny-keccak = { version = "2.0.2", features = ["keccak"] } keyring = { package = "sp-keyring", git = "https://github.com/paritytech/substrate", branch = "master" } sp-trie = { git = "https://github.com/paritytech/substrate", branch = "master" } @@ -124,6 +124,7 @@ std = [ "pallet-beefy-mmr/std", "pallet-bounties/std", "pallet-child-bounties/std", + "pallet-state-trie-migration/std", "pallet-transaction-payment/std", "pallet-transaction-payment-rpc-runtime-api/std", "pallet-collective/std", @@ -207,7 +208,6 @@ runtime-benchmarks = [ "pallet-vesting/runtime-benchmarks", "pallet-xcm/runtime-benchmarks", "frame-system-benchmarking/runtime-benchmarks", - "hex-literal", "xcm-builder/runtime-benchmarks", "runtime-parachains/runtime-benchmarks", "pallet-xcm-benchmarks/runtime-benchmarks", diff --git a/runtime/rococo/src/lib.rs b/runtime/rococo/src/lib.rs index a0975d1ba6bc..b230832b7454 100644 --- a/runtime/rococo/src/lib.rs +++ b/runtime/rococo/src/lib.rs @@ -115,7 +115,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { #[cfg(feature = "disable-runtime-api")] apis: sp_version::create_apis_vec![[]], transaction_version: 15, - state_version: 0, + state_version: 1, }; /// The BABE epoch configuration at genesis. @@ -1416,6 +1416,9 @@ construct_runtime! { // Validator Manager pallet. ValidatorManager: validator_manager::{Pallet, Call, Storage, Event} = 252, + // State trie migration pallet, only temporary. + StateTrieMigration: pallet_state_trie_migration = 254, + // Sudo. Sudo: pallet_sudo::{Pallet, Call, Storage, Event, Config} = 255, } @@ -1466,6 +1469,31 @@ pub type Executive = frame_executive::Executive< /// The payload being signed in transactions. pub type SignedPayload = generic::SignedPayload; +parameter_types! { + // The deposit configuration for the singed migration. Specially if you want to allow any signed account to do the migration (see `SignedFilter`, these deposits should be high) + pub const MigrationSignedDepositPerItem: Balance = 1 * CENTS; + pub const MigrationSignedDepositBase: Balance = 20 * CENTS * 100; + pub const MigrationMaxKeyLen: u32 = 512; +} + +impl pallet_state_trie_migration::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type Currency = Balances; + type SignedDepositPerItem = MigrationSignedDepositPerItem; + type SignedDepositBase = MigrationSignedDepositBase; + type ControlOrigin = EnsureRoot; + // specific account for the migration, can trigger the signed migrations. + type SignedFilter = frame_system::EnsureSignedBy; + + // Use same weights as substrate ones. + type WeightInfo = pallet_state_trie_migration::weights::SubstrateWeight; + type MaxKeyLen = MigrationMaxKeyLen; +} + +frame_support::ord_parameter_types! { + pub const MigController: AccountId = AccountId::from(hex_literal::hex!("52bc71c1eca5353749542dfdf0af97bf764f9c2f44e860cd485f1cd86400f649")); +} + #[cfg(feature = "runtime-benchmarks")] #[macro_use] extern crate frame_benchmarking;