Skip to content

feat(contracts)!: governance hardening — bound capture, remove structural recovery holes - #2038

Merged
alpergundogdu merged 11 commits into
mainfrom
claude/governance-hardening
Sep 15, 2026
Merged

alpergundogdu merged 11 commits into
mainfrom
claude/governance-hardening

Conversation

@alpergundogdu

Copy link
Copy Markdown
Contributor

Governance-hardening pass (milestone Governance hardening). Bounds every capture lever and removes the two structural holes that made governance capture unrecoverable — while keeping the contracts fully immutable (no proxies) and adding no trusted canceller/guardian. Each fix is one commit.

Fixes (Closes)

Still open

Testing

  • forge fmt clean · FOUNDRY_PROFILE=ci forge build --sizes --deny-warnings pass · forge test 847 passed, 0 failed · cargo build --workspace clean.
  • New tests cover each behavior change (immutable feed, un-pausable-exit + slash-safety, set-once judge, minBond grandfathering, decrease-only cap, treasury-only rescue).
  • ADRs updated to present-tense canon throughout (003, 005, 009, 014, 016, 026, 036).

🤖 Generated with Claude Code

alpergundogdu and others added 7 commits September 15, 2026 13:18
)

DecdnGovernor.feeRouter is immutable; a re-pointable PaymentPool.feeRouter
could sever the bytesPerEpoch vote-weight feed and permanently brick
governance. Wire it immutable at construction and remove the setter.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
)

The deliveryFloor ceiling doubled as the wire rate cap at ~1e11x market
price, letting a governance floor near the ceiling suppress ADR-036
vote-weight credit. Retune the shared cap to 1000 µUSDC/MB (~$1/GB), a
realistic ceiling that still catches below-market bytes but can never
zero out the electorate's weight.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
A re-settable SlashJudge let governance swap in a malicious judge to
fabricate slashes against honest operators. The judge must be wired
post-deploy (circular dependency with CapacityBond), so gate the setter
to a single address(0)->judge transition and freeze it thereafter.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
A malicious PAUSER could trap every operator's bond indefinitely because
requestUnbond/unbond were whenNotPaused. Un-gate the exit paths (client
reclaim is already un-pausable); the unbonding period and pending-slash
locks — not pause — protect slashing. Pause now halts intake/serving only.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Raising minBond de-activated existing operators below the new floor,
stripping vote weight (electorate purge). Grandfather active operators at
the floor they entered under; gate only new activations on the live
minBond. Governance can tighten the entry bar as the network matures
without purging the electorate. Slash ejection uses the grandfathered
floor, so a minBond raise alone never ejects.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
…und 1-10% (#2031)

A both-ways vote cap let a coalition raise it to concentrate weight and
entrench. Retune the ceiling to 10%, launch at the ceiling, and make the
setter decrease-only so governance can only ever decentralize. Keeps
bootstrap quorum reachable while the operator set is thin.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
… treasury (#2034)

rescueUSDC(to, amount) let governance drain the 30% buyback bucket to any
address. Snapshot the treasury as an immutable at construction and send
rescues only there, so the hatch can recover funds but never redirect
them. (A live FeeRouter.treasury() read is a circular deploy dependency;
the immutable snapshot is also non-redirectable by setTreasury.)

Co-Authored-By: Claude Opus 4.8 <[email protected]>

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.

🟡 Changes recommended

CapacityBond.bondFloorAtActivation is not captured on registerNode activation, so isActive can incorrectly treat newly-activated operators as having a zero floor under certain minBond decrease scenarios.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Governance-hardening pass across Solidity contracts, Rust protocol constants, tests, and ADRs to eliminate governance-capture “brick” vectors by freezing key pointers/knobs and tightening bounds (while keeping the system immutable and guardian-free).

Changes:

  • Freeze or constrain governance levers (e.g., PaymentPool.feeRouter immutable; CapacityBond.setSlashJudge set-once; DecdnGovernor.voteCapBps decrease-only with 10% launch cap).
  • Make operator exits unpausable (requestUnbond/unbond/deregisterNode) and add related safety tests.
  • Tighten MAX_RATE_PER_MB to 1000 across wire + on-chain + docs, and constrain BuybackBurner.rescueUSDC to an immutable treasury sink.
File summaries
File Description
crates/protocol/src/message.rs Lowers protocol MAX_RATE_PER_MB to 1000 and updates rationale/doc.
contracts/src/PaymentPool.sol Makes feeRouter immutable; removes setFeeRouter; tightens rate cap docs.
contracts/src/interfaces/IFeeRouterSettlement.sol Updates paused() probe doc to constructor-time.
contracts/src/DecdnGovernor.sol Sets vote-cap ceiling to 10%, launches at ceiling, and enforces decrease-only updates.
contracts/src/CapacityBond.sol Adds bondFloorAtActivation, makes exits unpausable, sets SlashJudge set-once, updates active/eject logic.
contracts/src/BuybackBurner.sol Adds immutable treasury; restricts rescueUSDC destination to it.
contracts/src/GuardedBuybackBurner.sol Threads new treasury constructor arg through guarded burner base.
contracts/src/BuybackBurnerUniswapV3.sol Threads new treasury constructor arg for Uniswap V3 burner.
contracts/src/BuybackBurnerBalancerV3.sol Threads new treasury constructor arg for Balancer V3 burner.
contracts/script/lib/BuybackVenueLib.sol Adds treasury parameter to burner deploy helpers.
contracts/script/BaseProtocolDeploy.s.sol Wires burner treasury as the timelock in deployment flow.
contracts/script/ActivateBuyback.s.sol Passes treasury argument during activation scripting.
contracts/test/PaymentPool.t.sol Updates tests for immutable feeRouter + new max-rate cap; removes router-setter tests/events.
contracts/test/InterfaceFreeze.t.sol Removes setFeeRouter selector assertion from interface freeze test.
contracts/test/GovernanceLifecycle.t.sol Updates lifecycle tests for vote-cap launch-at-ceiling + decrease-only behavior.
contracts/test/DeployProtocol.t.sol Updates peer-role wiring test to reflect set-once SlashJudge wiring.
contracts/test/DecdnGovernorDelegation.t.sol Updates delegation test docs for 10% launch vote cap.
contracts/test/DecdnGovernor.t.sol Updates expected vote weights under 10% cap; adds “launches at ceiling” assertion.
contracts/test/CapacityBond.t.sol Adds tests for unpausable exits + minBond grandfathering + set-once judge wiring.
contracts/test/BuybackBurnerUniswapV3.t.sol Updates burner construction with treasury argument.
contracts/test/BuybackBurnerBalancerV3.t.sol Updates burner construction with treasury argument across many test cases.
contracts/test/BuybackBurnerBalancerV3.swapburn.fork.t.sol Updates fork test deployment with treasury argument.
contracts/test/BuybackBurnerBalancerV3.fork.t.sol Updates fork test deployment with treasury argument.
contracts/test/BuybackBurner.t.sol Updates base burner tests for treasury-only rescue + new event signature.
contracts/.gas-snapshot Refreshes gas snapshot for updated bytecode / tests.
adr/036-served-bytes-voting-weight.md Updates cap defaults/range and economics to 10% launch, decrease-only.
adr/026-tokenomics.md Documents non-retroactive minBond via bondFloorAtActivation and treasury-only rescue hatch.
adr/016-contract-interactions.md Updates contract inventory + removes PaymentPool router repoint knob; documents immutable router binding.
adr/014-on-chain-verification.md Documents set-once SlashJudge wiring constraint.
adr/009-governance.md Updates governance parameters/constraints for vote cap + exit-not-pausable semantics.
adr/005-protocol.md Updates wire-cap explanation and ties it to on-chain deliveryFloor ceiling.
adr/003-payments.md Updates PaymentPool interface/docs for immutable router and new MAX_RATE_PER_MB value.
Review details
  • Files reviewed: 32/32 changed files
  • Comments generated: 2
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread contracts/src/CapacityBond.sol Resolved
Comment thread contracts/test/CapacityBond.t.sol Resolved
Resolve ADR 003/005 rate-floor conflicts: keep #2037's no-seller-clamp
behavior (floor is redemption-time only, node reads it for no wire
decision) and fold in #2036's MAX_RATE_PER_MB=1000 value + the
vote-weight-suppression rationale.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@github-actions

github-actions Bot commented Sep 15, 2026 •

Copy link
Copy Markdown

Contracts coverage

Line coverage: 89.73% (2550/2842 lines)
▼ -0.03pp vs base (89.75% → 89.73%)
Run: 34987434292

@github-actions

Copy link
Copy Markdown

Gas snapshot

No gas changes vs base.

alpergundogdu and others added 2 commits September 15, 2026 15:23
registerNode is an activation path distinct from bond(): an operator can
satisfy activeBond >= minBond without a bond() up-crossing when governance
lowered minBond after they bonded, leaving bondFloorAtActivation at 0 and
letting isActive treat them as always above the floor. Capture the live
minBond as the entry floor in registerNode when still zero. Adds a
regression test for the register-after-minBond-decrease path.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
…000 (#2036)

Lowering the wire cap to 1000 µUSDC/MB broke tests that hardcoded rates
above it. Rescale node_origin_pull attack-A (SELL 1000->25, QUOTE_A 960)
and the cli_fetch_topup deposit-exhaustion journeys (rate + refundable
floor M + working_deposit scaled together, blob size unchanged) so the
same economic scenarios hold under the new cap.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@github-actions

github-actions Bot commented Sep 15, 2026 •

Copy link
Copy Markdown

Coverage report

Total: 82.94% (was 82.79%, ▲ +0.15%) — 79550/95910 lines

File Coverage Lines Δ
crates/e2e/src/node.rs 30.62% 192/627 ▲ +2.29%
crates/protocol/src/message.rs 99.67% 301/302 ● 0.00%
History
Commit Total Δ vs base
7bf170b 82.95% ▲ +0.16%
4cc8c71 (HEAD) 82.94% ▲ +0.15%

Node-to-node top-up journey hardcoded 0.5 USDC/MB, above the new wire cap.
Rescale rate + refundable floor M + working deposit by the same factor
(blob size unchanged) so the deposit still exhausts mid-pull and reactive
top-up fires. Verified against the full anvil-e2e journeys suite.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@alpergundogdu
alpergundogdu merged commit 2ea70da into main Sep 15, 2026
25 checks passed
@alpergundogdu
alpergundogdu deleted the claude/governance-hardening branch September 15, 2026 18:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind:security Security impact; report a vulnerability to [email protected], not here

Projects

None yet

2 participants