Repository navigation
feat(node): durable blacklist deny-set, retiring the full-replay pin (#1181) - #1331
Conversation
…1181) The blacklist watcher full-replayed `ContentBlacklist` from the deploy block on every boot. That was not a tuning choice: `known` was in-memory, the contract exposes no enumeration view, and the watcher deliberately retains entries that are out of scope (wrong region) or appeal-suspended, because either can become enforceable again with no new `HashBlacklisted` log. A persisted cursor would resume past those logs and silently drop the entries from re-scoping — and serving a blacklisted hash is slashable. A COMPLIANCE PIN test held the line. Persisting the projection removes the premise, so the cursor can resume. - `decdn_incentive::store`: new `BlacklistEntryStore` trait. Its durability contract is deliberately stricter than `KeyedCheckpointStore`'s — these writes may NOT be debounced, because the cursor's safety depends on them committing first. - `channel_store`: `blacklist_entry_v1` redb table in the existing `channels.redb` (redb forbids two handles on one file), keyed `region || hash` so a same-hash entry in another region is a distinct row. - `resumable_watcher`: new explicit `ColdStart` policy on `FromCheckpoint`. Settlement's `None => head` is wrong here: a cold blacklist store must replay from `from_block` or a first boot misses every pre-existing entry. Making it an explicit field rather than a default keeps that a decision, not an accident. - `blacklist_watcher`: state writes through to the store, cursor resumes. Two invariants, both pinned by tests: 1. The cursor never leads the deny-set. Entry writes commit durably before the in-memory set is touched, and a failed write returns `Err` from `handle_log`, which `run_tick` propagates *before* `cfg.start.persist(end)` — so the cursor cannot advance past a log whose entry was lost. A lagging cursor is harmless: every operation is idempotent, so a wider rescan only costs RPC. 2. A cold store still replays everything (`ColdStart::FromBlock`). Degradation is toward safety: if the durable set is unreadable at boot, the watcher logs and falls back to `FullReplay` rather than resuming on a partial set. `drop_hash` is the one write that does not fail the tick — the hash is already durably evicted, so a failed delete costs one redundant re-check, not enforcement. Teardown now flushes `CheckpointKey::Blacklist`, mirroring the `Origin` key. Tests: durable-write failure aborts the tick; deny-set round-trips; redb entries survive reopen; removal is region-scoped while eviction is not; and the rewritten compliance pin now asserts the resume + cold-start-from-deploy-block pair. Verified: 1122 node+incentive tests pass; clippy `--all-targets`, `cargo fmt`, and `RUSTDOCFLAGS=-D warnings cargo doc` clean; the three `anvil-e2e` blacklist tests (global, regional scope, regional transition) pass. One pre-existing `g_origin_01_publish` e2e failure reproduces identically on a clean tree. Closes #1181. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Free Run ID: 📒 Files selected for processing (6)
WalkthroughThe blacklist watcher now persists its ChangesBlacklist watcher durability
Estimated code review effort: 4 (Complex) | ~60 minutes 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 |
There was a problem hiding this comment.
Code Review
This pull request implements a durable blacklist deny-set and a resumable scan cursor for the blacklist watcher (#1181). It introduces the BlacklistEntryStore trait and its implementation using a new redb table, allowing the watcher to persist the deny-set across restarts instead of performing a full replay from the deploy block on every boot. The resumable watcher is updated with a ColdStart policy to support both starting from head (for settlement) and from the deploy block (for the blacklist). Feedback suggests expanding a unit test to assert that drop_hash correctly removes entries from the durable store in addition to the in-memory set.
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 makes the node’s ContentBlacklist enforcement resumable and durable by persisting the blacklist deny-set to disk and safely enabling a persisted scan cursor. It introduces an explicit cold-start policy for checkpoint-based watchers so first-boot behavior is a deliberate, correctness-critical choice rather than an implicit default.
Changes:
- Add a durable
BlacklistEntryStoreprojection of(region, hash)entries and wire the blacklist watcher to commit entry writes before advancing its cursor. - Extend
CursorStart::FromCheckpointwith an explicitColdStartpolicy (HeadvsFromBlock) and update existing watcher call sites accordingly. - Persist and flush the blacklist scan checkpoint on shutdown, and store blacklist entries in a new
blacklist_entry_v1redb table.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| crates/node/src/runtime/mod.rs | Wires the blacklist watcher to the concrete (non-debounced) store and flushes the blacklist checkpoint on shutdown. |
| crates/node/src/payment_settlement.rs | Updates checkpoint-based cursor start to specify ColdStart::Head. |
| crates/node/src/channel_store.rs | Adds blacklist_entry_v1 redb table plus BlacklistEntryStore implementation with immediate durability commits. |
| crates/node/src/chain_events/resumable_watcher.rs | Introduces ColdStart and makes it an explicit field on CursorStart::FromCheckpoint. |
| crates/node/src/blacklist_watcher.rs | Persists the deny-set entries, reloads them on boot, and switches the watcher to a resumable cursor with safe cold-start replay. |
| crates/incentive/src/store.rs | Defines the BlacklistEntryStore trait and documents its stricter durability contract vs checkpoint persistence. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Coverage reportTotal: 81.74% (was 81.64%, ▲ +0.09%) — 50788/62137 lines
History
|
…mory Review catch on #1331: `drop_hash_clears_all_regions_for_that_hash_only` only exercised the in-memory `known` set, so `drop_hash`'s write-through to the durable store was unasserted. Deleting that store call left every assertion in the test passing while the evicted hash would walk back in on the next boot's reload — the redb-layer test in `channel_store` covers `remove_blacklist_hash` itself, but not the wiring to it. Switched the test to a store handle it can inspect and added the durable assertion. Confirmed by mutation: stripping the write-through now fails the test. Deviates from the suggested snippet in one respect — it indexed `remaining_entries[0]`, which the workspace's `indexing_slicing` deny rejects, so the whole vec is compared instead. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Closes #1181.
Why the pin existed
The blacklist watcher full-replayed
ContentBlacklistfrom the deploy block on every boot. That wasn't a tuning choice:knownwas in-memory, and the contract exposes no enumeration viewHashBlacklistedlog — aCapacityBond.updateRegionemits nothing on this contract at allServing a blacklisted hash is slashable, so a
COMPLIANCE PINtest held the line.Persisting the projection removes the premise. That is the whole change.
Change
decdn_incentive::storeBlacklistEntryStoretrait. Its durability contract is deliberately stricter thanKeyedCheckpointStore's: these writes may not be debounced, because the cursor's safety depends on them committing first.channel_storeblacklist_entry_v1redb table in the existingchannels.redb(redb forbids two handles on one file), keyedregion || hashso a same-hash entry in another region is a distinct row.resumable_watcherColdStartpolicy onFromCheckpoint.blacklist_watcherThe
ColdStartbit is load-bearingFromCheckpointresolved a cold store to head ("nothing predates the node") — correct for settlement, wrong here: a first boot would miss every pre-existing blacklist entry. It is now an explicit field (ColdStart::HeadvsColdStart::FromBlock) rather than a default, so the choice is a decision rather than an accident.Two invariants, both pinned by tests
Errfromhandle_log, whichrun_tickpropagates beforecfg.start.persist(end)— so the cursor cannot advance past a log whose entry was lost. A lagging cursor is harmless: every operation is idempotent, so a wider rescan only costs RPC.ColdStart::FromBlock).Degradation is toward safety
If the durable set is unreadable at boot, the watcher logs and falls back to
FullReplayrather than resuming on a partial set.drop_hashis the one write that does not fail the tick — the hash is already durably evicted, so a failed delete costs one redundant re-check, not enforcement.Teardown now flushes
CheckpointKey::Blacklist, mirroring theOriginkey.Tests
durable_write_failure_aborts_the_tick— the load-bearing invariantdeny_set_round_trips_through_the_storeblacklist_entries_survive_reopen(real redb, across reopen)blacklist_removal_is_region_scoped_but_eviction_is_notcursor_start_resumes_but_cold_starts_from_the_deploy_block— the rewritten compliance pinVerification
clippy --all-targets,cargo fmt --check,RUSTDOCFLAGS="-D warnings" cargo docall cleananvil-e2e: all three blacklist tests pass —global_blacklist_compliance,regional_blacklist_scope,regional_scope_transitiong_origin_01_publish::namespace_create_claim_and_union— pre-existing, reproduces identically on a clean stashed tree. Unrelated to this change.Side effect
Retires the #1108 crash-loop exposure at its source: a rate-limited boot no longer re-scans the whole chain.
🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Bug Fixes