Skip to content

docs(adr): full receipt-anchoring spec in ADR 027 §4 (#450 §B.3) - #460

Merged
alpergundogdu merged 3 commits into
mainfrom
adr/450-pr5-receipt-anchoring
May 7, 2026
Merged

alpergundogdu merged 3 commits into
mainfrom
adr/450-pr5-receipt-anchoring

Conversation

@alpergundogdu

Copy link
Copy Markdown
Contributor

Summary

Fifth slice of #450. Closes §B.3 — the full commitEpochReceiptRoot / commitEpochSummary spec in ADR 027 §4.

Most of §4 was already detailed: signatures, MMR storage, msg.sender-keyed commit, trust-then-challenge model, EpochReceiptSummary fields. This PR fills in the four gaps #450 §B.3 surfaced — concrete timing windows, view surface, storage-shape clarity, and event signatures — plus a one-line cross-reference in ADR 026 §3 pinning where bytes_i comes from on-chain.

What's added

ADR 027 §4 — four new subsections:

Subsection Adds
Timing windows Pins all four lifecycle deadlines to concrete defaults; closes the "post-epoch commit window" ambiguity by binding both commitEpochReceiptRoot and commitEpochSummary to the single epochEnd + summaryWindow deadline; challenge + claim windows open at the same moment so claimers and challengers see consistent state
View surface Declares the FeeRouter views needed for off-chain simulation and challenger tooling: epochEnd(epochId), currentEpoch(), epochSummary(operator, epochId), epochReceiptRoot (during accrual), epochReceiptCount, plus three window predicates
Storage shape Lays out the three-phase state evolution (accrual → finalisation → settled); flags struct-packing vs parallel-mappings as implementation-defined
Events EpochReceiptRootCommitted (per-write, including pre-finalisation overwrites), EpochSummaryCommitted (once at finalisation), EpochSummaryChallenged (once per successful challenge, surfaces both zeroing flags for indexers)

ADR 026 §3 — one-line cross-reference:

Clarifies that bytes_i in the gauge formula is sourced from EpochReceiptSummary.claimedBytes after the ADR 027 §4 challenge window closes; a successful challenge zeros that field and gauge share collapses to zero accordingly.

Timing summary (the load-bearing addition)

Window Opens Closes
commitEpochReceiptRoot epoch start epochEnd + summaryWindow
commitEpochSummary epochEnd epochEnd + summaryWindow
Challenge window epochEnd + summaryWindow + challengeWindow
Claim window epochEnd + summaryWindow + claimWindow

Defaults: epochLength = 1w (immutable), summaryWindow = 7d (governable), challengeWindow = 7d (governable), claimWindow = 26 epochs (governable).

Decisions baked in (per planning conversation)

Decision Pick
Epoch finalisation trigger Timestamp-based (epochEnd + summaryWindow seals both commit and summary)
ReceiptSummary fields Already in §4; no change — claimedBytes + claimedDistinctClients plus aggregateRoot
Receipt-root authenticity Already in §4; no change — msg.sender-keyed
Anti-griefing Already in §4; no change — trust-then-challenge with ChallengeReceiptSummary
epochEnd / currentEpoch views Added with three window predicates
Storage shape Implementation-defined; consolidated state exposed via epochSummary view
Per-write event semantics EpochReceiptRootCommitted fires on every commit (including overwrites); latest event reflects current MMR state

Out of scope

  • §C.2 OriginAssignment edge cases (PR 6, ADR 011)
  • §C.3 PublisherRegistry cap/timelock setters (PR 6, ADR 002)

Test plan

  • pre-commit run --files adr/027-distinct-client-receipts.md adr/026-gauge-boost-tokenomics.md clean
  • Render the new "Timing windows" / "View surface" / "Storage shape" / "Events" subsections on GitHub and verify the embedded code blocks fence correctly
  • Verify the ADR 026 §3 cross-reference into ADR 027 §4 challenge-window resolves

Related

🤖 Generated with Claude Code

Most of ADR 027 §4 was already detailed (signatures, MMR storage, msg.sender
keying, trust-then-challenge model, EpochReceiptSummary fields). This PR
fills in the gaps that #450 §B.3 surfaced:

ADR 027 §4 additions:

- "Timing windows" subsection pinning the four lifecycle deadlines to
  concrete defaults: epochLength (1w, immutable), summaryWindow (7d,
  governable), challengeWindow (7d, governable), claimWindow (26 epochs,
  governable). Single deadline (epochEnd + summaryWindow) seals both
  commitEpochReceiptRoot and commitEpochSummary; challenge and claim
  windows open at the same moment so claimers and challengers see
  consistent state.
- "View surface" subsection declaring the FeeRouter views needed for
  off-chain claim simulation and challenger tooling: epochEnd(epochId),
  currentEpoch(), epochSummary(operator, epochId), epochReceiptRoot
  (during accrual), and three window predicates.
- "Storage shape" subsection laying out the three-phase state evolution
  (accrual → finalisation → settled) and noting that struct packing vs
  parallel mappings is implementation-defined.
- "Events" subsection declaring EpochReceiptRootCommitted (per-write,
  including overwrites), EpochSummaryCommitted (once at finalisation),
  and EpochSummaryChallenged (once per successful challenge with
  zeroing flags).

ADR 026 §3 cross-reference: clarifies that bytes_i in the gauge formula
is sourced from EpochReceiptSummary.claimedBytes after the ADR 027 §4
challenge window closes.

Decisions baked in (per planning conversation):

- Epoch finalisation: timestamp-based (epochEnd + summaryWindow seals both
  commit and summary)
- ReceiptSummary fields: keep claimedBytes + claimedDistinctClients as
  the only operator-asserted fields (already specified)
- msg.sender-keyed commit (already specified in §4)
- Trust-then-challenge anti-griefing (already specified)
- Storage shape: implementation-defined; consolidated state exposed via
  epochSummary view

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 updates ADR 026 and ADR 027 to specify the timing windows, storage lifecycle, and Solidity interface for the receipt-anchoring and gauge-boost mechanisms. It defines deadlines for committing receipts and summaries, as well as the challenge and claim windows. Review feedback suggests improving timestamp consistency by explicitly including the genesis base in window definitions and clarifying that MMR operations are appends rather than overwrites to ensure technical accuracy.

Comment thread adr/027-distinct-client-receipts.md Resolved
Comment thread adr/027-distinct-client-receipts.md Resolved
alpergundogdu and others added 2 commits May 7, 2026 15:07
- Include genesisTimestamp in the commitEpochReceiptRoot opening-time
  formula for consistency with epochEnd's formula. Avoids ambiguity
  about the base reference.
- Reframe EpochReceiptRootCommitted event semantics to match the
  append-only MMR model documented in §"Storage shape": each call
  APPENDS a leaf; the latest event reflects the current MMR root
  and leaf count. Drops the misleading "overwrites" framing.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…indows

Cross-PR audit caught a forward reference that doesn't resolve: PR #460
claimed `summaryWindow` and `challengeWindow` are "governable per ADR
026 §11", but ADR 026 §11's safety-bounds table only covers the six
FeeRouter shares + `boostFloor` — those receipt-anchoring parameters
aren't there.

Reframe as: governable through standard governance proposal under the
ADR 009 48 h TimelockController delay; concrete bounds will be pinned
during the ADR 026 / 027 / 028 surface lock-down (#451) and added to
ADR 026 §11 at that time.

This is honest about what's not yet specified rather than implying a
spec exists that doesn't.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
alpergundogdu added a commit that referenced this pull request May 7, 2026
…onical (audit fix)

Cross-PR audit caught struct + event-shape divergence between PR #458
(IFeeRouter) and PR #460 (ADR 027 §4 canonical):

1. struct ReceiptSummary -> EpochReceiptSummary, with the canonical
   five fields (operator, epochId, claimedBytes, claimedDistinctClients,
   aggregateRoot). PR #458's two-field stub (distinctClientCount,
   totalBytes) used the wrong field names AND the wrong types
   (claimedDistinctClients is uint32 per ADR 027 §4 line 141, not uint256)
   AND was missing aggregateRoot.

2. EpochReceiptRootCommitted event: added leafCount field (the MMR's
   current depth). Matches the PR #460 declaration in ADR 027 §4 § Events
   so indexers don't have to chain prior events to reconstruct MMR state.

3. EpochSummaryCommitted event: renamed fields to claimedBytes /
   claimedDistinctClients (canonical), changed claimedDistinctClients to
   uint32 to match the storage type, added aggregateRoot field.

The struct is mirrored (not imported) so IFeeRouter is self-contained
in ADR 016 — but the canonical layout pointer to ADR 027 §4 is preserved
as the source of truth in case the layout changes during the surface
lock-down (#451).

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
alpergundogdu added a commit that referenced this pull request May 7, 2026
…+ §C.1) (#458)

* docs(adr): FeeRouter interface block in ADR 016 §1 (#450 §A.2 + §B.4 + §C.1)

Adds a formal `interface IFeeRouter { ... }` block as a new "#### Contract:
FeeRouter" subsection in ADR 016 §1, after "#### Tunable Economics" and
before "##### No proxy deployment patterns". Closes three §450 acceptance
bullets:

- §A.2 — formal interface block consolidating signatures previously
  scattered across §1 classDiagram, §3 call table, ADR 026 §2 narrative,
  and ADR 003 references
- §B.4 — tunability surface: setSharesAndDestinations(...) atomic
  setter + per-knob setters (setShares, setVotingEscrow, etc.)
- §C.1 — zero-address dependency pattern documented in the constructor
  notes and surfaced via the cross-validation invariant on setShares

Surface highlights:

- routeSettlement(operator, bytesDelivered, amount) — entry point.
- commitEpochReceiptRoot / commitEpochSummary — signature stubs;
  full spec lives in ADR 027 §4 (PR 5).
- claimBoost / claimDelegator — return amount transferred for tooling;
  reverts on epochs older than the 26-epoch window.
- executeDelegatorSwap(epoch, minOut) — keeper trigger on FeeRouter,
  forwards to DelegatorBuyer (single Balancer V3 caller).
- sweepUnclaimed(epochs[]) — permissionless storage cleanup past the
  claim window; matches pruneBlacklistedAssignment pattern.
- workingBytes / epochTotalWorkingBytes / gaugeBucket / delegatorBucket
  — read views; off-chain bundling via Multicall3.
- setSharesAndDestinations(sharesBps[6], dests) — atomic activation
  flip; per-knob setters for routine governance after wiring.
- pause() / unpause() — blocks routeSettlement + claims +
  executeDelegatorSwap + sweepUnclaimed; commit functions stay open so
  operators don't lose gauge eligibility during pauses.
- Per-knob setter events; SharesUpdated event for setShares.

Notes section pins the design choices: epochLength and claimWindow are
immutable; workingBytes returns per-operator only (caller bundles via
Multicall3); ReceiptSummary signature stubbed pending ADR 027 §4;
no initialize() helper; storage shape is implementation-defined.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* docs(adr): add depositDelegatorTokens callback to IFeeRouter

Missing from the initial IFeeRouter block — `DelegatorBuyer` calls back
into FeeRouter via `depositDelegatorTokens(epoch, amount)` after the
Balancer V3 swap completes (per the §1 classDiagram and §3 call table
already on main from #449, and per the IDelegatorBuyer block landing in
PR 4 / #459).

`msg.sender == delegatorBuyer` is the sole auth check — same single
trust boundary pattern used in IDelegatorBuyer.swapDelegatorBucket
(`msg.sender == feeRouter`).

Adds matching `DelegatorTokensDeposited` event.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* docs(adr): clarify getShares() returns governance-set state (#458 review)

Address Gemini review on PR #458: explicitly note that getShares()
returns the configured bucket-share percentages (governance-set, last
updated via setShares / setSharesAndDestinations) rather than
operator-asserted or per-epoch-derived values. Also pin the return-array
ordering to match the setShares parameter order so off-chain consumers
can index into the result without ambiguity.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* docs(adr): align epoch type to uint64 in IFeeRouter (audit fix)

Cross-PR audit caught two type/signature inconsistencies between PR #458
(IFeeRouter) and the canonical surface in ADR 027 §4 / the existing prose:

1. epoch type: ADR 027 §4 prose uses `uint64 epochId` consistently
   (in commitEpochReceiptRoot signature, EpochReceiptSummary.epochId
   field, MMR addressing). PR #458's IFeeRouter declarations used
   `uint256 epoch` everywhere — inconsistent with the canonical type and
   slightly costlier for calldata-array call sites (claimBoost, etc.).
   Aligned all 11 sites + 7 event declarations to `uint64 epochId`.

2. commitEpochSummary signature: ADR 027 §4 line 144 explicitly allows
   "the operator (or any third party)" to call commitEpochSummary, with
   the operator passed as a parameter. PR #458 had a 2-param shape
   (epoch, summary) implying msg.sender-as-operator only — would have
   blocked the third-party-relay path. Changed to the 3-param canonical
   shape: commitEpochSummary(address operator, uint64 epochId,
   ReceiptSummary calldata summary).

(commitEpochReceiptRoot stays msg.sender-keyed per ADR 027 §4 line 118
"the caller is recorded as the credited operator" — the root commit is
self-authorising; only the summary submission has the third-party path.)

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* docs(adr): also fix Settled event epoch type (uint256 -> uint64)

* docs(adr): align IFeeRouter ReceiptSummary + events to ADR 027 §4 canonical (audit fix)

Cross-PR audit caught struct + event-shape divergence between PR #458
(IFeeRouter) and PR #460 (ADR 027 §4 canonical):

1. struct ReceiptSummary -> EpochReceiptSummary, with the canonical
   five fields (operator, epochId, claimedBytes, claimedDistinctClients,
   aggregateRoot). PR #458's two-field stub (distinctClientCount,
   totalBytes) used the wrong field names AND the wrong types
   (claimedDistinctClients is uint32 per ADR 027 §4 line 141, not uint256)
   AND was missing aggregateRoot.

2. EpochReceiptRootCommitted event: added leafCount field (the MMR's
   current depth). Matches the PR #460 declaration in ADR 027 §4 § Events
   so indexers don't have to chain prior events to reconstruct MMR state.

3. EpochSummaryCommitted event: renamed fields to claimedBytes /
   claimedDistinctClients (canonical), changed claimedDistinctClients to
   uint32 to match the storage type, added aggregateRoot field.

The struct is mirrored (not imported) so IFeeRouter is self-contained
in ADR 016 — but the canonical layout pointer to ADR 027 §4 is preserved
as the source of truth in case the layout changes during the surface
lock-down (#451).

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

---------

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
@alpergundogdu
alpergundogdu merged commit be524f4 into main May 7, 2026
9 checks passed
@alpergundogdu
alpergundogdu deleted the adr/450-pr5-receipt-anchoring branch May 7, 2026 14:47
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