Repository navigation
docs(adr): pin gap-fix items (timing bounds, commitEpochSummary validation, ReceiptFraud offense) - #462
Conversation
…EpochSummary validation, receipt-fraud offense) Three deferred items from the audit follow-up are pinned here as a single coherent block, since they share the "lock down what was still vague after the #450 surface-gap audit" theme. ADR 026 §11 — timing-window safety bounds: - summaryWindow: 7 days default, [3 days, 14 days] bounds — gives honest operators time to aggregate receipts off-chain (lower) without delaying gauge finality more than a month at the most permissive setting (upper). - challengeWindow: 7 days default, [3 days, 14 days] bounds — gives bonded challengers time to verify signatures + identity-diversity heuristics (lower) without indefinitely delaying gauge payouts (upper). - claimWindow: 26 epochs default, [13, 52] epochs bounds — promoted from §2 prose to the canonical bounds table. - Cross-parameter invariant: claimWindow > challengeWindow enforced at the setter layer so a frozen-with-undetected-fraud summary cannot outlive the challenge window before the operator's claim resolves. ADR 027 §4 — commitEpochSummary validation rules: - New "commitEpochSummary validation rules" subsection explicitly pins six checks the contract MUST enforce: argument-struct consistency, epoch validity (epochId < currentEpoch), summary-window-open timing, cryptographic anti-griefing (summary.aggregateRoot == current MMR root), last-write-wins replacement during the summary window, and trust-then-challenge for the operator-asserted fields. - Third-party submission preserved (per the existing prose) — the cryptographic check on aggregateRoot makes the submitter's identity irrelevant for correctness; relayers can submit on operators' behalf without trust assumptions. ADR 014 + ADR 027 §5 — receipt-fraud offense: - New OffenseType.ReceiptFraud appended to the canonical enum (preserving the existing four ordinals so SafetyReserve indexing stays stable). - New ISlashJudge.submitReceiptFraudChallenge(challengedNode, epochId, fraudEvidence) entry point. No counter-evidence window — Merkle inclusion/exclusion proofs against the operator's own on-chain aggregateRoot are cryptographically dispositive. - Receipt-fraud preimage formula added to §3 evidenceHash spec: keccak256(abi.encode(uint8(OffenseType.ReceiptFraud), epochId, aggregateRoot)) — stable across alternate fraud-evidence formats (different Merkle proofs against the same aggregateRoot produce the same evidenceHash). - ADR 027 §5 bond model: 100 TOKEN bond (matches existing challengeBond, governable [10, 1000]); 5/15/50% escalating slash percentage on successful challenge; 50/30/20 challenger / SafetyReserve / burn distribution; 50/50 burn-or-to-operator on unsuccessful — all matching the four existing offense types. Over-claimed claimedBytes / claimedDistinctClients fields zeroed for the epoch on success (gauge eligibility forfeiture stacks with the stake slash). Closes the three "honest gaps that remain (deferred to #451 lock-down)" flagged in the cross-PR audit on the #450 series. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
There was a problem hiding this comment.
Code Review
This pull request introduces the ReceiptFraud offense type and its associated on-chain verification mechanism. Key updates include the addition of submitReceiptFraudChallenge to the ISlashJudge interface, detailed validation rules for commitEpochSummary in the FeeRouter, and the definition of governable timing windows and bond models for receipt fraud. Feedback was provided to standardize the units for summaryWindow, challengeWindow, and claimWindow to seconds to ensure consistency and prevent potential arithmetic errors during implementation.
| | `summaryWindow` | 7 days (604,800 s) | 3 days (259,200 s) | 14 days (1,209,600 s) | | ||
| | `challengeWindow` | 7 days (604,800 s) | 3 days (259,200 s) | 14 days (1,209,600 s) | | ||
| | `claimWindow` | 26 epochs | 13 epochs | 52 epochs | |
There was a problem hiding this comment.
The table mixes units (seconds vs epochs) for summaryWindow, challengeWindow, and claimWindow. To ensure consistency and implementation accuracy, use seconds as the primary unit for these parameters and include human-readable units in parentheses for readability. This prevents arithmetic errors and aligns with technical specification standards.
References
- Ensure the units are consistent across all definitions to avoid arithmetic errors in calculations like evidence-age windows.
- When documenting time-based parameters in technical specifications, use seconds as the primary unit for implementation accuracy, but include human-readable units in parentheses for readability.
There was a problem hiding this comment.
Addressed in latest commit: seconds-primary for summaryWindow / challengeWindow rows, matching the PR #461 convention. claimWindow stays in epochs since it's a count (not a wall-clock duration); contract derives the seconds-domain deadline via the immutable epochLength multiplier.
Switch summaryWindow / challengeWindow rows to seconds-primary formatting (human-readable in parens), matching the convention established in PR #461 for namespaceTransferTimelock — seconds is the unit the contract setter actually consumes. claimWindow stays in epochs (it's a count, not a wall-clock duration); note added that the contract derives the seconds-domain deadline internally via the immutable epochLength multiplier. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Summary
Pins the three "honest gaps" the cross-PR audit flagged at the end of the #450 series (
#455/#456/#458/#459/#460/#461). Lands as a single coherent block because the three pieces are interlocking — timing-window bounds + validation rules + receipt-fraud offense are the lock-down that closes the surface for audit.Decisions baked in
Gap 1 — timing-window safety bounds (ADR 026 §11)
Three rows added to the §11 bounds table:
summaryWindowchallengeWindowclaimWindowPlus a cross-parameter invariant:
claimWindow > challengeWindowenforced at the contract setter, so a frozen-with-fraud summary can't outlive the challenge window before the claim path runs. Updates that violate the invariant revert.Gap 2 —
commitEpochSummaryvalidation rules (ADR 027 §4)New "commitEpochSummary validation rules" subsection pinning six checks the contract enforces atomically:
summary.operator == operator,summary.epochId == epochId)epochId < currentEpoch())block.timestamp <= epochEnd(epochId) + summaryWindow)summary.aggregateRootMUST equal the current MMR root (load-bearing — makes third-party submission safe regardless of caller identity)claimedBytes,claimedDistinctClients) NOT verified at submit — fraud goes through the §Challenge window mechanismThird-party submission preserved per existing ADR 027 §4 prose; the cryptographic constraint on
aggregateRootis what makes it safe.Gap 3 — receipt-fraud offense type (ADR 014 + ADR 027 §5)
ADR 014:
OffenseTypeenum extended (append-only):{ Corruption, Phantom, RateManipulation, Blacklist, ReceiptFraud }. Existing ordinals preserved soSafetyReserveindexing stays stable.ISlashJudge.submitReceiptFraudChallenge(challengedNode, epochId, fraudEvidence)added — synchronous resolution, no counter-evidence window (Merkle proof is cryptographically dispositive).evidenceHashpreimage:keccak256(abi.encode(uint8(OffenseType.ReceiptFraud), epochId, aggregateRoot))— stable across alternate Merkle-proof formats.ADR 027 §5 — concrete bond model replaces the prior "pinned with the handler" placeholder:
[10, 1000]challengeBondOver-claimed
claimedBytes/claimedDistinctClientszeroed for the epoch on success — gauge eligibility forfeiture stacks with the stake slash.What this enables
OffenseTypeenum (no append-during-implementation gotcha) and a completeSlashJudgesurface for receipt-fraud handling.Test plan
pre-commit run --files <touched files>cleanevidenceHashpreimage example resolves without ambiguityRelated
🤖 Generated with Claude Code