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.rsdiffbeforeafterboth--- a/runtime/common/config/pallets/mod.rs
+++ b/runtime/common/config/pallets/mod.rs
@@ -23,7 +23,7 @@
weights::CommonWeights,
RelayChainBlockNumberProvider,
},
- Runtime, RuntimeEvent, RuntimeCall, RuntimeOrigin, Balances, Preimage,
+ Runtime, RuntimeEvent, RuntimeCall, RuntimeOrigin, Balances,
};
use frame_support::traits::{ConstU32, ConstU64};
use up_common::{
@@ -47,8 +47,7 @@
#[cfg(feature = "collator-selection")]
pub mod collator_selection;
-// todo:governance replace the feature with governance
-#[cfg(feature = "collator-selection")]
+#[cfg(feature = "governance")]
pub mod governance;
parameter_types! {
@@ -129,6 +128,9 @@
type RuntimeEvent = RuntimeEvent;
type RuntimeOrigin = RuntimeOrigin;
type RuntimeCall = RuntimeCall;
- type Preimages = Preimage;
+ #[cfg(feature = "governance")]
+ type Preimages = crate::Preimage;
+ #[cfg(not(feature = "governance"))]
+ type Preimages = ();
type WeightInfo = pallet_maintenance::weights::SubstrateWeight<Self>;
}
runtime/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.tomldiffbeforeafterboth1################################################################################2# Package34[package]5authors = ['Unique Network <support@uniquenetwork.io>']6build = 'build.rs'7description = 'Opal Runtime'8edition = '2021'9homepage = 'https://unique.network'10license = 'GPLv3'11name = 'opal-runtime'12repository = 'https://github.com/UniqueNetwork/unique-chain'13version.workspace = true1415[package.metadata.docs.rs]16targets = ['x86_64-unknown-linux-gnu']1718[features]19default = ['opal-runtime', 'std']20limit-testing = ['pallet-unique/limit-testing', 'up-data-structs/limit-testing']21opal-runtime = ['app-promotion', 'collator-selection', 'foreign-assets', 'pallet-test-utils', 'refungible']22pov-estimate = []23runtime-benchmarks = [24 'cumulus-pallet-parachain-system/runtime-benchmarks',25 'frame-benchmarking',26 'frame-support/runtime-benchmarks',27 'frame-system-benchmarking',28 'frame-system/runtime-benchmarks',29 'hex-literal',30 'pallet-app-promotion/runtime-benchmarks',31 'pallet-balances/runtime-benchmarks',32 'pallet-collator-selection/runtime-benchmarks',33 'pallet-common/runtime-benchmarks',34 'pallet-configuration/runtime-benchmarks',35 'pallet-ethereum/runtime-benchmarks',36 'pallet-evm-coder-substrate/runtime-benchmarks',37 'pallet-evm-migration/runtime-benchmarks',38 'pallet-foreign-assets/runtime-benchmarks',39 'pallet-fungible/runtime-benchmarks',40 'pallet-identity/runtime-benchmarks',41 'pallet-inflation/runtime-benchmarks',42 'pallet-maintenance/runtime-benchmarks',43 'pallet-nonfungible/runtime-benchmarks',44 "pallet-preimage/runtime-benchmarks",45 'pallet-refungible/runtime-benchmarks',46 'pallet-structure/runtime-benchmarks',47 'pallet-timestamp/runtime-benchmarks',48 'pallet-unique-scheduler-v2/runtime-benchmarks',49 'pallet-unique/runtime-benchmarks',50 'pallet-xcm/runtime-benchmarks',51 'sp-runtime/runtime-benchmarks',52 'xcm-builder/runtime-benchmarks',53]54std = [55 'codec/std',56 'cumulus-pallet-aura-ext/std',57 'cumulus-pallet-parachain-system/std',58 'cumulus-pallet-xcm/std',59 'cumulus-pallet-xcmp-queue/std',60 'cumulus-primitives-core/std',61 'cumulus-primitives-utility/std',62 'frame-executive/std',63 'frame-support/std',64 'frame-system-rpc-runtime-api/std',65 'frame-system/std',66 'frame-try-runtime/std',67 'pallet-aura/std',68 'pallet-balances/std',69 # 'pallet-contracts/std',70 # 'pallet-contracts-primitives/std',71 # 'pallet-contracts-rpc-runtime-api/std',72 # 'pallet-contract-helpers/std',73 "pallet-preimage/std",74 "pallet-authorship/std",75 "pallet-session/std",76 "sp-consensus-aura/std",77 'app-promotion-rpc/std',78 'evm-coder/std',79 'fp-evm-mapping/std',80 'fp-rpc/std',81 'fp-self-contained/std',82 'pallet-app-promotion/std',83 'pallet-base-fee/std',84 'pallet-charge-transaction/std',85 'pallet-collator-selection/std',86 'pallet-common/std',87 'pallet-configuration/std',88 'pallet-ethereum/std',89 'pallet-evm-coder-substrate/std',90 'pallet-evm-contract-helpers/std',91 'pallet-evm-migration/std',92 'pallet-evm-transaction-payment/std',93 'pallet-evm/std',94 'pallet-fungible/std',95 'pallet-identity/std',96 'pallet-inflation/std',97 'pallet-nonfungible/std',98 'pallet-randomness-collective-flip/std',99 'pallet-refungible/std',100 'pallet-structure/std',101 'pallet-sudo/std',102 'pallet-timestamp/std',103 'pallet-transaction-payment-rpc-runtime-api/std',104 'pallet-transaction-payment/std',105 'pallet-treasury/std',106 'pallet-unique-scheduler-v2/std',107 'pallet-unique/std',108 'parachain-info/std',109 'serde',110 'sp-api/std',111 'sp-block-builder/std',112 'sp-core/std',113 'sp-inherents/std',114 'sp-io/std',115 'sp-offchain/std',116 'sp-runtime/std',117 'sp-session/std',118 'sp-std/std',119 'sp-transaction-pool/std',120 'sp-version/std',121 'up-common/std',122 'up-data-structs/std',123 'up-pov-estimate-rpc/std',124 'up-rpc/std',125 'up-sponsorship/std',126 'xcm-builder/std',127 'xcm-executor/std',128 'xcm/std',129130 "orml-tokens/std",131 "orml-traits/std",132 "orml-vesting/std",133 "orml-xtokens/std",134 "pallet-foreign-assets/std",135136 'pallet-maintenance/std',137 'pallet-test-utils/std',138]139try-runtime = [140 "pallet-authorship/try-runtime",141 "pallet-collator-selection/try-runtime",142 "pallet-identity/try-runtime",143 "pallet-session/try-runtime",144 "pallet-preimage/try-runtime",145 'cumulus-pallet-aura-ext/try-runtime',146 'cumulus-pallet-dmp-queue/try-runtime',147 'cumulus-pallet-parachain-system/try-runtime',148 'cumulus-pallet-xcm/try-runtime',149 'cumulus-pallet-xcmp-queue/try-runtime',150 'fp-self-contained/try-runtime',151 'frame-executive/try-runtime',152 'frame-support/try-runtime',153 'frame-system/try-runtime',154 'frame-try-runtime',155 'frame-try-runtime?/try-runtime',156 'orml-tokens/try-runtime',157 'orml-vesting/try-runtime',158 'orml-xtokens/try-runtime',159 'pallet-app-promotion/try-runtime',160 'pallet-aura/try-runtime',161 'pallet-balances/try-runtime',162 'pallet-base-fee/try-runtime',163 'pallet-charge-transaction/try-runtime',164 'pallet-common/try-runtime',165 'pallet-configuration/try-runtime',166 'pallet-ethereum/try-runtime',167 'pallet-evm-coder-substrate/try-runtime',168 'pallet-evm-contract-helpers/try-runtime',169 'pallet-evm-migration/try-runtime',170 'pallet-evm-transaction-payment/try-runtime',171 'pallet-evm/try-runtime',172 'pallet-foreign-assets/try-runtime',173 'pallet-fungible/try-runtime',174 'pallet-inflation/try-runtime',175 'pallet-maintenance/try-runtime',176 'pallet-nonfungible/try-runtime',177 'pallet-randomness-collective-flip/try-runtime',178 'pallet-refungible/try-runtime',179 'pallet-structure/try-runtime',180 'pallet-sudo/try-runtime',181 'pallet-test-utils/try-runtime',182 'pallet-timestamp/try-runtime',183 'pallet-transaction-payment/try-runtime',184 'pallet-treasury/try-runtime',185 'pallet-unique-scheduler-v2/try-runtime',186 'pallet-unique/try-runtime',187 'pallet-xcm/try-runtime',188 'parachain-info/try-runtime',189]190191app-promotion = []192collator-selection = []193foreign-assets = []194pallet-test-utils = []195refungible = []196scheduler = []197198################################################################################199# local dependencies200201[dependencies]202# Note: `package = "parity-scale-codec"` must be supplied since the `Encode` macro searches for it.203codec = { workspace = true, package = "parity-scale-codec" }204205cumulus-pallet-aura-ext = { workspace = true }206cumulus-pallet-dmp-queue = { workspace = true }207cumulus-pallet-parachain-system = { workspace = true }208cumulus-pallet-xcm = { workspace = true }209cumulus-pallet-xcmp-queue = { workspace = true }210cumulus-primitives-core = { workspace = true }211cumulus-primitives-timestamp = { workspace = true }212cumulus-primitives-utility = { workspace = true }213frame-executive = { workspace = true }214frame-support = { workspace = true }215frame-system = { workspace = true }216frame-system-rpc-runtime-api = { workspace = true }217orml-tokens = { workspace = true }218orml-traits = { workspace = true }219orml-vesting = { workspace = true }220orml-xtokens = { workspace = true }221pallet-aura = { workspace = true }222pallet-authorship = { workspace = true }223pallet-balances = { workspace = true }224pallet-preimage = { workspace = true }225pallet-randomness-collective-flip = { workspace = true }226pallet-session = { workspace = true }227pallet-sudo = { workspace = true }228pallet-timestamp = { workspace = true }229pallet-transaction-payment = { workspace = true }230pallet-transaction-payment-rpc-runtime-api = { workspace = true }231pallet-treasury = { workspace = true }232pallet-xcm = { workspace = true }233parachain-info = { workspace = true }234polkadot-parachain = { workspace = true }235smallvec = { workspace = true }236sp-api = { workspace = true }237sp-arithmetic = { workspace = true }238sp-block-builder = { workspace = true }239sp-consensus-aura = { workspace = true }240sp-core = { workspace = true }241sp-inherents = { workspace = true }242sp-io = { workspace = true }243sp-offchain = { workspace = true }244sp-runtime = { workspace = true }245sp-session = { workspace = true }246sp-std = { workspace = true }247sp-transaction-pool = { workspace = true }248sp-version = { workspace = true }249xcm = { workspace = true }250xcm-builder = { workspace = true }251xcm-executor = { workspace = true }252253app-promotion-rpc = { workspace = true }254derivative = { workspace = true }255evm-coder = { workspace = true }256fp-evm = { workspace = true }257fp-evm-mapping = { workspace = true }258fp-rpc = { workspace = true }259fp-self-contained = { workspace = true }260log = { workspace = true }261num_enum = { workspace = true }262pallet-app-promotion = { workspace = true }263pallet-base-fee = { workspace = true }264pallet-charge-transaction = { workspace = true }265pallet-collator-selection = { workspace = true }266pallet-common = { workspace = true }267pallet-configuration = { workspace = true }268pallet-ethereum = { workspace = true }269pallet-evm = { workspace = true }270pallet-evm-coder-substrate = { workspace = true }271pallet-evm-contract-helpers = { workspace = true }272pallet-evm-migration = { workspace = true }273pallet-evm-precompile-simple = { workspace = true }274pallet-evm-transaction-payment = { workspace = true }275pallet-foreign-assets = { workspace = true }276pallet-fungible = { workspace = true }277pallet-identity = { workspace = true }278pallet-inflation = { workspace = true }279pallet-maintenance = { workspace = true }280pallet-nonfungible = { workspace = true }281pallet-refungible = { workspace = true }282pallet-structure = { workspace = true }283pallet-unique = { workspace = true }284pallet-unique-scheduler-v2 = { workspace = true }285precompile-utils-macro = { workspace = true }286scale-info = { workspace = true }287up-common = { workspace = true }288up-data-structs = { workspace = true }289up-pov-estimate-rpc = { workspace = true }290up-rpc = { workspace = true }291up-sponsorship = { workspace = true }292293################################################################################294# Optional dependencies295296frame-system-benchmarking = { workspace = true, optional = true}297frame-benchmarking = { workspace = true, optional = true }298frame-try-runtime = { workspace = true, optional = true }299serde = { workspace = true, optional = true }300hex-literal = { workspace = true, optional = true }301302################################################################################303# Test dependencies304305pallet-test-utils = { workspace = true }306307################################################################################308# Other Dependencies309310impl-trait-for-tuples = { workspace = true }311312[dev-dependencies]313logtest = { workspace = true }314315[build-dependencies]316substrate-wasm-builder = { workspace = true }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 = []