-
Notifications
You must be signed in to change notification settings - Fork 534
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
[EVM-703]: Saving events in boltdb should have retry mechanism #1652
Merged
goran-ethernal
merged 11 commits into
develop
from
EVM-703-Saving-events-in-boltdb-should-have-retry-mechanism
Jul 7, 2023
Merged
[EVM-703]: Saving events in boltdb should have retry mechanism #1652
goran-ethernal
merged 11 commits into
develop
from
EVM-703-Saving-events-in-boltdb-should-have-retry-mechanism
Jul 7, 2023
Conversation
This file contains 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
goran-ethernal
force-pushed
the
EVM-703-Saving-events-in-boltdb-should-have-retry-mechanism
branch
from
June 22, 2023 10:49
136d32b
to
925da24
Compare
goran-ethernal
force-pushed
the
EVM-703-Saving-events-in-boltdb-should-have-retry-mechanism
branch
6 times, most recently
from
June 26, 2023 07:05
42a0be1
to
6a8dced
Compare
goran-ethernal
force-pushed
the
EVM-703-Saving-events-in-boltdb-should-have-retry-mechanism
branch
from
June 26, 2023 08:10
6a8dced
to
7c6d353
Compare
vcastellm
reviewed
Jul 4, 2023
vcastellm
reviewed
Jul 5, 2023
vcastellm
approved these changes
Jul 5, 2023
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.
goran-ethernal
force-pushed
the
EVM-703-Saving-events-in-boltdb-should-have-retry-mechanism
branch
from
July 5, 2023 09:35
7c6d353
to
99dce46
Compare
goran-ethernal
force-pushed
the
EVM-703-Saving-events-in-boltdb-should-have-retry-mechanism
branch
from
July 5, 2023 10:21
0121c9e
to
438276d
Compare
igorcrevar
approved these changes
Jul 6, 2023
igorcrevar
reviewed
Jul 6, 2023
goran-ethernal
deleted the
EVM-703-Saving-events-in-boltdb-should-have-retry-mechanism
branch
July 7, 2023 08:08
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Description
Through this PR we implemented retry of inserting
bridge
events (stateSync
,exit
, andtransfer
events). Since errors on inserting events inboltdb
can happen (db errors, disk errors, etc.), we needed to provide a way to get missed events (events that failed onboltdb
insert). This is crucial, since if arelayer
node fails inserting someexit
orstateSync
events, those deposits and withdrawals will never be executed.This PR implements
eventsGetter[T contractsapi.EventAbi]
struct, which gets desired events from transaction receipts by providingfrom
andto
block.eventGetter
uses Go generics so it can be used on any event from edgecore-contracts
. It uses the plugin functions to have a more generic way of setting up events validation, events parsing and saving.Exit events retry
checkpointManager
now useseventGetter[ExitEvent]
to get missed events. To know which block was last processed for exit events, a new bucket is added toCheckpointStore
, calledlastProcessedBlock
. It is a bucket with single entry in it which indicates the last block that was processed for exit events. It is saved under a fixed keylastProcessedBlockKey
.On each block finalization by
consensus
or getting the block fromsyncer
,checkpointManager
will read thelastSaved
bucket to know which block was last processed, and if it missed some blocks, it will use theeventGetter
to gather all missed exit events and save them intoboltdb
througheventGetter
plugin functions.Transfer events retry (for voting power changes)
stakeManager
(which updates the voting power of validators onchildchain
, based onTransfer
events fromValidatorSet
contract, when their stake fromroot
gets bridged tochild
), now useseventGetter[contractsapi.TransferEvent]
to get missed events.StakeManagerStore
already had a mechanism inboltdb
to know which block was last processed forTransferEvents
so we just plugged in that logic toeventGetter
. Same as incheckpointManager
, on each block finalization byconsensuis
or getting the block fromsyncer
, it will read the last processed block from itsboltdb
store, and will useeventGetter
to collect any missed blocks so that it can update the voting power of validators correctly.State sync retry
Since
stateSync
events are events gotten from transactions onrootchain
, we can not use theeventGetter
for this, since it's limited tochildchain
use only. We getstateSync
events fromevenTracker
, a third party library that syncs withrootchain
and gets the desired logs. This is used on edge from the beginning ofpolybft
consensus protocol, but it didn't propagate errors that might happen when client saves the gottenstateSync
events todb
.AddLog
function now returns an error, andeventTrackerStore
(used for storingstateSyncEvents
), will propagate the error, and syncing withrootchain
will retry, meaning that it will try to save the last log to client again.Changes include
Checklist
Testing