git.delta.rocks / unique-network / refs/commits / 22e4325fd490

difftreelog

Merge pull request #1033 from UniqueNetwork/fix/enable-gov-on-unique

Yaroslav Bolyukin2023-11-03parents: #4f574e9 #88b31e7.patch.diff
in: master

10 files changed

modified.github/workflows/governance.ymldiffbeforeafterboth
--- a/.github/workflows/governance.yml
+++ b/.github/workflows/governance.yml
@@ -31,6 +31,7 @@
         id: create_matrix
         with:
           matrix: |
+            network {unique}, wasm_name {unique}
             network {quartz}, wasm_name {quartz}
             network {opal}, wasm_name {opal}
             network {sapphire}, wasm_name {quartz}
addedruntime/common/config/governance/identity.rsdiffbeforeafterboth
--- /dev/null
+++ b/runtime/common/config/governance/identity.rs
@@ -0,0 +1,33 @@
+use frame_support::parameter_types;
+use up_common::constants::{MILLIUNIQUE, UNIQUE};
+
+use crate::{
+	runtime_common::config::governance, Balance, Balances, Runtime, RuntimeEvent, Treasury,
+};
+
+parameter_types! {
+	// These do not matter as we forbid non-gov operations with the identity pallet
+	pub const BasicDeposit: Balance = 10 * UNIQUE;
+	pub const FieldDeposit: Balance = 25 * MILLIUNIQUE;
+	pub const SubAccountDeposit: Balance = 2 * UNIQUE;
+	pub const MaxSubAccounts: u32 = 100;
+	pub const MaxAdditionalFields: u32 = 100;
+	pub const MaxRegistrars: u32 = 20;
+}
+
+impl pallet_identity::Config for Runtime {
+	type RuntimeEvent = RuntimeEvent;
+	type Currency = Balances;
+	type BasicDeposit = BasicDeposit;
+	type FieldDeposit = FieldDeposit;
+	type MaxAdditionalFields = MaxAdditionalFields;
+	type MaxRegistrars = MaxRegistrars;
+	type MaxSubAccounts = MaxSubAccounts;
+	type SubAccountDeposit = SubAccountDeposit;
+
+	type RegistrarOrigin = governance::RootOrTechnicalCommitteeMember;
+	type ForceOrigin = governance::RootOrTechnicalCommitteeMember;
+
+	type Slashed = Treasury;
+	type WeightInfo = pallet_identity::weights::SubstrateWeight<Runtime>;
+}
modifiedruntime/common/config/governance/mod.rsdiffbeforeafterboth
--- a/runtime/common/config/governance/mod.rs
+++ b/runtime/common/config/governance/mod.rs
@@ -55,6 +55,8 @@
 pub mod scheduler;
 pub use scheduler::*;
 
+pub mod identity;
+
 impl pallet_gov_origins::Config for Runtime {}
 
 morph_types! {
modifiedruntime/common/config/pallets/collator_selection.rsdiffbeforeafterboth
--- a/runtime/common/config/pallets/collator_selection.rs
+++ b/runtime/common/config/pallets/collator_selection.rs
@@ -22,14 +22,13 @@
 	CollatorSelectionLicenseBondOverride,
 };
 use sp_runtime::Perbill;
-use up_common::constants::{MILLIUNIQUE, UNIQUE};
 
 #[cfg(feature = "governance")]
 use crate::config::governance;
 use crate::{
 	config::pallets::{MaxCollators, SessionPeriod, TreasuryAccountId},
 	Aura, Balance, Balances, BlockNumber, CollatorSelection, Runtime, RuntimeEvent,
-	RuntimeHoldReason, Session, SessionKeys, Treasury,
+	RuntimeHoldReason, Session, SessionKeys,
 };
 parameter_types! {
 	pub const SessionOffset: BlockNumber = 0;
@@ -59,43 +58,9 @@
 }
 
 parameter_types! {
-	// These do not matter as we forbid non-sudo operations with the identity pallet
-	pub const BasicDeposit: Balance = 10 * UNIQUE;
-	pub const FieldDeposit: Balance = 25 * MILLIUNIQUE;
-	pub const SubAccountDeposit: Balance = 2 * UNIQUE;
-	pub const MaxSubAccounts: u32 = 100;
-	pub const MaxAdditionalFields: u32 = 100;
-	pub const MaxRegistrars: u32 = 20;
-	pub const LicenceBondIdentifier: [u8; 16] = *b"licenceidentifie";
 	pub LicenseBond: Balance =  CollatorSelectionLicenseBondOverride::<Runtime>::get();
 	pub DesiredCollators: u32 = CollatorSelectionDesiredCollatorsOverride::<Runtime>::get();
 	pub KickThreshold: BlockNumber = CollatorSelectionKickThresholdOverride::<Runtime>::get();
-}
-
-impl pallet_identity::Config for Runtime {
-	type RuntimeEvent = RuntimeEvent;
-	type Currency = Balances;
-	type BasicDeposit = BasicDeposit;
-	type FieldDeposit = FieldDeposit;
-	type MaxAdditionalFields = MaxAdditionalFields;
-	type MaxRegistrars = MaxRegistrars;
-	type MaxSubAccounts = MaxSubAccounts;
-	type SubAccountDeposit = SubAccountDeposit;
-
-	#[cfg(feature = "governance")]
-	type RegistrarOrigin = governance::RootOrTechnicalCommitteeMember;
-
-	#[cfg(feature = "governance")]
-	type ForceOrigin = governance::RootOrTechnicalCommitteeMember;
-
-	#[cfg(not(feature = "governance"))]
-	type RegistrarOrigin = EnsureRoot<<Self as frame_system::Config>::AccountId>;
-
-	#[cfg(not(feature = "governance"))]
-	type ForceOrigin = EnsureRoot<<Self as frame_system::Config>::AccountId>;
-
-	type Slashed = Treasury;
-	type WeightInfo = pallet_identity::weights::SubstrateWeight<Runtime>;
 }
 
 parameter_types! {
modifiedruntime/common/construct_runtime.rsdiffbeforeafterboth
--- a/runtime/common/construct_runtime.rs
+++ b/runtime/common/construct_runtime.rs
@@ -50,7 +50,7 @@
 				Tokens: orml_tokens = 39,
 				// Contracts: pallet_contracts::{Pallet, Call, Storage, Event<T>} = 38,
 
-				#[cfg(feature = "collator-selection")]
+				#[cfg(feature = "governance")]
 				Identity: pallet_identity = 40,
 
 				#[cfg(feature = "preimage")]
modifiedruntime/common/identity.rsdiffbeforeafterboth
--- a/runtime/common/identity.rs
+++ b/runtime/common/identity.rs
@@ -16,7 +16,7 @@
 
 use parity_scale_codec::{Decode, Encode};
 use scale_info::TypeInfo;
-#[cfg(feature = "collator-selection")]
+#[cfg(feature = "governance")]
 use sp_runtime::transaction_validity::InvalidTransaction;
 use sp_runtime::{
 	traits::{DispatchInfoOf, SignedExtension},
@@ -59,7 +59,7 @@
 		_len: usize,
 	) -> TransactionValidity {
 		match call {
-			#[cfg(feature = "collator-selection")]
+			#[cfg(feature = "governance")]
 			RuntimeCall::Identity(_) => Err(TransactionValidityError::Invalid(InvalidTransaction::Call)),
 			_ => Ok(ValidTransaction::default()),
 		}
modifiedruntime/common/maintenance.rsdiffbeforeafterboth
--- a/runtime/common/maintenance.rs
+++ b/runtime/common/maintenance.rs
@@ -78,9 +78,12 @@
 				}
 
 				#[cfg(feature = "collator-selection")]
-				RuntimeCall::CollatorSelection(_)
-				| RuntimeCall::Session(_)
-				| RuntimeCall::Identity(_) => Err(TransactionValidityError::Invalid(InvalidTransaction::Call)),
+				RuntimeCall::CollatorSelection(_) | RuntimeCall::Session(_) => {
+					Err(TransactionValidityError::Invalid(InvalidTransaction::Call))
+				}
+
+				#[cfg(feature = "governance")]
+				RuntimeCall::Identity(_) => Err(TransactionValidityError::Invalid(InvalidTransaction::Call)),
 
 				#[cfg(feature = "pallet-test-utils")]
 				RuntimeCall::TestUtils(_) => Err(TransactionValidityError::Invalid(InvalidTransaction::Call)),
modifiedruntime/common/runtime_apis.rsdiffbeforeafterboth
--- a/runtime/common/runtime_apis.rs
+++ b/runtime/common/runtime_apis.rs
@@ -551,7 +551,7 @@
 					#[cfg(feature = "collator-selection")]
 					list_benchmark!(list, extra, pallet_collator_selection, CollatorSelection);
 
-					#[cfg(feature = "collator-selection")]
+					#[cfg(feature = "governance")]
 					list_benchmark!(list, extra, pallet_identity, Identity);
 
 					#[cfg(feature = "foreign-assets")]
@@ -615,7 +615,7 @@
 					#[cfg(feature = "collator-selection")]
 					add_benchmark!(params, batches, pallet_collator_selection, CollatorSelection);
 
-					#[cfg(feature = "collator-selection")]
+					#[cfg(feature = "governance")]
 					add_benchmark!(params, batches, pallet_identity, Identity);
 
 					#[cfg(feature = "foreign-assets")]
modifiedruntime/unique/Cargo.tomldiffbeforeafterboth
--- a/runtime/unique/Cargo.toml
+++ b/runtime/unique/Cargo.toml
@@ -214,7 +214,7 @@
 	'pallet-xcm/try-runtime',
 	'parachain-info/try-runtime',
 ]
-unique-runtime = ['app-promotion', 'foreign-assets', 'refungible']
+unique-runtime = ['app-promotion', 'foreign-assets', 'refungible', 'governance', 'preimage']
 
 app-promotion = []
 collator-selection = []
modifiedtests/src/pallet-presence.test.tsdiffbeforeafterboth
before · tests/src/pallet-presence.test.ts
1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617import {itSub, usingPlaygrounds, expect} from './util';1819// Pallets that must always be present20const requiredPallets = [21  'balances',22  'balancesadapter',23  'common',24  'timestamp',25  'transactionpayment',26  'treasury',27  'statetriemigration',28  'structure',29  'system',30  'utility',31  'vesting',32  'parachainsystem',33  'parachaininfo',34  'evm',35  'evmcodersubstrate',36  'evmcontracthelpers',37  'evmmigration',38  'evmtransactionpayment',39  'ethereum',40  'fungible',41  'xcmpqueue',42  'polkadotxcm',43  'cumulusxcm',44  'dmpqueue',45  'inflation',46  'unique',47  'nonfungible',48  'charging',49  'configuration',50  'tokens',51  'xtokens',52  'maintenance',53];5455// Pallets that depend on consensus and governance configuration56const consensusPallets = [57  'sudo',58  'aura',59  'auraext',60];6162describe('Pallet presence', () => {63  before(async () => {64    await usingPlaygrounds(async helper => {65      const runtimeVersion = await helper.callRpc('api.rpc.state.getRuntimeVersion', []);66      const chain = runtimeVersion.specName;6768      const refungible = 'refungible';69      const foreignAssets = 'foreignassets';70      const appPromotion = 'apppromotion';71      const collatorSelection = ['authorship', 'session', 'collatorselection', 'identity'];72      const preimage = ['preimage'];73      const governance = [74        'council',75        'councilmembership',76        'democracy',77        'fellowshipcollective',78        'fellowshipreferenda',79        'origins',80        'scheduler',81        'technicalcommittee',82        'technicalcommitteemembership',83      ];84      const testUtils = 'testutils';8586      if(chain.eq('opal')) {87        requiredPallets.push(88          refungible,89          foreignAssets,90          appPromotion,91          testUtils,92          ...collatorSelection,93          ...preimage,94          ...governance,95        );96      } else if(chain.eq('quartz') || chain.eq('sapphire')) {97        requiredPallets.push(98          refungible,99          appPromotion,100          foreignAssets,101          ...collatorSelection,102          ...preimage,103          ...governance,104        );105      } else if(chain.eq('unique')) {106        // Insert Unique additional pallets here107        requiredPallets.push(108          refungible,109          foreignAssets,110          appPromotion,111        );112      }113    });114  });115116  itSub('Required pallets are present', ({helper}) => {117    expect(helper.fetchAllPalletNames()).to.contain.members([...requiredPallets].sort());118  });119120  itSub('Governance and consensus pallets are present', ({helper}) => {121    expect(helper.fetchAllPalletNames()).to.contain.members([...consensusPallets].sort());122  });123124  itSub('No extra pallets are included', ({helper}) => {125    expect(helper.fetchAllPalletNames().sort()).to.be.deep.equal([...requiredPallets, ...consensusPallets].sort());126  });127});
after · tests/src/pallet-presence.test.ts
1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617import {itSub, usingPlaygrounds, expect} from './util';1819// Pallets that must always be present20const requiredPallets = [21  'balances',22  'balancesadapter',23  'common',24  'timestamp',25  'transactionpayment',26  'treasury',27  'statetriemigration',28  'structure',29  'system',30  'utility',31  'vesting',32  'parachainsystem',33  'parachaininfo',34  'evm',35  'evmcodersubstrate',36  'evmcontracthelpers',37  'evmmigration',38  'evmtransactionpayment',39  'ethereum',40  'fungible',41  'xcmpqueue',42  'polkadotxcm',43  'cumulusxcm',44  'dmpqueue',45  'inflation',46  'unique',47  'nonfungible',48  'charging',49  'configuration',50  'tokens',51  'xtokens',52  'maintenance',53];5455// Pallets that depend on consensus and governance configuration56const consensusPallets = [57  'sudo',58  'aura',59  'auraext',60];6162describe('Pallet presence', () => {63  before(async () => {64    await usingPlaygrounds(async helper => {65      const runtimeVersion = await helper.callRpc('api.rpc.state.getRuntimeVersion', []);66      const chain = runtimeVersion.specName;6768      const refungible = 'refungible';69      const foreignAssets = 'foreignassets';70      const appPromotion = 'apppromotion';71      const collatorSelection = ['authorship', 'session', 'collatorselection'];72      const preimage = ['preimage'];73      const governance = [74        'council',75        'councilmembership',76        'democracy',77        'fellowshipcollective',78        'fellowshipreferenda',79        'origins',80        'scheduler',81        'technicalcommittee',82        'technicalcommitteemembership',83        'identity',84      ];85      const testUtils = 'testutils';8687      if(chain.eq('opal')) {88        requiredPallets.push(89          refungible,90          foreignAssets,91          appPromotion,92          testUtils,93          ...collatorSelection,94          ...preimage,95          ...governance,96        );97      } else if(chain.eq('quartz') || chain.eq('sapphire')) {98        requiredPallets.push(99          refungible,100          appPromotion,101          foreignAssets,102          ...collatorSelection,103          ...preimage,104          ...governance,105        );106      } else if(chain.eq('unique')) {107        // Insert Unique additional pallets here108        requiredPallets.push(109          refungible,110          foreignAssets,111          appPromotion,112          ...preimage,113          ...governance,114        );115      }116    });117  });118119  itSub('Required pallets are present', ({helper}) => {120    expect(helper.fetchAllPalletNames()).to.contain.members([...requiredPallets].sort());121  });122123  itSub('Governance and consensus pallets are present', ({helper}) => {124    expect(helper.fetchAllPalletNames()).to.contain.members([...consensusPallets].sort());125  });126127  itSub('No extra pallets are included', ({helper}) => {128    expect(helper.fetchAllPalletNames().sort()).to.be.deep.equal([...requiredPallets, ...consensusPallets].sort());129  });130});