From be36e570c1dfd38c11e2fbec0217e6d4f6e6d0e5 Mon Sep 17 00:00:00 2001 From: Marius van der Wijden Date: Thu, 20 Aug 2020 09:49:35 +0200 Subject: [PATCH] core: more detailed metering for reorgs (#21420) --- core/blockchain.go | 8 ++++++-- core/tx_pool.go | 2 ++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/core/blockchain.go b/core/blockchain.go index 499c8eee6733..6acef13c4187 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -70,8 +70,11 @@ 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) + + blockReorgMeter = metrics.NewRegisteredMeter("chain/reorg/executes", nil) + blockReorgAddMeter = metrics.NewRegisteredMeter("chain/reorg/add", nil) + blockReorgDropMeter = metrics.NewRegisteredMeter("chain/reorg/drop", nil) + blockReorgInvalidatedTx = metrics.NewRegisteredMeter("chain/reorg/invalidTx", nil) blockPrefetchExecuteTimer = metrics.NewRegisteredTimer("chain/prefetch/executes", nil) blockPrefetchInterruptMeter = metrics.NewRegisteredMeter("chain/prefetch/interrupts", nil) @@ -2152,6 +2155,7 @@ func (bc *BlockChain) reorg(oldBlock, newBlock *types.Block) error { "drop", len(oldChain), "dropfrom", oldChain[0].Hash(), "add", len(newChain), "addfrom", newChain[0].Hash()) blockReorgAddMeter.Mark(int64(len(newChain))) blockReorgDropMeter.Mark(int64(len(oldChain))) + blockReorgMeter.Mark(1) } else { log.Error("Impossible reorg, please file an issue", "oldnum", oldBlock.Number(), "oldhash", oldBlock.Hash(), "newnum", newBlock.Number(), "newhash", newBlock.Hash()) } diff --git a/core/tx_pool.go b/core/tx_pool.go index 3100acf4d24d..0fe1d3db5b68 100644 --- a/core/tx_pool.go +++ b/core/tx_pool.go @@ -1422,6 +1422,8 @@ func (pool *TxPool) demoteUnexecutables() { pool.enqueueTx(hash, tx) } pendingGauge.Dec(int64(len(gapped))) + // This might happen in a reorg, so log it to the metering + blockReorgInvalidatedTx.Mark(int64(len(gapped))) } // Delete the entire pending entry if it became empty. if list.Empty() {