Skip to content

Commit

Permalink
Fix gov (bifrost-io#1142)
Browse files Browse the repository at this point in the history
* feat: 🎸 add Spender

* feat: 🎸 add origin ValidatorElection to channel_commission

* refactor: 💡 rename origin LiquidStaking

* fix: 🐛 rename track
  • Loading branch information
yooml authored Jan 10, 2024
1 parent 1defcc7 commit 79538b1
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 33 deletions.
4 changes: 2 additions & 2 deletions runtime/bifrost-kusama/src/governance/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
11 changes: 9 additions & 2 deletions runtime/bifrost-kusama/src/governance/origins.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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,
Expand Down Expand Up @@ -123,7 +124,7 @@ pub mod custom_origins {
Fellows: u16 = 3,
FellowshipExperts: u16 = 5,
FellowshipMasters: u16 = 7,
ValidatorElection,
LiquidStaking,
SALPAdmin,
TechAdmin,
CoreAdmin,
Expand Down Expand Up @@ -176,4 +177,10 @@ pub mod custom_origins {
Fellowship9Dan = 9,
}
}

decl_ensure! {
pub type Spender: EnsureOrigin<Success = Balance> {
TreasurySpend = 100_000 * BNCS,
}
}
}
2 changes: 1 addition & 1 deletion runtime/bifrost-kusama/src/governance/tracks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ const TRACKS_DATA: [(u16, pallet_referenda::TrackInfo<Balance, BlockNumber>); 8]
(
10,
pallet_referenda::TrackInfo {
name: "validator_election",
name: "liquid_staking",
max_deciding: 10,
decision_deposit: 2_500 * BNCS,
prepare_period: 2 * HOURS,
Expand Down
18 changes: 7 additions & 11 deletions runtime/bifrost-kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand All @@ -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
Expand Down Expand Up @@ -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<
Expand All @@ -841,11 +841,7 @@ type ApproveOrigin = EitherOfDiverse<

impl pallet_treasury::Config for Runtime {
type ApproveOrigin = ApproveOrigin;
type SpendOrigin = EnsureWithSuccess<
EitherOfDiverse<EnsureRoot<AccountId>, TreasurySpend>,
AccountId,
MaxBalance,
>;
type SpendOrigin = EitherOf<EnsureRootWithSuccess<AccountId, MaxBalance>, Spender>;
type Burn = Burn;
type BurnDestination = ();
type Currency = Balances;
Expand Down Expand Up @@ -1382,7 +1378,7 @@ impl bifrost_slp::Config for Runtime {
type RuntimeOrigin = RuntimeOrigin;
type RuntimeCall = RuntimeCall;
type MultiCurrency = Currencies;
type ControlOrigin = EitherOfDiverse<TechAdminOrCouncil, ValidatorElection>;
type ControlOrigin = EitherOfDiverse<TechAdminOrCouncil, LiquidStaking>;
type WeightInfo = weights::bifrost_slp::BifrostWeight<Runtime>;
type VtokenMinting = VtokenMinting;
type BifrostSlpx = Slpx;
Expand Down Expand Up @@ -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<CoreAdminOrCouncil, LiquidStaking>;
type CommissionPalletId = CommissionPalletId;
type BifrostCommissionReceiver = BifrostCommissionReceiver;
type WeightInfo = weights::bifrost_channel_commission::BifrostWeight<Runtime>;
Expand Down
4 changes: 2 additions & 2 deletions runtime/bifrost-polkadot/src/governance/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
11 changes: 9 additions & 2 deletions runtime/bifrost-polkadot/src/governance/origins.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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).
Expand Down Expand Up @@ -122,7 +123,7 @@ pub mod custom_origins {
Fellows: u16 = 3,
FellowshipExperts: u16 = 5,
FellowshipMasters: u16 = 7,
ValidatorElection,
LiquidStaking,
SALPAdmin,
TechAdmin,
CoreAdmin,
Expand Down Expand Up @@ -175,4 +176,10 @@ pub mod custom_origins {
Fellowship9Dan = 9,
}
}

decl_ensure! {
pub type Spender: EnsureOrigin<Success = Balance> {
TreasurySpend = 100_000 * BNCS,
}
}
}
2 changes: 1 addition & 1 deletion runtime/bifrost-polkadot/src/governance/tracks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ const TRACKS_DATA: [(u16, pallet_referenda::TrackInfo<Balance, BlockNumber>); 8]
(
10,
pallet_referenda::TrackInfo {
name: "validator_election",
name: "liquid_staking",
max_deciding: 10,
decision_deposit: 2_500 * BNCS,
prepare_period: 2 * HOURS,
Expand Down
20 changes: 8 additions & 12 deletions runtime/bifrost-polkadot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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! {
Expand Down Expand Up @@ -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<
Expand All @@ -801,11 +801,7 @@ type ApproveOrigin = EitherOfDiverse<

impl pallet_treasury::Config for Runtime {
type ApproveOrigin = ApproveOrigin;
type SpendOrigin = EnsureWithSuccess<
EitherOfDiverse<EnsureRoot<AccountId>, TreasurySpend>,
AccountId,
MaxBalance,
>;
type SpendOrigin = EitherOf<EnsureRootWithSuccess<AccountId, MaxBalance>, Spender>;
type Burn = Burn;
type BurnDestination = ();
type Currency = Balances;
Expand Down Expand Up @@ -1210,7 +1206,7 @@ impl bifrost_slp::Config for Runtime {
type RuntimeOrigin = RuntimeOrigin;
type RuntimeCall = RuntimeCall;
type MultiCurrency = Currencies;
type ControlOrigin = EitherOfDiverse<TechAdminOrCouncil, ValidatorElection>;
type ControlOrigin = EitherOfDiverse<TechAdminOrCouncil, LiquidStaking>;
type WeightInfo = weights::bifrost_slp::BifrostWeight<Runtime>;
type VtokenMinting = VtokenMinting;
type BifrostSlpx = Slpx;
Expand Down Expand Up @@ -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<CoreAdminOrCouncil, LiquidStaking>;
type CommissionPalletId = CommissionPalletId;
type BifrostCommissionReceiver = BifrostCommissionReceiver;
type WeightInfo = weights::bifrost_channel_commission::BifrostWeight<Runtime>;
Expand Down

0 comments on commit 79538b1

Please sign in to comment.