Repository navigation
Description
Found by the genesis-replay audit spun off from #1491. Same shape as the OriginAssignment namespace replay: a cold node discovers a set by scanning event logs from the deploy block because the backing contract exposes no enumerable view. This issue proposes replacing that cold-start replay with an enumerable point read, the same way #1491 does for the origin directory.
The replay
crates/node/src/blacklist_watcher.rs (spawn, ColdStart::FromBlock, .with_from_block(from_block)): a cold node replays the entire blacklist history from the ContentBlacklist deploy block to reconstruct the current blacklisted (region, hash) set. The first eth_getLogs window is the historical replay; later ticks are the live tail. The watcher's own module doc states it plainly: "ContentBlacklist exposes no enumeration view, so events are the only way."
Backing state — contracts/src/ContentBlacklist.sol:
mapping(bytes32 region => mapping(bytes32 hash => HashEntry)) internal _hashEntries;Nested mapping, no enumerable index. Every existing read (isHashBlacklisted, getHashEntry, …) is a point-read keyed by a hash you already know — there is no way to ask "give me the current set."
Core change
Add an enumerable per-region hash index to ContentBlacklist and switch the node's cold-start from log replay to a paginated point read.
Contract surface (ContentBlacklist.sol)
mapping(bytes32 region => EnumerableSet.Bytes32Set) _regionHashes, maintained on the add/remove paths (addHashRegional/removeHashRegional/ global add/remove) on the 0↔1 liveness transitions.- Paginated views:
blacklistedHashCount(bytes32 region)+blacklistedHashAt(bytes32 region, uint256 i)(offset/limit page form to matchdeferredSettlements(offset, limit)). A region enumerator to pair with them if the node needs to discover regions too — otherwise the node enumerates only the regions it's scoped to. - SSTOREs on the add/remove paths are accepted (per the audit constraint) — do not weigh index-maintenance gas against this.
Rust (crates/node/src/blacklist_watcher.rs)
- Cold start: replace the
ColdStart::FromBlockfull replay withblacklistedHashCount→blacklistedHashAt(i)→getHashEntryfor the node's scoped region(s). Authoritative current set, no deploy-block scan. - Live watcher (liveness only) stays: keep following the blacklist mutation events as the signal to re-read; drop only the historical-discovery role of the first window. The runtime still gates ALPN listeners on the initial-sync
InitialSyncResult, so cold start must still complete before serving — an authoritative enumerated read satisfies that better than replaying removed-then-re-added history.
Priority / caveats — [your call]
Weaker candidate than #1491, for two reasons:
- Already locally persisted. The watcher persists entries durably (
CheckpointKey::Blacklist+ durable projection), so warm restarts don't replay — only a first/cold boot (fresh disk, new node) does. OriginAssignment: vetted-publisher instant origins (collapse assignment into publisher vetting) #1491's origin directory persists only a cursor and leans on the live tail to re-surface older namespaces, so it replays more often. - Bigger enumerable surface. The nested
region => hashscoping means the index is per-region (and possibly a region enumerator too), vs. origin's single flatUintSetof namespaces.
Net: real replay-elimination and an authoritative-read upgrade for cold/new nodes, but lower payoff than the origin directory. Reasonable to land after #1491 or defer.
Do we need the whole set at all? (reconsidered — likely NOT)
The serve hot path checks self.cache.is_denied(hash) (crates/node/src/handlers/client/dispatch.rs:201) — a synchronous local lookup, so today the node mirrors the whole region blacklist locally. But a node can only ever be asked to serve a hash it has cached; it never needs verdicts for the rest of the global blacklist. The whole-set mirror materializes far more than this node can be asked about.
Alternative that removes the replay AND the enumerable view AND any contract change:
- Check
isHashBlacklisted(hash)at cache admission (first pull/cache of a blob) instead of mirroring the global set. The local deny-set then scopes to cached content only. - Keep the live event tail to revoke already-cached content that gets blacklisted later.
This is a bigger shift than swapping a getter — it moves enforcement off the synchronous hot path and re-frames the InitialSyncResult listener gate — so it isn't free. But it's the honest answer to "do we need the whole index": for blacklist, likely no.
So the enumerable-view proposal above is the right fix ONLY IF we deliberately keep mirroring the entire region blacklist locally (synchronous, fail-closed hot-path check). If we're open to scope-to-cached admission-time checks, prefer that — it needs no contract change. [your call] on which model to commit to; that decision should precede any contract work here.
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Activity
thiras commentedon Jul 29, 2026
Audited against
main(14abf22c): the contract and Rust work this issue proposes has already shipped in #1504, under different names. Closing via #1510, which carries no code change for this issue beyond a stale doc fix.Contract —
contracts/src/ContentBlacklist.sol::221—mapping(bytes32 region => EnumerableSet.Bytes32Set) internal _regionHashes, maintained in the two choke points_addHash/_removeHashRegional. Exactly the storage proposed here.:593blacklistedHashCount(bytes32 region),:614blacklistedHashes(bytes32 region, uint256 offset, uint256 limit).:231EnumerableSet.AddressSet _blacklistedAddrs(origin ∪ operator) withblacklistedAddressCount/blacklistedAddresses.Note the shape difference: the shipped view is the paginated page form
blacklistedHashes(offset, limit), matchingdeferredSettlements(offset, limit)— not the per-indexblacklistedHashAt(i)this issue proposed.blacklistedHashAtshould not be added; the page form supersedes it.Rust —
crates/node/src/blacklist_watcher.rs::1161— cold start isbootstrap_snapshot, which pins a block viaget_block_numberthen pagesblacklistedAddresses/blacklistedHashes, with a count-vs-seenensure!abort on a partial read (:461). Fail-closed, no log replay.CursorStart::Seeded, no persist), plus a periodic re-enumeration backstop (:724).ColdStart::FromBlockno longer exists —chain_events/resumable_watcher.rs:64now has the single variantHead, andFromBlockreturns nothing workspace-wide.On the "do we need the whole set at all?" alternative — not taken, deliberately. The node still mirrors the entire in-scope region blacklist locally.
handlers/client/dispatch.rs:201consultscache.is_denied/cache.is_chain_deniedsynchronously on the serve hot path, and the two-set/one-wire-code design exists to satisfy the ADR 011 §StreamRequest indistinguishability requirement. Moving enforcement to an admission-timeisHashBlacklistedcheck would re-frame that gate and theInitialSyncResultlistener gate, so it is a separate decision — not something to fold into a getter swap.Only stale prose remained:
crates/node/src/content_deny.rsstill said the watcher "fills that in once it has replayed". Fixed in #1510 along with the same class of drift inchain_origin_directory.rsandchain_events/backfill.rs.