set gasTip's type as normal value

This commit is contained in:
Danial 2025-05-31 20:54:40 +08:00
parent 2a1784baef
commit d74e870c8b
2 changed files with 8 additions and 11 deletions

View file

@ -229,7 +229,7 @@ type LegacyPool struct {
config Config config Config
chainconfig *params.ChainConfig chainconfig *params.ChainConfig
chain BlockChain chain BlockChain
gasTip atomic.Pointer[uint256.Int] gasTip *uint256.Int
txFeed event.Feed txFeed event.Feed
signer types.Signer signer types.Signer
mu sync.RWMutex mu sync.RWMutex
@ -307,7 +307,7 @@ func (pool *LegacyPool) Init(gasTip uint64, head *types.Header, reserver txpool.
pool.reserver = reserver pool.reserver = reserver
// Set the basic pool parameters // Set the basic pool parameters
pool.gasTip.Store(uint256.NewInt(gasTip)) pool.gasTip = uint256.NewInt(gasTip)
// Initialize the state with head block, or fallback to empty one in // Initialize the state with head block, or fallback to empty one in
// case the head state is not available (might occur when node is not // case the head state is not available (might occur when node is not
@ -418,13 +418,10 @@ func (pool *LegacyPool) SetGasTip(tip *big.Int) {
pool.mu.Lock() pool.mu.Lock()
defer pool.mu.Unlock() defer pool.mu.Unlock()
var ( old := pool.gasTip
newTip = uint256.MustFromBig(tip) pool.gasTip = uint256.MustFromBig(tip)
old = pool.gasTip.Load()
)
pool.gasTip.Store(newTip)
// If the min miner fee increased, remove transactions below the new threshold // If the min miner fee increased, remove transactions below the new threshold
if newTip.Cmp(old) > 0 { if pool.gasTip.Cmp(old) > 0 {
// pool.priced is sorted by GasFeeCap, so we have to iterate through pool.all instead // pool.priced is sorted by GasFeeCap, so we have to iterate through pool.all instead
drop := pool.all.TxsBelowTip(tip) drop := pool.all.TxsBelowTip(tip)
for _, tx := range drop { for _, tx := range drop {
@ -432,7 +429,7 @@ func (pool *LegacyPool) SetGasTip(tip *big.Int) {
} }
pool.priced.Removed(len(drop)) pool.priced.Removed(len(drop))
} }
log.Info("Legacy pool tip threshold updated", "tip", newTip) log.Info("Legacy pool tip threshold updated", "tip", tip)
} }
// Nonce returns the next nonce of an account, with all transactions executable // Nonce returns the next nonce of an account, with all transactions executable
@ -572,7 +569,7 @@ func (pool *LegacyPool) ValidateTxBasics(tx *types.Transaction) error {
1<<types.DynamicFeeTxType | 1<<types.DynamicFeeTxType |
1<<types.SetCodeTxType, 1<<types.SetCodeTxType,
MaxSize: txMaxSize, MaxSize: txMaxSize,
MinTip: pool.gasTip.Load().ToBig(), MinTip: pool.gasTip.ToBig(),
} }
return txpool.ValidateTransaction(tx, pool.currentHead.Load(), pool.signer, opts) return txpool.ValidateTransaction(tx, pool.currentHead.Load(), pool.signer, opts)
} }

View file

@ -434,7 +434,7 @@ func TestInvalidTransactions(t *testing.T) {
} }
tx = transaction(1, 100000, key) tx = transaction(1, 100000, key)
pool.gasTip.Store(uint256.NewInt(1000)) pool.gasTip = uint256.NewInt(1000)
if err, want := pool.addRemote(tx), txpool.ErrTxGasPriceTooLow; !errors.Is(err, want) { if err, want := pool.addRemote(tx), txpool.ErrTxGasPriceTooLow; !errors.Is(err, want) {
t.Errorf("want %v have %v", want, err) t.Errorf("want %v have %v", want, err)
} }