difftreelog
Merge pull request #993 from UniqueNetwork/fix/governance-with-batch
in: master
Fix/governance with batch
10 files changed
Cargo.tomldiffbeforeafterboth--- a/Cargo.toml
+++ b/Cargo.toml
@@ -119,6 +119,7 @@
pallet-state-trie-migration = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43" }
pallet-sudo = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43" }
pallet-timestamp = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43" }
+pallet-utility = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43" }
pallet-transaction-payment = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43" }
pallet-transaction-payment-rpc = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43" }
pallet-transaction-payment-rpc-runtime-api = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43" }
runtime/common/config/governance/technical_committee.rsdiffbeforeafterboth--- a/runtime/common/config/governance/technical_committee.rs
+++ b/runtime/common/config/governance/technical_committee.rs
@@ -38,7 +38,7 @@
type RemoveOrigin = RootOrMoreThanHalfCouncil;
type SwapOrigin = RootOrMoreThanHalfCouncil;
type ResetOrigin = EnsureRoot<AccountId>;
- type PrimeOrigin = EnsureRoot<AccountId>;
+ type PrimeOrigin = RootOrMoreThanHalfCouncil;
type MembershipInitialized = TechnicalCommittee;
type MembershipChanged = TechnicalCommittee;
type MaxMembers = TechnicalMaxMembers;
runtime/common/config/substrate.rsdiffbeforeafterboth1// 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::{18 traits::{Everything, ConstU32, NeverEnsureOrigin},19 weights::{20 constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight},21 ConstantMultiplier,22 },23 dispatch::DispatchClass,24 parameter_types, ord_parameter_types, PalletId,25};26use sp_runtime::{27 generic,28 traits::{BlakeTwo256, AccountIdLookup},29 Perbill, Permill, Percent,30};31use sp_arithmetic::traits::One;32use frame_system::{33 limits::{BlockLength, BlockWeights},34 EnsureRoot, EnsureSignedBy,35};36use pallet_transaction_payment::{Multiplier, ConstFeeMultiplier};37use crate::{38 runtime_common::DealWithFees, Runtime, RuntimeEvent, RuntimeCall, RuntimeOrigin, PalletInfo,39 System, Balances, SS58Prefix, Version,40};41use up_common::{types::*, constants::*};42use sp_std::vec;4344parameter_types! {45 pub const BlockHashCount: BlockNumber = 2400;46 pub RuntimeBlockLength: BlockLength =47 BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO);48 pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);49 pub const MaximumBlockLength: u32 = 5 * 1024 * 1024;50 pub RuntimeBlockWeights: BlockWeights = BlockWeights::builder()51 .base_block(BlockExecutionWeight::get())52 .for_class(DispatchClass::all(), |weights| {53 weights.base_extrinsic = ExtrinsicBaseWeight::get();54 })55 .for_class(DispatchClass::Normal, |weights| {56 weights.max_total = Some(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT);57 })58 .for_class(DispatchClass::Operational, |weights| {59 weights.max_total = Some(MAXIMUM_BLOCK_WEIGHT);60 // Operational transactions have some extra reserved space, so that they61 // are included even if block reached `MAXIMUM_BLOCK_WEIGHT`.62 weights.reserved = Some(63 MAXIMUM_BLOCK_WEIGHT - NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT64 );65 })66 .avg_block_initialization(AVERAGE_ON_INITIALIZE_RATIO)67 .build_or_panic();68}6970impl frame_system::Config for Runtime {71 /// The data to be stored in an account.72 type AccountData = pallet_balances::AccountData<Balance>;73 /// The identifier used to distinguish between accounts.74 type AccountId = AccountId;75 /// The basic call filter to use in dispatchable.76 type BaseCallFilter = Everything;77 /// Maximum number of block number to block hash mappings to keep (oldest pruned first).78 type BlockHashCount = BlockHashCount;79 /// The maximum length of a block (in bytes).80 type BlockLength = RuntimeBlockLength;81 /// The index type for blocks.82 type BlockNumber = BlockNumber;83 /// The weight of the overhead invoked on the block import process, independent of the extrinsics included in that block.84 type BlockWeights = RuntimeBlockWeights;85 /// The aggregated dispatch type that is available for extrinsics.86 type RuntimeCall = RuntimeCall;87 /// The weight of database operations that the runtime can invoke.88 type DbWeight = RocksDbWeight;89 /// The ubiquitous event type.90 type RuntimeEvent = RuntimeEvent;91 /// The type for hashing blocks and tries.92 type Hash = Hash;93 /// The hashing algorithm used.94 type Hashing = BlakeTwo256;95 /// The header type.96 type Header = generic::Header<BlockNumber, BlakeTwo256>;97 /// The index type for storing how many extrinsics an account has signed.98 type Index = Index;99 /// The lookup mechanism to get account ID from whatever is passed in dispatchers.100 type Lookup = AccountIdLookup<AccountId, ()>;101 /// What to do if an account is fully reaped from the system.102 type OnKilledAccount = ();103 /// What to do if a new account is created.104 type OnNewAccount = ();105 type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode<Self>;106 /// The ubiquitous origin type.107 type RuntimeOrigin = RuntimeOrigin;108 /// This type is being generated by `construct_runtime!`.109 type PalletInfo = PalletInfo;110 /// This is used as an identifier of the chain. 42 is the generic substrate prefix.111 type SS58Prefix = SS58Prefix;112 /// Weight information for the extrinsics of this pallet.113 type SystemWeightInfo = frame_system::weights::SubstrateWeight<Self>;114 /// Version of the runtime.115 type Version = Version;116 type MaxConsumers = ConstU32<16>;117}118119parameter_types! {120 pub const MigrationMaxKeyLen: u32 = 512;121}122ord_parameter_types! {123 pub const TrieMigrationSigned: AccountId = AccountId::from(hex_literal::hex!("3e2ee9b68b52c239488e8abbeb31284c0d4342ec7c3b53f8e50855051d54a319"));124}125126impl pallet_state_trie_migration::Config for Runtime {127 type WeightInfo = pallet_state_trie_migration::weights::SubstrateWeight<Self>;128 type RuntimeEvent = RuntimeEvent;129 type Currency = Balances;130 type SignedDepositPerItem = ();131 type SignedDepositBase = ();132 type ControlOrigin = EnsureRoot<AccountId>;133 // Only root can perform this migration134 type SignedFilter = EnsureSignedBy<TrieMigrationSigned, AccountId>;135 type MaxKeyLen = MigrationMaxKeyLen;136}137138parameter_types! {139 pub const MinimumPeriod: u64 = SLOT_DURATION / 2;140}141142impl pallet_timestamp::Config for Runtime {143 /// A timestamp: milliseconds since the unix epoch.144 type Moment = u64;145 type OnTimestampSet = ();146 type MinimumPeriod = MinimumPeriod;147 type WeightInfo = ();148}149150parameter_types! {151 // pub const ExistentialDeposit: u128 = 500;152 pub const ExistentialDeposit: u128 = EXISTENTIAL_DEPOSIT;153 pub const MaxLocks: u32 = 50;154 pub const MaxReserves: u32 = 50;155 pub const MaxHolds: u32 = 10;156 pub const MaxFreezes: u32 = 10;157}158159impl pallet_balances::Config for Runtime {160 type MaxLocks = MaxLocks;161 type MaxReserves = MaxReserves;162 type ReserveIdentifier = [u8; 16];163 /// The type for recording an account's balance.164 type Balance = Balance;165 /// The ubiquitous event type.166 type RuntimeEvent = RuntimeEvent;167 // FIXME: Is () the new treasury?168 // Switch to real treasury once we start having dust removals169 // Related issue: https://github.com/paritytech/polkadot/issues/7323170 type DustRemoval = ();171 type ExistentialDeposit = ExistentialDeposit;172 type AccountStore = System;173 type WeightInfo = pallet_balances::weights::SubstrateWeight<Self>;174 type HoldIdentifier = [u8; 16];175 type FreezeIdentifier = [u8; 16];176 type MaxHolds = MaxHolds;177 type MaxFreezes = MaxFreezes;178}179180parameter_types! {181 /// This value increases the priority of `Operational` transactions by adding182 /// a "virtual tip" that's equal to the `OperationalFeeMultiplier * final_fee`.183 pub const OperationalFeeMultiplier: u8 = 5;184185 pub FeeMultiplier: Multiplier = Multiplier::one();186}187188impl pallet_transaction_payment::Config for Runtime {189 type RuntimeEvent = RuntimeEvent;190 type OnChargeTransaction = pallet_transaction_payment::CurrencyAdapter<Balances, DealWithFees>;191 type LengthToFee = ConstantMultiplier<Balance, TransactionByteFee>;192 type OperationalFeeMultiplier = OperationalFeeMultiplier;193 type WeightToFee = pallet_configuration::WeightToFee<Self, Balance>;194 type FeeMultiplierUpdate = ConstFeeMultiplier<FeeMultiplier>;195}196197parameter_types! {198 pub const ProposalBond: Permill = Permill::from_percent(5);199 pub const ProposalBondMinimum: Balance = 1 * UNIQUE;200 pub const ProposalBondMaximum: Balance = 1000 * UNIQUE;201 pub const SpendPeriod: BlockNumber = 5 * MINUTES;202 pub const Burn: Permill = Permill::from_percent(0);203 pub const TipCountdown: BlockNumber = 1 * DAYS;204 pub const TipFindersFee: Percent = Percent::from_percent(20);205 pub const TipReportDepositBase: Balance = 1 * UNIQUE;206 pub const DataDepositPerByte: Balance = 1 * CENTIUNIQUE;207 pub const BountyDepositBase: Balance = 1 * UNIQUE;208 pub const BountyDepositPayoutDelay: BlockNumber = 1 * DAYS;209 pub const TreasuryModuleId: PalletId = PalletId(*b"py/trsry");210 pub const BountyUpdatePeriod: BlockNumber = 14 * DAYS;211 pub const MaximumReasonLength: u32 = 16384;212 pub const BountyCuratorDeposit: Permill = Permill::from_percent(50);213 pub const BountyValueMinimum: Balance = 5 * UNIQUE;214 pub const MaxApprovals: u32 = 100;215}216217impl pallet_treasury::Config for Runtime {218 type PalletId = TreasuryModuleId;219 type Currency = Balances;220 type ApproveOrigin = EnsureRoot<AccountId>;221 type RejectOrigin = EnsureRoot<AccountId>;222 type SpendOrigin = NeverEnsureOrigin<u128>;223 type RuntimeEvent = RuntimeEvent;224 type OnSlash = ();225 type ProposalBond = ProposalBond;226 type ProposalBondMinimum = ProposalBondMinimum;227 type ProposalBondMaximum = ProposalBondMaximum;228 type SpendPeriod = SpendPeriod;229 type Burn = Burn;230 type BurnDestination = ();231 type SpendFunds = ();232 type WeightInfo = pallet_treasury::weights::SubstrateWeight<Self>;233 type MaxApprovals = MaxApprovals;234}235236impl pallet_sudo::Config for Runtime {237 type RuntimeEvent = RuntimeEvent;238 type RuntimeCall = RuntimeCall;239 type WeightInfo = pallet_sudo::weights::SubstrateWeight<Self>;240}241242parameter_types! {243 pub const MaxAuthorities: u32 = 100_000;244}245246impl pallet_aura::Config for Runtime {247 type AuthorityId = AuraId;248 type DisabledValidators = ();249 type MaxAuthorities = MaxAuthorities;250}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::{18 traits::{Everything, ConstU32, NeverEnsureOrigin},19 weights::{20 constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight},21 ConstantMultiplier,22 },23 dispatch::DispatchClass,24 parameter_types, ord_parameter_types, PalletId,25};26use sp_runtime::{27 generic,28 traits::{BlakeTwo256, AccountIdLookup},29 Perbill, Permill, Percent,30};31use sp_arithmetic::traits::One;32use frame_system::{33 limits::{BlockLength, BlockWeights},34 EnsureRoot, EnsureSignedBy,35};36use pallet_transaction_payment::{Multiplier, ConstFeeMultiplier};37use crate::{38 runtime_common::DealWithFees, Runtime, RuntimeEvent, RuntimeCall, RuntimeOrigin, OriginCaller,39 PalletInfo, System, Balances, SS58Prefix, Version,40};41use up_common::{types::*, constants::*};42use sp_std::vec;4344parameter_types! {45 pub const BlockHashCount: BlockNumber = 2400;46 pub RuntimeBlockLength: BlockLength =47 BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO);48 pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);49 pub const MaximumBlockLength: u32 = 5 * 1024 * 1024;50 pub RuntimeBlockWeights: BlockWeights = BlockWeights::builder()51 .base_block(BlockExecutionWeight::get())52 .for_class(DispatchClass::all(), |weights| {53 weights.base_extrinsic = ExtrinsicBaseWeight::get();54 })55 .for_class(DispatchClass::Normal, |weights| {56 weights.max_total = Some(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT);57 })58 .for_class(DispatchClass::Operational, |weights| {59 weights.max_total = Some(MAXIMUM_BLOCK_WEIGHT);60 // Operational transactions have some extra reserved space, so that they61 // are included even if block reached `MAXIMUM_BLOCK_WEIGHT`.62 weights.reserved = Some(63 MAXIMUM_BLOCK_WEIGHT - NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT64 );65 })66 .avg_block_initialization(AVERAGE_ON_INITIALIZE_RATIO)67 .build_or_panic();68}6970impl frame_system::Config for Runtime {71 /// The data to be stored in an account.72 type AccountData = pallet_balances::AccountData<Balance>;73 /// The identifier used to distinguish between accounts.74 type AccountId = AccountId;75 /// The basic call filter to use in dispatchable.76 type BaseCallFilter = Everything;77 /// Maximum number of block number to block hash mappings to keep (oldest pruned first).78 type BlockHashCount = BlockHashCount;79 /// The maximum length of a block (in bytes).80 type BlockLength = RuntimeBlockLength;81 /// The index type for blocks.82 type BlockNumber = BlockNumber;83 /// The weight of the overhead invoked on the block import process, independent of the extrinsics included in that block.84 type BlockWeights = RuntimeBlockWeights;85 /// The aggregated dispatch type that is available for extrinsics.86 type RuntimeCall = RuntimeCall;87 /// The weight of database operations that the runtime can invoke.88 type DbWeight = RocksDbWeight;89 /// The ubiquitous event type.90 type RuntimeEvent = RuntimeEvent;91 /// The type for hashing blocks and tries.92 type Hash = Hash;93 /// The hashing algorithm used.94 type Hashing = BlakeTwo256;95 /// The header type.96 type Header = generic::Header<BlockNumber, BlakeTwo256>;97 /// The index type for storing how many extrinsics an account has signed.98 type Index = Index;99 /// The lookup mechanism to get account ID from whatever is passed in dispatchers.100 type Lookup = AccountIdLookup<AccountId, ()>;101 /// What to do if an account is fully reaped from the system.102 type OnKilledAccount = ();103 /// What to do if a new account is created.104 type OnNewAccount = ();105 type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode<Self>;106 /// The ubiquitous origin type.107 type RuntimeOrigin = RuntimeOrigin;108 /// This type is being generated by `construct_runtime!`.109 type PalletInfo = PalletInfo;110 /// This is used as an identifier of the chain. 42 is the generic substrate prefix.111 type SS58Prefix = SS58Prefix;112 /// Weight information for the extrinsics of this pallet.113 type SystemWeightInfo = frame_system::weights::SubstrateWeight<Self>;114 /// Version of the runtime.115 type Version = Version;116 type MaxConsumers = ConstU32<16>;117}118119parameter_types! {120 pub const MigrationMaxKeyLen: u32 = 512;121}122ord_parameter_types! {123 pub const TrieMigrationSigned: AccountId = AccountId::from(hex_literal::hex!("3e2ee9b68b52c239488e8abbeb31284c0d4342ec7c3b53f8e50855051d54a319"));124}125126impl pallet_state_trie_migration::Config for Runtime {127 type WeightInfo = pallet_state_trie_migration::weights::SubstrateWeight<Self>;128 type RuntimeEvent = RuntimeEvent;129 type Currency = Balances;130 type SignedDepositPerItem = ();131 type SignedDepositBase = ();132 type ControlOrigin = EnsureRoot<AccountId>;133 // Only root can perform this migration134 type SignedFilter = EnsureSignedBy<TrieMigrationSigned, AccountId>;135 type MaxKeyLen = MigrationMaxKeyLen;136}137138parameter_types! {139 pub const MinimumPeriod: u64 = SLOT_DURATION / 2;140}141142impl pallet_timestamp::Config for Runtime {143 /// A timestamp: milliseconds since the unix epoch.144 type Moment = u64;145 type OnTimestampSet = ();146 type MinimumPeriod = MinimumPeriod;147 type WeightInfo = ();148}149150parameter_types! {151 // pub const ExistentialDeposit: u128 = 500;152 pub const ExistentialDeposit: u128 = EXISTENTIAL_DEPOSIT;153 pub const MaxLocks: u32 = 50;154 pub const MaxReserves: u32 = 50;155 pub const MaxHolds: u32 = 10;156 pub const MaxFreezes: u32 = 10;157}158159impl pallet_balances::Config for Runtime {160 type MaxLocks = MaxLocks;161 type MaxReserves = MaxReserves;162 type ReserveIdentifier = [u8; 16];163 /// The type for recording an account's balance.164 type Balance = Balance;165 /// The ubiquitous event type.166 type RuntimeEvent = RuntimeEvent;167 // FIXME: Is () the new treasury?168 // Switch to real treasury once we start having dust removals169 // Related issue: https://github.com/paritytech/polkadot/issues/7323170 type DustRemoval = ();171 type ExistentialDeposit = ExistentialDeposit;172 type AccountStore = System;173 type WeightInfo = pallet_balances::weights::SubstrateWeight<Self>;174 type HoldIdentifier = [u8; 16];175 type FreezeIdentifier = [u8; 16];176 type MaxHolds = MaxHolds;177 type MaxFreezes = MaxFreezes;178}179180parameter_types! {181 /// This value increases the priority of `Operational` transactions by adding182 /// a "virtual tip" that's equal to the `OperationalFeeMultiplier * final_fee`.183 pub const OperationalFeeMultiplier: u8 = 5;184185 pub FeeMultiplier: Multiplier = Multiplier::one();186}187188impl pallet_transaction_payment::Config for Runtime {189 type RuntimeEvent = RuntimeEvent;190 type OnChargeTransaction = pallet_transaction_payment::CurrencyAdapter<Balances, DealWithFees>;191 type LengthToFee = ConstantMultiplier<Balance, TransactionByteFee>;192 type OperationalFeeMultiplier = OperationalFeeMultiplier;193 type WeightToFee = pallet_configuration::WeightToFee<Self, Balance>;194 type FeeMultiplierUpdate = ConstFeeMultiplier<FeeMultiplier>;195}196197parameter_types! {198 pub const ProposalBond: Permill = Permill::from_percent(5);199 pub const ProposalBondMinimum: Balance = 1 * UNIQUE;200 pub const ProposalBondMaximum: Balance = 1000 * UNIQUE;201 pub const SpendPeriod: BlockNumber = 5 * MINUTES;202 pub const Burn: Permill = Permill::from_percent(0);203 pub const TipCountdown: BlockNumber = 1 * DAYS;204 pub const TipFindersFee: Percent = Percent::from_percent(20);205 pub const TipReportDepositBase: Balance = 1 * UNIQUE;206 pub const DataDepositPerByte: Balance = 1 * CENTIUNIQUE;207 pub const BountyDepositBase: Balance = 1 * UNIQUE;208 pub const BountyDepositPayoutDelay: BlockNumber = 1 * DAYS;209 pub const TreasuryModuleId: PalletId = PalletId(*b"py/trsry");210 pub const BountyUpdatePeriod: BlockNumber = 14 * DAYS;211 pub const MaximumReasonLength: u32 = 16384;212 pub const BountyCuratorDeposit: Permill = Permill::from_percent(50);213 pub const BountyValueMinimum: Balance = 5 * UNIQUE;214 pub const MaxApprovals: u32 = 100;215}216217impl pallet_treasury::Config for Runtime {218 type PalletId = TreasuryModuleId;219 type Currency = Balances;220 type ApproveOrigin = EnsureRoot<AccountId>;221 type RejectOrigin = EnsureRoot<AccountId>;222 type SpendOrigin = NeverEnsureOrigin<u128>;223 type RuntimeEvent = RuntimeEvent;224 type OnSlash = ();225 type ProposalBond = ProposalBond;226 type ProposalBondMinimum = ProposalBondMinimum;227 type ProposalBondMaximum = ProposalBondMaximum;228 type SpendPeriod = SpendPeriod;229 type Burn = Burn;230 type BurnDestination = ();231 type SpendFunds = ();232 type WeightInfo = pallet_treasury::weights::SubstrateWeight<Self>;233 type MaxApprovals = MaxApprovals;234}235236impl pallet_sudo::Config for Runtime {237 type RuntimeEvent = RuntimeEvent;238 type RuntimeCall = RuntimeCall;239 type WeightInfo = pallet_sudo::weights::SubstrateWeight<Self>;240}241242parameter_types! {243 pub const MaxAuthorities: u32 = 100_000;244}245246impl pallet_aura::Config for Runtime {247 type AuthorityId = AuraId;248 type DisabledValidators = ();249 type MaxAuthorities = MaxAuthorities;250}251252impl pallet_utility::Config for Runtime {253 type RuntimeEvent = RuntimeEvent;254 type RuntimeCall = RuntimeCall;255 type PalletsOrigin = OriginCaller;256 type WeightInfo = pallet_utility::weights::SubstrateWeight<Self>;257}runtime/common/construct_runtime.rsdiffbeforeafterboth--- a/runtime/common/construct_runtime.rs
+++ b/runtime/common/construct_runtime.rs
@@ -136,6 +136,8 @@
BalancesAdapter: pallet_balances_adapter = 155,
+ Utility: pallet_utility = 156,
+
#[cfg(feature = "pallet-test-utils")]
TestUtils: pallet_test_utils = 255,
}
runtime/opal/Cargo.tomldiffbeforeafterboth--- a/runtime/opal/Cargo.toml
+++ b/runtime/opal/Cargo.toml
@@ -58,6 +58,7 @@
'pallet-refungible/runtime-benchmarks',
'pallet-structure/runtime-benchmarks',
'pallet-timestamp/runtime-benchmarks',
+ 'pallet-utility/runtime-benchmarks',
'pallet-unique-scheduler-v2/runtime-benchmarks',
'pallet-unique/runtime-benchmarks',
'pallet-xcm/runtime-benchmarks',
@@ -120,6 +121,7 @@
'pallet-structure/std',
'pallet-sudo/std',
'pallet-timestamp/std',
+ 'pallet-utility/std',
'pallet-transaction-payment-rpc-runtime-api/std',
'pallet-transaction-payment/std',
'pallet-treasury/std',
@@ -213,6 +215,7 @@
'pallet-sudo/try-runtime',
'pallet-test-utils?/try-runtime',
'pallet-timestamp/try-runtime',
+ 'pallet-utility/try-runtime',
'pallet-transaction-payment/try-runtime',
'pallet-treasury/try-runtime',
'pallet-unique-scheduler-v2/try-runtime',
@@ -263,6 +266,7 @@
pallet-state-trie-migration = { workspace = true }
pallet-sudo = { workspace = true }
pallet-timestamp = { workspace = true }
+pallet-utility = { workspace = true }
pallet-transaction-payment = { workspace = true }
pallet-transaction-payment-rpc-runtime-api = { workspace = true }
pallet-treasury = { workspace = true }
runtime/quartz/Cargo.tomldiffbeforeafterboth--- a/runtime/quartz/Cargo.toml
+++ b/runtime/quartz/Cargo.toml
@@ -55,6 +55,7 @@
'pallet-scheduler/runtime-benchmarks',
'pallet-structure/runtime-benchmarks',
'pallet-timestamp/runtime-benchmarks',
+ 'pallet-utility/runtime-benchmarks',
'pallet-unique/runtime-benchmarks',
'pallet-xcm/runtime-benchmarks',
'sp-runtime/runtime-benchmarks',
@@ -120,6 +121,7 @@
'pallet-structure/std',
'pallet-sudo/std',
'pallet-timestamp/std',
+ 'pallet-utility/std',
'pallet-transaction-payment-rpc-runtime-api/std',
'pallet-transaction-payment/std',
'pallet-treasury/std',
@@ -203,6 +205,7 @@
'pallet-structure/try-runtime',
'pallet-sudo/try-runtime',
'pallet-timestamp/try-runtime',
+ 'pallet-utility/try-runtime',
'pallet-transaction-payment/try-runtime',
'pallet-treasury/try-runtime',
'pallet-unique/try-runtime',
@@ -252,6 +255,7 @@
pallet-state-trie-migration = { workspace = true }
pallet-sudo = { workspace = true }
pallet-timestamp = { workspace = true }
+pallet-utility = { workspace = true }
pallet-transaction-payment = { workspace = true }
pallet-transaction-payment-rpc-runtime-api = { workspace = true }
pallet-treasury = { workspace = true }
runtime/unique/Cargo.tomldiffbeforeafterboth--- a/runtime/unique/Cargo.toml
+++ b/runtime/unique/Cargo.toml
@@ -52,6 +52,7 @@
'pallet-scheduler/runtime-benchmarks',
'pallet-structure/runtime-benchmarks',
'pallet-timestamp/runtime-benchmarks',
+ 'pallet-utility/runtime-benchmarks',
'pallet-unique/runtime-benchmarks',
'pallet-xcm/runtime-benchmarks',
'sp-runtime/runtime-benchmarks',
@@ -118,6 +119,7 @@
'pallet-structure/std',
'pallet-sudo/std',
'pallet-timestamp/std',
+ 'pallet-utility/std',
'pallet-transaction-payment-rpc-runtime-api/std',
'pallet-transaction-payment/std',
'pallet-treasury/std',
@@ -205,6 +207,7 @@
'pallet-structure/try-runtime',
'pallet-sudo/try-runtime',
'pallet-timestamp/try-runtime',
+ 'pallet-utility/try-runtime',
'pallet-transaction-payment/try-runtime',
'pallet-treasury/try-runtime',
'pallet-unique/try-runtime',
@@ -255,6 +258,7 @@
pallet-state-trie-migration = { workspace = true }
pallet-sudo = { workspace = true }
pallet-timestamp = { workspace = true }
+pallet-utility = { workspace = true }
pallet-transaction-payment = { workspace = true }
pallet-transaction-payment-rpc-runtime-api = { workspace = true }
pallet-treasury = { workspace = true }
tests/src/governance/init.test.tsdiffbeforeafterboth--- /dev/null
+++ b/tests/src/governance/init.test.ts
@@ -0,0 +1,192 @@
+import {IKeyringPair} from '@polkadot/types/types';
+import {usingPlaygrounds, itSub, expect, Pallets, requirePalletsOrSkip, describeGov} from '../util';
+import {Event} from '../util/playgrounds/unique.dev';
+import {ICounselors, democracyLaunchPeriod, democracyVotingPeriod, ITechComms, democracyEnactmentPeriod, clearCouncil, clearTechComm, clearFellowship} from './util';
+
+describeGov('Governance: Initialization', () => {
+ let donor: IKeyringPair;
+ let sudoer: IKeyringPair;
+ let counselors: ICounselors;
+ let techcomms: ITechComms;
+ let coreDevs: any;
+
+ const expectedAlexFellowRank = 7;
+ const expectedFellowRank = 6;
+
+ before(async function() {
+ await usingPlaygrounds(async (helper, privateKey) => {
+ requirePalletsOrSkip(this, helper, [Pallets.Democracy, Pallets.Council, Pallets.TechnicalCommittee]);
+
+ const councilMembers = await helper.council.membership.getMembers();
+ const techcommMembers = await helper.technicalCommittee.membership.getMembers();
+ expect(councilMembers.length == 0, 'The Council must be empty before the Gov Init');
+ expect(techcommMembers.length == 0, 'The Technical Commettee must be empty before the Gov Init');
+
+ donor = await privateKey({url: import.meta.url});
+ sudoer = await privateKey('//Alice');
+
+ const counselorsNum = 5;
+ const techCommsNum = 3;
+ const coreDevsNum = 2;
+ const [
+ alex,
+ ildar,
+ charu,
+ filip,
+ irina,
+
+ greg,
+ andy,
+ constantine,
+
+ yaroslav,
+ daniel,
+ ] = await helper.arrange.createAccounts(new Array(counselorsNum + techCommsNum + coreDevsNum).fill(10_000n), donor);
+
+ counselors = {
+ alex,
+ ildar,
+ charu,
+ filip,
+ irina,
+ };
+
+ techcomms = {
+ greg,
+ andy,
+ constantine,
+ };
+
+ coreDevs = {
+ yaroslav: yaroslav,
+ daniel: daniel,
+ };
+ });
+ });
+
+ itSub('Initialize Governance', async ({helper}) => {
+ const promoteFellow = (fellow: string, promotionsNum: number) => new Array(promotionsNum).fill(helper.fellowship.collective.promoteCall(fellow));
+
+ const expectFellowRank = async (fellow: string, expectedRank: number) => {
+ expect(await helper.fellowship.collective.getMemberRank(fellow)).to.be.equal(expectedRank);
+ };
+
+ console.log('\t- Setup the Prime of the Council via sudo');
+ await helper.getSudo().utility.batchAll(sudoer, [
+ helper.council.membership.addMemberCall(counselors.alex.address),
+ helper.council.membership.setPrimeCall(counselors.alex.address),
+
+ helper.fellowship.collective.addMemberCall(counselors.alex.address),
+ ...promoteFellow(counselors.alex.address, expectedAlexFellowRank),
+ ]);
+
+ let councilMembers = await helper.council.membership.getMembers();
+ const councilPrime = await helper.council.collective.getPrimeMember();
+ const alexFellowRank = await helper.fellowship.collective.getMemberRank(counselors.alex.address);
+ expect(councilMembers).to.be.deep.equal([counselors.alex.address]);
+ expect(councilPrime).to.be.equal(counselors.alex.address);
+ expect(alexFellowRank).to.be.equal(expectedAlexFellowRank);
+
+ console.log('\t- The Council Prime initializes the Technical Commettee');
+ const councilProposalThreshold = 1;
+
+ await helper.council.collective.propose(
+ counselors.alex,
+ helper.utility.batchAllCall([
+ helper.technicalCommittee.membership.addMemberCall(techcomms.greg.address),
+ helper.technicalCommittee.membership.addMemberCall(techcomms.andy.address),
+ helper.technicalCommittee.membership.addMemberCall(techcomms.constantine.address),
+
+ helper.technicalCommittee.membership.setPrimeCall(techcomms.greg.address),
+ ]),
+ councilProposalThreshold,
+ );
+
+ const techCommMembers = await helper.technicalCommittee.membership.getMembers();
+ const techCommPrime = await helper.technicalCommittee.membership.getPrimeMember();
+ const expectedTechComms = [techcomms.greg.address, techcomms.andy.address, techcomms.constantine.address];
+ expect(techCommMembers.length).to.be.equal(expectedTechComms.length);
+ expect(techCommMembers).to.containSubset(expectedTechComms);
+ expect(techCommPrime).to.be.equal(techcomms.greg.address);
+
+ console.log('\t- The Council Prime initiates a referendum to add counselors');
+ const returnPreimageHash = true;
+ const preimageHash = await helper.preimage.notePreimageFromCall(counselors.alex, helper.utility.batchAllCall([
+ helper.council.membership.addMemberCall(counselors.ildar.address),
+ helper.council.membership.addMemberCall(counselors.charu.address),
+ helper.council.membership.addMemberCall(counselors.filip.address),
+ helper.council.membership.addMemberCall(counselors.irina.address),
+
+ helper.fellowship.collective.addMemberCall(counselors.charu.address),
+ helper.fellowship.collective.addMemberCall(counselors.ildar.address),
+ helper.fellowship.collective.addMemberCall(counselors.irina.address),
+ helper.fellowship.collective.addMemberCall(counselors.filip.address),
+ helper.fellowship.collective.addMemberCall(techcomms.greg.address),
+ helper.fellowship.collective.addMemberCall(techcomms.andy.address),
+ helper.fellowship.collective.addMemberCall(techcomms.constantine.address),
+ helper.fellowship.collective.addMemberCall(coreDevs.yaroslav.address),
+ helper.fellowship.collective.addMemberCall(coreDevs.daniel.address),
+
+ ...promoteFellow(counselors.charu.address, expectedFellowRank),
+ ...promoteFellow(counselors.ildar.address, expectedFellowRank),
+ ...promoteFellow(counselors.irina.address, expectedFellowRank),
+ ...promoteFellow(counselors.filip.address, expectedFellowRank),
+ ...promoteFellow(techcomms.greg.address, expectedFellowRank),
+ ...promoteFellow(techcomms.andy.address, expectedFellowRank),
+ ...promoteFellow(techcomms.constantine.address, expectedFellowRank),
+ ...promoteFellow(coreDevs.yaroslav.address, expectedFellowRank),
+ ...promoteFellow(coreDevs.daniel.address, expectedFellowRank),
+ ]), returnPreimageHash);
+
+ await helper.council.collective.propose(
+ counselors.alex,
+ helper.democracy.externalProposeDefaultWithPreimageCall(preimageHash),
+ councilProposalThreshold,
+ );
+
+ console.log('\t- The referendum is being decided');
+ const startedEvent = await helper.wait.expectEvent(democracyLaunchPeriod, Event.Democracy.Started);
+
+ await helper.democracy.vote(counselors.filip, startedEvent.referendumIndex, {
+ Standard: {
+ vote: {
+ aye: true,
+ conviction: 1,
+ },
+ balance: 10_000n,
+ },
+ });
+
+ const passedReferendumEvent = await helper.wait.expectEvent(democracyVotingPeriod, Event.Democracy.Passed);
+ expect(passedReferendumEvent.referendumIndex).to.be.equal(startedEvent.referendumIndex);
+
+ await helper.wait.expectEvent(democracyEnactmentPeriod, Event.Scheduler.Dispatched);
+
+ councilMembers = await helper.council.membership.getMembers();
+ const expectedCounselors = [
+ counselors.alex.address,
+ counselors.ildar.address,
+ counselors.charu.address,
+ counselors.filip.address,
+ counselors.irina.address,
+ ];
+ expect(councilMembers.length).to.be.equal(expectedCounselors.length);
+ expect(councilMembers).to.containSubset(expectedCounselors);
+
+ await expectFellowRank(counselors.ildar.address, expectedFellowRank);
+ await expectFellowRank(counselors.charu.address, expectedFellowRank);
+ await expectFellowRank(counselors.filip.address, expectedFellowRank);
+ await expectFellowRank(counselors.irina.address, expectedFellowRank);
+ await expectFellowRank(techcomms.greg.address, expectedFellowRank);
+ await expectFellowRank(techcomms.andy.address, expectedFellowRank);
+ await expectFellowRank(techcomms.constantine.address, expectedFellowRank);
+ await expectFellowRank(coreDevs.yaroslav.address, expectedFellowRank);
+ await expectFellowRank(coreDevs.daniel.address, expectedFellowRank);
+ });
+
+ after(async function() {
+ await clearFellowship(sudoer);
+ await clearTechComm(sudoer);
+ await clearCouncil(sudoer);
+ });
+});
tests/src/pallet-presence.test.tsdiffbeforeafterboth--- a/tests/src/pallet-presence.test.ts
+++ b/tests/src/pallet-presence.test.ts
@@ -27,6 +27,7 @@
'statetriemigration',
'structure',
'system',
+ 'utility',
'vesting',
'parachainsystem',
'parachaininfo',
tests/src/util/playgrounds/unique.tsdiffbeforeafterboth--- a/tests/src/util/playgrounds/unique.ts
+++ b/tests/src/util/playgrounds/unique.ts
@@ -3255,8 +3255,8 @@
return this.helper.executeExtrinsic(signer, `api.tx.${this.collective}.promoteMember`, [member]);
}
- promoteCall(newMember: string) {
- return this.helper.constructApiCall(`api.tx.${this.collective}.promoteMember`, [newMember]);
+ promoteCall(member: string) {
+ return this.helper.constructApiCall(`api.tx.${this.collective}.promoteMember`, [member]);
}
demote(signer: TSigner, member: string) {
@@ -3275,6 +3275,10 @@
return (await this.helper.getApi().query.fellowshipCollective.members.keys())
.map((key) => key.args[0].toString());
}
+
+ async getMemberRank(member: string) {
+ return (await this.helper.callRpc('api.query.fellowshipCollective.members', [member])).toJSON().rank;
+ }
}
class ReferendaGroup extends HelperGroup<UniqueHelper> {
@@ -3381,6 +3385,10 @@
return this.helper.constructApiCall('api.tx.democracy.externalProposeDefault', [{Inline: proposalCall.method.toHex()}]);
}
+ externalProposeDefaultWithPreimageCall(preimage: string) {
+ return this.helper.constructApiCall('api.tx.democracy.externalProposeDefault', [{Legacy: preimage}]);
+ }
+
// ... and blacklist external proposal hash.
vetoExternal(signer: TSigner, proposalHash: string) {
return this.helper.executeExtrinsic(signer, 'api.tx.democracy.vetoExternal', [proposalHash]);
@@ -3733,6 +3741,20 @@
}
}
+class UtilityGroup<T extends ChainHelperBase> extends HelperGroup<T> {
+ async batch(signer: TSigner, txs: any[]) {
+ return await this.helper.executeExtrinsic(signer, 'api.tx.utility.batch', [txs]);
+ }
+
+ async batchAll(signer: TSigner, txs: any[]) {
+ return await this.helper.executeExtrinsic(signer, 'api.tx.utility.batchAll', [txs]);
+ }
+
+ batchAllCall(txs: any[]) {
+ return this.helper.constructApiCall('api.tx.utility.batchAll', [txs]);
+ }
+}
+
class AcalaAssetRegistryGroup extends HelperGroup<AcalaHelper> {
async registerForeignAsset(signer: TSigner, destination: any, metadata: AcalaAssetMetadata) {
await this.helper.executeExtrinsic(signer, 'api.tx.assetRegistry.registerForeignAsset', [destination, metadata], true);
@@ -3835,6 +3857,7 @@
xcm: XcmGroup<UniqueHelper>;
xTokens: XTokensGroup<UniqueHelper>;
tokens: TokensGroup<UniqueHelper>;
+ utility: UtilityGroup<UniqueHelper>;
constructor(logger?: ILogger, options: { [key: string]: any } = {}) {
super(logger, options.helperBase ?? UniqueHelper);
@@ -3865,6 +3888,7 @@
this.xcm = new XcmGroup(this, 'polkadotXcm');
this.xTokens = new XTokensGroup(this);
this.tokens = new TokensGroup(this);
+ this.utility = new UtilityGroup(this);
}
getSudo<T extends UniqueHelper>() {