-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Kusama state version switch and migration. #7015
Changes from 8 commits
b790797
4a8a379
dcdefbe
a69b387
707b986
f4bc170
925074a
efa685a
bdd9ae3
9f4c073
18cc436
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -133,7 +133,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { | |
#[cfg(feature = "disable-runtime-api")] | ||
apis: sp_version::create_apis_vec![[]], | ||
transaction_version: 21, | ||
state_version: 0, | ||
state_version: 1, | ||
}; | ||
|
||
/// The BABE epoch configuration at genesis. | ||
|
@@ -1306,6 +1306,26 @@ impl pallet_nomination_pools::Config for Runtime { | |
type MaxPointsToBalance = MaxPointsToBalance; | ||
} | ||
|
||
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 = 20 * CENTS * 100; | ||
pub const MigrationMaxKeyLen: u32 = 512; | ||
} | ||
|
||
impl pallet_state_trie_migration::Config for Runtime { | ||
type RuntimeEvent = RuntimeEvent; | ||
type Currency = Balances; | ||
type SignedDepositPerItem = MigrationSignedDepositPerItem; | ||
type SignedDepositBase = MigrationSignedDepositBase; | ||
type ControlOrigin = EnsureRoot<AccountId>; | ||
type SignedFilter = frame_support::traits::NeverEnsureOrigin<AccountId>; | ||
|
||
// Use same weights as substrate ones. | ||
type WeightInfo = pallet_state_trie_migration::weights::SubstrateWeight<Runtime>; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would be more appropriate to benchmark it properly in this runtime. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, not sure how much change it will be to do so (in theory there is no reason to see significant change: only wasm bin size may interfere a tiny bit maybe). |
||
type MaxKeyLen = MigrationMaxKeyLen; | ||
} | ||
|
||
construct_runtime! { | ||
pub enum Runtime where | ||
Block = Block, | ||
|
@@ -1423,6 +1443,9 @@ construct_runtime! { | |
Auctions: auctions::{Pallet, Call, Storage, Event<T>} = 72, | ||
Crowdloan: crowdloan::{Pallet, Call, Storage, Event<T>} = 73, | ||
|
||
// State trie migration pallet, only temporary. | ||
StateTrieMigration: pallet_state_trie_migration = 98, | ||
|
||
// Pallet for sending XCM. | ||
XcmPallet: pallet_xcm::{Pallet, Call, Storage, Event<T>, Origin, Config} = 99, | ||
} | ||
|
@@ -1484,7 +1507,7 @@ pub mod migrations { | |
); | ||
|
||
/// Unreleased migrations. Add new ones here: | ||
pub type Unreleased = (); | ||
pub type Unreleased = (init_state_migration::InitMigrate,); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Your comment:
would be suited here so whoever does the move from |
||
|
||
/// Unchecked extrinsic type as expected by this runtime. | ||
|
@@ -2358,3 +2381,46 @@ mod remote_tests { | |
}); | ||
} | ||
} | ||
|
||
mod init_state_migration { | ||
liamaharon marked this conversation as resolved.
Show resolved
Hide resolved
|
||
use super::Runtime; | ||
use frame_support::traits::OnRuntimeUpgrade; | ||
use pallet_state_trie_migration::{AutoLimits, MigrationLimits, MigrationProcess}; | ||
#[cfg(not(feature = "std"))] | ||
use sp_std::prelude::*; | ||
|
||
/// Initialize an automatic migration process. | ||
pub struct InitMigrate; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You need to add it to the list of migrations. |
||
impl OnRuntimeUpgrade for InitMigrate { | ||
#[cfg(feature = "try-runtime")] | ||
fn pre_upgrade() -> Result<Vec<u8>, &'static str> { | ||
frame_support::ensure!( | ||
AutoLimits::<Runtime>::get().is_none(), | ||
"Automigration already started." | ||
); | ||
Ok(Default::default()) | ||
} | ||
|
||
fn on_runtime_upgrade() -> frame_support::weights::Weight { | ||
if MigrationProcess::<Runtime>::get() == Default::default() && | ||
AutoLimits::<Runtime>::get().is_none() | ||
{ | ||
AutoLimits::<Runtime>::put(Some(MigrationLimits { item: 160, size: 204800 })); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Some comment about how this number is chosen would be good. |
||
log::info!("Automatic trie migration started."); | ||
<Runtime as frame_system::Config>::DbWeight::get().reads_writes(2, 1) | ||
} else { | ||
log::info!("Automatic trie migration not started."); | ||
<Runtime as frame_system::Config>::DbWeight::get().reads(2) | ||
} | ||
} | ||
|
||
#[cfg(feature = "try-runtime")] | ||
fn post_upgrade(_state: Vec<u8>) -> Result<(), &'static str> { | ||
frame_support::ensure!( | ||
AutoLimits::<Runtime>::get().is_some(), | ||
"Automigration started." | ||
); | ||
Ok(()) | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure? it would be hard to acquire.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not very comfortable with having a privilege account.
Actually I recently reconsider bringing back the inherent version of the migration (the main issue was the code was a bit everywhere and less cleanly separated, but looking backward, it would have really feel more comfortable to me).