diff options
author | HackyMiner <hackyminer@gmail.com> | 2019-08-22 17:28:23 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2019-08-22 17:28:23 +0800 |
commit | 7c229941ac332557bf148918a3a1cff98354e2df (patch) | |
tree | 758beb4c451cc6129424e804ffab02d42a88028f | |
parent | ac23073619252e05f2b2f801370ae7d6b1b38023 (diff) | |
download | go-tangerine-7c229941ac332557bf148918a3a1cff98354e2df.tar go-tangerine-7c229941ac332557bf148918a3a1cff98354e2df.tar.gz go-tangerine-7c229941ac332557bf148918a3a1cff98354e2df.tar.bz2 go-tangerine-7c229941ac332557bf148918a3a1cff98354e2df.tar.lz go-tangerine-7c229941ac332557bf148918a3a1cff98354e2df.tar.xz go-tangerine-7c229941ac332557bf148918a3a1cff98354e2df.tar.zst go-tangerine-7c229941ac332557bf148918a3a1cff98354e2df.zip |
core: log chain reorg/split metrics (#18950)
* core: log chain reorg/split metrics
* core: report 1-block reorgs on the metrics too
-rw-r--r-- | core/blockchain.go | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/core/blockchain.go b/core/blockchain.go index 2fd373c7c..833de3bc7 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -64,6 +64,8 @@ var ( blockValidationTimer = metrics.NewRegisteredTimer("chain/validation", nil) blockExecutionTimer = metrics.NewRegisteredTimer("chain/execution", nil) blockWriteTimer = metrics.NewRegisteredTimer("chain/write", nil) + blockReorgAddMeter = metrics.NewRegisteredMeter("chain/reorg/drop", nil) + blockReorgDropMeter = metrics.NewRegisteredMeter("chain/reorg/add", nil) blockPrefetchExecuteTimer = metrics.NewRegisteredTimer("chain/prefetch/executes", nil) blockPrefetchInterruptMeter = metrics.NewRegisteredMeter("chain/prefetch/interrupts", nil) @@ -1933,12 +1935,16 @@ func (bc *BlockChain) reorg(oldBlock, newBlock *types.Block) error { } // Ensure the user sees large reorgs if len(oldChain) > 0 && len(newChain) > 0 { - logFn := log.Debug + logFn := log.Info + msg := "Chain reorg detected" if len(oldChain) > 63 { + msg = "Large chain reorg detected" logFn = log.Warn } - logFn("Chain split detected", "number", commonBlock.Number(), "hash", commonBlock.Hash(), + logFn(msg, "number", commonBlock.Number(), "hash", commonBlock.Hash(), "drop", len(oldChain), "dropfrom", oldChain[0].Hash(), "add", len(newChain), "addfrom", newChain[0].Hash()) + blockReorgAddMeter.Mark(int64(len(newChain))) + blockReorgDropMeter.Mark(int64(len(oldChain))) } else { log.Error("Impossible reorg, please file an issue", "oldnum", oldBlock.Number(), "oldhash", oldBlock.Hash(), "newnum", newBlock.Number(), "newhash", newBlock.Hash()) } |