Skip to content

feat: update BlockTags during reorgs to prevent stale tag window#96

Merged
prestwich merged 2 commits intodevelopfrom
james/eng-1969-block-tags-reorg
Mar 11, 2026
Merged

feat: update BlockTags during reorgs to prevent stale tag window#96
prestwich merged 2 commits intodevelopfrom
james/eng-1969-block-tags-reorg

Conversation

@prestwich
Copy link
Member

@prestwich prestwich commented Mar 9, 2026

Summary

  • Add BlockTags::rewind_to(ancestor) method that caps all three tags at a given block number using fetch_min, with stores ordered latest → safe → finalized (reverse of update_all) to prevent readers from ever seeing latest < finalized
  • Call rewind_to in on_host_revert after drain_above but before notify_reorg, closing the window where latest could point to a non-existent block
  • Add unit tests and doc tests for the new method

Closes ENG-1969

Stack

This is the base PR in a stack of 4:

  1. feat: update BlockTags during reorgs to prevent stale tag window #96 ← this PRBlockTags::rewind_to for reorg tag updates
  2. feat: handle ChainEvent::Reorg in SubscriptionTask #97SubscriptionTask reorg handling (includes feat: update BlockTags during reorgs to prevent stale tag window #96)
  3. feat: handle reorgs in get_filter_changes with reorg watermark #98get_filter_changes reorg watermark (includes feat: update BlockTags during reorgs to prevent stale tag window #96, feat: handle ChainEvent::Reorg in SubscriptionTask #97)
  4. test: integration tests for reorg tracking in RPC subscriptions and filters #99 — Integration tests (includes feat: update BlockTags during reorgs to prevent stale tag window #96, feat: handle ChainEvent::Reorg in SubscriptionTask #97, feat: handle reorgs in get_filter_changes with reorg watermark #98)

Test plan

  • cargo clippy -p signet-rpc --all-features --all-targets — clean
  • cargo clippy -p signet-rpc --no-default-features --all-targets — clean
  • cargo clippy -p signet-node --all-features --all-targets — clean
  • cargo t -p signet-rpc — 35 unit + 4 doc tests pass
  • cargo +nightly fmt — clean
  • Integration tests in signet-node-tests (require full reth host setup)

🤖 Generated with Claude Code

Add `BlockTags::rewind_to(ancestor)` that caps all three tags (latest,
safe, finalized) at a given block number using `fetch_min`. Stores run
in reverse order (latest → safe → finalized) compared to `update_all`
so readers never observe `latest < finalized` while values decrease.

Called in `on_host_revert` after `drain_above` but before `notify_reorg`
so RPC consumers always see tags consistent with storage.

Closes ENG-1969

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@prestwich prestwich requested a review from a team as a code owner March 9, 2026 18:28
The previous order (latest → safe → finalized) allowed readers to
momentarily observe latest < finalized during a rewind. Reorder to
finalized → safe → latest so the invariant is maintained.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@prestwich prestwich merged commit fe9585f into develop Mar 11, 2026
6 checks passed
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