git.delta.rocks / unique-network / refs/commits / 23641e0cc8f7

difftreelog

refactor(preimage) switch governance feature to preimage

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

12 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"))]
27benchmarks! {26benchmarks! {
28 enable {27 enable {
29 }: _(RawOrigin::Root)28 }: _(RawOrigin::Root)
46 }45 }
47}46}
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}
7147
modifiedpallets/maintenance/src/lib.rsdiffbeforeafterboth
27pub mod pallet {27pub mod pallet {
28 use frame_support::{28 use frame_support::{dispatch::*, pallet_prelude::*};
29 dispatch::*,
30 pallet_prelude::*,
31 };
32 use frame_support::{29 use frame_support::{
33 traits::{QueryPreimage, StorePreimage},30 traits::{QueryPreimage, StorePreimage},
108 #[pallet::call_index(2)]105 #[pallet::call_index(2)]
109 #[pallet::weight(<T as Config>::WeightInfo::execute_preimage())]106 #[pallet::weight(<T as Config>::WeightInfo::execute_preimage())]
110 pub fn execute_preimage(_origin: OriginFor<T>, _hash: H256) -> DispatchResult {107 pub fn execute_preimage(_origin: OriginFor<T>, _hash: H256) -> DispatchResult {
111 #[cfg(feature = "governance")]108 #[cfg(feature = "preimage")]
112 {109 {
113 let origin = _origin;110 let origin = _origin;
114 let hash = _hash;111 let hash = _hash;
128 result125 result
129 }126 }
130127
131 #[cfg(not(feature = "governance"))]128 #[cfg(not(feature = "preimage"))]
132 {129 {
133 Err(DispatchError::Unavailable)130 Err(DispatchError::Unavailable)
134 }131 }
deletedruntime/common/config/pallets/governance.rsdiffbeforeafterboth

no changes

modifiedruntime/common/config/pallets/mod.rsdiffbeforeafterboth
47#[cfg(feature = "collator-selection")]47#[cfg(feature = "collator-selection")]
48pub mod collator_selection;48pub mod collator_selection;
4949
50#[cfg(feature = "governance")]50#[cfg(feature = "preimage")]
51pub mod governance;51pub mod preimage;
5252
53parameter_types! {53parameter_types! {
54 pub TreasuryAccountId: AccountId = TreasuryModuleId::get().into_account_truncating();54 pub TreasuryAccountId: AccountId = TreasuryModuleId::get().into_account_truncating();
128 type RuntimeEvent = RuntimeEvent;128 type RuntimeEvent = RuntimeEvent;
129 type RuntimeOrigin = RuntimeOrigin;129 type RuntimeOrigin = RuntimeOrigin;
130 type RuntimeCall = RuntimeCall;130 type RuntimeCall = RuntimeCall;
131 #[cfg(feature = "governance")]131 #[cfg(feature = "preimage")]
132 type Preimages = crate::Preimage;132 type Preimages = crate::Preimage;
133 #[cfg(not(feature = "governance"))]133 #[cfg(not(feature = "preimage"))]
134 type Preimages = ();134 type Preimages = ();
135 type WeightInfo = pallet_maintenance::weights::SubstrateWeight<Self>;135 type WeightInfo = pallet_maintenance::weights::SubstrateWeight<Self>;
136}136}
addedruntime/common/config/pallets/preimage.rsdiffbeforeafterboth

no changes

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 #[cfg(feature = "governance")]59 #[cfg(feature = "preimage")]
60 Preimage: pallet_preimage::{Pallet, Call, Storage, Event<T>} = 41,60 Preimage: pallet_preimage::{Pallet, Call, Storage, Event<T>} = 41,
6161
62 // 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 #[cfg(feature = "governance")]89 #[cfg(feature = "preimage")]
90 RuntimeCall::Preimage(_) => Err(TransactionValidityError::Invalid(InvalidTransaction::Call)),90 RuntimeCall::Preimage(_) => Err(TransactionValidityError::Invalid(InvalidTransaction::Call)),
9191
92 #[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 #[cfg(feature = "governance")]568 #[cfg(feature = "preimage")]
569 list_benchmark!(list, extra, pallet_preimage, Preimage);569 list_benchmark!(list, extra, pallet_preimage, Preimage);
570570
571 #[cfg(feature = "foreign-assets")]571 #[cfg(feature = "foreign-assets")]
632 #[cfg(feature = "collator-selection")]632 #[cfg(feature = "collator-selection")]
633 add_benchmark!(params, batches, pallet_identity, Identity);633 add_benchmark!(params, batches, pallet_identity, Identity);
634634
635 #[cfg(feature = "governance")]635 #[cfg(feature = "preimage")]
636 add_benchmark!(params, batches, pallet_preimage, Preimage);636 add_benchmark!(params, batches, pallet_preimage, Preimage);
637637
638 #[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', 'governance', 'pallet-test-utils', 'refungible']21opal-runtime = ['app-promotion', 'collator-selection', 'foreign-assets', 'preimage', '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 = []194preimage = []
195pallet-test-utils = []195pallet-test-utils = []
196refungible = []196refungible = []
197scheduler = []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', 'governance', 'refungible']23quartz-runtime = ['app-promotion', 'collator-selection', 'foreign-assets', 'preimage', '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 = []187preimage = []
188refungible = []188refungible = []
189scheduler = []189scheduler = []
190190
modifiedruntime/unique/Cargo.tomldiffbeforeafterboth
183app-promotion = []183app-promotion = []
184collator-selection = []184collator-selection = []
185foreign-assets = []185foreign-assets = []
186governance = []186preimage = []
187refungible = []187refungible = []
188scheduler = []188scheduler = []
189189
modifiedtests/src/pallet-presence.test.tsdiffbeforeafterboth
66 const foreignAssets = 'foreignassets';66 const foreignAssets = 'foreignassets';
67 const appPromotion = 'apppromotion';67 const appPromotion = 'apppromotion';
68 const collatorSelection = ['authorship', 'session', 'collatorselection', 'identity'];68 const collatorSelection = ['authorship', 'session', 'collatorselection', 'identity'];
69 const governance = ['preimage'];69 const preimage = ['preimage'];
70 const testUtils = 'testutils';70 const testUtils = 'testutils';
7171
72 if (chain.eq('OPAL by UNIQUE')) {72 if (chain.eq('OPAL by UNIQUE')) {
76 appPromotion,76 appPromotion,
77 testUtils,77 testUtils,
78 ...collatorSelection,78 ...collatorSelection,
79 ...governance,79 ...preimage,
80 );80 );
81 } else if (chain.eq('QUARTZ by UNIQUE') || chain.eq('SAPPHIRE by UNIQUE')) {81 } else if (chain.eq('QUARTZ by UNIQUE') || chain.eq('SAPPHIRE by UNIQUE')) {
82 requiredPallets.push(82 requiredPallets.push(
83 refungible,83 refungible,
84 appPromotion,84 appPromotion,
85 foreignAssets,85 foreignAssets,
86 ...collatorSelection,86 ...collatorSelection,
87 ...governance,87 ...preimage,
88 );88 );
89 } else if (chain.eq('UNIQUE')) {89 } else if (chain.eq('UNIQUE')) {
90 // Insert Unique additional pallets here90 // Insert Unique additional pallets here