@@ -26,6 +26,7 @@ import (
26
26
27
27
"github.com/ethereum/go-ethereum/common"
28
28
"github.com/ethereum/go-ethereum/common/prque"
29
+ "github.com/ethereum/go-ethereum/consensus/misc"
29
30
"github.com/ethereum/go-ethereum/core/state"
30
31
"github.com/ethereum/go-ethereum/core/types"
31
32
"github.com/ethereum/go-ethereum/event"
@@ -496,13 +497,30 @@ func (pool *TxPool) Content() (map[common.Address]types.Transactions, map[common
496
497
// Pending retrieves all currently processable transactions, grouped by origin
497
498
// account and sorted by nonce. The returned transaction set is a copy and can be
498
499
// freely modified by calling code.
499
- func (pool * TxPool ) Pending () (map [common.Address ]types.Transactions , error ) {
500
+ //
501
+ // The enforceTips parameter can be used to do an extra filtering on the pending
502
+ // transactions and only return those whose **effective** tip is large enough in
503
+ // the next pending execution environment.
504
+ func (pool * TxPool ) Pending (enforceTips bool ) (map [common.Address ]types.Transactions , error ) {
500
505
pool .mu .Lock ()
501
506
defer pool .mu .Unlock ()
502
507
503
508
pending := make (map [common.Address ]types.Transactions )
504
509
for addr , list := range pool .pending {
505
- pending [addr ] = list .Flatten ()
510
+ txs := list .Flatten ()
511
+
512
+ // If the miner requests tip enforcement, cap the lists now
513
+ if enforceTips && ! pool .locals .contains (addr ) {
514
+ for i , tx := range txs {
515
+ if tx .EffectiveTipIntCmp (pool .gasPrice , pool .priced .urgent .baseFee ) < 0 {
516
+ txs = txs [:i ]
517
+ break
518
+ }
519
+ }
520
+ }
521
+ if len (txs ) > 0 {
522
+ pending [addr ] = txs
523
+ }
506
524
}
507
525
return pending , nil
508
526
}
@@ -562,7 +580,7 @@ func (pool *TxPool) validateTx(tx *types.Transaction, local bool) error {
562
580
if tx .Tip ().BitLen () > 256 {
563
581
return ErrTipVeryHigh
564
582
}
565
- // Ensure feeCap is less than or equal to tip.
583
+ // Ensure feeCap is greater than or equal to tip.
566
584
if tx .FeeCapIntCmp (tx .Tip ()) < 0 {
567
585
return ErrTipAboveFeeCap
568
586
}
@@ -1114,8 +1132,9 @@ func (pool *TxPool) runReorg(done chan struct{}, reset *txpoolResetRequest, dirt
1114
1132
// because of another transaction (e.g. higher gas price).
1115
1133
if reset != nil {
1116
1134
pool .demoteUnexecutables ()
1117
- if reset .newHead != nil {
1118
- pool .priced .SetBaseFee (reset .newHead .BaseFee )
1135
+ if reset .newHead != nil && pool .chainconfig .IsLondon (new (big.Int ).Add (reset .newHead .Number , big .NewInt (1 ))) {
1136
+ pendingBaseFee := misc .CalcBaseFee (pool .chainconfig , reset .newHead )
1137
+ pool .priced .SetBaseFee (pendingBaseFee )
1119
1138
}
1120
1139
}
1121
1140
// Ensure pool.queue and pool.pending sizes stay within the configured limits.
0 commit comments