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
--- a/pallets/maintenance/src/benchmarking.rs
+++ b/pallets/maintenance/src/benchmarking.rs
@@ -23,30 +23,6 @@
 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)
modifiedpallets/maintenance/src/lib.rsdiffbeforeafterboth
--- a/pallets/maintenance/src/lib.rs
+++ b/pallets/maintenance/src/lib.rs
@@ -25,10 +25,7 @@
 
 #[frame_support::pallet]
 pub mod pallet {
-	use frame_support::{
-		dispatch::*,
-		pallet_prelude::*,
-	};
+	use frame_support::{dispatch::*, pallet_prelude::*};
 	use frame_support::{
 		traits::{QueryPreimage, StorePreimage},
 	};
@@ -108,11 +105,11 @@
 		#[pallet::call_index(2)]
 		#[pallet::weight(<T as Config>::WeightInfo::execute_preimage())]
 		pub fn execute_preimage(_origin: OriginFor<T>, _hash: H256) -> DispatchResult {
-			#[cfg(feature = "governance")]
+			#[cfg(feature = "preimage")]
 			{
 				let origin = _origin;
 				let hash = _hash;
-				
+
 				ensure_root(origin)?;
 
 				let len = T::Preimages::len(&hash).ok_or(DispatchError::Unavailable)?;
@@ -128,7 +125,7 @@
 				result
 			}
 
-			#[cfg(not(feature = "governance"))]
+			#[cfg(not(feature = "preimage"))]
 			{
 				Err(DispatchError::Unavailable)
 			}
deletedruntime/common/config/pallets/governance.rsdiffbeforeafterboth
--- a/runtime/common/config/pallets/governance.rs
+++ /dev/null
@@ -1,34 +0,0 @@
-// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.
-// This file is part of Unique Network.
-
-// Unique Network is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-
-// Unique Network is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
-
-// You should have received a copy of the GNU General Public License
-// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
-
-use frame_support::parameter_types;
-use frame_system::EnsureRoot;
-use crate::{AccountId, Balance, Balances, Runtime, RuntimeEvent};
-use up_common::constants::*;
-
-parameter_types! {
-	pub PreimageBaseDeposit: Balance = 1000 * UNIQUE; // deposit(2, 64);
-	// pub PreimageByteDeposit: Balance = 1 * CENTIUNIQUE; // deposit(0, 1);
-}
-
-impl pallet_preimage::Config for Runtime {
-	type WeightInfo = pallet_preimage::weights::SubstrateWeight<Runtime>;
-	type RuntimeEvent = RuntimeEvent;
-	type Currency = Balances;
-	type ManagerOrigin = EnsureRoot<AccountId>;
-	type BaseDeposit = PreimageBaseDeposit;
-	type ByteDeposit = TransactionByteFee;
-}
modifiedruntime/common/config/pallets/mod.rsdiffbeforeafterboth
--- a/runtime/common/config/pallets/mod.rs
+++ b/runtime/common/config/pallets/mod.rs
@@ -47,8 +47,8 @@
 #[cfg(feature = "collator-selection")]
 pub mod collator_selection;
 
-#[cfg(feature = "governance")]
-pub mod governance;
+#[cfg(feature = "preimage")]
+pub mod preimage;
 
 parameter_types! {
 	pub TreasuryAccountId: AccountId = TreasuryModuleId::get().into_account_truncating();
@@ -128,9 +128,9 @@
 	type RuntimeEvent = RuntimeEvent;
 	type RuntimeOrigin = RuntimeOrigin;
 	type RuntimeCall = RuntimeCall;
-	#[cfg(feature = "governance")]
+	#[cfg(feature = "preimage")]
 	type Preimages = crate::Preimage;
-	#[cfg(not(feature = "governance"))]
+	#[cfg(not(feature = "preimage"))]
 	type Preimages = ();
 	type WeightInfo = pallet_maintenance::weights::SubstrateWeight<Self>;
 }
addedruntime/common/config/pallets/preimage.rsdiffbeforeafterboth
--- /dev/null
+++ b/runtime/common/config/pallets/preimage.rs
@@ -0,0 +1,34 @@
+// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.
+// This file is part of Unique Network.
+
+// Unique Network is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+
+// Unique Network is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
+
+use frame_support::parameter_types;
+use frame_system::EnsureRoot;
+use crate::{AccountId, Balance, Balances, Runtime, RuntimeEvent};
+use up_common::constants::*;
+
+parameter_types! {
+	pub PreimageBaseDeposit: Balance = 1000 * UNIQUE; // deposit(2, 64);
+	// pub PreimageByteDeposit: Balance = 1 * CENTIUNIQUE; // deposit(0, 1);
+}
+
+impl pallet_preimage::Config for Runtime {
+	type WeightInfo = pallet_preimage::weights::SubstrateWeight<Runtime>;
+	type RuntimeEvent = RuntimeEvent;
+	type Currency = Balances;
+	type ManagerOrigin = EnsureRoot<AccountId>;
+	type BaseDeposit = PreimageBaseDeposit;
+	type ByteDeposit = TransactionByteFee;
+}
modifiedruntime/common/construct_runtime.rsdiffbeforeafterboth
--- a/runtime/common/construct_runtime.rs
+++ b/runtime/common/construct_runtime.rs
@@ -56,7 +56,7 @@
                 #[cfg(feature = "collator-selection")]
                 Identity: pallet_identity::{Pallet, Call, Storage, Event<T>} = 40,
 
-                #[cfg(feature = "governance")]
+                #[cfg(feature = "preimage")]
                 Preimage: pallet_preimage::{Pallet, Call, Storage, Event<T>} = 41,
 
                 // XCM helpers.
modifiedruntime/common/maintenance.rsdiffbeforeafterboth
--- a/runtime/common/maintenance.rs
+++ b/runtime/common/maintenance.rs
@@ -86,7 +86,7 @@
 				| RuntimeCall::Session(_)
 				| RuntimeCall::Identity(_) => Err(TransactionValidityError::Invalid(InvalidTransaction::Call)),
 
-				#[cfg(feature = "governance")]
+				#[cfg(feature = "preimage")]
 				RuntimeCall::Preimage(_) => Err(TransactionValidityError::Invalid(InvalidTransaction::Call)),
 
 				#[cfg(feature = "pallet-test-utils")]
modifiedruntime/common/runtime_apis.rsdiffbeforeafterboth
--- a/runtime/common/runtime_apis.rs
+++ b/runtime/common/runtime_apis.rs
@@ -565,7 +565,7 @@
                     #[cfg(feature = "collator-selection")]
                     list_benchmark!(list, extra, pallet_identity, Identity);
 
-                    #[cfg(feature = "governance")]
+                    #[cfg(feature = "preimage")]
                     list_benchmark!(list, extra, pallet_preimage, Preimage);
 
                     #[cfg(feature = "foreign-assets")]
@@ -632,7 +632,7 @@
                     #[cfg(feature = "collator-selection")]
                     add_benchmark!(params, batches, pallet_identity, Identity);
 
-                    #[cfg(feature = "governance")]
+                    #[cfg(feature = "preimage")]
                     add_benchmark!(params, batches, pallet_preimage, Preimage);
 
                     #[cfg(feature = "foreign-assets")]
modifiedruntime/opal/Cargo.tomldiffbeforeafterboth
before · runtime/opal/Cargo.toml
1################################################################################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', 'governance', '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 = []194governance = []195pallet-test-utils = []196refungible = []197scheduler = []198199################################################################################200# local dependencies201202[dependencies]203# Note: `package = "parity-scale-codec"` must be supplied since the `Encode` macro searches for it.204codec = { workspace = true, package = "parity-scale-codec" }205206cumulus-pallet-aura-ext = { workspace = true }207cumulus-pallet-dmp-queue = { workspace = true }208cumulus-pallet-parachain-system = { workspace = true }209cumulus-pallet-xcm = { workspace = true }210cumulus-pallet-xcmp-queue = { workspace = true }211cumulus-primitives-core = { workspace = true }212cumulus-primitives-timestamp = { workspace = true }213cumulus-primitives-utility = { workspace = true }214frame-executive = { workspace = true }215frame-support = { workspace = true }216frame-system = { workspace = true }217frame-system-rpc-runtime-api = { workspace = true }218orml-tokens = { workspace = true }219orml-traits = { workspace = true }220orml-vesting = { workspace = true }221orml-xtokens = { workspace = true }222pallet-aura = { workspace = true }223pallet-authorship = { workspace = true }224pallet-balances = { workspace = true }225pallet-preimage = { workspace = true }226pallet-randomness-collective-flip = { workspace = true }227pallet-session = { workspace = true }228pallet-sudo = { workspace = true }229pallet-timestamp = { workspace = true }230pallet-transaction-payment = { workspace = true }231pallet-transaction-payment-rpc-runtime-api = { workspace = true }232pallet-treasury = { workspace = true }233pallet-xcm = { workspace = true }234parachain-info = { workspace = true }235polkadot-parachain = { workspace = true }236smallvec = { workspace = true }237sp-api = { workspace = true }238sp-arithmetic = { workspace = true }239sp-block-builder = { workspace = true }240sp-consensus-aura = { workspace = true }241sp-core = { workspace = true }242sp-inherents = { workspace = true }243sp-io = { workspace = true }244sp-offchain = { workspace = true }245sp-runtime = { workspace = true }246sp-session = { workspace = true }247sp-std = { workspace = true }248sp-transaction-pool = { workspace = true }249sp-version = { workspace = true }250xcm = { workspace = true }251xcm-builder = { workspace = true }252xcm-executor = { workspace = true }253254app-promotion-rpc = { workspace = true }255derivative = { workspace = true }256evm-coder = { workspace = true }257fp-evm = { workspace = true }258fp-evm-mapping = { workspace = true }259fp-rpc = { workspace = true }260fp-self-contained = { workspace = true }261log = { workspace = true }262num_enum = { workspace = true }263pallet-app-promotion = { workspace = true }264pallet-base-fee = { workspace = true }265pallet-charge-transaction = { workspace = true }266pallet-collator-selection = { workspace = true }267pallet-common = { workspace = true }268pallet-configuration = { workspace = true }269pallet-ethereum = { workspace = true }270pallet-evm = { workspace = true }271pallet-evm-coder-substrate = { workspace = true }272pallet-evm-contract-helpers = { workspace = true }273pallet-evm-migration = { workspace = true }274pallet-evm-precompile-simple = { workspace = true }275pallet-evm-transaction-payment = { workspace = true }276pallet-foreign-assets = { workspace = true }277pallet-fungible = { workspace = true }278pallet-identity = { workspace = true }279pallet-inflation = { workspace = true }280pallet-maintenance = { workspace = true }281pallet-nonfungible = { workspace = true }282pallet-refungible = { workspace = true }283pallet-structure = { workspace = true }284pallet-unique = { workspace = true }285pallet-unique-scheduler-v2 = { workspace = true }286precompile-utils-macro = { workspace = true }287scale-info = { workspace = true }288up-common = { workspace = true }289up-data-structs = { workspace = true }290up-pov-estimate-rpc = { workspace = true }291up-rpc = { workspace = true }292up-sponsorship = { workspace = true }293294################################################################################295# Optional dependencies296297frame-system-benchmarking = { workspace = true, optional = true}298frame-benchmarking = { workspace = true, optional = true }299frame-try-runtime = { workspace = true, optional = true }300serde = { workspace = true, optional = true }301hex-literal = { workspace = true, optional = true }302303################################################################################304# Test dependencies305306pallet-test-utils = { workspace = true }307308################################################################################309# Other Dependencies310311impl-trait-for-tuples = { workspace = true }312313[dev-dependencies]314logtest = { workspace = true }315316[build-dependencies]317substrate-wasm-builder = { workspace = true }
modifiedruntime/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', 'governance', 'refungible']
+quartz-runtime = ['app-promotion', 'collator-selection', 'foreign-assets', 'preimage', 'refungible']
 runtime-benchmarks = [
 	'cumulus-pallet-parachain-system/runtime-benchmarks',
 	'frame-benchmarking',
@@ -184,7 +184,7 @@
 app-promotion = []
 collator-selection = []
 foreign-assets = []
-governance = []
+preimage = []
 refungible = []
 scheduler = []
 
modifiedruntime/unique/Cargo.tomldiffbeforeafterboth
--- a/runtime/unique/Cargo.toml
+++ b/runtime/unique/Cargo.toml
@@ -183,7 +183,7 @@
 app-promotion = []
 collator-selection = []
 foreign-assets = []
-governance = []
+preimage = []
 refungible = []
 scheduler = []
 
modifiedtests/src/pallet-presence.test.tsdiffbeforeafterboth
--- a/tests/src/pallet-presence.test.ts
+++ b/tests/src/pallet-presence.test.ts
@@ -66,7 +66,7 @@
       const foreignAssets = 'foreignassets';
       const appPromotion = 'apppromotion';
       const collatorSelection = ['authorship', 'session', 'collatorselection', 'identity'];
-      const governance = ['preimage'];
+      const preimage = ['preimage'];
       const testUtils = 'testutils';
 
       if (chain.eq('OPAL by UNIQUE')) {
@@ -76,7 +76,7 @@
           appPromotion,
           testUtils,
           ...collatorSelection,
-          ...governance,
+          ...preimage,
         );
       } else if (chain.eq('QUARTZ by UNIQUE') || chain.eq('SAPPHIRE by UNIQUE')) {
         requiredPallets.push(
@@ -84,7 +84,7 @@
           appPromotion,
           foreignAssets,
           ...collatorSelection,
-          ...governance,
+          ...preimage,
         );
       } else if (chain.eq('UNIQUE')) {
         // Insert Unique additional pallets here