Skip to content

Commit

Permalink
Fix bor-heimdall stall after chaindb removal (#11863)
Browse files Browse the repository at this point in the history
In the first run, init validators was skipped due to the check. Updated
it by checking the erigon3 code to init snapshot for 1st block (this
logic is borrowed from main branch).

cherry-pick adaptation of
#11725
  • Loading branch information
manav2401 authored Sep 4, 2024
1 parent afe96b3 commit a6fd068
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion eth/stagedsync/stage_bor_heimdall.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,10 +288,15 @@ func BorHeimdallForward(
return err
}

// this will happen if for example chaindb is removed
if lastPersistedBlockNum > blockNum {
lastPersistedBlockNum = blockNum
}

// if the last time we persisted snapshots is too far away re-run the forward
// initialization process - this is to avoid memory growth due to recusrion
// in persistValidatorSets
if snap == nil && blockNum-lastPersistedBlockNum > (snapshotPersistInterval*5) {
if snap == nil && (blockNum == 1 || blockNum-lastPersistedBlockNum > (snapshotPersistInterval*5)) {
snap, err = initValidatorSets(
ctx,
tx,
Expand Down

0 comments on commit a6fd068

Please sign in to comment.