@@ -97,8 +97,6 @@ type blobTxMeta struct {
9797 execTipCap * uint256.Int // Needed to prioritize inclusion order across accounts and validate replacement price bump
9898 execFeeCap * uint256.Int // Needed to validate replacement price bump
9999 blobFeeCap * uint256.Int // Needed to validate replacement price bump
100- execGas uint64 // Needed to check inclusion validity before reading the blob
101- blobGas uint64 // Needed to check inclusion validity before reading the blob
102100
103101 basefeeJumps float64 // Absolute number of 1559 fee adjustments needed to reach the tx's fee cap
104102 blobfeeJumps float64 // Absolute number of 4844 fee adjustments needed to reach the tx's blob fee cap
@@ -120,8 +118,6 @@ func newBlobTxMeta(id uint64, size uint32, tx *types.Transaction) *blobTxMeta {
120118 execTipCap : uint256 .MustFromBig (tx .GasTipCap ()),
121119 execFeeCap : uint256 .MustFromBig (tx .GasFeeCap ()),
122120 blobFeeCap : uint256 .MustFromBig (tx .BlobGasFeeCap ()),
123- execGas : tx .Gas (),
124- blobGas : tx .BlobGas (),
125121 }
126122 meta .basefeeJumps = dynamicFeeJumps (meta .execFeeCap )
127123 meta .blobfeeJumps = dynamicFeeJumps (meta .blobFeeCap )
@@ -311,8 +307,8 @@ type BlobPool struct {
311307 spent map [common.Address ]* uint256.Int // Expenditure tracking for individual accounts
312308 evict * evictHeap // Heap of cheapest accounts for eviction when full
313309
314- discoverFeed event.Feed // Event feed to send out new tx events on pool discovery (reorg excluded)
315- insertFeed event.Feed // Event feed to send out new tx events on pool inclusion (reorg included)
310+ eventFeed event.Feed // Event feed to send out new tx events on pool inclusion
311+ eventScope event.SubscriptionScope // Event scope to track and mass unsubscribe on termination
316312
317313 lock sync.RWMutex // Mutex protecting the pool during reorg handling
318314}
@@ -440,6 +436,8 @@ func (p *BlobPool) Close() error {
440436 if err := p .store .Close (); err != nil {
441437 errs = append (errs , err )
442438 }
439+ p .eventScope .Close ()
440+
443441 switch {
444442 case errs == nil :
445443 return nil
@@ -760,21 +758,15 @@ func (p *BlobPool) Reset(oldHead, newHead *types.Header) {
760758 // Run the reorg between the old and new head and figure out which accounts
761759 // need to be rechecked and which transactions need to be readded
762760 if reinject , inclusions := p .reorg (oldHead , newHead ); reinject != nil {
763- var adds []* types.Transaction
764761 for addr , txs := range reinject {
765762 // Blindly push all the lost transactions back into the pool
766763 for _ , tx := range txs {
767- if err := p .reinject (addr , tx .Hash ()); err == nil {
768- adds = append (adds , tx .WithoutBlobTxSidecar ())
769- }
764+ p .reinject (addr , tx .Hash ())
770765 }
771766 // Recheck the account's pooled transactions to drop included and
772767 // invalidated one
773768 p .recheck (addr , inclusions )
774769 }
775- if len (adds ) > 0 {
776- p .insertFeed .Send (core.NewTxsEvent {Txs : adds })
777- }
778770 }
779771 // Flush out any blobs from limbo that are older than the latest finality
780772 if p .chain .Config ().IsCancun (p .head .Number , p .head .Time ) {
@@ -929,13 +921,13 @@ func (p *BlobPool) reorg(oldHead, newHead *types.Header) (map[common.Address][]*
929921// Note, the method will not initialize the eviction cache values as those will
930922// be done once for all transactions belonging to an account after all individual
931923// transactions are injected back into the pool.
932- func (p * BlobPool ) reinject (addr common.Address , txhash common.Hash ) error {
924+ func (p * BlobPool ) reinject (addr common.Address , txhash common.Hash ) {
933925 // Retrieve the associated blob from the limbo. Without the blobs, we cannot
934926 // add the transaction back into the pool as it is not mineable.
935927 tx , err := p .limbo .pull (txhash )
936928 if err != nil {
937929 log .Error ("Blobs unavailable, dropping reorged tx" , "err" , err )
938- return err
930+ return
939931 }
940932 // TODO: seems like an easy optimization here would be getting the serialized tx
941933 // from limbo instead of re-serializing it here.
@@ -944,20 +936,20 @@ func (p *BlobPool) reinject(addr common.Address, txhash common.Hash) error {
944936 blob , err := rlp .EncodeToBytes (tx )
945937 if err != nil {
946938 log .Error ("Failed to encode transaction for storage" , "hash" , tx .Hash (), "err" , err )
947- return err
939+ return
948940 }
949941 id , err := p .store .Put (blob )
950942 if err != nil {
951943 log .Error ("Failed to write transaction into storage" , "hash" , tx .Hash (), "err" , err )
952- return err
944+ return
953945 }
954946
955947 // Update the indixes and metrics
956948 meta := newBlobTxMeta (id , p .store .Size (id ), tx )
957949 if _ , ok := p .index [addr ]; ! ok {
958950 if err := p .reserve (addr , true ); err != nil {
959951 log .Warn ("Failed to reserve account for blob pool" , "tx" , tx .Hash (), "from" , addr , "err" , err )
960- return err
952+ return
961953 }
962954 p .index [addr ] = []* blobTxMeta {meta }
963955 p .spent [addr ] = meta .costCap
@@ -968,7 +960,6 @@ func (p *BlobPool) reinject(addr common.Address, txhash common.Hash) error {
968960 }
969961 p .lookup [meta .hash ] = meta .id
970962 p .stored += uint64 (meta .size )
971- return nil
972963}
973964
974965// SetGasTip implements txpool.SubPool, allowing the blob pool's gas requirements
@@ -1163,19 +1154,9 @@ func (p *BlobPool) Get(hash common.Hash) *types.Transaction {
11631154// Add inserts a set of blob transactions into the pool if they pass validation (both
11641155// consensus validity and pool restictions).
11651156func (p * BlobPool ) Add (txs []* types.Transaction , local bool , sync bool ) []error {
1166- var (
1167- adds = make ([]* types.Transaction , 0 , len (txs ))
1168- errs = make ([]error , len (txs ))
1169- )
1157+ errs := make ([]error , len (txs ))
11701158 for i , tx := range txs {
11711159 errs [i ] = p .add (tx )
1172- if errs [i ] == nil {
1173- adds = append (adds , tx .WithoutBlobTxSidecar ())
1174- }
1175- }
1176- if len (adds ) > 0 {
1177- p .discoverFeed .Send (core.NewTxsEvent {Txs : adds })
1178- p .insertFeed .Send (core.NewTxsEvent {Txs : adds })
11791160 }
11801161 return errs
11811162}
@@ -1403,8 +1384,6 @@ func (p *BlobPool) Pending(enforceTips bool) map[common.Address][]*txpool.LazyTr
14031384 Time : time .Now (), // TODO(karalabe): Maybe save these and use that?
14041385 GasFeeCap : tx .execFeeCap .ToBig (),
14051386 GasTipCap : tx .execTipCap .ToBig (),
1406- Gas : tx .execGas ,
1407- BlobGas : tx .blobGas ,
14081387 })
14091388 }
14101389 if len (lazies ) > 0 {
@@ -1489,14 +1468,10 @@ func (p *BlobPool) updateLimboMetrics() {
14891468 limboSlotusedGauge .Update (int64 (slotused ))
14901469}
14911470
1492- // SubscribeTransactions registers a subscription for new transaction events,
1493- // supporting feeding only newly seen or also resurrected transactions.
1494- func (p * BlobPool ) SubscribeTransactions (ch chan <- core.NewTxsEvent , reorgs bool ) event.Subscription {
1495- if reorgs {
1496- return p .insertFeed .Subscribe (ch )
1497- } else {
1498- return p .discoverFeed .Subscribe (ch )
1499- }
1471+ // SubscribeTransactions registers a subscription of NewTxsEvent and
1472+ // starts sending event to the given channel.
1473+ func (p * BlobPool ) SubscribeTransactions (ch chan <- core.NewTxsEvent ) event.Subscription {
1474+ return p .eventScope .Track (p .eventFeed .Subscribe (ch ))
15001475}
15011476
15021477// Nonce returns the next nonce of an account, with all transactions executable
0 commit comments