Skip to content

Commit

Permalink
Revert "treasury pallet: remove unused config parameters (paritytech#…
Browse files Browse the repository at this point in the history
…4831)"

This reverts commit 5e62782.
  • Loading branch information
vedhavyas committed Oct 18, 2024
1 parent fc62793 commit f56a75d
Show file tree
Hide file tree
Showing 15 changed files with 41 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ use frame_support::{
parameter_types,
traits::{
tokens::UnityOrOuterConversion, EitherOf, EitherOfDiverse, FromContains, MapSuccess,
OriginTrait, TryWithMorphedArg,
NeverEnsureOrigin, OriginTrait, TryWithMorphedArg,
},
PalletId,
};
Expand Down Expand Up @@ -285,6 +285,14 @@ pub type FellowshipTreasuryPaymaster = PayOverXcm<
pub type FellowshipTreasuryInstance = pallet_treasury::Instance1;

impl pallet_treasury::Config<FellowshipTreasuryInstance> for Runtime {
// The creation of proposals via the treasury pallet is deprecated and should not be utilized.
// Instead, public or fellowship referenda should be used to propose and command the treasury
// spend or spend_local dispatchables. The parameters below have been configured accordingly to
// discourage its use.
// TODO: replace with `NeverEnsure` once polkadot-sdk 1.5 is released.
type ApproveOrigin = NeverEnsureOrigin<()>;
type OnSlash = ();

type WeightInfo = weights::pallet_treasury::WeightInfo<Runtime>;
type PalletId = FellowshipTreasuryPalletId;
type Currency = Balances;
Expand Down
2 changes: 2 additions & 0 deletions polkadot/runtime/common/src/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -328,8 +328,10 @@ mod tests {

impl pallet_treasury::Config for Test {
type Currency = pallet_balances::Pallet<Test>;
type ApproveOrigin = frame_system::EnsureRoot<AccountId>;
type RejectOrigin = frame_system::EnsureRoot<AccountId>;
type RuntimeEvent = RuntimeEvent;
type OnSlash = ();
type SpendPeriod = ();
type Burn = ();
type BurnDestination = ();
Expand Down
3 changes: 2 additions & 1 deletion polkadot/runtime/rococo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -502,8 +502,10 @@ parameter_types! {
impl pallet_treasury::Config for Runtime {
type PalletId = TreasuryPalletId;
type Currency = Balances;
type ApproveOrigin = EitherOfDiverse<EnsureRoot<AccountId>, Treasurer>;
type RejectOrigin = EitherOfDiverse<EnsureRoot<AccountId>, Treasurer>;
type RuntimeEvent = RuntimeEvent;
type OnSlash = Treasury;
type SpendPeriod = SpendPeriod;
type Burn = Burn;
type BurnDestination = Society;
Expand Down Expand Up @@ -562,7 +564,6 @@ impl pallet_bounties::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type MaximumReasonLength = MaximumReasonLength;
type WeightInfo = weights::pallet_bounties::WeightInfo<Runtime>;
type OnSlash = Treasury;
}

parameter_types! {
Expand Down
2 changes: 2 additions & 0 deletions polkadot/runtime/westend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -692,8 +692,10 @@ parameter_types! {
impl pallet_treasury::Config for Runtime {
type PalletId = TreasuryPalletId;
type Currency = Balances;
type ApproveOrigin = EitherOfDiverse<EnsureRoot<AccountId>, Treasurer>;
type RejectOrigin = EitherOfDiverse<EnsureRoot<AccountId>, Treasurer>;
type RuntimeEvent = RuntimeEvent;
type OnSlash = Treasury;
type SpendPeriod = SpendPeriod;
type Burn = Burn;
type BurnDestination = ();
Expand Down
25 changes: 0 additions & 25 deletions prdoc/1.14.0/pr_4831.prdoc

This file was deleted.

7 changes: 5 additions & 2 deletions substrate/bin/node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1231,11 +1231,16 @@ parameter_types! {
impl pallet_treasury::Config for Runtime {
type PalletId = TreasuryPalletId;
type Currency = Balances;
type ApproveOrigin = EitherOfDiverse<
EnsureRoot<AccountId>,
pallet_collective::EnsureProportionAtLeast<AccountId, CouncilCollective, 3, 5>,
>;
type RejectOrigin = EitherOfDiverse<
EnsureRoot<AccountId>,
pallet_collective::EnsureProportionMoreThan<AccountId, CouncilCollective, 1, 2>,
>;
type RuntimeEvent = RuntimeEvent;
type OnSlash = ();
type SpendPeriod = SpendPeriod;
type Burn = Burn;
type BurnDestination = ();
Expand Down Expand Up @@ -1289,7 +1294,6 @@ impl pallet_bounties::Config for Runtime {
type MaximumReasonLength = MaximumReasonLength;
type WeightInfo = pallet_bounties::weights::SubstrateWeight<Runtime>;
type ChildBountyManager = ChildBounties;
type OnSlash = Treasury;
}

parameter_types! {
Expand Down Expand Up @@ -1334,7 +1338,6 @@ impl pallet_tips::Config for Runtime {
type TipReportDepositBase = TipReportDepositBase;
type MaxTipAmount = ConstU128<{ 500 * DOLLARS }>;
type WeightInfo = pallet_tips::weights::SubstrateWeight<Runtime>;
type OnSlash = Treasury;
}

parameter_types! {
Expand Down
4 changes: 2 additions & 2 deletions substrate/frame/bounties/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ benchmarks_instance_pallet! {
Bounties::<T, I>::propose_bounty(RawOrigin::Signed(caller).into(), value, reason)?;
let bounty_id = BountyCount::<T, I>::get() - 1;
let approve_origin =
T::RejectOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?;
T::ApproveOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?;
}: close_bounty<T::RuntimeOrigin>(approve_origin, bounty_id)

close_bounty_active {
Expand All @@ -187,7 +187,7 @@ benchmarks_instance_pallet! {
Treasury::<T, I>::on_initialize(BlockNumberFor::<T>::zero());
let bounty_id = BountyCount::<T, I>::get() - 1;
let approve_origin =
T::RejectOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?;
T::ApproveOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?;
}: close_bounty<T::RuntimeOrigin>(approve_origin, bounty_id)
verify {
assert_last_event::<T, I>(Event::BountyCanceled { index: bounty_id }.into())
Expand Down
3 changes: 0 additions & 3 deletions substrate/frame/bounties/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,9 +247,6 @@ pub mod pallet {

/// The child bounty manager.
type ChildBountyManager: ChildBountyManager<BalanceOf<Self, I>>;

/// Handler for the unbalanced decrease when slashing for a rejected bounty.
type OnSlash: OnUnbalanced<pallet_treasury::NegativeImbalanceOf<Self, I>>;
}

#[pallet::error]
Expand Down
6 changes: 4 additions & 2 deletions substrate/frame/bounties/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,10 @@ parameter_types! {
impl pallet_treasury::Config for Test {
type PalletId = TreasuryPalletId;
type Currency = pallet_balances::Pallet<Test>;
type ApproveOrigin = frame_system::EnsureRoot<u128>;
type RejectOrigin = frame_system::EnsureRoot<u128>;
type RuntimeEvent = RuntimeEvent;
type OnSlash = ();
type SpendPeriod = ConstU64<2>;
type Burn = Burn;
type BurnDestination = (); // Just gets burned.
Expand All @@ -105,8 +107,10 @@ impl pallet_treasury::Config for Test {
impl pallet_treasury::Config<Instance1> for Test {
type PalletId = TreasuryPalletId2;
type Currency = pallet_balances::Pallet<Test>;
type ApproveOrigin = frame_system::EnsureRoot<u128>;
type RejectOrigin = frame_system::EnsureRoot<u128>;
type RuntimeEvent = RuntimeEvent;
type OnSlash = ();
type SpendPeriod = ConstU64<2>;
type Burn = Burn;
type BurnDestination = (); // Just gets burned.
Expand Down Expand Up @@ -145,7 +149,6 @@ impl Config for Test {
type MaximumReasonLength = ConstU32<16384>;
type WeightInfo = ();
type ChildBountyManager = ();
type OnSlash = ();
}

impl Config<Instance1> for Test {
Expand All @@ -161,7 +164,6 @@ impl Config<Instance1> for Test {
type MaximumReasonLength = ConstU32<16384>;
type WeightInfo = ();
type ChildBountyManager = ();
type OnSlash = ();
}

type TreasuryError = pallet_treasury::Error<Test>;
Expand Down
3 changes: 2 additions & 1 deletion substrate/frame/child-bounties/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,10 @@ parameter_types! {
impl pallet_treasury::Config for Test {
type PalletId = TreasuryPalletId;
type Currency = pallet_balances::Pallet<Test>;
type ApproveOrigin = frame_system::EnsureRoot<u128>;
type RejectOrigin = frame_system::EnsureRoot<u128>;
type RuntimeEvent = RuntimeEvent;
type OnSlash = ();
type SpendPeriod = ConstU64<2>;
type Burn = Burn;
type BurnDestination = ();
Expand Down Expand Up @@ -121,7 +123,6 @@ impl pallet_bounties::Config for Test {
type MaximumReasonLength = ConstU32<300>;
type WeightInfo = ();
type ChildBountyManager = ChildBounties;
type OnSlash = ();
}
impl pallet_child_bounties::Config for Test {
type RuntimeEvent = RuntimeEvent;
Expand Down
3 changes: 0 additions & 3 deletions substrate/frame/tips/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,6 @@ pub mod pallet {
/// update weights file when altering this method.
type Tippers: SortedMembers<Self::AccountId> + ContainsLengthBound;

/// Handler for the unbalanced decrease when slashing for a removed tip.
type OnSlash: OnUnbalanced<NegativeImbalanceOf<Self, I>>;

/// Weight information for extrinsics in this pallet.
type WeightInfo: WeightInfo;
}
Expand Down
6 changes: 4 additions & 2 deletions substrate/frame/tips/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,10 @@ parameter_types! {
impl pallet_treasury::Config for Test {
type PalletId = TreasuryPalletId;
type Currency = pallet_balances::Pallet<Test>;
type ApproveOrigin = frame_system::EnsureRoot<u128>;
type RejectOrigin = frame_system::EnsureRoot<u128>;
type RuntimeEvent = RuntimeEvent;
type OnSlash = ();
type SpendPeriod = ConstU64<2>;
type Burn = Burn;
type BurnDestination = (); // Just gets burned.
Expand All @@ -126,8 +128,10 @@ impl pallet_treasury::Config for Test {
impl pallet_treasury::Config<Instance1> for Test {
type PalletId = TreasuryPalletId2;
type Currency = pallet_balances::Pallet<Test>;
type ApproveOrigin = frame_system::EnsureRoot<u128>;
type RejectOrigin = frame_system::EnsureRoot<u128>;
type RuntimeEvent = RuntimeEvent;
type OnSlash = ();
type SpendPeriod = ConstU64<2>;
type Burn = Burn;
type BurnDestination = (); // Just gets burned.
Expand Down Expand Up @@ -158,7 +162,6 @@ impl Config for Test {
type DataDepositPerByte = ConstU64<1>;
type MaxTipAmount = ConstU64<10_000_000>;
type RuntimeEvent = RuntimeEvent;
type OnSlash = ();
type WeightInfo = ();
}

Expand All @@ -171,7 +174,6 @@ impl Config<Instance1> for Test {
type DataDepositPerByte = ConstU64<1>;
type MaxTipAmount = ConstU64<10_000_000>;
type RuntimeEvent = RuntimeEvent;
type OnSlash = ();
type WeightInfo = ();
}

Expand Down
6 changes: 6 additions & 0 deletions substrate/frame/treasury/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,13 +207,19 @@ pub mod pallet {
/// The staking balance.
type Currency: Currency<Self::AccountId> + ReservableCurrency<Self::AccountId>;

/// Origin from which approvals must come.
type ApproveOrigin: EnsureOrigin<Self::RuntimeOrigin>;

/// Origin from which rejections must come.
type RejectOrigin: EnsureOrigin<Self::RuntimeOrigin>;

/// The overarching event type.
type RuntimeEvent: From<Event<Self, I>>
+ IsType<<Self as frame_system::Config>::RuntimeEvent>;

/// Handler for the unbalanced decrease when slashing for a rejected proposal or bounty.
type OnSlash: OnUnbalanced<NegativeImbalanceOf<Self, I>>;

/// Period between successive spends.
#[pallet::constant]
type SpendPeriod: Get<BlockNumberFor<Self>>;
Expand Down
2 changes: 2 additions & 0 deletions substrate/frame/treasury/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,10 @@ impl<N: Get<u64>> ConversionFromAssetBalance<u64, u32, u64> for MulBy<N> {
impl Config for Test {
type PalletId = TreasuryPalletId;
type Currency = pallet_balances::Pallet<Test>;
type ApproveOrigin = frame_system::EnsureRoot<u128>;
type RejectOrigin = frame_system::EnsureRoot<u128>;
type RuntimeEvent = RuntimeEvent;
type OnSlash = ();
type SpendPeriod = ConstU64<2>;
type Burn = Burn;
type BurnDestination = (); // Just gets burned.
Expand Down
1 change: 1 addition & 0 deletions substrate/primitives/panic-handler/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
//!
//! By default, the panic handler aborts the process by calling [`std::process::exit`]. This can
//! temporarily be disabled by using an [`AbortGuard`].
#![allow(deprecated)]

use backtrace::Backtrace;
use regex::Regex;
Expand Down

0 comments on commit f56a75d

Please sign in to comment.