From dd3e628d805a38d3508190be1262b889738eddb4 Mon Sep 17 00:00:00 2001 From: ledgerwatch Date: Mon, 11 Sep 2023 12:17:41 +0100 Subject: [PATCH] Fix heimdall incorrect sync data bug (#8174) --- eth/stagedsync/stage_bor_heimdall.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/eth/stagedsync/stage_bor_heimdall.go b/eth/stagedsync/stage_bor_heimdall.go index 007922d57ee..135086de8b1 100644 --- a/eth/stagedsync/stage_bor_heimdall.go +++ b/eth/stagedsync/stage_bor_heimdall.go @@ -89,12 +89,6 @@ func BorHeimdallForward( if err != nil { return fmt.Errorf("getting headers progress: %w", err) } - - header, err = cfg.blockReader.HeaderByNumber(ctx, tx, headNumber) - - if err != nil { - return err - } } if s.BlockNumber == headNumber { @@ -129,6 +123,12 @@ func BorHeimdallForward( } for blockNum := lastBlockNum + 1; blockNum <= headNumber; blockNum++ { if blockNum%cfg.chainConfig.Bor.CalculateSprint(blockNum) == 0 { + if !mine { + header, err = cfg.blockReader.HeaderByNumber(ctx, tx, blockNum) + if err != nil { + return err + } + } if lastEventId, err = fetchAndWriteBorEvents(ctx, cfg.blockReader, cfg.chainConfig.Bor, header, lastEventId, cfg.chainConfig.ChainID.String(), tx, cfg.heimdallClient, cfg.stateReceiverABI, s.LogPrefix(), logger); err != nil { return err }