Skip to content

Commit 0d2d149

Browse files
committed
core/txpool: set 128 blocks as the fallback value for old blob eviction
1 parent 4cc9b43 commit 0d2d149

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

core/txpool/blobpool/blobpool.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -840,9 +840,7 @@ func (p *BlobPool) Reset(oldHead, newHead *types.Header) {
840840
}
841841
// Flush out any blobs from limbo that are older than the latest finality
842842
if p.chain.Config().IsCancun(p.head.Number, p.head.Time) {
843-
if h := p.chain.CurrentFinalBlock(); h != nil {
844-
p.limbo.finalize(h)
845-
}
843+
p.limbo.finalize(p.chain.CurrentFinalBlock(), newHead)
846844
}
847845
// Reset the price heap for the new set of basefee/blobfee pairs
848846
var (

core/txpool/blobpool/limbo.go

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -112,15 +112,25 @@ func (l *limbo) parseBlob(id uint64, data []byte) error {
112112
}
113113

114114
// finalize evicts all blobs belonging to a recently finalized block or older.
115-
func (l *limbo) finalize(final *types.Header) {
115+
func (l *limbo) finalize(final *types.Header, current *types.Header) {
116116
// Just in case there's no final block yet (network not yet merged, weird
117-
// restart, sethead, etc), fail gracefully.
118-
if final == nil {
119-
log.Error("Nil finalized block cannot evict old blobs")
120-
return
117+
// restart, sethead, etc), take 128 blocks ago as fallback.
118+
// TODO: Remove this fallback once there is a stable source of finality.
119+
// 128 is an impossible reorg depth, for about 10 mins under 5s block time.
120+
last := uint64(0)
121+
if final != nil {
122+
last = final.Number.Uint64()
123+
} else {
124+
if current == nil {
125+
log.Error("Nil finalized and current block cannot evict old blobs")
126+
return
127+
}
128+
if current.Number.Uint64() > 128 {
129+
last = current.Number.Uint64() - 128
130+
}
121131
}
122132
for block, ids := range l.groups {
123-
if block > final.Number.Uint64() {
133+
if block > last {
124134
continue
125135
}
126136
for id, owner := range ids {

0 commit comments

Comments
 (0)