Skip to content

Simplify ADR 027: drop DeliveryReceipt primitive, compute distinct-client diversity directly from settled vouchers #486

Closed

Description

@alpergundogdu

Background

ADR 027 introduces a DeliveryReceipt primitive paired 1:1 with each voucher, plus an MMR aggregator on FeeRouter, plus a submitReceiptFraudChallenge entry point on SlashJudge, plus an OffenseType.ReceiptFraud enum value, plus a 7-day challenge window, plus identity-diversity rules, plus cold-start exceptions, plus reputation gating — all to defend the gauge bucket against wash-trading per ADR 026 §Risks.

The wash-trading attack is real (gauge boost is core to the tokenomics, see ADR 026 §3), so the defense itself needs to stay. But the receipt primitive is largely redundant with the existing Voucher.

The redundancy

Required signal for diversity gating ADR 027 source Already available without receipts
Identity of paying party receipt.clientPubKey (signed) channel.client (set at openChannel, stored in contract)
Bytes attributable to that party receipt.bytesClaimed (signed) voucher.bytesDelivered (signed by same key)
Operator identity receipt.operatorAddress (signed) channel.provider (stored at openChannel)
Epoch attribution receipt.epochId (signed) settlement block timestamp, or add one epochId field to Voucher

The DeliveryReceipt typedef commits to the same field set the Voucher already commits to, signed by the same key.

Proposed simplification

Compute distinct-client diversity directly from settled-voucher state inside FeeRouter:

mapping(address operator => mapping(uint64 epoch => uint256)) public distinctClientCount;
mapping(address operator => mapping(uint64 epoch => mapping(address client => bool))) seen;
mapping(address operator => mapping(uint64 epoch => uint256)) public bytesPerEpoch;

// Inside settleChannel:
uint64 ep = epochOf(voucher);
address c = channel.client;
address op = channel.provider;
if (!seen[op][ep][c]) {
    seen[op][ep][c] = true;
    distinctClientCount[op][ep] += 1;
}
bytesPerEpoch[op][ep] += voucher.bytesDelivered;

At gauge claim time:

require(distinctClientCount[operator][epoch] >= MIN_DISTINCT_CLIENTS_PER_EPOCH);
uint256 bytes_i = bytesPerEpoch[operator][epoch];

Per-settlement gas: ~+25k (2 SLOADs + 1–2 SSTOREs).

What this removes

  • DeliveryReceipt EIP-712 typedef
  • Per-voucher requester-side extra signature
  • FeeRouter MMR aggregator (peaks + leafCount per (operator, epoch))
  • commitEpochReceiptRoot + commitEpochSummary keeper jobs
  • OffenseType.ReceiptFraud from ADR 014 enum
  • submitReceiptFraudChallenge entry point from SlashJudge
  • Bond economics for receipt-fraud challenges
  • 7-day challenge window state machine
  • Privacy regression on challenge (per-receipt clientPubKey exposure)
  • Funding-source diversity heuristic (kept as off-chain advisory if useful, but no longer load-bearing)

ADR 027 collapses from ~423 lines to ~80–120 lines.

What this keeps

  • MIN_DISTINCT_CLIENTS_PER_EPOCH threshold (default 5, governable)
  • Funded-channel minimum + funding age gates
  • Per-operator cooldown (a client identity counts at most once per IDENTITY_COOLDOWN)
  • Reputation-gated stricter thresholds (§6) — applied to thresholds, not to a new primitive
  • Cold-start exception (gaugeBootstrapEpochs)
  • enableGauge() launch prerequisite

Trade-offs

  • Epoch attribution at settlement, not delivery. For 90-day long-lived channels, bytes are credited to the settlement epoch rather than the delivery epoch. Mitigations: short voucher cadence (already exists), encourage epoch-boundary settlement, or extend Voucher with epochId for per-voucher attribution at settlement.
  • No "operator commits per-epoch summary" point. Gauge accrual is tied to settlement; long-channel operators face delayed gauge claim. Acceptable cost given the surface removed.
  • Funding-source diversity loses its dedicated home. Still doable off-chain, just not bonded under a formal fraud-challenge surface. The ADR §3 already calls it advisory and not cryptographically enforced.

Why this is safe

The on-chain diversity count is computed directly by FeeRouter from settled-voucher state — the operator never asserts a "summary" that could be a lie. There's nothing to challenge because there's nothing to forge: vouchers are already signed by channel.client (bound at openChannel), and the contract enforces uniqueness via the seen map.

Cascading changes

  • ADR 014: drop OffenseType.ReceiptFraud, drop submitReceiptFraudChallenge from ABI
  • ADR 016: drop submitReceiptFraudChallenge from contract diagram + function table; add FeeRouter per-settlement bookkeeping
  • ADR 026 §Risks: update wash-trading defense cross-ref to point at FeeRouter diversity counting
  • ADR 008 §3 (if it references receipt-fraud) — verify and update
  • appendix-fraud-detection.md: drop receipt-fraud challenger flow

🤖 Generated with Claude Code

Activity

  1. alpergundogdu commented on May 8, 2026

    @alpergundogdu
    ContributorAuthor

    Adding to scope: per-operator gauge-share cap, 5% default, governable.

    Defense-in-depth alongside the diversity gate. Even if a sophisticated attacker bypasses the funding-source diversity heuristic and funds N Sybils through mixers, the gauge upside is bounded at 5% of the total bucket per operator regardless of claimed bytes. This caps the wash-trading payoff to a known maximum and shifts the attack ROI calculation decisively toward unprofitable.

    Implementation: a single multiplicative cap inside ADR 026 §3 gauge formula. Trivial gas, ~2 lines of Solidity. Governable via ADR 009 safety bounds, e.g. [1%, 25%].

    Will land in the same PR as the diversity-counting simplification.

  2. alpergundogdu commented on May 8, 2026

    @alpergundogdu
    ContributorAuthor

    Scope expanded mid-PR after the wash-trading economic analysis (now in internal/ideas/wash-trading-economics.md) showed that the diversity gate is redundant with the per-operator gauge-share cap.

    Walked through the math:

    • The cap-binding self-deal threshold (~$21k/yr per operator with full ve-boost, ~$52k/yr without) is independent of the diversity gate. Whether the attacker uses 1 fake client or 5, the cap binds at the same volume and bounds extraction at 5% of the gauge bucket per operator-identity.
    • The diversity gate's marginal Sybil-cost contribution is $40 per attack operator (5 × 10 USDC vs 1 × 10 USDC channel deposits). Negligible against the dominant cost (50k TOKEN operator stake).
    • The "diverse client base" tokenomics signal the gate encoded was contestable — legitimate operators with concentrated client bases (single-enterprise CDN customers, dedicated-publisher origin nodes) would be excluded from gauge despite being honest. Diversity-of-service is captured better as a reputation signal off-chain than as an on-chain hard gate.

    So PR #488 was retargeted from "simplify ADR 027" to "delete ADR 027 entirely":

    • ADR 027 file deleted; number 027 reclaimed per the same pattern as 029/030/031/032 in CLAUDE.md
    • bytesPerEpoch storage map lives canonically in ADR 016 (FeeRouter)
    • Voucher.epochId field lives canonically in ADR 003
    • Per-operator gauge-share cap (5%, governable [1%, 25%]) lives canonically in ADR 026 §3
    • Launch prerequisite + enableGauge() lives canonically in ADR 026 §2
    • ADR 008 §12 rewritten as off-chain wash-trading signal (operator-cluster detection, governance cap-tuning input) rather than as a hard gauge-eligibility gate
    • 4 governance parameters dropped: MIN_DISTINCT_CLIENTS_PER_EPOCH, MIN_CHANNEL_FUNDING_USDC, MIN_CLIENT_AGE, IDENTITY_COOLDOWN
    • 2 FeeRouter storage maps dropped: distinctClientCount, _seenClient
    • StablePaymentChannel.lifetimeDepositOf() view removed (had no consumer outside the diversity gate)
    • summaryWindow / challengeWindow governable parameters from ADR 026 §11 dropped
    • MMR retention buffer from ADR 009 dropped

    Net diff: 14 files, +46 / −311 (~−265 lines). Closing this issue when PR #488 merges.

    🤖 Generated with Claude Code

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Fields

Priority

None yet

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions