|
|
|
@ -26,6 +26,7 @@ import ( |
|
|
|
|
|
|
|
|
|
"github.com/ethereum/go-ethereum/common" |
|
|
|
|
"github.com/ethereum/go-ethereum/common/prque" |
|
|
|
|
"github.com/ethereum/go-ethereum/consensus/misc" |
|
|
|
|
"github.com/ethereum/go-ethereum/core/state" |
|
|
|
|
"github.com/ethereum/go-ethereum/core/types" |
|
|
|
|
"github.com/ethereum/go-ethereum/event" |
|
|
|
@ -496,13 +497,30 @@ func (pool *TxPool) Content() (map[common.Address]types.Transactions, map[common |
|
|
|
|
// Pending retrieves all currently processable transactions, grouped by origin
|
|
|
|
|
// account and sorted by nonce. The returned transaction set is a copy and can be
|
|
|
|
|
// freely modified by calling code.
|
|
|
|
|
func (pool *TxPool) Pending() (map[common.Address]types.Transactions, error) { |
|
|
|
|
//
|
|
|
|
|
// The enforceTips parameter can be used to do an extra filtering on the pending
|
|
|
|
|
// transactions and only return those whose **effective** tip is large enough in
|
|
|
|
|
// the next pending execution environment.
|
|
|
|
|
func (pool *TxPool) Pending(enforceTips bool) (map[common.Address]types.Transactions, error) { |
|
|
|
|
pool.mu.Lock() |
|
|
|
|
defer pool.mu.Unlock() |
|
|
|
|
|
|
|
|
|
pending := make(map[common.Address]types.Transactions) |
|
|
|
|
for addr, list := range pool.pending { |
|
|
|
|
pending[addr] = list.Flatten() |
|
|
|
|
txs := list.Flatten() |
|
|
|
|
|
|
|
|
|
// If the miner requests tip enforcement, cap the lists now
|
|
|
|
|
if enforceTips && !pool.locals.contains(addr) { |
|
|
|
|
for i, tx := range txs { |
|
|
|
|
if tx.EffectiveTipIntCmp(pool.gasPrice, pool.priced.urgent.baseFee) < 0 { |
|
|
|
|
txs = txs[:i] |
|
|
|
|
break |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if len(txs) > 0 { |
|
|
|
|
pending[addr] = txs |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return pending, nil |
|
|
|
|
} |
|
|
|
@ -562,7 +580,7 @@ func (pool *TxPool) validateTx(tx *types.Transaction, local bool) error { |
|
|
|
|
if tx.Tip().BitLen() > 256 { |
|
|
|
|
return ErrTipVeryHigh |
|
|
|
|
} |
|
|
|
|
// Ensure feeCap is less than or equal to tip.
|
|
|
|
|
// Ensure feeCap is greater than or equal to tip.
|
|
|
|
|
if tx.FeeCapIntCmp(tx.Tip()) < 0 { |
|
|
|
|
return ErrTipAboveFeeCap |
|
|
|
|
} |
|
|
|
@ -1114,8 +1132,9 @@ func (pool *TxPool) runReorg(done chan struct{}, reset *txpoolResetRequest, dirt |
|
|
|
|
// because of another transaction (e.g. higher gas price).
|
|
|
|
|
if reset != nil { |
|
|
|
|
pool.demoteUnexecutables() |
|
|
|
|
if reset.newHead != nil { |
|
|
|
|
pool.priced.SetBaseFee(reset.newHead.BaseFee) |
|
|
|
|
if reset.newHead != nil && pool.chainconfig.IsLondon(new(big.Int).Add(reset.newHead.Number, big.NewInt(1))) { |
|
|
|
|
pendingBaseFee := misc.CalcBaseFee(pool.chainconfig, reset.newHead) |
|
|
|
|
pool.priced.SetBaseFee(pendingBaseFee) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
// Ensure pool.queue and pool.pending sizes stay within the configured limits.
|
|
|
|
|