Repository navigation
docs(adr): drop ADR 027 — wash-trading defense is the per-operator gauge cap alone - #488
Conversation
…eceipt primitive + per-operator gauge cap Wash-trading defense for the gauge bucket previously used a parallel DeliveryReceipt primitive (EIP-712 typedef per voucher window), an MMR aggregator on FeeRouter, an OffenseType.ReceiptFraud entry on SlashJudge, a 7-day fraud-challenge window with bond economics, and ~3 KB of audit surface. The receipt's signed field set was fully redundant with the voucher's (same signer = channel.client, same bytes, same channel, same operator). Replaces the entire mechanism with two storage maps + an inline check inside FeeRouter.routeSettlement: - distinctClientCount[operator][epoch] - bytesPerEpoch[operator][epoch] - _seenClient[operator][epoch][client] for idempotency Diversity threshold is enforced at gauge-claim time against these contract-computed views. There's no operator-asserted summary, so nothing to forge and no fraud-challenge mechanism needed. Adds defense-in-depth via ADR 026 §3: a per-operator gauge-share cap (MAX_GAUGE_SHARE_PER_OPERATOR, default 5%, governable [1%, 25%]) bounding wash-trading payoff regardless of Sybil sophistication. ADR 027 collapses from 423 lines to 215 lines (-50%). Cascading changes: - ADR 003: Voucher gains epochId field (Tier 3 schema break, bundled with enableGauge() cutover); routeSettlement signature extended to carry channel.client + epochId - ADR 008: footnote no longer claims receipt-fraud as the deterrent - ADR 014: drop OffenseType.ReceiptFraud, drop submitReceiptFraudChallenge, drop ABI for the entry point - ADR 016: contract diagram + function table reflect the new routeSettlement signature; drop CorruptionChallenger / receipt-fraud row; drop EpochReceiptSummary + commit* signatures - ADR 026: gauge formula §3 reads bytesPerEpoch directly; §3 gains per-operator gauge-share cap subsection; §11 governable parameters table updated; §Risks wash-trading rationale rewritten around the layered defenses; section heading "Pre-receipt-launch gauge accumulation" → "Pre-launch gauge accumulation" - ADR 028: offense count 4→3 (phantom, rate, blacklist) - architecture.md: ADR 014 + ADR 027 descriptions updated - appendix-fraud-detection.md: rewritten to drop receipt-summary fraud detection; reduced to stale-close detection only - appendix-l2-deployment.md: drop MMR-append cost discussion - appendix-operator-key-rotation.md: offense count 4→3 Refs: #486 Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
There was a problem hiding this comment.
Code Review
This pull request significantly simplifies the wash-trading defense mechanism by replacing the complex Merkle-based receipt attestation system with inline on-chain bookkeeping within the FeeRouter. Key changes include adding an epochId to vouchers, tracking distinct client counts and bytes per epoch directly during settlement, and introducing a per-operator gauge-share cap. Review feedback correctly identified documentation inconsistencies regarding the lifecycle of long-lived channels and discrepancies between pseudo-code and the updated routeSettlement interface.
| A voucher attributed to an old epoch past the lag bound reverts. This bounds storage growth (only recent epochs accept new settlements) and prevents manipulation of long-closed gauge accounting. | ||
|
|
||
| Receipts are signed by *requester* EVM keys (channel funder, not operator), and identity diversity is computed in the EVM-address space because channel deposits are USDC. Ed25519 is reserved for wire-level operator authentication ([ADR 005](005-protocol.md)); on-chain Ed25519 verification was already rejected as too expensive ([ADR 014 Alternatives](014-on-chain-verification.md#alternatives-considered)). | ||
| For long-lived channels spanning multiple epochs, the client signs separate per-epoch vouchers (incrementing `voucherNonce` across them per [ADR 003 Voucher Nonce Convention](003-payments.md)). The operator submits each at the relevant `settleChannel` call cadence — typically once per epoch boundary per active channel. |
There was a problem hiding this comment.
This sentence seems to contradict the behavior of settleChannel as described in adr/003-payments.md, which states that settleChannel sets the channel status to Closed. If a channel is closed, it cannot be used for subsequent epochs. This implies that with the new design, all bytes from a long-lived channel are attributed to a single epoch from the final voucher, which seems like a regression from the previous design that supported multi-epoch attribution. Could you clarify how byte attribution is supposed to work for long-lived channels that span multiple epochs to ensure internal consistency?
References
- Ensure protocol documentation is internally consistent by verifying that function descriptions, field lists, and edge-case logic are aligned across all sections of the document.
| ```solidity | ||
| function routeSettlement( | ||
| bytes32 channelId, | ||
| Voucher calldata voucher, | ||
| bytes calldata clientSignature | ||
| ) external { | ||
| // ... existing voucher verification, USDC routing per ADR 026 §2 ... | ||
|
|
||
| Channel storage ch = channels[channelId]; | ||
| address operator = ch.provider; | ||
| address client = ch.client; | ||
| uint64 epoch = epochOf(voucher); // see §2 below | ||
|
|
||
| if (!_seenClient[operator][epoch][client]) { | ||
| _seenClient[operator][epoch][client] = true; | ||
| distinctClientCount[operator][epoch] += 1; | ||
| } | ||
| bytesPerEpoch[operator][epoch] += voucher.bytesDelivered; | ||
| } | ||
| ``` |
There was a problem hiding this comment.
The pseudo-code for routeSettlement here is inconsistent with the interface defined in adr/016-contract-interactions.md and adr/003-payments.md. Those ADRs specify the signature as routeSettlement(address operator, address client, uint256 bytesDelivered, uint256 amount, uint64 epochId). To maintain consistency across the documentation, this pseudo-code should be updated to reflect the correct on-chain interface. The current signature and implementation details (like deriving operator and client from channelId) are misleading and fail to distinguish between operator-asserted values and on-chain state.
| ```solidity | |
| function routeSettlement( | |
| bytes32 channelId, | |
| Voucher calldata voucher, | |
| bytes calldata clientSignature | |
| ) external { | |
| // ... existing voucher verification, USDC routing per ADR 026 §2 ... | |
| Channel storage ch = channels[channelId]; | |
| address operator = ch.provider; | |
| address client = ch.client; | |
| uint64 epoch = epochOf(voucher); // see §2 below | |
| if (!_seenClient[operator][epoch][client]) { | |
| _seenClient[operator][epoch][client] = true; | |
| distinctClientCount[operator][epoch] += 1; | |
| } | |
| bytesPerEpoch[operator][epoch] += voucher.bytesDelivered; | |
| } | |
| ``` | |
| function routeSettlement( | |
| address operator, | |
| address client, | |
| uint256 bytesDelivered, | |
| uint256 amount, | |
| uint64 epochId | |
| ) external { | |
| // ... existing USDC routing per ADR 026 §2 ... | |
| if (!_seenClient[operator][epochId][client]) { | |
| _seenClient[operator][epochId][client] = true; | |
| distinctClientCount[operator][epochId] += 1; | |
| } | |
| bytesPerEpoch[operator][epochId] += bytesDelivered; | |
| } |
References
- Ensure protocol documentation is internally consistent by verifying that function descriptions, field lists, and edge-case logic are aligned across all sections of the document.
- Clearly distinguish between operator-asserted values (verified post-hoc via challenges) and values derived directly from on-chain state in protocol documentation.
…he per-operator gauge cap Cuts the diversity gate (funded-channel minimum, funding age, per-operator cooldown, distinct-client threshold) from the gauge security model. Analysis showed: 1. The cap is the binding constraint. The cap-binding self-deal threshold (~$21k/yr per operator with full ve-boost, ~$52k without) is independent of the diversity gate. Whether the attacker uses 1 fake client or 5, the math is identical. 2. The diversity gate's marginal Sybil-cost contribution is $40 per attack operator ($50 vs $10 in client-channel deposits). Negligible. 3. The "diverse client base" tokenomics signal the gate encoded was contestable: legitimate operators with concentrated client bases (single enterprise customer, dedicated-publisher origin nodes) would be excluded from gauge despite being honest. Diversity-of-service is captured better as a reputation signal (off-chain, ADR 008 §12) than as an on-chain hard gate. Drops: - ADR 027 entirely (the file is deleted; number is reclaimed per the same pattern as 029/030/031/032 documented in CLAUDE.md) - 4 governance parameters: MIN_DISTINCT_CLIENTS_PER_EPOCH, MIN_CHANNEL_FUNDING_USDC, MIN_CLIENT_AGE, IDENTITY_COOLDOWN - 2 storage maps from FeeRouter: distinctClientCount, _seenClient - ~15k gas per routeSettlement (only bytesPerEpoch SSTORE remains, ~5-10k) - StablePaymentChannel.lifetimeDepositOf() view + lifetimeDeposit storage (had no consumer outside the diversity gate) - ADR 008 §12 receipt-tier gating (replaced with off-chain reputation signal explanation) - summaryWindow / challengeWindow governable parameters from ADR 026 §11 - MMR retention buffer from ADR 009 The wash-trading defense is now purely the ADR 026 §3 per-operator gauge-share cap (5% default, governable [1%, 25%]) combined with the closed-pool gauge bucket structure and the 8% treasury+safety leakage per self-deal. Quantitative analysis lives in internal/ideas/wash-trading-economics.md. Net: ~310 lines deleted across 14 files. Routes everything through FeeRouter.bytesPerEpoch[operator][epoch] feeding ADR 026 §3's gauge formula directly, with no separate ADR for the trivial state map. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
|
Pushed 6818995 — second pass: ADR 027 deleted entirely. The diversity gate adds nothing the per-operator gauge-share cap doesn't already do, and the cap is the binding constraint regardless of how many distinct clients an attacker has. Net diff is now -265 lines across 14 files. |
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request simplifies the protocol's wash-trading defense by removing the complex 'Distinct-Client Delivery Receipts' (ADR 027) mechanism and its associated on-chain verification and slashing logic. It introduces a per-operator gauge-share cap (default 5%) in ADR 026 as the primary defense, while reframing reputation as an off-chain signal. The FeeRouter.routeSettlement interface is updated to include epochId and client parameters to support these changes. Feedback was provided to ensure the client parameter is consistently included in function signatures and descriptions across all affected ADR documentation.
| function routeSettlement( | ||
| address operator, | ||
| uint256 bytesDelivered, | ||
| uint256 amount | ||
| uint256 amount, | ||
| uint64 epochId // voucher.epochId per ADR 003 | ||
| ) external; |
There was a problem hiding this comment.
The routeSettlement function signature in the IFeeRouter interface is missing the client parameter. This parameter is present in the call table (line 478) and is required to populate the Settled event (line 250) for off-chain analytics and reputation signals as described in ADR 008 Section 12.
| function routeSettlement( | |
| address operator, | |
| uint256 bytesDelivered, | |
| uint256 amount | |
| uint256 amount, | |
| uint64 epochId // voucher.epochId per ADR 003 | |
| ) external; | |
| function routeSettlement( | |
| address operator, | |
| address client, // channel.client for reputation | |
| uint256 bytesDelivered, | |
| uint256 amount, | |
| uint64 epochId // voucher.epochId per ADR 003 | |
| ) external; |
References
- Ensure protocol documentation is internally consistent by verifying that function descriptions and field lists are aligned across all sections of the document.
| class FeeRouter { | ||
| +routeSettlement(op, bytes, amount) | ||
| +commitEpochReceiptRoot(epochId, root) | ||
| +routeSettlement(op, bytes, amount, epochId) |
There was a problem hiding this comment.
The class diagram for FeeRouter should be updated to include the client parameter in the routeSettlement method to maintain consistency with the rest of the ADR.
| +routeSettlement(op, bytes, amount, epochId) | |
| +routeSettlement(op, client, bytes, amount, epochId) |
References
- Ensure consistent use of canonical function names across all documentation artifacts, including class diagrams and Mermaid graphs.
| | --- | --- | --- | | ||
| | `routeSettlement(operator, bytesDelivered, amount)` | `IERC20.safeTransfer()` × 4 (operator base 40%, BuybackBurner 5%, Treasury 5%, SafetyReserve 3%; gauge 40% and delegator 7% retained in epoch USDC buckets, no transfer), `StakingRegistry.recordSettlement(operator)`. State updates: increments per-epoch USDC accumulators for the gauge and delegator buckets. Byte counters and receipt-root commitments do **not** flow through this call — gauge eligibility (`bytes_i` and `sum(working_bytes)` in the [ADR 026 §3](026-gauge-boost-tokenomics.md#3-gauge-boost-formula) formula) is sourced from per-(operator, epoch) receipt summaries via the separate `commitEpochReceiptRoot` / `commitEpochSummary` entry points ([ADR 027 §4](027-distinct-client-receipts.md#4-on-chain-anchoring-merkle-batched)). | `nonReentrant`, checks-effects-interactions, `ROUTER_CALLER_ROLE` | | ||
| | `commitEpochReceiptRoot(epochId, root)` | None (state-only). Appends one leaf to the per-(`msg.sender`, `epochId`) MMR receipt accumulator (per [ADR 027 §4](027-distinct-client-receipts.md#4-on-chain-anchoring-merkle-batched)). | None — `msg.sender` is the credited operator; the operator is self-authorising for their own gauge eligibility. | | ||
| | `routeSettlement(operator, bytesDelivered, amount, epochId)` | `IERC20.safeTransfer()` × 4 (operator base 40%, BuybackBurner 5%, Treasury 5%, SafetyReserve 3%; gauge 40% and delegator 7% retained in epoch USDC buckets, no transfer), `StakingRegistry.recordSettlement(operator)`. State updates: increments per-epoch USDC accumulators for the gauge and delegator buckets; increments `bytesPerEpoch[operator][epochId]` for the gauge formula. Gauge eligibility (`bytes_i` in the [ADR 026 §3](026-gauge-boost-tokenomics.md#3-gauge-boost-formula) formula) is sourced from this view at gauge-claim time, with the per-operator share cap binding the output. | `nonReentrant`, checks-effects-interactions, `ROUTER_CALLER_ROLE` | |
There was a problem hiding this comment.
The reentrancy table entry for routeSettlement is missing the client parameter in the function signature, which is inconsistent with the call table on line 478.
| | `routeSettlement(operator, bytesDelivered, amount, epochId)` | `IERC20.safeTransfer()` × 4 (operator base 40%, BuybackBurner 5%, Treasury 5%, SafetyReserve 3%; gauge 40% and delegator 7% retained in epoch USDC buckets, no transfer), `StakingRegistry.recordSettlement(operator)`. State updates: increments per-epoch USDC accumulators for the gauge and delegator buckets; increments `bytesPerEpoch[operator][epochId]` for the gauge formula. Gauge eligibility (`bytes_i` in the [ADR 026 §3](026-gauge-boost-tokenomics.md#3-gauge-boost-formula) formula) is sourced from this view at gauge-claim time, with the per-operator share cap binding the output. | `nonReentrant`, checks-effects-interactions, `ROUTER_CALLER_ROLE` | | |
| | routeSettlement(operator, client, bytesDelivered, amount, epochId) | IERC20.safeTransfer() × 4 (operator base 40%, BuybackBurner 5%, Treasury 5%, SafetyReserve 3%; gauge 40% and delegator 7% retained in epoch USDC buckets, no transfer), StakingRegistry.recordSettlement(operator). State updates: increments per-epoch USDC accumulators for the gauge and delegator buckets; increments bytesPerEpoch[operator][epochId] for the gauge formula. Gauge eligibility (bytes_i in the [ADR 026 §3](026-gauge-boost-tokenomics.md#3-gauge-boost-formula) formula) is sourced from this view at gauge-claim time, with the per-operator share cap binding the output. | nonReentrant, checks-effects-interactions, ROUTER_CALLER_ROLE | |
References
- Ensure protocol documentation is internally consistent by verifying that function descriptions and field lists are aligned across all sections of the document.
| 1. **`closeChannel`** — callable by client or provider only. Records the submitted voucher's `amount` in `claimedAmount`, `nonce` in `claimedNonce`, and `bytesDelivered` in `claimedBytes`, sets status to `Closing`, starts the dispute window. **No fee deduction, no router call.** **Zero-voucher close:** when **either party** calls `closeChannel` with `amount=0`, `nonce=0`, `bytesDelivered=0`, and an empty signature (`signature.length == 0`) on a channel with `claimedNonce == 0`, the signature verification is skipped — no client-signed voucher is needed. All other `closeChannel` calls — any call with `signature.length > 0`, or any call where `amount != 0`, `nonce != 0`, or `bytesDelivered != 0` — require normal EIP-712/ECDSA voucher verification. This is safe because voucher nonces start at 1 (nonce 0 is the sentinel for "no voucher submitted"; see [Voucher Nonce Convention](#voucher-nonce-convention)), so any real voucher has nonce ≥ 1 and can always be submitted via `disputeChannel` (which requires strictly higher nonce than `claimedNonce`). The dispute window still applies: if a valid voucher exists, any party can submit it via `disputeChannel`. At settlement, `claimedAmount=0` means the full deposit is refunded to the client and the provider receives nothing — no router call is made for a zero-amount settlement. | ||
| 2. **`disputeChannel`** (during dispute window) — callable by any address. If the submitted voucher has a strictly higher nonce, updates both `claimedAmount`, `claimedNonce`, and `claimedBytes` (see [Voucher Bytes-Delivered Field](#voucher-bytes-delivered-field)) to the new values. Still **no fee deduction, no router call**. Submissions with an equal or lower nonce revert with no state change. | ||
| 3. **`settleChannel`** (after dispute window expires) — callable by anyone. If `claimedAmount > 0`, computes `bytesDelivered` from the final voucher, transfers the full `claimedAmount` of USDC to the `FeeRouter`, and invokes `FeeRouter.routeSettlement(channel.provider, bytesDelivered, claimedAmount)` in the same transaction. Refunds `deposit - claimedAmount` to the client. Sets status to `Closed`. The router (not `StablePaymentChannel`) is responsible for forwarding the operator's 40% base share, dispatching the same-tx legs (5% buyback-and-burn, 5% treasury, 3% safety reserve), and accumulating the epoch-bucketed gauge and delegator pools per [ADR 026 §2](026-gauge-boost-tokenomics.md#2-feerouter-split-40407553). Gauge-eligibility receipt commitments are decoupled from channel settlement — operators commit per-epoch receipt roots directly to `FeeRouter` (see [ADR 027 §4](027-distinct-client-receipts.md#4-on-chain-anchoring-merkle-batched)). `settleChannel` is purely the USDC payment path; whether and when the bytes settled here count toward gauge eligibility depends on whether the operator commits a per-epoch root for the corresponding epoch. | ||
| 3. **`settleChannel`** (after dispute window expires) — callable by anyone. If `claimedAmount > 0`, computes `bytesDelivered` from the final voucher, transfers the full `claimedAmount` of USDC to the `FeeRouter`, and invokes `FeeRouter.routeSettlement(channel.provider, bytesDelivered, claimedAmount, voucher.epochId)` in the same transaction. Refunds `deposit - claimedAmount` to the client. Sets status to `Closed`. The router (not `StablePaymentChannel`) is responsible for forwarding the operator's 40% base share, dispatching the same-tx legs (5% buyback-and-burn, 5% treasury, 3% safety reserve), accumulating the epoch-bucketed gauge and delegator pools per [ADR 026 §2](026-gauge-boost-tokenomics.md#2-feerouter-split-40407553), and incrementing `bytesPerEpoch[operator][epochId]` for the gauge formula in [ADR 026 §3](026-gauge-boost-tokenomics.md#3-gauge-boost-formula). The per-operator gauge-share cap from [ADR 026 §3](026-gauge-boost-tokenomics.md#per-operator-gauge-share-cap) is the binding wash-trading defense; gauge bytes flow through `settleChannel` directly with no separate commit step. |
There was a problem hiding this comment.
The description of settleChannel is missing the channel.client argument in the call to FeeRouter.routeSettlement. This argument is required by the updated IFeeRouter interface in ADR 016 to support off-chain reputation signals.
| 3. **`settleChannel`** (after dispute window expires) — callable by anyone. If `claimedAmount > 0`, computes `bytesDelivered` from the final voucher, transfers the full `claimedAmount` of USDC to the `FeeRouter`, and invokes `FeeRouter.routeSettlement(channel.provider, bytesDelivered, claimedAmount, voucher.epochId)` in the same transaction. Refunds `deposit - claimedAmount` to the client. Sets status to `Closed`. The router (not `StablePaymentChannel`) is responsible for forwarding the operator's 40% base share, dispatching the same-tx legs (5% buyback-and-burn, 5% treasury, 3% safety reserve), accumulating the epoch-bucketed gauge and delegator pools per [ADR 026 §2](026-gauge-boost-tokenomics.md#2-feerouter-split-40407553), and incrementing `bytesPerEpoch[operator][epochId]` for the gauge formula in [ADR 026 §3](026-gauge-boost-tokenomics.md#3-gauge-boost-formula). The per-operator gauge-share cap from [ADR 026 §3](026-gauge-boost-tokenomics.md#per-operator-gauge-share-cap) is the binding wash-trading defense; gauge bytes flow through `settleChannel` directly with no separate commit step. | |
| 3. settleChannel (after dispute window expires) — callable by anyone. If claimedAmount > 0, computes bytesDelivered from the final voucher, transfers the full claimedAmount of USDC to the FeeRouter, and invokes FeeRouter.routeSettlement(channel.provider, channel.client, bytesDelivered, claimedAmount, voucher.epochId) in the same transaction. Refunds deposit - claimedAmount to the client. Sets status to Closed. The router (not StablePaymentChannel) is responsible for forwarding the operator's 40% base share, dispatching the same-tx legs (5% buyback-and-burn, 5% treasury, 3% safety reserve), accumulating the epoch-bucketed gauge and delegator pools per [ADR 026 §2](026-gauge-boost-tokenomics.md#2-feerouter-split-40407553), and incrementing bytesPerEpoch[operator][epochId] for the gauge formula in [ADR 026 §3](026-gauge-boost-tokenomics.md#3-gauge-boost-formula). The per-operator gauge-share cap from [ADR 026 §3](026-gauge-boost-tokenomics.md#per-operator-gauge-share-cap) is the binding wash-trading defense; gauge bytes flow through settleChannel directly with no separate commit step. |
References
- Ensure protocol documentation is internally consistent by verifying that function descriptions and field lists are aligned across all sections of the document.
| - `closeChannel` → requires status `Open`. **Callable by `channel.client` or `channel.provider` only** (`require(msg.sender == channel.client || msg.sender == channel.provider)`). Sets status to `Closing`, records `claimedAmount`, `claimedNonce`, and `claimedBytes` from the submitted voucher, emits `ChannelCloseInitiated`. No fund transfers. Third parties cannot initiate a close — they act only via `disputeChannel` (during the dispute window) or `settleChannel` (after expiration). **Zero-voucher close:** when **either party** calls with `amount == 0`, `nonce == 0`, `bytesDelivered == 0`, an empty signature (`signature.length == 0`), and `channel.claimedNonce == 0`, the voucher signature is not verified — this is the symmetric mechanism for releasing channels where no vouchers were ever signed (a provider releasing an abandoned channel; a client recovering their deposit when the node failed before the first voucher boundary). Since voucher nonces start at 1, any real voucher has a strictly higher nonce than the recorded `claimedNonce=0`, so `disputeChannel` works normally. The dispute window applies; the counterparty (or any third party) holding a real voucher can dispute. | ||
| - `disputeChannel` → requires status `Closing` and `block.timestamp < disputeDeadline`. Callable by any address holding a valid voucher with a strictly higher nonce. Updates `claimedAmount`, `claimedNonce`, and `claimedBytes`, emits `ChannelDisputed`. No fund transfers. Unrestricted caller access is intentional: third-party fraud detectors ([Appendix: Fraud Detection](appendix-fraud-detection.md)) must be able to submit higher-nonce vouchers on behalf of an offline party during the dispute window. | ||
| - `settleChannel` → requires status `Closing` and `block.timestamp >= disputeDeadline`. Callable by any address. Refunds `deposit - claimedAmount` to the client and, if `claimedAmount > 0`, transfers `claimedAmount` USDC to the configured `FeeRouter` and invokes `FeeRouter.routeSettlement(channel.provider, claimedBytes, claimedAmount)` in the same transaction. Sets status to `Closed`, emits `ChannelSettled`. **No fee is computed or skimmed inside this contract** — the router applies the [ADR 026](026-gauge-boost-tokenomics.md) six-bucket split and pays the operator's 40% base share same-tx (see [FeeRouter Integration](#feerouter-integration)). Gauge-eligibility receipt commitments are not part of this call — operators commit per-epoch roots directly to `FeeRouter.commitEpochReceiptRoot` (see [ADR 027 §4](027-distinct-client-receipts.md#4-on-chain-anchoring-merkle-batched)), independent of settlement timing and unaffected by which address calls `settleChannel`. | ||
| - `settleChannel` → requires status `Closing` and `block.timestamp >= disputeDeadline`. Callable by any address. Refunds `deposit - claimedAmount` to the client and, if `claimedAmount > 0`, transfers `claimedAmount` USDC to the configured `FeeRouter` and invokes `FeeRouter.routeSettlement(channel.provider, claimedBytes, claimedAmount, voucher.epochId)` in the same transaction. Sets status to `Closed`, emits `ChannelSettled`. **No fee is computed or skimmed inside this contract** — the router applies the [ADR 026](026-gauge-boost-tokenomics.md) six-bucket split and pays the operator's 40% base share same-tx (see [FeeRouter Integration](#feerouter-integration)). The router also increments `bytesPerEpoch[operator][epochId]` for the gauge formula in [ADR 026 §3](026-gauge-boost-tokenomics.md#3-gauge-boost-formula); the per-operator gauge-share cap from [ADR 026 §3](026-gauge-boost-tokenomics.md#per-operator-gauge-share-cap) is the binding wash-trading defense. |
There was a problem hiding this comment.
The summary description for settleChannel is missing the channel.client argument in the routeSettlement call, which is inconsistent with the updated interface requirements.
| - `settleChannel` → requires status `Closing` and `block.timestamp >= disputeDeadline`. Callable by any address. Refunds `deposit - claimedAmount` to the client and, if `claimedAmount > 0`, transfers `claimedAmount` USDC to the configured `FeeRouter` and invokes `FeeRouter.routeSettlement(channel.provider, claimedBytes, claimedAmount, voucher.epochId)` in the same transaction. Sets status to `Closed`, emits `ChannelSettled`. **No fee is computed or skimmed inside this contract** — the router applies the [ADR 026](026-gauge-boost-tokenomics.md) six-bucket split and pays the operator's 40% base share same-tx (see [FeeRouter Integration](#feerouter-integration)). The router also increments `bytesPerEpoch[operator][epochId]` for the gauge formula in [ADR 026 §3](026-gauge-boost-tokenomics.md#3-gauge-boost-formula); the per-operator gauge-share cap from [ADR 026 §3](026-gauge-boost-tokenomics.md#per-operator-gauge-share-cap) is the binding wash-trading defense. | |
| - settleChannel → requires status Closing and block.timestamp >= disputeDeadline. Callable by any address. Refunds deposit - claimedAmount to the client and, if claimedAmount > 0, transfers claimedAmount USDC to the configured FeeRouter and invokes FeeRouter.routeSettlement(channel.provider, channel.client, claimedBytes, claimedAmount, voucher.epochId) in the same transaction. Sets status to Closed, emits ChannelSettled. No fee is computed or skimmed inside this contract — the router applies the [ADR 026](026-gauge-boost-tokenomics.md) six-bucket split and pays the operator's 40% base share same-tx (see [FeeRouter Integration](#feerouter-integration)). The router also increments bytesPerEpoch[operator][epochId] for the gauge formula in [ADR 026 §3](026-gauge-boost-tokenomics.md#3-gauge-boost-formula); the per-operator gauge-share cap from [ADR 026 §3](026-gauge-boost-tokenomics.md#per-operator-gauge-share-cap) is the binding wash-trading defense. |
References
- Ensure protocol documentation is internally consistent by verifying that function descriptions and field lists are aligned across all sections of the document.
| #### Settlement-path interface | ||
|
|
||
| `StablePaymentChannel.settleChannel` MUST invoke `FeeRouter.routeSettlement(address operator, uint256 bytesDelivered, uint256 amount)` in the same transaction as the USDC `safeTransferFrom` to the router. The router pays the operator's 40% base share in that transaction and dispatches the 5% / 5% / 3% same-tx legs. Gauge eligibility does not flow through this call; the operator credits gauge bytes via `FeeRouter.commitEpochReceiptRoot` per [ADR 027 §4](027-distinct-client-receipts.md#4-on-chain-anchoring-merkle-batched). The full `IFeeRouter` interface (claim paths, epoch views, `commitEpochReceiptRoot`) is canonical in [ADR 016](016-contract-interactions.md). | ||
| `StablePaymentChannel.settleChannel` MUST invoke `FeeRouter.routeSettlement(address operator, uint256 bytesDelivered, uint256 amount, uint64 epochId)` in the same transaction as the USDC `safeTransferFrom` to the router. The router pays the operator's 40% base share in that transaction, dispatches the 5% / 5% / 3% same-tx legs, and increments `bytesPerEpoch[operator][epochId]` for the gauge formula per [ADR 026 §3](026-gauge-boost-tokenomics.md#3-gauge-boost-formula). The full `IFeeRouter` interface is canonical in [ADR 016](016-contract-interactions.md). |
There was a problem hiding this comment.
The settlement-path interface requirement for StablePaymentChannel.settleChannel is missing the address client parameter in the routeSettlement signature.
| `StablePaymentChannel.settleChannel` MUST invoke `FeeRouter.routeSettlement(address operator, uint256 bytesDelivered, uint256 amount, uint64 epochId)` in the same transaction as the USDC `safeTransferFrom` to the router. The router pays the operator's 40% base share in that transaction, dispatches the 5% / 5% / 3% same-tx legs, and increments `bytesPerEpoch[operator][epochId]` for the gauge formula per [ADR 026 §3](026-gauge-boost-tokenomics.md#3-gauge-boost-formula). The full `IFeeRouter` interface is canonical in [ADR 016](016-contract-interactions.md). | |
| StablePaymentChannel.settleChannel MUST invoke FeeRouter.routeSettlement(address operator, address client, uint256 bytesDelivered, uint256 amount, uint64 epochId) in the same transaction as the USDC safeTransferFrom to the router. The router pays the operator's 40% base share in that transaction, dispatches the 5% / 5% / 3% same-tx legs, and increments bytesPerEpoch[operator][epochId] for the gauge formula per [ADR 026 §3](026-gauge-boost-tokenomics.md#3-gauge-boost-formula). The full IFeeRouter interface is canonical in [ADR 016](016-contract-interactions.md). |
References
- Ensure protocol documentation is internally consistent by verifying that function descriptions and field lists are aligned across all sections of the document.
Per gemini-code-assist review on PR #488: dropped channel.client from routeSettlement signature in commit 6818995, but the Settled event still emits client (for ADR 008 §12 off-chain reputation signals) and the call table at ADR 016 line 478 still shows client in the args. Re-adds client to the signature and propagates the consistent shape across all references: - ADR 016: function signature, class diagram, reentrancy table — all show (operator, client, bytesDelivered, amount, epochId) - ADR 003: §settleChannel description, settlement-path interface, §3 callable-anyone description — all show the same signature - ADR 003 §31, §110: high-level fee-routing prose updated - ADR 016 §348, §399: deployment + role-grant prose updated - appendix-l2-deployment.md: gas-overhead description updated - appendix-poc-production-seams.md: PoC/production seam table updated The client param exists for the Settled event (off-chain analytics + reputation indexing); on-chain logic does not key on it. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
|
Addressed in 189672e: Re-added |
Per offline review: the client field on FeeRouter.Settled was redundant data. Off-chain reputation indexers can recover it by joining via tx hash with StablePaymentChannel's events: - ChannelSettled(channelId, provider, ...) is emitted in the same tx as routeSettlement (settleChannel calls routeSettlement inline) - ChannelOpened(channelId, client, provider, ...) was emitted at channel-open time, providing the channelId → client mapping - Standard subgraph join pattern (TheGraph, Dune, et al. all support it) So the client field on FeeRouter's signature/event was duplicating data StablePaymentChannel already exposes. Drops it everywhere: - IFeeRouter.routeSettlement signature: 5-arg → 4-arg - IFeeRouter.Settled event: removed indexed client - FeeRouter class diagram in ADR 016 - ADR 016 reentrancy table + call table - ADR 003: §settleChannel description (line 116), summary (line 423), fee-routing prose (line 31, 110), settlement-path interface (line 498) - ADR 016 §348 deployment prose, §397 role-grant authorization - appendix-poc-production-seams.md - appendix-l2-deployment.md Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
|
Pushed 212231c — dropped The reputation/analytics signal it provided is fully recoverable off-chain by joining via tx hash:
Standard subgraph join pattern. The client field on FeeRouter's signature/event was duplicating data StablePaymentChannel already exposes — gone. Net effect on this PR: signature is now |
Same root cause as the original fix: the §8 abuse-model table referenced `reputation-≥-medium` (prose form of `medium_rep_threshold`) and asserted reputation is "gauge-eligibility-gated" — both surfaces dropped by #488 when ADR 008 §12 was rewritten. The original test-plan grep matched the literal parameter name and missed the hyphenated prose form. Also drops "gauge-eligibility-gated" from the sybil-ring counter, which directly contradicts ADR 008 §12 ("There is no on-chain gauge-eligibility gate keyed on reputation"). The remaining "peer-aggregated" property still carries the sybil-cost argument. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
… bullet Two external reviews on PR #500 (Copilot + gemini-code-assist) flagged: 1. The "good reputation standing" phrase introduced in this PR is not defined in ADR 008. Switching to "reputable peer operator" matches evidence type (b)'s prior-art phrasing on the line above ("≥3 reputable peers per ADR 008") — terminology consistent within the doc and using language ADR 008 already supports. Applied at the §3 (c) row, §8 sybil-counter row, and §8 sybil-drain row. 2. The §Risks "Gauge-eligibility tier loss persists across appeal" bullet still asserted reputation drives a binary "tier transition" out of "gauge-pool eligibility" — three claims that contradict ADR 008 §12 post-#488 ("There is no on-chain gauge-eligibility gate keyed on reputation"). Reframed as a continuous selection-probability penalty (matches ADR 008 line 320 phrasing): the reputation hit lowers selection probability via ADR 001 node selection, which reduces real `bytes_delivered`, which reduces gauge share via the ADR 026 §3 formula. The legitimate underlying concern (preserved reputation hit costs more than the restituted slash for high-volume operators) is preserved; the false binary-gate framing is removed. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…quences (#500) * docs(adr): drop stale gauge-eligibility tier bullets in ADR 008 Consequences PR #488 rewrote ADR 008 §12 from a hard gauge-eligibility gate (High/Medium/Low tiers, receipt-tier thresholds, full exclusion at Low) to a soft off-chain wash-trading signal, but two bullets in the Consequences section still described the dropped surface — including references to `high_rep_threshold` / `medium_rep_threshold` and a non-existent §12.1. Delete both stale bullets. Also rewords ADR 028 §3 evidence type (c) which cited `medium_rep_threshold` "per ADR 008"; that parameter is no longer defined anywhere in ADR 008. Replace with soft-standing language consistent with evidence type (b) above (which already says "≥3 reputable peers per ADR 008" with no numeric threshold). Closes #492 Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * docs(adr): clean up two more stale rep-tier references in ADR 028 §8 Same root cause as the original fix: the §8 abuse-model table referenced `reputation-≥-medium` (prose form of `medium_rep_threshold`) and asserted reputation is "gauge-eligibility-gated" — both surfaces dropped by #488 when ADR 008 §12 was rewritten. The original test-plan grep matched the literal parameter name and missed the hyphenated prose form. Also drops "gauge-eligibility-gated" from the sybil-ring counter, which directly contradicts ADR 008 §12 ("There is no on-chain gauge-eligibility gate keyed on reputation"). The remaining "peer-aggregated" property still carries the sybil-cost argument. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * docs(adr): adopt 'reputable peer' terminology + rewrite line-188 risk bullet Two external reviews on PR #500 (Copilot + gemini-code-assist) flagged: 1. The "good reputation standing" phrase introduced in this PR is not defined in ADR 008. Switching to "reputable peer operator" matches evidence type (b)'s prior-art phrasing on the line above ("≥3 reputable peers per ADR 008") — terminology consistent within the doc and using language ADR 008 already supports. Applied at the §3 (c) row, §8 sybil-counter row, and §8 sybil-drain row. 2. The §Risks "Gauge-eligibility tier loss persists across appeal" bullet still asserted reputation drives a binary "tier transition" out of "gauge-pool eligibility" — three claims that contradict ADR 008 §12 post-#488 ("There is no on-chain gauge-eligibility gate keyed on reputation"). Reframed as a continuous selection-probability penalty (matches ADR 008 line 320 phrasing): the reputation hit lowers selection probability via ADR 001 node selection, which reduces real `bytes_delivered`, which reduces gauge share via the ADR 026 §3 formula. The legitimate underlying concern (preserved reputation hit costs more than the restituted slash for high-volume operators) is preserved; the false binary-gate framing is removed. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> --------- Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
Summary
Closes #486. Deletes ADR 027 entirely. The diversity-gate machinery (funded-channel minimum, funding age, per-operator cooldown, distinct-client threshold) is redundant with the ADR 026 §3 per-operator gauge-share cap — the cap is the binding constraint, the gate adds ~$40/operator setup cost (negligible) and a contestable tokenomics opinion (excluding legitimate concentrated-client operators).
Two commits:
04d4474— first pass: replacesDeliveryReceiptprimitive withFeeRouterdiversity counting + per-operator gauge cap. Removes MMR aggregator,OffenseType.ReceiptFraud,submitReceiptFraudChallenge, fraud-challenge window. ADR 027 collapses 423 → 215 lines.6818995— second pass (after `/internal/ideas/wash-trading-economics.md` analysis showed the diversity gate adds nothing the cap doesn't already do): deletes ADR 027 entirely. The remaining content (`bytesPerEpoch` storage map, `Voucher.epochId` field, `enableGauge()` launch prerequisite) lives in ADR 016 / ADR 003 / ADR 026 respectively. ADR 008 §12 rewritten as soft off-chain wash-trading signal rather than hard gauge-eligibility gate.Why ADR 027 is gone
For wash-trading to be profitable at all the attacker needs ve-boost; the cap-binding self-deal threshold (~$21k/yr per operator with full ve-boost, ~$52k 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 contributions:
The cap does the Sybil work; the tokenomics opinion is contestable and better captured as a reputation signal off-chain.
What's gone
CLAUDE.md.MIN_DISTINCT_CLIENTS_PER_EPOCH,MIN_CHANNEL_FUNDING_USDC,MIN_CLIENT_AGE,IDENTITY_COOLDOWNdistinctClientCount,_seenClientWhat's preserved
Diff
14 files, +46 / −311 (~265 net deletion across both commits). ADR 027 itself: 423 → 0 lines.
Combined with PR #480 (ADR 030 + ADR 014 §2 + OffenseType.Corruption — −190 net) the recent ADR-cleanup wave has cut ~750 lines of speculative production-grade machinery from the protocol design.
Test plan
🤖 Generated with Claude Code