feat(EventListener): Add onBlock re-org detection - #3248
Conversation
Track block hashes alongside block numbers in EventListener and verify parent-hash continuity on each new block. On a parent-hash mismatch, walk back to the fork point, eject events above it from EventManager, and re-emit them with removed: true so downstream consumers can invalidate any state derived from orphaned blocks. EventManager gains a removeAbove(blockNumber) method backed by a new blockNumbers index that maps block number -> set of block hashes, so orphaned events can be dropped in bulk without iterating the full event table. EventManager.remove() is updated to maintain the same index and guard against missing entries. EventManager continues to react to per-event re-org notification as received over websocket subscriptions, but that support could eventually be deprecated in favour of this. This is however necessary for HTTPS-based polling via eth_getLogs, where no built-in re-org detection exists. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3eb22010ee
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f1be6c97c5
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c8ec876412
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
The TVM RPC interface is extremely constrained vs. other EVM implementations. Many features don't work, notably event subscriptions. Trying to support this within the existing EVM listener was proving invasive, so spin the TVM-specific implementation out separately. This allows risk-free iterations to mature the code. We still hold out hope that it might one day be unified with the EVM implementation. --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The TVM RPC interface is extremely constrained vs. other EVM
implementations. Many features don't work, notably event subscriptions.
Trying to support this within the existing EVM listener was proving
invasive, so spin the TVM-specific implementation out separately. This
allows risk-free iterations to mature the code. We still hold out hope
that it might one day be unified with the EVM implementation.