From 936b1707baabf06bf7b0bc57a0179e0526ad34d4 Mon Sep 17 00:00:00 2001 From: Bryan Chen Date: Sun, 21 Jun 2020 16:35:22 +1200 Subject: [PATCH 1/2] update scheduler --- Cargo.lock | 4 ++-- runtime/common/src/parachains.rs | 2 +- runtime/kusama/src/lib.rs | 3 +++ runtime/polkadot/src/lib.rs | 3 +++ runtime/westend/src/lib.rs | 3 +++ 5 files changed, 12 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 55b417c691fb..a1b5111acf21 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3873,9 +3873,9 @@ dependencies = [ [[package]] name = "parity-scale-codec" -version = "1.3.0" +version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "329c8f7f4244ddb5c37c103641027a76c530e65e8e4b8240b29f81ea40508b17" +checksum = "a74f02beb35d47e0706155c9eac554b50c671e0d868fe8296bcdf44a9a4847bf" dependencies = [ "arrayvec 0.5.1", "bitvec", diff --git a/runtime/common/src/parachains.rs b/runtime/common/src/parachains.rs index ef67adb031f1..04b78024567f 100644 --- a/runtime/common/src/parachains.rs +++ b/runtime/common/src/parachains.rs @@ -300,7 +300,7 @@ pub trait Trait: CreateSignedTransaction> + attestations::Trait + ses } /// Origin for the parachains module. -#[derive(PartialEq, Eq, Clone)] +#[derive(PartialEq, Eq, Clone, Encode, Decode)] #[cfg_attr(feature = "std", derive(Debug))] pub enum Origin { /// It comes from a parachain. diff --git a/runtime/kusama/src/lib.rs b/runtime/kusama/src/lib.rs index 84376032372d..f0e5852c0fea 100644 --- a/runtime/kusama/src/lib.rs +++ b/runtime/kusama/src/lib.rs @@ -149,8 +149,10 @@ impl system::Trait for Runtime { impl scheduler::Trait for Runtime { type Event = Event; type Origin = Origin; + type PalletsOrigin = OriginCaller; type Call = Call; type MaximumWeight = MaximumBlockWeight; + type ScheduleOrigin = EnsureRoot; } parameter_types! { @@ -365,6 +367,7 @@ impl democracy::Trait for Runtime { type PreimageByteDeposit = PreimageByteDeposit; type Slash = Treasury; type Scheduler = Scheduler; + type PalletsOrigin = OriginCaller; type MaxVotes = MaxVotes; type OperationalPreimageOrigin = collective::EnsureMember; } diff --git a/runtime/polkadot/src/lib.rs b/runtime/polkadot/src/lib.rs index 6b05529f61d4..ba3b90fae506 100644 --- a/runtime/polkadot/src/lib.rs +++ b/runtime/polkadot/src/lib.rs @@ -175,8 +175,10 @@ impl system::Trait for Runtime { impl scheduler::Trait for Runtime { type Event = Event; type Origin = Origin; + type PalletsOrigin = OriginCaller; type Call = Call; type MaximumWeight = MaximumBlockWeight; + type ScheduleOrigin = EnsureRoot; } parameter_types! { @@ -411,6 +413,7 @@ impl democracy::Trait for Runtime { type OperationalPreimageOrigin = collective::EnsureMember; type Slash = Treasury; type Scheduler = Scheduler; + type PalletsOrigin = OriginCaller; type MaxVotes = MaxVotes; } diff --git a/runtime/westend/src/lib.rs b/runtime/westend/src/lib.rs index 4214ece1c4a6..3844a6913985 100644 --- a/runtime/westend/src/lib.rs +++ b/runtime/westend/src/lib.rs @@ -58,6 +58,7 @@ use im_online::sr25519::AuthorityId as ImOnlineId; use authority_discovery_primitives::AuthorityId as AuthorityDiscoveryId; use transaction_payment_rpc_runtime_api::RuntimeDispatchInfo; use session::historical as session_historical; +use system::EnsureRoot; #[cfg(feature = "std")] pub use staking::StakerStatus; @@ -138,8 +139,10 @@ impl system::Trait for Runtime { impl scheduler::Trait for Runtime { type Event = Event; type Origin = Origin; + type PalletsOrigin = OriginCaller; type Call = Call; type MaximumWeight = MaximumBlockWeight; + type ScheduleOrigin = EnsureRoot; } parameter_types! { From 3703dcea2d4d6d9bf4d7736bdc22be3bb6cde7f3 Mon Sep 17 00:00:00 2001 From: Bryan Chen Date: Sat, 27 Jun 2020 12:59:51 +1200 Subject: [PATCH 2/2] add runtime upgrade --- runtime/kusama/src/lib.rs | 20 +++++++++++++++++++- runtime/polkadot/src/lib.rs | 20 +++++++++++++++++++- 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/runtime/kusama/src/lib.rs b/runtime/kusama/src/lib.rs index 40478fe0d86d..daa19477b593 100644 --- a/runtime/kusama/src/lib.rs +++ b/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/runtime/polkadot/src/lib.rs b/runtime/polkadot/src/lib.rs index 599912ea838c..b21ad3bdbc85 100644 --- a/runtime/polkadot/src/lib.rs +++ b/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;