Skip to content

Commit 965ce5b

Browse files
committed
fix
1 parent 0e5ed2a commit 965ce5b

File tree

4 files changed

+28
-3
lines changed

4 files changed

+28
-3
lines changed

core/txpool/blobpool/blobpool.go

+15-2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ import (
2929
"sync"
3030
"time"
3131

32+
"github.com/holiman/billy"
33+
"github.com/holiman/uint256"
3234
"github.com/scroll-tech/go-ethereum/common"
3335
"github.com/scroll-tech/go-ethereum/consensus/misc/eip1559"
3436
"github.com/scroll-tech/go-ethereum/consensus/misc/eip4844"
@@ -42,8 +44,6 @@ import (
4244
"github.com/scroll-tech/go-ethereum/params"
4345
"github.com/scroll-tech/go-ethereum/rlp"
4446
"github.com/scroll-tech/go-ethereum/rollup/fees"
45-
"github.com/holiman/billy"
46-
"github.com/holiman/uint256"
4747
)
4848

4949
const (
@@ -1381,6 +1381,16 @@ func (p *BlobPool) drop() {
13811381
// Pending retrieves all currently processable transactions, grouped by origin
13821382
// account and sorted by nonce.
13831383
func (p *BlobPool) Pending(enforceTips bool) map[common.Address][]*txpool.LazyTransaction {
1384+
return p.pendingWithMax(enforceTips, math.MaxInt)
1385+
}
1386+
1387+
// PendingWithMax works similar to Pending but allows setting an upper limit on how many
1388+
// accounts to return
1389+
func (p *BlobPool) PendingWithMax(enforceTips bool, maxAccountsNum int) map[common.Address][]*txpool.LazyTransaction {
1390+
return p.pendingWithMax(enforceTips, maxAccountsNum)
1391+
}
1392+
1393+
func (p *BlobPool) pendingWithMax(enforceTips bool, maxAccountsNum int) map[common.Address][]*txpool.LazyTransaction {
13841394
// Track the amount of time waiting to retrieve the list of pending blob txs
13851395
// from the pool and the amount of time actually spent on assembling the data.
13861396
// The latter will be pretty much moot, but we've kept it to have symmetric
@@ -1411,6 +1421,9 @@ func (p *BlobPool) Pending(enforceTips bool) map[common.Address][]*txpool.LazyTr
14111421
if len(lazies) > 0 {
14121422
pending[addr] = lazies
14131423
}
1424+
if len(pending) >= maxAccountsNum {
1425+
break
1426+
}
14141427
}
14151428
return pending
14161429
}

core/txpool/subpool.go

+2
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@ type SubPool interface {
110110
// account and sorted by nonce.
111111
Pending(enforceTips bool) map[common.Address][]*LazyTransaction
112112

113+
PendingWithMax(enforceTips bool, maxAccountsNum int) map[common.Address][]*LazyTransaction
114+
113115
// SubscribeTransactions subscribes to new transaction events. The subscriber
114116
// can decide whether to receive notifications only for newly seen transactions
115117
// or also for reorged out ones.

core/txpool/txpool.go

+10
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,16 @@ func (p *TxPool) Pending(enforceTips bool) map[common.Address][]*LazyTransaction
318318
return txs
319319
}
320320

321+
func (p *TxPool) PendingWithMax(enforceTips bool, maxAccountsNum int) map[common.Address][]*LazyTransaction {
322+
txs := make(map[common.Address][]*LazyTransaction)
323+
for _, subpool := range p.subpools {
324+
for addr, set := range subpool.PendingWithMax(enforceTips, maxAccountsNum) {
325+
txs[addr] = set
326+
}
327+
}
328+
return txs
329+
}
330+
321331
// SubscribeTransactions registers a subscription for new transaction events,
322332
// supporting feeding only newly seen or also resurrected transactions.
323333
func (p *TxPool) SubscribeTransactions(ch chan<- core.NewTxsEvent, reorgs bool) event.Subscription {

miner/scroll_worker.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ func (w *worker) startNewPipeline(timestamp int64) {
382382

383383
tidyPendingStart := time.Now()
384384
// Fill the block with all available pending transactions.
385-
pending := w.eth.TxPool().Pending(false)
385+
pending := w.eth.TxPool().PendingWithMax(false, w.config.MaxAccountsNum)
386386
// Split the pending transactions into locals and remotes
387387
localTxs, remoteTxs := make(map[common.Address][]*txpool.LazyTransaction), pending
388388
for _, account := range w.eth.TxPool().Locals() {

0 commit comments

Comments
 (0)