Skip to content

feat(node): durable blacklist deny-set, retiring the full-replay pin (#1181) - #1331

Merged
thiras merged 2 commits into
mainfrom
feat/durable-blacklist-denyset
Jul 20, 2026
Merged

thiras merged 2 commits into
mainfrom
feat/durable-blacklist-denyset

Conversation

@thiras

@thiras thiras commented Jul 20, 2026 •

Copy link
Copy Markdown
Contributor

Closes #1181.

Why the pin existed

The blacklist watcher full-replayed ContentBlacklist from the deploy block on every boot. That wasn't a tuning choice:

  • known was in-memory, and the contract exposes no enumeration view
  • 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 CapacityBond.updateRegion emits nothing on this contract at all
  • so a persisted cursor would resume past those logs and silently drop the entries from re-scoping

Serving a blacklisted hash is slashable, so a COMPLIANCE PIN test held the line.

Persisting the projection removes the premise. That is the whole change.

Change

Layer What
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.
blacklist_watcher State writes through to the store; cursor resumes.

The ColdStart bit is load-bearing

FromCheckpoint resolved 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::Head vs ColdStart::FromBlock) rather than a default, so the choice is a decision rather than an accident.

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 — the load-bearing invariant
  • deny_set_round_trips_through_the_store
  • blacklist_entries_survive_reopen (real redb, across reopen)
  • blacklist_removal_is_region_scoped_but_eviction_is_not
  • cursor_start_resumes_but_cold_starts_from_the_deploy_block — the rewritten compliance pin

Verification

  • 1122 node+incentive tests pass
  • clippy --all-targets, cargo fmt --check, RUSTDOCFLAGS="-D warnings" cargo doc all clean
  • anvil-e2e: all three blacklist tests pass — global_blacklist_compliance, regional_blacklist_scope, regional_scope_transition

⚠️ One e2e failure, g_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

    • Blacklist watcher state now persists across restarts, enabling resumable scanning without rebuilding the full deny-set.
    • Added durable handling for blacklist additions, removals, and hash-wide evictions.
    • Added configurable cold-start behavior for checkpoint-based watchers.
  • Bug Fixes

    • Prevented scan progress from advancing when blacklist updates cannot be durably saved.
    • Ensured blacklist checkpoints are flushed during shutdown.

…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]>
Copilot AI review requested due to automatic review settings July 20, 2026 16:00
@coderabbitai

coderabbitai Bot commented Jul 20, 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: 0f930e3a-94b4-41b8-8e74-4b3014cfdabb

📥 Commits

Reviewing files that changed from the base of the PR and between 21d493a and 386e7bc.

📒 Files selected for processing (6)
  • crates/incentive/src/store.rs
  • crates/node/src/blacklist_watcher.rs
  • crates/node/src/chain_events/resumable_watcher.rs
  • crates/node/src/channel_store.rs
  • crates/node/src/payment_settlement.rs
  • crates/node/src/runtime/mod.rs

Walkthrough

The blacklist watcher now persists its (region, hash) deny-set, resumes from a durable checkpoint, supports configurable cold starts, propagates persistence failures, and flushes its checkpoint during shutdown. The channel store implements durable entry storage with reopen and eviction tests.

Changes

Blacklist watcher durability

Layer / File(s) Summary
Cursor and storage contracts
crates/incentive/src/store.rs, crates/node/src/chain_events/resumable_watcher.rs, crates/node/src/payment_settlement.rs
Adds BlacklistEntryStore and BlacklistEntryRow, introduces ColdStart, and updates checkpoint-backed cursor configuration and tests.
Persistent blacklist-entry store
crates/node/src/channel_store.rs
Adds the blacklist_entry_v1 table, durable region/hash mutations, hash-wide eviction, and persistence tests.
Durable watcher processing
crates/node/src/blacklist_watcher.rs
Loads persisted entries, persists log changes before updating memory, resumes from the blacklist checkpoint, and aborts processing when durable writes fail.
Runtime wiring and shutdown flush
crates/node/src/runtime/mod.rs
Passes durable stores into the watcher and explicitly flushes the blacklist checkpoint during shutdown.

Estimated code review effort: 4 (Complex) | ~60 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.

@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 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.

Comment thread crates/node/src/blacklist_watcher.rs Resolved

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 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 BlacklistEntryStore projection of (region, hash) entries and wire the blacklist watcher to commit entry writes before advancing its cursor.
  • Extend CursorStart::FromCheckpoint with an explicit ColdStart policy (Head vs FromBlock) 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_v1 redb 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.

@github-actions

github-actions Bot commented Jul 20, 2026 •

Copy link
Copy Markdown

Coverage report

Total: 81.74% (was 81.64%, ▲ +0.09%) — 50788/62137 lines

File Coverage Lines Δ
crates/incentive/src/store.rs 90.76% 167/184 ● 0.00%
crates/node/src/blacklist_watcher.rs 89.41% 633/708 ▲ +6.77%
crates/node/src/chain_events/resumable_watcher.rs 94.89% 799/842 ▲ +0.04%
crates/node/src/channel_store.rs 89.87% 1100/1224 ▲ +0.14%
crates/node/src/payment_settlement.rs 56.56% 944/1669 ▲ +0.03%
crates/node/src/runtime/mod.rs 45.69% 1081/2366 ▼ 0.12%
History
Commit Total Δ vs base
f5e8797 81.73% ▲ +0.09%
386e7bc (HEAD) 81.74% ▲ +0.09%

…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]>
@thiras
thiras merged commit 41fc49d into main Jul 20, 2026
23 checks passed
@thiras
thiras deleted the feat/durable-blacklist-denyset branch July 20, 2026 16:27
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.

ContentBlacklist: add getBlacklistVersion() counter + delta sync

2 participants