difftreelog
fix(preimage) maintenance not working with quantum preimage (due to runtimes)
in: master
9 files changed
pallets/maintenance/src/benchmarking.rsdiffbeforeafterboth--- a/pallets/maintenance/src/benchmarking.rs
+++ b/pallets/maintenance/src/benchmarking.rs
@@ -23,6 +23,30 @@
use codec::Encode;
use sp_std::vec;
+#[cfg(not(feature = "governance"))]
+benchmarks! {
+ enable {
+ }: _(RawOrigin::Root)
+ verify {
+ ensure!(<Enabled<T>>::get(), "didn't enable the MM");
+ }
+
+ disable {
+ Maintenance::<T>::enable(RawOrigin::Root.into())?;
+ }: _(RawOrigin::Root)
+ verify {
+ ensure!(!<Enabled<T>>::get(), "didn't disable the MM");
+ }
+
+ execute_preimage {
+ let call_hash = RuntimeCall::<T>::set_storage { items: vec![] }.encode();
+ let hash = T::Preimages::note(call_hash.into())?;
+ }: _(RawOrigin::Root, hash)
+ verify {
+ }
+}
+
+#[cfg(feature = "governance")]
benchmarks! {
enable {
}: _(RawOrigin::Root)
pallets/maintenance/src/lib.rsdiffbeforeafterboth--- a/pallets/maintenance/src/lib.rs
+++ b/pallets/maintenance/src/lib.rs
@@ -28,6 +28,8 @@
use frame_support::{
dispatch::*,
pallet_prelude::*,
+ };
+ use frame_support::{
traits::{QueryPreimage, StorePreimage},
};
use frame_system::pallet_prelude::*;
@@ -105,20 +107,31 @@
#[pallet::call_index(2)]
#[pallet::weight(<T as Config>::WeightInfo::execute_preimage())]
- pub fn execute_preimage(origin: OriginFor<T>, hash: H256) -> DispatchResult {
- ensure_root(origin)?;
+ pub fn execute_preimage(_origin: OriginFor<T>, _hash: H256) -> DispatchResult {
+ #[cfg(feature = "governance")]
+ {
+ let origin = _origin;
+ let hash = _hash;
+
+ ensure_root(origin)?;
- let len = T::Preimages::len(&hash).ok_or(DispatchError::Unavailable)?;
- let bounded = T::Preimages::pick::<<T as Config>::RuntimeCall>(hash, len);
- let (call, _) =
- T::Preimages::realize(&bounded).map_err(|_| DispatchError::Unavailable)?;
+ let len = T::Preimages::len(&hash).ok_or(DispatchError::Unavailable)?;
+ let bounded = T::Preimages::pick::<<T as Config>::RuntimeCall>(hash, len);
+ let (call, _) =
+ T::Preimages::realize(&bounded).map_err(|_| DispatchError::Unavailable)?;
- let result = match call.dispatch(frame_system::RawOrigin::Root.into()) {
- Ok(_) => Ok(()),
- Err(error_and_info) => Err(error_and_info.error),
- };
+ let result = match call.dispatch(frame_system::RawOrigin::Root.into()) {
+ Ok(_) => Ok(()),
+ Err(error_and_info) => Err(error_and_info.error),
+ };
- result
+ result
+ }
+
+ #[cfg(not(feature = "governance"))]
+ {
+ Err(DispatchError::Unavailable)
+ }
}
}
}
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.rsdiffbeforeafterboth--- a/runtime/common/construct_runtime.rs
+++ b/runtime/common/construct_runtime.rs
@@ -56,8 +56,7 @@
#[cfg(feature = "collator-selection")]
Identity: pallet_identity::{Pallet, Call, Storage, Event<T>} = 40,
- // todo:governance switch feature to governance
- #[cfg(feature = "collator-selection")]
+ #[cfg(feature = "governance")]
Preimage: pallet_preimage::{Pallet, Call, Storage, Event<T>} = 41,
// XCM helpers.
runtime/common/maintenance.rsdiffbeforeafterboth--- a/runtime/common/maintenance.rs
+++ b/runtime/common/maintenance.rs
@@ -86,8 +86,7 @@
| RuntimeCall::Session(_)
| RuntimeCall::Identity(_) => Err(TransactionValidityError::Invalid(InvalidTransaction::Call)),
- // todo:governance switch the feature to governance
- #[cfg(feature = "collator-selection")]
+ #[cfg(feature = "governance")]
RuntimeCall::Preimage(_) => Err(TransactionValidityError::Invalid(InvalidTransaction::Call)),
#[cfg(feature = "pallet-test-utils")]
runtime/common/runtime_apis.rsdiffbeforeafterboth--- a/runtime/common/runtime_apis.rs
+++ b/runtime/common/runtime_apis.rs
@@ -565,8 +565,7 @@
#[cfg(feature = "collator-selection")]
list_benchmark!(list, extra, pallet_identity, Identity);
- // todo:governance switch feature to governance
- #[cfg(feature = "collator-selection")]
+ #[cfg(feature = "governance")]
list_benchmark!(list, extra, pallet_preimage, Preimage);
#[cfg(feature = "foreign-assets")]
@@ -633,8 +632,7 @@
#[cfg(feature = "collator-selection")]
add_benchmark!(params, batches, pallet_identity, Identity);
- // todo:governance switch feature to governance
- #[cfg(feature = "collator-selection")]
+ #[cfg(feature = "governance")]
add_benchmark!(params, batches, pallet_preimage, Preimage);
#[cfg(feature = "foreign-assets")]
runtime/opal/Cargo.tomldiffbeforeafterboth--- a/runtime/opal/Cargo.toml
+++ b/runtime/opal/Cargo.toml
@@ -18,7 +18,7 @@
[features]
default = ['opal-runtime', 'std']
limit-testing = ['pallet-unique/limit-testing', 'up-data-structs/limit-testing']
-opal-runtime = ['app-promotion', 'collator-selection', 'foreign-assets', 'pallet-test-utils', 'refungible']
+opal-runtime = ['app-promotion', 'collator-selection', 'foreign-assets', 'governance', 'pallet-test-utils', 'refungible']
pov-estimate = []
runtime-benchmarks = [
'cumulus-pallet-parachain-system/runtime-benchmarks',
@@ -191,6 +191,7 @@
app-promotion = []
collator-selection = []
foreign-assets = []
+governance = []
pallet-test-utils = []
refungible = []
scheduler = []
runtime/quartz/Cargo.tomldiffbeforeafterboth--- a/runtime/quartz/Cargo.toml
+++ b/runtime/quartz/Cargo.toml
@@ -20,7 +20,7 @@
default = ['quartz-runtime', 'std']
limit-testing = ['pallet-unique/limit-testing', 'up-data-structs/limit-testing']
pov-estimate = []
-quartz-runtime = ['app-promotion', 'collator-selection', 'foreign-assets', 'refungible']
+quartz-runtime = ['app-promotion', 'collator-selection', 'foreign-assets', 'governance', 'refungible']
runtime-benchmarks = [
'cumulus-pallet-parachain-system/runtime-benchmarks',
'frame-benchmarking',
@@ -184,6 +184,7 @@
app-promotion = []
collator-selection = []
foreign-assets = []
+governance = []
refungible = []
scheduler = []
runtime/unique/Cargo.tomldiffbeforeafterboth--- a/runtime/unique/Cargo.toml
+++ b/runtime/unique/Cargo.toml
@@ -183,6 +183,7 @@
app-promotion = []
collator-selection = []
foreign-assets = []
+governance = []
refungible = []
scheduler = []