Update sync state and raw events regardless of handler registration - #321
Merged
Conversation
JonoPrest
commented
Nov 5, 2024
Comment on lines
-301
to
-313
| eventBatchQueueItem->updateEventSyncState( | ||
| ~inMemoryStore, | ||
| ~isPreRegisteringDynamicContracts=false, | ||
| ) | ||
| if config.enableRawEvents { | ||
| eventBatchQueueItem->addEventToRawEvents(~inMemoryStore) | ||
| } | ||
| latestProcessedBlocks | ||
| ->EventsProcessed.updateEventsProcessed( | ||
| ~chain=eventBatchQueueItem.chain, | ||
| ~blockNumber=eventBatchQueueItem.blockNumber, | ||
| ) | ||
| ->Ok |
Collaborator
Author
There was a problem hiding this comment.
This get's moved lower down the call stack so that it's run whether or not a handler is registered
DZakh
approved these changes
Nov 5, 2024
DZakh
left a comment
Member
There was a problem hiding this comment.
Nice. It even makes the code cleaner 👍
| | None => Ok() | ||
| } | ||
|
|
||
| result->Result.map(() => { |
Member
There was a problem hiding this comment.
I'd probably use if result->Result.isOk instead of Result.map. But this is really a preference which doesn't bring much benefits
Collaborator
Author
There was a problem hiding this comment.
We still need to return a mapped Ok value with the same Error if there is one.
JonoPrest
force-pushed
the
jp/save-events-with-no-handler
branch
from
November 6, 2024 08:05
7320186 to
8f9f489
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.
A quick one to close #282
This actually is a small bug for restarts in an edgecase described below, also I think it's an improvement.
Before this change, an event that doesn't have a handler registered (even if it has a contractRegister instead)
The edgecase bug this can cause is if the last event processed had only a contractRegister function. The event sync state will not increase and on a restart it would then include the event that had already been processed. There should be no crash or double processing though since it would only have a contractRegister function and this is already protected against double registrations.