mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-20 13:44:31 +00:00
core: more detailed metering for reorgs (#21420)
This commit is contained in:
parent
28baf9f1fd
commit
6935687790
2 changed files with 10 additions and 0 deletions
|
|
@ -58,6 +58,11 @@ var (
|
|||
blockInsertTimer = metrics.NewRegisteredTimer("chain/inserts", nil)
|
||||
CheckpointCh = make(chan int)
|
||||
ErrNoGenesis = errors.New("Genesis not found in chain")
|
||||
|
||||
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)
|
||||
)
|
||||
|
||||
const (
|
||||
|
|
@ -2245,6 +2250,9 @@ func (bc *BlockChain) reorg(oldBlock, newBlock *types.Block) error {
|
|||
}
|
||||
logFn("Chain split detected", "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)))
|
||||
blockReorgMeter.Mark(1)
|
||||
} else {
|
||||
log.Error("Impossible reorg, please file an issue", "oldnum", oldBlock.Number(), "oldhash", oldBlock.Hash(), "newnum", newBlock.Number(), "newhash", newBlock.Hash())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1581,6 +1581,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() {
|
||||
|
|
|
|||
Loading…
Reference in a new issue