Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
1d17819
frontrunning traits
Ank4n Mar 26, 2026
c3dc7e8
dont deprecate yet
Ank4n Mar 27, 2026
6f2742b
fmt
Ank4n Mar 27, 2026
14e3aa9
remov EraPayout from staking async
Ank4n Mar 27, 2026
ddd01ec
remove EraRewardAllocation. It belongs in staking async
Ank4n Mar 27, 2026
e14a388
move budget stuff to budget module
Ank4n Mar 27, 2026
187aa7f
remove AccountID from StakerRewardCalcualtor
Ank4n Mar 27, 2026
5075904
Merge branch 'master' into ankn-sp-staking-traits
Ank4n Mar 27, 2026
4571f1f
prdoc
Ank4n Mar 27, 2026
5eb51a5
extract dap changes from 10844
Ank4n Mar 27, 2026
0239e58
missing lock
Ank4n Mar 27, 2026
9b388b2
needs to be reverted when we integrate with staking changes
Ank4n Mar 27, 2026
cd7ede6
add default noop impl of issuance curve
Ank4n Mar 27, 2026
267a81e
comment on consts
Ank4n Mar 27, 2026
398b2cd
prdoc
Ank4n Mar 27, 2026
da7abca
weights
Ank4n Mar 27, 2026
eecc058
simplify
Ank4n Mar 27, 2026
f4f8a1f
update weights
Ank4n Mar 27, 2026
9ec5124
fmt
Ank4n Mar 27, 2026
946ff6a
improve trait docs
Ank4n Mar 30, 2026
bb15c4e
no duplicate assertion + test for budget id
Ank4n Mar 30, 2026
e0b4282
Merge branch 'master' into ankn-sp-staking-traits
Ank4n Mar 30, 2026
1a35968
Merge branch 'ankn-sp-staking-traits' into ankn-dap-budgets
Ank4n Mar 30, 2026
2df7d71
fmt
Ank4n Mar 30, 2026
10536cc
buffer_acc() only crate visibile
Ank4n Mar 31, 2026
213ba52
always advance issue time
Ank4n Mar 31, 2026
941ada8
use static parameter
Ank4n Mar 31, 2026
435b08c
try state fail checks
Ank4n Mar 31, 2026
caf5524
use u64 for account id
Ank4n Mar 31, 2026
ff9f4a6
no need to override acc id
Ank4n Mar 31, 2026
6a7c408
Revert "no need to override acc id"
Ank4n Mar 31, 2026
c0d1609
fix rustdoc
Ank4n Mar 31, 2026
7917bab
Merge branch 'ankn-sp-staking-traits' into ankn-dap-budgets
Ank4n Mar 31, 2026
7af0c6d
improve tests
Ank4n Mar 31, 2026
c6bbb0f
Merge branch 'master' into ankn-sp-staking-traits
sigurpol Mar 31, 2026
3ce6cb2
Merge branch 'ankn-sp-staking-traits' into ankn-dap-budgets
Ank4n Mar 31, 2026
a30d654
Merge branch 'master' into ankn-sp-staking-traits
Ank4n Mar 31, 2026
9380b2d
Merge branch 'ankn-sp-staking-traits' into ankn-dap-budgets
Ank4n Mar 31, 2026
b466762
fix ci
Ank4n Mar 31, 2026
8b63957
fmt
Ank4n Mar 31, 2026
195d8a1
fix clippy
Ank4n Mar 31, 2026
8d80024
Merge branch 'master' into ankn-dap-budgets
Ank4n Mar 31, 2026
4795651
disable dap budget check
Ank4n Mar 31, 2026
d2b0eaa
another offering to CI Gods
Ank4n Mar 31, 2026
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 Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -344,11 +344,23 @@ impl pallet_staking_async_rc_client::Config for Runtime {

parameter_types! {
pub const DapPalletId: frame_support::PalletId = frame_support::PalletId(*b"dap/buff");
/// Minimum time (ms) between issuance drips. 60s = drip at most once per minute.
pub const IssuanceCadence: u64 = 60_000;
/// Safety ceiling (ms) for elapsed time in a single drip. Prevents over-minting after stalls.
pub const MaxElapsedPerDrip: u64 = 600_000;
}

impl pallet_dap::Config for Runtime {
type Currency = Balances;
type PalletId = DapPalletId;
/// Noop — DAP does not mint until budget drip is enabled.
type IssuanceCurve = ();
Copy link
Copy Markdown
Contributor Author

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.

type BudgetRecipients = (pallet_dap::Pallet<Runtime>,);
type Time = pallet_timestamp::Pallet<Runtime>;
type IssuanceCadence = IssuanceCadence;
type MaxElapsedPerDrip = MaxElapsedPerDrip;
type BudgetOrigin = frame_system::EnsureRoot<AccountId>;
type WeightInfo = ();
}

#[derive(Encode, Decode)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2526,7 +2526,9 @@ mod dap {
#[test]
fn tx_fees_go_to_dap_buffer() {
let alice = AccountId::from(Sr25519Keyring::Alice);
let buffer = pallet_dap::Pallet::<Runtime>::buffer_account();
let buffer = <pallet_dap::Pallet<Runtime> as sp_staking::budget::BudgetRecipient<
AccountId,
>>::pot_account();
let ed = ExistentialDeposit::get();

ExtBuilder::<Runtime>::default()
Expand Down Expand Up @@ -2564,7 +2566,9 @@ mod dap {
fn dust_removal_goes_to_dap_buffer() {
let alice = AccountId::from(ALICE);
let bob = AccountId::from(BOB);
let buffer = pallet_dap::Pallet::<Runtime>::buffer_account();
let buffer = <pallet_dap::Pallet<Runtime> as sp_staking::budget::BudgetRecipient<
AccountId,
>>::pot_account();
let ed = ExistentialDeposit::get();
let dust = ed / 2;

Expand Down
24 changes: 24 additions & 0 deletions prdoc/pr_11527.prdoc
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
3 changes: 3 additions & 0 deletions substrate/frame/dap/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ frame-system = { workspace = true }
log = { workspace = true }
scale-info = { features = ["derive"], workspace = true }
sp-runtime = { workspace = true }
sp-staking = { workspace = true }

[dev-dependencies]
pallet-balances = { workspace = true, default-features = true }
Expand All @@ -40,13 +41,15 @@ std = [
"sp-core/std",
"sp-io/std",
"sp-runtime/std",
"sp-staking/std",
]
runtime-benchmarks = [
"frame-benchmarking/runtime-benchmarks",
"frame-support/runtime-benchmarks",
"frame-system/runtime-benchmarks",
"pallet-balances/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
"sp-staking/runtime-benchmarks",
]
try-runtime = [
"frame-support/try-runtime",
Expand Down
78 changes: 78 additions & 0 deletions substrate/frame/dap/src/benchmarking.rs
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);
}
}
Loading
Loading