Repository navigation
docs(adr): remove client priority staking surface (#402) - #445
Conversation
#402) Closes #402. The original ADR 003 §Client Priority Staking specced a refundable TOKEN deposit (`clientStake`/`clientUnstake`/`clientStakeOf`) as a soft signal nodes could check to prioritize clients during congestion. Working through the four edge cases in #402 surfaced three structural weaknesses: 1. Withdraw-anytime semantics meant the cost of priority was just the opportunity cost of holding TOKEN, so sophisticated clients could cycle a single deposit across many nodes — weak Sybil-resistance signal. 2. Misaligned with revenue: a node prioritizing a high-staker earned the same as serving a low-staker. 3. Marginal value, real surface cost — three contract entrypoints, a storage map, two events, and the off-chain `BindNodeId(nodeId, nonce=0)` ephemeral-binding ceremony in `StreamRequest` whose only consumer was the `clientStakeOf` lookup. This commit dissolves the mechanism. Two signals already in the protocol replace it as an operator-side implementation suggestion: - Committed voucher rate as primary priority key. ADR 003 already verifies `amount_delta / bytes_delta >= rate_per_mb` (a floor, not equality), so clients can commit at higher rates and nodes can sort by committed rate with zero protocol changes. The premium goes to the node as USDC revenue, aligning incentive with prioritization. - Optional staked-peer lane via `StakingRegistry.stakeOf` reads. Reuses the existing 50K TOKEN node-stake bookkeeping (real 7-day unstake commitment), no new contract surface. Admission and queueing policy is operator-defined and lives in a new appendix rather than as protocol-normative ADR text — different operators will tune it differently (small home node vs CDN-scale vs enterprise SLA). Net delta: - Remove §Client Priority Staking from ADR 003. - Remove `clientStake`/`clientUnstake`/`clientStakeOf` + `clientStakes` storage + `ClientStaked`/`ClientUnstaked` events from §StakingRegistry Modifications. - Update ADR 003 §Off-Chain (Ephemeral) Binding — the binding now serves voucher attribution only; the priority-staking framing is dropped, and the row in §Binding Requirements by Role is removed. - Update ADR 003 §NodeId-to-Ethereum Binding lead and §Slashing-Channel separation prose to drop "client priority staking" mentions. - Update ADR 005, 012, 014: drop `clientStakeOf` from binding-cache consumer lists (voucher attribution only). - Update ADR 012: drop the priority-staking client-role bullet and the ephemeral-binding consequence about losing priority on disconnect. - Update ADR 016: remove ClientStaker block from the TOKEN flow Mermaid diagram, drop "client priority stakes" from the funds-summary table, remove `clientStake()`/`clientUnstake()` rows from the function table. - Update ADR 024: drop the "Priority staking" wallet bullet from the Clients section. - New: `adr/appendix-admission-policy.md` documenting voucher-rate-based ordering, optional staked-peer lane via `stakeOf`, non-preemptive admission with reject-and-rate-hint, per-client concurrent-stream cap recommendation, and the four-question dissolution table. - Add new appendix to `adr/architecture.md` §Appendices and `adr/README.md` reading-order book build file list. Wire format unchanged. No ripple to ADR 001/012/022 schemas. Contract surface shrinks (the `client*` functions had no remaining consumer). https://claude.ai/code/session_01V3AAY9Jnsmkqf3xg8c98Ui
There was a problem hiding this comment.
Code Review
This pull request removes the on-chain client priority staking mechanism across several ADRs and introduces a new appendix defining a node-side admission and priority policy. The new policy utilizes committed voucher rates and registered node-stake as signals for handling congestion. Review feedback suggests removing historical narratives and iteration details from the documentation to maintain a clean record of the current design, and recommends adding a check for division-by-zero in the admission policy pseudo-code.
| [ADR 003](003-payments.md) specifies the per-MB voucher payment mechanism but does not say how a node decides which `StreamRequest` to admit when its concurrent-stream limit, bandwidth, or backend capacity is saturated. Earlier drafts of ADR 003 included a `clientStake` / `clientStakeOf` mechanism — a refundable TOKEN deposit a client could make to be prioritized during congestion. That mechanism was removed (see #402) for three structural weaknesses: | ||
|
|
||
| 1. Withdraw-anytime semantics meant the cost of priority was just opportunity cost of holding TOKEN — sophisticated clients could cycle a single deposit across many nodes. | ||
| 2. The signal was misaligned with revenue: a node prioritizing a high-staker earned the same as serving a low-staker. | ||
| 3. It added contract surface (three entrypoints, a storage map, two events) and a wire-level binding ceremony for marginal value. |
There was a problem hiding this comment.
This section contains historical narrative regarding the removal of the clientStake mechanism. According to the general rules, canonical documentation (like ADRs and their appendices) should maintain a clean record of the current design. Historical context, iteration details, or information about dropped features should reside in issue discussions or merge commit messages rather than the documentation itself.
References
- Avoid including historical narratives, iteration details, or information about dropped features in canonical documentation (e.g., ADRs). Such context should reside in issue discussions or merge commit messages to maintain a clean record of the current design.
| ``` | ||
| on incoming StreamRequest: | ||
| requester = recover_address_from_voucher_or_binding() | ||
| committed_rate = voucher.amount_delta / voucher.bytes_delta |
There was a problem hiding this comment.
The pseudo-code calculation for committed_rate does not account for a potential division by zero if voucher.bytes_delta is zero. While this is an appendix, ensuring the logic is robust prevents implementation errors.
| committed_rate = voucher.amount_delta / voucher.bytes_delta | |
| committed_rate = if voucher.bytes_delta > 0 { voucher.amount_delta / voucher.bytes_delta } else { 0 } |
| - [ADR 003](003-payments.md) — payment channels, voucher format, `rate_per_mb` floor semantics | ||
| - [ADR 005](005-protocol.md) — `StreamRequest` / `StreamResponse` / voucher wire format, per-ALPN concurrent-stream limits | ||
| - [ADR 026 §7](026-gauge-boost-tokenomics.md#7-operator-economics-and-minimum-stake) — `MIN_STAKE = 50,000 TOKEN`, 7-day unstake delay | ||
| - Issue #402 — original ADR-gap discussion, closed as decided-against |
There was a problem hiding this comment.
This reference to Issue #402 includes historical narrative about the decision-making process ('closed as decided-against'). Per the general rules, such context should be omitted from canonical documentation to maintain a clean record of the current design. If this section is intended to document a rejected alternative, it should describe the design and the reasoning ('what and why') without invoking the iteration narrative.
References
- Avoid including historical narratives, iteration details, or information about dropped features in canonical documentation (e.g., ADRs). Such context should reside in issue discussions or merge commit messages to maintain a clean record of the current design.
- When documenting rejected alternatives in a canonical record, describe the rejected design unambiguously without invoking deleted or superseded files. The purpose of such a section is to explain 'what was rejected and why', not to maintain an iteration narrative.
- §Context: drop iteration narrative about removed clientStake mechanism; describe admission policy as a node-side scheduling concern in positive form. - Pseudocode: guard against bytes_delta == 0 before computing committed_rate to avoid divide-by-zero in implementations. - Drop §"How this resolves the prior #402 questions" — the useful semantic invariants (per-stream, admission-time-only, address resolution) are folded into §Properties; the rest was iteration narrative that belongs in the issue and commit messages, not the canonical appendix. - §References: drop the #402 entry; the issue tracker is the wrong consumer for canonical cross-references. Per CLAUDE.md / adr/README.md: ADRs and appendices read as the canonical specification, not as an iteration log. https://claude.ai/code/session_01V3AAY9Jnsmkqf3xg8c98Ui
Per discussion on PR #445: the appendix carries too little canonical content to justify its own file. Detailed implementation guidance (two-lane scheduler pseudocode, non-preemptive admission, per-client cap, variations) lives in #446 instead — that's the right granularity for operator-facing implementation suggestions. ADR 003 §Admission and Priority retains a tight description of the two protocol-available signals (committed voucher rate as floor-not- equality, and StakingRegistry.stakeOf for optional lane eligibility) since that information is genuinely about the protocol surface, not about scheduling policy. Reverts: - Delete adr/appendix-admission-policy.md - Revert architecture.md §Appendices entry - Revert adr/README.md reading-order book build file list https://claude.ai/code/session_01V3AAY9Jnsmkqf3xg8c98Ui
Closes #402.
Summary
The original ADR 003 §Client Priority Staking specced a refundable TOKEN deposit (
clientStake/clientUnstake/clientStakeOf) as a soft signal nodes could check to prioritize clients during congestion. Working through the four edge cases in #402 surfaced three structural weaknesses:BindNodeId(nodeId, nonce=0)ephemeral-binding ceremony inStreamRequestwhose only consumer was theclientStakeOflookup.This PR dissolves the mechanism. ADR 003's new §Admission and Priority section names the two protocol-available signals nodes can use for any admission policy (committed voucher rate, plus optional
StakingRegistry.stakeOfreads for a staked-peer lane), but leaves the policy itself out of protocol scope — admission and queueing are node-side scheduling concerns, and different operators (small home node, CDN-scale, enterprise SLA tier) will tune them differently.Detailed implementation guidance (two-lane scheduler pseudocode, non-preemptive admission with reject-and-rate-hint, per-client concurrent-stream cap, variations operators may implement) is filed as #446 rather than as a canonical appendix — small enough to live in an issue, and the issue tracker is the right consumer for operator-facing implementation suggestions.
Files changed
ADR 003 (
adr/003-payments.md)clientStake/clientUnstake/clientStakeOf+clientStakesstorage +ClientStaked/ClientUnstakedevents from §StakingRegistry ModificationsstakeOflookup) without prescribing scheduling policyOther ADRs
adr/005-protocol.md: dropclientStakeOffrom the §Client identity binding consumer listadr/012-client.md: drop the priority-staking client-role bullet, dropclientStakeOffrom the §Identity Lifecycle session step, drop the ephemeral-binding consequence about losing priority on disconnectadr/014-on-chain-verification.md: dropclientStakeOffrom the binding-cache consumer noteadr/016-contract-interactions.md: removeClientStakerblock from the TOKEN flow Mermaid diagram, drop "client priority stakes" from the funds-summary table, removeclientStake()/clientUnstake()rows from the StakingRegistry function tableadr/024-account-abstraction.md: drop the "Priority staking" wallet bullet from the Clients sectionNo new appendix. The earlier draft of this PR added
adr/appendix-admission-policy.mdplus listing entries inadr/architecture.mdandadr/README.md; those were reverted in favour of #446 carrying the implementation guidance.Wire / contract / schema impact
StreamRequest/StreamResponseephemeral-binding fields stay (now described as "voucher attribution" only).clientStake/clientUnstake/clientStakeOfhad no remaining consumer after the priority mechanism was demoted.NodeInfo, noservesflag, no ADR 012 bootstrap change, no ADR 022 origin-discovery change.Test plan
markdownlint --dotclean on all touched files (verified locally)clientStake/clientUnstake/clientStakeOf/ClientStaker/ClientStaked/ClientUnstaked/client priorityreferences anywhere inadr/(verified withgrep)pre-commit run --all-files(binary not available locally — will run in CI)[ADR 005](005-protocol.md#client-identity-binding)from ADR 003 §Off-Chain Binding resolves to the existing §Client identity binding section;[ADR 026 §7](026-gauge-boost-tokenomics.md#7-operator-economics-and-minimum-stake)from §Admission and Priority resolvesNotes
The
servesflag / mesh-pollution concern raised earlier in design discussion is intentionally not in scope here. Clients who want priority-via-stake do so by registering as a node (existing path), and the question of whethergetActiveNodes()should filter such addresses is orthogonal to this change. If we later want to filter, that's a separate ADR 001 schema change.https://claude.ai/code/session_01V3AAY9Jnsmkqf3xg8c98Ui