Skip to content

feat(EventListener): Add onBlock re-org detection - #3248

Merged
pxrl merged 8 commits into
masterfrom
pxrl/reorgDetection
Apr 17, 2026
Merged

feat(EventListener): Add onBlock re-org detection#3248
pxrl merged 8 commits into
masterfrom
pxrl/reorgDetection

Conversation

@pxrl

@pxrl pxrl commented Apr 16, 2026

Copy link
Copy Markdown
Collaborator

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.

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>

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 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".

Comment thread src/clients/EventListener.ts Outdated
@pxrl

pxrl commented Apr 17, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 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".

Comment thread src/clients/EventListener.ts Outdated
Comment thread src/clients/EventListener.ts Outdated
@pxrl

pxrl commented Apr 17, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 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".

Comment thread src/libexec/RelayerSpokePoolListenerTVM.ts
Comment thread src/libexec/RelayerSpokePoolListenerTVM.ts
nicholaspai
nicholaspai previously approved these changes Apr 17, 2026
@pxrl
pxrl merged commit 5775e42 into master Apr 17, 2026
4 checks passed
@pxrl
pxrl deleted the pxrl/reorgDetection branch April 17, 2026 18:05
nicholaspai pushed a commit that referenced this pull request Apr 17, 2026
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>
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