difftreelog
fix(preimage) maintenance not working with quantum preimage (due to runtimes)
in: master
9 files changed
pallets/maintenance/src/benchmarking.rsdiffbeforeafterboth23use codec::Encode;23use codec::Encode;24use sp_std::vec;24use sp_std::vec;252526#[cfg(not(feature = "governance"))]26benchmarks! {27benchmarks! {27 enable {28 enable {28 }: _(RawOrigin::Root)29 }: _(RawOrigin::Root)45 }46 }46}47}4849#[cfg(feature = "governance")]50benchmarks! {51 enable {52 }: _(RawOrigin::Root)53 verify {54 ensure!(<Enabled<T>>::get(), "didn't enable the MM");55 }5657 disable {58 Maintenance::<T>::enable(RawOrigin::Root.into())?;59 }: _(RawOrigin::Root)60 verify {61 ensure!(!<Enabled<T>>::get(), "didn't disable the MM");62 }6364 execute_preimage {65 let call_hash = RuntimeCall::<T>::set_storage { items: vec![] }.encode();66 let hash = T::Preimages::note(call_hash.into())?;67 }: _(RawOrigin::Root, hash)68 verify {69 }70}4771pallets/maintenance/src/lib.rsdiffbeforeafterboth28 use frame_support::{28 use frame_support::{29 dispatch::*,29 dispatch::*,30 pallet_prelude::*,30 pallet_prelude::*,31 traits::{QueryPreimage, StorePreimage},32 };31 };32 use frame_support::{33 traits::{QueryPreimage, StorePreimage},34 };33 use frame_system::pallet_prelude::*;35 use frame_system::pallet_prelude::*;34 use sp_core::H256;36 use sp_core::H256;3537105107106 #[pallet::call_index(2)]108 #[pallet::call_index(2)]107 #[pallet::weight(<T as Config>::WeightInfo::execute_preimage())]109 #[pallet::weight(<T as Config>::WeightInfo::execute_preimage())]108 pub fn execute_preimage(origin: OriginFor<T>, hash: H256) -> DispatchResult {110 pub fn execute_preimage(_origin: OriginFor<T>, _hash: H256) -> DispatchResult {111 #[cfg(feature = "governance")]112 {113 let origin = _origin;114 let hash = _hash;115 109 ensure_root(origin)?;116 ensure_root(origin)?;110117119 };126 };120127121 result128 result129 }130131 #[cfg(not(feature = "governance"))]132 {133 Err(DispatchError::Unavailable)134 }122 }135 }123 }136 }124}137}runtime/common/config/pallets/mod.rsdiffbeforeafterboth23 weights::CommonWeights,23 weights::CommonWeights,24 RelayChainBlockNumberProvider,24 RelayChainBlockNumberProvider,25 },25 },26 Runtime, RuntimeEvent, RuntimeCall, RuntimeOrigin, Balances, Preimage,26 Runtime, RuntimeEvent, RuntimeCall, RuntimeOrigin, Balances,27};27};28use frame_support::traits::{ConstU32, ConstU64};28use frame_support::traits::{ConstU32, ConstU64};29use up_common::{29use up_common::{47#[cfg(feature = "collator-selection")]47#[cfg(feature = "collator-selection")]48pub mod collator_selection;48pub mod collator_selection;494950// todo:governance replace the feature with governance51#[cfg(feature = "collator-selection")]50#[cfg(feature = "governance")]52pub mod governance;51pub mod governance;535254parameter_types! {53parameter_types! {129 type RuntimeEvent = RuntimeEvent;128 type RuntimeEvent = RuntimeEvent;130 type RuntimeOrigin = RuntimeOrigin;129 type RuntimeOrigin = RuntimeOrigin;131 type RuntimeCall = RuntimeCall;130 type RuntimeCall = RuntimeCall;131 #[cfg(feature = "governance")]132 type Preimages = Preimage;132 type Preimages = crate::Preimage;133 #[cfg(not(feature = "governance"))]134 type Preimages = ();133 type WeightInfo = pallet_maintenance::weights::SubstrateWeight<Self>;135 type WeightInfo = pallet_maintenance::weights::SubstrateWeight<Self>;134}136}135137runtime/common/construct_runtime.rsdiffbeforeafterboth56 #[cfg(feature = "collator-selection")]56 #[cfg(feature = "collator-selection")]57 Identity: pallet_identity::{Pallet, Call, Storage, Event<T>} = 40,57 Identity: pallet_identity::{Pallet, Call, Storage, Event<T>} = 40,585859 // todo:governance switch feature to governance60 #[cfg(feature = "collator-selection")]59 #[cfg(feature = "governance")]61 Preimage: pallet_preimage::{Pallet, Call, Storage, Event<T>} = 41,60 Preimage: pallet_preimage::{Pallet, Call, Storage, Event<T>} = 41,626163 // XCM helpers.62 // XCM helpers.runtime/common/maintenance.rsdiffbeforeafterboth86 | RuntimeCall::Session(_)86 | RuntimeCall::Session(_)87 | RuntimeCall::Identity(_) => Err(TransactionValidityError::Invalid(InvalidTransaction::Call)),87 | RuntimeCall::Identity(_) => Err(TransactionValidityError::Invalid(InvalidTransaction::Call)),888889 // todo:governance switch the feature to governance90 #[cfg(feature = "collator-selection")]89 #[cfg(feature = "governance")]91 RuntimeCall::Preimage(_) => Err(TransactionValidityError::Invalid(InvalidTransaction::Call)),90 RuntimeCall::Preimage(_) => Err(TransactionValidityError::Invalid(InvalidTransaction::Call)),929193 #[cfg(feature = "pallet-test-utils")]92 #[cfg(feature = "pallet-test-utils")]runtime/common/runtime_apis.rsdiffbeforeafterboth565 #[cfg(feature = "collator-selection")]565 #[cfg(feature = "collator-selection")]566 list_benchmark!(list, extra, pallet_identity, Identity);566 list_benchmark!(list, extra, pallet_identity, Identity);567567568 // todo:governance switch feature to governance569 #[cfg(feature = "collator-selection")]568 #[cfg(feature = "governance")]570 list_benchmark!(list, extra, pallet_preimage, Preimage);569 list_benchmark!(list, extra, pallet_preimage, Preimage);571570572 #[cfg(feature = "foreign-assets")]571 #[cfg(feature = "foreign-assets")]633 #[cfg(feature = "collator-selection")]632 #[cfg(feature = "collator-selection")]634 add_benchmark!(params, batches, pallet_identity, Identity);633 add_benchmark!(params, batches, pallet_identity, Identity);635634636 // todo:governance switch feature to governance637 #[cfg(feature = "collator-selection")]635 #[cfg(feature = "governance")]638 add_benchmark!(params, batches, pallet_preimage, Preimage);636 add_benchmark!(params, batches, pallet_preimage, Preimage);639637640 #[cfg(feature = "foreign-assets")]638 #[cfg(feature = "foreign-assets")]runtime/opal/Cargo.tomldiffbeforeafterboth18[features]18[features]19default = ['opal-runtime', 'std']19default = ['opal-runtime', 'std']20limit-testing = ['pallet-unique/limit-testing', 'up-data-structs/limit-testing']20limit-testing = ['pallet-unique/limit-testing', 'up-data-structs/limit-testing']21opal-runtime = ['app-promotion', 'collator-selection', 'foreign-assets', 'pallet-test-utils', 'refungible']21opal-runtime = ['app-promotion', 'collator-selection', 'foreign-assets', 'governance', 'pallet-test-utils', 'refungible']22pov-estimate = []22pov-estimate = []23runtime-benchmarks = [23runtime-benchmarks = [24 'cumulus-pallet-parachain-system/runtime-benchmarks',24 'cumulus-pallet-parachain-system/runtime-benchmarks',191app-promotion = []191app-promotion = []192collator-selection = []192collator-selection = []193foreign-assets = []193foreign-assets = []194governance = []194pallet-test-utils = []195pallet-test-utils = []195refungible = []196refungible = []196scheduler = []197scheduler = []runtime/quartz/Cargo.tomldiffbeforeafterboth20default = ['quartz-runtime', 'std']20default = ['quartz-runtime', 'std']21limit-testing = ['pallet-unique/limit-testing', 'up-data-structs/limit-testing']21limit-testing = ['pallet-unique/limit-testing', 'up-data-structs/limit-testing']22pov-estimate = []22pov-estimate = []23quartz-runtime = ['app-promotion', 'collator-selection', 'foreign-assets', 'refungible']23quartz-runtime = ['app-promotion', 'collator-selection', 'foreign-assets', 'governance', 'refungible']24runtime-benchmarks = [24runtime-benchmarks = [25 'cumulus-pallet-parachain-system/runtime-benchmarks',25 'cumulus-pallet-parachain-system/runtime-benchmarks',26 'frame-benchmarking',26 'frame-benchmarking',184app-promotion = []184app-promotion = []185collator-selection = []185collator-selection = []186foreign-assets = []186foreign-assets = []187governance = []187refungible = []188refungible = []188scheduler = []189scheduler = []189190runtime/unique/Cargo.tomldiffbeforeafterboth183app-promotion = []183app-promotion = []184collator-selection = []184collator-selection = []185foreign-assets = []185foreign-assets = []186governance = []186refungible = []187refungible = []187scheduler = []188scheduler = []188189