mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 05:51:02 +00:00
Statemine state migration runtime changes. (#1743)
* init, using polkadot master * version update * weights copy pasted from substrate * feature gate migration * changes from reviews * Change controller addresses. * fix * rename feature to state-trie-version-1
This commit is contained in:
Generated
+18
@@ -6134,6 +6134,23 @@ dependencies = [
|
|||||||
"sp-arithmetic",
|
"sp-arithmetic",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "pallet-state-trie-migration"
|
||||||
|
version = "4.0.0-dev"
|
||||||
|
source = "git+https://github.com/paritytech/substrate?branch=master#f447beec6eefbf452520b90cb0d199eaaf114342"
|
||||||
|
dependencies = [
|
||||||
|
"frame-benchmarking",
|
||||||
|
"frame-support",
|
||||||
|
"frame-system",
|
||||||
|
"log",
|
||||||
|
"parity-scale-codec",
|
||||||
|
"scale-info",
|
||||||
|
"sp-core",
|
||||||
|
"sp-io",
|
||||||
|
"sp-runtime",
|
||||||
|
"sp-std",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pallet-sudo"
|
name = "pallet-sudo"
|
||||||
version = "4.0.0-dev"
|
version = "4.0.0-dev"
|
||||||
@@ -11525,6 +11542,7 @@ dependencies = [
|
|||||||
"pallet-multisig",
|
"pallet-multisig",
|
||||||
"pallet-proxy",
|
"pallet-proxy",
|
||||||
"pallet-session",
|
"pallet-session",
|
||||||
|
"pallet-state-trie-migration",
|
||||||
"pallet-timestamp",
|
"pallet-timestamp",
|
||||||
"pallet-transaction-payment",
|
"pallet-transaction-payment",
|
||||||
"pallet-transaction-payment-rpc-runtime-api",
|
"pallet-transaction-payment-rpc-runtime-api",
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ description = "Kusama variant of Statemint parachain runtime"
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive", "max-encoded-len"] }
|
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive", "max-encoded-len"] }
|
||||||
hex-literal = { version = "0.3.4", optional = true }
|
hex-literal = { version = "0.3.4" }
|
||||||
log = { version = "0.4.17", default-features = false }
|
log = { version = "0.4.17", default-features = false }
|
||||||
scale-info = { version = "2.3.0", default-features = false, features = ["derive"] }
|
scale-info = { version = "2.3.0", default-features = false, features = ["derive"] }
|
||||||
smallvec = "1.10.0"
|
smallvec = "1.10.0"
|
||||||
@@ -44,6 +44,7 @@ sp-session = { git = "https://github.com/paritytech/substrate", default-features
|
|||||||
sp-std = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
|
sp-std = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
|
||||||
sp-transaction-pool = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
|
sp-transaction-pool = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
|
||||||
sp-version = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
|
sp-version = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
|
||||||
|
pallet-state-trie-migration = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master", optional = true }
|
||||||
|
|
||||||
# Polkadot
|
# Polkadot
|
||||||
kusama-runtime-constants = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" }
|
kusama-runtime-constants = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" }
|
||||||
@@ -72,7 +73,6 @@ pallet-xcm-benchmarks = { git = "https://github.com/paritytech/polkadot", branch
|
|||||||
|
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
hex-literal = "0.3.4"
|
|
||||||
asset-test-utils = { path = "../test-utils"}
|
asset-test-utils = { path = "../test-utils"}
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
@@ -80,8 +80,15 @@ substrate-wasm-builder = { git = "https://github.com/paritytech/substrate", bran
|
|||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = [ "std" ]
|
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 = [
|
runtime-benchmarks = [
|
||||||
"hex-literal",
|
|
||||||
"frame-benchmarking/runtime-benchmarks",
|
"frame-benchmarking/runtime-benchmarks",
|
||||||
"frame-support/runtime-benchmarks",
|
"frame-support/runtime-benchmarks",
|
||||||
"frame-system-benchmarking/runtime-benchmarks",
|
"frame-system-benchmarking/runtime-benchmarks",
|
||||||
@@ -100,6 +107,7 @@ runtime-benchmarks = [
|
|||||||
"pallet-collator-selection/runtime-benchmarks",
|
"pallet-collator-selection/runtime-benchmarks",
|
||||||
"cumulus-pallet-xcmp-queue/runtime-benchmarks",
|
"cumulus-pallet-xcmp-queue/runtime-benchmarks",
|
||||||
"pallet-xcm-benchmarks/runtime-benchmarks",
|
"pallet-xcm-benchmarks/runtime-benchmarks",
|
||||||
|
"pallet-state-trie-migration/runtime-benchmarks",
|
||||||
]
|
]
|
||||||
try-runtime = [
|
try-runtime = [
|
||||||
"cumulus-pallet-aura-ext/try-runtime",
|
"cumulus-pallet-aura-ext/try-runtime",
|
||||||
@@ -125,6 +133,7 @@ try-runtime = [
|
|||||||
"pallet-utility/try-runtime",
|
"pallet-utility/try-runtime",
|
||||||
"pallet-xcm/try-runtime",
|
"pallet-xcm/try-runtime",
|
||||||
"parachain-info/try-runtime",
|
"parachain-info/try-runtime",
|
||||||
|
"pallet-state-trie-migration/try-runtime",
|
||||||
]
|
]
|
||||||
std = [
|
std = [
|
||||||
"codec/std",
|
"codec/std",
|
||||||
@@ -143,6 +152,7 @@ std = [
|
|||||||
"pallet-multisig/std",
|
"pallet-multisig/std",
|
||||||
"pallet-proxy/std",
|
"pallet-proxy/std",
|
||||||
"pallet-session/std",
|
"pallet-session/std",
|
||||||
|
"pallet-state-trie-migration/std",
|
||||||
"pallet-timestamp/std",
|
"pallet-timestamp/std",
|
||||||
"pallet-transaction-payment-rpc-runtime-api/std",
|
"pallet-transaction-payment-rpc-runtime-api/std",
|
||||||
"pallet-transaction-payment/std",
|
"pallet-transaction-payment/std",
|
||||||
|
|||||||
@@ -82,6 +82,20 @@ impl_opaque_keys! {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "state-trie-version-1")]
|
||||||
|
#[sp_version::runtime_version]
|
||||||
|
pub const VERSION: RuntimeVersion = RuntimeVersion {
|
||||||
|
spec_name: create_runtime_str!("statemine"),
|
||||||
|
impl_name: create_runtime_str!("statemine"),
|
||||||
|
authoring_version: 1,
|
||||||
|
spec_version: 9300,
|
||||||
|
impl_version: 0,
|
||||||
|
apis: RUNTIME_API_VERSIONS,
|
||||||
|
transaction_version: 8,
|
||||||
|
state_version: 1,
|
||||||
|
};
|
||||||
|
|
||||||
|
#[cfg(not(feature = "state-trie-version-1"))]
|
||||||
#[sp_version::runtime_version]
|
#[sp_version::runtime_version]
|
||||||
pub const VERSION: RuntimeVersion = RuntimeVersion {
|
pub const VERSION: RuntimeVersion = RuntimeVersion {
|
||||||
spec_name: create_runtime_str!("statemine"),
|
spec_name: create_runtime_str!("statemine"),
|
||||||
@@ -596,6 +610,9 @@ construct_runtime!(
|
|||||||
// The main stage.
|
// The main stage.
|
||||||
Assets: pallet_assets::{Pallet, Call, Storage, Event<T>} = 50,
|
Assets: pallet_assets::{Pallet, Call, Storage, Event<T>} = 50,
|
||||||
Uniques: pallet_uniques::{Pallet, Call, Storage, Event<T>} = 51,
|
Uniques: pallet_uniques::{Pallet, Call, Storage, Event<T>} = 51,
|
||||||
|
|
||||||
|
#[cfg(feature = "state-trie-version-1")]
|
||||||
|
StateTrieMigration: pallet_state_trie_migration = 70,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -979,3 +996,49 @@ cumulus_pallet_parachain_system::register_validate_block! {
|
|||||||
BlockExecutor = cumulus_pallet_aura_ext::BlockExecutor::<Runtime, Executive>,
|
BlockExecutor = cumulus_pallet_aura_ext::BlockExecutor::<Runtime, Executive>,
|
||||||
CheckInherents = CheckInherents,
|
CheckInherents = CheckInherents,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[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 = 1 * 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 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>;
|
||||||
|
|
||||||
|
// 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! {
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user