-
Notifications
You must be signed in to change notification settings - Fork 4
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
396: Don't skip any blocks if the head of the chain advances by more than one block. #397
Conversation
… more than one block.
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!
defaultStatediffMetrics.lastEventHeight.Update(int64(nextHeight)) | ||
} | ||
} else { | ||
log.Warn("WriteLoop: received unexpected block from the past", "block height", nextHeight, "last height", lastHeight) |
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.
Will be interesting to see if/how often this occurs.
@@ -438,6 +471,8 @@ func (sds *Service) Loop(chainEventCh chan core.ChainEvent) { | |||
select { | |||
//Notify chain event channel of events | |||
case chainEvent := <-chainEventCh: | |||
// TODO: Do we need to track the last streamed block as we do for the WriteLoop so that we can detect |
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.
For correctness we should, but nothing currently uses the streaming functionality (and won't in the foreseeable future) so we don't need to. We should consider removing the statediff streaming during the pluggeth port @roysc.
Port of cerc-io/go-ethereum#399 and cerc-io/go-ethereum#397. Co-authored-by: Thomas E Lackey <telackey@bozemanpass.com> Reviewed-on: https://git.vdb.to/cerc-io/plugeth-statediff/pulls/8
As #396 shows, we can get scenarios when the chain advances by more than a single block, but the event which is seen by the WriteLoop will only be for the new head block--however many blocks in advance it is--allowing gaps to open in the statediffing.
This code will detect and trigger statediffing for the skipped blocks. The functionality is similar to the previous "head gap" filling code. Similar enough that we are able to remove that code and allow this to cover both cases.