Skip to content

feat(contracts): emergency multisig, compliance window, regional-body lifecycle (#1167, #1169, #1178) - #1364

Merged
thiras merged 3 commits into
mainfrom
feat/adr011-takedown-contracts
Jul 22, 2026
Merged

thiras merged 3 commits into
mainfrom
feat/adr011-takedown-contracts

Conversation

@thiras

@thiras thiras commented Jul 22, 2026 •

Copy link
Copy Markdown
Contributor

Batch of three ADR 011 gaps from the ADR→implementation gap analysis. They share HashEntry, _addHash, and the IContentBlacklistHashView tuple SlashJudge decodes — splitting them would pay that ABI + storage migration three times.

#1169 — compliance window before slashing

SlashJudge anchored slash eligibility to addedAt. 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 / _liveBefore compare against that. complianceWindow (24h) and emergencyComplianceWindow (2h) are governable within [1h, 7d].

effectiveAt is 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 / emergencyAddOrigin behind the existing EMERGENCY_MULTISIG_ROLE, with category-based auto-expiry (GENERAL 14d, CSAM/TERRORIST 90d). Ratification is re-adding under addHashGlobal, which clears the emergency flag.

emergencyAddOrigin deliberately does not eject from CapacityBond — ejection is permanent and forces the bond into unbonding, which would be incoherent paired with a self-expiring entry. Permanent removal stays addOperator.

Expiry is enforced in two places on purpose:

  • _isLive honours the deadline directly, so an uncleaned entry stops being enforceable the instant it lapses.
  • Permissionless expireEmergencyEntry / expireEmergencyOrigin materialize it. This is required, not cosmetic: expiry otherwise shrinks the enforced set with getBlacklistVersion() 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 emitted OriginBlacklistUpdated(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 every addHashRegional / 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 is deregisterRegionalBody.

Signer disjointness is verified on-chain where both sides expose a Safe-shaped getOwners(). The comparison address is checked to actually hold EMERGENCY_MULTISIG_ROLE, so the probe can't be aimed at a decoy. Where either side isn't enumerable, registration succeeds with signersVerified = false and 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:

  1. § Compliance Window's table said emergency entries were effective at addedAt, while the BlacklistEntry comment said addedAt + window. Now one rule.
  2. § Blacklist version claimed the counter never advances without a matching log — but auto-expiry changed the enforced set with the counter frozen, which is worse. Now documents expireEmergencyEntry as 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

forge fmt --check                                          ✓
FOUNDRY_PROFILE=ci forge build --sizes --deny warnings     ✓
forge test                                                 ✓ 808 passed, 0 failed
forge snapshot                                             ✓ regenerated
aderyn --no-snippets                                       ✓ High: 0
slither . --config-file slither.config.json                ✓ exit 0
pre-commit run --all-files                                 ✓

New coverage: 33 tests across ContentBlacklist.t.sol (121 total) and SlashJudge.t.sol (54 total) — window stamping and non-restamping, both bound violations, category expiry at both terms, ratification surviving expiry, permissionless expiry emitting HashRemoved + version bump, cross-region write refusal, the full suspension lifecycle incl. the 14-day lapse, and signer overlap / disjoint / non-enumerable registration.

ContentBlacklist grows 14,348 → 19,640 B, leaving 4,936 B of EIP-170 margin.

CapacityBondRegionE2E slash 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

    • Added compliance windows for blacklist entries, with separate governance and emergency settings.
    • Emergency blacklist entries and origins can now expire automatically or be cleared permissionlessly after their deadlines.
    • Added emergency severity categories and regional governance body lifecycle controls.
    • Regional bodies are now bound to specific regions with signer-overlap safeguards.
  • Bug Fixes

    • Updated enforcement and slashing eligibility to use effective timestamps, honor suspensions, and exclude expired emergency entries.
  • Documentation

    • Clarified blacklist timing, regional enforcement, emergency expiry, and operational remediation procedures.

…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]>
Copilot AI review requested due to automatic review settings July 22, 2026 00:03
@gemini-code-assist

Copy link
Copy Markdown

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@coderabbitai

coderabbitai Bot commented Jul 22, 2026 •

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@thiras, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 18 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Free

Run ID: f2f5d2d1-f640-43c7-9a14-01bec99f6691

📥 Commits

Reviewing files that changed from the base of the PR and between c191566 and a6e0e16.

📒 Files selected for processing (7)
  • adr/011-content-takedown.md
  • contracts/.gas-snapshot
  • contracts/src/ContentBlacklist.sol
  • contracts/test/ContentBlacklist.t.sol
  • crates/e2e/src/chain.rs
  • crates/e2e/tests/g_node_04_blacklist_compliance.rs
  • crates/incentive/src/content_blacklist.rs

Walkthrough

Changes

Content blacklist compliance

Layer / File(s) Summary
Blacklist contracts and compliance model
adr/011-content-takedown.md, contracts/src/ContentBlacklist.sol, contracts/src/interfaces/*
Compliance windows, effective timestamps, emergency categories, expanded hash entries, origin metadata, and signer enumeration interfaces are defined.
Emergency and regional governance flows
contracts/src/ContentBlacklist.sol, contracts/test/ContentBlacklist.t.sol, contracts/test/GovernanceLifecycle.t.sol, adr/016-contract-interactions.md
Emergency add/expiry paths and region-bound registration, suspension, signer checks, and deregistration are implemented and tested.
Slash enforcement and regression coverage
contracts/src/SlashJudge.sol, contracts/test/SlashJudge.t.sol, contracts/test/CapacityBondRegionE2E.t.sol, docs/runbook.md, adr/014-on-chain-verification.md, *.gas-snapshot
Slash eligibility uses effectiveAt and emergency expiry state; integration tests, runbook guidance, ADR verification, and gas snapshots are updated.
Estimated code review effort: 4 (Complex) | ~45 minutes

Note

🎁 Summarized by CodeRabbit Free

Your 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 @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Jul 22, 2026 •

Copy link
Copy Markdown

Contracts coverage

Line coverage: 89.58% (2657/2966 lines)
▲ +0.41pp vs base (89.17% → 89.58%)
Run: 29884492437

@github-actions

Copy link
Copy Markdown

Gas snapshot

No gas changes vs base.

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.

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; update SlashJudge to anchor blacklist slashing to effectiveAt (not addedAt).
  • 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.

Comment thread contracts/src/ContentBlacklist.sol Resolved
Comment thread contracts/src/ContentBlacklist.sol Resolved
@thiras thiras changed the title feat(contracts): ADR 011 takedown enforcement (#1167, #1169, #1178) feat(contracts): emergency multisig, compliance window, regional-body lifecycle (#1167, #1169, #1178) Jul 22, 2026
…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]>
@github-actions

github-actions Bot commented Jul 22, 2026 •

Copy link
Copy Markdown

Coverage report

Total: 81.55% (was 81.61%, ▼ 0.06%) — 53777/65943 lines

File Coverage Lines Δ
crates/e2e/src/chain.rs 1.12% 11/985 ▼ 0.06%
History
Commit Total Δ vs base
67297cd 81.55% ▼ 0.06%
a6e0e16 (HEAD) 81.55% ▼ 0.06%

…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.
@thiras
thiras merged commit a7caac7 into main Jul 22, 2026
23 checks passed
@thiras
thiras deleted the feat/adr011-takedown-contracts branch July 22, 2026 02:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants