Skip to content

docs(adr): align ADR 016 contract tables with shipped contracts; correct the Balancer V3 approval target - #1570

Merged
alpergundogdu merged 3 commits into
mainfrom
docs/1557-adr016-inventory-drift
Aug 3, 2026
Merged

alpergundogdu merged 3 commits into
mainfrom
docs/1557-adr016-inventory-drift

Conversation

@yigitdot

@yigitdot yigitdot commented Aug 1, 2026 •

Copy link
Copy Markdown
Contributor

ADR 016's Contract Inventory and Constructor Dependencies tables are the single reference for security audits, so they have to match the shipped Solidity. Five places had drifted. Review surfaced a sixth — the Balancer V3 approval target, which spans ADR 003 and ADR 018 as well — plus three defects found by a verification pass over the PR itself. Documentation only: no contract, script, or Rust code is touched.

What changed

1. CapacityBond constructor + terms acceptance. The row now lists all nine constructor arguments, including currentTermsHash, and notes that the zero sentinel reverts ZeroTermsHash so a terms-disabled deployment is unreachable. A new § Operator-terms acceptance subsection covers the mechanism: registerNode reverting TermsHashMismatch, the EIP-712 registration signature carrying termsHash, the TermsAccepted record, the GOVERNANCE_ROLE-gated setCurrentTermsHash, and why the parameter carries no numeric safety rail. setCurrentTermsHash is also added to the GOVERNANCE_ROLE role-assignment row, the Governor→CapacityBond call-table row, and the Governance-Controlled Parameters table.

2. FeeRouter constructor. The row now lists capacityBond and windowEpochs. The constructor reads CapacityBond.epochLength() once, reverts EpochLengthMismatch unless it equals the passed epochLength, then drops the reference — a deploy-time dependency, not a stored one — and windowEpochs is bounds-checked [4, 26]. The deployment-order graph gains the matching FeeRouter → CapacityBond edge, previously invisible.

3. ContentBlacklist constructor. The pinned signature is now the real one, ContentBlacklist(ICapacityBondEjector capacityBond, address admin), with both arguments zero-rejected and the admin receiving DEFAULT_ADMIN_ROLE + GOVERNANCE_ROLE.

4. Ed25519Verifier. The contract gains an inventory row and a deployment step at 4, immediately before CapacityBond, whose constructor takes its address and rejects zero; steps 4–13 shift to 5–14. It also gains a Cross-Contract Call Graph edge and call-table row for the verify call CapacityBond makes in registerNode / bindNodeId / reclaimNodeId, and the OZ AccessControl usage row is corrected to exclude it.

5. BuybackBurner inventory row. The row now describes the shipped three-layer hierarchy: the abstract venue-neutral BuybackBurner base on SunsettingPausable, the abstract GuardedBuybackBurner MEV-defense layer, and the concrete BuybackBurnerBalancerV3 / BuybackBurnerUniswapV3 venue bindings.

6. Balancer V3 approval target — the Vault is not one. All three ADRs documented BuybackBurner as self-approving the Balancer V3 Vault, and ADR 016 cited the worst instance as its authority: ADR 018 § Buyback execution carried it as a titled "Approvals footgun — the contract approves the Vault" paragraph. The shipped BuybackBurnerBalancerV3._swap does the opposite — the Router pulls tokenIn through permit2.transferFrom, so each swap approves in two scoped legs and resets both to 0 afterwards. balancerVault is read-only: isPoolRegistered, getStaticSwapFeePercentage, and the scaled-18 leg balances behind the TWAP. Correcting ADR 016 alone would have pointed a fixed claim at an unfixed source, so all eight occurrences are corrected together.

Review fixes

A verification pass over this PR (ADR 016 claims against contracts/src/, the Permit2 correction plus a corpus-wide sweep, and ASD-STE100 compliance) confirmed every substantive claim the PR adds and found no surviving instance of the old Vault claim. It also found three defects, fixed in 0d866cb:

Stale cross-ADR step reference — introduced by this PR. adr/036-served-bytes-voting-weight.md:193 said "Deployment Order step 13 (DecdnGovernor)". Inserting Ed25519Verifier as step 4 shifted the Governor to 14. make -C adr check-refs validates anchors, not bare step numbers, so CI stayed green on a wrong reference. It was the only external reference to ADR 016's numbering.

Deployment row 7 named an abstract contract in a mandatory-looking slot. BuybackBurner is abstract (BuybackBurner.sol:42) and undeployable, while item 5 above now labels it so and the row body describes BuybackBurnerBalancerV3's Config. The burner is also not in the main pipeline: it deploys only under if (act.activate) (off by default) after the Governor — which ADR 016's own prose at :388 already said. The row now names the concrete bindings and marks position 7 a dependency slot, not a wall-clock one. Deliberately not renumbered, since renumbering caused the finding above.

§ Operator-terms acceptance omitted a caveat ADR 019 makes explicit — that registration-only enforcement does not freeze an operator's obligations at the version they signed. Added, with the duplicated governance-norm sentence dropped in favour of pointing at ADR 019.

Also applied: rows :307 (225w) and :308 (173w) had grown past the table's prior maximum, so they were extracted to construction-notes subsections following the OriginAssignment precedent already in the file (→ 82w and 77w); the Permit2 mechanism was written out in full in five places that all already cross-linked ADR 018, so it is reduced to one authority plus pointers on a single term; and four pre-existing one-liners were swept (a solid Mermaid arrow for a non-dependency, a Permit2 reference pointing at a section with no Permit2 text, an unnamed PoolNotWired precondition, and two ADR 003 links naming a section title that does not exist).

The rows the issue verified clean — SlashAppeal, SlashJudge, PaymentChannel, PublisherRegistry constructors, the ADR 009/002 bounds, and the SunsettingPausable deadline — are untouched.

Verification

$ make -C adr check-refs
no bare ADR references (37 files; code + H1 titles excluded, H2-H6 checked)
all ADR cross-links carry a #anchor
1632 ADR #anchor link(s) resolve (38 files scanned, 809 headings indexed)
no numeric §N refs or numbered headings (RFC/EIP/BIP § exempt)

pre-commit run --files passes on all four ADRs, and full CI is green. Because check-refs cannot see bare step numbers, that class is checked separately with grep -rn "step 1[0-4]\b" adr/*.md. Every claim was read back against contracts/src/.

Follow-up

#1579 tracks three related pieces of drift outside this PR's scope, all fallout from the venue-neutral burner refactor: ADR 003's flat "canonical BuybackBurner interface" table (which lists setVault, a Balancer-only method), the approvals footgun missing from adr/appendix-l2-deployment.md despite ADR 018 requiring it, and IBuybackBurner being referenced in two places without existing.

Closes #1557

🤖 Generated with Claude Code

…hipped contracts

Add the deployed Ed25519Verifier to the contract inventory and the
deployment order, renumbering the constructor-dependency steps so the
sequence is executable. Correct the CapacityBond, FeeRouter, and
ContentBlacklist constructor rows against the shipped Solidity, describe
the BuybackBurner class hierarchy, and document CapacityBond's
operator-terms acceptance mechanism.

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

coderabbitai Bot commented Aug 1, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

@yigitdot, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 55 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Free

Run ID: 4f9dee4b-702a-4f3f-b62c-d5b273b02348

📥 Commits

Reviewing files that changed from the base of the PR and between b2a9651 and 0d866cb.

📒 Files selected for processing (4)
  • adr/003-payments.md
  • adr/016-contract-interactions.md
  • adr/018-liquidity-strategy.md
  • adr/036-served-bytes-voting-weight.md

Note

🎁 Summarized by CodeRabbit Free

Your organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login.

Comment @coderabbitai help to get the list of available commands.

Copilot AI 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.

Pull request overview

This PR updates ADR 016 to bring its contract inventory, deployment order, constructor dependency tables, and cross-contract call references back in sync with the shipped Solidity contracts, so the ADR remains a reliable audit reference.

Changes:

  • Expands/updates constructor dependency documentation (notably for CapacityBond, FeeRouter, ContentBlacklist) and adds an Ed25519Verifier deployment step.
  • Adds an “Operator-terms acceptance” section describing CapacityBond’s currentTermsHash mechanism and governance control (setCurrentTermsHash).
  • Updates call graph / call tables and role/parameter tables to reflect the new/updated dependencies and surfaces.
Suppressed comments (1)

adr/016-contract-interactions.md:458

  • This call-table note repeats the same incorrect claim about self-approving the Vault. In the shipped BuybackBurnerBalancerV3, the Router pulls tokenIn via Permit2 and the Vault is used for pool/state reads; there is no direct Vault allowance/approval path.
| BuybackBurner | Balancer V3 Router | `swapSingleTokenExactIn(pool, tokenIn, tokenOut, exactAmountIn, minAmountOut, deadline, wethIsEth, userData)` | `BuybackBurner` self-approves the **Balancer V3 Vault** address (NOT the Router) during its initialization — the Vault pulls input tokens from the `msg.sender` of the Router call. This is the V3 footgun; see [ADR 018 § Buyback execution via Balancer V3](018-liquidity-strategy.md#buyback-execution-via-balancer-v3) | Yes |

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread adr/016-contract-interactions.md Resolved
…Permit2

ADRs 003, 016, and 018 all documented BuybackBurner as self-approving the
Balancer V3 Vault, with ADR 018 carrying it as a titled "approvals footgun"
that ADR 016 cites as the authority. The shipped BuybackBurnerBalancerV3 does
the opposite: the Router pulls tokenIn through permit2.transferFrom, so _swap
approves in two scoped legs (usdc.forceApprove(permit2, amountIn), then
permit2.approve(usdc, swapRouter, amountIn, block.timestamp)) and resets both
to zero afterwards. The Vault is never an approval target — balancerVault is
read-only for isPoolRegistered, getStaticSwapFeePercentage, and the scaled-18
leg balances behind the TWAP.

Corrected in all eight places, plus two adjacent drifts found while fixing it:
the base BuybackBurner stores only USDC and TOKEN (not the Vault and pool),
and the ADR 016 constructor row omitted admin, vault_, permit2_, and the
GuardParams band.

Documentation only — no contract, script, or Rust code is touched.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@yigitdot yigitdot changed the title docs(adr-016): align contract inventory and constructor tables with shipped contracts docs(adr): align ADR 016 contract tables with shipped contracts; correct the Balancer V3 approval target Aug 1, 2026
@yigitdot

yigitdot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor Author

Response to the Copilot review

One finding, and it was correct. Both the inline comment on :307 and the suppressed comment on :458 are fixed in 1b09788 — replying here as well because a suppressed comment has no thread.

The finding

BuybackBurner does not self-approve the Balancer V3 Vault. BuybackBurnerBalancerV3._swap (contracts/src/BuybackBurnerBalancerV3.sol:165-183):

usdc.forceApprove(address(permit2), amountIn);
permit2.approve(address(usdc), address(swapRouter), uint160(amountIn), uint48(block.timestamp));
tokenOut = swapRouter.swapSingleTokenExactIn(...);
permit2.approve(address(usdc), address(swapRouter), 0, 0);
usdc.forceApprove(address(permit2), 0);

The Router pulls tokenIn through permit2.transferFrom, so the spend is authorized in two scoped legs and both are reset to zero in the same transaction. balancerVault is read-only for this contract — isPoolRegistered (:277), getStaticSwapFeePercentage (:188), and the scaled-18 leg balances behind the TWAP (:285). The contract's own NatSpec says so at :66-69: "not as an approval target".

Scope of the fix

The claim was in three ADRs, eight places — and ADR 016 cited the worst instance as its authority. ADR 018 § Buyback execution carried it as a titled "Approvals footgun — the contract approves the Vault" paragraph. Fixing only the two lines flagged would have left a corrected ADR 016 pointing at an uncorrected source, so all three are corrected together:

File Lines
adr/016-contract-interactions.md 307 (inventory row), 458 (call table), 675 (function-level note)
adr/003-payments.md 594 (setter table), 598 (V3 integration note)
adr/018-liquidity-strategy.md 10 (amendment), 114 (footgun paragraph), 138 (parameter table), 163 (activation criterion)

Two adjacent drifts turned up while fixing it and are in the same commit:

  • ADR 018:10 claimed the base BuybackBurner "stores only the Vault and pool". It stores only usdc and token (BuybackBurner.sol:58,61); the Vault, pool, Router, and Permit2 all live in the subclass.
  • ADR 016:307 omitted admin, vault_, permit2_, and the GuardParams band from the constructor list — the same drift class this PR exists to close, and permit2_ is zero-rejected.

Note on the review summary

The overview above predates this commit and describes five changes. There are now six: the PR title and body have been updated, and the "Follow-up spotted, not fixed here" section — which flagged exactly this issue and deferred it — is gone, because it is now fixed here.

Verification

make -C adr check-refs and pre-commit run --files pass on all three ADRs. Still documentation-only: no contract, script, or Rust code is touched.

… oversized cells

Review of #1570 confirmed every factual claim it adds against contracts/src/,
and found no surviving instance of the old Vault-approval error. It also found
three defects, fixed here.

Correctness:

- adr/036:193 said "Deployment Order step 13 (DecdnGovernor)". Inserting
  Ed25519Verifier as step 4 shifted the Governor to 14. This PR broke it and
  check-refs cannot catch bare step numbers, so CI stayed green. It was the
  only external reference to ADR 016's numbering.
- Deployment row 7 named BuybackBurner, which is abstract and undeployable,
  and sat in a slot implying it ships with the mandatory pipeline. It does
  not: it is deployed only under genesis activation (off by default), after
  the Governor. ADR 016's own prose already said so. The row now names the
  concrete venue bindings and marks the slot a dependency position, not a
  wall-clock one. Deliberately not renumbered — renumbering caused the break
  above.
- The currentTermsHash paragraph stated registration-only enforcement without
  ADR 019's caveat that this does not freeze an operator's obligations at the
  version they signed. Added, and the duplicated governance-norm sentence
  dropped in favour of pointing at ADR 019.

Readability: rows 307 (225w) and 308 (173w) had grown past the table's prior
maximum and carried bolded pseudo-headings. Extracted to BuybackBurner and
FeeRouter construction-notes subsections, following the OriginAssignment
precedent already in the file. Inventory rows 27 and 32 trimmed likewise.

Consistency: the Permit2 mechanism was written out in full in five places, all
of which already cross-linked ADR 018 as the authority. Reduced to one
authoritative explanation plus pointers, on a single name ("scoped per-swap
Permit2 approval") and a single reset spelling.

Also swept, pre-existing: the Mermaid OA --> CB edge was solid for a
non-dependency while the analogous FR -.-> BB is dotted; 018:179 pointed its
Permit2 reference at a section with no Permit2 text; 018:113 described the
executeBuyback precondition without naming PoolNotWired or the Vault leg; two
ADR 003 links named a section title that does not exist.

Documentation only — no contract, script, or Rust code is touched.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@github-actions

github-actions Bot commented Aug 2, 2026

Copy link
Copy Markdown

Gas snapshot

No gas changes vs base.

@github-actions

github-actions Bot commented Aug 2, 2026

Copy link
Copy Markdown

Contracts coverage

Line coverage: 89.80% (2597/2892 lines)
▲ +0.00pp vs base (89.80% → 89.80%)
Run: 30724721906

@github-actions

github-actions Bot commented Aug 2, 2026

Copy link
Copy Markdown

Coverage report

Total: 80.16% (was 80.15%, ● 0.00%) — 56271/70202 lines

No Rust files changed in this PR.

History
Commit Total Δ vs base
0d866cb (HEAD) 80.16% ● 0.00%

@alpergundogdu
alpergundogdu merged commit f6695ff into main Aug 3, 2026
25 checks passed
@alpergundogdu
alpergundogdu deleted the docs/1557-adr016-inventory-drift branch August 3, 2026 11:44
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.

ADR 016: contract inventory and constructor tables drift from the shipped contracts

3 participants