fix(evmreader): avoid delaying work by skiping old blocks notifications#781
Draft
renatomaia wants to merge 1 commit into
Draft
fix(evmreader): avoid delaying work by skiping old blocks notifications#781renatomaia wants to merge 1 commit into
renatomaia wants to merge 1 commit into
Conversation
c323cc3 to
1baa9f1
Compare
mpolitzer
reviewed
May 27, 2026
| // Discard accumulated block notifications to work only the most recent. | ||
| blockNumber, err := r.client.BlockNumber(ctx) | ||
| if err == nil { | ||
| for header.Number.Uint64() != blockNumber { |
There was a problem hiding this comment.
UNTESTED
You can drain the channel without relying on block number retrieval:
for {
select {
case header = <-headers:
default:
break
}
}
Author
There was a problem hiding this comment.
I tried that but the notification thread does not execute fast enough to keed the channel from blocking.
I added a size to the channel (buffer of notifications) to be able to mitigate this problem, but it should be a size large enough that the notification thread will be scheduled before our for discarding the notifications can finish.
Anyhow, @vfusco suggested I poll the block number and remove the use of single block notification.
…ocket notifications
1baa9f1 to
a7bbab4
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
EVM Reader was processing each single new chain block notification, therefore when the processing was too slow (>2 seconds) the notifications accumulated and the EVM Reader could not keep up since worked one block at time. The fix is to skip old block notifications when a more recent is already available.