@@ -4,13 +4,11 @@ import (
44 "container/heap"
55 "context"
66 "errors"
7- mapset "github.com/deckarep/golang-set/v2"
8- "github.com/ethereum/go-ethereum/miner"
9- "github.com/ethereum/go-ethereum/rpc"
107 "math/big"
118 "sync"
129 "time"
1310
11+ mapset "github.com/deckarep/golang-set/v2"
1412 "github.com/ethereum/go-ethereum/common"
1513 "github.com/ethereum/go-ethereum/core"
1614 "github.com/ethereum/go-ethereum/core/state"
@@ -19,7 +17,9 @@ import (
1917 "github.com/ethereum/go-ethereum/event"
2018 "github.com/ethereum/go-ethereum/log"
2119 "github.com/ethereum/go-ethereum/metrics"
20+ "github.com/ethereum/go-ethereum/miner"
2221 "github.com/ethereum/go-ethereum/params"
22+ "github.com/ethereum/go-ethereum/rpc"
2323)
2424
2525const (
@@ -167,22 +167,25 @@ func (p *BundlePool) AddBundle(bundle *types.Bundle, originBundle *types.SendBun
167167 return ErrBundleTimestampTooHigh
168168 }
169169
170+ hash := bundle .Hash ()
170171 price , err := p .simulator .SimulateBundle (bundle )
171172 if err != nil {
173+ log .Warn ("Bundle simulation failed" , "hash" , hash , "err" , err )
172174 return err
173175 }
174176 bundle .Price = price
175177
176178 p .mu .Lock ()
177179 defer p .mu .Unlock ()
178180
179- hash := bundle .Hash ()
180181 if _ , ok := p .bundles [hash ]; ok {
182+ log .Debug ("Bundle already exists in pool" , "hash" , hash )
181183 return ErrBundleAlreadyExist
182184 }
183185
184186 if p .slots + numSlots (bundle ) > p .config .GlobalSlots {
185187 if ! p .drop (bundle ) {
188+ log .Warn ("Bundle rejected, gas price too low to replace existing" , "hash" , hash , "price" , price )
186189 return ErrBundleGasPriceLow
187190 }
188191 }
@@ -205,13 +208,15 @@ func (p *BundlePool) AddBundle(bundle *types.Bundle, originBundle *types.SendBun
205208 heap .Push (& p .bundleHeap , bundle )
206209 p .slots += numSlots (bundle )
207210
211+ log .Info ("Bundle added to pool" , "hash" , hash , "price" , price , "txCount" , len (bundle .Txs ), "poolSize" , len (p .bundles ), "slots" , p .slots )
212+
208213 bundleGauge .Update (int64 (len (p .bundles )))
209214 slotsGauge .Update (int64 (p .slots ))
210215 return nil
211216}
212217
213218func (p * BundlePool ) GetBundle (hash common.Hash ) * types.Bundle {
214- p .mu .RUnlock ()
219+ p .mu .RLock ()
215220 defer p .mu .RUnlock ()
216221
217222 return p .bundles [hash ]
@@ -220,6 +225,7 @@ func (p *BundlePool) GetBundle(hash common.Hash) *types.Bundle {
220225func (p * BundlePool ) PruneBundle (hash common.Hash ) {
221226 p .mu .Lock ()
222227 defer p .mu .Unlock ()
228+ log .Debug ("Bundle pruned externally" , "hash" , hash )
223229 p .deleteBundle (hash )
224230}
225231
@@ -232,6 +238,7 @@ func (p *BundlePool) PendingBundles(blockNumber uint64, blockTimestamp uint64) [
232238 // Prune outdated bundles
233239 if (bundle .MaxTimestamp != 0 && blockTimestamp > bundle .MaxTimestamp ) ||
234240 (bundle .MaxBlockNumber != 0 && blockNumber > bundle .MaxBlockNumber ) {
241+ log .Debug ("Bundle expired in PendingBundles" , "hash" , hash , "maxTimestamp" , bundle .MaxTimestamp , "blockTimestamp" , blockTimestamp , "maxBlockNumber" , bundle .MaxBlockNumber , "blockNumber" , blockNumber )
235242 p .deleteBundle (hash )
236243 continue
237244 }
@@ -373,9 +380,11 @@ func (p *BundlePool) reset(newHead *types.Header) {
373380 for hash , bundle := range p .bundles {
374381 if (bundle .MaxTimestamp != 0 && newHead .Time > bundle .MaxTimestamp ) ||
375382 (bundle .MaxBlockNumber != 0 && newHead .Number .Cmp (new (big.Int ).SetUint64 (bundle .MaxBlockNumber )) > 0 ) {
383+ log .Debug ("Bundle pruned on reset (expired)" , "hash" , hash , "headNumber" , newHead .Number , "headTime" , newHead .Time , "maxBlockNumber" , bundle .MaxBlockNumber , "maxTimestamp" , bundle .MaxTimestamp )
376384 p .slots -= numSlots (p .bundles [hash ])
377385 delete (p .bundles , hash )
378386 } else if txSet .Contains (bundle .Txs [0 ].Hash ()) {
387+ log .Debug ("Bundle pruned on reset (tx already included)" , "hash" , hash , "headNumber" , newHead .Number , "firstTx" , bundle .Txs [0 ].Hash ())
379388 p .slots -= numSlots (p .bundles [hash ])
380389 delete (p .bundles , hash )
381390 }
@@ -402,6 +411,7 @@ func (p *BundlePool) drop(bundle *types.Bundle) bool {
402411 for len (p .bundleHeap ) > 0 {
403412 if dropSlots >= numSlots (bundle ) {
404413 for _ , dropBundle := range dropBundles {
414+ log .Info ("Bundle dropped due to slot limit" , "hash" , dropBundle .Hash (), "price" , dropBundle .Price )
405415 p .deleteBundle (dropBundle .Hash ())
406416 }
407417 return true
@@ -438,7 +448,7 @@ func (p *BundlePool) minimalBundleGasPrice() *big.Int {
438448 return new (big.Int )
439449}
440450
441- func (p * BundlePool ) SetMaxGas ( maxGas uint64 ) {}
451+ func (p * BundlePool ) SetMaxTxGas ( maxTxGas uint64 ) {}
442452
443453// =====================================================================================================================
444454
0 commit comments