From 03e67e885fcd7ca7e83dc76ad8822ce85b343ad8 Mon Sep 17 00:00:00 2001 From: wjrjerome Date: Sun, 25 Feb 2024 17:04:43 +1100 Subject: [PATCH] fix: error handling on x.getEpochSwitchInfo in sendTimeout should return error --- 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 d03f2d656a16..19d5d3f3dd46 100644 --- a/consensus/XDPoS/engines/engine_v2/timeout.go +++ b/consensus/XDPoS/engines/engine_v2/timeout.go @@ -193,6 +193,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)