Skip to content

feat: handle ChainEvent::Reorg in SubscriptionTask#97

Merged
prestwich merged 3 commits intodevelopfrom
james/eng-1970
Mar 13, 2026
Merged

feat: handle ChainEvent::Reorg in SubscriptionTask#97
prestwich merged 3 commits intodevelopfrom
james/eng-1970

Conversation

@prestwich
Copy link
Member

@prestwich prestwich commented Mar 9, 2026

Summary

  • Add InterestKind::filter_reorg_for_sub to filter removed logs from reorg notifications against subscription criteria, emitting matching logs with removed: true per the Ethereum JSON-RPC spec
  • Replace the no-op ChainEvent::Reorg arm in SubscriptionTask::task_future with proper handling that buffers filtered removed logs for emission to subscribers
  • Block subscriptions handle reorgs gracefully by returning an empty buffer (removed block headers are not available from the reorg notification)

Closes ENG-1970 (subticket 4 of ENG-1900).

Stack

This PR includes commits from #96. Review only the top commit.

  1. feat: update BlockTags during reorgs to prevent stale tag window #96BlockTags::rewind_to for reorg tag updates
  2. feat: handle ChainEvent::Reorg in SubscriptionTask #97 ← this PRSubscriptionTask reorg handling
  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

  • Unit tests for matching removed logs with removed: true
  • Unit tests for filtering out non-matching removed logs
  • Unit test for block subscription returning empty buffer on reorg
  • cargo clippy -p signet-rpc --all-features --all-targets clean
  • All 45 existing + new tests pass

🤖 Generated with Claude Code

…mission

Replace the no-op reorg arm in SubscriptionTask::task_future with proper
handling that filters removed logs against subscription criteria and emits
them with `removed: true` per the Ethereum JSON-RPC spec.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@prestwich prestwich marked this pull request as ready for review March 11, 2026 13:04
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Address review feedback:
- Replace `removed_hashes`/`removed_logs` with per-block `RemovedBlock`
  structs carrying headers, so removed logs include `block_hash`,
  `block_number`, and `block_timestamp` per the Ethereum JSON-RPC spec.
- Use `let else` instead of match for early return (Evalir).
- Take `ReorgNotification` by value in `filter_reorg_for_sub` to avoid
  intermediate `collect` and per-log clones.
- Use `into_inner()` on `SealedHeader` instead of `inner().clone()`.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@prestwich prestwich requested review from Evalir and Fraser999 March 12, 2026 17:56
@prestwich prestwich merged commit c602aa8 into develop Mar 13, 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.

3 participants