Repository navigation
refactor(contracts): rename stake→bond on CapacityBond surface - #768
Conversation
Unify the operator-collateral concept on "bond" across the contract ABI, the incentive crate's sol! mirror, and residual ADR wording. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…Math→BondMath Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…env) Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…ings Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…face - anvil-e2e test: CapacityBondWrite.stake() -> bond() binding + call site - chain_staker_set doc: predicate now bond >= minBond (matches contract) - ADR 003: getStakeMultiple -> getBondMultiple, stake-multiple -> bond-multiple - CLAUDE.md inventory: StakeMath -> BondMath helper The node-side StakerSet DHT abstraction and conceptual 'staking' prose in other ADRs/README are deliberately left (separate node-membership vocabulary, not the contract surface). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Contracts coverageLine coverage: 87.49% (1693/1935 lines) |
Gas snapshotGas changes vs baseRun: 26775819393 |
There was a problem hiding this comment.
Code Review
This pull request performs a comprehensive rename of the operator-collateral vocabulary from 'stake' to 'bond' across the entire codebase, including Solidity contracts, Rust crates, deploy scripts, tests, and ADR documentation. This includes renaming StakeMath.sol to BondMath.sol and updating all associated functions, variables, events, and errors (e.g., activeStake to activeBond, setMinStake to setMinBond, and requestUnstake to requestUnbond) to unify the terminology under 'bond' with zero functional changes. There are no review comments, so I have no feedback to provide.
There was a problem hiding this comment.
Pull request overview
This PR completes the behavior-neutral vocabulary refactor that renames the operator-collateral “stake” surface to “bond” across the Solidity CapacityBond ABI and its dependent Rust bindings, tests, deploy scripts, and supporting documentation/ADRs.
Changes:
- Renamed
CapacityBondpublic ABI/state/events/errors fromstake*tobond*(andStakeMath→BondMath) with corresponding updates in Foundry tests and deploy scripts. - Updated Rust-side contract bindings (
alloy::sol!) and the feature-gated anvil e2e binding to match the new ABI. - Aligned ADR and repo documentation wording to the new “bond” vocabulary where it references the operator-collateral pool.
Reviewed changes
Copilot reviewed 26 out of 26 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| docs/superpowers/specs/2026-06-01-bond-vocabulary-rename-design.md | Design spec documenting the rename map and scope/risks. |
| docs/superpowers/plans/2026-06-01-bond-vocabulary-rename.md | Step-by-step implementation plan for the rename work. |
| crates/node/tests/anvil_settlement_e2e.rs | Updates local CapacityBondWrite binding and e2e flow to call bond(). |
| crates/node/src/dht/chain_staker_set.rs | Doc-comment updated to reflect bond ≥ minBond predicate wording. |
| crates/incentive/src/lib.rs | Crate docs updated from staking → bonding wording. |
| crates/incentive/src/capacity_bond.rs | Updates the alloy::sol! ABI mirror docs/events to “bond” vocabulary. |
| crates/incentive/Cargo.toml | Crate description updated to bonding terminology. |
| contracts/test/SlashAppeal.t.sol | Test helpers/constants updated to bond()/minBond_ naming. |
| contracts/test/GovernanceLifecycle.t.sol | Lifecycle tests updated for minBond / setMinBond and bond() usage. |
| contracts/test/E2EProtocol.t.sol | E2E test updated to bond() and related terminology. |
| contracts/test/DeployProtocolScript.t.sol | Script test updated to assert minBond/DEFAULT_MIN_BOND serialization. |
| contracts/test/DeployProtocol.t.sol | Deploy test config updated from minStake → minBond. |
| contracts/test/CapacityBond.t.sol | Core CapacityBond tests updated to new ABI + BondMath library naming. |
| contracts/src/Token.sol | Token docs updated to reference bonding and CapacityBond.bond. |
| contracts/src/interfaces/ISlashJudge.sol | Doc wording updated from stake → bond. |
| contracts/src/interfaces/ICapacityBond.sol | Interface docs updated to activeBond / bond() terminology. |
| contracts/src/CapacityBond.sol | Main ABI rename (stake* → bond*), internal renames, and BondMath import. |
| contracts/src/BondMath.sol | Renamed helper library from StakeMath → BondMath and updated docs. |
| contracts/script/DeployProtocol.s.sol | Env/config rename MIN_STAKE/DEFAULT_MIN_STAKE → MIN_BOND/DEFAULT_MIN_BOND, manifest key update. |
| contracts/script/BaseProtocolDeploy.s.sol | Deploy config struct/constructor arg renamed to minBond. |
| contracts/.gas-snapshot | Gas snapshot updated for renamed test names and small gas deltas. |
| CLAUDE.md | Repo layout docs updated to mention BondMath instead of StakeMath. |
| adr/036-served-bytes-voting-weight.md | ADR wording updated for minBond/2 auto-ejection reference. |
| adr/028-slashing-appeals.md | ADR wording updated from stake-reduction → bond-reduction terminology. |
| adr/026-tokenomics.md | ADR wording updated to align operator-collateral references on bond vocabulary. |
| adr/003-payments.md | Updates the fee-discount paragraph to refer to getBondMultiple (but leaves adjacent staking prose). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Coverage reportTotal: 86.95% (was 86.95%, ● 0.00%) — 25203/28985 lines
History
|
Addresses PR #768 review: ADR 003 mixed 'stake'/'bond' prose and carried a stale 'remainingStake' event signature in a Solidity snippet. Sweep all operator-collateral references to bond vocabulary (the payments ADR documents CapacityBond directly) and fix the event signature to match the deployed contract (remainingBond). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Addresses PR #768 review: replace hard-coded /home/thiras/dev/decdn/decdn with $(git rev-parse --show-toplevel) so the plan's shell snippets are portable. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…on control (#446) Reframe ADR 003 §Admission and Priority to match the protocol's actual congestion semantics: - Congestion control happens at probe time — declining to sign has_blob:true, gated by the max_probe_holds hold budget. A signed StreamResponse{ok:false} after a positive probe is slash evidence regardless of its unsigned error code, so it is never a congestion lever. - Committed voucher rate is a mid-stream signal for ordering admitted streams (the first Voucher arrives only after StreamResponse{ok:true}), not an admission key. - Registered node-bond (CapacityBond.bondOf) is usable only for requesters that are themselves registered operators — node-to-node cache-miss probes; it prioritizes probe-acceptance, not a stream-time admission lane. End-client probe eligibility comes from reputation/region/allow-list. Align the ADR 016 bondOf consumer row to the probe-acceptance framing. The worked reference design stays in issue #446. Rebuilt on top of #768 (stake→bond rename); keeps the canonical bondOf name. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…on control (#446) Reframe ADR 003 §Admission and Priority to match the protocol's actual congestion semantics: congestion control at probe time (declining to sign has_blob:true, gated by max_probe_holds), committed voucher rate as a mid-stream ordering signal (not an admission key), and registered node-bond (CapacityBond.bondOf) as probe-acceptance prioritization usable only for registered-operator node-to-node requesters. Align the ADR 016 bondOf consumer row to the probe-acceptance framing. The worked reference design stays in issue #446. Rebuilt on current main (post #768 stake→bond rename and #769 accessor-name alignment); keeps the canonical bondOf name. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…on control (#446) (#756) Reframe ADR 003 §Admission and Priority to match the protocol's actual congestion semantics: congestion control at probe time (declining to sign has_blob:true, gated by max_probe_holds), committed voucher rate as a mid-stream ordering signal (not an admission key), and registered node-bond (CapacityBond.bondOf) as probe-acceptance prioritization usable only for registered-operator node-to-node requesters. Align the ADR 016 bondOf consumer row to the probe-acceptance framing. The worked reference design stays in issue #446. Rebuilt on current main (post #768 stake→bond rename and #769 accessor-name alignment); keeps the canonical bondOf name. Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
Summary
Behavior-neutral rename of the operator-collateral surface from stake to bond, finishing the migration begun when
StakingRegistrywas renamed toCapacityBond(ADR 026 v2.2). Previously an operator staked but unbonded the same single pool — this unifies the verb pair.CapacityBond.sol):stake/requestUnstake/unstake→bond/requestUnbond/unbond;stakeOf/getStakeMultiple→bondOf/getBondMultiple;setMinStake→setMinBond; stateactiveStake/minStake→activeBond/minBond; eventsStaked/Unstaked/MinStakeUpdated→Bonded/Unbonded/MinBondUpdated; errorsInsufficientStake/StakeBelowMinimum→InsufficientBond/BondBelowMinimum; constantsMIN_STAKE_FLOOR/CEILING→MIN_BOND_FLOOR/CEILING.StakeMath.sol→BondMath.sol(library + file);_reduceStakeAtTier→_reduceBondAtTier.MIN_STAKEenv →MIN_BOND,cfg.minStake→cfg.minBond, serialized key updated.incentivecratealloy::sol!mirror + the feature-gated nodeanvil-e2etest's localCapacityBondWritebinding.getStakeMultipleidentifier).CapacityBondbytecode size unchanged at 24,466 B.Preserved as already-correct bond vocabulary:
unbondingOf,unbondingPeriod,UnbondingRequested,firstBondedAt. Left untouched (distinct concepts):SlashAppeal/SlashJudge/ContentBlacklistappeal & challenge bonds.Deliberately out of scope (separate node-membership vocabulary, not the contract surface): the node-side
StakerSetDHT abstraction (~200 occurrences) and narrative "staking"/"staked node" prose in other ADRs/README/glossary. One small seam to note:chain_staker_set.rs:5's doc-comment now quotes the contract predicate asbond ≥ minBondwhile the surroundingStakerSetabstraction keeps its "staker" naming — intentional.Design spec + implementation plan included under
docs/superpowers/.Test Plan
FOUNDRY_PROFILE=ci forge build --sizes --deny warnings— clean,CapacityBondsize unchanged (24,466 B)forge test— 440/440 passcargo build && cargo clippy --all-targets --all-features— cleancargo nextest run— 1314/1314 passcargo test -p decdn-node --features anvil-e2e --no-run— gated e2e binding compilesstake-identifier grep clean (only the historicalStakingRegistrycomment + English "stakeholder"/"mistakenly" survive)🤖 Generated with Claude Code