From 05183faa499428c2bd70f10eb7ead44e491448f9 Mon Sep 17 00:00:00 2001 From: zjb0807 Date: Wed, 28 Aug 2024 09:42:17 +0800 Subject: [PATCH 1/3] update state version to 1 on acala --- runtime/acala/Cargo.toml | 4 ++++ runtime/acala/src/lib.rs | 26 +++++++++++++++++++++++++- runtime/karura/Cargo.toml | 4 ---- runtime/karura/src/lib.rs | 24 ------------------------ 4 files changed, 29 insertions(+), 29 deletions(-) diff --git a/runtime/acala/Cargo.toml b/runtime/acala/Cargo.toml index 6e33d40b4..9c23728b6 100644 --- a/runtime/acala/Cargo.toml +++ b/runtime/acala/Cargo.toml @@ -55,6 +55,7 @@ sp-staking = { workspace = true } sp-std = { workspace = true } sp-transaction-pool = { workspace = true } sp-version = { workspace = true } +pallet-state-trie-migration = { workspace = true, optional = true } # cumulus cumulus-pallet-aura-ext = { workspace = true } @@ -199,6 +200,7 @@ std = [ "sp-transaction-pool/std", "sp-version/std", "substrate-wasm-builder", + "pallet-state-trie-migration/std", "cumulus-pallet-aura-ext/std", "cumulus-pallet-parachain-system/std", @@ -295,6 +297,7 @@ runtime-benchmarks = [ "pallet-utility/runtime-benchmarks", "sp-runtime/runtime-benchmarks", "sp-staking/runtime-benchmarks", + "pallet-state-trie-migration/runtime-benchmarks", "cumulus-pallet-parachain-system/runtime-benchmarks", "cumulus-pallet-xcmp-queue/runtime-benchmarks", @@ -355,6 +358,7 @@ try-runtime = [ "pallet-transaction-payment/try-runtime", "pallet-treasury/try-runtime", "pallet-utility/try-runtime", + "pallet-state-trie-migration/try-runtime", "cumulus-pallet-aura-ext/try-runtime", "cumulus-pallet-parachain-system/try-runtime", diff --git a/runtime/acala/src/lib.rs b/runtime/acala/src/lib.rs index d6645eb83..25b7a1128 100644 --- a/runtime/acala/src/lib.rs +++ b/runtime/acala/src/lib.rs @@ -132,7 +132,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 3, - state_version: 0, + state_version: 1, }; /// The version information used to identify this runtime when compiled @@ -1830,6 +1830,28 @@ impl orml_parameters::Config for Runtime { type WeightInfo = (); } +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 MigrationSignedDepositPerItem: Balance = dollar(KAR); + pub MigrationSignedDepositBase: Balance = dollar(KAR); + pub const MigrationMaxKeyLen: u32 = 512; +} + +impl pallet_state_trie_migration::Config for Runtime { + // An origin that can control the whole pallet: should be Root, or a part of your council. + type ControlOrigin = EnsureRootOrTwoThirdsTechnicalCommittee; + // specific account for the migration, can trigger the signed migrations. + type SignedFilter = frame_support::traits::NeverEnsureOrigin; + type RuntimeEvent = RuntimeEvent; + type Currency = Balances; + type RuntimeHoldReason = RuntimeHoldReason; + type MaxKeyLen = MigrationMaxKeyLen; + type SignedDepositPerItem = MigrationSignedDepositPerItem; + type SignedDepositBase = MigrationSignedDepositBase; + // Replace this with weight based on your runtime. + type WeightInfo = pallet_state_trie_migration::weights::SubstrateWeight; +} + construct_runtime!( pub enum Runtime { // Core & Utility @@ -1939,6 +1961,8 @@ construct_runtime!( // Parachain System, always put it at the end ParachainSystem: cumulus_pallet_parachain_system = 30, + StateTrieMigration: pallet_state_trie_migration = 254, + // Temporary Sudo: pallet_sudo = 255, } diff --git a/runtime/karura/Cargo.toml b/runtime/karura/Cargo.toml index 512a9c0fe..88b3a8133 100644 --- a/runtime/karura/Cargo.toml +++ b/runtime/karura/Cargo.toml @@ -55,7 +55,6 @@ sp-staking = { workspace = true } sp-std = { workspace = true } sp-transaction-pool = { workspace = true } sp-version = { workspace = true } -pallet-state-trie-migration = { workspace = true, optional = true } # cumulus cumulus-pallet-aura-ext = { workspace = true } @@ -201,7 +200,6 @@ std = [ "sp-transaction-pool/std", "sp-version/std", "substrate-wasm-builder", - "pallet-state-trie-migration/std", "cumulus-pallet-aura-ext/std", "cumulus-pallet-parachain-system/std", @@ -300,7 +298,6 @@ runtime-benchmarks = [ "pallet-utility/runtime-benchmarks", "sp-runtime/runtime-benchmarks", "sp-staking/runtime-benchmarks", - "pallet-state-trie-migration/runtime-benchmarks", "cumulus-pallet-parachain-system/runtime-benchmarks", "cumulus-pallet-xcmp-queue/runtime-benchmarks", @@ -361,7 +358,6 @@ try-runtime = [ "pallet-transaction-payment/try-runtime", "pallet-treasury/try-runtime", "pallet-utility/try-runtime", - "pallet-state-trie-migration/try-runtime", "cumulus-pallet-aura-ext/try-runtime", "cumulus-pallet-parachain-system/try-runtime", diff --git a/runtime/karura/src/lib.rs b/runtime/karura/src/lib.rs index 80604e211..61232df53 100644 --- a/runtime/karura/src/lib.rs +++ b/runtime/karura/src/lib.rs @@ -1837,28 +1837,6 @@ impl orml_parameters::Config for Runtime { type WeightInfo = (); } -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 MigrationSignedDepositPerItem: Balance = dollar(KAR); - pub MigrationSignedDepositBase: Balance = dollar(KAR); - pub const MigrationMaxKeyLen: u32 = 512; -} - -impl pallet_state_trie_migration::Config for Runtime { - // An origin that can control the whole pallet: should be Root, or a part of your council. - type ControlOrigin = EnsureRootOrTwoThirdsTechnicalCommittee; - // specific account for the migration, can trigger the signed migrations. - type SignedFilter = frame_support::traits::NeverEnsureOrigin; - type RuntimeEvent = RuntimeEvent; - type Currency = Balances; - type RuntimeHoldReason = RuntimeHoldReason; - type MaxKeyLen = MigrationMaxKeyLen; - type SignedDepositPerItem = MigrationSignedDepositPerItem; - type SignedDepositBase = MigrationSignedDepositBase; - // Replace this with weight based on your runtime. - type WeightInfo = pallet_state_trie_migration::weights::SubstrateWeight; -} - construct_runtime!( pub enum Runtime { // Core & Utility @@ -1969,8 +1947,6 @@ construct_runtime!( // Parachain System, always put it at the end ParachainSystem: cumulus_pallet_parachain_system = 30, - StateTrieMigration: pallet_state_trie_migration = 254, - // Temporary Sudo: pallet_sudo = 255, } From 0fecb6825a7a3d0cda34168afd7d7d94ebbd6bd5 Mon Sep 17 00:00:00 2001 From: zjb0807 Date: Wed, 28 Aug 2024 10:19:11 +0800 Subject: [PATCH 2/3] add migration to clean StateTrieMigration --- Cargo.lock | 2 +- runtime/karura/src/lib.rs | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 10512f1ab..e0d9acee8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -123,6 +123,7 @@ dependencies = [ "pallet-proxy", "pallet-scheduler", "pallet-session", + "pallet-state-trie-migration", "pallet-sudo", "pallet-timestamp", "pallet-tips", @@ -2921,7 +2922,6 @@ dependencies = [ "pallet-proxy", "pallet-scheduler", "pallet-session", - "pallet-state-trie-migration", "pallet-sudo", "pallet-timestamp", "pallet-tips", diff --git a/runtime/karura/src/lib.rs b/runtime/karura/src/lib.rs index 61232df53..897130f87 100644 --- a/runtime/karura/src/lib.rs +++ b/runtime/karura/src/lib.rs @@ -1993,8 +1993,12 @@ pub type Executive = frame_executive::Executive< Migrations, >; +parameter_types! { + pub const StateTrieMigrationName: &'static str = "StateTrieMigration"; +} + #[allow(unused_parens)] -type Migrations = (); +type Migrations = (frame_support::migrations::RemovePallet); #[cfg(feature = "runtime-benchmarks")] #[macro_use] From b4f29e34b2809aa7dd1848a1ddf2c662cca69d9e Mon Sep 17 00:00:00 2001 From: zjb0807 Date: Wed, 28 Aug 2024 10:44:11 +0800 Subject: [PATCH 3/3] fix --- runtime/acala/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/runtime/acala/src/lib.rs b/runtime/acala/src/lib.rs index 25b7a1128..52e9c8be1 100644 --- a/runtime/acala/src/lib.rs +++ b/runtime/acala/src/lib.rs @@ -1832,8 +1832,8 @@ impl orml_parameters::Config for Runtime { 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 MigrationSignedDepositPerItem: Balance = dollar(KAR); - pub MigrationSignedDepositBase: Balance = dollar(KAR); + pub MigrationSignedDepositPerItem: Balance = dollar(ACA); + pub MigrationSignedDepositBase: Balance = dollar(ACA); pub const MigrationMaxKeyLen: u32 = 512; }