-
Notifications
You must be signed in to change notification settings - Fork 12
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
Start poller after fast sync is completed #54
Changes from 4 commits
fd2b284
f989ec1
0b67e2a
82fb6c4
b1ab7ea
16e3318
3f3464a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -116,12 +116,22 @@ func (fp *FinalityProviderInstance) Start() error { | |
zap.String("pk", fp.GetBtcPkHex()), zap.Uint64("height", startHeight)) | ||
|
||
poller := NewChainPoller(fp.logger, fp.cfg.PollerConfig, fp.cc, fp.consumerCon, fp.metrics) | ||
fp.poller = poller | ||
|
||
if err := poller.Start(startHeight); err != nil { | ||
return fmt.Errorf("failed to start the poller: %w", err) | ||
// get the last finalized height | ||
lastFinalizedBlock, err := fp.latestFinalizedBlockWithRetry() | ||
if err != nil { | ||
return err | ||
} | ||
|
||
fp.poller = poller | ||
// Start the poller if fast sync is disabled or there's no finalized block | ||
if (fp.cfg.FastSyncInterval == 0 || lastFinalizedBlock == nil) && !fp.poller.IsRunning() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we move There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If this // start poller after fast sync is finished
if !fp.poller.IsRunning() {
err := fp.poller.Start(res.LastProcessedHeight + 1)
if err != nil {
fp.logger.Error("failed to start the poller", zap.Error(err))
fp.reportCriticalErr(err)
}
continue
} There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure we should add these check because up to here the fast sync is already finished and should be safe to start the poller. Can we have a workaround in e2e? |
||
if err := fp.poller.Start(startHeight); err != nil { | ||
fp.logger.Error("failed to start the poller", zap.Error(err)) | ||
fp.reportCriticalErr(err) | ||
return err | ||
} | ||
} | ||
|
||
fp.laggingTargetChan = make(chan uint64, 1) | ||
|
||
|
@@ -275,6 +285,16 @@ func (fp *FinalityProviderInstance) finalitySigSubmissionLoop() { | |
zap.Uint64("last_processed_height", res.LastProcessedHeight), | ||
) | ||
|
||
// start poller after fast sync is finished | ||
if !fp.poller.IsRunning() { | ||
err := fp.poller.Start(res.LastProcessedHeight + 1) | ||
if err != nil { | ||
fp.logger.Error("failed to start the poller", zap.Error(err)) | ||
fp.reportCriticalErr(err) | ||
} | ||
continue | ||
} | ||
Comment on lines
+223
to
+230
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think the start of the poller should be controlled within the sig submission loop. The poller should be already started when the loop is on |
||
|
||
// inform the poller to skip to the next block of the last | ||
// processed one | ||
err := fp.poller.SkipToHeight(fp.GetLastProcessedHeight() + 1) | ||
|
@@ -399,6 +419,11 @@ func (fp *FinalityProviderInstance) checkLaggingLoop() { | |
} | ||
|
||
func (fp *FinalityProviderInstance) tryFastSync(targetBlockHeight uint64) (*FastSyncResult, error) { | ||
fp.logger.Debug( | ||
"trying fast sync", | ||
zap.String("pk", fp.GetBtcPkHex()), | ||
zap.Uint64("target_block_height", targetBlockHeight)) | ||
|
||
if fp.inSync.Load() { | ||
return nil, fmt.Errorf("the finality-provider %s is already in sync", fp.GetBtcPkHex()) | ||
} | ||
|
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.
without this,
TestOpFpNoVotingPower
will fail b/c it's trying to stop a poller that's not startedThere 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.
isn't this the same as
!cp.isStarted.Swap(false)
? It's just nil is returned instead of an errorThere 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.
yes, now
TestOpFpNoVotingPower
will start the poller, it can be removed.