Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Allow the treasury to have a maximum bound on the bond #10689

Merged
merged 2 commits into from
Jan 19, 2022
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
1 change: 1 addition & 0 deletions bin/node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -880,6 +880,7 @@ impl pallet_treasury::Config for Runtime {
type OnSlash = ();
type ProposalBond = ProposalBond;
type ProposalBondMinimum = ProposalBondMinimum;
type ProposalBondMaximum = ();
type SpendPeriod = SpendPeriod;
type Burn = Burn;
type BurnDestination = ();
Expand Down
1 change: 1 addition & 0 deletions docs/Upgrading-2.0-to-3.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ As mentioned above, Bounties, Tips and Lottery have been extracted out of treasu
type OnSlash = ();
type ProposalBond = ProposalBond;
type ProposalBondMinimum = ProposalBondMinimum;
type ProposalBondMaximum = ();
type SpendPeriod = SpendPeriod;
type Burn = Burn;
+ type BurnDestination = ();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this an actual + sign in the text?

Expand Down
1 change: 1 addition & 0 deletions frame/bounties/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ impl pallet_treasury::Config for Test {
type OnSlash = ();
type ProposalBond = ProposalBond;
type ProposalBondMinimum = ConstU64<1>;
type ProposalBondMaximum = ();
type SpendPeriod = ConstU64<2>;
type Burn = Burn;
type BurnDestination = (); // Just gets burned.
Expand Down
1 change: 1 addition & 0 deletions frame/child-bounties/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ impl pallet_treasury::Config for Test {
type OnSlash = ();
type ProposalBond = ProposalBond;
type ProposalBondMinimum = ConstU64<1>;
type ProposalBondMaximum = ();
type SpendPeriod = ConstU64<2>;
type Burn = Burn;
type BurnDestination = ();
Expand Down
1 change: 1 addition & 0 deletions frame/tips/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ impl pallet_treasury::Config for Test {
type OnSlash = ();
type ProposalBond = ProposalBond;
type ProposalBondMinimum = ConstU64<1>;
type ProposalBondMaximum = ();
type SpendPeriod = ConstU64<2>;
type Burn = Burn;
type BurnDestination = (); // Just gets burned.
Expand Down
10 changes: 9 additions & 1 deletion frame/treasury/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,10 @@ pub mod pallet {
#[pallet::constant]
type ProposalBondMinimum: Get<BalanceOf<Self, I>>;

/// Maximum amount of funds that should be placed in a deposit for making a proposal.
#[pallet::constant]
type ProposalBondMaximum: Get<Option<BalanceOf<Self, I>>>;

/// Period between successive spends.
#[pallet::constant]
type SpendPeriod: Get<Self::BlockNumber>;
Expand Down Expand Up @@ -404,7 +408,11 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {

/// The needed bond for a proposal whose spend is `value`.
fn calculate_bond(value: BalanceOf<T, I>) -> BalanceOf<T, I> {
T::ProposalBondMinimum::get().max(T::ProposalBond::get() * value)
let mut r = T::ProposalBondMinimum::get().max(T::ProposalBond::get() * value);
if let Some(m) = T::ProposalBondMaximum::get() {
r = r.min(m);
}
r
}

/// Spend some money! returns number of approvals before spend.
Expand Down
1 change: 1 addition & 0 deletions frame/treasury/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ impl Config for Test {
type OnSlash = ();
type ProposalBond = ProposalBond;
type ProposalBondMinimum = ConstU64<1>;
type ProposalBondMaximum = ();
type SpendPeriod = ConstU64<2>;
type Burn = Burn;
type BurnDestination = (); // Just gets burned.
Expand Down