Skip to content

Commit

Permalink
add underprice counters (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
nibty authored Apr 17, 2024
1 parent 8ee9a70 commit cd3a43d
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)

underpricedMinAcceptedPriceTxCounter = metrics.GetOrRegisterMeter("txpool/underpriced/minaccepted", nil)
underpricedRecommendedTipTxCounter = metrics.GetOrRegisterMeter("txpool/underpriced/recommendedtip", nil)
underpricedRecommendedTipAndMinPriceTxCounter = metrics.GetOrRegisterMeter("txpool/underpriced/recommendedtipandminprice", 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 {
underpricedMinAcceptedPriceTxCounter.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 {
underpricedRecommendedTipTxCounter.Mark(1)
return ErrUnderpriced
}
if tx.GasFeeCapIntCmp(new(big.Int).Add(recommendedGasTip, minPrice)) < 0 {
underpricedRecommendedTipAndMinPriceTxCounter.Mark(1)
return ErrUnderpriced
}
}
Expand Down

0 comments on commit cd3a43d

Please sign in to comment.