Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

Commit 0e3e7cb

Browse files
chemecoderobe
authored andcommitted
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 5df6c5c. * test ci * Revert "test ci" This reverts commit 0747761. Co-authored-by: parity-processbot <>
1 parent 42cb31d commit 0e3e7cb

File tree

3 files changed

+50
-4
lines changed

3 files changed

+50
-4
lines changed

Cargo.lock

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

runtime/rococo/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ pallet-beefy = { git = "https://github.com/paritytech/substrate", default-featur
4141
pallet-beefy-mmr = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.33" }
4242
pallet-bounties = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.33" }
4343
pallet-child-bounties = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.33" }
44+
pallet-state-trie-migration = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.33", default-features = false }
4445
pallet-transaction-payment = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.33" }
4546
pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.33" }
4647
pallet-collective = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.33" }
@@ -77,7 +78,7 @@ pallet-xcm-benchmarks = { path = "../../xcm/pallet-xcm-benchmarks", default-feat
7778

7879
frame-benchmarking = { git = "https://github.com/paritytech/substrate", default-features = false, optional = true , branch = "polkadot-v0.9.33" }
7980
frame-system-benchmarking = { git = "https://github.com/paritytech/substrate", default-features = false, optional = true , branch = "polkadot-v0.9.33" }
80-
hex-literal = { version = "0.3.4", optional = true }
81+
hex-literal = { version = "0.3.4" }
8182

8283
runtime-common = { package = "polkadot-runtime-common", path = "../common", default-features = false }
8384
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
8990
xcm-builder = { package = "xcm-builder", path = "../../xcm/xcm-builder", default-features = false }
9091

9192
[dev-dependencies]
92-
hex-literal = "0.3.4"
9393
tiny-keccak = { version = "2.0.2", features = ["keccak"] }
9494
keyring = { package = "sp-keyring", git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.33" }
9595
sp-trie = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.33" }
@@ -124,6 +124,7 @@ std = [
124124
"pallet-beefy-mmr/std",
125125
"pallet-bounties/std",
126126
"pallet-child-bounties/std",
127+
"pallet-state-trie-migration/std",
127128
"pallet-transaction-payment/std",
128129
"pallet-transaction-payment-rpc-runtime-api/std",
129130
"pallet-collective/std",
@@ -207,7 +208,6 @@ runtime-benchmarks = [
207208
"pallet-vesting/runtime-benchmarks",
208209
"pallet-xcm/runtime-benchmarks",
209210
"frame-system-benchmarking/runtime-benchmarks",
210-
"hex-literal",
211211
"xcm-builder/runtime-benchmarks",
212212
"runtime-parachains/runtime-benchmarks",
213213
"pallet-xcm-benchmarks/runtime-benchmarks",

runtime/rococo/src/lib.rs

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
115115
#[cfg(feature = "disable-runtime-api")]
116116
apis: sp_version::create_apis_vec![[]],
117117
transaction_version: 15,
118-
state_version: 0,
118+
state_version: 1,
119119
};
120120

121121
/// The BABE epoch configuration at genesis.
@@ -1416,6 +1416,9 @@ construct_runtime! {
14161416
// Validator Manager pallet.
14171417
ValidatorManager: validator_manager::{Pallet, Call, Storage, Event<T>} = 252,
14181418

1419+
// State trie migration pallet, only temporary.
1420+
StateTrieMigration: pallet_state_trie_migration = 254,
1421+
14191422
// Sudo.
14201423
Sudo: pallet_sudo::{Pallet, Call, Storage, Event<T>, Config<T>} = 255,
14211424
}
@@ -1458,6 +1461,31 @@ pub type Executive = frame_executive::Executive<
14581461
/// The payload being signed in transactions.
14591462
pub type SignedPayload = generic::SignedPayload<RuntimeCall, SignedExtra>;
14601463

1464+
parameter_types! {
1465+
// 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)
1466+
pub const MigrationSignedDepositPerItem: Balance = 1 * CENTS;
1467+
pub const MigrationSignedDepositBase: Balance = 20 * CENTS * 100;
1468+
pub const MigrationMaxKeyLen: u32 = 512;
1469+
}
1470+
1471+
impl pallet_state_trie_migration::Config for Runtime {
1472+
type RuntimeEvent = RuntimeEvent;
1473+
type Currency = Balances;
1474+
type SignedDepositPerItem = MigrationSignedDepositPerItem;
1475+
type SignedDepositBase = MigrationSignedDepositBase;
1476+
type ControlOrigin = EnsureRoot<AccountId>;
1477+
// specific account for the migration, can trigger the signed migrations.
1478+
type SignedFilter = frame_system::EnsureSignedBy<MigController, AccountId>;
1479+
1480+
// Use same weights as substrate ones.
1481+
type WeightInfo = pallet_state_trie_migration::weights::SubstrateWeight<Runtime>;
1482+
type MaxKeyLen = MigrationMaxKeyLen;
1483+
}
1484+
1485+
frame_support::ord_parameter_types! {
1486+
pub const MigController: AccountId = AccountId::from(hex_literal::hex!("52bc71c1eca5353749542dfdf0af97bf764f9c2f44e860cd485f1cd86400f649"));
1487+
}
1488+
14611489
#[cfg(feature = "runtime-benchmarks")]
14621490
#[macro_use]
14631491
extern crate frame_benchmarking;

0 commit comments

Comments
 (0)