git.delta.rocks / unique-network / refs/commits / 64ac6cdfa3e0

difftreelog

fix enable governance on Unique

Daniel Shiposha2023-11-02parent: #4f574e9.patch.diff
in: master

9 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
before · runtime/common/config/pallets/collator_selection.rs
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/>.1617use frame_support::{parameter_types, PalletId};18#[cfg(not(feature = "governance"))]19use frame_system::EnsureRoot;20use pallet_configuration::{21	CollatorSelectionDesiredCollatorsOverride, CollatorSelectionKickThresholdOverride,22	CollatorSelectionLicenseBondOverride,23};24use sp_runtime::Perbill;25use up_common::constants::{MILLIUNIQUE, UNIQUE};2627#[cfg(feature = "governance")]28use crate::config::governance;29use crate::{30	config::pallets::{MaxCollators, SessionPeriod, TreasuryAccountId},31	Aura, Balance, Balances, BlockNumber, CollatorSelection, Runtime, RuntimeEvent,32	RuntimeHoldReason, Session, SessionKeys, Treasury,33};34parameter_types! {35	pub const SessionOffset: BlockNumber = 0;36}3738impl pallet_session::Config for Runtime {39	type RuntimeEvent = RuntimeEvent;40	type ValidatorId = <Self as frame_system::Config>::AccountId;41	// we don't have stash and controller, thus we don't need the convert as well.42	type ValidatorIdOf = pallet_collator_selection::IdentityCollator;43	type ShouldEndSession = pallet_session::PeriodicSessions<SessionPeriod, SessionOffset>;44	type NextSessionRotation = pallet_session::PeriodicSessions<SessionPeriod, SessionOffset>;45	type SessionManager = CollatorSelection;46	// Essentially just Aura, but lets be pedantic.47	type SessionHandler = <SessionKeys as sp_runtime::traits::OpaqueKeys>::KeyTypeIdProviders;48	type Keys = SessionKeys;49	type WeightInfo = pallet_session::weights::SubstrateWeight<Self>; // ();50}5152parameter_types! {53	pub const UncleGenerations: u32 = 0;54}5556impl pallet_authorship::Config for Runtime {57	type FindAuthor = pallet_session::FindAccountFromAuthorIndex<Self, Aura>;58	type EventHandler = CollatorSelection;59}6061parameter_types! {62	// These do not matter as we forbid non-sudo operations with the identity pallet63	pub const BasicDeposit: Balance = 10 * UNIQUE;64	pub const FieldDeposit: Balance = 25 * MILLIUNIQUE;65	pub const SubAccountDeposit: Balance = 2 * UNIQUE;66	pub const MaxSubAccounts: u32 = 100;67	pub const MaxAdditionalFields: u32 = 100;68	pub const MaxRegistrars: u32 = 20;69	pub const LicenceBondIdentifier: [u8; 16] = *b"licenceidentifie";70	pub LicenseBond: Balance =  CollatorSelectionLicenseBondOverride::<Runtime>::get();71	pub DesiredCollators: u32 = CollatorSelectionDesiredCollatorsOverride::<Runtime>::get();72	pub KickThreshold: BlockNumber = CollatorSelectionKickThresholdOverride::<Runtime>::get();73}7475impl pallet_identity::Config for Runtime {76	type RuntimeEvent = RuntimeEvent;77	type Currency = Balances;78	type BasicDeposit = BasicDeposit;79	type FieldDeposit = FieldDeposit;80	type MaxAdditionalFields = MaxAdditionalFields;81	type MaxRegistrars = MaxRegistrars;82	type MaxSubAccounts = MaxSubAccounts;83	type SubAccountDeposit = SubAccountDeposit;8485	#[cfg(feature = "governance")]86	type RegistrarOrigin = governance::RootOrTechnicalCommitteeMember;8788	#[cfg(feature = "governance")]89	type ForceOrigin = governance::RootOrTechnicalCommitteeMember;9091	#[cfg(not(feature = "governance"))]92	type RegistrarOrigin = EnsureRoot<<Self as frame_system::Config>::AccountId>;9394	#[cfg(not(feature = "governance"))]95	type ForceOrigin = EnsureRoot<<Self as frame_system::Config>::AccountId>;9697	type Slashed = Treasury;98	type WeightInfo = pallet_identity::weights::SubstrateWeight<Runtime>;99}100101parameter_types! {102	pub const PotId: PalletId = PalletId(*b"PotStake");103	pub const SlashRatio: Perbill = Perbill::from_percent(100);104}105106impl pallet_collator_selection::Config for Runtime {107	type RuntimeEvent = RuntimeEvent;108	type RuntimeHoldReason = RuntimeHoldReason;109	type Currency = Balances;110	// We allow root only to execute privileged collator selection operations.111112	// We allow root or the unanimous technical committee113	// to execute privileged collator selection operations.114	#[cfg(feature = "governance")]115	type UpdateOrigin = governance::RootOrAllTechnicalCommittee;116117	// If there is no governance,118	// we allow root only to execute privileged collator selection operations.119	#[cfg(not(feature = "governance"))]120	type UpdateOrigin = EnsureRoot<<Self as frame_system::Config>::AccountId>;121122	type TreasuryAccountId = TreasuryAccountId;123	type PotId = PotId;124	type MaxCollators = MaxCollators;125	type SlashRatio = SlashRatio;126	type ValidatorId = <Self as frame_system::Config>::AccountId;127	type ValidatorIdOf = pallet_collator_selection::IdentityCollator;128	type ValidatorRegistration = Session;129	type WeightInfo = pallet_collator_selection::weights::SubstrateWeight<Runtime>;130	type DesiredCollators = DesiredCollators;131	type LicenseBond = LicenseBond;132	type KickThreshold = KickThreshold;133}
after · runtime/common/config/pallets/collator_selection.rs
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/>.1617use frame_support::{parameter_types, PalletId};18#[cfg(not(feature = "governance"))]19use frame_system::EnsureRoot;20use pallet_configuration::{21	CollatorSelectionDesiredCollatorsOverride, CollatorSelectionKickThresholdOverride,22	CollatorSelectionLicenseBondOverride,23};24use sp_runtime::Perbill;2526#[cfg(feature = "governance")]27use crate::config::governance;28use crate::{29	config::pallets::{MaxCollators, SessionPeriod, TreasuryAccountId},30	Aura, Balance, Balances, BlockNumber, CollatorSelection, Runtime, RuntimeEvent,31	RuntimeHoldReason, Session, SessionKeys,32};33parameter_types! {34	pub const SessionOffset: BlockNumber = 0;35}3637impl pallet_session::Config for Runtime {38	type RuntimeEvent = RuntimeEvent;39	type ValidatorId = <Self as frame_system::Config>::AccountId;40	// we don't have stash and controller, thus we don't need the convert as well.41	type ValidatorIdOf = pallet_collator_selection::IdentityCollator;42	type ShouldEndSession = pallet_session::PeriodicSessions<SessionPeriod, SessionOffset>;43	type NextSessionRotation = pallet_session::PeriodicSessions<SessionPeriod, SessionOffset>;44	type SessionManager = CollatorSelection;45	// Essentially just Aura, but lets be pedantic.46	type SessionHandler = <SessionKeys as sp_runtime::traits::OpaqueKeys>::KeyTypeIdProviders;47	type Keys = SessionKeys;48	type WeightInfo = pallet_session::weights::SubstrateWeight<Self>; // ();49}5051parameter_types! {52	pub const UncleGenerations: u32 = 0;53}5455impl pallet_authorship::Config for Runtime {56	type FindAuthor = pallet_session::FindAccountFromAuthorIndex<Self, Aura>;57	type EventHandler = CollatorSelection;58}5960parameter_types! {61	pub LicenseBond: Balance =  CollatorSelectionLicenseBondOverride::<Runtime>::get();62	pub DesiredCollators: u32 = CollatorSelectionDesiredCollatorsOverride::<Runtime>::get();63	pub KickThreshold: BlockNumber = CollatorSelectionKickThresholdOverride::<Runtime>::get();64}6566parameter_types! {67	pub const PotId: PalletId = PalletId(*b"PotStake");68	pub const SlashRatio: Perbill = Perbill::from_percent(100);69}7071impl pallet_collator_selection::Config for Runtime {72	type RuntimeEvent = RuntimeEvent;73	type RuntimeHoldReason = RuntimeHoldReason;74	type Currency = Balances;75	// We allow root only to execute privileged collator selection operations.7677	// We allow root or the unanimous technical committee78	// to execute privileged collator selection operations.79	#[cfg(feature = "governance")]80	type UpdateOrigin = governance::RootOrAllTechnicalCommittee;8182	// If there is no governance,83	// we allow root only to execute privileged collator selection operations.84	#[cfg(not(feature = "governance"))]85	type UpdateOrigin = EnsureRoot<<Self as frame_system::Config>::AccountId>;8687	type TreasuryAccountId = TreasuryAccountId;88	type PotId = PotId;89	type MaxCollators = MaxCollators;90	type SlashRatio = SlashRatio;91	type ValidatorId = <Self as frame_system::Config>::AccountId;92	type ValidatorIdOf = pallet_collator_selection::IdentityCollator;93	type ValidatorRegistration = Session;94	type WeightInfo = pallet_collator_selection::weights::SubstrateWeight<Runtime>;95	type DesiredCollators = DesiredCollators;96	type LicenseBond = LicenseBond;97	type KickThreshold = KickThreshold;98}
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 = []