@@ -88,6 +88,10 @@ const (
8888 // limboedTransactionStore is the subfolder containing the currently included
8989 // but not yet finalized transaction blobs.
9090 limboedTransactionStore = "limbo"
91+
92+ // storeVersion is the current slotter layout used for the billy.Database
93+ // store.
94+ storeVersion = 1
9195)
9296
9397// blobTxMeta is the minimal subset of types.BlobTx necessary to validate and
@@ -395,23 +399,48 @@ func (p *BlobPool) Init(gasTip uint64, head *types.Header, reserver txpool.Reser
395399 }
396400 p .head , p .state = head , state
397401
398- // Check if we need to migrate the blob database to a new format
402+ // Create new slotter for pre-Osaka blob configuration.
399403 slotter := newSlotter (eip4844 .LatestMaxBlobsPerBlock (p .chain .Config ()))
404+
405+ // Check if we need to migrate our blob db to the new slotter.
400406 if p .chain .Config ().IsOsaka (head .Number , head .Time ) {
401- // Check if we need to migrate our blob db to the new slotter
402- oldSlotSize := 135168
403- if _ , err := os .Stat (filepath .Join (queuedir , fmt .Sprintf ("bkt_%08d.bag" , oldSlotSize ))); err == nil {
407+ // Open the store using the version slotter to see if any version has been
408+ // written.
409+ var version int
410+ index := func (_ uint64 , _ uint32 , blob []byte ) {
411+ version = max (version , parseSlotterVersion (blob ))
412+ }
413+ store , err := billy .Open (billy.Options {Path : queuedir }, newVersionSlotter (), index )
414+ if err != nil {
415+ return err
416+ }
417+ store .Close ()
418+
419+ // If the version found is less than the currently configured store version,
420+ // perform a migration then write the updated version of the store.
421+ if version < storeVersion {
404422 newSlotter := newSlotterEIP7594 (eip4844 .LatestMaxBlobsPerBlock (p .chain .Config ()))
405423 if err := billy .Migrate (billy.Options {Path : queuedir , Repair : true }, slotter , newSlotter ); err != nil {
406424 return err
407425 }
426+ store , err = billy .Open (billy.Options {Path : queuedir }, newVersionSlotter (), nil )
427+ if err != nil {
428+ return err
429+ }
430+ writeSlotterVersion (store , storeVersion )
431+ store .Close ()
408432 }
433+ // Set the slotter to the format now that the Osaka is active.
409434 slotter = newSlotterEIP7594 (eip4844 .LatestMaxBlobsPerBlock (p .chain .Config ()))
410435 }
411436
412437 // Index all transactions on disk and delete anything unprocessable
413438 var fails []uint64
414439 index := func (id uint64 , size uint32 , blob []byte ) {
440+ if len (blob ) == 1 {
441+ // Skip version blob if found.
442+ return
443+ }
415444 if p .parseTransaction (id , size , blob ) != nil {
416445 fails = append (fails , id )
417446 }
0 commit comments