diff --git a/.github/workflows/check-migrations.yml b/.github/workflows/check-migrations.yml index 8038081d36..7159d46467 100644 --- a/.github/workflows/check-migrations.yml +++ b/.github/workflows/check-migrations.yml @@ -78,6 +78,8 @@ jobs: EXTRA_FLAGS+=" --blocktime ${{ matrix.runtime.blocktime }} " + TRY_RUNTIME_EXTRA_ARGS+="${{ matrix.runtime.try_runtime_args }}" + # Disable the spec version check when we dont want to release. # The program prints either `1` or `0`. if [ "$(.github/changelog-processor.py CHANGELOG.md --should-release)" = "0" ]; then @@ -87,10 +89,12 @@ jobs: echo "Enabling the spec version check since we are releasing" fi + echo "Try runtime extra args: $TRY_RUNTIME_EXTRA_ARGS" echo "Flags: $EXTRA_FLAGS" echo "Checks: $CHECKS" echo "EXTRA_FLAGS=$EXTRA_FLAGS" >> $GITHUB_ENV + echo "TRY_RUNTIME_EXTRA_ARGS=$TRY_RUNTIME_EXTRA_ARGS" >> $GITHUB_ENV echo "CHECKS=$CHECKS" >> $GITHUB_ENV - name: Set rust version via common env file @@ -119,19 +123,19 @@ jobs: export RUST_LOG=remote-ext=debug,runtime=debug echo "Extra args: $EXTRA_FLAGS" - + # Store the command in a variable so we can log it COMMAND="try-runtime \ --runtime $RUNTIME_BLOB_PATH \ + $TRY_RUNTIME_EXTRA_ARGS \ on-runtime-upgrade --checks=$CHECKS \ $EXTRA_FLAGS \ live --uri ${{ matrix.runtime.uri }}" - + # Echo the command before running it, for debugging purposes echo "Running command:" echo "$COMMAND" eval "$COMMAND" - # This will only run if all the tests in its "needs" array passed. # Add this as your required job, becuase if the matrix changes size (new things get added) diff --git a/.github/workflows/runtimes-matrix.json b/.github/workflows/runtimes-matrix.json index 172c53929c..3ded9e08f8 100644 --- a/.github/workflows/runtimes-matrix.json +++ b/.github/workflows/runtimes-matrix.json @@ -28,7 +28,8 @@ "path": "system-parachains/asset-hubs/asset-hub-kusama", "uri": "wss://kusama-asset-hub-rpc.polkadot.io:443", "is_relay": false, - "blocktime": 12000 + "blocktime": 12000, + "try_runtime_args": "--overwrite-state-version 1" }, { "name": "asset-hub-polkadot", @@ -36,7 +37,8 @@ "path": "system-parachains/asset-hubs/asset-hub-polkadot", "uri": "wss://polkadot-asset-hub-rpc.polkadot.io:443", "is_relay": false, - "blocktime": 12000 + "blocktime": 12000, + "try_runtime_args": "--overwrite-state-version 1" }, { "name": "bridge-hub-kusama", diff --git a/CHANGELOG.md b/CHANGELOG.md index a8051308f8..ec74140c0d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Correct weights of the scheduler pallet to avoid failing fellowship proposals ([polkadot-fellows/runtimes#614](https://github.com/polkadot-fellows/runtimes/pull/614)) +### Added + +- Enabled state-trie-migration for Kusama and Polkadot Asset Hubs ([polkadot-fellows/runtimes/pull/604](https://github.com/polkadot-fellows/runtimes/pull/604)) + ## [1.4.1] 26.02.2025 ### Fixed diff --git a/Cargo.lock b/Cargo.lock index dadec39626..35c7d0000e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -795,6 +795,7 @@ dependencies = [ "pallet-nfts-runtime-api", "pallet-proxy", "pallet-session", + "pallet-state-trie-migration", "pallet-timestamp", "pallet-transaction-payment", "pallet-transaction-payment-rpc-runtime-api", diff --git a/system-parachains/asset-hubs/asset-hub-kusama/Cargo.toml b/system-parachains/asset-hubs/asset-hub-kusama/Cargo.toml index 8dc09251b7..495f64e82c 100644 --- a/system-parachains/asset-hubs/asset-hub-kusama/Cargo.toml +++ b/system-parachains/asset-hubs/asset-hub-kusama/Cargo.toml @@ -45,7 +45,7 @@ pallet-nfts = { workspace = true } pallet-nfts-runtime-api = { workspace = true } pallet-proxy = { workspace = true } pallet-session = { workspace = true } -pallet-state-trie-migration = { optional = true, workspace = true } +pallet-state-trie-migration = { workspace = true } pallet-timestamp = { workspace = true } pallet-transaction-payment = { workspace = true } pallet-transaction-payment-rpc-runtime-api = { workspace = true } @@ -113,14 +113,6 @@ substrate-wasm-builder = { optional = true, workspace = true } [features] default = ["std"] -# When enabled the `state_version` is set to `1`. -# This means that the chain will start using the new state format. The migration is lazy, so -# it requires to write a storage value to use the new state format. To migrate all the other -# storage values that aren't touched the state migration pallet is added as well. -# This pallet will migrate the entire state, controlled through some account. -# -# This feature should be removed when the main-net will be migrated. -state-trie-version-1 = ["pallet-state-trie-migration"] runtime-benchmarks = [ "assets-common/runtime-benchmarks", "cumulus-pallet-parachain-system/runtime-benchmarks", diff --git a/system-parachains/asset-hubs/asset-hub-kusama/src/lib.rs b/system-parachains/asset-hubs/asset-hub-kusama/src/lib.rs index 7d3bb5724a..88d0b47ca6 100644 --- a/system-parachains/asset-hubs/asset-hub-kusama/src/lib.rs +++ b/system-parachains/asset-hubs/asset-hub-kusama/src/lib.rs @@ -115,7 +115,6 @@ impl_opaque_keys! { } } -#[cfg(feature = "state-trie-version-1")] #[sp_version::runtime_version] pub const VERSION: RuntimeVersion = RuntimeVersion { // Note: "statemine" is the legacy name for this chain. It has been renamed to @@ -131,22 +130,6 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { state_version: 1, }; -#[cfg(not(feature = "state-trie-version-1"))] -#[sp_version::runtime_version] -pub const VERSION: RuntimeVersion = RuntimeVersion { - // Note: "statemine" is the legacy name for this change. It has been renamed to - // "asset-hub-kusama". Many wallets/tools depend on the `spec_name`, so it remains "statemine" - // for the time being. Wallets/tools should update to treat "asset-hub-kusama" equally. - spec_name: create_runtime_str!("statemine"), - impl_name: create_runtime_str!("statemine"), - authoring_version: 1, - spec_version: 1_004_001, - impl_version: 0, - apis: RUNTIME_API_VERSIONS, - transaction_version: 15, - state_version: 0, -}; - /// The version information used to identify this runtime when compiled natively. #[cfg(feature = "std")] pub fn native_version() -> NativeVersion { @@ -1067,7 +1050,7 @@ construct_runtime!( PoolAssets: pallet_assets:: = 55, AssetConversion: pallet_asset_conversion = 56, - #[cfg(feature = "state-trie-version-1")] + // State trie migration pallet, only temporary. StateTrieMigration: pallet_state_trie_migration = 70, } ); @@ -1797,51 +1780,35 @@ cumulus_pallet_parachain_system::register_validate_block! { BlockExecutor = cumulus_pallet_aura_ext::BlockExecutor::, } -#[cfg(feature = "state-trie-version-1")] 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 = CENTS; pub const MigrationSignedDepositBase: Balance = 2_000 * CENTS; - pub const MigrationMaxKeyLen: u32 = 512; + pub const MigrationMaxKeyLen: u32 = 32; } -#[cfg(feature = "state-trie-version-1")] impl pallet_state_trie_migration::Config for Runtime { type RuntimeEvent = RuntimeEvent; type Currency = Balances; type RuntimeHoldReason = RuntimeHoldReason; type SignedDepositPerItem = MigrationSignedDepositPerItem; type SignedDepositBase = MigrationSignedDepositBase; - // An origin that can control the whole pallet: should be Root, or a part of your council. - type ControlOrigin = frame_system::EnsureSignedBy; - // specific account for the migration, can trigger the signed migrations. - type SignedFilter = frame_system::EnsureSignedBy; + // An origin that can control the whole pallet: should be Root or the Fellowship. + type ControlOrigin = EitherOfDiverse< + EnsureRoot, + EnsureXcm>, + >; + type SignedFilter = EnsureSignedBy; // Replace this with weight based on your runtime. type WeightInfo = pallet_state_trie_migration::weights::SubstrateWeight; type MaxKeyLen = MigrationMaxKeyLen; } - -#[cfg(feature = "state-trie-version-1")] -frame_support::ord_parameter_types! { +// Statemint State Migration Controller account controlled by parity.io. Can trigger migration. +// See bot code https://github.com/paritytech/polkadot-scripts/blob/master/src/services/state_trie_migration.ts +ord_parameter_types! { pub const MigController: AccountId = AccountId::from(hex_literal::hex!("8458ed39dc4b6f6c7255f7bc42be50c2967db126357c999d44e12ca7ac80dc52")); - pub const RootMigController: AccountId = AccountId::from(hex_literal::hex!("8458ed39dc4b6f6c7255f7bc42be50c2967db126357c999d44e12ca7ac80dc52")); -} - -#[cfg(feature = "state-trie-version-1")] -#[test] -fn ensure_key_ss58() { - use frame_support::traits::SortedMembers; - use sp_core::crypto::Ss58Codec; - let acc = - AccountId::from_ss58check("5F4EbSkZz18X36xhbsjvDNs6NuZ82HyYtq5UiJ1h9SBHJXZD").unwrap(); - //panic!("{:x?}", acc); - assert_eq!(acc, MigController::sorted_members()[0]); - let acc = - AccountId::from_ss58check("5F4EbSkZz18X36xhbsjvDNs6NuZ82HyYtq5UiJ1h9SBHJXZD").unwrap(); - assert_eq!(acc, RootMigController::sorted_members()[0]); - //panic!("{:x?}", acc); } #[cfg(test)] @@ -1917,4 +1884,13 @@ mod tests { ForeignAssetsAssetDeposit::get() ); } + + #[test] + fn ensure_key_ss58() { + use frame_support::traits::SortedMembers; + use sp_core::crypto::Ss58Codec; + let acc = + AccountId::from_ss58check("5F4EbSkZz18X36xhbsjvDNs6NuZ82HyYtq5UiJ1h9SBHJXZD").unwrap(); + assert_eq!(acc, MigController::sorted_members()[0]); + } } diff --git a/system-parachains/asset-hubs/asset-hub-polkadot/Cargo.toml b/system-parachains/asset-hubs/asset-hub-polkadot/Cargo.toml index a5407b281b..41fa2262d3 100644 --- a/system-parachains/asset-hubs/asset-hub-polkadot/Cargo.toml +++ b/system-parachains/asset-hubs/asset-hub-polkadot/Cargo.toml @@ -10,7 +10,7 @@ version.workspace = true [dependencies] codec = { features = ["derive", "max-encoded-len"], workspace = true } -hex-literal = { optional = true, workspace = true } +hex-literal = { workspace = true } log = { workspace = true } scale-info = { features = ["derive"], workspace = true } serde_json = { features = ["alloc"], workspace = true } @@ -45,6 +45,7 @@ pallet-nfts = { workspace = true } pallet-nfts-runtime-api = { workspace = true } pallet-proxy = { workspace = true } pallet-session = { workspace = true } +pallet-state-trie-migration = { workspace = true } pallet-timestamp = { workspace = true } pallet-transaction-payment = { workspace = true } pallet-transaction-payment-rpc-runtime-api = { workspace = true } @@ -104,7 +105,6 @@ pallet-xcm-bridge-hub-router = { workspace = true } snowbridge-router-primitives = { workspace = true } [dev-dependencies] -hex-literal = { workspace = true } asset-test-utils = { workspace = true } parachains-runtimes-test-utils = { workspace = true } @@ -124,7 +124,6 @@ runtime-benchmarks = [ "frame-support/runtime-benchmarks", "frame-system-benchmarking/runtime-benchmarks", "frame-system/runtime-benchmarks", - "hex-literal", "kusama-runtime-constants/runtime-benchmarks", "pallet-asset-conversion/runtime-benchmarks", "pallet-assets/runtime-benchmarks", @@ -134,6 +133,7 @@ runtime-benchmarks = [ "pallet-multisig/runtime-benchmarks", "pallet-nfts/runtime-benchmarks", "pallet-proxy/runtime-benchmarks", + "pallet-state-trie-migration/runtime-benchmarks", "pallet-timestamp/runtime-benchmarks", "pallet-uniques/runtime-benchmarks", "pallet-utility/runtime-benchmarks", @@ -173,6 +173,7 @@ try-runtime = [ "pallet-nfts/try-runtime", "pallet-proxy/try-runtime", "pallet-session/try-runtime", + "pallet-state-trie-migration/try-runtime", "pallet-timestamp/try-runtime", "pallet-transaction-payment/try-runtime", "pallet-uniques/try-runtime", @@ -222,6 +223,7 @@ std = [ "pallet-nfts/std", "pallet-proxy/std", "pallet-session/std", + "pallet-state-trie-migration/std", "pallet-timestamp/std", "pallet-transaction-payment-rpc-runtime-api/std", "pallet-transaction-payment/std", diff --git a/system-parachains/asset-hubs/asset-hub-polkadot/src/lib.rs b/system-parachains/asset-hubs/asset-hub-polkadot/src/lib.rs index a5c1858508..5c69c8491f 100644 --- a/system-parachains/asset-hubs/asset-hub-polkadot/src/lib.rs +++ b/system-parachains/asset-hubs/asset-hub-polkadot/src/lib.rs @@ -97,7 +97,7 @@ use frame_support::{ construct_runtime, dispatch::DispatchClass, genesis_builder_helper::{build_state, get_preset}, - parameter_types, + ord_parameter_types, parameter_types, traits::{ fungible, fungibles, tokens::imbalance::ResolveAssetTo, AsEnsureOriginWithArg, ConstBool, ConstU32, ConstU64, ConstU8, Contains, EitherOfDiverse, Equals, EverythingBut, @@ -108,7 +108,7 @@ use frame_support::{ }; use frame_system::{ limits::{BlockLength, BlockWeights}, - EnsureRoot, EnsureSigned, + EnsureRoot, EnsureSigned, EnsureSignedBy, }; use pallet_nfts::PalletFeatures; use parachains_common::{ @@ -159,7 +159,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 15, - state_version: 0, + state_version: 1, }; /// The version information used to identify this runtime when compiled natively. @@ -1008,6 +1008,9 @@ construct_runtime!( ForeignAssets: pallet_assets:: = 53, PoolAssets: pallet_assets:: = 54, AssetConversion: pallet_asset_conversion = 55, + + // State trie migration pallet, only temporary. + StateTrieMigration: pallet_state_trie_migration = 70, } ); @@ -1756,6 +1759,37 @@ cumulus_pallet_parachain_system::register_validate_block! { BlockExecutor = cumulus_pallet_aura_ext::BlockExecutor::, } +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 = CENTS; + pub const MigrationSignedDepositBase: Balance = 2_000 * CENTS; + pub const MigrationMaxKeyLen: u32 = 32; +} + +impl pallet_state_trie_migration::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type Currency = Balances; + type RuntimeHoldReason = RuntimeHoldReason; + type SignedDepositPerItem = MigrationSignedDepositPerItem; + type SignedDepositBase = MigrationSignedDepositBase; + // An origin that can control the whole pallet: should be Root, or the fellowship. + type ControlOrigin = EitherOfDiverse< + EnsureRoot, + EnsureXcm>, + >; + type SignedFilter = EnsureSignedBy; + + // Replace this with weight based on your runtime. + type WeightInfo = pallet_state_trie_migration::weights::SubstrateWeight; + + type MaxKeyLen = MigrationMaxKeyLen; +} +// Statemint State Migration Controller account controlled by parity.io. Can trigger migration. +// See bot code https://github.com/paritytech/polkadot-scripts/blob/master/src/services/state_trie_migration.ts +ord_parameter_types! { + pub const MigController: AccountId = AccountId::from(hex_literal::hex!("8458ed39dc4b6f6c7255f7bc42be50c2967db126357c999d44e12ca7ac80dc52")); +} + #[cfg(test)] mod tests { use super::*; @@ -1829,4 +1863,13 @@ mod tests { ForeignAssetsAssetDeposit::get() ); } + + #[test] + fn ensure_key_ss58() { + use frame_support::traits::SortedMembers; + use sp_core::crypto::Ss58Codec; + let acc = + AccountId::from_ss58check("5F4EbSkZz18X36xhbsjvDNs6NuZ82HyYtq5UiJ1h9SBHJXZD").unwrap(); + assert_eq!(acc, MigController::sorted_members()[0]); + } }