Skip to content

feat: handle ChainEvent::Reorg in SubscriptionTask#97

Open
prestwich wants to merge 2 commits intodevelopfrom
james/eng-1970
Open

feat: handle ChainEvent::Reorg in SubscriptionTask#97
prestwich wants to merge 2 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>
Comment on lines +106 to +109
let filter = match self.as_filter() {
Some(f) => f,
None => return self.empty_sub_buffer(),
};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this could be a let else

Comment on lines +103 to +104
/// Block subscriptions return an empty buffer — removed block headers
/// are not available from the reorg notification.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we update ReorgNotification to hold removed headers rather than removed hashes? That way, we could populate the logs' hash, number and timestamp fields.

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