Skip to content
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
81b485f
Remove `state-trie-version-1` feature and related code.
nkpar Feb 17, 2025
cb23f58
Refactor runtime configuration for improved clarity
nkpar Feb 17, 2025
f27db8b
Revert "Refactor runtime configuration for improved clarity"
nkpar Feb 17, 2025
9ae4509
Update ControlOrigin to use EnsureRoot for migration control
nkpar Feb 17, 2025
250f311
Update lib.rs
nkpar Feb 18, 2025
ae405b1
Update lib.rs
nkpar Feb 19, 2025
c61b433
Update lib.rs
nkpar Feb 19, 2025
4f6fe69
Update lib.rs
nkpar Feb 20, 2025
20ad36b
Update spec_version across runtimes to 1_004_001
nkpar Feb 20, 2025
b0fce78
Updating changelog
nkpar Feb 20, 2025
75f462f
fixed changelog, updated comment on Statemint account
nkpar Feb 24, 2025
4ea3335
Added state trie migration for Polkadot AH
nkpar Feb 25, 2025
c2781cb
Update CHANGELOG.md
nkpar Feb 25, 2025
ab1101d
Added missed test
nkpar Feb 25, 2025
b6d5a81
Update system-parachains/asset-hubs/asset-hub-kusama/src/lib.rs
nkpar Feb 25, 2025
6eacb41
Add temporary state version overwrite for asset-hub-kusama and asset-…
nkpar Feb 25, 2025
dfd7ba4
Putting flag in the right position
nkpar Feb 25, 2025
268e01e
Update check-migrations.yml
nkpar Feb 25, 2025
4b97b77
Improved comment to Migration Controller
nkpar Feb 26, 2025
90e258b
adressed review comments and removed rootmigration controller
nkpar Feb 26, 2025
6a0b65f
Review fixes: simplify passing arguments for runtime
nkpar Feb 26, 2025
c32260d
review fixes: clarity in comments, version and env set fixes
nkpar Feb 26, 2025
5605f19
Update lib.rs
nkpar Feb 26, 2025
428b0dd
more clarity in comments
nkpar Feb 26, 2025
d392124
Improve comments for State Migration Controller, adding warnings and …
nkpar Feb 27, 2025
1f3b936
Enhance comments in migration configuration to clarify usage and warn…
nkpar Feb 27, 2025
3e996e2
Merge branch 'main' into state-trie-migrations-ah
nkpar Feb 27, 2025
44318d4
Merge branch 'main' into state-trie-migrations-ah
nkpar Mar 3, 2025
0bf4056
Remove unused dependency 'hex-literal' from Cargo.toml
nkpar Mar 3, 2025
7ce1306
Update system-parachains/asset-hubs/asset-hub-kusama/src/lib.rs
nkpar Mar 4, 2025
6de92e1
Update system-parachains/asset-hubs/asset-hub-polkadot/src/lib.rs
nkpar Mar 4, 2025
170c6af
Update CHANGELOG.md
nkpar Mar 4, 2025
efc06ac
Merge branch 'main' into state-trie-migrations-ah
nkpar Mar 4, 2025
6ba3517
Update CHANGELOG.md
nkpar Mar 4, 2025
4f678bd
Update CHANGELOG.md
nkpar Mar 4, 2025
3276a66
Removed warnign as absolute
nkpar Mar 4, 2025
094e930
rust fmt (nightly)
nkpar Mar 4, 2025
675bd19
Merge branch 'main' into state-trie-migrations-ah
nkpar Mar 5, 2025
c792ad7
Update system-parachains/asset-hubs/asset-hub-kusama/src/lib.rs
nkpar Mar 6, 2025
b001639
Update system-parachains/asset-hubs/asset-hub-polkadot/src/lib.rs
nkpar Mar 6, 2025
37a2369
Update system-parachains/asset-hubs/asset-hub-kusama/src/lib.rs
nkpar Mar 6, 2025
8cbaf0d
Update system-parachains/asset-hubs/asset-hub-polkadot/src/lib.rs
nkpar Mar 6, 2025
5517df7
Update .github/workflows/runtimes-matrix.json
nkpar Mar 6, 2025
bff122f
Update .github/workflows/check-migrations.yml
nkpar Mar 6, 2025
c7fde57
Update .github/workflows/check-migrations.yml
nkpar Mar 6, 2025
ebdaff8
naming improvement
nkpar Mar 6, 2025
64c9805
Update .github/workflows/check-migrations.yml
bkchr Mar 6, 2025
7ee2abb
Update .github/workflows/check-migrations.yml
bkchr Mar 6, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions .github/workflows/check-migrations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ jobs:

EXTRA_FLAGS+=" --blocktime ${{ matrix.runtime.blocktime }} "

# Add the overwrite_state_version flag if it exists
RUNTIME_EXTRA_ARGS="${{ matrix.runtime.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
Expand All @@ -87,6 +90,7 @@ jobs:
echo "Enabling the spec version check since we are releasing"
fi

echo "Runtime extra args: $RUNTIME_EXTRA_ARGS"
echo "Flags: $EXTRA_FLAGS"
echo "Checks: $CHECKS"

Expand Down Expand Up @@ -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 \
$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)
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/runtimes-matrix.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,17 @@
"path": "system-parachains/asset-hubs/asset-hub-kusama",
"uri": "wss://kusama-asset-hub-rpc.polkadot.io:443",
"is_relay": false,
"blocktime": 12000
"blocktime": 12000,
"runtime_args": "--overwrite-state-version 1"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need this? The on chain version is still 0?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bkchr As I updated state version in this PR - otherwise check will fail

Copy link
Member

@ggwpez ggwpez Mar 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The externalities initialize with the state version of the snapshot (0) and then at the end of the block it is 1 and fails to match the state root. Now instead we initialise with 1.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we building a block because of the possible multi block migrations?

},
{
"name": "asset-hub-polkadot",
"package": "asset-hub-polkadot-runtime",
"path": "system-parachains/asset-hubs/asset-hub-polkadot",
"uri": "wss://polkadot-asset-hub-rpc.polkadot.io:443",
"is_relay": false,
"blocktime": 12000
"blocktime": 12000,
"runtime_args": "--overwrite-state-version 1"
},
{
"name": "bridge-hub-kusama",
Expand Down
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@ Changelog for the runtimes governed by the Polkadot Fellowship.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## [unreleased]

### Fixed

### Added

- Enabled state-trie-migration for Kusama and Polkadot Asset Hubs ([polkadot-fellows/runtimes/pull/604](https://github.com/polkadot-fellows/runtimes/pull/604))

### Changed

## [1.4.0] 07.02.2025

### Fixed
Expand Down
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion relay/kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("kusama"),
impl_name: create_runtime_str!("parity-kusama"),
authoring_version: 2,
spec_version: 1_004_000,
spec_version: 1_004_001,
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 26,
Expand Down
2 changes: 1 addition & 1 deletion relay/polkadot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("polkadot"),
impl_name: create_runtime_str!("parity-polkadot"),
authoring_version: 0,
spec_version: 1_004_000,
spec_version: 1_004_001,
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 26,
Expand Down
10 changes: 1 addition & 9 deletions system-parachains/asset-hubs/asset-hub-kusama/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down Expand Up @@ -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",
Expand Down
65 changes: 21 additions & 44 deletions system-parachains/asset-hubs/asset-hub-kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,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
Expand All @@ -121,29 +120,13 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("statemine"),
impl_name: create_runtime_str!("statemine"),
authoring_version: 1,
spec_version: 1_004_000,
spec_version: 1_004_001,
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 15,
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_000,
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 {
Expand Down Expand Up @@ -1020,7 +1003,7 @@ construct_runtime!(
PoolAssets: pallet_assets::<Instance3> = 55,
AssetConversion: pallet_asset_conversion = 56,

#[cfg(feature = "state-trie-version-1")]
// State trie migration pallet, only temporary.
StateTrieMigration: pallet_state_trie_migration = 70,
}
);
Expand Down Expand Up @@ -1749,51 +1732,35 @@ cumulus_pallet_parachain_system::register_validate_block! {
BlockExecutor = cumulus_pallet_aura_ext::BlockExecutor::<Runtime, Executive>,
}

#[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;
}

#[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<RootMigController, AccountId>;
// specific account for the migration, can trigger the signed migrations.
type SignedFilter = frame_system::EnsureSignedBy<MigController, AccountId>;
/// An origin that can control the whole pallet: should be Root or the Fellowship.
type ControlOrigin = EitherOfDiverse<
EnsureRoot<AccountId>,
EnsureXcm<IsVoiceOfBody<FellowshipLocation, FellowsBodyId>>,
>;
/// specific account for the migration, can trigger the signed migrations.
type SignedFilter = EnsureSignedBy<MigController, AccountId>;

// Replace this with weight based on your runtime.
type WeightInfo = pallet_state_trie_migration::weights::SubstrateWeight<Runtime>;

type MaxKeyLen = MigrationMaxKeyLen;
}

#[cfg(feature = "state-trie-version-1")]
frame_support::ord_parameter_types! {
// Statemint State Migration Controller. Controlled by parity.io.
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)]
Expand Down Expand Up @@ -1869,4 +1836,14 @@ 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();
//panic!("{:x?}", acc);
assert_eq!(acc, MigController::sorted_members()[0]);
}
}
8 changes: 5 additions & 3 deletions system-parachains/asset-hubs/asset-hub-polkadot/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down Expand Up @@ -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 }
Expand Down Expand Up @@ -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 }

Expand All @@ -124,7 +124,6 @@ runtime-benchmarks = [
"frame-support/runtime-benchmarks",
"frame-system-benchmarking/runtime-benchmarks",
"frame-system/runtime-benchmarks",
"hex-literal",
"pallet-asset-conversion/runtime-benchmarks",
"pallet-assets/runtime-benchmarks",
"pallet-balances/runtime-benchmarks",
Expand All @@ -133,6 +132,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",
Expand Down Expand Up @@ -170,6 +170,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",
Expand Down Expand Up @@ -219,6 +220,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",
Expand Down
Loading
Loading