Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/remove tips&bounty pallet #1246

Merged
merged 4 commits into from
May 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 37 additions & 47 deletions runtime/bifrost-kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ use frame_support::{
OnUnbalanced,
},
};
use frame_system::pallet_prelude::BlockNumberFor;
use frame_system::{EnsureRoot, EnsureRootWithSuccess, EnsureSigned};
use hex_literal::hex;
use orml_oracle::{DataFeeder, DataProvider, DataProviderExtended};
Expand Down Expand Up @@ -465,8 +466,6 @@ impl InstanceFilter<RuntimeCall> for ProxyType {
RuntimeCall::PhragmenElection(..) |
RuntimeCall::TechnicalMembership(..) |
RuntimeCall::Treasury(..) |
RuntimeCall::Bounties(..) |
RuntimeCall::Tips(..) |
RuntimeCall::ConvictionVoting(..) |
RuntimeCall::Referenda(..) |
RuntimeCall::FellowshipCollective(..) |
Expand All @@ -489,8 +488,7 @@ impl InstanceFilter<RuntimeCall> for ProxyType {
RuntimeCall::Council(..) | RuntimeCall::TechnicalCommittee(..) |
RuntimeCall::PhragmenElection(..) |
RuntimeCall::Treasury(..) |
RuntimeCall::Bounties(..) |
RuntimeCall::Tips(..) | RuntimeCall::Utility(..) |
RuntimeCall::Utility(..) |
// OpenGov calls
RuntimeCall::ConvictionVoting(..) |
RuntimeCall::Referenda(..) |
Expand All @@ -503,8 +501,8 @@ impl InstanceFilter<RuntimeCall> for ProxyType {
},
ProxyType::IdentityJudgement => matches!(
c,
RuntimeCall::Identity(pallet_identity::Call::provide_judgement { .. }) |
RuntimeCall::Utility(..)
RuntimeCall::Identity(pallet_identity::Call::provide_judgement { .. })
| RuntimeCall::Utility(..)
),
}
}
Expand Down Expand Up @@ -845,22 +843,13 @@ parameter_types! {
pub ProposalBondMaximum: Balance = 500 * BNCS;
pub const SpendPeriod: BlockNumber = 6 * DAYS;
pub const Burn: Permill = Permill::from_perthousand(0);
pub const TipCountdown: BlockNumber = 1 * DAYS;
pub const TipFindersFee: Percent = Percent::from_percent(20);
pub TipReportDepositBase: Balance = 1 * BNCS;
pub DataDepositPerByte: Balance = 10 * cent::<Runtime>(NativeCurrencyId::get());
pub BountyDepositBase: Balance = 1 * BNCS;
pub const BountyDepositPayoutDelay: BlockNumber = 4 * DAYS;
pub const BountyUpdatePeriod: BlockNumber = 90 * DAYS;
pub const MaximumReasonLength: u32 = 16384;
pub const PayoutSpendPeriod: BlockNumber = 30 * DAYS;
pub const BountyCuratorDeposit: Permill = Permill::from_percent(50);
pub BountyValueMinimum: Balance = 10 * BNCS;
pub const MaxApprovals: u32 = 100;

pub const CuratorDepositMultiplier: Permill = Permill::from_percent(50);
pub CuratorDepositMin: Balance = 1 * BNCS;
pub CuratorDepositMax: Balance = 100 * BNCS;
pub const MaxBalance: Balance = 800_000 * BNCS;
}

Expand Down Expand Up @@ -891,38 +880,11 @@ impl pallet_treasury::Config for Runtime {
type ProposalBondMinimum = ProposalBondMinimum;
type ProposalBondMaximum = ProposalBondMaximum;
type RejectOrigin = MoreThanHalfCouncil;
type SpendFunds = Bounties;
type SpendFunds = ();
type SpendPeriod = SpendPeriod;
type WeightInfo = pallet_treasury::weights::SubstrateWeight<Runtime>;
}

impl pallet_bounties::Config for Runtime {
type BountyDepositBase = BountyDepositBase;
type BountyDepositPayoutDelay = BountyDepositPayoutDelay;
type BountyUpdatePeriod = BountyUpdatePeriod;
type BountyValueMinimum = BountyValueMinimum;
type CuratorDepositMultiplier = CuratorDepositMultiplier;
type CuratorDepositMin = CuratorDepositMin;
type CuratorDepositMax = CuratorDepositMax;
type DataDepositPerByte = DataDepositPerByte;
type RuntimeEvent = RuntimeEvent;
type MaximumReasonLength = MaximumReasonLength;
type WeightInfo = pallet_bounties::weights::SubstrateWeight<Runtime>;
type ChildBountyManager = ();
}

impl pallet_tips::Config for Runtime {
type DataDepositPerByte = DataDepositPerByte;
type RuntimeEvent = RuntimeEvent;
type MaximumReasonLength = MaximumReasonLength;
type TipCountdown = TipCountdown;
type TipFindersFee = TipFindersFee;
type TipReportDepositBase = TipReportDepositBase;
type Tippers = PhragmenElection;
type MaxTipAmount = ();
type WeightInfo = pallet_tips::weights::SubstrateWeight<Runtime>;
}

impl pallet_transaction_payment::Config for Runtime {
type FeeMultiplierUpdate = SlowAdjustingFeeUpdate<Self>;
type LengthToFee = ConstantMultiplier<Balance, TransactionByteFee>;
Expand Down Expand Up @@ -1157,11 +1119,12 @@ impl FeeGetter<RuntimeCall> for ExtraFeeMatcher {
extra_fee_name: ExtraFeeName::StatemineTransfer,
extra_fee_currency: RelayCurrencyId::get(),
},
RuntimeCall::VtokenVoting(bifrost_vtoken_voting::Call::vote { vtoken, .. }) =>
RuntimeCall::VtokenVoting(bifrost_vtoken_voting::Call::vote { vtoken, .. }) => {
ExtraFeeInfo {
extra_fee_name: ExtraFeeName::VoteVtoken,
extra_fee_currency: vtoken.to_token().unwrap_or(vtoken),
},
}
},
RuntimeCall::VtokenVoting(bifrost_vtoken_voting::Call::remove_delegator_vote {
vtoken,
..
Expand Down Expand Up @@ -1997,8 +1960,6 @@ construct_runtime! {

// Treasury stuff
Treasury: pallet_treasury = 61,
Bounties: pallet_bounties = 62,
Tips: pallet_tips = 63,
Preimage: pallet_preimage = 64,

// Third party modules
Expand Down Expand Up @@ -2086,18 +2047,47 @@ pub type SignedPayload = generic::SignedPayload<RuntimeCall, SignedExtra>;
/// upgrades in case governance decides to do so. THE ORDER IS IMPORTANT.
pub type Migrations = migrations::Unreleased;

parameter_types! {
pub const TipsPalletName: &'static str = "Tips";
pub const BountiesPalletName: &'static str = "Bounties";
}

/// The runtime migrations per release.
pub mod migrations {
#![allow(unused_imports)]
use super::*;

/// Unreleased migrations. Add new ones here:
pub type Unreleased = (
// Unlock & unreserve funds
pallet_tips::migrations::unreserve_deposits::UnreserveDeposits<UnlockConfigForTips, ()>,
cumulus_pallet_xcmp_queue::migration::v4::MigrationToV4<Runtime>,
migration::slpx_migrates_whitelist::UpdateWhitelist,
frame_support::migrations::RemovePallet<
TipsPalletName,
<Runtime as frame_system::Config>::DbWeight,
>,
frame_support::migrations::RemovePallet<
BountiesPalletName,
<Runtime as frame_system::Config>::DbWeight,
>,
);
}

// Special Config for tips pallets, allowing us to run migrations for them without
// implementing their configs on [`Runtime`].
pub struct UnlockConfigForTips;
impl pallet_tips::migrations::unreserve_deposits::UnlockConfig<()> for UnlockConfigForTips {
type Currency = Balances;
type Hash = Hash;
type DataDepositPerByte = DataDepositPerByte;
type TipReportDepositBase = TipReportDepositBase;
type AccountId = AccountId;
type BlockNumber = BlockNumberFor<Runtime>;
type DbWeight = <Runtime as frame_system::Config>::DbWeight;
type PalletName = TipsPalletName;
}

/// Executive: handles dispatch to the various modules.
pub type Executive = frame_executive::Executive<
Runtime,
Expand Down
10 changes: 0 additions & 10 deletions runtime/bifrost-kusama/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -581,16 +581,6 @@ impl Contains<RuntimeCall> for SafeCallFilter {
pallet_identity::Call::quit_sub { .. },
) |
RuntimeCall::Vesting(..) |
RuntimeCall::Bounties(
pallet_bounties::Call::propose_bounty { .. } |
pallet_bounties::Call::approve_bounty { .. } |
pallet_bounties::Call::propose_curator { .. } |
pallet_bounties::Call::unassign_curator { .. } |
pallet_bounties::Call::accept_curator { .. } |
pallet_bounties::Call::award_bounty { .. } |
pallet_bounties::Call::claim_bounty { .. } |
pallet_bounties::Call::close_bounty { .. },
) |
RuntimeCall::PolkadotXcm(pallet_xcm::Call::limited_reserve_transfer_assets { .. }) |
RuntimeCall::Proxy(..) |
RuntimeCall::Tokens(
Expand Down
104 changes: 45 additions & 59 deletions runtime/bifrost-polkadot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ use frame_support::{
Currency, EitherOf, EitherOfDiverse, Get, LinearStoragePrice,
},
};
use frame_system::pallet_prelude::BlockNumberFor;
use frame_system::{EnsureRoot, EnsureRootWithSuccess, EnsureSigned};
use hex_literal::hex;
use parity_scale_codec::{Decode, Encode, MaxEncodedLen};
Expand Down Expand Up @@ -449,32 +450,29 @@ impl InstanceFilter<RuntimeCall> for ProxyType {
RuntimeCall::PhragmenElection(..) |
RuntimeCall::TechnicalMembership(..) |
RuntimeCall::Treasury(..) |
RuntimeCall::Bounties(..) |
RuntimeCall::Tips(..) |
RuntimeCall::Vesting(bifrost_vesting::Call::vest{..}) |
RuntimeCall::Vesting(bifrost_vesting::Call::vest_other{..}) |
// Specifically omitting Vesting `vested_transfer`, and `force_vested_transfer`
RuntimeCall::Utility(..) |
RuntimeCall::Proxy(..) |
RuntimeCall::Multisig(..)
),
ProxyType::Governance =>
matches!(
c,
RuntimeCall::Democracy(..) |
RuntimeCall::Council(..) | RuntimeCall::TechnicalCommittee(..) |
RuntimeCall::PhragmenElection(..) |
RuntimeCall::Treasury(..) |
RuntimeCall::Bounties(..) |
RuntimeCall::Tips(..) | RuntimeCall::Utility(..)
),
ProxyType::Governance => matches!(
c,
RuntimeCall::Democracy(..)
| RuntimeCall::Council(..)
| RuntimeCall::TechnicalCommittee(..)
| RuntimeCall::PhragmenElection(..)
| RuntimeCall::Treasury(..)
| RuntimeCall::Utility(..)
),
ProxyType::CancelProxy => {
matches!(c, RuntimeCall::Proxy(pallet_proxy::Call::reject_announcement { .. }))
},
ProxyType::IdentityJudgement => matches!(
c,
RuntimeCall::Identity(pallet_identity::Call::provide_judgement { .. }) |
RuntimeCall::Utility(..)
RuntimeCall::Identity(pallet_identity::Call::provide_judgement { .. })
| RuntimeCall::Utility(..)
),
}
}
Expand Down Expand Up @@ -816,8 +814,6 @@ parameter_types! {
pub const SpendPeriod: BlockNumber = 6 * DAYS;
pub const PayoutSpendPeriod: BlockNumber = 30 * DAYS;
pub const Burn: Permill = Permill::from_perthousand(0);
pub const TipCountdown: BlockNumber = 1 * DAYS;
pub const TipFindersFee: Percent = Percent::from_percent(20);
pub const TipReportDepositBase: Balance = 1 * DOLLARS;
pub const DataDepositPerByte: Balance = 1 * CENTS;
pub const MaxApprovals: u32 = 100;
Expand Down Expand Up @@ -851,49 +847,11 @@ impl pallet_treasury::Config for Runtime {
type ProposalBondMinimum = ProposalBondMinimum;
type ProposalBondMaximum = ProposalBondMaximum;
type RejectOrigin = MoreThanHalfCouncil;
type SpendFunds = Bounties;
type SpendFunds = ();
type SpendPeriod = SpendPeriod;
type WeightInfo = pallet_treasury::weights::SubstrateWeight<Runtime>;
}

parameter_types! {
pub const BountyDepositBase: Balance = 1 * DOLLARS;
pub const BountyDepositPayoutDelay: BlockNumber = 8 * DAYS;
pub const BountyUpdatePeriod: BlockNumber = 90 * DAYS;
pub const MaximumReasonLength: u32 = 16384;
pub const CuratorDepositMultiplier: Permill = Permill::from_percent(50);
pub const CuratorDepositMin: Balance = 10 * DOLLARS;
pub const CuratorDepositMax: Balance = 200 * DOLLARS;
pub const BountyValueMinimum: Balance = 10 * DOLLARS;
}

impl pallet_bounties::Config for Runtime {
type BountyDepositBase = BountyDepositBase;
type BountyDepositPayoutDelay = BountyDepositPayoutDelay;
type BountyUpdatePeriod = BountyUpdatePeriod;
type BountyValueMinimum = BountyValueMinimum;
type CuratorDepositMultiplier = CuratorDepositMultiplier;
type CuratorDepositMin = CuratorDepositMin;
type CuratorDepositMax = CuratorDepositMax;
type DataDepositPerByte = DataDepositPerByte;
type RuntimeEvent = RuntimeEvent;
type MaximumReasonLength = MaximumReasonLength;
type WeightInfo = pallet_bounties::weights::SubstrateWeight<Runtime>;
type ChildBountyManager = ();
}

impl pallet_tips::Config for Runtime {
type DataDepositPerByte = DataDepositPerByte;
type RuntimeEvent = RuntimeEvent;
type MaximumReasonLength = MaximumReasonLength;
type MaxTipAmount = ();
type TipCountdown = TipCountdown;
type TipFindersFee = TipFindersFee;
type TipReportDepositBase = TipReportDepositBase;
type Tippers = PhragmenElection;
type WeightInfo = pallet_tips::weights::SubstrateWeight<Runtime>;
}

impl pallet_transaction_payment::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type FeeMultiplierUpdate = SlowAdjustingFeeUpdate<Self>;
Expand Down Expand Up @@ -1013,11 +971,12 @@ impl FeeGetter<RuntimeCall> for ExtraFeeMatcher {
extra_fee_name: ExtraFeeName::StatemineTransfer,
extra_fee_currency: RelayCurrencyId::get(),
},
RuntimeCall::VtokenVoting(bifrost_vtoken_voting::Call::vote { vtoken, .. }) =>
RuntimeCall::VtokenVoting(bifrost_vtoken_voting::Call::vote { vtoken, .. }) => {
ExtraFeeInfo {
extra_fee_name: ExtraFeeName::VoteVtoken,
extra_fee_currency: vtoken.to_token().unwrap_or(vtoken),
},
}
},
RuntimeCall::VtokenVoting(bifrost_vtoken_voting::Call::remove_delegator_vote {
vtoken,
..
Expand Down Expand Up @@ -1818,8 +1777,6 @@ construct_runtime! {

// Treasury stuff
Treasury: pallet_treasury = 61,
Bounties: pallet_bounties = 62,
Tips: pallet_tips = 63,
Preimage: pallet_preimage = 64,

// Third party modules
Expand Down Expand Up @@ -1905,18 +1862,47 @@ pub type SignedPayload = generic::SignedPayload<RuntimeCall, SignedExtra>;
/// upgrades in case governance decides to do so. THE ORDER IS IMPORTANT.
pub type Migrations = migrations::Unreleased;

parameter_types! {
pub const TipsPalletName: &'static str = "Tips";
pub const BountiesPalletName: &'static str = "Bounties";
}

/// The runtime migrations per release.
pub mod migrations {
#[allow(unused_imports)]
use super::*;

/// Unreleased migrations. Add new ones here:
pub type Unreleased = (
// Unlock & unreserve funds
pallet_tips::migrations::unreserve_deposits::UnreserveDeposits<UnlockConfigForTips, ()>,
cumulus_pallet_xcmp_queue::migration::v4::MigrationToV4<Runtime>,
migration::slpx_migrates_whitelist::UpdateWhitelist,
frame_support::migrations::RemovePallet<
TipsPalletName,
<Runtime as frame_system::Config>::DbWeight,
>,
frame_support::migrations::RemovePallet<
BountiesPalletName,
<Runtime as frame_system::Config>::DbWeight,
>,
);
}

// Special Config for tips pallets, allowing us to run migrations for them without
// implementing their configs on [`Runtime`].
pub struct UnlockConfigForTips;
impl pallet_tips::migrations::unreserve_deposits::UnlockConfig<()> for UnlockConfigForTips {
type Currency = Balances;
type Hash = Hash;
type DataDepositPerByte = DataDepositPerByte;
type TipReportDepositBase = TipReportDepositBase;
type AccountId = AccountId;
type BlockNumber = BlockNumberFor<Runtime>;
type DbWeight = <Runtime as frame_system::Config>::DbWeight;
type PalletName = TipsPalletName;
}

/// Executive: handles dispatch to the various modules.
pub type Executive = frame_executive::Executive<
Runtime,
Expand Down
10 changes: 0 additions & 10 deletions runtime/bifrost-polkadot/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -441,16 +441,6 @@ impl Contains<RuntimeCall> for SafeCallFilter {
pallet_identity::Call::quit_sub { .. },
) |
RuntimeCall::Vesting(..) |
RuntimeCall::Bounties(
pallet_bounties::Call::propose_bounty { .. } |
pallet_bounties::Call::approve_bounty { .. } |
pallet_bounties::Call::propose_curator { .. } |
pallet_bounties::Call::unassign_curator { .. } |
pallet_bounties::Call::accept_curator { .. } |
pallet_bounties::Call::award_bounty { .. } |
pallet_bounties::Call::claim_bounty { .. } |
pallet_bounties::Call::close_bounty { .. },
) |
RuntimeCall::PolkadotXcm(pallet_xcm::Call::limited_reserve_transfer_assets { .. }) |
RuntimeCall::Proxy(..) |
RuntimeCall::Tokens(
Expand Down