Skip to content

Implementation guidance: node admission and queueing policy #446

Closed

Description

@alpergundogdu

Tracking issue for node-side admission and queueing policy — i.e. how a node decides which incoming StreamRequests to accept under congestion, and in what order.

This is out of protocol scope (ADR 003 §Admission and Priority names the two signals nodes have available; the wire format carries no priority bits and the contract surface has no priority-aware entrypoints). Different operators (small home node, CDN-scale, enterprise SLA tier) will tune it differently. The notes below are one workable design for implementors to reference; alternative implementations are acceptable.

Filed in lieu of an appendix — small enough to live as an issue.

Recommended design

A two-lane scheduler keyed on the two protocol-available signals: committed voucher rate (per-stream priority key) and StakingRegistry.stakeOf (binary lane eligibility).

on incoming StreamRequest:
    requester = recover_address_from_voucher_or_binding()
    if voucher.bytes_delta == 0:
        reject(ErrorCode::RateBelowFloor, hint: rate_per_mb_floor)
    committed_rate = voucher.amount_delta / voucher.bytes_delta

    if committed_rate < rate_per_mb_floor:
        reject(ErrorCode::RateBelowFloor, hint: rate_per_mb_floor)

    lane = if StakingRegistry.stakeOf(requester) >= MIN_STAKE { Priority } else { Regular }
    queue = admission_queue[lane]

    if queue.is_full():
        if committed_rate <= queue.lowest_committed_rate():
            reject(ErrorCode::Overloaded, hint: queue.lowest_committed_rate() + epsilon)
        else:
            // Admit; do NOT preempt already-admitted streams.
            admit(StreamRequest)
    else:
        admit(StreamRequest)

Drain order: Priority lane first, Regular lane only when Priority is empty. Within a lane, sort admitted streams by committed_rate descending.

Properties

  • Per-stream. Each StreamRequest is admitted independently against its own committed rate. No per-session, per-connection, or per-client priority state.
  • Admission-time-only. Priority is fixed at admission. Subsequent changes to stakeOf or other inputs do not re-rank in-flight streams.
  • Non-preemptive. Once admitted, a stream runs to completion (or its protocol-level timeout). A late-arriving higher-rate stream does not bump an admitted stream.
  • No waiting queue. A StreamRequest is either admitted or rejected — no pending state. "Starvation forever" is impossible by construction; the worst case is repeated rejection, which is observable client-side and recoverable (retry elsewhere or commit at a higher rate).
  • Reject-with-hint. Rejections carry an actionable next step (rate floor or current admission floor in the relevant lane).
  • Address resolution. Lane eligibility uses the address recovered from the voucher signature or channel.client. The optional ephemeral binding in StreamRequest (ADR 005) is for voucher attribution, not a priority requirement.

Per-client concurrent-stream cap (recommended)

Independent of the lane mechanism, nodes SHOULD apply a per-client concurrent-stream cap (e.g., 10 streams per Ethereum address simultaneously) to prevent a single wealthy client from monopolizing all admission slots. Node-policy parameter; tune to traffic profile. Orthogonal to the per-ALPN concurrent-stream limit (ADR 005).

Variations operators may implement

  • Voucher-rate alone (no priority lane). Simplest.
  • Different lane eligibility — reputation-based, region-based, or a private allow-list for an enterprise SLA tier.
  • Rate-window aging — bump effective priority of a stream waiting at the floor rate. Smooths starvation in heavy-load steady state at the cost of complexity.
  • FCFS at the rate floor with reject-otherwise. Suitable for small home nodes without congestion.
  • Weighted-fair queueing across clients — when per-client fairness is more important than revenue maximization.

References

Activity

  1. added
    kind:docs
    on May 7, 2026
  2. self-assigned this
    on May 22, 2026
  3. yigitdot commented on May 23, 2026

    @yigitdot
    Contributor

    PR #672 (which proposed folding the design above into ADR 003 §Admission and Priority) drew a protocol-layer review from gemini-code-assist. Verifying each comment against ADRs 003, 005, and 014, all three are substantively correct. The design has three issues that I think need addressing before any ADR fold-in.

    1. No voucher at admission

    StreamRequest (ADR 005 §cdn/client/v1, l. 140) carries hash, channel_id, byte_offset, timestamp_us, voucher_interval_mb, and optional ethereum_address / binding_signature. It does not carry a voucher. The first Voucher arrives mid-Streaming, after StreamResponse{ok:true}; ADR 005 (l. 332) explicitly forbids voucher-before-response.

    So the recommended-policy pseudocode line committed_rate = voucher.amount_delta / voucher.bytes_delta is uncomputable at admission time. The committed per-MB rate is a mid-stream signal, not an admission key.

    2. StreamResponse{ok:false} after a positive probe is slashable regardless of error code

    ADR 005 §EvictedSinceProbe semantics is explicit:

    Returning EvictedSinceProbe in a signed StreamResponse with ok: false within the 30-second slashing window still constitutes valid phantom-announcement slash evidence — the error code is unsigned and invisible to the on-chain verifier. Implementations MUST NOT treat this error code as a "safe" way to refuse a stream after a positive probe.

    The same holds for Overloaded and BlobTooLarge (ADR 005 §BlobTooLarge → Probe interaction). The on-chain verifier sees only ok: false; the error field is unsigned. The recommended-policy pseudocode line reject: StreamResponse { ok: false, error: Overloaded } is therefore slashable in the normal probe-then-request flow.

    The protocol's actual congestion mechanism lives at probe time: under load, a node responds has_blob: false (ADR 005 §Probe-triggered eviction hold + §Hold budget). The max_probe_holds budget IS the capacity gate. Bare timeout / non-response is reputation-only and not slashable (ADR 003 §Phantom blob announcement).

    3. Rate hints in signed rate_per_mb are slash evidence

    A StreamResponse carries a signed rate_per_mb whether ok is true or false (ADR 005 slash_sig paragraph; ADR 014). ADR 003 §Rate bait-and-switch: StreamResponse.rate_per_mb > ProbeResponse.rate_per_mb within 30s is on-chain slash evidence. The "Reject-with-hint" property — "the lane's current admission-floor rate" — if placed in that signed field and exceeding the probed rate, is self-incriminating. Any hint must travel in unsigned channels.

    Suggested redesign direction

    Without proposing final wording, the three points above push the design toward:

    • Admission/congestion control at probe time. The lever is whether to sign has_blob: true. The capacity gate is the max_probe_holds hold budget. Stake-lane eligibility can apply to probe-acceptance decisions for requesters whose stake the node can determine — practically, this is node-to-node cache-miss probes (the requester is a registered operator). For end-client probes the eligibility signal needs to be reputation, region, an allow-list, or similar (cf. the existing "Variations" list).
    • Committed voucher rate as a mid-stream scheduling signal, not an admission key. Once the first voucher arrives in Streaming, the rate can influence bandwidth allocation among admitted streams. ADR 003's pre-existing "nodes MAY use the committed rate as a per-stream priority key" reads correctly under this framing — ordering admitted streams, not gating admission.
    • StreamResponse{ok:false} rejection is safe only when no signed has_blob: true probe to that requester for that hash exists within 30s. After a positive probe the node is committed; the only safe non-delivery options are timeout / bare stream close (reputation cost, no slash).
    • Rejection hints, if conveyed, must not be placed in signed StreamResponse fields. Either drop the hint or convey it out-of-band.

    The per-client concurrent-stream cap and the operator-variations list are orthogonal and unaffected.

    PR #672 is being closed; happy to help once a corrected design lands here.

  4. yigitdot commented on Jun 1, 2026

    @yigitdot
    Contributor

    Corrected recommended design

    This supersedes the Recommended design in the issue body. That version keyed admission on committed voucher rate and rejected with StreamResponse{ok:false} — both protocol-incorrect for the reasons in the comment above (and why #672 was closed). The corrected design moves congestion control to probe time and demotes committed rate to a mid-stream signal.

    1. The capacity gate is at probe time

    Under load, the lever is whether to sign has_blob: true. Responding has_blob: false is costless; the max_probe_holds hold budget (ADR 005 §Hold budget) IS the capacity gate. Bare timeout / non-response is reputation-only, not slashable (ADR 003 §Phantom blob announcement).

    A StreamResponse{ok:false} after a positive probe within 30s is phantom-announcement slash evidence regardless of the (unsigned) error code — Overloaded, EvictedSinceProbe, BlobTooLarge are all slashable in the normal probe-then-request flow. So ok:false is never a congestion mechanism. After a positive probe the node is committed; the only safe non-delivery is timeout / bare stream close (reputation cost, no slash).

    on incoming Probe(hash) from requester:
        if not have_or_can_serve(hash):
            return ProbeResponse { has_blob: false }          # costless, not slashable
    
        lane = lane_for(requester)                             # see §2
        if not admit_probe(lane, hash):                        # hold-budget / lane pressure
            return ProbeResponse { has_blob: false }           # decline to commit — costless
    
        hold = acquire_probe_hold(hash)                        # 35s eviction hold (ADR 005)
        if hold.is_none():                                     # max_probe_holds exhausted
            return ProbeResponse { has_blob: false }
        return ProbeResponse { has_blob: true, rate_per_mb }   # commits to serve for 30s
    

    2. Lane eligibility — at probe time

    Stake (CapacityBond.bondOf / StakingRegistry) is determinable only when the requester is itself a registered operator — practically, node-to-node cache-miss probes (where the requester's NodeId↔address binding is on-chain). For those, a node MAY reserve probe-acceptance headroom for bondOf >= bond_required(declared_capacity) requesters.

    For end-client probes there is no stake signal (clients aren't registered). Lane eligibility there must come from reputation, region, or an allow-list (cf. the Variations list).

    3. Committed voucher rate — a mid-stream scheduling signal, not an admission key

    No voucher exists at probe/admission time. Once the first Voucher arrives in Streaming, the node MAY order/bandwidth-allocate already-admitted, in-flight streams by committed rate (amount_delta / bytes_delta) descending. This is the framing under which ADR 003's pre-existing "nodes MAY use the committed rate as a per-stream priority key" reads correctly — ordering admitted streams, not gating admission.

    4. Rejection hints must not ride signed StreamResponse fields

    StreamResponse.rate_per_mb is signed. StreamResponse.rate_per_mb > ProbeResponse.rate_per_mb within 30s is rate-bait-and-switch slash evidence (ADR 003 §Rate bait-and-switch). Any "current admission-floor" hint, if placed there and exceeding the probed rate, is self-incriminating. Convey hints out-of-band, or drop them. (The rate_per_mb floor itself remains conveyable as before; it is the higher-than-probed hint that is unsafe.)

    Unchanged from the original design

    • Per-client concurrent-stream cap — orthogonal; still recommended (e.g. 10 concurrent streams per Ethereum address) to stop a single wealthy client monopolizing slots. Independent of the per-ALPN limit (ADR 005).
    • Variations operators may implement — the full list in the issue body still applies (voucher-rate ordering alone, reputation/region/allow-list lanes, rate-window aging, FCFS-at-floor, weighted-fair queueing).

    Doc status

  5. yigitdot commented on Jun 1, 2026

    @yigitdot
    Contributor

    Follow-up implementation issue: #757 (probe-time stake-lane eligibility in the probe handler). ADR correction: #756.

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

Metadata

Metadata

Assignees

Labels

kind:docsprio:low

Type

No type

Fields

Priority

None yet

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions