From a9480d9fe88224ee647279ff58d0982806d6eee1 Mon Sep 17 00:00:00 2001 From: Bryan Chen Date: Sat, 27 Jun 2020 12:59:51 +1200 Subject: [PATCH] add runtime upgrade --- polkadot/runtime/kusama/src/lib.rs | 20 +++++++++++++++++++- polkadot/runtime/polkadot/src/lib.rs | 20 +++++++++++++++++++- 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/polkadot/runtime/kusama/src/lib.rs b/polkadot/runtime/kusama/src/lib.rs index 40478fe0d8..daa19477b5 100644 --- a/polkadot/runtime/kusama/src/lib.rs +++ b/polkadot/runtime/kusama/src/lib.rs @@ -883,6 +883,17 @@ impl proxy::Trait for Runtime { type MaxProxies = MaxProxies; } +pub struct CustomOnRuntimeUpgrade; + impl frame_support::traits::OnRuntimeUpgrade for CustomOnRuntimeUpgrade { + fn on_runtime_upgrade() -> frame_support::weights::Weight { + if scheduler::Module::::migrate_v1_to_t2() { + ::MaximumBlockWeight::get() + } else { + ::DbWeight::get().reads(1) + } + } +} + construct_runtime! { pub enum Runtime where Block = Block, @@ -984,7 +995,14 @@ pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; /// Executive: handles dispatch to the various modules. -pub type Executive = executive::Executive, Runtime, AllModules>; +pub type Executive = executive::Executive< + Runtime, + Block, + system::ChainContext, + Runtime, + AllModules, + CustomOnRuntimeUpgrade +>; /// The payload being signed in the transactions. pub type SignedPayload = generic::SignedPayload; diff --git a/polkadot/runtime/polkadot/src/lib.rs b/polkadot/runtime/polkadot/src/lib.rs index 599912ea83..b21ad3bdbc 100644 --- a/polkadot/runtime/polkadot/src/lib.rs +++ b/polkadot/runtime/polkadot/src/lib.rs @@ -865,6 +865,17 @@ impl proxy::Trait for Runtime { type MaxProxies = MaxProxies; } +pub struct CustomOnRuntimeUpgrade; + impl frame_support::traits::OnRuntimeUpgrade for CustomOnRuntimeUpgrade { + fn on_runtime_upgrade() -> frame_support::weights::Weight { + if scheduler::Module::::migrate_v1_to_t2() { + ::MaximumBlockWeight::get() + } else { + ::DbWeight::get().reads(1) + } + } +} + construct_runtime! { pub enum Runtime where Block = Block, @@ -962,7 +973,14 @@ pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; /// Executive: handles dispatch to the various modules. -pub type Executive = executive::Executive, Runtime, AllModules>; +pub type Executive = executive::Executive< + Runtime, + Block, + system::ChainContext, + Runtime, + AllModules, + CustomOnRuntimeUpgrade +>; /// The payload being signed in transactions. pub type SignedPayload = generic::SignedPayload;