Repository navigation
fix(contracts): separate governance blacklist ejection from slash auto-ejection (#850) - #877
Conversation
…o-ejection (#850) `CapacityBond.ejected` was a single flag set by two mechanisms with different intended permanence: recoverable slash auto-ejection (bond < minBond/2, ADR 026) and permanent governance blacklisting via `ContentBlacklist.addOperator()` -> `CapacityBond.ejectNode()` (ADR 011). Because `bond()` cleared `ejected` once balance >= minBond, a blacklisted operator could self-reinstate within one block by re-bonding, defeating the protocol's primary response to repeat illegal-content sourcing. Add a separate `blacklistEjected` latch: - `bond()` reinstatement now requires `!blacklistEjected`. - `ejectNode()` sets the latch UNCONDITIONALLY (outside the one-time `if (!ejected)` effects guard) so an already-slash-ejected operator is still latched. - New `unEjectNode(address)` (BLACKLIST_ROLE, idempotent) clears only the latch; re-entry then flows through the normal re-bond path. - `ContentBlacklist.removeOperator()` calls `unEjectNode` unconditionally (idempotent re-sync, repairs any latch/local-flag drift) + zero-address guard, and gains `nonReentrant`. - `ICapacityBondEjector` extended with `unEjectNode`. Tests lock in the core invariant via the real `registerNode`/`isActive` gates (not just the booleans), the slash-recoverability regression, role gating, idempotency, zero-address reverts, and event emission/absence. Docs: ADR 011/016/026 document the two-flag distinction and reconcile the stale `addOrigin`/`removeOrigin` naming with `addOperator`/`removeOperator`. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Contracts coverageLine coverage: 89.57% (1829/2042 lines) |
Gas snapshotGas changes vs baseRun: 27304098100 |
There was a problem hiding this comment.
Code Review
This pull request introduces a governance-blacklist ejection latch (blacklistEjected) in the CapacityBond contract to prevent blacklisted operators from self-reinstating by simply re-bonding above the minimum threshold. It adds the unEjectNode function to safely clear this latch when governance lifts a blacklist, and updates ContentBlacklist to invoke this function upon operator removal. Extensive unit and integration tests have been added to verify these behaviors. There are no review comments to address.
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.
There was a problem hiding this comment.
Pull request overview
This PR addresses a high-severity contracts security issue where CapacityBond.ejected conflated two different ejection mechanisms (slash auto-ejection vs governance blacklisting), allowing governance-blacklisted operators to self-reinstate by re-bonding. The fix introduces a separate governance latch (blacklistEjected) and a symmetric unEjectNode governance path to ensure blacklist ejection cannot be cleared by bond().
Changes:
- Add
blacklistEjectedlatch toCapacityBond, preventingbond()from clearingejectedwhen governance-blacklisted. - Extend the
ContentBlacklist↔CapacityBondintegration with a newunEjectNodecall onremoveOperator, plus zero-address guard andnonReentrant. - Add comprehensive tests and update ADR documentation to reflect the two-ejection-cause model and the new un-ejection flow.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| contracts/src/CapacityBond.sol | Adds blacklistEjected, gates bond() reinstatement, latches in ejectNode, and introduces unEjectNode + event. |
| contracts/src/ContentBlacklist.sol | Makes removeOperator nonReentrant, adds zero-address guard, and unconditionally calls capacityBond.unEjectNode for latch resync. |
| contracts/src/interfaces/ICapacityBondEjector.sol | Extends interface with unEjectNode to support symmetric ejection control. |
| contracts/test/CapacityBond.t.sol | Adds end-to-end and regression tests covering blacklist latch behavior, idempotency, role gating, and event assertions. |
| contracts/test/ContentBlacklist.t.sol | Updates mock ejector and adds tests ensuring removeOperator triggers unEjectNode and rejects zero address. |
| adr/011-content-takedown.md | Documents the two-cause ejection model and the latch + re-bond re-entry flow; updates API naming. |
| adr/016-contract-interactions.md | Updates cross-contract call graph/role tables to include unEjectNode and updated naming. |
| adr/026-tokenomics.md | Clarifies slash auto-ejection recoverability and its non-override of governance blacklist latch. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
Closes #850 (HIGH severity, security, poc-blocking).
CapacityBond.ejectedwas a single flag set by two mechanisms with different intended permanence:minBond/2, ADR 026) — meant to be recoverable by re-bonding.ContentBlacklist.addOperator()→CapacityBond.ejectNode()(BLACKLIST_ROLE, ADR 011) — meant to be permanent until governance lifts it.Because
bond()clearedejectedfor any cause oncenewBalance >= minBond, a governance-blacklisted operator could self-reinstate within one block by re-bonding +registerNode— defeating the protocol's primary response to repeat illegal-content sourcing. A corollary asymmetry:removeOperator()never un-ejected onCapacityBond.Fix — a separate
blacklistEjectedlatchmapping(address => bool) public blacklistEjected.bond()reinstatement now requires!blacklistEjected[msg.sender].ejectNode()sets the latch unconditionally (outside theif (!ejected)one-time-effects guard) so an already-slash-ejected operator is still latched.unEjectNode(address) onlyRole(BLACKLIST_ROLE)(idempotent) clears only the latch; re-entry then flows through the normal re-bond path (per ADR 011).ContentBlacklist.removeOperator()callsunEjectNodeunconditionally (idempotent re-sync that repairs any latch/local-flag drift) + a zero-address guard, and gainsnonReentrant.ICapacityBondEjectorextended withunEjectNode.ejectedremains the master active-gate;registerNode/isActiveare unchanged.blacklistEjectedonly prevents premature clearing ofejected.Tests
Lock in the security property via the real
registerNode→OperatorEjected/isActivegates (not just the booleans), plus: slash-recoverability regression, the already-slash-ejected-then-blacklisted ordering, role gating, idempotency, zero-address reverts, andReinstated/BlacklistEjectionCleared/EjectedByBlacklistevent emission-and-absence assertions.Docs
ADR 011/016/026 now document the two-flag distinction, and the stale
addOrigin/removeOriginnaming is reconciled with the actualaddOperator/removeOperatorsurface.Design notes
CapacityBondruntime 22,509 B / 24,576 B).unEjectNodere-sync closes a latch/local-flag desync class, and the registration-path test makes theisActiveassertions load-bearing rather than tautological.Verification
forge fmt --check: cleanFOUNDRY_PROFILE=ci forge build --sizes --deny warnings: pass (CapacityBond 22,509 B)forge test: 524 passed, 0 failedaderyn: 0 high ·slither: exit 0 (only pre-existing informational notes)🤖 Generated with Claude Code