-
Notifications
You must be signed in to change notification settings - Fork 23
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
Fix start height edge case #426
Conversation
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.
Generally LGTM, few non-blocking comments that I am posting early.
I'll add an approval soon but want to read/think some more on the catchup mechanism before I do.
main/main.go
Outdated
zap.Error(err), | ||
// Calculate the starting block height for the relayer only if we're processing historical blocks | ||
// Otherwies, the first block we process is the next block after the current height | ||
height := currentHeight + 1 |
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.
nit, free to drop: I prefer having this in an else statement below the if cfg.ProcessMissedBlocks
instead of setting it here and overwriting it.
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, I agree the else statement would make it clearer
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 went with a slightly different approach so that we can emit the process-missed-blocks=false
log only once per source chain. Lmk if you agree.
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.
LGTM after the comments are addressed
main/main.go
Outdated
zap.Error(err), | ||
// Calculate the starting block height for the relayer only if we're processing historical blocks | ||
// Otherwies, the first block we process is the next block after the current height | ||
height := currentHeight + 1 |
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, I agree the else statement would make it clearer
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.
Minor typo but LGTM
Co-authored-by: Ian Suvak <ian.suvak@avalabs.org> Signed-off-by: cam-schultz <78878559+cam-schultz@users.noreply.github.com>
Why this should be merged
Fixes a bug when handling the edge case in which the the DB stores a height, but the catch up mechanism is disabled. In that scenario, we were initializing the checkpoint manager in such a way that it never committed to the database.
How this works
Suppose the DB stores block 100, the current height is 200, and on restart, we set
process-missed-blocks=false
. The relayer will correctly skip blocks 100-200 for processing, but will initialize the checkpoint manager with block 100. To prevent gaps, the checkpoint manager only commits blocks if they are exactly 1 greater than the max committed height. In this scenario, the next block height the checkpoint manager sees is 200, which is never committed.This fixes this by:
process-missed-blocks=false
process-missed-blocks=false
, there's a race condition between fetching of the current height and the beginning of the Listener that could cause a gap.How this was tested
CI
How is this documented
N/A