backfill

package
v5.0.3 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2024 License: GPL-3.0 Imports: 36 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrChainBroken = errors.New("batch is not the ancestor of a known finalized root")

ErrChainBroken indicates a backfill batch can't be imported to the db because it is not known to be the ancestor of the canonical chain.

Functions

This section is empty.

Types

type BeaconDB

type BeaconDB interface {
	SaveBackfillStatus(context.Context, *dbval.BackfillStatus) error
	BackfillStatus(context.Context) (*dbval.BackfillStatus, error)
	BackfillFinalizedIndex(ctx context.Context, blocks []blocks.ROBlock, finalizedChildRoot [32]byte) error
	OriginCheckpointBlockRoot(context.Context) ([32]byte, error)
	Block(context.Context, [32]byte) (interfaces.ReadOnlySignedBeaconBlock, error)
	SaveROBlocks(ctx context.Context, blks []blocks.ROBlock, cache bool) error
	StateOrError(ctx context.Context, blockRoot [32]byte) (state.BeaconState, error)
}

BeaconDB describes the set of DB methods that the StatusUpdater type needs to function.

type InitializerWaiter

type InitializerWaiter interface {
	WaitForInitializer(ctx context.Context) (*verification.Initializer, error)
}

InitializerWaiter is an interface that is satisfied by verification.InitializerWaiter. Using this interface enables node init to satisfy this requirement for the backfill service while also allowing backfill to mock it in tests.

type PeerAssigner

type PeerAssigner interface {
	Assign(busy map[peer.ID]bool, n int) ([]peer.ID, error)
}

PeerAssigner describes a type that provides an Assign method, which can assign the best peer to service an RPC blockRequest. The Assign method takes a map of peers that should be excluded, allowing the caller to avoid making multiple concurrent requests to the same peer.

type Service

type Service struct {
	// contains filtered or unexported fields
}

func NewService

func NewService(ctx context.Context, su *Store, bStore *filesystem.BlobStorage, cw startup.ClockWaiter, p p2p.P2P, pa PeerAssigner, opts ...ServiceOption) (*Service, error)

NewService initializes the backfill Service. Like all implementations of the Service interface, the service won't begin its runloop until Start() is called.

func (*Service) Start

func (s *Service) Start()

Start begins the runloop of backfill.Service in the current goroutine.

func (*Service) Status

func (*Service) Status() error

func (*Service) Stop

func (*Service) Stop() error

type ServiceOption

type ServiceOption func(*Service) error

ServiceOption represents a functional option for the backfill service constructor.

func WithBatchSize

func WithBatchSize(n uint64) ServiceOption

WithBatchSize configures the size of backfill batches, similar to the initial-sync block-batch-limit flag. It should usually be left at the default value.

func WithEnableBackfill

func WithEnableBackfill(enabled bool) ServiceOption

WithEnableBackfill toggles the entire backfill service on or off, intended to be used by a feature flag.

func WithInitSyncWaiter

func WithInitSyncWaiter(w func() error) ServiceOption

WithInitSyncWaiter sets a function on the service which will block until init-sync completes for the first time, or returns an error if context is canceled.

func WithMinimumSlot added in v5.0.2

func WithMinimumSlot(s primitives.Slot) ServiceOption

WithMinimumSlot allows the user to specify a different backfill minimum slot than the spec default of current - MIN_EPOCHS_FOR_BLOCK_REQUESTS. If this value is greater than current - MIN_EPOCHS_FOR_BLOCK_REQUESTS, it will be ignored with a warning log.

func WithVerifierWaiter

func WithVerifierWaiter(viw InitializerWaiter) ServiceOption

WithVerifierWaiter sets the verification.InitializerWaiter for the backfill Service.

func WithWorkerCount

func WithWorkerCount(n int) ServiceOption

WithWorkerCount sets the number of goroutines in the batch processing pool that can concurrently make p2p requests to download data for batches.

type Store

type Store struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Store provides a way to update and query the status of a backfill process that may be necessary to track when a node was initialized via checkpoint sync. With checkpoint sync, there will be a gap in node history from genesis until the checkpoint sync origin block. Store provides the means to update the value keeping track of the lower end of the missing block range via the FillFwd() method, to check whether a Slot is missing from the database via the AvailableBlock() method, and to see the current StartGap() and EndGap().

func NewUpdater

func NewUpdater(ctx context.Context, store BeaconDB) (*Store, error)

NewUpdater correctly initializes a StatusUpdater value with the required database value.

func (*Store) AvailableBlock

func (s *Store) AvailableBlock(sl primitives.Slot) bool

AvailableBlock determines if the given slot is covered by the current chain history. If the slot is <= backfill low slot, or >= backfill high slot, the result is true. If the slot is between the backfill low and high slots, the result is false.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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