From cd3a43d3cc0e2feb3ee17e4c6cd0d75756c2dc74 Mon Sep 17 00:00:00 2001 From: Nicholas Pettas Date: Wed, 17 Apr 2024 10:56:39 -0700 Subject: [PATCH] add underprice counters (#22) --- evmcore/tx_pool.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/evmcore/tx_pool.go b/evmcore/tx_pool.go index f994fb626..b8b552f9b 100644 --- a/evmcore/tx_pool.go +++ b/evmcore/tx_pool.go @@ -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) @@ -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 } }