From c7cb63dd09ff61c2617e13569b893ee5f8204427 Mon Sep 17 00:00:00 2001 From: Banana-J Date: Sat, 9 Mar 2024 16:25:47 +1100 Subject: [PATCH] fix: error handling on x.getEpochSwitchInfo in sendTimeout should return error (#444) Co-authored-by: wjrjerome --- consensus/XDPoS/engines/engine_v2/timeout.go | 1 + 1 file changed, 1 insertion(+) diff --git a/consensus/XDPoS/engines/engine_v2/timeout.go b/consensus/XDPoS/engines/engine_v2/timeout.go index 4331ba3ecd..d53ed386ee 100644 --- a/consensus/XDPoS/engines/engine_v2/timeout.go +++ b/consensus/XDPoS/engines/engine_v2/timeout.go @@ -199,6 +199,7 @@ func (x *XDPoS_v2) sendTimeout(chain consensus.ChainReader) error { epochSwitchInfo, err := x.getEpochSwitchInfo(chain, currentBlockHeader, currentBlockHeader.Hash()) if err != nil { log.Error("[sendTimeout] Error when trying to get current epoch switch info for a non-epoch block", "currentRound", x.currentRound, "currentBlockNum", currentBlockHeader.Number, "currentBlockHash", currentBlockHeader.Hash(), "epochNum", epochNum) + return err } gapNumber = epochSwitchInfo.EpochSwitchBlockInfo.Number.Uint64() - epochSwitchInfo.EpochSwitchBlockInfo.Number.Uint64()%x.config.Epoch - x.config.Gap log.Debug("[sendTimeout] non-epoch-switch block found its epoch block and calculated the gapNumber", "epochSwitchInfo.EpochSwitchBlockInfo.Number", epochSwitchInfo.EpochSwitchBlockInfo.Number.Uint64(), "gapNumber", gapNumber)