Repository navigation
feat(contracts): emergency multisig, compliance window, regional-body lifecycle (#1167, #1169, #1178) - #1364
Conversation
…ompliance window, regional-body lifecycle Batches three ADR 011 gaps that all rewrite the same `HashEntry` state and the `IContentBlacklistHashView` tuple `SlashJudge` decodes, so splitting them would pay that ABI migration three times. **#1169 — compliance window.** `SlashJudge` anchored slash eligibility to `addedAt`, so a node polling on the 10-minute default could be slashed for a delivery served before it could know the entry existed. Entries now carry `effectiveAt = addedAt + window`, and the slash check compares against that. `complianceWindow` (24h) and `emergencyComplianceWindow` (2h) are governable within `[1h, 7d]`. The value is stamped at add time, never derived: a governance change must not move the boundary under deliveries already served, and the original must survive an appeal suspension. **#1167 — emergency multisig surface.** Adds `emergencyAdd` / `emergencyAddOrigin` behind `EMERGENCY_MULTISIG_ROLE` with category-based auto-expiry (GENERAL 14d, CSAM/TERRORIST 90d), ratified by re-adding under governance. `_isLive` honours the deadline directly, and permissionless `expireEmergencyEntry` / `expireEmergencyOrigin` materialize it — required, not cosmetic: expiry otherwise shrinks the enforced set with `getBlacklistVersion()` frozen, and ADR 011 § Polling has nodes fetch deltas only when it advances. **#1178 — regional-body lifecycle.** `registerRegionalBody(address)` was a bare role grant, so any registered body could write entries for any region. Bodies are now bound one-to-one to a region and checked on every write, with suspend / ratify / unsuspend / deregister and an on-chain signer-disjointness probe against the emergency multisig (falling back to the ADR's off-chain regime, recorded in the event, when either side is not enumerable). An unratified suspension lapses after 14 days — governance silence is not ratification. ADR 011 carried two internal contradictions this had to settle: the compliance table said emergency entries were effective at `addedAt` while the struct comment said `addedAt + window`, and § Blacklist version claimed the counter never moves without a log while auto-expiry moved the set without one. Both are now one rule, in place. Also refreshes the stale runbook § takedown guidance, which still told operators no grace window existed and that regional entries were not slashable. Closes #1167 Closes #1169 Closes #1178 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
|
Warning Review limit reached
Next review available in: 18 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Free Run ID: 📒 Files selected for processing (7)
WalkthroughChangesContent blacklist compliance
Note 🎁 Summarized by CodeRabbit FreeYour organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login. Comment |
Contracts coverageLine coverage: 89.58% (2657/2966 lines) |
Gas snapshotNo gas changes vs base. |
There was a problem hiding this comment.
Pull request overview
Implements the remaining ADR 011 “takedown enforcement” gaps in the Solidity system by introducing a compliance-window grace period for slashing, adding an emergency-multisig takedown path with auto-expiry + permissionless expiry materialization, and completing the regional governance body lifecycle/scoping and signer-disjointness enforcement. This primarily affects ContentBlacklist (data model + authority) and SlashJudge (eligibility checks), with ADR + runbook updates and expanded Foundry test coverage to match the revised on-chain behavior.
Changes:
- Add
effectiveAt(stamped at add time) and compliance-window governance; updateSlashJudgeto anchor blacklist slashing toeffectiveAt(notaddedAt). - Add emergency multisig hash/origin takedown surface with category-based auto-expiry plus permissionless expiry materialization.
- Bind regional bodies 1:1 to regions (and add suspend/ratify/unsuspend/deregister lifecycle) + implement best-effort on-chain signer disjointness probing.
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| docs/runbook.md | Updates operator runbook takedown guidance to reflect grace windows, regional slashing, and emergency expiry semantics. |
| contracts/src/ContentBlacklist.sol | Adds compliance-window stamping, emergency takedown paths + expiry materialization, regional body scoping/lifecycle, and signer disjointness probing. |
| contracts/src/SlashJudge.sol | Updates blacklist eligibility checks to use effectiveAt and ignore expired emergency entries. |
| contracts/src/interfaces/IEnumerableSigners.sol | Introduces minimal Safe-shaped getOwners() interface for signer enumeration probing. |
| contracts/src/interfaces/IContentBlacklistHashView.sol | Expands the consumer tuple to mirror the new HashEntry layout required by SlashJudge. |
| contracts/test/SlashJudge.t.sol | Adds regression and new-path tests for compliance window and emergency expiry behavior. |
| contracts/test/GovernanceLifecycle.t.sol | Updates governance lifecycle tests for the new registerRegionalBody signature and adds a revert-path case. |
| contracts/test/ContentBlacklist.t.sol | Adds broad test coverage for compliance-window stamping, emergency expiry/materialization, and regional body lifecycle + disjointness. |
| contracts/test/CapacityBondRegionE2E.t.sol | Updates E2E slashing tests to warp past the compliance window and uses the new regional body registration flow. |
| contracts/.gas-snapshot | Updates contract gas snapshot results after the added logic/tests. |
| .gas-snapshot | Adds/updates repo-root gas snapshot output. |
| adr/016-contract-interactions.md | Updates post-deploy procedure for the new registerRegionalBody(..., emergencyMultisig) surface. |
| adr/014-on-chain-verification.md | Updates the on-chain verification step description for blacklist enforcement (effectiveAt + expiry + suspension). |
| adr/011-content-takedown.md | Reconciles ADR contradictions and documents expiry materialization, window stamping, and regional body lifecycle/scoping rules. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…ss-layer harness
The `anvil e2e` job caught two real cross-layer breaks the Rust-only suites
cannot see.
**`HashEntry` ABI drift.** `decdn-incentive`'s `sol!` binding still declared the
old `{uint64 addedAt; bool suspended}`. A static struct return is ABI-identical
to the flattened tuple, so a stale declaration mis-decodes silently rather than
failing loudly — exactly the failure mode the binding's own doc warns about for
the event declarations. Now mirrors all five fields, with `effectiveAt` marked
as the slashability boundary so a reader does not reach for `addedAt`.
**Regional-body authority.** `ChainFixture::add_hash_regional` granted the
Timelock a bare `REGIONAL_BODY_ROLE` and wrote from it. That is no longer
sufficient authority — a body is scoped to one region — so `addHashRegional`
reverted `NotRegionalBodyFor`. The fixture now registers a distinct
region-derived body per jurisdiction (idempotently; the contract enforces
one-region-per-body in both directions, so a shared address would revert on the
second region) and sends from it.
Also adds `ChainFixture::advance_time` / `compliance_window`, and steps
`drive_blacklist_slash` past the window before stamping evidence. That is the
point of #1169, not an obstacle to it: without the warp the challenge reverts
`BlacklistAfterResponse`, which is the correct new behaviour. The window is read
from the contract rather than hardcoded so a governance change to the default
cannot quietly turn the assertion into a no-op. The journey's module doc claimed
"no on-chain compliance-window grace" — true when written, now not.
Verified locally with anvil + forge: `decdn-e2e --features anvil-e2e` 19/19
passing, including the `regional_blacklist_scope` case CI failed on.
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Coverage reportTotal: 81.55% (was 81.61%, ▼ 0.06%) — 53777/65943 lines
History
|
…rnance Review catch: `emergencyAdd` / `emergencyAddOrigin` could be aimed at a target governance had already blacklisted permanently. `_addHash` sets `e.emergency` unconditionally and `emergencyAddOrigin` re-stamped `_emergencyOrigins` unconditionally, so either call flipped a standing governance entry into an auto-expiring one. That is a privilege escalation, not a cosmetic overwrite. `removeHashGlobal` is `GOVERNANCE_ROLE` only and no other multisig route reaches a permanent, silent removal — `fastTrackBlacklistAppeal` merely suspends, needs a bonded appeal, and governance can reverse it. Downgrading a governance entry gave the multisig the same outcome on a 14-day delay, after which anyone could permissionlessly delete it, with no vote ever taken. Both paths now revert on a governance-held target. Re-adding over the multisig's OWN emergency entry stays allowed — escalating a category or re-arming a lapsed entry sustains a takedown rather than undoing one — and governance ratification (`addHashGlobal` over an emergency entry) is untouched, since the guard constrains only the emergency entry points. Regression tests assert the revert AND that the governance entry survives 365 days afterwards; both fail without the guards. The permitted directions are pinned alongside so a future "simplification" cannot quietly re-open the hole. ADR 011 records the one-way property in § Contract and § Compliance Window. Verified: forge test 813/813, aderyn High 0, slither exit 0, anvil e2e 19/19.
Batch of three ADR 011 gaps from the ADR→implementation gap analysis. They share
HashEntry,_addHash, and theIContentBlacklistHashViewtupleSlashJudgedecodes — splitting them would pay that ABI + storage migration three times.#1169 — compliance window before slashing
SlashJudgeanchored slash eligibility toaddedAt. With a 10-minute default poll interval (ADR 011 § Polling), a node could be slashed for a delivery served before it could possibly know the entry existed.Entries now carry
effectiveAt = addedAt + window, and_checkBlacklistedBefore/_liveBeforecompare against that.complianceWindow(24h) andemergencyComplianceWindow(2h) are governable within[1h, 7d].effectiveAtis stamped at add time, never derived — a live computation would let a governance window change retroactively move the slash boundary under deliveries already served, and ADR 011 requires the original to survive an appeal suspension/reversal.#1167 — emergency multisig takedown surface
emergencyAdd/emergencyAddOriginbehind the existingEMERGENCY_MULTISIG_ROLE, with category-based auto-expiry (GENERAL14d,CSAM/TERRORIST90d). Ratification is re-adding underaddHashGlobal, which clears theemergencyflag.emergencyAddOrigindeliberately does not eject fromCapacityBond— ejection is permanent and forces the bond into unbonding, which would be incoherent paired with a self-expiring entry. Permanent removal staysaddOperator.Expiry is enforced in two places on purpose:
_isLivehonours the deadline directly, so an uncleaned entry stops being enforceable the instant it lapses.expireEmergencyEntry/expireEmergencyOriginmaterialize it. This is required, not cosmetic: expiry otherwise shrinks the enforced set withgetBlacklistVersion()frozen, and ADR 011 § Polling has nodes fetch deltas only when that counter advances — a delta-polling node would keep enforcing an expired entry forever. On the origin side, where there is no version at all, the emittedOriginBlacklistUpdated(origin, false)is the only signal that exists.#1178 — regional-body lifecycle + signer disjointness
registerRegionalBody(address)was a bare_grantRole, so any registered body could write entries for any region — the regional/global split was decorative. Bodies are now bound one-to-one to a region, checked on everyaddHashRegional/removeHashRegional.Adds
suspendRegionalBody(multisig),ratifyRegionalBodySuspension/unsuspendRegionalBody/deregisterRegionalBody(governance). An unratified suspension lapses after 14 days: ADR 011 ties it to the emergency-entry ratification window, and emergency entries expire on silence. Sustaining one indefinitely would let the multisig disable a jurisdiction permanently with no vote ever taken; the durable instrument isderegisterRegionalBody.Signer disjointness is verified on-chain where both sides expose a Safe-shaped
getOwners(). The comparison address is checked to actually holdEMERGENCY_MULTISIG_ROLE, so the probe can't be aimed at a decoy. Where either side isn't enumerable, registration succeeds withsignersVerified = falseand the ADR's off-chain obligation applies — the event records which regime was used.ADR reconciliation
ADR 011 carried two internal contradictions this had to settle, fixed in place:
addedAt, while theBlacklistEntrycomment saidaddedAt + window. Now one rule.expireEmergencyEntryas the materializing path.docs/runbook.md§ takedown was also stale in the operator-facing direction: it told operators there was no grace window and that regional entries weren't slashable. Both untrue as of this PR (and the regional half was already untrue).Verification
New coverage: 33 tests across
ContentBlacklist.t.sol(121 total) andSlashJudge.t.sol(54 total) — window stamping and non-restamping, both bound violations, category expiry at both terms, ratification surviving expiry, permissionless expiry emittingHashRemoved+ version bump, cross-region write refusal, the full suspension lifecycle incl. the 14-day lapse, and signer overlap / disjoint / non-enumerable registration.ContentBlacklistgrows 14,348 → 19,640 B, leaving 4,936 B of EIP-170 margin.CapacityBondRegionE2Eslash tests now warp past the compliance window before slashing — that behaviour change is the point of #1169.Closes #1167
Closes #1169
Closes #1178
🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Bug Fixes
Documentation