Skip to content

Commit

Permalink
save
Browse files Browse the repository at this point in the history
  • Loading branch information
Giulio2002 committed Feb 20, 2025
1 parent a261f9e commit f33d68c
Showing 1 changed file with 0 additions and 30 deletions.
30 changes: 0 additions & 30 deletions cl/phase1/stages/forward_sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,30 +101,6 @@ func downloadAndProcessEip4844DA(ctx context.Context, logger log.Logger, cfg *Cf
return highestProcessed - 1, err
}

func filterUnneededBlocks(ctx context.Context, blocks []*cltypes.SignedBeaconBlock, cfg *Cfg) []*cltypes.SignedBeaconBlock {
filtered := make([]*cltypes.SignedBeaconBlock, 0, len(blocks))
// Find the latest block in the list
for _, block := range blocks {
blockRoot, err := block.Block.HashSSZ()
if err != nil {
panic(err)
}
_, hasInFcu := cfg.forkChoice.GetHeader(blockRoot)

var hasSignedHeaderInDB bool
if err = cfg.indiciesDB.View(ctx, func(tx kv.Tx) error {
_, hasSignedHeaderInDB, err = beacon_indicies.ReadSignedHeaderByBlockRoot(ctx, tx, blockRoot)
return err
}); err != nil {
panic(err)
}
if !hasInFcu || !hasSignedHeaderInDB {
filtered = append(filtered, block)
}
}
return filtered
}

// processDownloadedBlockBatches processes a batch of downloaded blocks.
// It takes the highest block processed, a flag to determine if insertion is needed, and a list of signed beacon blocks as input.
// It returns the new highest block processed and an error if any.
Expand All @@ -134,12 +110,6 @@ func processDownloadedBlockBatches(ctx context.Context, logger log.Logger, cfg *
return blocks[i].Block.Slot < blocks[j].Block.Slot
})

// Filter out blocks that are already in the FCU or have a signed header in the DB
blocks = filterUnneededBlocks(ctx, blocks, cfg)
if len(blocks) == 0 {
return highestBlockProcessed, nil
}

var (
blockRoot common.Hash
st *state.CachingBeaconState
Expand Down

0 comments on commit f33d68c

Please sign in to comment.