Repository navigation
feat(contracts)!: governance hardening — bound capture, remove structural recovery holes - #2038
Conversation
) 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]>
There was a problem hiding this comment.
🟡 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.feeRouterimmutable;CapacityBond.setSlashJudgeset-once;DecdnGovernor.voteCapBpsdecrease-only with 10% launch cap). - Make operator exits unpausable (
requestUnbond/unbond/deregisterNode) and add related safety tests. - Tighten
MAX_RATE_PER_MBto1000across wire + on-chain + docs, and constrainBuybackBurner.rescueUSDCto 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.
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]>
Contracts coverageLine coverage: 89.73% (2550/2842 lines) |
Gas snapshotNo gas changes vs base. |
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]>
Coverage reportTotal: 82.94% (was 82.79%, ▲ +0.15%) — 79550/95910 lines
History
|
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]>
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)
PaymentPool.feeRouterimmutable, dropsetFeeRouter. A re-pointable router could sever the immutableDecdnGovernorbytesPerEpochvote-weight feed and permanently brick governance. Top structural hole.requestUnbond/unbond,deregisterNode) un-pausable (live vuln: a malicious PAUSER could trap every bond). Slash safety is independent of pause (unbonding window + escrow), proven by new tests. Pause now halts intake/serving only.CapacityBond.setSlashJudgeset-once (circular deploy dep precludes constructor-immutable): the judge is wired once, then frozen — governance can't swap in a malicious judge.CapacityBond.minBondnon-retroactive: grandfather active operators at the floor they entered under; gate only new activations on the liveminBond. Governance can tighten entry for newcomers without purging the electorate; slash-eject uses the grandfathered floor.voteCapBpsone-way decrease-only, launch at 10%, bound 1–10%. Removes the entrenchment (raise-to-concentrate) vector; higher launch cap keeps bootstrap quorum reachable.BuybackBurner.rescueUSDCto an immutable treasury snapshot (drop the arbitrary destination). Rescue can recover stranded USDC but never redirect it.MAX_RATE_PER_MBto 1000 µUSDC/MB (~$1/GB). ThedeliveryFloorceiling was ~1e11× market, letting a high floor selectively suppress ADR-036 vote-weight credit. Also corrects the stale "reverts" doc (it clamps).Still open
DEFAULT_ADMIN_ROLE) — deferred: it carries a design fork (which roles stay rotatable) posted as a comment for team input. Not in this PR.setContentBlacklistset-once) was mooted by refactor(contracts,node)!: drop ContentBlacklist coupling from OriginAssignment (#2032) #2035 on main, which dropped the OriginAssignment↔ContentBlacklist coupling entirely.Testing
forge fmtclean ·FOUNDRY_PROFILE=ci forge build --sizes --deny-warningspass ·forge test847 passed, 0 failed ·cargo build --workspaceclean.🤖 Generated with Claude Code