-
Notifications
You must be signed in to change notification settings - Fork 93
improve(relayer): Catch identifiable re-org events by blockHash #2447
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
In order to make a subsequent refactoring diff smaller.
There's no need to filter based on the complete set of unique attributes - in practice it's more desirable to cast the net wide and discard anything matching the re-orged blockHash.
| } | ||
| let removedEventIdx: number; | ||
| do { | ||
| removedEventIdx = pendingEvents.findIndex(({ blockHash }) => blockHash === event.blockHash); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this require the event which was reorged to be reincluded in this block? What if the event was removed by a reorg and not mined again yet?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah; these dropped events are currently reported per-event over the event subscription. Per current implementation we require one notification per event, per blockHash. The change implemented here is to permit a single removed event notification to drop all stored events for a given blockHash, so we basically cast the net a little wider, which is beneficial in case one of the removed event notifications doesn't materialise (for whatever reason).
There's a follow-on change required which will actually track block hashes and reconcile when a re-org happens by finding a common ancestor and invalidating everything inbetween. That's still pending.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. Makes sense.
There's no need to filter based on the complete set of unique attributes -
in practice it's more desirable to cast the net wide and discard anything
matching the re-orged blockHash.
nb. This change only discards events by blockHash before they've been
read into SpokePoolClient state by
SpokePoolClient.update(). At thatpoint the blockHash is discarded so it's no longer possible to identify
the event by its blockHash; this needs a separate solution.