Skip to content

feat(contracts): carry the post-change version on ContentBlacklist hash events - #1326

Merged
thiras merged 1 commit into
mainfrom
feat/contentblacklist-versioned-events
Jul 19, 2026
Merged

thiras merged 1 commit into
mainfrom
feat/contentblacklist-versioned-events

Conversation

@thiras

@thiras thiras commented Jul 19, 2026 •

Copy link
Copy Markdown
Contributor

A delta consumer polls getBlacklistVersion() to decide whether to fetch, then reads event logs to learn what changed. That split only works if two things hold: every advance of the counter has a matching log, and each log says which revision it belongs to.

Neither held. HashBlacklisted and HashRemoved carried no version, and the appeal-driven suspend/resume path bumped _blacklistVersion while emitting nothing at all — it flips whether a live entry is enforced (_isLive) without adding or removing anything, so it fell between the two existing events. A node fetching deltas could see the counter move with no event behind it and silently under-enforce a resumed hash, which is the compliance failure the poll cycle exists to prevent.

Changes

  • HashBlacklisted / HashRemoved now carry the post-change version — the getBlacklistVersion() value after the change, so a consumer can order events and confirm no gap.
  • New HashSuspensionUpdated, emitted from the _setEntrySuspended choke point. That choke point already existed to keep the counter bumps in one place; the event now sits with it, so every bump has exactly one matching log.
  • ADR 011 § Polling documents the mechanism.

Why version is not indexed

EVM topic filters match by set membership, not range, so indexing version buys no "give me versions 5–12" query — it would only let you ask for an exact set of versions you already knew. The node instead keys eth_getLogs on a block range from its last-seen checkpoint and uses version to order the deltas and prove it has seen every revision. The counter answers whether to fetch; the events answer what changed.

Scope

Origin blacklisting stays deliberately outside this mechanism. OriginBlacklistUpdated carries no version and is enforced via OriginAssignment cross-reference at selection time with lazy permissionless cleanup, not the hash version poll.

Also included, in ADR 011 only: operator standing under appeal path 2 does not require a region match on a global entry — a global entry binds every region, so any in-scope operator has standing without one.

Verification

  • forge fmt --check — clean
  • FOUNDRY_PROFILE=ci forge build --sizes --deny warnings — clean
  • forge test — 753 passed, 0 failed
  • aderyn — 0 high; slither --config-file slither.config.json — exit 0
  • ContentBlacklist is 14,920 bytes, well clear of the EIP-170 limit

New tests: test_HashRemoved_carriesVersion, and test_HashSuspensionUpdated_onSuspendAndResume — which asserts on both edges (fast-track suspends, reversal resumes), since the resume side is the one whose absence caused silent under-enforcement.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Documentation
    • Updated content takedown and appeal guidance for global vs regional entries, including sentinel handling and synchronization semantics.
  • API Updates
    • Renamed global blacklist operations and reordered regional parameters.
    • Updated blacklist events to include the current version, added suspension-change events, and updated origin status eventing.
  • Bug Fixes
    • Improved transparency of removal and suspension/resumption lifecycle changes via consistent, versioned event reporting.
  • Tests / Chores
    • Extended event assertions for versioning and suspension transitions; refreshed gas snapshots.

Copilot AI review requested due to automatic review settings July 19, 2026 19:42
@coderabbitai

coderabbitai Bot commented Jul 19, 2026 •

Copy link
Copy Markdown

Review Change Stack

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Free

Run ID: 780b0fc5-e541-4fab-94bb-4bf712bc77cb

📥 Commits

Reviewing files that changed from the base of the PR and between 586f8a1 and 0d68cb6.

📒 Files selected for processing (5)
  • adr/011-content-takedown.md
  • contracts/.gas-snapshot
  • contracts/src/ContentBlacklist.sol
  • contracts/test/ContentBlacklist.t.sol
  • crates/incentive/src/content_blacklist.rs
🚧 Files skipped from review as they are similar to previous changes (3)
  • contracts/src/ContentBlacklist.sol
  • contracts/test/ContentBlacklist.t.sol
  • adr/011-content-takedown.md

Walkthrough

The ADR revises ContentBlacklist governance, appeal, event, and polling semantics. The contract and Rust ABI emit versioned hash events, tests validate event payloads, and gas snapshots are updated.

Changes

Blacklist Event Versioning

Layer / File(s) Summary
Contract and appeal semantics
adr/011-content-takedown.md
The ADR documents renamed blacklist functions, regional parameter ordering, sentinel-based appeal scope, revised event definitions, and block-range polling behavior.
Versioned blacklist events
contracts/src/ContentBlacklist.sol, crates/incentive/src/content_blacklist.rs
Hash addition, removal, and suspension events include the post-change blacklist version, with matching Rust ABI declarations.
Event regression coverage
contracts/test/ContentBlacklist.t.sol
Tests verify versioned removal and suspension events and update hash-addition event expectations.
Gas baseline updates
contracts/.gas-snapshot
Recorded gas metrics are updated for ContentBlacklist and other affected test cases.

Estimated code review effort: 2 (Simple) | ~10 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 19, 2026 •

Copy link
Copy Markdown

Contracts coverage

Line coverage: 88.96% (2499/2809 lines)
▲ +0.00pp vs base (88.96% → 88.96%)
Run: 29703724134

@github-actions

github-actions Bot commented Jul 19, 2026 •

Copy link
Copy Markdown

Gas snapshot

No gas changes vs base.

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request updates the content takedown architecture (ADR 011) and its implementation in ContentBlacklist.sol to include the post-change blacklist version in the HashBlacklisted, HashRemoved, and HashSuspensionUpdated events, enabling delta consumers to reliably order events and detect gaps. Additionally, the scope of appeals has been expanded to cover global entries, and several interface functions and events have been renamed or updated to align with these design changes. Unit tests have been added and updated to verify the new event payloads and version tracking. There are no review comments, and I have no feedback to provide.

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.

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

This PR updates the ContentBlacklist contract’s hash-related events to carry the post-change blacklist version, and adds a dedicated event for appeal-driven suspend/resume so every _blacklistVersion increment has a corresponding log entry. This supports delta consumers that poll getBlacklistVersion() to decide whether to fetch, and then use logs to determine what changed.

Changes:

  • Extend HashBlacklisted and HashRemoved to include the post-change version, and emit that value from the add/remove helpers.
  • Add HashSuspensionUpdated emitted from _setEntrySuspended, ensuring appeal-driven suspend/resume version bumps are never “silent”.
  • Add/adjust Foundry tests to assert the version-bearing events, and update ADR 011 polling documentation accordingly.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
contracts/src/ContentBlacklist.sol Adds version to hash add/remove events and introduces HashSuspensionUpdated emitted from the suspend/resume choke point.
contracts/test/ContentBlacklist.t.sol Adds tests asserting version-bearing removal and suspension events; updates existing event expectations for new signatures.
adr/011-content-takedown.md Documents the polling/log strategy and updates the described events (but has interface-type inconsistencies noted in review comments).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +39 to +43
// Regional governance path — REGIONAL_BODY_ROLE, callable only by a
// registered regional body. Both revert on the global sentinel, so a
// regional body can never reach a global entry.
function addHashRegional(string calldata region, bytes32 blake3Hash, string calldata reason) external;
function removeHashRegional(string calldata region, bytes32 blake3Hash) external;
Comment on lines +71 to +74
// Per-entry appeal flow (see § Blacklist Entry Appeals). Regional entries are
// the primary case; global entries are filable by naming GLOBAL_REGION.
// openBlacklistAppeal reverts on the UNSET region sentinel (bytes32(0)) and on
// entries past their filing window. The filer declares one standing path:
…sh events

A delta consumer polls `getBlacklistVersion()` to decide whether to fetch, then
reads event logs to learn what changed. That only works if every advance of the
counter has a matching log and each log says which revision it belongs to —
otherwise the version can move with no event behind it, and a node silently
under-enforces a resumed hash. Under-enforcement is precisely the compliance
failure the poll cycle exists to prevent.

Three changes:

- `HashBlacklisted` and `HashRemoved` now carry the post-change `version`.
- New `HashSuspensionUpdated`, emitted from the `_setEntrySuspended` choke point.
  This was the gap: an appeal-driven suspend/resume flips whether a live entry is
  enforced and bumps `_blacklistVersion`, but added or removed nothing — so it
  advanced the counter with no log at all.
- ADR 011 § Polling documents the mechanism, including why `version` is NOT
  indexed: EVM topic filters match by set membership, not range, so indexing buys
  no range query. The node keys `eth_getLogs` on a block range from its last-seen
  checkpoint and uses `version` to order deltas and prove there is no gap.

Origin blacklisting stays deliberately outside this: `OriginBlacklistUpdated`
carries no version and is enforced via `OriginAssignment` cross-reference at
selection time, not the hash version poll.

Also in ADR 011: operator standing under appeal path 2 does not require a region
match on a **global** entry — a global entry binds every region, so any in-scope
operator has standing.

Verified: `forge fmt --check`, `FOUNDRY_PROFILE=ci forge build --sizes --deny
warnings`, `forge test` (753 passed), `aderyn` (0 high), `slither` (exit 0).
ContentBlacklist is 14,920 bytes, well under the EIP-170 limit.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@thiras
thiras force-pushed the feat/contentblacklist-versioned-events branch from 586f8a1 to 0d68cb6 Compare July 19, 2026 21:05
@github-actions

Copy link
Copy Markdown

Coverage report

Total: 81.63% (was 81.63%, ● 0.00%) — 50381/61722 lines

No coverage data for changed Rust files.

History
Commit Total Δ vs base
0d68cb6 (HEAD) 81.63% ● 0.00%

@thiras
thiras merged commit 4a527b1 into main Jul 19, 2026
42 of 45 checks passed
@thiras
thiras deleted the feat/contentblacklist-versioned-events branch July 19, 2026 22:18
thiras added a commit that referenced this pull request Jul 20, 2026
…nUpdated (#1330)

#1326 added `HashSuspensionUpdated` to `ContentBlacklist` so that every
`_blacklistVersion` bump has a matching log. The node did not consume it.

The watcher already *honored* suspension, but only indirectly: suspended
entries stay in `known` and the batched re-scope asks the contract's
`isHashBlacklistedForOperator` view, which accounts for `suspended`. The gap
was latency on the **resume** edge — an appeal reversal/lapse re-arms
enforcement while emitting no `HashBlacklisted`, so the hash stayed servable
until the next re-scope pass (up to a full rescan cadence). Serving a
re-enforced hash is slashable, so that window is real exposure.

- `crates/incentive/src/content_blacklist.rs`: mirror the `HashSuspensionUpdated`
  declaration so the binding's `SIGNATURE_HASH` matches the contract.
- `crates/node/src/blacklist_watcher.rs`: subscribe to the third topic, dispatch
  it, and add `on_suspension_log`:
    - resume (`suspended == false`) -> re-check scope immediately, exactly as
      `on_blacklisted_log` does for a fresh entry;
    - suspend (`suspended == true`) -> retain in `known`, no re-check. Suspension
      only ever narrows what is enforced, and local eviction is deliberately
      sticky and one-way, so there is nothing to undo.
  Both edges keep the entry in `known` so the periodic re-scope still watches it.

The periodic re-scope remains the backstop and is NOT redundant: it is still the
only thing that catches a region/ripening transition
(`CapacityBond.updateRegion`), which emits no event at all.

Tests cover both edges against the mocked provider: the resume path surfaces
`Recheck::Failed` (proving it attempted the re-check), the suspend path returns
`Recheck::NoAction` (proving it spent no RPC), and both assert the entry stays
in `known`.

Refs #1300. Does not touch the full-replay cursor or its COMPLIANCE PIN — the
delta-sync half of #1181 is separate.

Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants