blocks

package
v1.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 12, 2025 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Cmd = &cobra.Command{
	Use:   "check-blocks-integrity",
	Short: "Checks the EVM blocks integrity. Note that the given DB dir should not be currently in use by a running node.",
	RunE: func(*cobra.Command, []string) error {
		pebbleDB, err := pebble.OpenDB(databaseDir)
		if err != nil {
			return fmt.Errorf("failed to open pebble db: %w", err)
		}
		defer func() {
			_ = pebbleDB.Close()
		}()
		store := pebble.New(pebbleDB, log.Logger)

		blocks := pebble.NewBlocks(store, flowGo.ChainID(chainID))

		latestHeight, err := blocks.LatestEVMHeight()
		if err != nil {
			return fmt.Errorf("failed to get latest EVM height: %w", err)
		}
		log.Info().Msgf("Checking for missing EVM blocks from genesis up to EVM height %d", latestHeight)

		var missingBlocks []uint64
		for height := uint64(0); height <= latestHeight; height++ {
			_, err := blocks.GetByHeight(height)
			if errors.Is(err, errs.ErrEntityNotFound) {
				log.Error().Msgf("missing EVM block with height: %d", height)
				missingBlocks = append(missingBlocks, height)
			} else if err != nil {
				log.Error().Err(err).Msgf("failed to get block at height: %d", height)
			}
		}

		if len(missingBlocks) > 0 {
			log.Error().Msgf("Found %d missing blocks in the EVM blocks database", len(missingBlocks))
			return nil
		}

		log.Info().Msg("EVM blocks DB has no integrity issues. All blocks are indexed.")

		return nil
	},
}

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL