From 22e4325fd4904dc4bcea870fa2984cbc98369887 Mon Sep 17 00:00:00 2001 From: Yaroslav Bolyukin Date: Fri, 03 Nov 2023 01:43:34 +0000 Subject: [PATCH] Merge pull request #1033 from UniqueNetwork/fix/enable-gov-on-unique --- --- 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} --- /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; +} --- 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! { --- 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::::get(); pub DesiredCollators: u32 = CollatorSelectionDesiredCollatorsOverride::::get(); pub KickThreshold: BlockNumber = CollatorSelectionKickThresholdOverride::::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<::AccountId>; - - #[cfg(not(feature = "governance"))] - type ForceOrigin = EnsureRoot<::AccountId>; - - type Slashed = Treasury; - type WeightInfo = pallet_identity::weights::SubstrateWeight; } parameter_types! { --- 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} = 38, - #[cfg(feature = "collator-selection")] + #[cfg(feature = "governance")] Identity: pallet_identity = 40, #[cfg(feature = "preimage")] --- 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()), } --- 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)), --- 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")] --- 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 = [] --- a/tests/src/pallet-presence.test.ts +++ b/tests/src/pallet-presence.test.ts @@ -68,7 +68,7 @@ const refungible = 'refungible'; const foreignAssets = 'foreignassets'; const appPromotion = 'apppromotion'; - const collatorSelection = ['authorship', 'session', 'collatorselection', 'identity']; + const collatorSelection = ['authorship', 'session', 'collatorselection']; const preimage = ['preimage']; const governance = [ 'council', @@ -80,6 +80,7 @@ 'scheduler', 'technicalcommittee', 'technicalcommitteemembership', + 'identity', ]; const testUtils = 'testutils'; @@ -108,6 +109,8 @@ refungible, foreignAssets, appPromotion, + ...preimage, + ...governance, ); } }); -- gitstuff