Skip to content

docs(adr): pin gap-fix items (timing bounds, commitEpochSummary validation, ReceiptFraud offense) - #462

Merged
alpergundogdu merged 2 commits into
mainfrom
adr/450-gap-fix
May 7, 2026
Merged

alpergundogdu merged 2 commits into
mainfrom
adr/450-gap-fix

Conversation

@alpergundogdu

Copy link
Copy Markdown
Contributor

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:

Parameter Default Min Max
summaryWindow 7 days 3 days 14 days
challengeWindow 7 days 3 days 14 days
claimWindow 26 epochs 13 epochs 52 epochs

Plus a cross-parameter invariant: claimWindow > challengeWindow enforced 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 — commitEpochSummary validation rules (ADR 027 §4)

New "commitEpochSummary validation rules" subsection pinning six checks the contract enforces atomically:

  1. Argument-struct consistency (summary.operator == operator, summary.epochId == epochId)
  2. Epoch validity (epochId < currentEpoch())
  3. Summary window open (block.timestamp <= epochEnd(epochId) + summaryWindow)
  4. Cryptographic anti-griefing: summary.aggregateRoot MUST equal the current MMR root (load-bearing — makes third-party submission safe regardless of caller identity)
  5. Last-write-wins during the summary window (each commit re-verifies against latest MMR)
  6. Operator-asserted fields (claimedBytes, claimedDistinctClients) NOT verified at submit — fraud goes through the §Challenge window mechanism

Third-party submission preserved per existing ADR 027 §4 prose; the cryptographic constraint on aggregateRoot is what makes it safe.

Gap 3 — receipt-fraud offense type (ADR 014 + ADR 027 §5)

ADR 014:

  • OffenseType enum extended (append-only): { Corruption, Phantom, RateManipulation, Blacklist, ReceiptFraud }. Existing ordinals preserved so SafetyReserve indexing stays stable.
  • ISlashJudge.submitReceiptFraudChallenge(challengedNode, epochId, fraudEvidence) added — synchronous resolution, no counter-evidence window (Merkle proof is cryptographically dispositive).
  • Receipt-fraud evidenceHash preimage: 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:

Parameter Default Bounds Rationale
Receipt-fraud challenge bond 100 TOKEN [10, 1000] Matches existing challengeBond
Slash percentage 5/15/50% escalating per ADR 026 §8 Same as other offenses
Slash distribution 50% challenger / 30% SafetyReserve / 20% burn per ADR 026 §8 Identical to other offenses
Bond outcome on unsuccessful challenge 50% burn / 50% to operator per ADR 014 § Bond Handling Standard handling

Over-claimed claimedBytes / claimedDistinctClients zeroed for the epoch on success — gauge eligibility forfeiture stacks with the stake slash.

What this enables

Test plan

  • pre-commit run --files <touched files> clean
  • Render the new ADR 026 §11 rows on GitHub and verify the three timing-window bounds + cross-parameter invariant paragraph read coherently
  • Spot-check that ADR 027 §4 "commitEpochSummary validation rules" and the existing "Challenge window" / "Timing windows" subsections compose correctly (no duplicate or contradictory claims)
  • Verify the ADR 014 OffenseType enum extension preserves the canonical ordinals (Corruption=0, Phantom=1, RateManipulation=2, Blacklist=3, ReceiptFraud=4) and the receipt-fraud evidenceHash preimage example resolves without ambiguity

Related

🤖 Generated with Claude Code

…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]>

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread adr/026-gauge-boost-tokenomics.md Outdated
Comment on lines +562 to +564
| `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 |

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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
  1. Ensure the units are consistent across all definitions to avoid arithmetic errors in calculations like evidence-age windows.
  2. 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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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]>
@alpergundogdu
alpergundogdu merged commit bb44c82 into main May 7, 2026
9 checks passed
@alpergundogdu
alpergundogdu deleted the adr/450-gap-fix branch May 7, 2026 15:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant