core/txpool/blobpool: fix convertTxs to record ids instead of txs

This commit is contained in:
healthykim 2026-05-12 12:29:01 +02:00
parent 9c376a4055
commit 723e7304b8

View file

@ -570,19 +570,16 @@ func (p *BlobPool) Init(gasTip uint64, head *types.Header, reserver txpool.Reser
} }
// Index all transactions on disk and delete anything unprocessable // Index all transactions on disk and delete anything unprocessable
var ( var (
fails []uint64 toDelete []uint64
convertTxs []*types.Transaction convertTxs []uint64
) )
index := func(id uint64, size uint32, blob []byte) { index := func(id uint64, size uint32, blob []byte) {
legacy, err := p.parseTransaction(id, size, blob) legacy, err := p.parseTransaction(id, size, blob)
if err != nil { if err != nil {
fails = append(fails, id) toDelete = append(toDelete, id)
} else if legacy { } else if legacy {
fails = append(fails, id) toDelete = append(toDelete, id)
tx := new(types.Transaction) convertTxs = append(convertTxs, id)
if err := rlp.DecodeBytes(blob, tx); err == nil {
convertTxs = append(convertTxs, tx)
}
} }
} }
store, err := billy.Open(billy.Options{Path: queuedir, Repair: true}, slotter, index) store, err := billy.Open(billy.Options{Path: queuedir, Repair: true}, slotter, index)
@ -593,11 +590,20 @@ func (p *BlobPool) Init(gasTip uint64, head *types.Header, reserver txpool.Reser
// Migrate legacy transactions (types.Transaction) to pooledBlobTx format. // Migrate legacy transactions (types.Transaction) to pooledBlobTx format.
if len(convertTxs) > 0 { if len(convertTxs) > 0 {
for _, tx := range convertTxs { for _, id := range convertTxs {
var tx types.Transaction
data, err := p.store.Get(id)
if err != nil {
continue
}
err = rlp.DecodeBytes(data, &tx)
if err != nil {
continue
}
if tx.BlobTxSidecar() == nil { if tx.BlobTxSidecar() == nil {
continue continue
} }
ptx := newBlobTxForPool(tx) ptx := newBlobTxForPool(&tx)
blob, err := rlp.EncodeToBytes(ptx) blob, err := rlp.EncodeToBytes(ptx)
if err != nil { if err != nil {
continue continue
@ -609,24 +615,24 @@ func (p *BlobPool) Init(gasTip uint64, head *types.Header, reserver txpool.Reser
meta := newBlobTxMeta(id, ptx.TxSize(), p.store.Size(id), ptx) meta := newBlobTxMeta(id, ptx.TxSize(), p.store.Size(id), ptx)
// If the newly inserted transaction fails to be tracked, // If the newly inserted transaction fails to be tracked,
// it should also be removed with those in `fails` // it should also be removed with those in `toDelete`
sender, err := types.Sender(p.signer, ptx.Tx) sender, err := types.Sender(p.signer, ptx.Tx)
if err != nil { if err != nil {
fails = append(fails, id) toDelete = append(toDelete, id)
continue continue
} }
if err := p.trackTransaction(meta, sender); err != nil { if err := p.trackTransaction(meta, sender); err != nil {
fails = append(fails, id) toDelete = append(toDelete, id)
continue continue
} }
} }
} }
if len(fails) > 0 { if len(toDelete) > 0 {
log.Warn("Dropping invalidated blob transactions", "ids", fails) log.Warn("Dropping invalidated blob transactions", "ids", toDelete)
dropInvalidMeter.Mark(int64(len(fails))) dropInvalidMeter.Mark(int64(len(toDelete)))
for _, id := range fails { for _, id := range toDelete {
if err := p.store.Delete(id); err != nil { if err := p.store.Delete(id); err != nil {
p.Close() p.Close()
return err return err