Skip to content

ADR surface-gap audit: missing interface blocks and unspecified function signatures across the unified contract surface #450

Closed

Description

@alpergundogdu

Summary

Follow-up to #449. With the contract inventory unified, the next blocker for audit-readiness is that several contracts have no canonical Solidity interface block in the ADRs — their signatures are scattered across narrative paragraphs, mermaid diagrams, and call-table rows. Other functions are referenced in cross-contract call graphs but never specified anywhere. This issue is the inventory pass; the actual fills land as a series of small ADR PRs (step 3 of the planning sequence).

Why now

Auditors and implementers both need a single canonical place per contract that says "here is the external surface". For PublisherRegistry, OriginAssignment, ContentBlacklist, StakingRegistry, StablePaymentChannel, SlashJudge, BuybackBurner, and TOKEN this exists today (formal interface IFoo { ... } blocks in ADR 002 / 003 / 011 / 014). For the remaining contracts in the unified inventory it does not.

This issue lists every gap; PRs against it land the missing interface blocks.

A. Missing formal interface blocks

For each contract below, no consolidated interface IFoo { ... } block exists in any ADR. Methods are inferred from prose, mermaid diagrams, and ADR 016 §3 call-table rows.

A.1 VotingEscrow (ADR 026 §4)

ADR 026 §4 describes the contract narratively and mentions createLock, increaseAmount, increaseUnlockTime, balanceOfAt, totalSupplyAt. Add a formal interface block to ADR 026 §4 covering at minimum:

  • createLock(uint256 amount, uint256 unlockTime) / increaseAmount(uint256) / increaseUnlockTime(uint256 unlockTime) / withdraw()
  • balanceOf(address) / balanceOfAt(address, uint256 ts) / totalSupply() / totalSupplyAt(uint256 ts)
  • delegate(address) (Governor Bravo pattern, referenced in ADR 009 §44)
  • Lock view: locked(address) returns (uint256 amount, uint256 end)
  • Events: LockCreated, LockIncreased, LockExtended, Withdrawn, DelegateChanged

A.2 FeeRouter (ADR 016 §1, ADR 026 §2)

The function-name pieces are scattered across the ADR 016 §3 call table, ADR 026 §2 narrative, and the ADR 016 §1 mermaid classDiagram block. Add a formal interface block to ADR 016 (new subsection §"FeeRouter contract surface") covering:

  • routeSettlement(address operator, uint256 bytesDelivered, uint256 amount) (signature confirmed by ADR 003 §110, §407 and ADR 016 §283 — verify all three stay in sync)
  • claimBoost(uint256[] epochs) / claimDelegator(uint256[] epochs)
  • commitEpochReceiptRoot(uint256 epoch, bytes32 root) / commitEpochSummary(...) (called by operators; see §B.3 below)
  • workingBytes(address operator, uint256 epoch) / read-side surface for off-chain claim simulation
  • executeDelegatorSwap(uint256 epoch, uint256 minOut) (KEEPER_ROLE)
  • Tunability surface from ADR: unify contract surface; drop PoC/Production phasing in favor of tunable economics #449 §B (see §B.4 below)
  • Events: Settled, BoostClaimed, DelegatorClaimed, EpochReceiptRootCommitted, DelegatorSwapped, plus the share/dependency setter events

A.3 SafetyReserve (ADR 026 §5, ADR 028)

ADR 028 §123 defines the appeal extensions but the base interface (payout, incidents) is only referenced. Consolidate in ADR 026 §5 (and link from ADR 028):

  • payout(bytes32 bundle, address recipient, uint256 amount) — PAYOUT_AUTHORIZER_ROLE per ADR 016 §454
  • incidents(uint256 id) view returning the on-chain incident record
  • ADR 028 §123 appeal extensions: openSlashAppeal / fastTrackAppeal / rejectAppeal / ratifyAppeal / reverseAppeal
  • Slashing-redirect inflow surface (StakingRegistry calls SafetyReserve with TOKEN; per ADR 016 §300 row — what's the function signature it calls?)
  • Keeper-triggered TOKEN→USDC swap path per ADR 016 §190 (same Vault-scoped self-approval pattern as BuybackBurner)
  • Events: IncidentRecorded, Paid, SlashAppealOpened, SlashAppealFastTracked, SlashAppealRejected, SlashAppealRatified, SlashAppealReversed, SlashedTokenReceived, SwapExecuted

A.4 DelegatorBuyer (or BuybackBurner-multi-output mode)

ADR 026 §6 describes the swap behavior; ADR 016 §35 leaves the implementation choice deferred. Either way, FeeRouter.executeDelegatorSwap needs to know what it's calling. Add a minimal interface to ADR 026 §6:

  • swapDelegatorBucket(uint256 epoch, uint256 amountIn, uint256 minOut) — KEEPER_ROLE or FeeRouter-only
  • A defined return path so swapped TOKEN ends up in FeeRouter's delegator bucket for claimDelegator to draw against (storage write target needs to be specified — does DelegatorBuyer push to FeeRouter, or does FeeRouter pull?)

B. Function signatures referenced but never specified

B.1 StakingRegistry.isActive(address operator) → bool

Referenced in:

  • ADR 016 §3 call graph line OA -->|"isActive(operator)"| SR
  • ADR 016 §3 call table row 295 (OriginAssignment → StakingRegistry: isActive(operator))
  • ADR 011 §454 (OriginAssignment reads StakingRegistry.isActive(operator))
  • ADR 016 §586, §587, §591 (OriginAssignment.proposeAssignment / activateAssignment / default-open setters validate per operator)

Not in IStakingRegistry definition. Add to ADR 003 §"IStakingRegistry interface" (currently around §623 where nodeIdOf lives).

B.2 nodeIdOf return type — pick one

Cross-ADR inconsistency:

  • ADR 003 §623: function nodeIdOf(address operator) external view returns (bytes32 nodeId, bool active); (tuple)
  • ADR 022 §148: also claims tuple return ("a single read per operator, returning (nodeId, active)")
  • Implementation in feat(contracts): scaffold PoC EVM contract set per ADR 016 #237: returns plain bytes32 (no active flag)

Resolve by either: (a) splitting into nodeIdOf(address) returns (bytes32) + isActive(address) returns (bool) (matches §B.1), or (b) keeping the tuple. Recommendation: (a) — separate functions are cheaper to compose and avoid tuple-return gas overhead when callers only need one value. Update ADR 003 §623 and ADR 022 §148 accordingly.

B.3 commitEpochReceiptRoot / commitEpochSummary full spec

ADR 003 §407 says "operators commit per-epoch roots directly to FeeRouter.commitEpochReceiptRoot (see ADR 027 §4)". ADR 016 §538 references the same names. The full signatures, who-can-call rules, when-callable rules, storage layout, and interaction with routeSettlement and claimBoost need a formal spec in ADR 027 §4 (anchoring) — and a back-link from ADR 026 §3 (gauge formula).

B.4 Tunability surface from #449 §B

Issue #449 §B specifies the tunability pattern but the actual function signatures haven't landed in any ADR:

  • FeeRouter.setShares(uint256 operatorBaseBps, uint256 gaugeBoostBps, uint256 delegatorBps, uint256 buybackBps, uint256 treasuryBps, uint256 safetyBps) — GOVERNANCE_ROLE, sum-to-10000 invariant, cross-validation against dependency addresses
  • FeeRouter.setVotingEscrow(address) / setSafetyReserve(address) / setDelegatorBuyer(address) / setBuybackBurner(address) / setTreasury(address) — GOVERNANCE_ROLE, governance timelock
  • Read views: getShares() returns (uint256[6]), votingEscrow() / safetyReserve() / delegatorBuyer() / buybackBurner() / treasury() address getters

Lands as part of A.2 in ADR 016.

B.5 PaymentChannel.setFeeRouter carve-out

ADR 003 §341 declares the function. #449 §C adds the §97 carve-out clarifying that helper-contract addresses are governance-mutable on signing contracts. The actual setter signature, the role that can call it, and the timelock requirement are not yet specified in ADR 003. Add to ADR 003 §"Governance functions" near §341.

B.6 StakingRegistry → SafetyReserve slashing-redirect call

ADR 016 §300 row says StakingRegistry → SafetyReserve for the 30% slashed-TOKEN redirect, but the receiving function on SafetyReserve is unnamed. Either:

  • SafetyReserve exposes a safeTransfer-only inflow (no callback) and StakingRegistry.slash does safeTransfer(safetyReserve, slashedAmount * 30 / 100) — simplest
  • SafetyReserve.recordSlashInflow(address slashedNode, uint256 amount) for indexed accounting

Pick one and specify in §A.3.

C. Construction and init edge cases

C.1 FeeRouter zero-address dependencies

Issue #449 §A & §E state that FeeRouter deploys with zero-address dependencies for VotingEscrow / SafetyReserve / DelegatorBuyer if those aren't ready, with setShares cross-validation enforcing share=0 when address=0. The constructor parameter list in ADR 016 §152 currently requires all addresses. Update §152 to allow zero addresses and document the cross-validation invariant.

C.2 OriginAssignment edge cases

ADR 011 §"Contract: OriginAssignment" specifies the proposal/activation flow but does not enumerate edge cases:

  • Zero proposed operators in proposeAssignment — revert? allow as "remove all origins"?
  • Multiple pending proposals for the same namespace — overwrite previous, or revert until previous is activated/expired?
  • Pending proposal expiry — does a stale proposal time out, or does it sit until manually replaced?
  • All proposed operators become inactive between proposal and activation — activateAssignment reverts and publisher must re-propose (ADR 011 §427) — confirmed; document the storage-cleanup behavior for the rejected proposal

Resolve in ADR 011 §"Contract: OriginAssignment" or in a new §"Edge cases" subsection.

C.3 PublisherRegistry namespace registration cap & timelock binding

ADR 002 §93 says "per-publisher namespace cap and ownership-transfer timelock are governable parameters with safety bounds (see ADR 009)". ADR 009 §92 has the bounds. The actual setter functions (setMaxNamespacesPerPublisher, setNamespaceTransferTimelock) and which contract holds these (governance parameter store vs PublisherRegistry-local) need to be pinned. Add to ADR 002 §"Contract: PublisherRegistry".

Out of scope

Acceptance

Each subsection becomes one ADR PR. Track here:

  • §A.1 VotingEscrow interface block in ADR 026 §4
  • §A.2 FeeRouter interface block in ADR 016 (new subsection)
  • §A.3 SafetyReserve interface block in ADR 026 §5 (with appeals extensions consolidated from ADR 028)
  • §A.4 DelegatorBuyer minimal interface in ADR 026 §6
  • §B.1 StakingRegistry.isActive(operator) in ADR 003 IStakingRegistry block
  • §B.2 nodeIdOf return type aligned across ADR 003 §623, ADR 022 §148, and feat(contracts): scaffold PoC EVM contract set per ADR 016 #237's source
  • §B.3 commitEpochReceiptRoot / commitEpochSummary full spec in ADR 027 §4
  • §B.4 FeeRouter tunability setters in ADR 016
  • §B.5 PaymentChannel.setFeeRouter setter spec in ADR 003
  • §B.6 StakingRegistry → SafetyReserve redirect call signature pinned
  • §C.1 FeeRouter zero-address constructor in ADR 016 §152
  • §C.2 OriginAssignment edge cases in ADR 011
  • §C.3 PublisherRegistry cap/timelock setters in ADR 002

Related

Metadata

Metadata

Assignees

Labels

design:adrdesign:missing-decisionkind:docs

Type

No type

Fields

Priority

None yet

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions