Skip to content

ADR gap: client priority staking edge-case semantics #402

Closed

Description

@alpergundogdu

Gap

ADR 003 § Client Priority Staking specifies the basic mechanic — clientStake / clientUnstake, no minimum, no slashing, no unbonding period, off-chain enforcement — but leaves several edge cases implicit:

  1. Mid-session stake changes. A client raises their stake mid-stream. Does the node's priority queue re-evaluate immediately, at the next chunk boundary, or only on next StreamRequest? Symmetric question for stake reductions.
  2. In-flight behavior on clientUnstake. The withdraw-anytime semantics implies a stake can drop to zero while a stream is active. Does the node demote in-flight streams, allow them to complete, or is this a node-policy decision (and if so, should the protocol surface that variability)?
  3. Priority granularity. Per-stream, per-session, or per-connection? Affects how nodes compute the priority key and whether multiple parallel streams from the same client share a single priority slot.
  4. Ephemeral binding interaction. ADR 003 supports clients with no on-chain registration via an ephemeral BindNodeId(nodeId, nonce=0) in StreamRequest. Are ephemeral-bound clients eligible for priority lookup, or does priority require a persistent registration?

Refs

  • ADR 003 — defines the on-chain clientStake/clientUnstake surface and ephemeral binding path
  • ADR 016 — StakingRegistry clientUnstake() "anytime" without conditions

Why it needs an ADR

These are the kind of unspecified edges where well-meaning implementations diverge silently. A short ADR (or extension to ADR 003) defining the four behaviors above would prevent priority-handling bugs in node implementations.

Origin

Split out from #190 (gap 11) as a standalone tracking issue.

Activity

  1. added
    kind:docs
    design:economics
    design:missing-decision
    design:adr
    prio:medium
    on May 5, 2026
  2. alpergundogdu commented on May 7, 2026

    @alpergundogdu
    ContributorAuthor

    Decision: dissolve, don't extend

    After working through the four edge cases, the cleaner answer turned out to be: client priority staking shouldn't be in the protocol at all. The four gaps in this issue dissolve once admission and queueing become an operator-side implementation concern instead of a protocol-normative mechanism.

    Rationale

    The original mechanism (refundable TOKEN deposit → soft signal during congestion) had three structural weaknesses:

    1. Withdraw-anytime semantics meant the cost of priority was just opportunity cost of holding TOKEN — sophisticated clients can cycle a single deposit across many nodes, so the Sybil-resistance signal is weak.
    2. Misaligned with revenue. A node prioritizing a high-staker earns the same as serving a low-staker. The protocol is asking nodes to bear a congestion-management cost without any economic alignment.
    3. Marginal value, real surface cost — three contract entrypoints, a storage map, two events, and the off-chain BindNodeId(nodeId, nonce=0) ceremony in StreamRequest whose only consumer was the clientStakeOf lookup.

    What replaces it

    Two signals that already exist in the protocol, repurposed as an operator-side implementation suggestion, not a protocol obligation:

    • Voucher-rate as primary signal. ADR 003 already verifies amount_delta / bytes_delta >= rate_per_mb — the advertised rate is a floor, not equality. Clients are free to commit at higher rates today; nodes can sort the admission queue by committed voucher rate desc with zero protocol changes. The cost of priority becomes real per-MB premium paid in USDC, aligned with node revenue.
    • Optional staked-peer lane via StakingRegistry.stakeOf reads. Nodes that wish to favour staked peers (node-to-node cache pulls, registered "priority client" addresses) can lift them into a higher-priority lane via a single contract read. No new contract surface — the lookup uses the existing node-stake bookkeeping with its 7-day unstake delay (real commitment, not refundable-anytime).

    Why an appendix and not an ADR

    Different operators will run different admission policies — a small home node, a CDN-scale operator, and an enterprise SLA tier all have different appetites for fairness vs. revenue, different concurrent-stream caps, different starvation tolerances. Pinning a single policy as protocol-normative would either (a) freeze a bad default or (b) be ignored. The appendix frames it as a workable design operators MAY adopt, with the four gaps in this issue addressed inline:

    • Mid-session stake changes: N/A — admission-time only by construction.
    • In-flight on clientUnstake: N/A — no client-stake surface, and node-side admission is non-preemptive (already-admitted streams complete normally).
    • Priority granularity: per-stream — admission queue sorts each StreamRequest independently.
    • Ephemeral binding eligibility: N/A — ephemeral binding is removed (it was only there to feed clientStakeOf).

    Net delta

    • ADR 003: remove §Client Priority Staking, §Off-Chain (Ephemeral) Binding for Clients, the "Client (priority staking)" row from the binding-requirements table, and the clientStake/clientUnstake/clientStakeOf + clientStakes storage + ClientStaked/ClientUnstaked events from §StakingRegistry Modifications. One-line pointer to the new appendix.
    • New: adr/appendix-admission-policy.md covering voucher-rate-based ordering, optional staked-peer lane, non-preemptive admission with reject-and-rate-hint, and per-client concurrent-stream cap as a SHOULD.
    • Contract surface: shrinks (the client* functions and storage are removed since they had no remaining consumer).
    • Wire format: unchanged.
    • No ripple to ADR 001/012/022 — no NodeInfo schema change, no serves flag.

    PR incoming.


    Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

design:adrdesign:economicsdesign:missing-decisionkind:docsprio:medium

Type

No type

Fields

Priority

None yet

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions