From d17905651233846f5438cff8cd3dbaa45f385e5c Mon Sep 17 00:00:00 2001 From: GalaIO Date: Mon, 25 Sep 2023 20:11:52 +0800 Subject: [PATCH] logs: add some logs to trace block miner, justified reorg; (#1894) --- core/blockchain_insert.go | 2 +- core/forkchoice.go | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/core/blockchain_insert.go b/core/blockchain_insert.go index 3e913cb87..ffe2d6501 100644 --- a/core/blockchain_insert.go +++ b/core/blockchain_insert.go @@ -56,7 +56,7 @@ func (st *insertStats) report(chain []*types.Block, index int, dirty common.Stor // Assemble the log context and send it to the logger context := []interface{}{ - "number", end.Number(), "hash", end.Hash(), + "number", end.Number(), "hash", end.Hash(), "miner", end.Coinbase(), "blocks", st.processed, "txs", txs, "mgas", float64(st.usedGas) / 1000000, "elapsed", common.PrettyDuration(elapsed), "mgasps", float64(st.usedGas) * 1000 / float64(elapsed), } diff --git a/core/forkchoice.go b/core/forkchoice.go index d2e939fad..c42ed24d6 100644 --- a/core/forkchoice.go +++ b/core/forkchoice.go @@ -137,5 +137,9 @@ func (f *ForkChoice) ReorgNeededWithFastFinality(current *types.Header, header * return f.ReorgNeeded(current, header) } + if justifiedNumber > curJustifiedNumber && header.Number.Cmp(current.Number) <= 0 { + log.Info("Chain find higher justifiedNumber", "fromHeight", current.Number, "fromHash", current.Hash(), "fromMiner", current.Coinbase, "fromJustified", curJustifiedNumber, + "toHeight", header.Number, "toHash", header.Hash(), "toMiner", header.Coinbase, "toJustified", justifiedNumber) + } return justifiedNumber > curJustifiedNumber, nil }