From 79538b1074a1e8177cac5867509f507aaadee3f7 Mon Sep 17 00:00:00 2001 From: yooml Date: Wed, 10 Jan 2024 20:30:12 +0800 Subject: [PATCH] Fix gov (#1142) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: 🎸 add Spender * feat: 🎸 add origin ValidatorElection to channel_commission * refactor: 💡 rename origin LiquidStaking * fix: 🐛 rename track --- runtime/bifrost-kusama/src/governance/mod.rs | 4 ++-- .../bifrost-kusama/src/governance/origins.rs | 11 ++++++++-- .../bifrost-kusama/src/governance/tracks.rs | 2 +- runtime/bifrost-kusama/src/lib.rs | 18 +++++++---------- .../bifrost-polkadot/src/governance/mod.rs | 4 ++-- .../src/governance/origins.rs | 11 ++++++++-- .../bifrost-polkadot/src/governance/tracks.rs | 2 +- runtime/bifrost-polkadot/src/lib.rs | 20 ++++++++----------- 8 files changed, 39 insertions(+), 33 deletions(-) diff --git a/runtime/bifrost-kusama/src/governance/mod.rs b/runtime/bifrost-kusama/src/governance/mod.rs index 26cd81894..5b5a487a6 100644 --- a/runtime/bifrost-kusama/src/governance/mod.rs +++ b/runtime/bifrost-kusama/src/governance/mod.rs @@ -24,8 +24,8 @@ pub mod fellowship; mod origins; pub use origins::{ custom_origins, CoreAdmin, Fellows, FellowshipAdmin, FellowshipExperts, FellowshipInitiates, - FellowshipMasters, ReferendumCanceller, ReferendumKiller, SALPAdmin, TechAdmin, - ValidatorElection, WhitelistedCaller, *, + FellowshipMasters, LiquidStaking, ReferendumCanceller, ReferendumKiller, SALPAdmin, TechAdmin, + WhitelistedCaller, *, }; mod tracks; pub use tracks::TracksInfo; diff --git a/runtime/bifrost-kusama/src/governance/origins.rs b/runtime/bifrost-kusama/src/governance/origins.rs index 56cee987a..5abc45aa5 100644 --- a/runtime/bifrost-kusama/src/governance/origins.rs +++ b/runtime/bifrost-kusama/src/governance/origins.rs @@ -21,6 +21,7 @@ pub use custom_origins::*; #[frame_support::pallet] pub mod custom_origins { + use crate::{Balance, BNCS}; use frame_support::pallet_prelude::*; use strum_macros::EnumString; @@ -46,7 +47,7 @@ pub mod custom_origins { ReferendumKiller, // Fellows, /// Origin for managing validater node of SLP protocol. - ValidatorElection, + LiquidStaking, /// Origin able to execute SALP protocol. #[strum(serialize = "salp_admin")] SALPAdmin, @@ -123,7 +124,7 @@ pub mod custom_origins { Fellows: u16 = 3, FellowshipExperts: u16 = 5, FellowshipMasters: u16 = 7, - ValidatorElection, + LiquidStaking, SALPAdmin, TechAdmin, CoreAdmin, @@ -176,4 +177,10 @@ pub mod custom_origins { Fellowship9Dan = 9, } } + + decl_ensure! { + pub type Spender: EnsureOrigin { + TreasurySpend = 100_000 * BNCS, + } + } } diff --git a/runtime/bifrost-kusama/src/governance/tracks.rs b/runtime/bifrost-kusama/src/governance/tracks.rs index a613eba64..fac57bfc7 100644 --- a/runtime/bifrost-kusama/src/governance/tracks.rs +++ b/runtime/bifrost-kusama/src/governance/tracks.rs @@ -121,7 +121,7 @@ const TRACKS_DATA: [(u16, pallet_referenda::TrackInfo); 8] ( 10, pallet_referenda::TrackInfo { - name: "validator_election", + name: "liquid_staking", max_deciding: 10, decision_deposit: 2_500 * BNCS, prepare_period: 2 * HOURS, diff --git a/runtime/bifrost-kusama/src/lib.rs b/runtime/bifrost-kusama/src/lib.rs index 457f9836d..cb0644d5b 100644 --- a/runtime/bifrost-kusama/src/lib.rs +++ b/runtime/bifrost-kusama/src/lib.rs @@ -89,9 +89,9 @@ use cumulus_pallet_parachain_system::{RelayNumberStrictlyIncreases, RelaychainDa use frame_support::{ dispatch::DispatchClass, sp_runtime::traits::{Convert, ConvertInto}, - traits::{Currency, EitherOfDiverse, Get, Imbalance, LockIdentifier, OnUnbalanced}, + traits::{Currency, EitherOf, EitherOfDiverse, Get, Imbalance, LockIdentifier, OnUnbalanced}, }; -use frame_system::{EnsureRoot, EnsureSigned, EnsureWithSuccess}; +use frame_system::{EnsureRoot, EnsureRootWithSuccess, EnsureSigned}; use hex_literal::hex; use orml_oracle::{DataFeeder, DataProvider, DataProviderExtended}; use parity_scale_codec::{Decode, Encode, MaxEncodedLen}; @@ -107,7 +107,7 @@ use zenlink_stable_amm::traits::{StableAmmApi, StablePoolLpCurrencyIdGenerate, V pub mod governance; use governance::{ custom_origins, fellowship::FellowshipReferendaInstance, CoreAdmin, CoreAdminOrCouncil, - SALPAdmin, TechAdmin, TechAdminOrCouncil, TreasurySpend, ValidatorElection, + LiquidStaking, SALPAdmin, Spender, TechAdmin, TechAdminOrCouncil, }; // xcm config @@ -831,7 +831,7 @@ parameter_types! { pub const CuratorDepositMultiplier: Permill = Permill::from_percent(50); pub CuratorDepositMin: Balance = 1 * BNCS; pub CuratorDepositMax: Balance = 100 * BNCS; - pub const MaxBalance: Balance = 100_000 * BNCS; + pub const MaxBalance: Balance = 800_000 * BNCS; } type ApproveOrigin = EitherOfDiverse< @@ -841,11 +841,7 @@ type ApproveOrigin = EitherOfDiverse< impl pallet_treasury::Config for Runtime { type ApproveOrigin = ApproveOrigin; - type SpendOrigin = EnsureWithSuccess< - EitherOfDiverse, TreasurySpend>, - AccountId, - MaxBalance, - >; + type SpendOrigin = EitherOf, Spender>; type Burn = Burn; type BurnDestination = (); type Currency = Balances; @@ -1382,7 +1378,7 @@ impl bifrost_slp::Config for Runtime { type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; type MultiCurrency = Currencies; - type ControlOrigin = EitherOfDiverse; + type ControlOrigin = EitherOfDiverse; type WeightInfo = weights::bifrost_slp::BifrostWeight; type VtokenMinting = VtokenMinting; type BifrostSlpx = Slpx; @@ -1798,7 +1794,7 @@ parameter_types! { impl bifrost_channel_commission::Config for Runtime { type RuntimeEvent = RuntimeEvent; type MultiCurrency = Currencies; - type ControlOrigin = CoreAdminOrCouncil; + type ControlOrigin = EitherOfDiverse; type CommissionPalletId = CommissionPalletId; type BifrostCommissionReceiver = BifrostCommissionReceiver; type WeightInfo = weights::bifrost_channel_commission::BifrostWeight; diff --git a/runtime/bifrost-polkadot/src/governance/mod.rs b/runtime/bifrost-polkadot/src/governance/mod.rs index 26cd81894..5b5a487a6 100644 --- a/runtime/bifrost-polkadot/src/governance/mod.rs +++ b/runtime/bifrost-polkadot/src/governance/mod.rs @@ -24,8 +24,8 @@ pub mod fellowship; mod origins; pub use origins::{ custom_origins, CoreAdmin, Fellows, FellowshipAdmin, FellowshipExperts, FellowshipInitiates, - FellowshipMasters, ReferendumCanceller, ReferendumKiller, SALPAdmin, TechAdmin, - ValidatorElection, WhitelistedCaller, *, + FellowshipMasters, LiquidStaking, ReferendumCanceller, ReferendumKiller, SALPAdmin, TechAdmin, + WhitelistedCaller, *, }; mod tracks; pub use tracks::TracksInfo; diff --git a/runtime/bifrost-polkadot/src/governance/origins.rs b/runtime/bifrost-polkadot/src/governance/origins.rs index 81cacf371..5fffa211d 100644 --- a/runtime/bifrost-polkadot/src/governance/origins.rs +++ b/runtime/bifrost-polkadot/src/governance/origins.rs @@ -21,6 +21,7 @@ pub use custom_origins::*; #[frame_support::pallet] pub mod custom_origins { + use crate::{Balance, BNCS}; use frame_support::pallet_prelude::*; use strum_macros::EnumString; @@ -46,7 +47,7 @@ pub mod custom_origins { ReferendumKiller, // Fellows, /// Origin for managing validater node of SLP protocol. - ValidatorElection, + LiquidStaking, /// Origin able to execute SALP protocol. SALPAdmin, /// Origin commanded by any members of the Polkadot Fellowship (no Dan grade needed). @@ -122,7 +123,7 @@ pub mod custom_origins { Fellows: u16 = 3, FellowshipExperts: u16 = 5, FellowshipMasters: u16 = 7, - ValidatorElection, + LiquidStaking, SALPAdmin, TechAdmin, CoreAdmin, @@ -175,4 +176,10 @@ pub mod custom_origins { Fellowship9Dan = 9, } } + + decl_ensure! { + pub type Spender: EnsureOrigin { + TreasurySpend = 100_000 * BNCS, + } + } } diff --git a/runtime/bifrost-polkadot/src/governance/tracks.rs b/runtime/bifrost-polkadot/src/governance/tracks.rs index a613eba64..fac57bfc7 100644 --- a/runtime/bifrost-polkadot/src/governance/tracks.rs +++ b/runtime/bifrost-polkadot/src/governance/tracks.rs @@ -121,7 +121,7 @@ const TRACKS_DATA: [(u16, pallet_referenda::TrackInfo); 8] ( 10, pallet_referenda::TrackInfo { - name: "validator_election", + name: "liquid_staking", max_deciding: 10, decision_deposit: 2_500 * BNCS, prepare_period: 2 * HOURS, diff --git a/runtime/bifrost-polkadot/src/lib.rs b/runtime/bifrost-polkadot/src/lib.rs index dc8b8b343..8ba43fe96 100644 --- a/runtime/bifrost-polkadot/src/lib.rs +++ b/runtime/bifrost-polkadot/src/lib.rs @@ -89,9 +89,9 @@ use cumulus_primitives_core::ParaId as CumulusParaId; use frame_support::{ dispatch::DispatchClass, sp_runtime::traits::{Convert, ConvertInto}, - traits::{Currency, EitherOfDiverse, Get}, + traits::{Currency, EitherOf, EitherOfDiverse, Get}, }; -use frame_system::{EnsureRoot, EnsureSigned, EnsureWithSuccess}; +use frame_system::{EnsureRoot, EnsureRootWithSuccess, EnsureSigned}; use hex_literal::hex; use parity_scale_codec::{Decode, Encode, MaxEncodedLen}; // zenlink imports @@ -116,8 +116,8 @@ use xcm_executor::{ pub mod governance; use crate::xcm_config::XcmRouter; use governance::{ - custom_origins, fellowship::FellowshipReferendaInstance, CoreAdminOrCouncil, SALPAdmin, - TechAdmin, TechAdminOrCouncil, TreasurySpend, ValidatorElection, + custom_origins, fellowship::FellowshipReferendaInstance, CoreAdminOrCouncil, LiquidStaking, + SALPAdmin, Spender, TechAdmin, TechAdminOrCouncil, }; impl_opaque_keys! { @@ -791,7 +791,7 @@ parameter_types! { pub const TipReportDepositBase: Balance = 1 * DOLLARS; pub const DataDepositPerByte: Balance = 1 * CENTS; pub const MaxApprovals: u32 = 100; - pub const MaxBalance: Balance = 100_000 * BNCS; + pub const MaxBalance: Balance = 800_000 * BNCS; } type ApproveOrigin = EitherOfDiverse< @@ -801,11 +801,7 @@ type ApproveOrigin = EitherOfDiverse< impl pallet_treasury::Config for Runtime { type ApproveOrigin = ApproveOrigin; - type SpendOrigin = EnsureWithSuccess< - EitherOfDiverse, TreasurySpend>, - AccountId, - MaxBalance, - >; + type SpendOrigin = EitherOf, Spender>; type Burn = Burn; type BurnDestination = (); type Currency = Balances; @@ -1210,7 +1206,7 @@ impl bifrost_slp::Config for Runtime { type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; type MultiCurrency = Currencies; - type ControlOrigin = EitherOfDiverse; + type ControlOrigin = EitherOfDiverse; type WeightInfo = weights::bifrost_slp::BifrostWeight; type VtokenMinting = VtokenMinting; type BifrostSlpx = Slpx; @@ -1606,7 +1602,7 @@ parameter_types! { impl bifrost_channel_commission::Config for Runtime { type RuntimeEvent = RuntimeEvent; type MultiCurrency = Currencies; - type ControlOrigin = CoreAdminOrCouncil; + type ControlOrigin = EitherOfDiverse; type CommissionPalletId = CommissionPalletId; type BifrostCommissionReceiver = BifrostCommissionReceiver; type WeightInfo = weights::bifrost_channel_commission::BifrostWeight;