Repository navigation
docs(adr): SafetyReserve + DelegatorBuyer interface blocks (#450 §A.3 + §A.4 + §B.6) - #459
Conversation
… + §A.4 + §B.6) ADR 026 §5: adds "#### Contract: SafetyReserve" subsection with the formal interface block consolidating signatures previously scattered across ADR 016 §1, ADR 026 §5 prose, and ADR 028 §123 stubs. ADR 026 §6: adds "#### Contract: DelegatorBuyer" subsection. Both implementation choices (parallel contract vs BuybackBurner multi-output mode) ship the same interface; the choice stays deferred per ADR 016 §1. Surface highlights: ISafetyReserve: - payout(bytes32 bundle, address recipient, uint256 usdcAmount) — single entry point. usdcAmount is named explicitly to encode the USDC-only payout constraint (TOKEN inflow gets swapped before becoming available). - Incident struct: bundle, recipient, usdcAmount, paidAt, paidBy, reason (enum: OutageRestitution, SlashAppealRatification, ProtocolHack, MisattributionFix, Other). Lets indexers reconstruct without aux state. - recordSlashInflow(operator, amount) — SLASH_INFLOW_REPORTER_ROLE-gated callback from StakingRegistry; new role mirrors SETTLEMENT_REPORTER_ROLE. Resolves §B.6. - swapAccumulatedTokens(amountIn, minOut) — KEEPER_ROLE per-call batch swap of accumulated TOKEN to USDC. Per-call shape lets keepers MEV-sequence; bounded by min/maxBatchAmount. - Appeal extension stubs (openSlashAppeal, fastTrackAppeal, rejectAppeal, ratifyAppeal, reverseAppeal) — signatures only; full state machine and window timing live in ADR 028 §6 and finalize under #451. - Full event set including Paid, SlashInflowRecorded, SwapExecuted, the five appeal-state events, and per-setter Updated events. - Pause blocks payout + swap; recordSlashInflow stays open so slashing accounting is never lost. IDelegatorBuyer: - swapDelegatorBucket(epoch, amountIn, minOut) — msg.sender == feeRouter is the sole auth check (single trust boundary, no KEEPER_ROLE on DelegatorBuyer needed). After Balancer swap, deposits resulting TOKEN back via IFeeRouter.depositDelegatorTokens. - Standard governance setters (setFeeRouter, setPool, slippage, batch bounds), pause/unpause, full event set. - Notes pin the deferred implementation choice and the §97 carve-out application for setFeeRouter. depositDelegatorTokens callback on FeeRouter is referenced in IDelegatorBuyer's prose but not added to IFeeRouter here — that fix lands on PR 3 (#458) directly since IFeeRouter is its scope. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
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]>
There was a problem hiding this comment.
Code Review
This pull request introduces the ISafetyReserve and IDelegatorBuyer interfaces to the adr/026-gauge-boost-tokenomics.md document, defining the logic for incident payouts, slash inflows, and delegator token swaps. Feedback was provided regarding missing anchor slugs in internal Markdown links to ensure proper navigation, the addition of missing events in the ISafetyReserve interface for consistency with its governance setters, and correcting an invalid anchor link to another ADR.
| // ─── Slash-appeal extensions (per ADR 028) ──────────────────────── | ||
| // Signature stubs only; full appeal state machine, window timing, | ||
| // and authorization rules are specified in | ||
| // [ADR 028 §6](028-slashing-appeals.md) and finalized as part of the |
There was a problem hiding this comment.
The link to ADR 028 §6 is missing an anchor slug. Per the repository's general rules, internal Markdown links should point to the specific section header using the correct GFM slug format.
| // [ADR 028 §6](028-slashing-appeals.md) and finalized as part of the | |
| // [ADR 028 §6](028-slashing-appeals.md#6-contract-surface) and finalized as part of the |
References
- Internal Markdown links must use correct GitHub Flavored Markdown (GFM) anchor slugs, generated by converting headers to lowercase and replacing spaces with hyphens.
There was a problem hiding this comment.
Addressed in 1143ac1: anchor now #6-contract-surface.
| event EmergencyMultisigUpdated(address indexed oldAddr, address indexed newAddr); | ||
| event AppealWindowUpdated(uint64 oldValue, uint64 newValue); | ||
| event PoolUpdated(address indexed oldPool, address indexed newPool); | ||
| event SlippageToleranceUpdated(uint256 oldBps, uint256 newBps); |
There was a problem hiding this comment.
The ISafetyReserve interface defines setters for minBatchAmount and maxBatchAmount (lines 249-250), but the corresponding events are missing from the Events section. For consistency with the IDelegatorBuyer interface and to ensure governance changes are observable, these events should be added.
| event SlippageToleranceUpdated(uint256 oldBps, uint256 newBps); | |
| event SlippageToleranceUpdated(uint256 oldBps, uint256 newBps); | |
| event MinBatchAmountUpdated(uint256 oldValue, uint256 newValue); | |
| event MaxBatchAmountUpdated(uint256 oldValue, uint256 newValue); |
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, including consistent use of recorded fields and exclusion criteria.
There was a problem hiding this comment.
Added MinBatchAmountUpdated and MaxBatchAmountUpdated events in 1143ac1.
|
|
||
| - **USDC-only payouts.** `usdcAmount` is named explicitly so the constraint is visible in the storage layout and on every `Paid` event. If a future ADR ever motivates multi-currency payouts, the additive shape is a `tokenOut` field plus an allowlist setter — no breaking change to existing `Incident` storage. | ||
| - **Governor and emergency-multisig addresses are governance-mutable.** The `setGovernor` / `setEmergencyMultisig` setters allow the eventual handover from the deployer EOA to `TimelockController` (per [ADR 016 § Post-Deployment Initialization](016-contract-interactions.md#post-deployment-initialization)) and any future re-pointing without contract redeployment. The 48h timelock constraint applies via `GOVERNANCE_ROLE`. | ||
| - **Appeal extensions are signature stubs.** This interface pins the function names and parameter types; the full state machine (`Open` → `FastTracked` / `Rejected` → `Ratified` / `Reversed` / `Lapsed`), window timing (filing, multisig review, ratification), and bond/restitution caps live in [ADR 028 §6](028-slashing-appeals.md) and are surface-locked under #451. |
There was a problem hiding this comment.
The link to ADR 028 §6 is missing an anchor slug. It should point to #6-contract-surface to adhere to GFM standards and improve document navigation.
References
- Internal Markdown links must use correct GitHub Flavored Markdown (GFM) anchor slugs, generated by converting headers to lowercase and replacing spaces with hyphens.
There was a problem hiding this comment.
Addressed in 1143ac1: anchor now #6-contract-surface.
- Fix two ADR 028 §6 cross-references to use the correct GFM anchor (#6-contract-surface). - Add MinBatchAmountUpdated and MaxBatchAmountUpdated events to ISafetyReserve, mirroring the per-setter event pattern used in IDelegatorBuyer and across the rest of the unified surface. The `#contract-feerouter` anchor in IDelegatorBuyer's swapDelegatorBucket comment is a forward reference to the heading PR #458 adds — it'll resolve once #458 merges. Keeping the anchor as-is rather than pointing at the existing `#feerouter` heading on main, which is the §6 Reentrancy Analysis subsection (different semantic target). Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…R_ROLE (audit fix) Cross-PR audit caught two issues in PR #459's surface: 1. epoch type: IDelegatorBuyer.swapDelegatorBucket and the DelegatorSwapped event used `uint256 epoch`, inconsistent with the canonical `uint64 epochId` used in ADR 027 §4 prose and now in IFeeRouter (#458 audit fix). Aligned both. 2. SLASH_INFLOW_REPORTER_ROLE undeclared in ADR 016 §5: PR #459 introduced this role on ISafetyReserve.recordSlashInflow but didn't add the corresponding row to the access control matrix. Added — mirrors SETTLEMENT_REPORTER_ROLE pattern (grant to StakingRegistry post-deploy). 3. KEEPER_ROLE row updated to remove DelegatorBuyer (the planning decision was msg.sender == feeRouter as the sole auth check on DelegatorBuyer.swapDelegatorBucket — not a KEEPER_ROLE) and add SafetyReserve.swapAccumulatedTokens. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Audit follow-up to 331a363. The SLASH_INFLOW_REPORTER_ROLE row was added to ADR 016 §5, but the corresponding grant call was missing from the "Post-Deployment Initialization" sequence — leaving auditors unable to verify when/where this role gets bound. Pairs the SafetyReserve.grantRole(SLASH_INFLOW_REPORTER_ROLE, stakingRegistry) call into post-deploy step 3 (alongside the SLASH_ROLE grant), matching the security-pairing pattern called out in the "Deployment atomicity" note. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…+ §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]>
Summary
Fourth slice of #450. Closes three acceptance bullets — §A.3, §A.4, §B.6 — by adding formal interface blocks for
SafetyReserve(ADR 026 §5) andDelegatorBuyer(ADR 026 §6).What's added
ADR 026 §5 —
interface ISafetyReserve { ... }payout(bytes32 bundle, address recipient, uint256 usdcAmount)— single entry point;usdcAmountnamed explicitly to encode the USDC-only constraintIncidentstruct withbundle,recipient,usdcAmount,paidAt,paidBy,reason(enum:OutageRestitution,SlashAppealRatification,ProtocolHack,MisattributionFix,Other);incidents(id)+incidentCount()viewsrecordSlashInflow(operator, amount)—SLASH_INFLOW_REPORTER_ROLE-gated callback fromStakingRegistry; new role mirrorsSETTLEMENT_REPORTER_ROLEswapAccumulatedTokens(amountIn, minOut)—KEEPER_ROLEper-call batch swap; bounded bymin/maxBatchAmountopenSlashAppeal,fastTrackAppeal,rejectAppeal,ratifyAppeal,reverseAppeal— full state machine deferred to ADR 028 §6 / #451setGovernor,setEmergencyMultisig,setAppealWindow,setMin/MaxBatchAmount,setPool,setSlippageToleranceBpspayout+swapAccumulatedTokens;recordSlashInflowstays open so slashing accounting is never lost during pausesPaid,SlashInflowRecorded,SwapExecuted, five appeal-state events, six setter eventsADR 026 §6 —
interface IDelegatorBuyer { ... }swapDelegatorBucket(epoch, amountIn, minOut)—msg.sender == feeRouteras the sole auth check (single trust boundary, noKEEPER_ROLEneeded). After Balancer swap, deposits resulting TOKEN back viaIFeeRouter.depositDelegatorTokensfeeRouter,pool,slippageToleranceBps,min/maxSwapAmountsetFeeRouter,setPool,setSlippageToleranceBps,setMin/MaxSwapAmountpause/unpauseDelegatorSwapped, five setter eventsDecisions baked in (per planning conversation)
payoutbundle registrationpayout)Incidentstruct fieldsbundle,recipient,usdcAmount,paidAt,paidBy,reasonenum — five primitive fields plus the categorical tagusdcAmountfield name encodes the constraintSLASH_INFLOW_REPORTER_ROLEgranted toStakingRegistryswapAccumulatedTokensshapemin/maxBatchAmountboundsDelegatorBuyer.swapDelegatorBucketauthmsg.sender == feeRouteronly (single trust boundary)Not included
IFeeRouter.depositDelegatorTokens(epoch, amount)— referenced inIDelegatorBuyer.swapDelegatorBucketprose but not added toIFeeRouterhere. PR 3 (decdn#458) is the scope for theIFeeRouterblock; the missing method will land as a small follow-up commit on that branch.Out of scope
commitEpochReceiptRoot/commitEpochSummaryfull spec (PR 5, ADR 027 §4)Test plan
pre-commit run --files adr/026-gauge-boost-tokenomics.mdcleanRelated
IStakingRegistry), docs(adr): VotingEscrow interface block in ADR 026 §4 (#450 §A.1) #456 (IVotingEscrow), docs(adr): FeeRouter interface block in ADR 016 §1 (#450 §A.2 + §B.4 + §C.1) #458 (IFeeRouter)commitEpochReceiptRoot/commitEpochSummaryfull spec in ADR 027 §4🤖 Generated with Claude Code