Skip to content
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

allow to gracefully exit from CL downloading stage (#10887) #11020

Merged
merged 1 commit into from
Jul 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions cl/clstages/clstages.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,12 @@ func (s *StageGraph[CONFIG, ARGUMENTS]) StartWithStage(ctx context.Context, star
errch := make(chan error)
start := time.Now()
go func() {
sctx, cn := context.WithCancel(ctx)
defer cn()
// we run this is a goroutine so that the process can exit in the middle of a stage
// since caplin is designed to always be able to recover regardless of db state, this should be safe
select {
case errch <- currentStage.ActionFunc(sctx, lg, cfg, args):
case <-sctx.Done():
errch <- sctx.Err()
case errch <- currentStage.ActionFunc(ctx, lg, cfg, args):
case <-ctx.Done(): // we are not sure if actionFunc exits on ctx
errch <- ctx.Err()
}
}()
err := <-errch
Expand Down
2 changes: 1 addition & 1 deletion cl/phase1/stages/clstages.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ func ConsensusClStages(ctx context.Context,
}
// This stage is special so use context.Background() TODO(Giulio2002): make the context be passed in
startingSlot := cfg.state.LatestBlockHeader().Slot
downloader := network2.NewBackwardBeaconDownloader(context.Background(), cfg.rpc, cfg.executionClient, cfg.indiciesDB)
downloader := network2.NewBackwardBeaconDownloader(ctx, cfg.rpc, cfg.executionClient, cfg.indiciesDB)

if err := SpawnStageHistoryDownload(StageHistoryReconstruction(downloader, cfg.antiquary, cfg.sn, cfg.indiciesDB, cfg.executionClient, cfg.beaconCfg, cfg.backfilling, cfg.blobBackfilling, false, startingRoot, startingSlot, cfg.tmpdir, 600*time.Millisecond, cfg.blockCollector, cfg.blockReader, cfg.blobStore, logger), context.Background(), logger); err != nil {
cfg.hasDownloaded = false
Expand Down
Loading