Skip to content

Commit

Permalink
save
Browse files Browse the repository at this point in the history
  • Loading branch information
Giulio2002 committed Oct 7, 2024
1 parent 1182663 commit 42bd826
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 2 deletions.
53 changes: 53 additions & 0 deletions cmd/capcli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -1115,3 +1115,56 @@ func (c *CheckBlobsSnapshotsCount) Run(ctx *Context) error {
}
return nil
}

type DumpBlobsSnapshotsToStore struct {
chainCfg
outputFolder
withPPROF
}

func (c *DumpBlobsSnapshotsToStore) Run(ctx *Context) error {
_, beaconConfig, _, err := clparams.GetConfigsByNetworkName(c.Chain)
if err != nil {
return err
}
c.withProfile()
log.Root().SetHandler(log.LvlFilterHandler(log.LvlDebug, log.StderrHandler))
log.Info("Started the checking process", "chain", c.Chain)
dirs := datadir.New(c.Datadir)
log.Root().SetHandler(log.LvlFilterHandler(log.LvlInfo, log.StderrHandler))

db, blobStore, err := caplin1.OpenCaplinDatabase(ctx, beaconConfig, nil, dirs.CaplinIndexing, dirs.CaplinBlobs, nil, false, 0)
if err != nil {
return err
}
tx, err := db.BeginRo(ctx)
if err != nil {
return err
}
defer tx.Rollback()

csn := freezeblocks.NewCaplinSnapshots(ethconfig.BlocksFreezing{}, beaconConfig, dirs, log.Root())
if err := csn.ReopenFolder(); err != nil {
return err
}
to := csn.FrozenBlobs()
start := max(beaconConfig.SlotsPerEpoch * beaconConfig.DenebForkEpoch)
for i := start; i < to; i++ {
sds, err := csn.ReadBlobSidecars(i)
if err != nil {
return err
}
blockRoot, err := beacon_indicies.ReadCanonicalBlockRoot(tx, i)
if err != nil {
return err
}
if blockRoot == (libcommon.Hash{}) {
continue
}
if err := blobStore.WriteBlobSidecars(ctx, blockRoot, sds); err != nil {
return err
}
}

return nil
}
4 changes: 2 additions & 2 deletions turbo/snapshotsync/freezeblocks/caplin_snapshots.go
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ func dumpBeaconBlocksRange(ctx context.Context, db kv.RoDB, fromSlot uint64, toS
return BeaconSimpleIdx(ctx, f, salt, tmpDir, p, lvl, logger)
}

func dumpBlobSidecarsRange(ctx context.Context, db kv.RoDB, storage blob_storage.BlobStorage, fromSlot uint64, toSlot uint64, salt uint32, dirs datadir.Dirs, workers int, blobCountFn BlobCountBySlotFn, lvl log.Lvl, logger log.Logger) error {
func DumpBlobSidecarsRange(ctx context.Context, db kv.RoDB, storage blob_storage.BlobStorage, fromSlot uint64, toSlot uint64, salt uint32, dirs datadir.Dirs, workers int, blobCountFn BlobCountBySlotFn, lvl log.Lvl, logger log.Logger) error {
tmpDir, snapDir := dirs.Tmp, dirs.Snap

segName := snaptype.BlobSidecars.FileName(0, fromSlot, toSlot)
Expand Down Expand Up @@ -671,7 +671,7 @@ func DumpBlobsSidecar(ctx context.Context, blobStorage blob_storage.BlobStorage,
}
to := chooseSegmentEnd(i, toSlot, snaptype.CaplinEnums.BlobSidecars, nil)
logger.Log(lvl, "Dumping blobs sidecars", "from", i, "to", to)
if err := dumpBlobSidecarsRange(ctx, db, blobStorage, i, to, salt, dirs, compressWorkers, blobCountFn, lvl, logger); err != nil {
if err := DumpBlobSidecarsRange(ctx, db, blobStorage, i, to, salt, dirs, compressWorkers, blobCountFn, lvl, logger); err != nil {
return err
}
}
Expand Down

0 comments on commit 42bd826

Please sign in to comment.