-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Implement Budget Distribution logic in pallet-dap #11527
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
Merged
Merged
Changes from all commits
Commits
Show all changes
44 commits
Select commit
Hold shift + click to select a range
1d17819
frontrunning traits
Ank4n c3dc7e8
dont deprecate yet
Ank4n 6f2742b
fmt
Ank4n 14e3aa9
remov EraPayout from staking async
Ank4n ddd01ec
remove EraRewardAllocation. It belongs in staking async
Ank4n e14a388
move budget stuff to budget module
Ank4n 187aa7f
remove AccountID from StakerRewardCalcualtor
Ank4n 5075904
Merge branch 'master' into ankn-sp-staking-traits
Ank4n 4571f1f
prdoc
Ank4n 5eb51a5
extract dap changes from 10844
Ank4n 0239e58
missing lock
Ank4n 9b388b2
needs to be reverted when we integrate with staking changes
Ank4n cd7ede6
add default noop impl of issuance curve
Ank4n 267a81e
comment on consts
Ank4n 398b2cd
prdoc
Ank4n da7abca
weights
Ank4n eecc058
simplify
Ank4n f4f8a1f
update weights
Ank4n 9ec5124
fmt
Ank4n 946ff6a
improve trait docs
Ank4n bb15c4e
no duplicate assertion + test for budget id
Ank4n e0b4282
Merge branch 'master' into ankn-sp-staking-traits
Ank4n 1a35968
Merge branch 'ankn-sp-staking-traits' into ankn-dap-budgets
Ank4n 2df7d71
fmt
Ank4n 10536cc
buffer_acc() only crate visibile
Ank4n 213ba52
always advance issue time
Ank4n 941ada8
use static parameter
Ank4n 435b08c
try state fail checks
Ank4n caf5524
use u64 for account id
Ank4n ff9f4a6
no need to override acc id
Ank4n 6a7c408
Revert "no need to override acc id"
Ank4n c0d1609
fix rustdoc
Ank4n 7917bab
Merge branch 'ankn-sp-staking-traits' into ankn-dap-budgets
Ank4n 7af0c6d
improve tests
Ank4n c6bbb0f
Merge branch 'master' into ankn-sp-staking-traits
sigurpol 3ce6cb2
Merge branch 'ankn-sp-staking-traits' into ankn-dap-budgets
Ank4n a30d654
Merge branch 'master' into ankn-sp-staking-traits
Ank4n 9380b2d
Merge branch 'ankn-sp-staking-traits' into ankn-dap-budgets
Ank4n b466762
fix ci
Ank4n 8b63957
fmt
Ank4n 195d8a1
fix clippy
Ank4n 8d80024
Merge branch 'master' into ankn-dap-budgets
Ank4n 4795651
disable dap budget check
Ank4n d2b0eaa
another offering to CI Gods
Ank4n File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| title: Add issuance drip and budget distribution to pallet-dap | ||
| doc: | ||
| - audience: Runtime Dev | ||
| description: |- | ||
| Adds issuance drip and budget distribution to `pallet-dap`. DAP mints new tokens on a | ||
| configurable cadence via `IssuanceCurve` and distributes them to registered | ||
| `BudgetRecipient`s according to a governance-updatable allocation map. | ||
|
|
||
| Includes `set_budget_allocation` extrinsic, `OnUnbalanced` slash handling with buffer | ||
| deactivation, safety ceiling on elapsed time, and a V1→V2 migration struct (not yet applied). | ||
|
|
||
| All runtimes are configured with a noop `IssuanceCurve` (`()` impl that returns 0) so there | ||
| is no behavior change. Minting will be enabled when staking is integrated with DAP. | ||
| crates: | ||
| - name: pallet-dap | ||
| bump: major | ||
| - name: sp-staking | ||
| bump: minor | ||
| - name: asset-hub-westend-runtime | ||
| bump: major | ||
| - name: pallet-staking-async-parachain-runtime | ||
| bump: patch | ||
| - name: pallet-ahm-test | ||
| bump: patch |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| // This file is part of Substrate. | ||
|
|
||
| // Copyright (C) Parity Technologies (UK) Ltd. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| //! Benchmarks for pallet-dap. | ||
|
|
||
| use super::*; | ||
| use frame_benchmarking::v2::*; | ||
| use frame_support::traits::Time; | ||
| use frame_system::RawOrigin; | ||
| use sp_staking::budget::BudgetRecipientList; | ||
|
|
||
| #[benchmarks] | ||
| mod benchmarks { | ||
| use super::*; | ||
|
|
||
| /// Build a valid allocation from registered recipients, distributing evenly and giving | ||
| /// the remainder to the last recipient to ensure the sum is exactly 100%. | ||
| fn build_even_allocation<T: Config>() -> BudgetAllocationMap { | ||
| let recipients = T::BudgetRecipients::recipients(); | ||
| let count = recipients.len() as u32; | ||
| let mut allocations = BudgetAllocationMap::new(); | ||
|
|
||
| for (i, (key, _)) in recipients.into_iter().enumerate() { | ||
| let perbill = if i as u32 == count - 1 { | ||
| let used: u32 = allocations.values().map(|p| p.deconstruct()).sum(); | ||
| Perbill::from_parts(Perbill::one().deconstruct().saturating_sub(used)) | ||
| } else { | ||
| Perbill::from_rational(1u32, count) | ||
| }; | ||
| allocations.try_insert(key, perbill).expect("bounded by MAX_BUDGET_RECIPIENTS"); | ||
| } | ||
|
|
||
| allocations | ||
| } | ||
|
|
||
| #[benchmark] | ||
| fn set_budget_allocation() { | ||
| let allocations = build_even_allocation::<T>(); | ||
|
|
||
| #[extrinsic_call] | ||
| _(RawOrigin::Root, allocations.clone()); | ||
|
|
||
| assert_eq!(BudgetAllocation::<T>::get(), allocations); | ||
| } | ||
|
|
||
| #[benchmark] | ||
| fn drip_issuance() { | ||
| let allocations = build_even_allocation::<T>(); | ||
| BudgetAllocation::<T>::put(allocations); | ||
|
|
||
| // Seed the timestamp so the drip fires. | ||
| let now: u64 = T::Time::now().saturated_into(); | ||
| let past = now.saturating_sub(T::IssuanceCadence::get() + 1); | ||
| LastIssuanceTimestamp::<T>::put(past); | ||
|
|
||
| #[block] | ||
| { | ||
| Pallet::<T>::drip_issuance(); | ||
| } | ||
|
|
||
| // Timestamp should be updated. | ||
| assert!(LastIssuanceTimestamp::<T>::get() > past); | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
minting disabled in this PR. Enabled with staking budget changes impl PR.