From 08c2f3af97e07b56312ce88c5f8dc6a0366e9c23 Mon Sep 17 00:00:00 2001 From: Valery Gantchev Date: Mon, 8 Apr 2024 16:26:34 +0200 Subject: [PATCH 01/18] Add dependencies for OpenGov --- Cargo.lock | 3 +++ Cargo.toml | 6 ++++++ runtime/basilisk/Cargo.toml | 3 +++ 3 files changed, 12 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index b71b1f59dd..58afdb0b17 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -912,6 +912,7 @@ dependencies = [ "pallet-collator-rewards", "pallet-collator-selection", "pallet-collective", + "pallet-conviction-voting", "pallet-currencies", "pallet-democracy 4.0.0-dev", "pallet-duster", @@ -925,6 +926,7 @@ dependencies = [ "pallet-nft", "pallet-preimage", "pallet-proxy", + "pallet-referenda", "pallet-relaychain-info", "pallet-route-executor", "pallet-scheduler", @@ -939,6 +941,7 @@ dependencies = [ "pallet-treasury", "pallet-uniques", "pallet-utility", + "pallet-whitelist", "pallet-xcm", "pallet-xcm-rate-limiter", "pallet-xyk", diff --git a/Cargo.toml b/Cargo.toml index d0d34b6bb3..aed102a652 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -53,6 +53,7 @@ pallet-babe = { git = "https://github.com/paritytech/polkadot-sdk", rev = "c8d22 pallet-balances = { git = "https://github.com/paritytech/polkadot-sdk", rev = "c8d2251cafadc108ba2f1f8a3208dc547ff38901", default-features = false } pallet-bounties = { git = "https://github.com/paritytech/polkadot-sdk", rev = "c8d2251cafadc108ba2f1f8a3208dc547ff38901", default-features = false } pallet-collective = { git = "https://github.com/paritytech/polkadot-sdk", rev = "c8d2251cafadc108ba2f1f8a3208dc547ff38901", default-features = false } +pallet-conviction-voting = { git = "https://github.com/paritytech/polkadot-sdk", rev = "c8d2251cafadc108ba2f1f8a3208dc547ff38901", default-features = false } pallet-democracy = { git = "https://github.com/paritytech/polkadot-sdk", rev = "c8d2251cafadc108ba2f1f8a3208dc547ff38901", default-features = false } pallet-election-provider-multi-phase = { git = "https://github.com/paritytech/polkadot-sdk", rev = "c8d2251cafadc108ba2f1f8a3208dc547ff38901", default-features = false } pallet-elections-phragmen = { git = "https://github.com/paritytech/polkadot-sdk", rev = "c8d2251cafadc108ba2f1f8a3208dc547ff38901", default-features = false } @@ -65,6 +66,7 @@ pallet-offences = { git = "https://github.com/paritytech/polkadot-sdk", rev = "c pallet-offences-benchmarking = { git = "https://github.com/paritytech/polkadot-sdk", rev = "c8d2251cafadc108ba2f1f8a3208dc547ff38901", default-features = false } pallet-proxy = { git = "https://github.com/paritytech/polkadot-sdk", rev = "c8d2251cafadc108ba2f1f8a3208dc547ff38901", default-features = false } pallet-recovery = { git = "https://github.com/paritytech/polkadot-sdk", rev = "c8d2251cafadc108ba2f1f8a3208dc547ff38901", default-features = false } +pallet-referenda = { git = "https://github.com/paritytech/polkadot-sdk", rev = "c8d2251cafadc108ba2f1f8a3208dc547ff38901", default-features = false } pallet-scheduler = { git = "https://github.com/paritytech/polkadot-sdk", rev = "c8d2251cafadc108ba2f1f8a3208dc547ff38901", default-features = false } pallet-session = { git = "https://github.com/paritytech/polkadot-sdk", rev = "c8d2251cafadc108ba2f1f8a3208dc547ff38901", default-features = false } pallet-session-benchmarking = { git = "https://github.com/paritytech/polkadot-sdk", rev = "c8d2251cafadc108ba2f1f8a3208dc547ff38901", default-features = false } @@ -83,6 +85,7 @@ pallet-treasury = { git = "https://github.com/paritytech/polkadot-sdk", rev = "c pallet-uniques = { git = "https://github.com/paritytech/polkadot-sdk", rev = "c8d2251cafadc108ba2f1f8a3208dc547ff38901", default-features = false } pallet-utility = { git = "https://github.com/paritytech/polkadot-sdk", rev = "c8d2251cafadc108ba2f1f8a3208dc547ff38901", default-features = false } pallet-vesting = { git = "https://github.com/paritytech/polkadot-sdk", rev = "c8d2251cafadc108ba2f1f8a3208dc547ff38901", default-features = false } +pallet-whitelist = { git = "https://github.com/paritytech/polkadot-sdk", rev = "c8d2251cafadc108ba2f1f8a3208dc547ff38901", default-features = false } pallet-preimage = { git = "https://github.com/paritytech/polkadot-sdk", rev = "c8d2251cafadc108ba2f1f8a3208dc547ff38901", default-features = false } sc-authority-discovery = { git = "https://github.com/paritytech/polkadot-sdk", rev = "c8d2251cafadc108ba2f1f8a3208dc547ff38901", default-features = false } sc-basic-authorship = { git = "https://github.com/paritytech/polkadot-sdk", rev = "c8d2251cafadc108ba2f1f8a3208dc547ff38901", default-features = false } @@ -246,6 +249,7 @@ pallet-babe = { git = "https://github.com/galacticcouncil/polkadot-sdk", rev = " pallet-balances = { git = "https://github.com/galacticcouncil/polkadot-sdk", rev = "062d92eae0f3bb9908faf2d4e241eef17368b9d3" } pallet-bounties = { git = "https://github.com/galacticcouncil/polkadot-sdk", rev = "062d92eae0f3bb9908faf2d4e241eef17368b9d3" } pallet-collective = { git = "https://github.com/galacticcouncil/polkadot-sdk", rev = "062d92eae0f3bb9908faf2d4e241eef17368b9d3" } +pallet-conviction-voting = { git = "https://github.com/galacticcouncil/polkadot-sdk", rev = "062d92eae0f3bb9908faf2d4e241eef17368b9d3" } pallet-democracy = { git = "https://github.com/galacticcouncil/polkadot-sdk", rev = "062d92eae0f3bb9908faf2d4e241eef17368b9d3" } pallet-election-provider-multi-phase = { git = "https://github.com/galacticcouncil/polkadot-sdk", rev = "062d92eae0f3bb9908faf2d4e241eef17368b9d3" } pallet-elections-phragmen = { git = "https://github.com/galacticcouncil/polkadot-sdk", rev = "062d92eae0f3bb9908faf2d4e241eef17368b9d3" } @@ -258,6 +262,7 @@ pallet-offences = { git = "https://github.com/galacticcouncil/polkadot-sdk", rev pallet-offences-benchmarking = { git = "https://github.com/galacticcouncil/polkadot-sdk", rev = "062d92eae0f3bb9908faf2d4e241eef17368b9d3" } pallet-proxy = { git = "https://github.com/galacticcouncil/polkadot-sdk", rev = "062d92eae0f3bb9908faf2d4e241eef17368b9d3" } pallet-recovery = { git = "https://github.com/galacticcouncil/polkadot-sdk", rev = "062d92eae0f3bb9908faf2d4e241eef17368b9d3" } +pallet-referenda = { git = "https://github.com/galacticcouncil/polkadot-sdk", rev = "062d92eae0f3bb9908faf2d4e241eef17368b9d3" } pallet-scheduler = { git = "https://github.com/galacticcouncil/polkadot-sdk", rev = "062d92eae0f3bb9908faf2d4e241eef17368b9d3" } pallet-session = { git = "https://github.com/galacticcouncil/polkadot-sdk", rev = "062d92eae0f3bb9908faf2d4e241eef17368b9d3" } pallet-session-benchmarking = { git = "https://github.com/galacticcouncil/polkadot-sdk", rev = "062d92eae0f3bb9908faf2d4e241eef17368b9d3" } @@ -276,6 +281,7 @@ pallet-treasury = { git = "https://github.com/galacticcouncil/polkadot-sdk", rev pallet-uniques = { git = "https://github.com/galacticcouncil/polkadot-sdk", rev = "062d92eae0f3bb9908faf2d4e241eef17368b9d3" } pallet-utility = { git = "https://github.com/galacticcouncil/polkadot-sdk", rev = "062d92eae0f3bb9908faf2d4e241eef17368b9d3" } pallet-vesting = { git = "https://github.com/galacticcouncil/polkadot-sdk", rev = "062d92eae0f3bb9908faf2d4e241eef17368b9d3" } +pallet-whitelist = { git = "https://github.com/galacticcouncil/polkadot-sdk", rev = "062d92eae0f3bb9908faf2d4e241eef17368b9d3" } pallet-preimage = { git = "https://github.com/galacticcouncil/polkadot-sdk", rev = "062d92eae0f3bb9908faf2d4e241eef17368b9d3" } sc-authority-discovery = { git = "https://github.com/galacticcouncil/polkadot-sdk", rev = "062d92eae0f3bb9908faf2d4e241eef17368b9d3" } sc-basic-authorship = { git = "https://github.com/galacticcouncil/polkadot-sdk", rev = "062d92eae0f3bb9908faf2d4e241eef17368b9d3" } diff --git a/runtime/basilisk/Cargo.toml b/runtime/basilisk/Cargo.toml index 625b84cd2c..4af633460d 100644 --- a/runtime/basilisk/Cargo.toml +++ b/runtime/basilisk/Cargo.toml @@ -101,15 +101,18 @@ frame-try-runtime = { workspace = true, optional = true } pallet-aura = { workspace = true } pallet-balances = { workspace = true } pallet-collective = { workspace = true } +pallet-conviction-voting = { workspace = true } pallet-preimage = { workspace = true } pallet-session = { workspace = true } pallet-proxy = { workspace = true } pallet-multisig = { workspace = true } +pallet-referenda = { workspace = true } pallet-timestamp = { workspace = true } pallet-transaction-payment = { workspace = true } pallet-transaction-payment-rpc-runtime-api = { workspace = true } pallet-uniques = { workspace = true } pallet-utility = { workspace = true } +pallet-whitelist = { workspace = true } sp-api = { workspace = true } sp-block-builder = { workspace = true } sp-consensus-aura = { workspace = true } From 4f0cca09a199a8c6460ff5ed8fbcc078b4c1657c Mon Sep 17 00:00:00 2001 From: Valery Gantchev Date: Mon, 8 Apr 2024 17:02:03 +0200 Subject: [PATCH 02/18] Isolate old governance config --- runtime/basilisk/src/assets.rs | 5 +- runtime/basilisk/src/governance/mod.rs | 54 ++++++++++++++ .../src/{governance.rs => governance/old.rs} | 73 ++----------------- runtime/basilisk/src/system.rs | 42 ++++++++++- runtime/basilisk/src/xcm.rs | 5 +- 5 files changed, 106 insertions(+), 73 deletions(-) create mode 100644 runtime/basilisk/src/governance/mod.rs rename runtime/basilisk/src/{governance.rs => governance/old.rs} (77%) diff --git a/runtime/basilisk/src/assets.rs b/runtime/basilisk/src/assets.rs index 1e4177794f..1a61b5522c 100644 --- a/runtime/basilisk/src/assets.rs +++ b/runtime/basilisk/src/assets.rs @@ -16,7 +16,10 @@ // limitations under the License. use super::*; -use crate::governance::{SuperMajorityCouncilOrRoot, SuperMajorityTechCommitteeOrRoot, UnanimousTechCommitteeOrRoot}; +use crate::governance::old::{ + MajorityTechCommitteeOrRoot, SuperMajorityCouncilOrRoot, SuperMajorityTechCommitteeOrRoot, + UnanimousTechCommitteeOrRoot, +}; use crate::system::NativeAssetId; use hydradx_traits::{ diff --git a/runtime/basilisk/src/governance/mod.rs b/runtime/basilisk/src/governance/mod.rs new file mode 100644 index 0000000000..cee26c5c84 --- /dev/null +++ b/runtime/basilisk/src/governance/mod.rs @@ -0,0 +1,54 @@ +// This file is part of Basilisk-node. + +// Copyright (C) 2020-2023 Intergalactic, Limited (GIB). +// SPDX-License-Identifier: Apache-2.0 + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +use super::*; +use crate::old::{MajorityCouncilOrRoot, SuperMajorityCouncilOrRoot}; +use frame_support::{parameter_types, sp_runtime::Permill, traits::NeverEnsureOrigin, PalletId}; +use primitives::constants::{currency::DOLLARS, time::DAYS}; + +// Old governance configurations. +pub mod old; + +parameter_types! { + pub const ProposalBond: Permill = Permill::from_percent(3); + pub const ProposalBondMinimum: Balance = 100 * DOLLARS; + pub const ProposalBondMaximum: Balance = 500 * DOLLARS; + pub const SpendPeriod: BlockNumber = 3 * DAYS; + pub const Burn: Permill = Permill::from_percent(0); + pub const TreasuryPalletId: PalletId = PalletId(*b"py/trsry"); + pub const MaxApprovals: u32 = 100; + pub TreasuryAccount: AccountId = Treasury::account_id(); +} + +impl pallet_treasury::Config for Runtime { + type Currency = Balances; + type ApproveOrigin = SuperMajorityCouncilOrRoot; + type RejectOrigin = MajorityCouncilOrRoot; + type RuntimeEvent = RuntimeEvent; + type OnSlash = Treasury; + type ProposalBond = ProposalBond; + type ProposalBondMinimum = ProposalBondMinimum; + type ProposalBondMaximum = ProposalBondMaximum; + type SpendPeriod = SpendPeriod; + type Burn = Burn; + type PalletId = TreasuryPalletId; + type BurnDestination = (); + type WeightInfo = weights::treasury::BasiliskWeight; + type SpendFunds = (); + type MaxApprovals = MaxApprovals; + type SpendOrigin = NeverEnsureOrigin; +} diff --git a/runtime/basilisk/src/governance.rs b/runtime/basilisk/src/governance/old.rs similarity index 77% rename from runtime/basilisk/src/governance.rs rename to runtime/basilisk/src/governance/old.rs index be48ba6014..26db29fd77 100644 --- a/runtime/basilisk/src/governance.rs +++ b/runtime/basilisk/src/governance/old.rs @@ -15,17 +15,17 @@ // See the License for the specific language governing permissions and // limitations under the License. -use super::*; +use crate::*; + use primitives::constants::{ - currency::{deposit, CENTS, DOLLARS}, + currency::{CENTS, DOLLARS}, time::{DAYS, HOURS}, }; use frame_support::{ parameter_types, - sp_runtime::{Perbill, Percent, Permill}, - traits::{EitherOfDiverse, EqualPrivilegeOnly, LockIdentifier, NeverEnsureOrigin}, - PalletId, + sp_runtime::{Perbill, Percent}, + traits::{EitherOfDiverse, LockIdentifier}, }; use frame_system::{EnsureRoot, EnsureSigned}; use pallet_collective::EnsureProportionAtLeast; @@ -198,66 +198,3 @@ impl pallet_tips::Config for Runtime { type Tippers = Elections; type WeightInfo = weights::tips::BasiliskWeight; } - -parameter_types! { - pub const PreimageMaxSize: u32 = 4096 * 1024; - pub PreimageBaseDeposit: Balance = deposit(2, 64); - pub PreimageByteDeposit: Balance = deposit(0, 1); -} - -impl pallet_preimage::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type WeightInfo = (); - type Currency = Balances; - type ManagerOrigin = EnsureRoot; - type BaseDeposit = PreimageBaseDeposit; - type ByteDeposit = PreimageByteDeposit; -} - -parameter_types! { - pub MaximumSchedulerWeight: Weight = Perbill::from_percent(10) * BlockWeights::get().max_block; - pub const MaxScheduledPerBlock: u32 = 50; -} - -impl pallet_scheduler::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type RuntimeOrigin = RuntimeOrigin; - type PalletsOrigin = OriginCaller; - type RuntimeCall = RuntimeCall; - type MaximumWeight = MaximumSchedulerWeight; - type ScheduleOrigin = EnsureRoot; - type OriginPrivilegeCmp = EqualPrivilegeOnly; - type MaxScheduledPerBlock = MaxScheduledPerBlock; - type WeightInfo = weights::scheduler::BasiliskWeight; - type Preimages = Preimage; -} - -parameter_types! { - pub const ProposalBond: Permill = Permill::from_percent(3); - pub const ProposalBondMinimum: Balance = 100 * DOLLARS; - pub const ProposalBondMaximum: Balance = 500 * DOLLARS; - pub const SpendPeriod: BlockNumber = 3 * DAYS; - pub const Burn: Permill = Permill::from_percent(0); - pub const TreasuryPalletId: PalletId = PalletId(*b"py/trsry"); - pub const MaxApprovals: u32 = 100; - pub TreasuryAccount: AccountId = Treasury::account_id(); -} - -impl pallet_treasury::Config for Runtime { - type Currency = Balances; - type ApproveOrigin = SuperMajorityCouncilOrRoot; - type RejectOrigin = MajorityCouncilOrRoot; - type RuntimeEvent = RuntimeEvent; - type OnSlash = Treasury; - type ProposalBond = ProposalBond; - type ProposalBondMinimum = ProposalBondMinimum; - type ProposalBondMaximum = ProposalBondMaximum; - type SpendPeriod = SpendPeriod; - type Burn = Burn; - type PalletId = TreasuryPalletId; - type BurnDestination = (); - type WeightInfo = weights::treasury::BasiliskWeight; - type SpendFunds = (); - type MaxApprovals = MaxApprovals; - type SpendOrigin = NeverEnsureOrigin; -} diff --git a/runtime/basilisk/src/system.rs b/runtime/basilisk/src/system.rs index 0f6cc4bac8..06591c27e2 100644 --- a/runtime/basilisk/src/system.rs +++ b/runtime/basilisk/src/system.rs @@ -16,7 +16,10 @@ // limitations under the License. use super::*; -use crate::governance::{MajorityCouncilOrRoot, MajorityTechCommitteeOrRoot}; +use crate::governance::{ + old::{MajorityCouncilOrRoot, MajorityTechCommitteeOrRoot, SuperMajorityTechCommitteeOrRoot}, + TreasuryAccount, +}; use pallet_transaction_multi_payment::{DepositAll, TransferFees}; use pallet_transaction_payment::{Multiplier, TargetedFeeAdjustment}; @@ -31,14 +34,14 @@ use frame_support::{ dispatch::DispatchClass, parameter_types, sp_runtime::{traits::IdentityLookup, FixedPointNumber, Perbill, Perquintill, RuntimeDebug}, - traits::{ConstBool, Contains, InstanceFilter, SortedMembers}, + traits::{ConstBool, Contains, EqualPrivilegeOnly, InstanceFilter, SortedMembers}, weights::{ constants::{BlockExecutionWeight, RocksDbWeight, WEIGHT_REF_TIME_PER_MICROS}, ConstantMultiplier, WeightToFeeCoefficient, WeightToFeeCoefficients, WeightToFeePolynomial, }, PalletId, }; -use frame_system::EnsureSignedBy; +use frame_system::{EnsureRoot, EnsureSignedBy}; use hydradx_adapters::RelayChainBlockNumberProvider; use scale_info::TypeInfo; @@ -283,6 +286,39 @@ impl InstanceFilter for ProxyType { } } +parameter_types! { + pub const PreimageMaxSize: u32 = 4096 * 1024; + pub PreimageBaseDeposit: Balance = deposit(2, 64); + pub PreimageByteDeposit: Balance = deposit(0, 1); +} + +impl pallet_preimage::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type WeightInfo = (); + type Currency = Balances; + type ManagerOrigin = EnsureRoot; + type BaseDeposit = PreimageBaseDeposit; + type ByteDeposit = PreimageByteDeposit; +} + +parameter_types! { + pub MaximumSchedulerWeight: Weight = Perbill::from_percent(10) * BlockWeights::get().max_block; + pub const MaxScheduledPerBlock: u32 = 50; +} + +impl pallet_scheduler::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type RuntimeOrigin = RuntimeOrigin; + type PalletsOrigin = OriginCaller; + type RuntimeCall = RuntimeCall; + type MaximumWeight = MaximumSchedulerWeight; + type ScheduleOrigin = EnsureRoot; + type OriginPrivilegeCmp = EqualPrivilegeOnly; + type MaxScheduledPerBlock = MaxScheduledPerBlock; + type WeightInfo = weights::scheduler::BasiliskWeight; + type Preimages = Preimage; +} + parameter_types! { pub ProxyDepositBase: Balance = 4 * DOLLARS + 480 * MILLICENTS; pub ProxyDepositFactor: Balance = 1_980 * MILLICENTS; diff --git a/runtime/basilisk/src/xcm.rs b/runtime/basilisk/src/xcm.rs index 6defe9fb96..6b5da361ef 100644 --- a/runtime/basilisk/src/xcm.rs +++ b/runtime/basilisk/src/xcm.rs @@ -16,7 +16,10 @@ // limitations under the License. use super::*; -use crate::governance::{MajorityTechCommitteeOrRoot, SuperMajorityCouncilOrRoot, TreasuryAccount}; +use crate::governance::{ + old::{MajorityTechCommitteeOrRoot, SuperMajorityCouncilOrRoot, SuperMajorityTechCommitteeOrRoot}, + TreasuryAccount, +}; use crate::system::WeightToFee; use codec::{Decode, Encode, MaxEncodedLen}; From d17a6ed0ce2e47eede7c2c88a2f183e1be04d871 Mon Sep 17 00:00:00 2001 From: Valery Gantchev Date: Mon, 8 Apr 2024 17:24:35 +0200 Subject: [PATCH 03/18] Add features for the new dependencies --- Cargo.lock | 1 + runtime/basilisk/Cargo.toml | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index 58afdb0b17..2b03523497 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -956,6 +956,7 @@ dependencies = [ "serde", "smallvec", "sp-api", + "sp-arithmetic", "sp-block-builder", "sp-consensus-aura", "sp-core", diff --git a/runtime/basilisk/Cargo.toml b/runtime/basilisk/Cargo.toml index 4af633460d..26505082c6 100644 --- a/runtime/basilisk/Cargo.toml +++ b/runtime/basilisk/Cargo.toml @@ -114,6 +114,7 @@ pallet-uniques = { workspace = true } pallet-utility = { workspace = true } pallet-whitelist = { workspace = true } sp-api = { workspace = true } +sp-arithmetic = { workspace = true } sp-block-builder = { workspace = true } sp-consensus-aura = { workspace = true } sp-core = { workspace = true } @@ -166,6 +167,9 @@ runtime-benchmarks = [ "pallet-xcm-rate-limiter/runtime-benchmarks", "pallet-elections-phragmen/runtime-benchmarks", "pallet-state-trie-migration/runtime-benchmarks", + "pallet-conviction-voting/runtime-benchmarks", + "pallet-referenda/runtime-benchmarks", + "pallet-whitelist/runtime-benchmarks", ] std = [ "codec/std", @@ -216,6 +220,7 @@ std = [ "hydradx-traits/std", "hydradx-adapters/std", "sp-api/std", + "sp-arithmetic/std", "sp-block-builder/std", "sp-consensus-aura/std", "sp-core/std", @@ -244,6 +249,9 @@ std = [ "pallet-ema-oracle/std", "pallet-xcm-rate-limiter/std", "pallet-state-trie-migration/std", + "pallet-conviction-voting/std", + "pallet-referenda/std", + "pallet-whitelist/std", ] try-runtime= [ "frame-try-runtime", @@ -297,4 +305,7 @@ try-runtime= [ "pallet-collator-rewards/try-runtime", "pallet-xcm-rate-limiter/try-runtime", "pallet-state-trie-migration/try-runtime", + "pallet-conviction-voting/try-runtime", + "pallet-referenda/try-runtime", + "pallet-whitelist/try-runtime", ] From a8b39041b170f8fea1fbb95f51065ba69c255170 Mon Sep 17 00:00:00 2001 From: Valery Gantchev Date: Wed, 8 May 2024 15:21:10 +0200 Subject: [PATCH 04/18] flag origins to be replaced --- runtime/basilisk/src/assets.rs | 5 +++++ runtime/basilisk/src/governance/mod.rs | 2 ++ runtime/basilisk/src/system.rs | 6 ++++++ runtime/basilisk/src/xcm.rs | 5 +++++ 4 files changed, 18 insertions(+) diff --git a/runtime/basilisk/src/assets.rs b/runtime/basilisk/src/assets.rs index 1a61b5522c..540b392553 100644 --- a/runtime/basilisk/src/assets.rs +++ b/runtime/basilisk/src/assets.rs @@ -148,6 +148,7 @@ parameter_types! { } impl pallet_asset_registry::Config for Runtime { type RuntimeEvent = RuntimeEvent; + // TODO origin type RegistryOrigin = SuperMajorityTechCommitteeOrRoot; type AssetId = AssetId; type Balance = Balance; @@ -171,6 +172,7 @@ impl pallet_duster::Config for Runtime { type MinCurrencyDeposits = AssetRegistry; type Reward = DustingReward; type NativeCurrencyId = NativeAssetId; + // TODO origin type BlacklistUpdateOrigin = MajorityTechCommitteeOrRoot; type WeightInfo = weights::duster::BasiliskWeight; } @@ -262,6 +264,7 @@ impl pallet_lbp::Config for Runtime { type RuntimeEvent = RuntimeEvent; type MultiCurrency = Currencies; type LockedBalance = MultiCurrencyLockedBalance; + // TODO origin type CreatePoolOrigin = SuperMajorityTechCommitteeOrRoot; type LBPWeightFunction = pallet_lbp::LBPWeightFunction; type AssetPairAccountId = AssetPairAccountId; @@ -351,6 +354,7 @@ impl pallet_uniques::Config for Runtime { type CollectionId = CollectionId; type ItemId = ItemId; type Currency = KusamaCurrency; + // TODO origin type ForceOrigin = SuperMajorityCouncilOrRoot; // Standard collection creation is disallowed type CreateOrigin = AsEnsureOriginWithArg>; @@ -377,6 +381,7 @@ impl pallet_xyk_liquidity_mining::Config for Runtime { type RuntimeEvent = RuntimeEvent; type MultiCurrency = Currencies; type AMM = XYK; + // TODO origin type CreateOrigin = UnanimousTechCommitteeOrRoot; type PalletId = LMPalletId; type NftCollectionId = LiquidityMiningNftCollectionId; diff --git a/runtime/basilisk/src/governance/mod.rs b/runtime/basilisk/src/governance/mod.rs index cee26c5c84..a14974528b 100644 --- a/runtime/basilisk/src/governance/mod.rs +++ b/runtime/basilisk/src/governance/mod.rs @@ -36,7 +36,9 @@ parameter_types! { impl pallet_treasury::Config for Runtime { type Currency = Balances; + // TODO origin type ApproveOrigin = SuperMajorityCouncilOrRoot; + // TODO origin type RejectOrigin = MajorityCouncilOrRoot; type RuntimeEvent = RuntimeEvent; type OnSlash = Treasury; diff --git a/runtime/basilisk/src/system.rs b/runtime/basilisk/src/system.rs index 06591c27e2..68ede7f446 100644 --- a/runtime/basilisk/src/system.rs +++ b/runtime/basilisk/src/system.rs @@ -229,6 +229,7 @@ impl pallet_transaction_payment::Config for Runtime { impl pallet_transaction_multi_payment::Config for Runtime { type RuntimeEvent = RuntimeEvent; + // TODO origin type AcceptedCurrencyOrigin = MajorityTechCommitteeOrRoot; type Currencies = Currencies; type RouteProvider = Router; @@ -396,6 +397,7 @@ parameter_types! { impl pallet_collator_selection::Config for Runtime { type RuntimeEvent = RuntimeEvent; type Currency = Balances; + // TODO origin type UpdateOrigin = MajorityTechCommitteeOrRoot; type PotId = PotId; type MaxCandidates = MaxCandidates; @@ -439,6 +441,7 @@ impl pallet_relaychain_info::Config for Runtime { impl pallet_transaction_pause::Config for Runtime { type RuntimeEvent = RuntimeEvent; + // TODO origin type UpdateOrigin = MajorityTechCommitteeOrRoot; type WeightInfo = weights::transaction_pause::BasiliskWeight; } @@ -485,7 +488,9 @@ impl pallet_identity::Config for Runtime { type MaxAdditionalFields = MaxAdditionalFields; type MaxRegistrars = MaxRegistrars; type Slashed = Treasury; + // TODO origin type ForceOrigin = MajorityCouncilOrRoot; + // TODO origin type RegistrarOrigin = MajorityCouncilOrRoot; type WeightInfo = (); } @@ -521,6 +526,7 @@ parameter_types! { } impl pallet_state_trie_migration::Config for Runtime { + // TODO origin type ControlOrigin = SuperMajorityTechCommitteeOrRoot; type SignedFilter = EnsureSignedBy; type RuntimeEvent = RuntimeEvent; diff --git a/runtime/basilisk/src/xcm.rs b/runtime/basilisk/src/xcm.rs index 6b5da361ef..ce12af6934 100644 --- a/runtime/basilisk/src/xcm.rs +++ b/runtime/basilisk/src/xcm.rs @@ -176,7 +176,9 @@ impl cumulus_pallet_xcmp_queue::Config for Runtime { type XcmExecutor = XcmExecutor; type ChannelInfo = ParachainSystem; type VersionWrapper = PolkadotXcm; + // TODO origin type ExecuteOverweightOrigin = MajorityTechCommitteeOrRoot; + // TODO origin type ControllerOrigin = MajorityTechCommitteeOrRoot; type ControllerOriginConverter = XcmOriginToCallOrigin; type PriceForSiblingDelivery = (); @@ -192,6 +194,7 @@ impl cumulus_pallet_xcmp_queue::Config for Runtime { impl cumulus_pallet_dmp_queue::Config for Runtime { type RuntimeEvent = RuntimeEvent; type XcmExecutor = XcmExecutor; + // TODO origin type ExecuteOverweightOrigin = MajorityTechCommitteeOrRoot; } @@ -224,6 +227,7 @@ impl orml_unknown_tokens::Config for Runtime { impl orml_xcm::Config for Runtime { type RuntimeEvent = RuntimeEvent; + // TODO origin type SovereignOrigin = SuperMajorityCouncilOrRoot; } @@ -265,6 +269,7 @@ impl pallet_xcm::Config for Runtime { type WeightInfo = weights::xcm::BasiliskWeight; #[cfg(feature = "runtime-benchmarks")] type ReachableDest = ReachableDest; + // TODO origin type AdminOrigin = SuperMajorityTechCommitteeOrRoot; type MaxRemoteLockConsumers = ConstU32<0>; type RemoteLockConsumerIdentifier = (); From e1515f5492ef3b76b938659a6cbd26bd70d9d58b Mon Sep 17 00:00:00 2001 From: Valery Gantchev Date: Wed, 8 May 2024 15:57:55 +0200 Subject: [PATCH 05/18] resolve merge conflicts --- runtime/basilisk/src/governance/mod.rs | 70 ++++++++++++- runtime/basilisk/src/governance/old.rs | 137 ------------------------- runtime/basilisk/src/system.rs | 14 ++- 3 files changed, 78 insertions(+), 143 deletions(-) diff --git a/runtime/basilisk/src/governance/mod.rs b/runtime/basilisk/src/governance/mod.rs index a14974528b..721105b518 100644 --- a/runtime/basilisk/src/governance/mod.rs +++ b/runtime/basilisk/src/governance/mod.rs @@ -32,6 +32,7 @@ parameter_types! { pub const TreasuryPalletId: PalletId = PalletId(*b"py/trsry"); pub const MaxApprovals: u32 = 100; pub TreasuryAccount: AccountId = Treasury::account_id(); + pub const TreasuryPayoutPeriod: u32 = 30 * DAYS; } impl pallet_treasury::Config for Runtime { @@ -49,8 +50,73 @@ impl pallet_treasury::Config for Runtime { type Burn = Burn; type PalletId = TreasuryPalletId; type BurnDestination = (); - type WeightInfo = weights::treasury::BasiliskWeight; + type WeightInfo = weights::pallet_treasury::BasiliskWeight; type SpendFunds = (); type MaxApprovals = MaxApprovals; - type SpendOrigin = NeverEnsureOrigin; + #[cfg(not(feature = "runtime-benchmarks"))] + type SpendOrigin = NeverEnsureOrigin; // Disabled, no spending + #[cfg(feature = "runtime-benchmarks")] + type SpendOrigin = + frame_system::EnsureWithSuccess, AccountId, crate::benches::BenchmarkMaxBalance>; + type AssetKind = (); + type Beneficiary = AccountId; + type BeneficiaryLookup = IdentityLookup; + type Paymaster = PayFromTreasuryAccount; + type BalanceConverter = UnityAssetBalanceConversion; + type PayoutPeriod = TreasuryPayoutPeriod; + #[cfg(feature = "runtime-benchmarks")] + type BenchmarkHelper = benchmarking::BenchmarkHelper; +} + +pub struct PayFromTreasuryAccount; + +impl Pay for PayFromTreasuryAccount { + type Balance = Balance; + type Beneficiary = AccountId; + type AssetKind = (); + type Id = (); + type Error = DispatchError; + + #[cfg(not(feature = "runtime-benchmarks"))] + fn pay( + who: &Self::Beneficiary, + _asset_kind: Self::AssetKind, + amount: Self::Balance, + ) -> Result { + let _ = >::transfer( + &TreasuryAccount::get(), + who, + amount, + Preservation::Expendable, + )?; + Ok(()) + } + + #[cfg(feature = "runtime-benchmarks")] + fn pay( + who: &Self::Beneficiary, + _asset_kind: Self::AssetKind, + amount: Self::Balance, + ) -> Result { + // In case of benchmarks, we adjust the value by multiplying it by 1_000_000_000_000, otherwise it fails with BelowMinimum limit error, because + // treasury benchmarks uses only 100 as the amount. + let _ = >::transfer( + &TreasuryAccount::get(), + who, + amount * 1_000_000_000_000, + Preservation::Expendable, + )?; + Ok(()) + } + + fn check_payment(_id: Self::Id) -> PaymentStatus { + PaymentStatus::Success + } + + #[cfg(feature = "runtime-benchmarks")] + fn ensure_successful(_: &Self::Beneficiary, _: Self::AssetKind, amount: Self::Balance) { + >::mint_into(&TreasuryAccount::get(), amount * 1_000_000_000_000).unwrap(); + } + #[cfg(feature = "runtime-benchmarks")] + fn ensure_concluded(_: Self::Id) {} } diff --git a/runtime/basilisk/src/governance/old.rs b/runtime/basilisk/src/governance/old.rs index bcea495551..58407de7fe 100644 --- a/runtime/basilisk/src/governance/old.rs +++ b/runtime/basilisk/src/governance/old.rs @@ -207,140 +207,3 @@ impl pallet_tips::Config for Runtime { type Tippers = Elections; type WeightInfo = weights::pallet_tips::BasiliskWeight; } - -parameter_types! { - pub const PreimageMaxSize: u32 = 4096 * 1024; - pub PreimageBaseDeposit: Balance = deposit(2, 64); - pub PreimageByteDeposit: Balance = deposit(0, 1); - pub const PreimageHoldReason: RuntimeHoldReason = RuntimeHoldReason::Preimage(pallet_preimage::HoldReason::Preimage); -} - -impl pallet_preimage::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type WeightInfo = weights::pallet_preimage::BasiliskWeight; - type Currency = Balances; - type ManagerOrigin = EnsureRoot; - type Consideration = HoldConsideration< - AccountId, - Balances, - PreimageHoldReason, - LinearStoragePrice, - >; -} - -parameter_types! { - pub MaximumSchedulerWeight: Weight = Perbill::from_percent(10) * BlockWeights::get().max_block; - pub const MaxScheduledPerBlock: u32 = 50; -} - -impl pallet_scheduler::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type RuntimeOrigin = RuntimeOrigin; - type PalletsOrigin = OriginCaller; - type RuntimeCall = RuntimeCall; - type MaximumWeight = MaximumSchedulerWeight; - type ScheduleOrigin = EnsureRoot; - type OriginPrivilegeCmp = EqualPrivilegeOnly; - type MaxScheduledPerBlock = MaxScheduledPerBlock; - type WeightInfo = weights::pallet_scheduler::BasiliskWeight; - type Preimages = Preimage; -} - -parameter_types! { - pub const ProposalBond: Permill = Permill::from_percent(3); - pub const ProposalBondMinimum: Balance = 100 * DOLLARS; - pub const ProposalBondMaximum: Balance = 500 * DOLLARS; - pub const SpendPeriod: BlockNumber = 3 * DAYS; - pub const Burn: Permill = Permill::from_percent(0); - pub const TreasuryPalletId: PalletId = PalletId(*b"py/trsry"); - pub const MaxApprovals: u32 = 100; - pub TreasuryAccount: AccountId = Treasury::account_id(); - pub const TreasuryPayoutPeriod: u32 = 30 * DAYS; -} - -pub struct PayFromTreasuryAccount; - -impl Pay for PayFromTreasuryAccount { - type Balance = Balance; - type Beneficiary = AccountId; - type AssetKind = (); - type Id = (); - type Error = DispatchError; - - #[cfg(not(feature = "runtime-benchmarks"))] - fn pay( - who: &Self::Beneficiary, - _asset_kind: Self::AssetKind, - amount: Self::Balance, - ) -> Result { - let _ = >::transfer( - &TreasuryAccount::get(), - who, - amount, - Preservation::Expendable, - )?; - Ok(()) - } - - #[cfg(feature = "runtime-benchmarks")] - fn pay( - who: &Self::Beneficiary, - _asset_kind: Self::AssetKind, - amount: Self::Balance, - ) -> Result { - // In case of benchmarks, we adjust the value by multiplying it by 1_000_000_000_000, otherwise it fails with BelowMinimum limit error, because - // treasury benchmarks uses only 100 as the amount. - let _ = >::transfer( - &TreasuryAccount::get(), - who, - amount * 1_000_000_000_000, - Preservation::Expendable, - )?; - Ok(()) - } - - fn check_payment(_id: Self::Id) -> PaymentStatus { - PaymentStatus::Success - } - - #[cfg(feature = "runtime-benchmarks")] - fn ensure_successful(_: &Self::Beneficiary, _: Self::AssetKind, amount: Self::Balance) { - >::mint_into(&TreasuryAccount::get(), amount * 1_000_000_000_000).unwrap(); - } - #[cfg(feature = "runtime-benchmarks")] - fn ensure_concluded(_: Self::Id) {} -} - -#[cfg(not(feature = "runtime-benchmarks"))] -use frame_support::traits::NeverEnsureOrigin; - -impl pallet_treasury::Config for Runtime { - type Currency = Balances; - type ApproveOrigin = SuperMajorityCouncilOrRoot; - type RejectOrigin = MajorityCouncilOrRoot; - type RuntimeEvent = RuntimeEvent; - type OnSlash = Treasury; - type ProposalBond = ProposalBond; - type ProposalBondMinimum = ProposalBondMinimum; - type ProposalBondMaximum = ProposalBondMaximum; - type SpendPeriod = SpendPeriod; - type Burn = Burn; - type PalletId = TreasuryPalletId; - type BurnDestination = (); - type WeightInfo = weights::pallet_treasury::BasiliskWeight; - type SpendFunds = (); - type MaxApprovals = MaxApprovals; - #[cfg(not(feature = "runtime-benchmarks"))] - type SpendOrigin = NeverEnsureOrigin; // Disabled, no spending - #[cfg(feature = "runtime-benchmarks")] - type SpendOrigin = - frame_system::EnsureWithSuccess, AccountId, crate::benches::BenchmarkMaxBalance>; - type AssetKind = (); - type Beneficiary = AccountId; - type BeneficiaryLookup = IdentityLookup; - type Paymaster = PayFromTreasuryAccount; - type BalanceConverter = UnityAssetBalanceConversion; - type PayoutPeriod = TreasuryPayoutPeriod; - #[cfg(feature = "runtime-benchmarks")] - type BenchmarkHelper = benchmarking::BenchmarkHelper; -} diff --git a/runtime/basilisk/src/system.rs b/runtime/basilisk/src/system.rs index 6502308642..e91764ec9f 100644 --- a/runtime/basilisk/src/system.rs +++ b/runtime/basilisk/src/system.rs @@ -332,15 +332,20 @@ parameter_types! { pub const PreimageMaxSize: u32 = 4096 * 1024; pub PreimageBaseDeposit: Balance = deposit(2, 64); pub PreimageByteDeposit: Balance = deposit(0, 1); + pub const PreimageHoldReason: RuntimeHoldReason = RuntimeHoldReason::Preimage(pallet_preimage::HoldReason::Preimage); } impl pallet_preimage::Config for Runtime { type RuntimeEvent = RuntimeEvent; - type WeightInfo = (); + type WeightInfo = weights::pallet_preimage::BasiliskWeight; type Currency = Balances; type ManagerOrigin = EnsureRoot; - type BaseDeposit = PreimageBaseDeposit; - type ByteDeposit = PreimageByteDeposit; + type Consideration = HoldConsideration< + AccountId, + Balances, + PreimageHoldReason, + LinearStoragePrice, + >; } parameter_types! { @@ -357,10 +362,11 @@ impl pallet_scheduler::Config for Runtime { type ScheduleOrigin = EnsureRoot; type OriginPrivilegeCmp = EqualPrivilegeOnly; type MaxScheduledPerBlock = MaxScheduledPerBlock; - type WeightInfo = weights::scheduler::BasiliskWeight; + type WeightInfo = weights::pallet_scheduler::BasiliskWeight; type Preimages = Preimage; } + parameter_types! { pub ProxyDepositBase: Balance = 4 * DOLLARS + 480 * MILLICENTS; pub ProxyDepositFactor: Balance = 1_980 * MILLICENTS; From 890f4c28c16dff8b49ddd0aded3caa430947b3b6 Mon Sep 17 00:00:00 2001 From: Valery Gantchev Date: Wed, 8 May 2024 16:44:40 +0200 Subject: [PATCH 06/18] fixes --- runtime/basilisk/src/governance/mod.rs | 13 ++++++++++++- runtime/basilisk/src/governance/old.rs | 13 +++---------- runtime/basilisk/src/system.rs | 9 ++++----- 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/runtime/basilisk/src/governance/mod.rs b/runtime/basilisk/src/governance/mod.rs index 721105b518..508a66ef97 100644 --- a/runtime/basilisk/src/governance/mod.rs +++ b/runtime/basilisk/src/governance/mod.rs @@ -17,8 +17,18 @@ use super::*; use crate::old::{MajorityCouncilOrRoot, SuperMajorityCouncilOrRoot}; -use frame_support::{parameter_types, sp_runtime::Permill, traits::NeverEnsureOrigin, PalletId}; +use frame_support::{ + parameter_types, + sp_runtime::Permill, + traits::{ + fungible, + tokens::{Pay, PaymentStatus, Preservation, UnityAssetBalanceConversion}, + NeverEnsureOrigin, + }, + PalletId, +}; use primitives::constants::{currency::DOLLARS, time::DAYS}; +use sp_runtime::{traits::IdentityLookup, DispatchError}; // Old governance configurations. pub mod old; @@ -53,6 +63,7 @@ impl pallet_treasury::Config for Runtime { type WeightInfo = weights::pallet_treasury::BasiliskWeight; type SpendFunds = (); type MaxApprovals = MaxApprovals; + // TODO origin TreasurySpender #[cfg(not(feature = "runtime-benchmarks"))] type SpendOrigin = NeverEnsureOrigin; // Disabled, no spending #[cfg(feature = "runtime-benchmarks")] diff --git a/runtime/basilisk/src/governance/old.rs b/runtime/basilisk/src/governance/old.rs index 58407de7fe..677d86fc5d 100644 --- a/runtime/basilisk/src/governance/old.rs +++ b/runtime/basilisk/src/governance/old.rs @@ -18,24 +18,17 @@ use crate::*; use primitives::constants::{ - currency::{CENTS, DOLLARS}, - currency::{deposit, CENTS, DOLLARS, UNITS}, + currency::{CENTS, DOLLARS, UNITS}, time::{DAYS, HOURS}, }; -use frame_support::traits::fungible::HoldConsideration; -use frame_support::traits::tokens::{Pay, PaymentStatus, Preservation, UnityAssetBalanceConversion}; -use frame_support::traits::{fungible, LinearStoragePrice}; use frame_support::{ parameter_types, - sp_runtime::{Perbill, Percent, Permill}, - traits::{EitherOfDiverse, EqualPrivilegeOnly, LockIdentifier}, - PalletId, + sp_runtime::{Perbill, Percent}, + traits::{EitherOfDiverse, LockIdentifier}, }; use frame_system::{EnsureRoot, EnsureSigned}; use pallet_collective::EnsureProportionAtLeast; -use sp_runtime::traits::IdentityLookup; -use sp_runtime::DispatchError; use sp_staking::currency_to_vote::U128CurrencyToVote; pub type MajorityCouncilOrRoot = diff --git a/runtime/basilisk/src/system.rs b/runtime/basilisk/src/system.rs index e91764ec9f..b7cf7518ac 100644 --- a/runtime/basilisk/src/system.rs +++ b/runtime/basilisk/src/system.rs @@ -36,7 +36,10 @@ use frame_support::{ dispatch::DispatchClass, parameter_types, sp_runtime::{traits::IdentityLookup, FixedPointNumber, Perbill, Perquintill, RuntimeDebug}, - traits::{ConstBool, Contains, EqualPrivilegeOnly, InstanceFilter, SortedMembers}, + traits::{ + fungible::HoldConsideration, ConstBool, Contains, EqualPrivilegeOnly, InstanceFilter, LinearStoragePrice, + SortedMembers, + }, weights::{ constants::{BlockExecutionWeight, RocksDbWeight, WEIGHT_REF_TIME_PER_MICROS}, ConstantMultiplier, WeightToFeeCoefficient, WeightToFeeCoefficients, WeightToFeePolynomial, @@ -366,7 +369,6 @@ impl pallet_scheduler::Config for Runtime { type Preimages = Preimage; } - parameter_types! { pub ProxyDepositBase: Balance = 4 * DOLLARS + 480 * MILLICENTS; pub ProxyDepositFactor: Balance = 1_980 * MILLICENTS; @@ -588,9 +590,6 @@ parameter_types! { #[cfg(feature = "runtime-benchmarks")] use frame_system::EnsureSigned; -#[cfg(not(feature = "runtime-benchmarks"))] -use frame_system::EnsureSignedBy; - impl pallet_state_trie_migration::Config for Runtime { // TODO origin type ControlOrigin = SuperMajorityTechCommitteeOrRoot; From b153671a2424abe8191c580072729a015f7c79ed Mon Sep 17 00:00:00 2001 From: Valery Gantchev Date: Wed, 29 May 2024 20:47:31 +0200 Subject: [PATCH 07/18] origins and tracks --- primitives/src/constants.rs | 1 + runtime/basilisk/src/governance/mod.rs | 4 + runtime/basilisk/src/governance/origins.rs | 136 +++++++++++++++ runtime/basilisk/src/governance/tracks.rs | 193 +++++++++++++++++++++ 4 files changed, 334 insertions(+) create mode 100644 runtime/basilisk/src/governance/origins.rs create mode 100644 runtime/basilisk/src/governance/tracks.rs diff --git a/primitives/src/constants.rs b/primitives/src/constants.rs index 2334bb795e..dc4455a598 100644 --- a/primitives/src/constants.rs +++ b/primitives/src/constants.rs @@ -21,6 +21,7 @@ pub mod currency { pub const FORTUNE: Balance = u128::MAX; pub const UNITS: Balance = 1_000_000_000_000; pub const DOLLARS: Balance = UNITS * 100; // 100 UNITS ~= 1 $ + pub const GRAND: Balance = UNITS * 1_000; pub const CENTS: Balance = DOLLARS / 100; // 1 UNITS ~= 1 cent pub const MILLICENTS: Balance = CENTS / 1_000; pub const NATIVE_EXISTENTIAL_DEPOSIT: Balance = CENTS; diff --git a/runtime/basilisk/src/governance/mod.rs b/runtime/basilisk/src/governance/mod.rs index 508a66ef97..4e5c571740 100644 --- a/runtime/basilisk/src/governance/mod.rs +++ b/runtime/basilisk/src/governance/mod.rs @@ -30,6 +30,8 @@ use frame_support::{ use primitives::constants::{currency::DOLLARS, time::DAYS}; use sp_runtime::{traits::IdentityLookup, DispatchError}; +mod origins; +mod tracks; // Old governance configurations. pub mod old; @@ -131,3 +133,5 @@ impl Pay for PayFromTreasuryAccount { #[cfg(feature = "runtime-benchmarks")] fn ensure_concluded(_: Self::Id) {} } + +impl origins::pallet_custom_origins::Config for Runtime {} diff --git a/runtime/basilisk/src/governance/origins.rs b/runtime/basilisk/src/governance/origins.rs new file mode 100644 index 0000000000..30e0f3b6e5 --- /dev/null +++ b/runtime/basilisk/src/governance/origins.rs @@ -0,0 +1,136 @@ +// This file is part of Basilisk-node. + +// Copyright (C) 2020-2023 Intergalactic, Limited (GIB). +// SPDX-License-Identifier: Apache-2.0 + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//! Custom origins for governance interventions. + +pub use pallet_custom_origins::*; + +#[frame_support::pallet] +pub mod pallet_custom_origins { + use crate::Balance; + use primitives::constants::currency::GRAND; + use frame_support::pallet_prelude::*; + + #[pallet::config] + pub trait Config: frame_system::Config {} + + #[pallet::pallet] + pub struct Pallet(_); + + #[derive(PartialEq, Eq, Clone, MaxEncodedLen, Encode, Decode, TypeInfo, RuntimeDebug)] + #[pallet::origin] + pub enum Origin { + /// Origin able to dispatch a whitelisted call. + WhitelistedCaller, + /// Origin able to cancel referenda. + ReferendumCanceller, + /// Origin able to kill referenda. + ReferendumKiller, + /// Origin for managing general stuff such as the registrar and permissioned HRMP + /// channel operations. + GeneralAdmin, + /// TODO descr + ProtocolCommitteeAdmin, + /// Origin for spending very high amounts of BSX from the treasury as well as generally + /// administering it. + Treasurer, + /// Origin able to spend up to roughly $5,000 from the treasury at once. + Spender, + /// Origin able to spend up to roughly $500 from the treasury at once. + Tipper, + } + + macro_rules! decl_unit_ensures { + ( $name:ident: $success_type:ty = $success:expr ) => { + pub struct $name; + impl> + From> + EnsureOrigin for $name + { + type Success = $success_type; + fn try_origin(o: O) -> Result { + o.into().and_then(|o| match o { + Origin::$name => Ok($success), + r => Err(O::from(r)), + }) + } + #[cfg(feature = "runtime-benchmarks")] + fn try_successful_origin() -> Result { + Ok(O::from(Origin::$name)) + } + } + }; + ( $name:ident ) => { decl_unit_ensures! { $name : () = () } }; + ( $name:ident: $success_type:ty = $success:expr, $( $rest:tt )* ) => { + decl_unit_ensures! { $name: $success_type = $success } + decl_unit_ensures! { $( $rest )* } + }; + ( $name:ident, $( $rest:tt )* ) => { + decl_unit_ensures! { $name } + decl_unit_ensures! { $( $rest )* } + }; + () => {} + } + decl_unit_ensures!( + GeneralAdmin, + ProtocolCommitteeAdmin, + WhitelistedCaller, + ReferendumCanceller, + ReferendumKiller, + Treasurer, + ); + + macro_rules! decl_ensure { + ( + $vis:vis type $name:ident: EnsureOrigin { + $( $item:ident = $success:expr, )* + } + ) => { + $vis struct $name; + impl> + From> + EnsureOrigin for $name + { + type Success = $success_type; + fn try_origin(o: O) -> Result { + o.into().and_then(|o| match o { + $( + Origin::$item => Ok($success), + )* + r => Err(O::from(r)), + }) + } + #[cfg(feature = "runtime-benchmarks")] + fn try_successful_origin() -> Result { + // By convention the more privileged origins go later, so for greatest chance + // of success, we want the last one. + let _result: Result = Err(()); + $( + let _result: Result = Ok(O::from(Origin::$item)); + )* + _result + } + } + } + } + + decl_ensure! { + pub type Spender: EnsureOrigin { + Tipper = 2_500 * GRAND, + Spender = 25_000 * GRAND, + Treasurer = 2_500_000 * GRAND, + } + } +} diff --git a/runtime/basilisk/src/governance/tracks.rs b/runtime/basilisk/src/governance/tracks.rs new file mode 100644 index 0000000000..6623849118 --- /dev/null +++ b/runtime/basilisk/src/governance/tracks.rs @@ -0,0 +1,193 @@ +// This file is part of Basilisk-node. + +// Copyright (C) 2020-2023 Intergalactic, Limited (GIB). +// SPDX-License-Identifier: Apache-2.0 + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//! Track configurations for governance. + +use super::*; +use primitives::constants::{currency::UNITS, time::{HOURS, MINUTES}}; +const fn percent(x: i32) -> sp_arithmetic::FixedI64 { + sp_arithmetic::FixedI64::from_rational(x as u128, 100) +} + +use pallet_referenda::Curve; +const APP_LINEAR: Curve = Curve::make_linear(7, 7, percent(50), percent(100)); +const APP_LINEAR_FLAT: Curve = Curve::make_linear(4, 7, percent(50), percent(100)); +const APP_RECIP: Curve = Curve::make_reciprocal(1, 7, percent(80), percent(50), percent(100)); +const SUP_LINEAR: Curve = Curve::make_linear(7, 7, percent(0), percent(50)); +const SUP_RECIP: Curve = Curve::make_reciprocal(5, 7, percent(1), percent(0), percent(50)); +const SUP_FAST_RECIP: Curve = Curve::make_reciprocal(3, 7, percent(1), percent(0), percent(50)); +const SUP_WHITELISTED_CALLER: Curve = Curve::make_reciprocal(1, 28, percent(20), percent(1), percent(50)); + +const TRACKS_DATA: [(u16, pallet_referenda::TrackInfo); 9] = [ + ( + 0, + pallet_referenda::TrackInfo { + name: "root", + max_deciding: 1, + decision_deposit: 100_000_000 * UNITS, + prepare_period: 24 * HOURS, + decision_period: 7 * DAYS, + confirm_period: 24 * HOURS, + min_enactment_period: 24 * HOURS, + min_approval: APP_RECIP, + min_support: SUP_LINEAR, + }, + ), + ( + 1, + pallet_referenda::TrackInfo { + name: "whitelisted_caller", + max_deciding: 10, + decision_deposit: 1_000_000 * UNITS, + prepare_period: 10 * MINUTES, + decision_period: 7 * DAYS, + confirm_period: 10 * MINUTES, + min_enactment_period: 10 * MINUTES, + min_approval: APP_RECIP, + min_support: SUP_WHITELISTED_CALLER, + }, + ), + ( + 2, + pallet_referenda::TrackInfo { + name: "referendum_canceller", + max_deciding: 10, + decision_deposit: 10_000_000 * UNITS, + prepare_period: 60 * MINUTES, + decision_period: 7 * DAYS, + confirm_period: 24 * HOURS, + min_enactment_period: 10 * MINUTES, + min_approval: APP_LINEAR_FLAT, + min_support: SUP_FAST_RECIP, + }, + ), + ( + 3, + pallet_referenda::TrackInfo { + name: "referendum_killer", + max_deciding: 10, + decision_deposit: 50_000_000 * UNITS, + prepare_period: 60 * MINUTES, + decision_period: 7 * DAYS, + confirm_period: 3 * HOURS, + min_enactment_period: 10 * MINUTES, + min_approval: APP_LINEAR_FLAT, + min_support: SUP_FAST_RECIP, + }, + ), + ( + 4, + pallet_referenda::TrackInfo { + name: "general_admin", + max_deciding: 10, + decision_deposit: 10_000_000 * UNITS, + prepare_period: 60 * MINUTES, + decision_period: 7 * DAYS, + confirm_period: 3 * HOURS, + min_enactment_period: 10 * MINUTES, + min_approval: APP_RECIP, + min_support: SUP_RECIP, + }, + ), + ( + 5, + pallet_referenda::TrackInfo { + name: "protocol_committee_admin", + max_deciding: 10, + decision_deposit: 50_000_000 * UNITS, + prepare_period: 60 * MINUTES, + decision_period: 7 * DAYS, + confirm_period: 24 * HOURS, + min_enactment_period: 24 * HOURS, + min_approval: APP_LINEAR_FLAT, + min_support: SUP_RECIP, + }, + ), + ( + 6, + pallet_referenda::TrackInfo { + name: "treasurer", + max_deciding: 10, + decision_deposit: 50_000_000 * UNITS, + prepare_period: 60 * MINUTES, + decision_period: 7 * DAYS, + confirm_period: 12 * HOURS, + min_enactment_period: 10 * MINUTES, + min_approval: APP_RECIP, + min_support: SUP_LINEAR, + }, + ), + ( + 7, + pallet_referenda::TrackInfo { + name: "spender", + max_deciding: 10, + decision_deposit: 5_000_000 * UNITS, + prepare_period: 60 * MINUTES, + decision_period: 7 * DAYS, + confirm_period: 3 * HOURS, + min_enactment_period: 10 * MINUTES, + min_approval: APP_LINEAR, + min_support: SUP_RECIP, + }, + ), + ( + 8, + pallet_referenda::TrackInfo { + name: "tipper", + max_deciding: 10, + decision_deposit: 500_000 * UNITS, + prepare_period: 60 * MINUTES, + decision_period: 7 * DAYS, + confirm_period: 3 * HOURS, + min_enactment_period: 10 * MINUTES, + min_approval: APP_LINEAR_FLAT, + min_support: SUP_FAST_RECIP, + }, + ), +]; + +pub struct TracksInfo; +impl pallet_referenda::TracksInfo for TracksInfo { + type Id = u16; + type RuntimeOrigin = ::PalletsOrigin; + fn tracks() -> &'static [(Self::Id, pallet_referenda::TrackInfo)] { + &TRACKS_DATA[..] + } + fn track_for(id: &Self::RuntimeOrigin) -> Result { + if let Ok(system_origin) = frame_system::RawOrigin::try_from(id.clone()) { + match system_origin { + frame_system::RawOrigin::Root => Ok(0), + _ => Err(()), + } + } else if let Ok(custom_origin) = origins::Origin::try_from(id.clone()) { + match custom_origin { + origins::Origin::WhitelistedCaller => Ok(1), + origins::Origin::ReferendumCanceller => Ok(2), + origins::Origin::ReferendumKiller => Ok(3), + origins::Origin::GeneralAdmin => Ok(4), + origins::Origin::ProtocolCommitteeAdmin => Ok(5), + origins::Origin::Treasurer => Ok(6), + origins::Origin::Spender => Ok(7), + origins::Origin::Tipper => Ok(8), + } + } else { + Err(()) + } + } +} +pallet_referenda::impl_tracksinfo_get!(TracksInfo, Balance, BlockNumber); From 556b34e0222ec02bdc7a044f48307f716cc6705c Mon Sep 17 00:00:00 2001 From: Valery Gantchev Date: Wed, 29 May 2024 21:15:55 +0200 Subject: [PATCH 08/18] hook up OpenGov pallets --- runtime/basilisk/src/governance/mod.rs | 69 ++- runtime/basilisk/src/lib.rs | 10 + runtime/basilisk/src/weights/mod.rs | 3 + .../src/weights/pallet_conviction_voting.rs | 172 ++++++ .../basilisk/src/weights/pallet_referenda.rs | 520 ++++++++++++++++++ .../basilisk/src/weights/pallet_whitelist.rs | 108 ++++ 6 files changed, 879 insertions(+), 3 deletions(-) create mode 100644 runtime/basilisk/src/weights/pallet_conviction_voting.rs create mode 100644 runtime/basilisk/src/weights/pallet_referenda.rs create mode 100644 runtime/basilisk/src/weights/pallet_whitelist.rs diff --git a/runtime/basilisk/src/governance/mod.rs b/runtime/basilisk/src/governance/mod.rs index 4e5c571740..6c94637a0f 100644 --- a/runtime/basilisk/src/governance/mod.rs +++ b/runtime/basilisk/src/governance/mod.rs @@ -16,25 +16,90 @@ // limitations under the License. use super::*; +use crate::governance::tracks::TracksInfo; use crate::old::{MajorityCouncilOrRoot, SuperMajorityCouncilOrRoot}; +use crate::origins::{Spender, ReferendumCanceller, ReferendumKiller, WhitelistedCaller}; use frame_support::{ parameter_types, sp_runtime::Permill, traits::{ + EitherOf, fungible, tokens::{Pay, PaymentStatus, Preservation, UnityAssetBalanceConversion}, NeverEnsureOrigin, }, PalletId, }; +use frame_system::{EnsureRoot, EnsureRootWithSuccess}; use primitives::constants::{currency::DOLLARS, time::DAYS}; use sp_runtime::{traits::IdentityLookup, DispatchError}; -mod origins; +pub mod origins; mod tracks; // Old governance configurations. pub mod old; +parameter_types! { + pub const VoteLockingPeriod: BlockNumber = 7 * DAYS; +} + +impl pallet_conviction_voting::Config for Runtime { + type WeightInfo = weights::pallet_conviction_voting::WeightInfo; + type RuntimeEvent = RuntimeEvent; + type Currency = Balances; + type VoteLockingPeriod = VoteLockingPeriod; + type MaxVotes = ConstU32<512>; + type MaxTurnout = + frame_support::traits::tokens::currency::ActiveIssuanceOf; + type Polls = Referenda; +} + + +parameter_types! { + pub const MaxBalance: Balance = Balance::max_value(); +} +pub type TreasurySpender = EitherOf, Spender>; + +impl origins::pallet_custom_origins::Config for Runtime {} + +impl pallet_whitelist::Config for Runtime { + type WeightInfo = weights::pallet_whitelist::WeightInfo; + type RuntimeCall = RuntimeCall; + type RuntimeEvent = RuntimeEvent; + // TODO WhitelistOrigin + // EitherOfDiverse<.., EnsureXcm>, + type WhitelistOrigin = EnsureRoot; + type DispatchWhitelistedOrigin = EitherOf, WhitelistedCaller>; + type Preimages = Preimage; +} + + +parameter_types! { + pub const AlarmInterval: BlockNumber = 1; + pub const SubmissionDeposit: Balance = 1 * DOLLARS; + pub const UndecidingTimeout: BlockNumber = 14 * DAYS; +} + +impl pallet_referenda::Config for Runtime { + type WeightInfo = weights::pallet_referenda::WeightInfo; + type RuntimeCall = RuntimeCall; + type RuntimeEvent = RuntimeEvent; + type Scheduler = Scheduler; + type Currency = Balances; + type SubmitOrigin = frame_system::EnsureSigned; + type CancelOrigin = EitherOf, ReferendumCanceller>; + type KillOrigin = EitherOf, ReferendumKiller>; + type Slash = Treasury; + type Votes = pallet_conviction_voting::VotesOf; + type Tally = pallet_conviction_voting::TallyOf; + type SubmissionDeposit = SubmissionDeposit; + type MaxQueued = ConstU32<100>; + type UndecidingTimeout = UndecidingTimeout; + type AlarmInterval = AlarmInterval; + type Tracks = TracksInfo; + type Preimages = Preimage; +} + parameter_types! { pub const ProposalBond: Permill = Permill::from_percent(3); pub const ProposalBondMinimum: Balance = 100 * DOLLARS; @@ -133,5 +198,3 @@ impl Pay for PayFromTreasuryAccount { #[cfg(feature = "runtime-benchmarks")] fn ensure_concluded(_: Self::Id) {} } - -impl origins::pallet_custom_origins::Config for Runtime {} diff --git a/runtime/basilisk/src/lib.rs b/runtime/basilisk/src/lib.rs index 8cdd6ac188..98f22152b5 100644 --- a/runtime/basilisk/src/lib.rs +++ b/runtime/basilisk/src/lib.rs @@ -43,6 +43,7 @@ pub mod xcm; pub use assets::*; pub use governance::*; +pub use governance::origins::pallet_custom_origins; pub use system::*; pub use xcm::*; @@ -190,6 +191,12 @@ construct_runtime!( Multisig: pallet_multisig = 22, StateTrieMigration: pallet_state_trie_migration = 23, + // OpenGov + ConvictionVoting: pallet_conviction_voting::{Pallet, Call, Storage, Event} = 24, + Referenda: pallet_referenda::{Pallet, Call, Storage, Event} = 25, + Origins: pallet_custom_origins::{Origin} = 26, + Whitelist: pallet_whitelist::{Pallet, Call, Storage, Event} = 27, + // Parachain and XCM - starts at index 50 ParachainSystem: cumulus_pallet_parachain_system exclude_parts { Config } = 50, ParachainInfo: staging_parachain_info = 51, @@ -574,6 +581,9 @@ mod benches { [pallet_state_trie_migration, StateTrieMigration] [pallet_collator_selection, CollatorSelection] [pallet_xcm, PalletXcmExtrinsiscsBenchmark::] + [pallet_conviction_voting, ConvictionVoting] + [pallet_referenda, Referenda] + [pallet_whitelist, Whitelist] ); } diff --git a/runtime/basilisk/src/weights/mod.rs b/runtime/basilisk/src/weights/mod.rs index 53f8c66810..a267cb75e5 100644 --- a/runtime/basilisk/src/weights/mod.rs +++ b/runtime/basilisk/src/weights/mod.rs @@ -7,6 +7,7 @@ pub mod pallet_asset_registry; pub mod pallet_balances; pub mod pallet_collator_selection; pub mod pallet_collective; +pub mod pallet_conviction_voting; pub mod pallet_currencies; pub mod pallet_democracy; pub mod pallet_duster; @@ -20,6 +21,7 @@ pub mod pallet_multisig; pub mod pallet_nft; pub mod pallet_preimage; pub mod pallet_proxy; +pub mod pallet_referenda; pub mod pallet_route_executor; pub mod pallet_scheduler; pub mod pallet_state_trie_migration; @@ -29,6 +31,7 @@ pub mod pallet_transaction_multi_payment; pub mod pallet_transaction_pause; pub mod pallet_treasury; pub mod pallet_utility; +pub mod pallet_whitelist; pub mod pallet_xcm; pub mod pallet_xyk; pub mod pallet_xyk_liquidity_mining; diff --git a/runtime/basilisk/src/weights/pallet_conviction_voting.rs b/runtime/basilisk/src/weights/pallet_conviction_voting.rs new file mode 100644 index 0000000000..82f6ea3acb --- /dev/null +++ b/runtime/basilisk/src/weights/pallet_conviction_voting.rs @@ -0,0 +1,172 @@ +// Copyright 2017-2022 Parity Technologies (UK) Ltd. +// This file is part of Polkadot. + +// Polkadot 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. + +// Polkadot 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 Polkadot. If not, see . +//! Autogenerated weights for `pallet_conviction_voting` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2023-03-07, STEPS: `2`, REPEAT: `1`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` +//! HOSTNAME: `cob`, CPU: `` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("polkadot-dev"), DB CACHE: 1024 + +// Executed Command: +// ./target/release/polkadot +// benchmark +// pallet +// --chain=polkadot-dev +// --steps=2 +// --repeat=1 +// --pallet=pallet_conviction_voting +// --extrinsic=* +// --execution=wasm +// --wasm-execution=compiled +// --header=./file_header.txt +// --output=./runtime/polkadot/src/weights/ + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{traits::Get, weights::Weight}; +use sp_std::marker::PhantomData; + +/// Weight functions for `pallet_conviction_voting`. +pub struct WeightInfo(PhantomData); +impl pallet_conviction_voting::WeightInfo for WeightInfo { + /// Storage: Referenda ReferendumInfoFor (r:1 w:1) + /// Proof: Referenda ReferendumInfoFor (max_values: None, max_size: Some(936), added: 3411, mode: MaxEncodedLen) + /// Storage: ConvictionVoting VotingFor (r:1 w:1) + /// Proof: ConvictionVoting VotingFor (max_values: None, max_size: Some(27241), added: 29716, mode: MaxEncodedLen) + /// Storage: ConvictionVoting ClassLocksFor (r:1 w:1) + /// Proof: ConvictionVoting ClassLocksFor (max_values: None, max_size: Some(311), added: 2786, mode: MaxEncodedLen) + /// Storage: Balances Locks (r:1 w:1) + /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) + /// Storage: Scheduler Agenda (r:1 w:1) + /// Proof: Scheduler Agenda (max_values: None, max_size: Some(38963), added: 41438, mode: MaxEncodedLen) + fn vote_new() -> Weight { + // Proof Size summary in bytes: + // Measured: `13612` + // Estimated: `86075` + // Minimum execution time: 174_000_000 picoseconds. + Weight::from_parts(174_000_000, 0) + .saturating_add(Weight::from_parts(0, 86075)) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(5)) + } + /// Storage: Referenda ReferendumInfoFor (r:1 w:1) + /// Proof: Referenda ReferendumInfoFor (max_values: None, max_size: Some(936), added: 3411, mode: MaxEncodedLen) + /// Storage: ConvictionVoting VotingFor (r:1 w:1) + /// Proof: ConvictionVoting VotingFor (max_values: None, max_size: Some(27241), added: 29716, mode: MaxEncodedLen) + /// Storage: ConvictionVoting ClassLocksFor (r:1 w:1) + /// Proof: ConvictionVoting ClassLocksFor (max_values: None, max_size: Some(311), added: 2786, mode: MaxEncodedLen) + /// Storage: Balances Locks (r:1 w:1) + /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) + /// Storage: Scheduler Agenda (r:2 w:2) + /// Proof: Scheduler Agenda (max_values: None, max_size: Some(38963), added: 41438, mode: MaxEncodedLen) + fn vote_existing() -> Weight { + // Proof Size summary in bytes: + // Measured: `14364` + // Estimated: `127513` + // Minimum execution time: 240_000_000 picoseconds. + Weight::from_parts(240_000_000, 0) + .saturating_add(Weight::from_parts(0, 127513)) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().writes(6)) + } + /// Storage: ConvictionVoting VotingFor (r:1 w:1) + /// Proof: ConvictionVoting VotingFor (max_values: None, max_size: Some(27241), added: 29716, mode: MaxEncodedLen) + /// Storage: Referenda ReferendumInfoFor (r:1 w:1) + /// Proof: Referenda ReferendumInfoFor (max_values: None, max_size: Some(936), added: 3411, mode: MaxEncodedLen) + /// Storage: Scheduler Agenda (r:2 w:2) + /// Proof: Scheduler Agenda (max_values: None, max_size: Some(38963), added: 41438, mode: MaxEncodedLen) + fn remove_vote() -> Weight { + // Proof Size summary in bytes: + // Measured: `14084` + // Estimated: `118973` + // Minimum execution time: 219_000_000 picoseconds. + Weight::from_parts(219_000_000, 0) + .saturating_add(Weight::from_parts(0, 118973)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(4)) + } + /// Storage: ConvictionVoting VotingFor (r:1 w:1) + /// Proof: ConvictionVoting VotingFor (max_values: None, max_size: Some(27241), added: 29716, mode: MaxEncodedLen) + /// Storage: Referenda ReferendumInfoFor (r:1 w:0) + /// Proof: Referenda ReferendumInfoFor (max_values: None, max_size: Some(936), added: 3411, mode: MaxEncodedLen) + fn remove_other_vote() -> Weight { + // Proof Size summary in bytes: + // Measured: `13139` + // Estimated: `35107` + // Minimum execution time: 109_000_000 picoseconds. + Weight::from_parts(109_000_000, 0) + .saturating_add(Weight::from_parts(0, 35107)) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(1)) + } + /// Storage: ConvictionVoting VotingFor (r:2 w:2) + /// Proof: ConvictionVoting VotingFor (max_values: None, max_size: Some(27241), added: 29716, mode: MaxEncodedLen) + /// Storage: Referenda ReferendumInfoFor (r:512 w:512) + /// Proof: Referenda ReferendumInfoFor (max_values: None, max_size: Some(936), added: 3411, mode: MaxEncodedLen) + /// Storage: Scheduler Agenda (r:2 w:2) + /// Proof: Scheduler Agenda (max_values: None, max_size: Some(38963), added: 41438, mode: MaxEncodedLen) + /// Storage: ConvictionVoting ClassLocksFor (r:1 w:1) + /// Proof: ConvictionVoting ClassLocksFor (max_values: None, max_size: Some(311), added: 2786, mode: MaxEncodedLen) + /// Storage: Balances Locks (r:1 w:1) + /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) + /// The range of component `r` is `[0, 512]`. + fn delegate(_r: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `272 + r * (427 ±0)` + // Estimated: `1900250` + // Minimum execution time: 86_000_000 picoseconds. + Weight::from_parts(27_182_000_000, 0) + .saturating_add(Weight::from_parts(0, 1900250)) + .saturating_add(T::DbWeight::get().reads(518)) + .saturating_add(T::DbWeight::get().writes(518)) + } + /// Storage: ConvictionVoting VotingFor (r:2 w:2) + /// Proof: ConvictionVoting VotingFor (max_values: None, max_size: Some(27241), added: 29716, mode: MaxEncodedLen) + /// Storage: Referenda ReferendumInfoFor (r:512 w:512) + /// Proof: Referenda ReferendumInfoFor (max_values: None, max_size: Some(936), added: 3411, mode: MaxEncodedLen) + /// Storage: Scheduler Agenda (r:2 w:2) + /// Proof: Scheduler Agenda (max_values: None, max_size: Some(38963), added: 41438, mode: MaxEncodedLen) + /// The range of component `r` is `[0, 512]`. + fn undelegate(_r: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `470 + r * (426 ±0)` + // Estimated: `1891710` + // Minimum execution time: 59_000_000 picoseconds. + Weight::from_parts(27_242_000_000, 0) + .saturating_add(Weight::from_parts(0, 1891710)) + .saturating_add(T::DbWeight::get().reads(516)) + .saturating_add(T::DbWeight::get().writes(516)) + } + /// Storage: ConvictionVoting VotingFor (r:1 w:1) + /// Proof: ConvictionVoting VotingFor (max_values: None, max_size: Some(27241), added: 29716, mode: MaxEncodedLen) + /// Storage: ConvictionVoting ClassLocksFor (r:1 w:1) + /// Proof: ConvictionVoting ClassLocksFor (max_values: None, max_size: Some(311), added: 2786, mode: MaxEncodedLen) + /// Storage: Balances Locks (r:1 w:1) + /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) + fn unlock() -> Weight { + // Proof Size summary in bytes: + // Measured: `12385` + // Estimated: `39246` + // Minimum execution time: 121_000_000 picoseconds. + Weight::from_parts(121_000_000, 0) + .saturating_add(Weight::from_parts(0, 39246)) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(3)) + } +} diff --git a/runtime/basilisk/src/weights/pallet_referenda.rs b/runtime/basilisk/src/weights/pallet_referenda.rs new file mode 100644 index 0000000000..5ebe89b694 --- /dev/null +++ b/runtime/basilisk/src/weights/pallet_referenda.rs @@ -0,0 +1,520 @@ +// Copyright 2017-2022 Parity Technologies (UK) Ltd. +// This file is part of Polkadot. + +// Polkadot 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. + +// Polkadot 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 Polkadot. If not, see . +//! Autogenerated weights for `pallet_referenda` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2023-03-07, STEPS: `1`, REPEAT: `1`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` +//! HOSTNAME: `cob`, CPU: `` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("polkadot-dev"), DB CACHE: 1024 + +// Executed Command: +// ./target/release/polkadot +// benchmark +// pallet +// --chain=polkadot-dev +// --steps=1 +// --repeat=1 +// --pallet=pallet_referenda +// --extrinsic=* +// --execution=wasm +// --wasm-execution=compiled +// --header=./file_header.txt +// --output=./runtime/polkadot/src/weights/ + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{traits::Get, weights::Weight}; +use sp_std::marker::PhantomData; + +/// Weight functions for `pallet_referenda`. +pub struct WeightInfo(PhantomData); +impl pallet_referenda::WeightInfo for WeightInfo { + /// Storage: Referenda ReferendumCount (r:1 w:1) + /// Proof: Referenda ReferendumCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Scheduler Agenda (r:1 w:1) + /// Proof: Scheduler Agenda (max_values: None, max_size: Some(38963), added: 41438, mode: MaxEncodedLen) + /// Storage: Referenda ReferendumInfoFor (r:0 w:1) + /// Proof: Referenda ReferendumInfoFor (max_values: None, max_size: Some(936), added: 3411, mode: MaxEncodedLen) + fn submit() -> Weight { + // Proof Size summary in bytes: + // Measured: `290` + // Estimated: `43917` + // Minimum execution time: 54_000_000 picoseconds. + Weight::from_parts(54_000_000, 0) + .saturating_add(Weight::from_parts(0, 43917)) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(3)) + } + /// Storage: Referenda ReferendumInfoFor (r:1 w:1) + /// Proof: Referenda ReferendumInfoFor (max_values: None, max_size: Some(936), added: 3411, mode: MaxEncodedLen) + /// Storage: Scheduler Agenda (r:2 w:2) + /// Proof: Scheduler Agenda (max_values: None, max_size: Some(38963), added: 41438, mode: MaxEncodedLen) + fn place_decision_deposit_preparing() -> Weight { + // Proof Size summary in bytes: + // Measured: `575` + // Estimated: `88267` + // Minimum execution time: 64_000_000 picoseconds. + Weight::from_parts(64_000_000, 0) + .saturating_add(Weight::from_parts(0, 88267)) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(3)) + } + /// Storage: Referenda ReferendumInfoFor (r:1 w:1) + /// Proof: Referenda ReferendumInfoFor (max_values: None, max_size: Some(936), added: 3411, mode: MaxEncodedLen) + /// Storage: Referenda DecidingCount (r:1 w:0) + /// Proof: Referenda DecidingCount (max_values: None, max_size: Some(14), added: 2489, mode: MaxEncodedLen) + /// Storage: Referenda TrackQueue (r:1 w:1) + /// Proof: Referenda TrackQueue (max_values: None, max_size: Some(2012), added: 4487, mode: MaxEncodedLen) + fn place_decision_deposit_queued() -> Weight { + // Proof Size summary in bytes: + // Measured: `3203` + // Estimated: `13357` + // Minimum execution time: 82_000_000 picoseconds. + Weight::from_parts(82_000_000, 0) + .saturating_add(Weight::from_parts(0, 13357)) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(2)) + } + /// Storage: Referenda ReferendumInfoFor (r:1 w:1) + /// Proof: Referenda ReferendumInfoFor (max_values: None, max_size: Some(936), added: 3411, mode: MaxEncodedLen) + /// Storage: Referenda DecidingCount (r:1 w:0) + /// Proof: Referenda DecidingCount (max_values: None, max_size: Some(14), added: 2489, mode: MaxEncodedLen) + /// Storage: Referenda TrackQueue (r:1 w:1) + /// Proof: Referenda TrackQueue (max_values: None, max_size: Some(2012), added: 4487, mode: MaxEncodedLen) + fn place_decision_deposit_not_queued() -> Weight { + // Proof Size summary in bytes: + // Measured: `3223` + // Estimated: `13357` + // Minimum execution time: 59_000_000 picoseconds. + Weight::from_parts(59_000_000, 0) + .saturating_add(Weight::from_parts(0, 13357)) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(2)) + } + /// Storage: Referenda ReferendumInfoFor (r:1 w:1) + /// Proof: Referenda ReferendumInfoFor (max_values: None, max_size: Some(936), added: 3411, mode: MaxEncodedLen) + /// Storage: Referenda DecidingCount (r:1 w:1) + /// Proof: Referenda DecidingCount (max_values: None, max_size: Some(14), added: 2489, mode: MaxEncodedLen) + /// Storage: Balances InactiveIssuance (r:1 w:0) + /// Proof: Balances InactiveIssuance (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) + /// Storage: Scheduler Agenda (r:2 w:2) + /// Proof: Scheduler Agenda (max_values: None, max_size: Some(38963), added: 41438, mode: MaxEncodedLen) + fn place_decision_deposit_passing() -> Weight { + // Proof Size summary in bytes: + // Measured: `575` + // Estimated: `93247` + // Minimum execution time: 142_000_000 picoseconds. + Weight::from_parts(142_000_000, 0) + .saturating_add(Weight::from_parts(0, 93247)) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(4)) + } + /// Storage: Referenda ReferendumInfoFor (r:1 w:1) + /// Proof: Referenda ReferendumInfoFor (max_values: None, max_size: Some(936), added: 3411, mode: MaxEncodedLen) + /// Storage: Referenda DecidingCount (r:1 w:1) + /// Proof: Referenda DecidingCount (max_values: None, max_size: Some(14), added: 2489, mode: MaxEncodedLen) + /// Storage: Balances InactiveIssuance (r:1 w:0) + /// Proof: Balances InactiveIssuance (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) + fn place_decision_deposit_failing() -> Weight { + // Proof Size summary in bytes: + // Measured: `482` + // Estimated: `9381` + // Minimum execution time: 54_000_000 picoseconds. + Weight::from_parts(54_000_000, 0) + .saturating_add(Weight::from_parts(0, 9381)) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(2)) + } + /// Storage: Referenda ReferendumInfoFor (r:1 w:1) + /// Proof: Referenda ReferendumInfoFor (max_values: None, max_size: Some(936), added: 3411, mode: MaxEncodedLen) + fn refund_decision_deposit() -> Weight { + // Proof Size summary in bytes: + // Measured: `415` + // Estimated: `4401` + // Minimum execution time: 35_000_000 picoseconds. + Weight::from_parts(35_000_000, 0) + .saturating_add(Weight::from_parts(0, 4401)) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } + /// Storage: Referenda ReferendumInfoFor (r:1 w:1) + /// Proof: Referenda ReferendumInfoFor (max_values: None, max_size: Some(936), added: 3411, mode: MaxEncodedLen) + fn refund_submission_deposit() -> Weight { + // Proof Size summary in bytes: + // Measured: `405` + // Estimated: `4401` + // Minimum execution time: 36_000_000 picoseconds. + Weight::from_parts(36_000_000, 0) + .saturating_add(Weight::from_parts(0, 4401)) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } + /// Storage: Referenda ReferendumInfoFor (r:1 w:1) + /// Proof: Referenda ReferendumInfoFor (max_values: None, max_size: Some(936), added: 3411, mode: MaxEncodedLen) + /// Storage: Scheduler Agenda (r:2 w:2) + /// Proof: Scheduler Agenda (max_values: None, max_size: Some(38963), added: 41438, mode: MaxEncodedLen) + fn cancel() -> Weight { + // Proof Size summary in bytes: + // Measured: `451` + // Estimated: `88267` + // Minimum execution time: 52_000_000 picoseconds. + Weight::from_parts(52_000_000, 0) + .saturating_add(Weight::from_parts(0, 88267)) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(3)) + } + /// Storage: Referenda ReferendumInfoFor (r:1 w:1) + /// Proof: Referenda ReferendumInfoFor (max_values: None, max_size: Some(936), added: 3411, mode: MaxEncodedLen) + /// Storage: Scheduler Agenda (r:2 w:2) + /// Proof: Scheduler Agenda (max_values: None, max_size: Some(38963), added: 41438, mode: MaxEncodedLen) + /// Storage: Referenda MetadataOf (r:1 w:0) + /// Proof: Referenda MetadataOf (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) + fn kill() -> Weight { + // Proof Size summary in bytes: + // Measured: `756` + // Estimated: `91784` + // Minimum execution time: 141_000_000 picoseconds. + Weight::from_parts(141_000_000, 0) + .saturating_add(Weight::from_parts(0, 91784)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(3)) + } + /// Storage: Referenda TrackQueue (r:1 w:0) + /// Proof: Referenda TrackQueue (max_values: None, max_size: Some(2012), added: 4487, mode: MaxEncodedLen) + /// Storage: Referenda DecidingCount (r:1 w:1) + /// Proof: Referenda DecidingCount (max_values: None, max_size: Some(14), added: 2489, mode: MaxEncodedLen) + fn one_fewer_deciding_queue_empty() -> Weight { + // Proof Size summary in bytes: + // Measured: `174` + // Estimated: `8956` + // Minimum execution time: 12_000_000 picoseconds. + Weight::from_parts(12_000_000, 0) + .saturating_add(Weight::from_parts(0, 8956)) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(1)) + } + /// Storage: Referenda TrackQueue (r:1 w:1) + /// Proof: Referenda TrackQueue (max_values: None, max_size: Some(2012), added: 4487, mode: MaxEncodedLen) + /// Storage: Referenda ReferendumInfoFor (r:1 w:1) + /// Proof: Referenda ReferendumInfoFor (max_values: None, max_size: Some(936), added: 3411, mode: MaxEncodedLen) + /// Storage: Balances InactiveIssuance (r:1 w:0) + /// Proof: Balances InactiveIssuance (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) + /// Storage: Scheduler Agenda (r:2 w:2) + /// Proof: Scheduler Agenda (max_values: None, max_size: Some(38963), added: 41438, mode: MaxEncodedLen) + fn one_fewer_deciding_failing() -> Weight { + // Proof Size summary in bytes: + // Measured: `3972` + // Estimated: `95245` + // Minimum execution time: 139_000_000 picoseconds. + Weight::from_parts(139_000_000, 0) + .saturating_add(Weight::from_parts(0, 95245)) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(4)) + } + /// Storage: Referenda TrackQueue (r:1 w:1) + /// Proof: Referenda TrackQueue (max_values: None, max_size: Some(2012), added: 4487, mode: MaxEncodedLen) + /// Storage: Referenda ReferendumInfoFor (r:1 w:1) + /// Proof: Referenda ReferendumInfoFor (max_values: None, max_size: Some(936), added: 3411, mode: MaxEncodedLen) + /// Storage: Balances InactiveIssuance (r:1 w:0) + /// Proof: Balances InactiveIssuance (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) + /// Storage: Scheduler Agenda (r:2 w:2) + /// Proof: Scheduler Agenda (max_values: None, max_size: Some(38963), added: 41438, mode: MaxEncodedLen) + fn one_fewer_deciding_passing() -> Weight { + // Proof Size summary in bytes: + // Measured: `3972` + // Estimated: `95245` + // Minimum execution time: 153_000_000 picoseconds. + Weight::from_parts(153_000_000, 0) + .saturating_add(Weight::from_parts(0, 95245)) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(4)) + } + /// Storage: Referenda ReferendumInfoFor (r:1 w:1) + /// Proof: Referenda ReferendumInfoFor (max_values: None, max_size: Some(936), added: 3411, mode: MaxEncodedLen) + /// Storage: Referenda TrackQueue (r:1 w:1) + /// Proof: Referenda TrackQueue (max_values: None, max_size: Some(2012), added: 4487, mode: MaxEncodedLen) + /// Storage: Scheduler Agenda (r:1 w:0) + /// Proof: Scheduler Agenda (max_values: None, max_size: Some(38963), added: 41438, mode: MaxEncodedLen) + fn nudge_referendum_requeued_insertion() -> Weight { + // Proof Size summary in bytes: + // Measured: `3990` + // Estimated: `52306` + // Minimum execution time: 82_000_000 picoseconds. + Weight::from_parts(82_000_000, 0) + .saturating_add(Weight::from_parts(0, 52306)) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(2)) + } + /// Storage: Referenda ReferendumInfoFor (r:1 w:1) + /// Proof: Referenda ReferendumInfoFor (max_values: None, max_size: Some(936), added: 3411, mode: MaxEncodedLen) + /// Storage: Referenda TrackQueue (r:1 w:1) + /// Proof: Referenda TrackQueue (max_values: None, max_size: Some(2012), added: 4487, mode: MaxEncodedLen) + /// Storage: Scheduler Agenda (r:1 w:0) + /// Proof: Scheduler Agenda (max_values: None, max_size: Some(38963), added: 41438, mode: MaxEncodedLen) + fn nudge_referendum_requeued_slide() -> Weight { + // Proof Size summary in bytes: + // Measured: `3990` + // Estimated: `52306` + // Minimum execution time: 76_000_000 picoseconds. + Weight::from_parts(76_000_000, 0) + .saturating_add(Weight::from_parts(0, 52306)) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(2)) + } + /// Storage: Referenda ReferendumInfoFor (r:1 w:1) + /// Proof: Referenda ReferendumInfoFor (max_values: None, max_size: Some(936), added: 3411, mode: MaxEncodedLen) + /// Storage: Referenda DecidingCount (r:1 w:0) + /// Proof: Referenda DecidingCount (max_values: None, max_size: Some(14), added: 2489, mode: MaxEncodedLen) + /// Storage: Referenda TrackQueue (r:1 w:1) + /// Proof: Referenda TrackQueue (max_values: None, max_size: Some(2012), added: 4487, mode: MaxEncodedLen) + /// Storage: Scheduler Agenda (r:1 w:0) + /// Proof: Scheduler Agenda (max_values: None, max_size: Some(38963), added: 41438, mode: MaxEncodedLen) + fn nudge_referendum_queued() -> Weight { + // Proof Size summary in bytes: + // Measured: `3964` + // Estimated: `55785` + // Minimum execution time: 108_000_000 picoseconds. + Weight::from_parts(108_000_000, 0) + .saturating_add(Weight::from_parts(0, 55785)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(2)) + } + /// Storage: Referenda ReferendumInfoFor (r:1 w:1) + /// Proof: Referenda ReferendumInfoFor (max_values: None, max_size: Some(936), added: 3411, mode: MaxEncodedLen) + /// Storage: Referenda DecidingCount (r:1 w:0) + /// Proof: Referenda DecidingCount (max_values: None, max_size: Some(14), added: 2489, mode: MaxEncodedLen) + /// Storage: Referenda TrackQueue (r:1 w:1) + /// Proof: Referenda TrackQueue (max_values: None, max_size: Some(2012), added: 4487, mode: MaxEncodedLen) + /// Storage: Scheduler Agenda (r:1 w:0) + /// Proof: Scheduler Agenda (max_values: None, max_size: Some(38963), added: 41438, mode: MaxEncodedLen) + fn nudge_referendum_not_queued() -> Weight { + // Proof Size summary in bytes: + // Measured: `3984` + // Estimated: `55785` + // Minimum execution time: 85_000_000 picoseconds. + Weight::from_parts(85_000_000, 0) + .saturating_add(Weight::from_parts(0, 55785)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(2)) + } + /// Storage: Referenda ReferendumInfoFor (r:1 w:1) + /// Proof: Referenda ReferendumInfoFor (max_values: None, max_size: Some(936), added: 3411, mode: MaxEncodedLen) + /// Storage: Scheduler Agenda (r:1 w:1) + /// Proof: Scheduler Agenda (max_values: None, max_size: Some(38963), added: 41438, mode: MaxEncodedLen) + fn nudge_referendum_no_deposit() -> Weight { + // Proof Size summary in bytes: + // Measured: `403` + // Estimated: `46829` + // Minimum execution time: 37_000_000 picoseconds. + Weight::from_parts(37_000_000, 0) + .saturating_add(Weight::from_parts(0, 46829)) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(2)) + } + /// Storage: Referenda ReferendumInfoFor (r:1 w:1) + /// Proof: Referenda ReferendumInfoFor (max_values: None, max_size: Some(936), added: 3411, mode: MaxEncodedLen) + /// Storage: Scheduler Agenda (r:1 w:1) + /// Proof: Scheduler Agenda (max_values: None, max_size: Some(38963), added: 41438, mode: MaxEncodedLen) + fn nudge_referendum_preparing() -> Weight { + // Proof Size summary in bytes: + // Measured: `451` + // Estimated: `46829` + // Minimum execution time: 33_000_000 picoseconds. + Weight::from_parts(33_000_000, 0) + .saturating_add(Weight::from_parts(0, 46829)) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(2)) + } + /// Storage: Referenda ReferendumInfoFor (r:1 w:1) + /// Proof: Referenda ReferendumInfoFor (max_values: None, max_size: Some(936), added: 3411, mode: MaxEncodedLen) + fn nudge_referendum_timed_out() -> Weight { + // Proof Size summary in bytes: + // Measured: `310` + // Estimated: `4401` + // Minimum execution time: 22_000_000 picoseconds. + Weight::from_parts(22_000_000, 0) + .saturating_add(Weight::from_parts(0, 4401)) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } + /// Storage: Referenda ReferendumInfoFor (r:1 w:1) + /// Proof: Referenda ReferendumInfoFor (max_values: None, max_size: Some(936), added: 3411, mode: MaxEncodedLen) + /// Storage: Referenda DecidingCount (r:1 w:1) + /// Proof: Referenda DecidingCount (max_values: None, max_size: Some(14), added: 2489, mode: MaxEncodedLen) + /// Storage: Balances InactiveIssuance (r:1 w:0) + /// Proof: Balances InactiveIssuance (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) + /// Storage: Scheduler Agenda (r:1 w:1) + /// Proof: Scheduler Agenda (max_values: None, max_size: Some(38963), added: 41438, mode: MaxEncodedLen) + fn nudge_referendum_begin_deciding_failing() -> Weight { + // Proof Size summary in bytes: + // Measured: `451` + // Estimated: `51809` + // Minimum execution time: 46_000_000 picoseconds. + Weight::from_parts(46_000_000, 0) + .saturating_add(Weight::from_parts(0, 51809)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(3)) + } + /// Storage: Referenda ReferendumInfoFor (r:1 w:1) + /// Proof: Referenda ReferendumInfoFor (max_values: None, max_size: Some(936), added: 3411, mode: MaxEncodedLen) + /// Storage: Referenda DecidingCount (r:1 w:1) + /// Proof: Referenda DecidingCount (max_values: None, max_size: Some(14), added: 2489, mode: MaxEncodedLen) + /// Storage: Balances InactiveIssuance (r:1 w:0) + /// Proof: Balances InactiveIssuance (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) + /// Storage: Scheduler Agenda (r:1 w:1) + /// Proof: Scheduler Agenda (max_values: None, max_size: Some(38963), added: 41438, mode: MaxEncodedLen) + fn nudge_referendum_begin_deciding_passing() -> Weight { + // Proof Size summary in bytes: + // Measured: `451` + // Estimated: `51809` + // Minimum execution time: 49_000_000 picoseconds. + Weight::from_parts(49_000_000, 0) + .saturating_add(Weight::from_parts(0, 51809)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(3)) + } + /// Storage: Referenda ReferendumInfoFor (r:1 w:1) + /// Proof: Referenda ReferendumInfoFor (max_values: None, max_size: Some(936), added: 3411, mode: MaxEncodedLen) + /// Storage: Balances InactiveIssuance (r:1 w:0) + /// Proof: Balances InactiveIssuance (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) + /// Storage: Scheduler Agenda (r:1 w:1) + /// Proof: Scheduler Agenda (max_values: None, max_size: Some(38963), added: 41438, mode: MaxEncodedLen) + fn nudge_referendum_begin_confirming() -> Weight { + // Proof Size summary in bytes: + // Measured: `504` + // Estimated: `48330` + // Minimum execution time: 39_000_000 picoseconds. + Weight::from_parts(39_000_000, 0) + .saturating_add(Weight::from_parts(0, 48330)) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(2)) + } + /// Storage: Referenda ReferendumInfoFor (r:1 w:1) + /// Proof: Referenda ReferendumInfoFor (max_values: None, max_size: Some(936), added: 3411, mode: MaxEncodedLen) + /// Storage: Balances InactiveIssuance (r:1 w:0) + /// Proof: Balances InactiveIssuance (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) + /// Storage: Scheduler Agenda (r:1 w:1) + /// Proof: Scheduler Agenda (max_values: None, max_size: Some(38963), added: 41438, mode: MaxEncodedLen) + fn nudge_referendum_end_confirming() -> Weight { + // Proof Size summary in bytes: + // Measured: `487` + // Estimated: `48330` + // Minimum execution time: 41_000_000 picoseconds. + Weight::from_parts(41_000_000, 0) + .saturating_add(Weight::from_parts(0, 48330)) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(2)) + } + /// Storage: Referenda ReferendumInfoFor (r:1 w:1) + /// Proof: Referenda ReferendumInfoFor (max_values: None, max_size: Some(936), added: 3411, mode: MaxEncodedLen) + /// Storage: Balances InactiveIssuance (r:1 w:0) + /// Proof: Balances InactiveIssuance (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) + /// Storage: Scheduler Agenda (r:1 w:1) + /// Proof: Scheduler Agenda (max_values: None, max_size: Some(38963), added: 41438, mode: MaxEncodedLen) + fn nudge_referendum_continue_not_confirming() -> Weight { + // Proof Size summary in bytes: + // Measured: `504` + // Estimated: `48330` + // Minimum execution time: 34_000_000 picoseconds. + Weight::from_parts(34_000_000, 0) + .saturating_add(Weight::from_parts(0, 48330)) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(2)) + } + /// Storage: Referenda ReferendumInfoFor (r:1 w:1) + /// Proof: Referenda ReferendumInfoFor (max_values: None, max_size: Some(936), added: 3411, mode: MaxEncodedLen) + /// Storage: Balances InactiveIssuance (r:1 w:0) + /// Proof: Balances InactiveIssuance (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) + /// Storage: Scheduler Agenda (r:1 w:1) + /// Proof: Scheduler Agenda (max_values: None, max_size: Some(38963), added: 41438, mode: MaxEncodedLen) + fn nudge_referendum_continue_confirming() -> Weight { + // Proof Size summary in bytes: + // Measured: `508` + // Estimated: `48330` + // Minimum execution time: 32_000_000 picoseconds. + Weight::from_parts(32_000_000, 0) + .saturating_add(Weight::from_parts(0, 48330)) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(2)) + } + /// Storage: Referenda ReferendumInfoFor (r:1 w:1) + /// Proof: Referenda ReferendumInfoFor (max_values: None, max_size: Some(936), added: 3411, mode: MaxEncodedLen) + /// Storage: Balances InactiveIssuance (r:1 w:0) + /// Proof: Balances InactiveIssuance (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) + /// Storage: Scheduler Agenda (r:2 w:2) + /// Proof: Scheduler Agenda (max_values: None, max_size: Some(38963), added: 41438, mode: MaxEncodedLen) + /// Storage: Scheduler Lookup (r:1 w:1) + /// Proof: Scheduler Lookup (max_values: None, max_size: Some(48), added: 2523, mode: MaxEncodedLen) + fn nudge_referendum_approved() -> Weight { + // Proof Size summary in bytes: + // Measured: `508` + // Estimated: `93281` + // Minimum execution time: 73_000_000 picoseconds. + Weight::from_parts(73_000_000, 0) + .saturating_add(Weight::from_parts(0, 93281)) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(4)) + } + /// Storage: Referenda ReferendumInfoFor (r:1 w:1) + /// Proof: Referenda ReferendumInfoFor (max_values: None, max_size: Some(936), added: 3411, mode: MaxEncodedLen) + /// Storage: Balances InactiveIssuance (r:1 w:0) + /// Proof: Balances InactiveIssuance (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) + /// Storage: Scheduler Agenda (r:1 w:1) + /// Proof: Scheduler Agenda (max_values: None, max_size: Some(38963), added: 41438, mode: MaxEncodedLen) + fn nudge_referendum_rejected() -> Weight { + // Proof Size summary in bytes: + // Measured: `504` + // Estimated: `48330` + // Minimum execution time: 40_000_000 picoseconds. + Weight::from_parts(40_000_000, 0) + .saturating_add(Weight::from_parts(0, 48330)) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(2)) + } + /// Storage: Referenda ReferendumInfoFor (r:1 w:0) + /// Proof: Referenda ReferendumInfoFor (max_values: None, max_size: Some(936), added: 3411, mode: MaxEncodedLen) + /// Storage: Preimage StatusFor (r:1 w:0) + /// Proof: Preimage StatusFor (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen) + /// Storage: Referenda MetadataOf (r:0 w:1) + /// Proof: Referenda MetadataOf (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) + fn set_some_metadata() -> Weight { + // Proof Size summary in bytes: + // Measured: `454` + // Estimated: `7957` + // Minimum execution time: 25_000_000 picoseconds. + Weight::from_parts(25_000_000, 0) + .saturating_add(Weight::from_parts(0, 7957)) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(1)) + } + /// Storage: Referenda ReferendumInfoFor (r:1 w:0) + /// Proof: Referenda ReferendumInfoFor (max_values: None, max_size: Some(936), added: 3411, mode: MaxEncodedLen) + /// Storage: Referenda MetadataOf (r:1 w:1) + /// Proof: Referenda MetadataOf (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) + fn clear_metadata() -> Weight { + // Proof Size summary in bytes: + // Measured: `387` + // Estimated: `7918` + // Minimum execution time: 22_000_000 picoseconds. + Weight::from_parts(22_000_000, 0) + .saturating_add(Weight::from_parts(0, 7918)) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(1)) + } +} diff --git a/runtime/basilisk/src/weights/pallet_whitelist.rs b/runtime/basilisk/src/weights/pallet_whitelist.rs new file mode 100644 index 0000000000..552d0df189 --- /dev/null +++ b/runtime/basilisk/src/weights/pallet_whitelist.rs @@ -0,0 +1,108 @@ +// Copyright 2017-2022 Parity Technologies (UK) Ltd. +// This file is part of Polkadot. + +// Polkadot 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. + +// Polkadot 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 Polkadot. If not, see . +//! Autogenerated weights for `pallet_whitelist` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2023-03-07, STEPS: `2`, REPEAT: `1`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` +//! HOSTNAME: `cob`, CPU: `` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("polkadot-dev"), DB CACHE: 1024 + +// Executed Command: +// ./target/release/polkadot +// benchmark +// pallet +// --chain=polkadot-dev +// --steps=2 +// --repeat=1 +// --pallet=pallet_whitelist +// --extrinsic=* +// --execution=wasm +// --wasm-execution=compiled +// --header=./file_header.txt +// --output=./runtime/polkadot/src/weights/ + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{traits::Get, weights::Weight}; +use sp_std::marker::PhantomData; + +/// Weight functions for `pallet_whitelist`. +pub struct WeightInfo(PhantomData); +impl pallet_whitelist::WeightInfo for WeightInfo { + /// Storage: Whitelist WhitelistedCall (r:1 w:1) + /// Proof: Whitelist WhitelistedCall (max_values: None, max_size: Some(40), added: 2515, mode: MaxEncodedLen) + /// Storage: Preimage StatusFor (r:1 w:1) + /// Proof: Preimage StatusFor (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen) + fn whitelist_call() -> Weight { + // Proof Size summary in bytes: + // Measured: `118` + // Estimated: `7061` + // Minimum execution time: 33_000_000 picoseconds. + Weight::from_parts(33_000_000, 0) + .saturating_add(Weight::from_parts(0, 7061)) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(2)) + } + /// Storage: Whitelist WhitelistedCall (r:1 w:1) + /// Proof: Whitelist WhitelistedCall (max_values: None, max_size: Some(40), added: 2515, mode: MaxEncodedLen) + /// Storage: Preimage StatusFor (r:1 w:1) + /// Proof: Preimage StatusFor (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen) + fn remove_whitelisted_call() -> Weight { + // Proof Size summary in bytes: + // Measured: `247` + // Estimated: `7061` + // Minimum execution time: 24_000_000 picoseconds. + Weight::from_parts(24_000_000, 0) + .saturating_add(Weight::from_parts(0, 7061)) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(2)) + } + /// Storage: Whitelist WhitelistedCall (r:1 w:1) + /// Proof: Whitelist WhitelistedCall (max_values: None, max_size: Some(40), added: 2515, mode: MaxEncodedLen) + /// Storage: Preimage PreimageFor (r:1 w:1) + /// Proof: Preimage PreimageFor (max_values: None, max_size: Some(4194344), added: 4196819, mode: Measured) + /// Storage: Preimage StatusFor (r:1 w:1) + /// Proof: Preimage StatusFor (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen) + /// The range of component `n` is `[1, 4194294]`. + fn dispatch_whitelisted_call(_n: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `311 + n * (1 ±0)` + // Estimated: `4205175` + // Minimum execution time: 43_000_000 picoseconds. + Weight::from_parts(4_138_000_000, 0) + .saturating_add(Weight::from_parts(0, 4205175)) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(3)) + } + /// Storage: Whitelist WhitelistedCall (r:1 w:1) + /// Proof: Whitelist WhitelistedCall (max_values: None, max_size: Some(40), added: 2515, mode: MaxEncodedLen) + /// Storage: Preimage StatusFor (r:1 w:1) + /// Proof: Preimage StatusFor (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen) + /// The range of component `n` is `[1, 10000]`. + fn dispatch_whitelisted_call_with_preimage(_n: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `247` + // Estimated: `7061` + // Minimum execution time: 32_000_000 picoseconds. + Weight::from_parts(45_000_000, 0) + .saturating_add(Weight::from_parts(0, 7061)) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(2)) + } +} From e53146e30ee66993f07f3678f1376dee6490e03d Mon Sep 17 00:00:00 2001 From: Valery Gantchev Date: Wed, 29 May 2024 22:03:12 +0200 Subject: [PATCH 09/18] replace origins --- runtime/basilisk/src/assets.rs | 20 ++++++++------------ runtime/basilisk/src/governance/mod.rs | 17 +++++------------ runtime/basilisk/src/governance/origins.rs | 6 +++--- runtime/basilisk/src/governance/tracks.rs | 4 ++-- runtime/basilisk/src/system.rs | 21 ++++++++------------- runtime/basilisk/src/xcm.rs | 19 +++++++------------ 6 files changed, 33 insertions(+), 54 deletions(-) diff --git a/runtime/basilisk/src/assets.rs b/runtime/basilisk/src/assets.rs index b106162410..3ba956c6f2 100644 --- a/runtime/basilisk/src/assets.rs +++ b/runtime/basilisk/src/assets.rs @@ -20,6 +20,7 @@ use crate::governance::old::{ MajorityTechCommitteeOrRoot, SuperMajorityCouncilOrRoot, SuperMajorityTechCommitteeOrRoot, UnanimousTechCommitteeOrRoot, }; +use crate::governance::origins::GeneralAdmin; use crate::system::NativeAssetId; use hydradx_traits::{ @@ -41,12 +42,12 @@ use frame_support::{ parameter_types, sp_runtime::{app_crypto::sp_core::crypto::UncheckedFrom, traits::Zero}, traits::{ - AsEnsureOriginWithArg, Contains, Currency, Defensive, EnsureOrigin, Get, Imbalance, LockIdentifier, + AsEnsureOriginWithArg, Contains, Currency, Defensive, EitherOf, EnsureOrigin, Get, Imbalance, LockIdentifier, NeverEnsureOrigin, OnUnbalanced, }, BoundedVec, PalletId, }; -use frame_system::RawOrigin; +use frame_system::{EnsureRoot, RawOrigin}; use orml_tokens::CurrencyAdapter; use orml_traits::currency::MutationHooks; @@ -148,8 +149,7 @@ parameter_types! { } impl pallet_asset_registry::Config for Runtime { type RuntimeEvent = RuntimeEvent; - // TODO origin - type RegistryOrigin = SuperMajorityTechCommitteeOrRoot; + type RegistryOrigin = EitherOf, GeneralAdmin>; type AssetId = AssetId; type Balance = Balance; type AssetNativeLocation = AssetLocation; @@ -172,8 +172,7 @@ impl pallet_duster::Config for Runtime { type MinCurrencyDeposits = AssetRegistry; type Reward = DustingReward; type NativeCurrencyId = NativeAssetId; - // TODO origin - type BlacklistUpdateOrigin = MajorityTechCommitteeOrRoot; + type BlacklistUpdateOrigin = EitherOf, GeneralAdmin>; type WeightInfo = weights::pallet_duster::BasiliskWeight; } @@ -264,8 +263,7 @@ impl pallet_lbp::Config for Runtime { type RuntimeEvent = RuntimeEvent; type MultiCurrency = Currencies; type LockedBalance = MultiCurrencyLockedBalance; - // TODO origin - type CreatePoolOrigin = SuperMajorityTechCommitteeOrRoot; + type CreatePoolOrigin = EitherOf, GeneralAdmin>; type LBPWeightFunction = pallet_lbp::LBPWeightFunction; type AssetPairAccountId = AssetPairAccountId; type WeightInfo = weights::pallet_lbp::BasiliskWeight; @@ -355,8 +353,7 @@ impl pallet_uniques::Config for Runtime { type CollectionId = CollectionId; type ItemId = ItemId; type Currency = KusamaCurrency; - // TODO origin - type ForceOrigin = SuperMajorityCouncilOrRoot; + type ForceOrigin = EnsureRoot; // Standard collection creation is disallowed type CreateOrigin = AsEnsureOriginWithArg>; type Locker = (); @@ -382,8 +379,7 @@ impl pallet_xyk_liquidity_mining::Config for Runtime { type RuntimeEvent = RuntimeEvent; type MultiCurrency = Currencies; type AMM = XYK; - // TODO origin - type CreateOrigin = UnanimousTechCommitteeOrRoot; + type CreateOrigin = EitherOf, GeneralAdmin>; type PalletId = LMPalletId; type NftCollectionId = LiquidityMiningNftCollectionId; type NFTHandler = NFT; diff --git a/runtime/basilisk/src/governance/mod.rs b/runtime/basilisk/src/governance/mod.rs index 6c94637a0f..0be8707d36 100644 --- a/runtime/basilisk/src/governance/mod.rs +++ b/runtime/basilisk/src/governance/mod.rs @@ -17,16 +17,15 @@ use super::*; use crate::governance::tracks::TracksInfo; -use crate::old::{MajorityCouncilOrRoot, SuperMajorityCouncilOrRoot}; -use crate::origins::{Spender, ReferendumCanceller, ReferendumKiller, WhitelistedCaller}; +use crate::origins::{Spender, ReferendumCanceller, ReferendumKiller, Treasurer, WhitelistedCaller}; use frame_support::{ parameter_types, sp_runtime::Permill, traits::{ EitherOf, + EitherOfDiverse, fungible, tokens::{Pay, PaymentStatus, Preservation, UnityAssetBalanceConversion}, - NeverEnsureOrigin, }, PalletId, }; @@ -66,14 +65,11 @@ impl pallet_whitelist::Config for Runtime { type WeightInfo = weights::pallet_whitelist::WeightInfo; type RuntimeCall = RuntimeCall; type RuntimeEvent = RuntimeEvent; - // TODO WhitelistOrigin - // EitherOfDiverse<.., EnsureXcm>, type WhitelistOrigin = EnsureRoot; type DispatchWhitelistedOrigin = EitherOf, WhitelistedCaller>; type Preimages = Preimage; } - parameter_types! { pub const AlarmInterval: BlockNumber = 1; pub const SubmissionDeposit: Balance = 1 * DOLLARS; @@ -114,10 +110,8 @@ parameter_types! { impl pallet_treasury::Config for Runtime { type Currency = Balances; - // TODO origin - type ApproveOrigin = SuperMajorityCouncilOrRoot; - // TODO origin - type RejectOrigin = MajorityCouncilOrRoot; + type ApproveOrigin = EitherOfDiverse, Treasurer>; + type RejectOrigin = EitherOfDiverse, Treasurer>; type RuntimeEvent = RuntimeEvent; type OnSlash = Treasury; type ProposalBond = ProposalBond; @@ -130,9 +124,8 @@ impl pallet_treasury::Config for Runtime { type WeightInfo = weights::pallet_treasury::BasiliskWeight; type SpendFunds = (); type MaxApprovals = MaxApprovals; - // TODO origin TreasurySpender #[cfg(not(feature = "runtime-benchmarks"))] - type SpendOrigin = NeverEnsureOrigin; // Disabled, no spending + type SpendOrigin = TreasurySpender; #[cfg(feature = "runtime-benchmarks")] type SpendOrigin = frame_system::EnsureWithSuccess, AccountId, crate::benches::BenchmarkMaxBalance>; diff --git a/runtime/basilisk/src/governance/origins.rs b/runtime/basilisk/src/governance/origins.rs index 30e0f3b6e5..db584f1481 100644 --- a/runtime/basilisk/src/governance/origins.rs +++ b/runtime/basilisk/src/governance/origins.rs @@ -43,8 +43,8 @@ pub mod pallet_custom_origins { /// Origin for managing general stuff such as the registrar and permissioned HRMP /// channel operations. GeneralAdmin, - /// TODO descr - ProtocolCommitteeAdmin, + /// Origin for managing the composition of the fellowship. + TechFellowshipAdmin, /// Origin for spending very high amounts of BSX from the treasury as well as generally /// administering it. Treasurer, @@ -86,7 +86,7 @@ pub mod pallet_custom_origins { } decl_unit_ensures!( GeneralAdmin, - ProtocolCommitteeAdmin, + TechFellowshipAdmin, WhitelistedCaller, ReferendumCanceller, ReferendumKiller, diff --git a/runtime/basilisk/src/governance/tracks.rs b/runtime/basilisk/src/governance/tracks.rs index 6623849118..2b7f5c3da6 100644 --- a/runtime/basilisk/src/governance/tracks.rs +++ b/runtime/basilisk/src/governance/tracks.rs @@ -106,7 +106,7 @@ const TRACKS_DATA: [(u16, pallet_referenda::TrackInfo); 9] ( 5, pallet_referenda::TrackInfo { - name: "protocol_committee_admin", + name: "tech_fellowship_admin", max_deciding: 10, decision_deposit: 50_000_000 * UNITS, prepare_period: 60 * MINUTES, @@ -180,7 +180,7 @@ impl pallet_referenda::TracksInfo for TracksInfo { origins::Origin::ReferendumCanceller => Ok(2), origins::Origin::ReferendumKiller => Ok(3), origins::Origin::GeneralAdmin => Ok(4), - origins::Origin::ProtocolCommitteeAdmin => Ok(5), + origins::Origin::TechFellowshipAdmin => Ok(5), origins::Origin::Treasurer => Ok(6), origins::Origin::Spender => Ok(7), origins::Origin::Tipper => Ok(8), diff --git a/runtime/basilisk/src/system.rs b/runtime/basilisk/src/system.rs index b7cf7518ac..73fa1f36eb 100644 --- a/runtime/basilisk/src/system.rs +++ b/runtime/basilisk/src/system.rs @@ -18,6 +18,7 @@ use super::*; use crate::governance::{ old::{MajorityCouncilOrRoot, MajorityTechCommitteeOrRoot, SuperMajorityTechCommitteeOrRoot}, + origins::GeneralAdmin, TreasuryAccount, }; @@ -29,15 +30,15 @@ use primitives::constants::{ time::{HOURS, SLOT_DURATION}, }; + use codec::{Decode, Encode, MaxEncodedLen}; -use frame_support::pallet_prelude::Get; -use frame_support::traits::Defensive; use frame_support::{ dispatch::DispatchClass, + pallet_prelude::Get, parameter_types, sp_runtime::{traits::IdentityLookup, FixedPointNumber, Perbill, Perquintill, RuntimeDebug}, traits::{ - fungible::HoldConsideration, ConstBool, Contains, EqualPrivilegeOnly, InstanceFilter, LinearStoragePrice, + fungible::HoldConsideration, ConstBool, Contains, Defensive, EitherOf, EqualPrivilegeOnly, InstanceFilter, LinearStoragePrice, SortedMembers, }, weights::{ @@ -271,8 +272,7 @@ impl InspectEvmAccounts for EvmAccounts { impl pallet_transaction_multi_payment::Config for Runtime { type RuntimeEvent = RuntimeEvent; - // TODO origin - type AcceptedCurrencyOrigin = MajorityTechCommitteeOrRoot; + type AcceptedCurrencyOrigin = EitherOf, GeneralAdmin>; type Currencies = Currencies; type RouteProvider = Router; type OraclePriceProvider = adapter::OraclePriceProvider; @@ -447,8 +447,7 @@ parameter_types! { impl pallet_collator_selection::Config for Runtime { type RuntimeEvent = RuntimeEvent; type Currency = Balances; - // TODO origin - type UpdateOrigin = MajorityTechCommitteeOrRoot; + type UpdateOrigin = EitherOf, GeneralAdmin>; type PotId = PotId; type MaxCandidates = MaxCandidates; type MaxInvulnerables = MaxInvulnerables; @@ -494,7 +493,6 @@ impl pallet_relaychain_info::Config for Runtime { impl pallet_transaction_pause::Config for Runtime { type RuntimeEvent = RuntimeEvent; - // TODO origin type UpdateOrigin = MajorityTechCommitteeOrRoot; type WeightInfo = weights::pallet_transaction_pause::BasiliskWeight; } @@ -544,10 +542,8 @@ impl pallet_identity::Config for Runtime { type IdentityInformation = pallet_identity::legacy::IdentityInfo; type MaxRegistrars = MaxRegistrars; type Slashed = Treasury; - // TODO origin - type ForceOrigin = MajorityCouncilOrRoot; - // TODO origin - type RegistrarOrigin = MajorityCouncilOrRoot; + type ForceOrigin = EitherOf, GeneralAdmin>; + type RegistrarOrigin = EitherOf, GeneralAdmin>; type OffchainSignature = Signature; type SigningPublicKey = ::Signer; type UsernameAuthorityOrigin = EnsureRoot; @@ -591,7 +587,6 @@ parameter_types! { use frame_system::EnsureSigned; impl pallet_state_trie_migration::Config for Runtime { - // TODO origin type ControlOrigin = SuperMajorityTechCommitteeOrRoot; #[cfg(feature = "runtime-benchmarks")] type SignedFilter = EnsureSigned; diff --git a/runtime/basilisk/src/xcm.rs b/runtime/basilisk/src/xcm.rs index 6f0a6e6a0c..9029d60cb1 100644 --- a/runtime/basilisk/src/xcm.rs +++ b/runtime/basilisk/src/xcm.rs @@ -16,10 +16,8 @@ // limitations under the License. use super::*; -use crate::governance::{ - old::{MajorityTechCommitteeOrRoot, SuperMajorityCouncilOrRoot, SuperMajorityTechCommitteeOrRoot}, - TreasuryAccount, -}; +use crate::governance::TreasuryAccount; +use crate::origins::GeneralAdmin; use crate::system::WeightToFee; use codec::{Decode, Encode, MaxEncodedLen}; @@ -28,9 +26,10 @@ use frame_support::traits::TransformOrigin; use frame_support::{ parameter_types, sp_runtime::traits::Convert, - traits::{Contains, Everything, Get, Nothing}, + traits::{Contains, EitherOf, Everything, Get, Nothing}, PalletId, }; +use frame_system::EnsureRoot; use hydradx_adapters::xcm_exchange::XcmAssetExchanger; use hydradx_adapters::xcm_execute_filter::AllowTransferAndSwap; use hydradx_adapters::{MultiCurrencyTrader, ToFeeReceiver}; @@ -205,15 +204,13 @@ impl cumulus_pallet_xcmp_queue::Config for Runtime { type RuntimeEvent = RuntimeEvent; type ChannelInfo = ParachainSystem; type VersionWrapper = PolkadotXcm; - // TODO origin - type ControllerOrigin = MajorityTechCommitteeOrRoot; + type ControllerOrigin = EitherOf, GeneralAdmin>; type ControllerOriginConverter = XcmOriginToCallOrigin; type PriceForSiblingDelivery = polkadot_runtime_common::xcm_sender::NoPriceForMessageDelivery; type WeightInfo = weights::cumulus_pallet_xcmp_queue::BasiliskWeight; type XcmpQueue = TransformOrigin; type MaxInboundSuspended = MaxInboundSuspended; } - parameter_type_with_key! { pub ParachainMinFee: |_location: Location| -> Option { None @@ -245,8 +242,7 @@ impl orml_unknown_tokens::Config for Runtime { impl orml_xcm::Config for Runtime { type RuntimeEvent = RuntimeEvent; - // TODO origin - type SovereignOrigin = SuperMajorityCouncilOrRoot; + type SovereignOrigin = EnsureRoot; } parameter_types! { @@ -280,8 +276,7 @@ impl pallet_xcm::Config for Runtime { type SovereignAccountOf = (); type MaxLockers = ConstU32<8>; type WeightInfo = weights::pallet_xcm::BasiliskWeight; - // TODO origin - type AdminOrigin = SuperMajorityTechCommitteeOrRoot; + type AdminOrigin = EnsureRoot; type MaxRemoteLockConsumers = ConstU32<0>; type RemoteLockConsumerIdentifier = (); } From 83559db174657daa005877a9fa178059aaebe2dc Mon Sep 17 00:00:00 2001 From: Valery Gantchev Date: Wed, 29 May 2024 22:10:00 +0200 Subject: [PATCH 10/18] cleanup origins --- runtime/basilisk/src/assets.rs | 8 ++------ runtime/basilisk/src/governance/old.rs | 2 -- runtime/basilisk/src/system.rs | 4 ++-- 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/runtime/basilisk/src/assets.rs b/runtime/basilisk/src/assets.rs index 3ba956c6f2..92c11e0ba4 100644 --- a/runtime/basilisk/src/assets.rs +++ b/runtime/basilisk/src/assets.rs @@ -16,10 +16,6 @@ // limitations under the License. use super::*; -use crate::governance::old::{ - MajorityTechCommitteeOrRoot, SuperMajorityCouncilOrRoot, SuperMajorityTechCommitteeOrRoot, - UnanimousTechCommitteeOrRoot, -}; use crate::governance::origins::GeneralAdmin; use crate::system::NativeAssetId; @@ -645,7 +641,7 @@ impl pallet_route_executor::Config for Runtime { type DefaultRoutePoolType = DefaultRoutePoolType; type WeightInfo = RouterWeightInfo; type InspectRegistry = AssetRegistry; - type TechnicalOrigin = SuperMajorityTechCommitteeOrRoot; + type TechnicalOrigin = EitherOf, GeneralAdmin>; } parameter_types! { @@ -660,7 +656,7 @@ parameter_types! { impl pallet_ema_oracle::Config for Runtime { type RuntimeEvent = RuntimeEvent; type WeightInfo = weights::pallet_ema_oracle::BasiliskWeight; - type AuthorityOrigin = SuperMajorityTechCommitteeOrRoot; + type AuthorityOrigin = EitherOf, GeneralAdmin>; type BlockNumberProvider = RelayChainBlockNumberProvider; type SupportedPeriods = SupportedPeriods; type OracleWhitelist = Everything; diff --git a/runtime/basilisk/src/governance/old.rs b/runtime/basilisk/src/governance/old.rs index 677d86fc5d..c65742e015 100644 --- a/runtime/basilisk/src/governance/old.rs +++ b/runtime/basilisk/src/governance/old.rs @@ -37,8 +37,6 @@ pub type UnanimousCouncilOrRoot = EitherOfDiverse, EnsureRoot>; pub type SuperMajorityCouncilOrRoot = EitherOfDiverse, EnsureRoot>; -pub type SuperMajorityTechCommitteeOrRoot = - EitherOfDiverse, EnsureRoot>; pub type UnanimousTechCommitteeOrRoot = EitherOfDiverse, EnsureRoot>; pub type MajorityTechCommitteeOrRoot = diff --git a/runtime/basilisk/src/system.rs b/runtime/basilisk/src/system.rs index 73fa1f36eb..144c638684 100644 --- a/runtime/basilisk/src/system.rs +++ b/runtime/basilisk/src/system.rs @@ -17,7 +17,7 @@ use super::*; use crate::governance::{ - old::{MajorityCouncilOrRoot, MajorityTechCommitteeOrRoot, SuperMajorityTechCommitteeOrRoot}, + old::MajorityTechCommitteeOrRoot, origins::GeneralAdmin, TreasuryAccount, }; @@ -587,7 +587,7 @@ parameter_types! { use frame_system::EnsureSigned; impl pallet_state_trie_migration::Config for Runtime { - type ControlOrigin = SuperMajorityTechCommitteeOrRoot; + type ControlOrigin = EnsureRoot; #[cfg(feature = "runtime-benchmarks")] type SignedFilter = EnsureSigned; #[cfg(not(feature = "runtime-benchmarks"))] From c2d3c1b108f9518296cd28182252f75004a30021 Mon Sep 17 00:00:00 2001 From: Valery Gantchev Date: Wed, 29 May 2024 22:11:30 +0200 Subject: [PATCH 11/18] fmt clippy --- runtime/basilisk/src/governance/mod.rs | 11 ++++------- runtime/basilisk/src/governance/origins.rs | 8 ++++---- runtime/basilisk/src/governance/tracks.rs | 5 ++++- runtime/basilisk/src/lib.rs | 2 +- runtime/basilisk/src/system.rs | 11 +++-------- 5 files changed, 16 insertions(+), 21 deletions(-) diff --git a/runtime/basilisk/src/governance/mod.rs b/runtime/basilisk/src/governance/mod.rs index 0be8707d36..986f8a6d7e 100644 --- a/runtime/basilisk/src/governance/mod.rs +++ b/runtime/basilisk/src/governance/mod.rs @@ -17,15 +17,14 @@ use super::*; use crate::governance::tracks::TracksInfo; -use crate::origins::{Spender, ReferendumCanceller, ReferendumKiller, Treasurer, WhitelistedCaller}; +use crate::origins::{ReferendumCanceller, ReferendumKiller, Spender, Treasurer, WhitelistedCaller}; use frame_support::{ parameter_types, sp_runtime::Permill, traits::{ - EitherOf, - EitherOfDiverse, fungible, tokens::{Pay, PaymentStatus, Preservation, UnityAssetBalanceConversion}, + EitherOf, EitherOfDiverse, }, PalletId, }; @@ -48,12 +47,10 @@ impl pallet_conviction_voting::Config for Runtime { type Currency = Balances; type VoteLockingPeriod = VoteLockingPeriod; type MaxVotes = ConstU32<512>; - type MaxTurnout = - frame_support::traits::tokens::currency::ActiveIssuanceOf; + type MaxTurnout = frame_support::traits::tokens::currency::ActiveIssuanceOf; type Polls = Referenda; } - parameter_types! { pub const MaxBalance: Balance = Balance::max_value(); } @@ -72,7 +69,7 @@ impl pallet_whitelist::Config for Runtime { parameter_types! { pub const AlarmInterval: BlockNumber = 1; - pub const SubmissionDeposit: Balance = 1 * DOLLARS; + pub const SubmissionDeposit: Balance = DOLLARS; pub const UndecidingTimeout: BlockNumber = 14 * DAYS; } diff --git a/runtime/basilisk/src/governance/origins.rs b/runtime/basilisk/src/governance/origins.rs index db584f1481..f3bb1f9896 100644 --- a/runtime/basilisk/src/governance/origins.rs +++ b/runtime/basilisk/src/governance/origins.rs @@ -22,8 +22,8 @@ pub use pallet_custom_origins::*; #[frame_support::pallet] pub mod pallet_custom_origins { use crate::Balance; - use primitives::constants::currency::GRAND; use frame_support::pallet_prelude::*; + use primitives::constants::currency::GRAND; #[pallet::config] pub trait Config: frame_system::Config {} @@ -43,9 +43,9 @@ pub mod pallet_custom_origins { /// Origin for managing general stuff such as the registrar and permissioned HRMP /// channel operations. GeneralAdmin, - /// Origin for managing the composition of the fellowship. - TechFellowshipAdmin, - /// Origin for spending very high amounts of BSX from the treasury as well as generally + /// Origin for managing the composition of the fellowship. + TechFellowshipAdmin, + /// Origin for spending very high amounts of BSX from the treasury as well as generally /// administering it. Treasurer, /// Origin able to spend up to roughly $5,000 from the treasury at once. diff --git a/runtime/basilisk/src/governance/tracks.rs b/runtime/basilisk/src/governance/tracks.rs index 2b7f5c3da6..66e3585d12 100644 --- a/runtime/basilisk/src/governance/tracks.rs +++ b/runtime/basilisk/src/governance/tracks.rs @@ -18,7 +18,10 @@ //! Track configurations for governance. use super::*; -use primitives::constants::{currency::UNITS, time::{HOURS, MINUTES}}; +use primitives::constants::{ + currency::UNITS, + time::{HOURS, MINUTES}, +}; const fn percent(x: i32) -> sp_arithmetic::FixedI64 { sp_arithmetic::FixedI64::from_rational(x as u128, 100) } diff --git a/runtime/basilisk/src/lib.rs b/runtime/basilisk/src/lib.rs index 98f22152b5..452703d7e8 100644 --- a/runtime/basilisk/src/lib.rs +++ b/runtime/basilisk/src/lib.rs @@ -42,8 +42,8 @@ mod system; pub mod xcm; pub use assets::*; -pub use governance::*; pub use governance::origins::pallet_custom_origins; +pub use governance::*; pub use system::*; pub use xcm::*; diff --git a/runtime/basilisk/src/system.rs b/runtime/basilisk/src/system.rs index 144c638684..a94dea1a89 100644 --- a/runtime/basilisk/src/system.rs +++ b/runtime/basilisk/src/system.rs @@ -16,11 +16,7 @@ // limitations under the License. use super::*; -use crate::governance::{ - old::MajorityTechCommitteeOrRoot, - origins::GeneralAdmin, - TreasuryAccount, -}; +use crate::governance::{old::MajorityTechCommitteeOrRoot, origins::GeneralAdmin, TreasuryAccount}; use pallet_transaction_multi_payment::{DepositAll, TransferFees}; use pallet_transaction_payment::{Multiplier, TargetedFeeAdjustment}; @@ -30,7 +26,6 @@ use primitives::constants::{ time::{HOURS, SLOT_DURATION}, }; - use codec::{Decode, Encode, MaxEncodedLen}; use frame_support::{ dispatch::DispatchClass, @@ -38,8 +33,8 @@ use frame_support::{ parameter_types, sp_runtime::{traits::IdentityLookup, FixedPointNumber, Perbill, Perquintill, RuntimeDebug}, traits::{ - fungible::HoldConsideration, ConstBool, Contains, Defensive, EitherOf, EqualPrivilegeOnly, InstanceFilter, LinearStoragePrice, - SortedMembers, + fungible::HoldConsideration, ConstBool, Contains, Defensive, EitherOf, EqualPrivilegeOnly, InstanceFilter, + LinearStoragePrice, SortedMembers, }, weights::{ constants::{BlockExecutionWeight, RocksDbWeight, WEIGHT_REF_TIME_PER_MICROS}, From 05c6cf016992ddd601a7a2b8b30701e16d981b69 Mon Sep 17 00:00:00 2001 From: Valery Gantchev Date: Fri, 7 Jun 2024 14:23:31 +0200 Subject: [PATCH 12/18] versions and clippy --- Cargo.lock | 16 ++++++++-------- primitives/Cargo.toml | 2 +- runtime/basilisk/Cargo.toml | 2 +- runtime/basilisk/src/lib.rs | 2 +- runtime/basilisk/src/system.rs | 2 +- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index cc683a7bc2..ae8f28351a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -903,7 +903,7 @@ dependencies = [ "polkadot-parachain-primitives", "polkadot-primitives", "polkadot-service", - "primitives 6.6.1", + "primitives 6.6.2", "sc-basic-authorship", "sc-block-builder", "sc-chain-spec", @@ -953,7 +953,7 @@ dependencies = [ [[package]] name = "basilisk-runtime" -version = "115.0.0" +version = "116.0.0" dependencies = [ "cumulus-pallet-aura-ext", "cumulus-pallet-parachain-system", @@ -1030,7 +1030,7 @@ dependencies = [ "polkadot-parachain-primitives", "polkadot-runtime-common", "primitive-types", - "primitives 6.6.1", + "primitives 6.6.2", "scale-info", "serde", "smallvec", @@ -7408,7 +7408,7 @@ dependencies = [ "pallet-uniques", "parity-scale-codec", "pretty_assertions", - "primitives 6.6.1", + "primitives 6.6.2", "scale-info", "serde", "sp-arithmetic", @@ -8295,7 +8295,7 @@ dependencies = [ "pallet-xyk", "parity-scale-codec", "pretty_assertions", - "primitives 6.6.1", + "primitives 6.6.2", "scale-info", "sp-arithmetic", "sp-core", @@ -8323,7 +8323,7 @@ dependencies = [ "pallet-xyk", "pallet-xyk-liquidity-mining", "parity-scale-codec", - "primitives 6.6.1", + "primitives 6.6.2", "scale-info", "sp-arithmetic", "sp-core", @@ -9941,7 +9941,7 @@ dependencies = [ [[package]] name = "primitives" -version = "6.6.1" +version = "6.6.2" dependencies = [ "frame-support", "parity-scale-codec", @@ -10788,7 +10788,7 @@ dependencies = [ "polkadot-runtime-parachains", "polkadot-service", "pretty_assertions", - "primitives 6.6.1", + "primitives 6.6.2", "rococo-runtime", "sc-consensus-grandpa", "sp-api", diff --git a/primitives/Cargo.toml b/primitives/Cargo.toml index 4e83f9f0a8..dbd83291a5 100644 --- a/primitives/Cargo.toml +++ b/primitives/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "primitives" -version = "6.6.1" +version = "6.6.2" authors = ["GalacticCouncil"] edition = "2021" repository = "https://github.com/galacticcouncil/Basilisk-node" diff --git a/runtime/basilisk/Cargo.toml b/runtime/basilisk/Cargo.toml index a9bf03367b..1722388d92 100644 --- a/runtime/basilisk/Cargo.toml +++ b/runtime/basilisk/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "basilisk-runtime" -version = "115.0.0" +version = "116.0.0" authors = ["GalacticCouncil"] edition = "2021" homepage = "https://github.com/galacticcouncil/Basilisk-node" diff --git a/runtime/basilisk/src/lib.rs b/runtime/basilisk/src/lib.rs index b9532929b0..03e4c48c35 100644 --- a/runtime/basilisk/src/lib.rs +++ b/runtime/basilisk/src/lib.rs @@ -102,7 +102,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("basilisk"), impl_name: create_runtime_str!("basilisk"), authoring_version: 1, - spec_version: 115, + spec_version: 116, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 1, diff --git a/runtime/basilisk/src/system.rs b/runtime/basilisk/src/system.rs index a94dea1a89..beab5cafd7 100644 --- a/runtime/basilisk/src/system.rs +++ b/runtime/basilisk/src/system.rs @@ -42,7 +42,7 @@ use frame_support::{ }, PalletId, }; -use frame_system::{EnsureRoot, EnsureSignedBy}; +use frame_system::EnsureRoot; use hydradx_adapters::RelayChainBlockNumberProvider; use hydradx_traits::evm::InspectEvmAccounts; use primitives::constants::time::DAYS; From af3abc7498228a6fb073d0a4a8e7a9d9704ccc33 Mon Sep 17 00:00:00 2001 From: Valery Gantchev Date: Fri, 7 Jun 2024 14:30:21 +0200 Subject: [PATCH 13/18] fix build --- runtime/basilisk/src/system.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/runtime/basilisk/src/system.rs b/runtime/basilisk/src/system.rs index beab5cafd7..0916f61c24 100644 --- a/runtime/basilisk/src/system.rs +++ b/runtime/basilisk/src/system.rs @@ -581,6 +581,9 @@ parameter_types! { #[cfg(feature = "runtime-benchmarks")] use frame_system::EnsureSigned; +#[cfg(not(feature = "runtime-benchmarks"))] +use frame_system::EnsureSignedBy; + impl pallet_state_trie_migration::Config for Runtime { type ControlOrigin = EnsureRoot; #[cfg(feature = "runtime-benchmarks")] From fc2d2b789b3b705076d62783a26993a13a890dc0 Mon Sep 17 00:00:00 2001 From: Valery Gantchev Date: Sat, 8 Jun 2024 13:28:42 +0200 Subject: [PATCH 14/18] keep TechComm --- runtime/basilisk/src/governance/mod.rs | 22 ++++++++++++++++++++++ runtime/basilisk/src/governance/old.rs | 21 +-------------------- 2 files changed, 23 insertions(+), 20 deletions(-) diff --git a/runtime/basilisk/src/governance/mod.rs b/runtime/basilisk/src/governance/mod.rs index 986f8a6d7e..84679091d4 100644 --- a/runtime/basilisk/src/governance/mod.rs +++ b/runtime/basilisk/src/governance/mod.rs @@ -30,6 +30,7 @@ use frame_support::{ }; use frame_system::{EnsureRoot, EnsureRootWithSuccess}; use primitives::constants::{currency::DOLLARS, time::DAYS}; +use sp_arithmetic::Perbill; use sp_runtime::{traits::IdentityLookup, DispatchError}; pub mod origins; @@ -37,6 +38,27 @@ mod tracks; // Old governance configurations. pub mod old; +parameter_types! { + pub const TechnicalMotionDuration: BlockNumber = 5 * DAYS; + pub const TechnicalMaxProposals: u32 = 20; + pub const TechnicalMaxMembers: u32 = 10; + pub MaxProposalWeight: Weight = Perbill::from_percent(50) * BlockWeights::get().max_block; +} + +type TechnicalCollective = pallet_collective::Instance2; +impl pallet_collective::Config for Runtime { + type RuntimeOrigin = RuntimeOrigin; + type Proposal = RuntimeCall; + type RuntimeEvent = RuntimeEvent; + type MotionDuration = TechnicalMotionDuration; + type MaxProposals = TechnicalMaxProposals; + type MaxMembers = TechnicalMaxMembers; + type DefaultVote = pallet_collective::PrimeDefaultVote; + type WeightInfo = weights::pallet_collective::BasiliskWeight; + type MaxProposalWeight = MaxProposalWeight; + type SetMembersOrigin = EnsureRoot; +} + parameter_types! { pub const VoteLockingPeriod: BlockNumber = 7 * DAYS; } diff --git a/runtime/basilisk/src/governance/old.rs b/runtime/basilisk/src/governance/old.rs index c65742e015..3a8646862c 100644 --- a/runtime/basilisk/src/governance/old.rs +++ b/runtime/basilisk/src/governance/old.rs @@ -15,6 +15,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +use crate::governance::TechnicalCollective; use crate::*; use primitives::constants::{ @@ -157,26 +158,6 @@ impl pallet_collective::Config for Runtime { type SetMembersOrigin = EnsureRoot; } -parameter_types! { - pub const TechnicalMotionDuration: BlockNumber = 5 * DAYS; - pub const TechnicalMaxProposals: u32 = 20; - pub const TechnicalMaxMembers: u32 = 10; -} - -type TechnicalCollective = pallet_collective::Instance2; -impl pallet_collective::Config for Runtime { - type RuntimeOrigin = RuntimeOrigin; - type Proposal = RuntimeCall; - type RuntimeEvent = RuntimeEvent; - type MotionDuration = TechnicalMotionDuration; - type MaxProposals = TechnicalMaxProposals; - type MaxMembers = TechnicalMaxMembers; - type DefaultVote = pallet_collective::PrimeDefaultVote; - type WeightInfo = weights::pallet_collective::BasiliskWeight; - type MaxProposalWeight = MaxProposalWeight; - type SetMembersOrigin = EnsureRoot; -} - parameter_types! { pub const DataDepositPerByte: Balance = CENTS; pub const TipCountdown: BlockNumber = 24 * HOURS; From 0080d5c80fa26dd68271f472ffd6e35ca2060d87 Mon Sep 17 00:00:00 2001 From: Valery Gantchev Date: Sat, 8 Jun 2024 13:52:40 +0200 Subject: [PATCH 15/18] Remove TechFellowshipAdmin --- runtime/basilisk/src/governance/origins.rs | 3 --- runtime/basilisk/src/governance/tracks.rs | 27 +++++----------------- 2 files changed, 6 insertions(+), 24 deletions(-) diff --git a/runtime/basilisk/src/governance/origins.rs b/runtime/basilisk/src/governance/origins.rs index f3bb1f9896..a8987a6577 100644 --- a/runtime/basilisk/src/governance/origins.rs +++ b/runtime/basilisk/src/governance/origins.rs @@ -43,8 +43,6 @@ pub mod pallet_custom_origins { /// Origin for managing general stuff such as the registrar and permissioned HRMP /// channel operations. GeneralAdmin, - /// Origin for managing the composition of the fellowship. - TechFellowshipAdmin, /// Origin for spending very high amounts of BSX from the treasury as well as generally /// administering it. Treasurer, @@ -86,7 +84,6 @@ pub mod pallet_custom_origins { } decl_unit_ensures!( GeneralAdmin, - TechFellowshipAdmin, WhitelistedCaller, ReferendumCanceller, ReferendumKiller, diff --git a/runtime/basilisk/src/governance/tracks.rs b/runtime/basilisk/src/governance/tracks.rs index 66e3585d12..f557818f6d 100644 --- a/runtime/basilisk/src/governance/tracks.rs +++ b/runtime/basilisk/src/governance/tracks.rs @@ -35,7 +35,7 @@ const SUP_RECIP: Curve = Curve::make_reciprocal(5, 7, percent(1), percent(0), pe const SUP_FAST_RECIP: Curve = Curve::make_reciprocal(3, 7, percent(1), percent(0), percent(50)); const SUP_WHITELISTED_CALLER: Curve = Curve::make_reciprocal(1, 28, percent(20), percent(1), percent(50)); -const TRACKS_DATA: [(u16, pallet_referenda::TrackInfo); 9] = [ +const TRACKS_DATA: [(u16, pallet_referenda::TrackInfo); 8] = [ ( 0, pallet_referenda::TrackInfo { @@ -108,20 +108,6 @@ const TRACKS_DATA: [(u16, pallet_referenda::TrackInfo); 9] ), ( 5, - pallet_referenda::TrackInfo { - name: "tech_fellowship_admin", - max_deciding: 10, - decision_deposit: 50_000_000 * UNITS, - prepare_period: 60 * MINUTES, - decision_period: 7 * DAYS, - confirm_period: 24 * HOURS, - min_enactment_period: 24 * HOURS, - min_approval: APP_LINEAR_FLAT, - min_support: SUP_RECIP, - }, - ), - ( - 6, pallet_referenda::TrackInfo { name: "treasurer", max_deciding: 10, @@ -135,7 +121,7 @@ const TRACKS_DATA: [(u16, pallet_referenda::TrackInfo); 9] }, ), ( - 7, + 6, pallet_referenda::TrackInfo { name: "spender", max_deciding: 10, @@ -149,7 +135,7 @@ const TRACKS_DATA: [(u16, pallet_referenda::TrackInfo); 9] }, ), ( - 8, + 7, pallet_referenda::TrackInfo { name: "tipper", max_deciding: 10, @@ -183,10 +169,9 @@ impl pallet_referenda::TracksInfo for TracksInfo { origins::Origin::ReferendumCanceller => Ok(2), origins::Origin::ReferendumKiller => Ok(3), origins::Origin::GeneralAdmin => Ok(4), - origins::Origin::TechFellowshipAdmin => Ok(5), - origins::Origin::Treasurer => Ok(6), - origins::Origin::Spender => Ok(7), - origins::Origin::Tipper => Ok(8), + origins::Origin::Treasurer => Ok(5), + origins::Origin::Spender => Ok(6), + origins::Origin::Tipper => Ok(7), } } else { Err(()) From 187c6fabf82d08a226ae73a12e1ba0c298c38937 Mon Sep 17 00:00:00 2001 From: mrq Date: Tue, 11 Jun 2024 11:53:22 +0200 Subject: [PATCH 16/18] grand is based on dollars --- primitives/src/constants.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/primitives/src/constants.rs b/primitives/src/constants.rs index dc4455a598..06e3c59f50 100644 --- a/primitives/src/constants.rs +++ b/primitives/src/constants.rs @@ -21,7 +21,7 @@ pub mod currency { pub const FORTUNE: Balance = u128::MAX; pub const UNITS: Balance = 1_000_000_000_000; pub const DOLLARS: Balance = UNITS * 100; // 100 UNITS ~= 1 $ - pub const GRAND: Balance = UNITS * 1_000; + pub const GRAND: Balance = DOLLARS * 1_000; pub const CENTS: Balance = DOLLARS / 100; // 1 UNITS ~= 1 cent pub const MILLICENTS: Balance = CENTS / 1_000; pub const NATIVE_EXISTENTIAL_DEPOSIT: Balance = CENTS; From f8ce3652450763d6d7014f992f2132c095756a90 Mon Sep 17 00:00:00 2001 From: Valery Gantchev Date: Tue, 11 Jun 2024 12:16:35 +0200 Subject: [PATCH 17/18] update spending tracks thresholds --- primitives/src/constants.rs | 1 - runtime/basilisk/src/governance/origins.rs | 9 +++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/primitives/src/constants.rs b/primitives/src/constants.rs index 06e3c59f50..2334bb795e 100644 --- a/primitives/src/constants.rs +++ b/primitives/src/constants.rs @@ -21,7 +21,6 @@ pub mod currency { pub const FORTUNE: Balance = u128::MAX; pub const UNITS: Balance = 1_000_000_000_000; pub const DOLLARS: Balance = UNITS * 100; // 100 UNITS ~= 1 $ - pub const GRAND: Balance = DOLLARS * 1_000; pub const CENTS: Balance = DOLLARS / 100; // 1 UNITS ~= 1 cent pub const MILLICENTS: Balance = CENTS / 1_000; pub const NATIVE_EXISTENTIAL_DEPOSIT: Balance = CENTS; diff --git a/runtime/basilisk/src/governance/origins.rs b/runtime/basilisk/src/governance/origins.rs index a8987a6577..d16197e47e 100644 --- a/runtime/basilisk/src/governance/origins.rs +++ b/runtime/basilisk/src/governance/origins.rs @@ -23,7 +23,7 @@ pub use pallet_custom_origins::*; pub mod pallet_custom_origins { use crate::Balance; use frame_support::pallet_prelude::*; - use primitives::constants::currency::GRAND; + use primitives::constants::currency::UNITS; #[pallet::config] pub trait Config: frame_system::Config {} @@ -125,9 +125,10 @@ pub mod pallet_custom_origins { decl_ensure! { pub type Spender: EnsureOrigin { - Tipper = 2_500 * GRAND, - Spender = 25_000 * GRAND, - Treasurer = 2_500_000 * GRAND, + // Tipper = 2_500 * 1000 * GRAND, + Tipper = 5_000_000 * GRAND, // ~= $500 + Spender = 50_000_000 * GRAND, // ~= $5,000 + Treasurer = 5_000_000_000 * GRAND, // ~= $500,000 } } } From 4337f0ff11b811ed5a3476ac865de66a46d11ec9 Mon Sep 17 00:00:00 2001 From: Valery Gantchev Date: Tue, 11 Jun 2024 12:17:27 +0200 Subject: [PATCH 18/18] update spending tracks thresholds --- runtime/basilisk/src/governance/origins.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/runtime/basilisk/src/governance/origins.rs b/runtime/basilisk/src/governance/origins.rs index d16197e47e..46ad4ec553 100644 --- a/runtime/basilisk/src/governance/origins.rs +++ b/runtime/basilisk/src/governance/origins.rs @@ -125,10 +125,9 @@ pub mod pallet_custom_origins { decl_ensure! { pub type Spender: EnsureOrigin { - // Tipper = 2_500 * 1000 * GRAND, - Tipper = 5_000_000 * GRAND, // ~= $500 - Spender = 50_000_000 * GRAND, // ~= $5,000 - Treasurer = 5_000_000_000 * GRAND, // ~= $500,000 + Tipper = 5_000_000 * UNITS, // ~= $500 + Spender = 50_000_000 * UNITS, // ~= $5,000 + Treasurer = 5_000_000_000 * UNITS, // ~= $500,000 } } }