From 86ec9080917acc0a8cf13892b7f9f1fe6a9951f2 Mon Sep 17 00:00:00 2001 From: Jerome Date: Thu, 30 Jun 2022 23:07:09 +1000 Subject: [PATCH] add DivergingBlockNumber in forensics report (#105) --- consensus/XDPoS/engines/engine_v2/forensics.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/consensus/XDPoS/engines/engine_v2/forensics.go b/consensus/XDPoS/engines/engine_v2/forensics.go index 4f66da628c..5f674d216b 100644 --- a/consensus/XDPoS/engines/engine_v2/forensics.go +++ b/consensus/XDPoS/engines/engine_v2/forensics.go @@ -157,9 +157,17 @@ func (f *Forensics) SendForensicProof(chain consensus.ChainReader, engine *XDPoS accrossEpoches = true } + ancestorBlock := chain.GetHeaderByHash(ancestorHash) + + if ancestorBlock == nil { + log.Error("[SendForensicProof] Unable to find the ancestor block by its hash", "Hash", ancestorHash) + return fmt.Errorf("Can't find ancestor block via hash") + } + content, err := json.Marshal(&types.ForensicsContent{ - DivergingBlockHash: ancestorHash.Hex(), - AcrossEpoch: accrossEpoches, + DivergingBlockHash: ancestorHash.Hex(), + AcrossEpoch: accrossEpoches, + DivergingBlockNumber: ancestorBlock.Number.Uint64(), SmallerRoundInfo: &types.ForensicsInfo{ HashPath: ancestorToLowerRoundPath, QuorumCert: lowerRoundQC,