Skip to content

[Staking] Add issuance and budget traits in prep for Budget Split#11513

Merged
Ank4n merged 15 commits intomasterfrom
ankn-sp-staking-traits
Mar 31, 2026
Merged

[Staking] Add issuance and budget traits in prep for Budget Split#11513
Ank4n merged 15 commits intomasterfrom
ankn-sp-staking-traits

Conversation

@Ank4n
Copy link
Copy Markdown
Contributor

@Ank4n Ank4n commented Mar 26, 2026

Overview

Moves EraPayout trait to sp-staking and adds new traits for issuance, budget distribution, and reward calculation.

Extracted changes from the main PR: #10844
Also see: #11512

Changes

sp-staking

  • EraPayout: moved from pallet-staking and pallet-staking-async to sp-staking, eliminating the duplicate definitions.
  • budget module: stake independent traits:
    • IssuanceCurve: successor to EraPayout, computes issuance from total supply + elapsed time (no staking state dependency).
    • BudgetRecipient / BudgetRecipientList: register pot accounts for inflation distribution. Runtime wires as a tuple.
    • BudgetKey: bounded identifier for budget categories.
  • StakerRewardCalculator: trait for calculating validator incentive weights and staker reward splits.

pallet-staking / pallet-staking-async

  • Removed local EraPayout definitions, re-exported from sp-staking.

Comment thread substrate/frame/staking-async/src/lib.rs
///
/// [`budget::IssuanceCurve`] is the successor to this trait, decoupling issuance computation
/// from staking state.
pub trait EraPayout<Balance> {
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.

Will be deprecated in the following PR

@Ank4n Ank4n marked this pull request as ready for review March 27, 2026 06:35
@Ank4n Ank4n requested a review from a team as a code owner March 27, 2026 06:35
@Ank4n Ank4n changed the title Traits in prep for Budget Split [Staking] New traits in prep for Budget Split Mar 27, 2026
@Ank4n Ank4n added the T2-pallets This PR/Issue is related to a particular pallet. label Mar 27, 2026
@Ank4n Ank4n changed the title [Staking] New traits in prep for Budget Split [Staking] Add issuance and budget traits in prep for Budget Split Mar 27, 2026
Comment thread substrate/primitives/staking/src/lib.rs Outdated
/// Result of staker reward calculation.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct StakerRewardResult<Balance> {
/// Total payout for the validator (staking reward + commission).
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
/// Total payout for the validator (staking reward + commission).
/// Total payout for the validator (self-stake incentive + commission).

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.

Its not self-stake incentive, but the reward based on their self stake from the stakers pot (shared with nominators).

/// Calculate the reward weight for a validator based on their self-stake.
///
/// Used for distributing validator self-stake incentive rewards proportionally.
fn calculate_validator_incentive_weight(self_stake: Balance) -> Balance;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Without any implementation yet, can you document how these two are meant to be used?

I think I figured it out last time by looking at the code, but have forgotten again, and not intuitive enough (= I am not smart enough) to reverse-engineer 🙈

I am not sure what is this weight + how it related to the validator_payout part of StakerRewardResult. It seems like our flow for validators and nominators are different, while they should not be?

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.

improved the doc, hopefully more now? 946ff6a

This trait combines staker reward split and incentive weight calculation. Could argue to split it as well, but a runtime can always create a custom impl that delegates to different strategies internally, so I think this is fine.

tldr for incentive weight: every validator gets reward proportional to their_weight / total_weight.

Copy link
Copy Markdown
Contributor

@kianenigma kianenigma left a comment

Choose a reason for hiding this comment

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

LGTM though seeing these traits independent and without any impl made me think a bit more if they are intuitive or not.

Comment thread substrate/primitives/staking/src/budget.rs
Ank4n added a commit that referenced this pull request Mar 31, 2026
@Ank4n Ank4n enabled auto-merge March 31, 2026 11:03
Comment thread prdoc/pr_11513.prdoc
- name: pallet-staking
bump: patch
- name: pallet-staking-async
bump: patch
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Contributor Author

@Ank4n Ank4n Mar 31, 2026

Choose a reason for hiding this comment

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

its moved to sp-staking and re-exported from the crates where it was removed. So should not break anything, right? Or am I missing something?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I believe you're right but I don't think check-semver is too smart to catch it 😅 Now, it's not a mandatory job to merge, but will require some attention if (hopefully not) it doesn't make the cut for 2604. Do nothing or validate:false might be an option as well

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.

Don't wanna retrigger CI (it takes forever 😂 )
pallet_staking_async will bump to major in the following PRs. But I can keep an eye on this.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

totally fine by me - let's all 🙏 that CI Gods are gentle with us and we can merge now finally 😄

@Ank4n Ank4n added this pull request to the merge queue Mar 31, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Mar 31, 2026
@Ank4n Ank4n enabled auto-merge March 31, 2026 14:04
@Ank4n Ank4n added this pull request to the merge queue Mar 31, 2026
Merged via the queue into master with commit 129a48a Mar 31, 2026
351 of 430 checks passed
@Ank4n Ank4n deleted the ankn-sp-staking-traits branch March 31, 2026 18:48
github-merge-queue Bot pushed a commit that referenced this pull request Mar 31, 2026
Stacked on #11513. 
Extracted from #10844.

## Overview

Adds issuance drip and budget distribution to `pallet-dap`. DAP becomes
a generic inflation engine: it mints new tokens on a configurable
cadence and distributes them to registered budget recipients.

No runtime behavior change: the existing chain configuration continues
to mint via `EraPayout` trait in staking. DAP can be configured as a
noop (cadence = 0 or empty budget).

## Changes

### pallet-dap
- **Issuance drip**: `drip_issuance()` runs in `on_initialize`. Computes
mint amount via `IssuanceCurve` (total issuance + elapsed time) and
distributes to `BudgetRecipient`s per a governance-updatable
`BudgetAllocation` map that must sum to 100%.
- **Safety guards**: `MaxElapsedPerDrip` ceiling prevents over-minting
if the chain stalls. First-block initialization skips drip to avoid
minting for an unknown period.
- **Buffer accounting**: buffer's share is deactivated on inflow (mint +
`OnUnbalanced` slashes).
- **`set_budget_allocation`** extrinsic (root-only): validates keys
match registered recipients and percentages sum to exactly 100%.
- **`BudgetRecipient` impl**: DAP exposes its buffer as a recipient
(key: `"buffer"`).
- **Migration**: `MigrateV1ToV2` seeds `LastIssuanceTimestamp` and
`BudgetAllocation` for existing chains. Not wired up in WAH or other
runtimes yet.

## TODOs
- [x] Wire benchmark weights.

## In Later PR
- Revert [these
changes](9b388b2)

---------

Co-authored-by: Paolo La Camera <paolo@parity.io>
lexnv added a commit that referenced this pull request Apr 1, 2026
Squashed commit of the following:

commit 1b3ad0b
Author: Alexandru Vasile <alexandru.vasile@parity.io>
Date:   Wed Apr 1 10:55:36 2026 +0000

    Adjust metrics

    Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

commit 61d37db
Author: Alexandru Vasile <alexandru.vasile@parity.io>
Date:   Wed Apr 1 09:58:38 2026 +0000

    metrics: Bump some other buckets

    Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

commit ab2a221
Author: Alexandru Vasile <alexandru.vasile@parity.io>
Date:   Wed Apr 1 09:57:11 2026 +0000

    collator-proto/metrics: Fix blindspot in collation fetch latency metrics

    Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

commit 0d6888a
Author: Ankan <10196091+Ank4n@users.noreply.github.com>
Date:   Wed Apr 1 00:18:21 2026 +0200

    Implement Budget Distribution logic in pallet-dap (#11527)

    Stacked on #11513.
    Extracted from #10844.

    ## Overview

    Adds issuance drip and budget distribution to `pallet-dap`. DAP becomes
    a generic inflation engine: it mints new tokens on a configurable
    cadence and distributes them to registered budget recipients.

    No runtime behavior change: the existing chain configuration continues
    to mint via `EraPayout` trait in staking. DAP can be configured as a
    noop (cadence = 0 or empty budget).

    ## Changes

    ### pallet-dap
    - **Issuance drip**: `drip_issuance()` runs in `on_initialize`. Computes
    mint amount via `IssuanceCurve` (total issuance + elapsed time) and
    distributes to `BudgetRecipient`s per a governance-updatable
    `BudgetAllocation` map that must sum to 100%.
    - **Safety guards**: `MaxElapsedPerDrip` ceiling prevents over-minting
    if the chain stalls. First-block initialization skips drip to avoid
    minting for an unknown period.
    - **Buffer accounting**: buffer's share is deactivated on inflow (mint +
    `OnUnbalanced` slashes).
    - **`set_budget_allocation`** extrinsic (root-only): validates keys
    match registered recipients and percentages sum to exactly 100%.
    - **`BudgetRecipient` impl**: DAP exposes its buffer as a recipient
    (key: `"buffer"`).
    - **Migration**: `MigrateV1ToV2` seeds `LastIssuanceTimestamp` and
    `BudgetAllocation` for existing chains. Not wired up in WAH or other
    runtimes yet.

    ## TODOs
    - [x] Wire benchmark weights.

    ## In Later PR
    - Revert [these
    changes](9b388b2)

    ---------

    Co-authored-by: Paolo La Camera <paolo@parity.io>

commit 8b53323
Author: Javier Viola <363911+pepoviola@users.noreply.github.com>
Date:   Tue Mar 31 21:26:58 2026 +0200

    bump zombienet version to v0.4.9 (#11569)

    This version move the internal monitor to a diff log target, eliminating
    the current spam of tracing logs.

    Thx!

    ---------

    Co-authored-by: Bastian Köcher <git@kchr.de>

commit 129a48a
Author: Ankan <10196091+Ank4n@users.noreply.github.com>
Date:   Tue Mar 31 19:06:21 2026 +0200

    [Staking] Add issuance and budget traits in prep for Budget Split (#11513)

    # Overview

    Moves `EraPayout` trait to `sp-staking` and adds new traits for
    issuance, budget distribution, and reward calculation.

    Extracted changes from the main PR: #10844
    Also see: #11512

    ## Changes

    ### sp-staking
    - `EraPayout`: moved from `pallet-staking` and `pallet-staking-async` to
    `sp-staking`, eliminating the duplicate definitions.
    - `budget` module: stake independent traits:
    - `IssuanceCurve`: successor to `EraPayout`, computes issuance from
    total supply + elapsed time (no staking state dependency).
    - `BudgetRecipient` / `BudgetRecipientList`: register pot accounts for
    inflation distribution. Runtime wires as a tuple.
      - `BudgetKey`: bounded identifier for budget categories.
    - `StakerRewardCalculator`: trait for calculating validator incentive
    weights and staker reward splits.

    ### pallet-staking / pallet-staking-async
    - Removed local `EraPayout` definitions, re-exported from `sp-staking`.

    ---------

    Co-authored-by: Paolo La Camera <paolo@parity.io>

commit 10a517e
Author: Dmitry Markin <dmitry@markin.tech>
Date:   Tue Mar 31 18:37:01 2026 +0300

    Implement `bitswap_v1_get` RPC method (#11521)

    Implement `bitswap_v1_get` RPC method according to the
    [spec](https://github.com/paritytech/json-rpc-interface-spec/blob/main/src/api/bitswap_v1_get.md).

    ---------

    Co-authored-by: cmd[bot] <41898282+github-actions[bot]@users.noreply.github.com>
    Co-authored-by: Lukasz Rubaszewski <117115317+lrubasze@users.noreply.github.com>

commit 2c99855
Author: Paolo La Camera <paolo@parity.io>
Date:   Tue Mar 31 16:42:03 2026 +0200

    Fix can_inc_consumer check blocking session key rotation in pallet_session (#11573)

    Check consumer capacity only when we actually increment the consumer
    count (first-time local registration or external-to-local transition),
    not on key rotation.

    Notes:
    1. setting keys via `stakingRcClient` didn't suffer of this issue since
    by-pass `do_set_keys()`
    2. setting and purging keys via session pallet directly on RC is
    deprecated and will be removed soon - but better safe than sorry till
    then

    ---------

    Co-authored-by: cmd[bot] <41898282+github-actions[bot]@users.noreply.github.com>

commit de0a245
Author: Luka Ciric <luka.ciric2106@gmail.com>
Date:   Tue Mar 31 16:39:48 2026 +0200

    Raise offence queue eras bound limit (#11435)

    Fixes a bug where **OffenceQueueEras** bound (BondingDuration) was
    incorrect when `SlashDeferDuration=0`. The oldest reportable offence era
    formula allowed more eras than the bound could hold.

    ---------

    Co-authored-by: cmd[bot] <41898282+github-actions[bot]@users.noreply.github.com>
    Co-authored-by: Ankan <10196091+Ank4n@users.noreply.github.com>

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
franciscoaguirre pushed a commit that referenced this pull request Apr 7, 2026
…1513)

# Overview

Moves `EraPayout` trait to `sp-staking` and adds new traits for
issuance, budget distribution, and reward calculation.

Extracted changes from the main PR: #10844 
Also see: #11512

## Changes

### sp-staking
- `EraPayout`: moved from `pallet-staking` and `pallet-staking-async` to
`sp-staking`, eliminating the duplicate definitions.
- `budget` module: stake independent traits:
- `IssuanceCurve`: successor to `EraPayout`, computes issuance from
total supply + elapsed time (no staking state dependency).
- `BudgetRecipient` / `BudgetRecipientList`: register pot accounts for
inflation distribution. Runtime wires as a tuple.
  - `BudgetKey`: bounded identifier for budget categories.
- `StakerRewardCalculator`: trait for calculating validator incentive
weights and staker reward splits.

### pallet-staking / pallet-staking-async
- Removed local `EraPayout` definitions, re-exported from `sp-staking`.

---------

Co-authored-by: Paolo La Camera <paolo@parity.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

T2-pallets This PR/Issue is related to a particular pallet.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants