-
Notifications
You must be signed in to change notification settings - Fork 115
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
Luxor/reduce council budget #5062
Changes from 15 commits
0faab6d
b797a10
86a254c
b7f9bc7
192a773
28e6fb1
ddc9a39
f3a8c3e
ccc7490
ba85a32
a88003d
1f823ff
82b039d
c2acd1e
cb13cf6
86d862f
84a3456
35e7175
d44b700
4195007
e0076f9
3a4804a
9b820c8
61f0c66
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -423,6 +423,11 @@ decl_event! { | |
/// Councilor reward has been updated. | ||
CouncilorRewardUpdated(Balance), | ||
|
||
/// Councilor budget has been decreased | ||
/// Params: | ||
/// - Reduction amount | ||
CouncilBudgetDecreased(Balance), | ||
|
||
/// Request has been funded | ||
RequestFunded(AccountId, Balance), | ||
|
||
|
@@ -518,6 +523,9 @@ decl_error! { | |
|
||
/// Cannot withdraw: insufficient budget balance. | ||
InsufficientBalanceForTransfer, | ||
|
||
/// Cannot reduce the budget by the given amount. | ||
ReductionAmountTooLarge | ||
} | ||
} | ||
|
||
|
@@ -843,6 +851,38 @@ decl_module! { | |
Ok(()) | ||
} | ||
|
||
/// Decrease the council total budget | ||
/// | ||
/// # <weight> | ||
/// | ||
/// ## weight | ||
/// `O (1)` | ||
/// - db: | ||
/// - `O(1)` doesn't depend on the state or parameters | ||
/// # </weight> | ||
#[weight = 10_000_000] // TODO: adjust | ||
pub fn decrease_council_budget(origin, reduction_amount: Balance<T>) -> Result<(), Error<T>> { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. when adding a new dispatch that is invoked by a proposal, it is best to try to add it at the end so that the method index of existing dispatches doesn't change, so we can have the option to not remove all pending proposals on runtime upgrades. |
||
// ensure action can be started | ||
EnsureChecks::<T>::can_decrease_council_budget(origin)?; | ||
|
||
// ensure reduction amount is not too large | ||
ensure!( | ||
reduction_amount <= Self::budget(), | ||
Error::<T>::ReductionAmountTooLarge | ||
); | ||
|
||
// | ||
// == MUTATION SAFE == | ||
// | ||
|
||
// update state | ||
Mutations::<T>::decrease_budget(reduction_amount); | ||
|
||
// emit event | ||
Self::deposit_event(RawEvent::CouncilBudgetDecreased(reduction_amount)); | ||
|
||
Ok(()) | ||
} | ||
|
||
/// Transfers funds from council budget to account | ||
/// | ||
|
@@ -1788,6 +1828,13 @@ impl<T: Config> EnsureChecks<T> { | |
|
||
Ok(()) | ||
} | ||
|
||
// Ensures there is no problem in decreasing the council budget | ||
fn can_decrease_council_budget(origin: T::RuntimeOrigin) -> Result<(), Error<T>> { | ||
ensure_root(origin)?; | ||
|
||
Ok(()) | ||
} | ||
} | ||
|
||
impl<T: Config + common::membership::MembershipTypes> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -93,7 +93,6 @@ frame_support::construct_runtime!( | |
Membership: membership::{Pallet, Call, Storage, Event<T>}, | ||
ProposalsCodex: proposals_codex::{Pallet, Call, Storage, Event<T>}, | ||
ProposalsEngine: proposals_engine::{Pallet, Call, Storage, Event<T>}, | ||
Council: council::{Pallet, Call, Storage, Event<T>}, | ||
Referendum: referendum::<Instance1>::{Pallet, Call, Storage, Event<T>}, | ||
ProposalsDiscussion: proposals_discussion::{Pallet, Call, Storage, Event<T>}, | ||
ForumWorkingGroup: working_group::<Instance1>::{Pallet, Call, Storage, Event<T>}, | ||
|
@@ -105,6 +104,7 @@ frame_support::construct_runtime!( | |
OperationsWorkingGroupBeta: working_group::<Instance7>::{Pallet, Call, Storage, Event<T>}, | ||
OperationsWorkingGroupGamma: working_group::<Instance8>::{Pallet, Call, Storage, Event<T>}, | ||
DistributionWorkingGroup: working_group::<Instance9>::{Pallet, Call, Storage, Event<T>}, | ||
Council: council::{Pallet, Call, Storage, Event<T>}, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why did you find it necessary to move the Council pallet down here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. without that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is is something about the way this particular mock is implemented with respect to types. We do not seem to need to do the same for the main runtime/lib.rs |
||
} | ||
); | ||
|
||
|
@@ -670,6 +670,7 @@ impl crate::Config for Test { | |
type FundingRequestProposalMaxAccounts = FundingRequestProposalMaxAccounts; | ||
type SetMaxValidatorCountProposalMaxValidators = SetMaxValidatorCountProposalMaxValidators; | ||
type SetPalletFozenStatusProposalParameters = DefaultProposalParameters; | ||
type DecreaseCouncilBudgetProposalParameters = DefaultProposalParameters; | ||
} | ||
|
||
parameter_types! { | ||
|
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.
Should we add a weight function for this dispatch
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 was part of a bigger issue that there are no benchmarks.
I have added that for the
reduce_council_budget
, thanks for pointing it out