From 5d643008fb223a673ed6fbf1e1683d0ee4e79c0d Mon Sep 17 00:00:00 2001 From: jasl Date: Fri, 15 Jul 2022 20:34:57 +0800 Subject: [PATCH] Apply runtime changes --- runtime/khala/src/lib.rs | 24 +++++++++++++----------- runtime/khala/src/migrations.rs | 17 +++++++++++++++++ runtime/phala/src/lib.rs | 24 +++++++++++++----------- runtime/phala/src/migrations.rs | 1 + runtime/rhala/src/lib.rs | 24 +++++++++++++----------- runtime/rhala/src/migrations.rs | 17 +++++++++++++++++ runtime/shell/src/lib.rs | 2 ++ runtime/thala/src/lib.rs | 24 +++++++++++++----------- runtime/thala/src/migrations.rs | 17 +++++++++++++++++ 9 files changed, 106 insertions(+), 44 deletions(-) diff --git a/runtime/khala/src/lib.rs b/runtime/khala/src/lib.rs index ea70b323..1d0d347d 100644 --- a/runtime/khala/src/lib.rs +++ b/runtime/khala/src/lib.rs @@ -48,6 +48,7 @@ mod migrations; mod msg_routing; use codec::{Decode, Encode, MaxEncodedLen}; +use cumulus_pallet_parachain_system::RelayNumberStrictlyIncreases; use sp_api::impl_runtime_apis; use sp_core::{crypto::KeyTypeId, OpaqueMetadata}; use sp_runtime::{ @@ -66,7 +67,7 @@ use static_assertions::const_assert; pub use frame_support::{ construct_runtime, match_types, parameter_types, traits::{ - AsEnsureOriginWithArg, Contains, Currency, EnsureOneOf, EqualPrivilegeOnly, Everything, + AsEnsureOriginWithArg, Contains, Currency, EitherOfDiverse, EqualPrivilegeOnly, Everything, Imbalance, InstanceFilter, IsInVec, KeyOwnerProofSystem, LockIdentifier, Nothing, OnUnbalanced, Randomness, U128CurrencyToVote, }, @@ -190,7 +191,7 @@ pub type Executive = frame_executive::Executive< AllPalletsWithSystem, >; -type EnsureRootOrHalfCouncil = EnsureOneOf< +type EnsureRootOrHalfCouncil = EitherOfDiverse< EnsureRoot, pallet_collective::EnsureProportionMoreThan, >; @@ -813,6 +814,7 @@ impl cumulus_pallet_parachain_system::Config for Runtime { type OutboundXcmpMessageSource = XcmpQueue; type XcmpMessageHandler = XcmpQueue; type ReservedXcmpWeight = ReservedXcmpWeight; + type CheckAssociatedRelayNumber = RelayNumberStrictlyIncreases; } parameter_types! { @@ -1271,11 +1273,11 @@ parameter_types! { impl pallet_treasury::Config for Runtime { type PalletId = TreasuryPalletId; type Currency = Balances; - type ApproveOrigin = EnsureOneOf< + type ApproveOrigin = EitherOfDiverse< EnsureRoot, pallet_collective::EnsureProportionAtLeast, >; - type RejectOrigin = EnsureOneOf< + type RejectOrigin = EitherOfDiverse< EnsureRoot, pallet_collective::EnsureProportionMoreThan, >; @@ -1314,41 +1316,41 @@ impl pallet_democracy::Config for Runtime { type VoteLockingPeriod = EnactmentPeriod; // Same as EnactmentPeriod type MinimumDeposit = MinimumDeposit; /// A straight majority of the council can decide what their next motion is. - type ExternalOrigin = EnsureOneOf< + type ExternalOrigin = EitherOfDiverse< pallet_collective::EnsureProportionAtLeast, frame_system::EnsureRoot, >; /// A super-majority can have the next scheduled referendum be a straight majority-carries vote. - type ExternalMajorityOrigin = EnsureOneOf< + type ExternalMajorityOrigin = EitherOfDiverse< pallet_collective::EnsureProportionAtLeast, frame_system::EnsureRoot, >; /// A unanimous council can have the next scheduled referendum be a straight default-carries /// (NTB) vote. - type ExternalDefaultOrigin = EnsureOneOf< + type ExternalDefaultOrigin = EitherOfDiverse< pallet_collective::EnsureProportionAtLeast, frame_system::EnsureRoot, >; /// Two thirds of the technical committee can have an ExternalMajority/ExternalDefault vote /// be tabled immediately and with a shorter voting/enactment period. - type FastTrackOrigin = EnsureOneOf< + type FastTrackOrigin = EitherOfDiverse< pallet_collective::EnsureProportionAtLeast, frame_system::EnsureRoot, >; - type InstantOrigin = EnsureOneOf< + type InstantOrigin = EitherOfDiverse< pallet_collective::EnsureProportionAtLeast, frame_system::EnsureRoot, >; type InstantAllowed = InstantAllowed; type FastTrackVotingPeriod = FastTrackVotingPeriod; // To cancel a proposal which has been passed, 2/3 of the council must agree to it. - type CancellationOrigin = EnsureOneOf< + type CancellationOrigin = EitherOfDiverse< pallet_collective::EnsureProportionAtLeast, EnsureRoot, >; // To cancel a proposal before it has been passed, the technical committee must be unanimous or // Root must agree. - type CancelProposalOrigin = EnsureOneOf< + type CancelProposalOrigin = EitherOfDiverse< pallet_collective::EnsureProportionAtLeast, EnsureRoot, >; diff --git a/runtime/khala/src/migrations.rs b/runtime/khala/src/migrations.rs index f2855aab..25f708fc 100644 --- a/runtime/khala/src/migrations.rs +++ b/runtime/khala/src/migrations.rs @@ -2,3 +2,20 @@ use super::*; #[allow(unused_imports)] use frame_support::traits::OnRuntimeUpgrade; + +// Note to "late-migration": +// +// All the migrations defined in this file are so called "late-migration". We should have done the +// pallet migrations as soon as we perform the runtime upgrade. However the runtime v1090 was done +// without applying the necessary migrations. Without the migrations, affected pallets can no +// longer access the state db properly. +// +// So here we need to redo the migrations afterward. An immediate problem is that, after the new +// pallets are upgraded, they may have already written some data under the new pallet storage +// prefixes. Most of the pre_upgrade logic checks there's no data under the new pallets as a safe +// guard. However for "late-migrations" this is not the case. +// +// The final decision is to just skip the pre_upgrade checks. We have carefully checked all the +// pre_upgrade checks and confirmed that only the prefix checks are skipped. All the other checks +// are still performed in an offline try-runtime test. + diff --git a/runtime/phala/src/lib.rs b/runtime/phala/src/lib.rs index 62c802d5..5bbd4b25 100644 --- a/runtime/phala/src/lib.rs +++ b/runtime/phala/src/lib.rs @@ -47,6 +47,7 @@ use constants::{ mod migrations; use codec::{Decode, Encode, MaxEncodedLen}; +use cumulus_pallet_parachain_system::RelayNumberStrictlyIncreases; use sp_api::impl_runtime_apis; use sp_core::{crypto::KeyTypeId, OpaqueMetadata}; use sp_runtime::{ @@ -65,7 +66,7 @@ use static_assertions::const_assert; pub use frame_support::{ construct_runtime, match_types, parameter_types, traits::{ - Contains, Currency, EnsureOneOf, EqualPrivilegeOnly, Everything, Imbalance, InstanceFilter, + Contains, Currency, EitherOfDiverse, EqualPrivilegeOnly, Everything, Imbalance, InstanceFilter, IsInVec, KeyOwnerProofSystem, LockIdentifier, Nothing, OnUnbalanced, Randomness, U128CurrencyToVote, }, @@ -186,7 +187,7 @@ pub type Executive = frame_executive::Executive< AllPalletsWithSystem, >; -type EnsureRootOrHalfCouncil = EnsureOneOf< +type EnsureRootOrHalfCouncil = EitherOfDiverse< EnsureRoot, pallet_collective::EnsureProportionMoreThan, >; @@ -751,6 +752,7 @@ impl cumulus_pallet_parachain_system::Config for Runtime { type OutboundXcmpMessageSource = XcmpQueue; type XcmpMessageHandler = XcmpQueue; type ReservedXcmpWeight = ReservedXcmpWeight; + type CheckAssociatedRelayNumber = RelayNumberStrictlyIncreases; } impl pallet_parachain_info::Config for Runtime {} @@ -895,11 +897,11 @@ parameter_types! { impl pallet_treasury::Config for Runtime { type PalletId = TreasuryPalletId; type Currency = Balances; - type ApproveOrigin = EnsureOneOf< + type ApproveOrigin = EitherOfDiverse< EnsureRoot, pallet_collective::EnsureProportionAtLeast, >; - type RejectOrigin = EnsureOneOf< + type RejectOrigin = EitherOfDiverse< EnsureRoot, pallet_collective::EnsureProportionMoreThan, >; @@ -938,41 +940,41 @@ impl pallet_democracy::Config for Runtime { type VoteLockingPeriod = EnactmentPeriod; // Same as EnactmentPeriod type MinimumDeposit = MinimumDeposit; /// A straight majority of the council can decide what their next motion is. - type ExternalOrigin = EnsureOneOf< + type ExternalOrigin = EitherOfDiverse< pallet_collective::EnsureProportionAtLeast, frame_system::EnsureRoot, >; /// A super-majority can have the next scheduled referendum be a straight majority-carries vote. - type ExternalMajorityOrigin = EnsureOneOf< + type ExternalMajorityOrigin = EitherOfDiverse< pallet_collective::EnsureProportionAtLeast, frame_system::EnsureRoot, >; /// A unanimous council can have the next scheduled referendum be a straight default-carries /// (NTB) vote. - type ExternalDefaultOrigin = EnsureOneOf< + type ExternalDefaultOrigin = EitherOfDiverse< pallet_collective::EnsureProportionAtLeast, frame_system::EnsureRoot, >; /// Two thirds of the technical committee can have an ExternalMajority/ExternalDefault vote /// be tabled immediately and with a shorter voting/enactment period. - type FastTrackOrigin = EnsureOneOf< + type FastTrackOrigin = EitherOfDiverse< pallet_collective::EnsureProportionAtLeast, frame_system::EnsureRoot, >; - type InstantOrigin = EnsureOneOf< + type InstantOrigin = EitherOfDiverse< pallet_collective::EnsureProportionAtLeast, frame_system::EnsureRoot, >; type InstantAllowed = InstantAllowed; type FastTrackVotingPeriod = FastTrackVotingPeriod; // To cancel a proposal which has been passed, 2/3 of the council must agree to it. - type CancellationOrigin = EnsureOneOf< + type CancellationOrigin = EitherOfDiverse< pallet_collective::EnsureProportionAtLeast, EnsureRoot, >; // To cancel a proposal before it has been passed, the technical committee must be unanimous or // Root must agree. - type CancelProposalOrigin = EnsureOneOf< + type CancelProposalOrigin = EitherOfDiverse< pallet_collective::EnsureProportionAtLeast, EnsureRoot, >; diff --git a/runtime/phala/src/migrations.rs b/runtime/phala/src/migrations.rs index 919fd0fc..25f708fc 100644 --- a/runtime/phala/src/migrations.rs +++ b/runtime/phala/src/migrations.rs @@ -18,3 +18,4 @@ use frame_support::traits::OnRuntimeUpgrade; // The final decision is to just skip the pre_upgrade checks. We have carefully checked all the // pre_upgrade checks and confirmed that only the prefix checks are skipped. All the other checks // are still performed in an offline try-runtime test. + diff --git a/runtime/rhala/src/lib.rs b/runtime/rhala/src/lib.rs index 60fc188d..d4e10696 100644 --- a/runtime/rhala/src/lib.rs +++ b/runtime/rhala/src/lib.rs @@ -48,6 +48,7 @@ mod migrations; mod msg_routing; use codec::{Decode, Encode, MaxEncodedLen}; +use cumulus_pallet_parachain_system::RelayNumberStrictlyIncreases; use sp_api::impl_runtime_apis; use sp_core::{crypto::KeyTypeId, OpaqueMetadata}; use sp_runtime::{ @@ -66,7 +67,7 @@ use static_assertions::const_assert; pub use frame_support::{ construct_runtime, match_types, parameter_types, traits::{ - AsEnsureOriginWithArg, Contains, Currency, EnsureOneOf, EqualPrivilegeOnly, Everything, + AsEnsureOriginWithArg, Contains, Currency, EitherOfDiverse, EqualPrivilegeOnly, Everything, Imbalance, InstanceFilter, IsInVec, KeyOwnerProofSystem, LockIdentifier, Nothing, OnUnbalanced, Randomness, U128CurrencyToVote, }, @@ -192,7 +193,7 @@ pub type Executive = frame_executive::Executive< AllPalletsWithSystem, >; -type EnsureRootOrHalfCouncil = EnsureOneOf< +type EnsureRootOrHalfCouncil = EitherOfDiverse< EnsureRoot, pallet_collective::EnsureProportionMoreThan, >; @@ -812,6 +813,7 @@ impl cumulus_pallet_parachain_system::Config for Runtime { type OutboundXcmpMessageSource = XcmpQueue; type XcmpMessageHandler = XcmpQueue; type ReservedXcmpWeight = ReservedXcmpWeight; + type CheckAssociatedRelayNumber = RelayNumberStrictlyIncreases; } parameter_types! { @@ -1269,11 +1271,11 @@ parameter_types! { impl pallet_treasury::Config for Runtime { type PalletId = TreasuryPalletId; type Currency = Balances; - type ApproveOrigin = EnsureOneOf< + type ApproveOrigin = EitherOfDiverse< EnsureRoot, pallet_collective::EnsureProportionAtLeast, >; - type RejectOrigin = EnsureOneOf< + type RejectOrigin = EitherOfDiverse< EnsureRoot, pallet_collective::EnsureProportionMoreThan, >; @@ -1312,41 +1314,41 @@ impl pallet_democracy::Config for Runtime { type VoteLockingPeriod = EnactmentPeriod; // Same as EnactmentPeriod type MinimumDeposit = MinimumDeposit; /// A straight majority of the council can decide what their next motion is. - type ExternalOrigin = EnsureOneOf< + type ExternalOrigin = EitherOfDiverse< pallet_collective::EnsureProportionAtLeast, frame_system::EnsureRoot, >; /// A super-majority can have the next scheduled referendum be a straight majority-carries vote. - type ExternalMajorityOrigin = EnsureOneOf< + type ExternalMajorityOrigin = EitherOfDiverse< pallet_collective::EnsureProportionAtLeast, frame_system::EnsureRoot, >; /// A unanimous council can have the next scheduled referendum be a straight default-carries /// (NTB) vote. - type ExternalDefaultOrigin = EnsureOneOf< + type ExternalDefaultOrigin = EitherOfDiverse< pallet_collective::EnsureProportionAtLeast, frame_system::EnsureRoot, >; /// Two thirds of the technical committee can have an ExternalMajority/ExternalDefault vote /// be tabled immediately and with a shorter voting/enactment period. - type FastTrackOrigin = EnsureOneOf< + type FastTrackOrigin = EitherOfDiverse< pallet_collective::EnsureProportionAtLeast, frame_system::EnsureRoot, >; - type InstantOrigin = EnsureOneOf< + type InstantOrigin = EitherOfDiverse< pallet_collective::EnsureProportionAtLeast, frame_system::EnsureRoot, >; type InstantAllowed = InstantAllowed; type FastTrackVotingPeriod = FastTrackVotingPeriod; // To cancel a proposal which has been passed, 2/3 of the council must agree to it. - type CancellationOrigin = EnsureOneOf< + type CancellationOrigin = EitherOfDiverse< pallet_collective::EnsureProportionAtLeast, EnsureRoot, >; // To cancel a proposal before it has been passed, the technical committee must be unanimous or // Root must agree. - type CancelProposalOrigin = EnsureOneOf< + type CancelProposalOrigin = EitherOfDiverse< pallet_collective::EnsureProportionAtLeast, EnsureRoot, >; diff --git a/runtime/rhala/src/migrations.rs b/runtime/rhala/src/migrations.rs index f2855aab..25f708fc 100644 --- a/runtime/rhala/src/migrations.rs +++ b/runtime/rhala/src/migrations.rs @@ -2,3 +2,20 @@ use super::*; #[allow(unused_imports)] use frame_support::traits::OnRuntimeUpgrade; + +// Note to "late-migration": +// +// All the migrations defined in this file are so called "late-migration". We should have done the +// pallet migrations as soon as we perform the runtime upgrade. However the runtime v1090 was done +// without applying the necessary migrations. Without the migrations, affected pallets can no +// longer access the state db properly. +// +// So here we need to redo the migrations afterward. An immediate problem is that, after the new +// pallets are upgraded, they may have already written some data under the new pallet storage +// prefixes. Most of the pre_upgrade logic checks there's no data under the new pallets as a safe +// guard. However for "late-migrations" this is not the case. +// +// The final decision is to just skip the pre_upgrade checks. We have carefully checked all the +// pre_upgrade checks and confirmed that only the prefix checks are skipped. All the other checks +// are still performed in an offline try-runtime test. + diff --git a/runtime/shell/src/lib.rs b/runtime/shell/src/lib.rs index e6b381a6..628c1043 100644 --- a/runtime/shell/src/lib.rs +++ b/runtime/shell/src/lib.rs @@ -25,6 +25,7 @@ include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs")); pub mod xcm_config; use codec::{Decode, Encode}; +use cumulus_pallet_parachain_system::RelayNumberStrictlyIncreases; use frame_support::unsigned::TransactionValidityError; use scale_info::TypeInfo; use sp_api::impl_runtime_apis; @@ -166,6 +167,7 @@ impl cumulus_pallet_parachain_system::Config for Runtime { type ReservedDmpWeight = ReservedDmpWeight; type XcmpMessageHandler = (); type ReservedXcmpWeight = (); + type CheckAssociatedRelayNumber = RelayNumberStrictlyIncreases; } impl parachain_info::Config for Runtime {} diff --git a/runtime/thala/src/lib.rs b/runtime/thala/src/lib.rs index 97d4d456..c1bc8d02 100644 --- a/runtime/thala/src/lib.rs +++ b/runtime/thala/src/lib.rs @@ -48,6 +48,7 @@ mod migrations; mod msg_routing; use codec::{Decode, Encode, MaxEncodedLen}; +use cumulus_pallet_parachain_system::RelayNumberStrictlyIncreases; use sp_api::impl_runtime_apis; use sp_core::{crypto::KeyTypeId, OpaqueMetadata}; use sp_runtime::{ @@ -66,7 +67,7 @@ use static_assertions::const_assert; pub use frame_support::{ construct_runtime, match_types, parameter_types, traits::{ - AsEnsureOriginWithArg, Contains, Currency, EnsureOneOf, EqualPrivilegeOnly, Everything, + AsEnsureOriginWithArg, Contains, Currency, EitherOfDiverse, EqualPrivilegeOnly, Everything, Imbalance, InstanceFilter, IsInVec, KeyOwnerProofSystem, LockIdentifier, Nothing, OnUnbalanced, Randomness, U128CurrencyToVote, }, @@ -193,7 +194,7 @@ pub type Executive = frame_executive::Executive< (), >; -type EnsureRootOrHalfCouncil = EnsureOneOf< +type EnsureRootOrHalfCouncil = EitherOfDiverse< EnsureRoot, pallet_collective::EnsureProportionMoreThan, >; @@ -814,6 +815,7 @@ impl cumulus_pallet_parachain_system::Config for Runtime { type OutboundXcmpMessageSource = XcmpQueue; type XcmpMessageHandler = XcmpQueue; type ReservedXcmpWeight = ReservedXcmpWeight; + type CheckAssociatedRelayNumber = RelayNumberStrictlyIncreases; } parameter_types! { @@ -1278,11 +1280,11 @@ parameter_types! { impl pallet_treasury::Config for Runtime { type PalletId = TreasuryPalletId; type Currency = Balances; - type ApproveOrigin = EnsureOneOf< + type ApproveOrigin = EitherOfDiverse< EnsureRoot, pallet_collective::EnsureProportionAtLeast, >; - type RejectOrigin = EnsureOneOf< + type RejectOrigin = EitherOfDiverse< EnsureRoot, pallet_collective::EnsureProportionMoreThan, >; @@ -1321,41 +1323,41 @@ impl pallet_democracy::Config for Runtime { type VoteLockingPeriod = EnactmentPeriod; // Same as EnactmentPeriod type MinimumDeposit = MinimumDeposit; /// A straight majority of the council can decide what their next motion is. - type ExternalOrigin = EnsureOneOf< + type ExternalOrigin = EitherOfDiverse< pallet_collective::EnsureProportionAtLeast, frame_system::EnsureRoot, >; /// A super-majority can have the next scheduled referendum be a straight majority-carries vote. - type ExternalMajorityOrigin = EnsureOneOf< + type ExternalMajorityOrigin = EitherOfDiverse< pallet_collective::EnsureProportionAtLeast, frame_system::EnsureRoot, >; /// A unanimous council can have the next scheduled referendum be a straight default-carries /// (NTB) vote. - type ExternalDefaultOrigin = EnsureOneOf< + type ExternalDefaultOrigin = EitherOfDiverse< pallet_collective::EnsureProportionAtLeast, frame_system::EnsureRoot, >; /// Two thirds of the technical committee can have an ExternalMajority/ExternalDefault vote /// be tabled immediately and with a shorter voting/enactment period. - type FastTrackOrigin = EnsureOneOf< + type FastTrackOrigin = EitherOfDiverse< pallet_collective::EnsureProportionAtLeast, frame_system::EnsureRoot, >; - type InstantOrigin = EnsureOneOf< + type InstantOrigin = EitherOfDiverse< pallet_collective::EnsureProportionAtLeast, frame_system::EnsureRoot, >; type InstantAllowed = InstantAllowed; type FastTrackVotingPeriod = FastTrackVotingPeriod; // To cancel a proposal which has been passed, 2/3 of the council must agree to it. - type CancellationOrigin = EnsureOneOf< + type CancellationOrigin = EitherOfDiverse< pallet_collective::EnsureProportionAtLeast, EnsureRoot, >; // To cancel a proposal before it has been passed, the technical committee must be unanimous or // Root must agree. - type CancelProposalOrigin = EnsureOneOf< + type CancelProposalOrigin = EitherOfDiverse< pallet_collective::EnsureProportionAtLeast, EnsureRoot, >; diff --git a/runtime/thala/src/migrations.rs b/runtime/thala/src/migrations.rs index f2855aab..25f708fc 100644 --- a/runtime/thala/src/migrations.rs +++ b/runtime/thala/src/migrations.rs @@ -2,3 +2,20 @@ use super::*; #[allow(unused_imports)] use frame_support::traits::OnRuntimeUpgrade; + +// Note to "late-migration": +// +// All the migrations defined in this file are so called "late-migration". We should have done the +// pallet migrations as soon as we perform the runtime upgrade. However the runtime v1090 was done +// without applying the necessary migrations. Without the migrations, affected pallets can no +// longer access the state db properly. +// +// So here we need to redo the migrations afterward. An immediate problem is that, after the new +// pallets are upgraded, they may have already written some data under the new pallet storage +// prefixes. Most of the pre_upgrade logic checks there's no data under the new pallets as a safe +// guard. However for "late-migrations" this is not the case. +// +// The final decision is to just skip the pre_upgrade checks. We have carefully checked all the +// pre_upgrade checks and confirmed that only the prefix checks are skipped. All the other checks +// are still performed in an offline try-runtime test. +