Skip to content

docs(adr): align ADR 016 CapacityBond genesis-credit surface with shipped contract (#771) - #787

Merged
thiras merged 2 commits into
mainfrom
docs/771-adr016-capacitybond-align
Jun 3, 2026
Merged

thiras merged 2 commits into
mainfrom
docs/771-adr016-capacitybond-align

Conversation

@thiras

@thiras thiras commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Closes #771

Documentation-only alignment of adr/016-contract-interactions.md against the shipped contract (source of truth): contracts/src/CapacityBond.sol, contracts/src/interfaces/ICapacityBond.sol, contracts/src/DecdnGovernor.sol. Every name/signature was verified via forge inspect CapacityBond abi (and forge inspect DecdnGovernor abi) plus direct source reads. No contract or Rust code changed.

Changes

  1. accrueGenesisVest(operator) removed — no such function exists. Vesting is computed on demand; shipped reads are curveVested(operator) / claimableCredit(operator) (internal _curveVested). Fixed in the ICapacityBond block, class diagram, comments, and reentrancy table.
  2. claimVestedCredit arity — shipped is claimVestedCredit() external (no operator arg; acts on msg.sender; nonReentrant whenNotPaused). Fixed in interface block, class diagram, reentrancy table.
  3. PendingCredit struct — corrected to { uint128 originalGrant; uint128 claimed; uint64 grantedAt; } (no stored vested). Fixed the grant guard (originalGrant == 0) and the slashing-applies-to pool (originalGrant - claimed).
  4. bondedAmount → activeBond / bondOf — bondedAmount is not a shipped field; storage mapping is activeBond, surfaced via bondOf(operator).
  5. CapacityBond constructor row — k/α and the capacity band are storage defaults initialized in-constructor and tunable post-deploy (setK/setAlpha/setMinCapacityMbps/setMaxCapacityMbps), NOT constructor args; age_ramp_months lives on DecdnGovernor. Listed the actual constructor params.
  6. Capacity-band names — aligned to shipped minCapacityMbps / maxCapacityMbps.

Review

Source of truth = the shipped contract. Re-verified the final diff against the live ABI:

  • pendingCredit(address) returns tuple (uint128 originalGrant, uint128 claimed, uint64 grantedAt) ✓
  • claimVestedCredit() no-arg, nonpayable ✓; curveVested/claimableCredit/bondOf are view -> uint256 ✓
  • setK/setAlpha/setMinCapacityMbps/setMaxCapacityMbps exist on CapacityBond ✓

Finding declined (1): The issue's items 6 (Tunable-Economics) and 7 (Governor self-governance setters) asked to mark k/α as not on-chain-tunable and to add setVoteCapBps/setAgeRampMonths. The shipped contract contradicts the "not tunable" premise — setK/setAlpha exist on CapacityBond (kConstant/alphaWad storage), and the ADR already documents setVoteCapBps/setAgeRampMonths correctly on DecdnGovernor (checkpointed, with events). Per the source-of-truth rule, those tables were left matching the contract rather than introducing new errors.

Coordination with #770

Items 6–7 overlap open issue #770's tables (Tunable-Economics, Cross-Contract Call Graph / GOVERNANCE_ROLE). Those tables were already contract-accurate, so this PR makes no edits there — keeping the change scoped to the genesis-credit / constructor / struct surface to avoid collisions with #770.

🤖 Generated with Claude Code

…pped contract (#771)

Fix doc/contract mismatches in ADR 016 against the shipped CapacityBond,
ICapacityBond, and DecdnGovernor sources (verified via `forge inspect`):

- Remove non-existent `accrueGenesisVest(operator)`; vesting is on-demand
  via `curveVested(operator)` / `claimableCredit(operator)`.
- Correct `claimVestedCredit` to its shipped no-arg form (acts on msg.sender,
  `nonReentrant whenNotPaused`).
- Fix `PendingCredit` struct to `{ uint128 originalGrant; uint128 claimed;
  uint64 grantedAt; }` (no stored `vested`); update the grant guard and
  slashing-applies-to pool to `originalGrant - claimed`.
- Replace `bondedAmount` with the shipped `activeBond` storage / `bondOf`
  read.
- Correct the CapacityBond constructor-params row: k/alpha and the capacity
  band are storage defaults set in-constructor and tunable post-deploy, not
  constructor args; age_ramp_months lives on DecdnGovernor.
- Align capacity-band parameter names to `minCapacityMbps`/`maxCapacityMbps`.

Items 6-7 (Tunable-Economics k/alpha tunability, Governor self-governance
setters) were already correct in the shipped ADR; the issue's premise that
k/alpha are not on-chain-tunable is contradicted by the contract
(`setK`/`setAlpha`), so those tables are left as-is to match the contract.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Copilot AI review requested due to automatic review settings June 2, 2026 18:54

@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 the contract interactions ADR to reflect architectural changes in the CapacityBond contract, transitioning from state-mutating genesis credit vesting to on-demand view-based calculations (curveVested and claimableCredit) and updating the PendingCredit struct. It also documents new constructor and governance-tunable parameters. The review feedback recommends explicitly defining the safety bounds for minCapacityMbps in the parameter table as 10 Mbps to 1000 Mbps to ensure consistency with the implementation and other ADRs.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

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

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’s documented CapacityBond “genesis credit” surface to match the currently shipped Solidity contracts, removing stale function/field names and correcting struct/signature details so the ADR reflects the real ABI.

Changes:

  • Replaced nonexistent/incorrect genesis-credit functions (accrueGenesisVest, claimVestedCredit(address)) with shipped curveVested, claimableCredit, and claimVestedCredit() (no args).
  • Corrected PendingCredit struct fields and updated the slashing-at-risk pool description to use originalGrant - claimed.
  • Updated deployment/economics/reentrancy tables to use shipped names (bondOf/activeBond, minCapacityMbps/maxCapacityMbps) and constructor parameter list.

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

Comment thread adr/016-contract-interactions.md Resolved
Fill in minCapacityMbps Min/Max safety bounds (10 Mbps / 1 Gbps) in the
governable-parameters table, matching the shipped CapacityBond
_enforceMinCapacityBounds(MIN_CAPACITY_FLOOR_MBPS=10,
MIN_CAPACITY_CEILING_MBPS=1000) and ADR 026.

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

@alpergundogdu alpergundogdu left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Review — ADR 016 CapacityBond genesis-credit alignment

Docs-only, and I independently verified every claim against the shipped contract (contracts/src/CapacityBond.sol) — they all check out:

  • accrueGenesisVest does not exist; curveVested(address) external view (line 786) and claimableCredit(address) public view (line 793) do. ✓
  • claimVestedCredit() external nonReentrant whenNotPaused — no operator arg, acts on msg.sender (line 837). ✓
  • struct PendingCredit { uint128 originalGrant; uint128 claimed; uint64 grantedAt; } (lines 333–337) — no stored vested. ✓
  • bondOf(address) exists (line 1473); bondedAmount does not (storage is activeBond). ✓
  • setK / setAlpha / setMinCapacityMbps / setMaxCapacityMbps all exist under GOVERNANCE_ROLE (lines 1330–1378), confirming the curve coefficients and capacity band are storage-with-defaults + post-deploy tunable, not constructor args. ✓
  • grantGenesisCredit(operator, amount) and the one-grant guard align with the corrected originalGrant == 0 text. ✓

The "source of truth = shipped contract" discipline is exactly right, and declining issue #771's items 6–7 (because the contract contradicts the "not tunable" premise — setK/setAlpha exist) rather than introducing new errors into the ADR is the correct call. Scoping out the items 6–7 tables to avoid colliding with #770 is also sensible.

No code/CI surface touched, claims accurate. LGTM.


Generated by Claude Code

@thiras
thiras merged commit c540ef7 into main Jun 3, 2026
19 checks passed
@thiras
thiras deleted the docs/771-adr016-capacitybond-align branch June 3, 2026 13:39
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: align CapacityBond genesis-credit surface + economics tables with shipped contract

3 participants