-
Notifications
You must be signed in to change notification settings - Fork 1.2k
pallet-bounties: allow bounties to never expire #7723
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
Changes from 7 commits
52698ec
fa19b53
4e49830
08c637d
2478bfc
c8cb79e
4654163
2e22a58
3890ab0
91eb76d
2ef5617
1ee5b56
a927617
cda4673
5c18edd
e0600e3
133ca5b
6e42b1e
5ce7249
c34e68e
a143787
7a9f641
e254cec
1f6b1bb
3bde188
e754423
0b8c2a5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| title: '[pallet-bounties] Make BountyUpdatePeriod optional' | ||
| doc: | ||
| - audience: Runtime Dev | ||
| description: Refactored `BountyUpdatePeriod` to be optional and adjusted expiration handling to default to `BlockNumber::MAX` when `None`. | ||
| crates: | ||
| - name: pallet-bounties | ||
| bump: patch | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -99,7 +99,10 @@ use frame_support::traits::{ | |
| }; | ||
|
|
||
| use sp_runtime::{ | ||
| traits::{AccountIdConversion, BadOrigin, BlockNumberProvider, Saturating, StaticLookup, Zero}, | ||
| traits::{ | ||
| AccountIdConversion, BadOrigin, BlockNumberProvider, Bounded, Saturating, StaticLookup, | ||
| Zero, | ||
| }, | ||
| DispatchResult, Permill, RuntimeDebug, | ||
| }; | ||
|
|
||
|
|
@@ -221,9 +224,9 @@ pub mod pallet { | |
| #[pallet::constant] | ||
| type BountyDepositPayoutDelay: Get<BlockNumberFor<Self, I>>; | ||
|
|
||
| /// Bounty duration in blocks. | ||
| /// Optional bounty duration in blocks. If `None`, it is considered `BlockNumber::MAX`. | ||
|
||
| #[pallet::constant] | ||
| type BountyUpdatePeriod: Get<BlockNumberFor<Self, I>>; | ||
| type BountyUpdatePeriod: Get<Option<BlockNumberFor<Self, I>>>; | ||
|
||
|
|
||
| /// The curator deposit is calculated as a percentage of the curator fee. | ||
| /// | ||
|
|
@@ -578,8 +581,9 @@ pub mod pallet { | |
| T::Currency::reserve(curator, deposit)?; | ||
| bounty.curator_deposit = deposit; | ||
|
|
||
| let update_due = | ||
| Self::treasury_block_number() + T::BountyUpdatePeriod::get(); | ||
| let update_due = Self::treasury_block_number() + | ||
| T::BountyUpdatePeriod::get() | ||
| .unwrap_or(BlockNumberFor::<T, I>::max_value()); | ||
| bounty.status = | ||
| BountyStatus::Active { curator: curator.clone(), update_due }; | ||
|
|
||
|
|
@@ -820,8 +824,10 @@ pub mod pallet { | |
| match bounty.status { | ||
| BountyStatus::Active { ref curator, ref mut update_due } => { | ||
| ensure!(*curator == signer, Error::<T, I>::RequireCurator); | ||
| *update_due = (Self::treasury_block_number() + | ||
| T::BountyUpdatePeriod::get()) | ||
| *update_due = (Self::treasury_block_number().saturating_add( | ||
| T::BountyUpdatePeriod::get() | ||
| .unwrap_or(BlockNumberFor::<T, I>::max_value()), | ||
|
||
| )) | ||
| .max(*update_due); | ||
| }, | ||
| _ => return Err(Error::<T, I>::UnexpectedStatus.into()), | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,7 +25,7 @@ use frame_support::ensure; | |
| use frame_system::RawOrigin; | ||
| use pallet_bounties::Pallet as Bounties; | ||
| use pallet_treasury::Pallet as Treasury; | ||
| use sp_runtime::traits::BlockNumberProvider; | ||
| use sp_runtime::traits::{BlockNumberProvider, Bounded}; | ||
|
|
||
| use crate::*; | ||
|
|
||
|
|
@@ -273,7 +273,11 @@ mod benchmarks { | |
| setup_pot_account::<T>(); | ||
| let bounty_setup = activate_child_bounty::<T>(0, T::MaximumReasonLength::get())?; | ||
| Treasury::<T>::on_initialize(frame_system::Pallet::<T>::block_number()); | ||
| set_block_number::<T>(T::SpendPeriod::get() + T::BountyUpdatePeriod::get() + 1u32.into()); | ||
| set_block_number::<T>( | ||
|
||
| T::SpendPeriod::get() + | ||
| T::BountyUpdatePeriod::get().unwrap_or(BlockNumberFor::<T>::max_value()) + | ||
ggwpez marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| 1u32.into(), | ||
| ); | ||
| let caller = whitelisted_caller(); | ||
|
|
||
| #[extrinsic_call] | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this will be included in the release notes. I would explain what this means. this is more like a description of the implementation, it can be read from the code.
also please add PR description
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated. Thanks!