Skip to content

Commit eb7db79

Browse files
VBulikovawskii
andauthored
allow to gracefully exit from CL downloading stage (#10887) (#11020)
Duplicating #10887 Co-authored-by: awskii <[email protected]>
1 parent 1a050db commit eb7db79

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

cl/clstages/clstages.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,12 @@ func (s *StageGraph[CONFIG, ARGUMENTS]) StartWithStage(ctx context.Context, star
3232
errch := make(chan error)
3333
start := time.Now()
3434
go func() {
35-
sctx, cn := context.WithCancel(ctx)
36-
defer cn()
3735
// we run this is a goroutine so that the process can exit in the middle of a stage
3836
// since caplin is designed to always be able to recover regardless of db state, this should be safe
3937
select {
40-
case errch <- currentStage.ActionFunc(sctx, lg, cfg, args):
41-
case <-sctx.Done():
42-
errch <- sctx.Err()
38+
case errch <- currentStage.ActionFunc(ctx, lg, cfg, args):
39+
case <-ctx.Done(): // we are not sure if actionFunc exits on ctx
40+
errch <- ctx.Err()
4341
}
4442
}()
4543
err := <-errch

cl/phase1/stages/clstages.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ func ConsensusClStages(ctx context.Context,
252252
}
253253
// This stage is special so use context.Background() TODO(Giulio2002): make the context be passed in
254254
startingSlot := cfg.state.LatestBlockHeader().Slot
255-
downloader := network2.NewBackwardBeaconDownloader(context.Background(), cfg.rpc, cfg.executionClient, cfg.indiciesDB)
255+
downloader := network2.NewBackwardBeaconDownloader(ctx, cfg.rpc, cfg.executionClient, cfg.indiciesDB)
256256

257257
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 {
258258
cfg.hasDownloaded = false

0 commit comments

Comments
 (0)