git.delta.rocks / unique-network / refs/commits / cec8ffa65f46

difftreelog

fix(preimage) maintenance not working with quantum preimage (due to runtimes)

Fahrrader2023-02-21parent: #c80473f.patch.diff
in: master

9 files changed

modifiedpallets/maintenance/src/benchmarking.rsdiffbeforeafterboth
23use codec::Encode;23use codec::Encode;
24use sp_std::vec;24use sp_std::vec;
2525
26#[cfg(not(feature = "governance"))]
26benchmarks! {27benchmarks! {
27 enable {28 enable {
28 }: _(RawOrigin::Root)29 }: _(RawOrigin::Root)
45 }46 }
46}47}
48
49#[cfg(feature = "governance")]
50benchmarks! {
51 enable {
52 }: _(RawOrigin::Root)
53 verify {
54 ensure!(<Enabled<T>>::get(), "didn't enable the MM");
55 }
56
57 disable {
58 Maintenance::<T>::enable(RawOrigin::Root.into())?;
59 }: _(RawOrigin::Root)
60 verify {
61 ensure!(!<Enabled<T>>::get(), "didn't disable the MM");
62 }
63
64 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}
4771
modifiedpallets/maintenance/src/lib.rsdiffbeforeafterboth
28 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;
3537
105107
106 #[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)?;
110117
119 };126 };
120127
121 result128 result
129 }
130
131 #[cfg(not(feature = "governance"))]
132 {
133 Err(DispatchError::Unavailable)
134 }
122 }135 }
123 }136 }
124}137}
modifiedruntime/common/config/pallets/mod.rsdiffbeforeafterboth
23 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;
4949
50// todo:governance replace the feature with governance
51#[cfg(feature = "collator-selection")]50#[cfg(feature = "governance")]
52pub mod governance;51pub mod governance;
5352
54parameter_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}
135137
modifiedruntime/common/construct_runtime.rsdiffbeforeafterboth
56 #[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,
5858
59 // todo:governance switch feature to governance
60 #[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,
6261
63 // XCM helpers.62 // XCM helpers.
modifiedruntime/common/maintenance.rsdiffbeforeafterboth
86 | RuntimeCall::Session(_)86 | RuntimeCall::Session(_)
87 | RuntimeCall::Identity(_) => Err(TransactionValidityError::Invalid(InvalidTransaction::Call)),87 | RuntimeCall::Identity(_) => Err(TransactionValidityError::Invalid(InvalidTransaction::Call)),
8888
89 // todo:governance switch the feature to governance
90 #[cfg(feature = "collator-selection")]89 #[cfg(feature = "governance")]
91 RuntimeCall::Preimage(_) => Err(TransactionValidityError::Invalid(InvalidTransaction::Call)),90 RuntimeCall::Preimage(_) => Err(TransactionValidityError::Invalid(InvalidTransaction::Call)),
9291
93 #[cfg(feature = "pallet-test-utils")]92 #[cfg(feature = "pallet-test-utils")]
modifiedruntime/common/runtime_apis.rsdiffbeforeafterboth
565 #[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);
567567
568 // todo:governance switch feature to governance
569 #[cfg(feature = "collator-selection")]568 #[cfg(feature = "governance")]
570 list_benchmark!(list, extra, pallet_preimage, Preimage);569 list_benchmark!(list, extra, pallet_preimage, Preimage);
571570
572 #[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);
635634
636 // todo:governance switch feature to governance
637 #[cfg(feature = "collator-selection")]635 #[cfg(feature = "governance")]
638 add_benchmark!(params, batches, pallet_preimage, Preimage);636 add_benchmark!(params, batches, pallet_preimage, Preimage);
639637
640 #[cfg(feature = "foreign-assets")]638 #[cfg(feature = "foreign-assets")]
modifiedruntime/opal/Cargo.tomldiffbeforeafterboth
18[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 = []
modifiedruntime/quartz/Cargo.tomldiffbeforeafterboth
20default = ['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 = []
189190
modifiedruntime/unique/Cargo.tomldiffbeforeafterboth
183app-promotion = []183app-promotion = []
184collator-selection = []184collator-selection = []
185foreign-assets = []185foreign-assets = []
186governance = []
186refungible = []187refungible = []
187scheduler = []188scheduler = []
188189