Skip to content

Commit

Permalink
add underprice counters
Browse files Browse the repository at this point in the history
  • Loading branch information
nibty committed Apr 9, 2024
1 parent 2a85607 commit 33b576d
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions evmcore/tx_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ var (
underpricedTxMeter = metrics.GetOrRegisterMeter("txpool/underpriced", nil)
overflowedTxMeter = metrics.GetOrRegisterMeter("txpool/overflowed", nil)

underpriced1TxCounter = metrics.GetOrRegisterMeter("txpool/underpriced1", nil)
underpriced2TxCounter = metrics.GetOrRegisterMeter("txpool/underpriced2", nil)
underpriced3TxCounter = metrics.GetOrRegisterMeter("txpool/underpriced3", nil)

pendingGauge = metrics.GetOrRegisterGauge("txpool/pending", nil)
queuedGauge = metrics.GetOrRegisterGauge("txpool/queued", nil)
localGauge = metrics.GetOrRegisterGauge("txpool/local", nil)
Expand Down Expand Up @@ -623,14 +627,17 @@ func (pool *TxPool) validateTx(tx *types.Transaction, local bool) error {
// Drop non-local transactions under our own minimal accepted gas price or tip
local = local || pool.locals.contains(from) // account may be local even if the transaction arrived from the network
if !local && tx.GasTipCapIntCmp(pool.gasPrice) < 0 {
underpriced1TxCounter.Mark(1)
return ErrUnderpriced
}
// Ensure Opera-specific hard bounds
if recommendedGasTip, minPrice := pool.chain.EffectiveMinTip(), pool.chain.MinGasPrice(); recommendedGasTip != nil && minPrice != nil {
if tx.GasTipCapIntCmp(recommendedGasTip) < 0 {
underpriced2TxCounter.Mark(1)
return ErrUnderpriced
}
if tx.GasFeeCapIntCmp(new(big.Int).Add(recommendedGasTip, minPrice)) < 0 {
underpriced3TxCounter.Mark(1)
return ErrUnderpriced
}
}
Expand Down

0 comments on commit 33b576d

Please sign in to comment.