localbuilder

package
v0.1.1-experimental.3 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// MetricsPayloadIDCacheHit is used to count the number of times a built
	// payload retrieval is attempted and found.
	MetricsPayloadIDCacheHit = prefix +
		"payload-id-cache-hit"

	// MetricGetPayloadMiss is used to count the number of times a built
	// payload retrieval is attempted but not found.
	MetricsPayloadIDCacheMiss = prefix +
		"payload-id-cache-miss"

	// MetricErrorRetrievingPayload is used to count the number of times an
	// error
	// occurs when attempting to retrieve a built payload.
	MetricsPayloadIDCacheError = prefix +
		"get-payload-error"

	// MetricLocalBuilderReceivedNilPayload is used to count the number of times
	// the local builder receives a nil payload.
	MetricsLocalBuilderReceivedNilPayload = prefix +
		"local-builder-received-nil-payload"
)

Variables

View Source
var (
	// ErrNilPayloadOnValidResponse is returned when a nil payload ID is
	// received on a VALID engine response.
	ErrNilPayloadOnValidResponse = errors.New(
		"received nil payload ID on VALID engine response",
	)

	// ErrNilPayloadID is returned when a nil payload ID is received.
	ErrNilPayloadID = errors.New("received nil payload ID")

	// ErrPayloadIDNotFound is returned when a payload ID is not found in the
	// cache.
	ErrPayloadIDNotFound = errors.New("unable to find payload ID in cache")

	// ErrCachedPayloadNotFoundOnExecutionClient is returned when a cached
	// payloadID is not found on the execution client.
	ErrCachedPayloadNotFoundOnExecutionClient = errors.New(
		"cached payload ID could not be resolved on execution client",
	)

	// ErrLocalBuildingDisabled is returned when local building is disabled.
	ErrLocalBuildingDisabled = errors.New("local building is disabled")
)

Functions

func WithBaseService

func WithBaseService(base service.BaseService) service.Option[Service]

WithBaseService returns an Option that sets the BaseService for the Service.

func WithBuilderConfig

func WithBuilderConfig(cfg *builderconfig.Config) service.Option[Service]

WithBuilderConfig sets the builder config.

func WithExecutionEngine

func WithExecutionEngine(ee ExecutionEngine) service.Option[Service]

WithExecutionEngine sets the execution engine.

func WithPayloadCache

func WithPayloadCache(pc *cache.PayloadIDCache) service.Option[Service]

WithPayloadCache sets the payload cache.

Types

type ExecutionEngine

type ExecutionEngine interface {
	// GetPayload returns the payload and blobs bundle for the given slot.
	GetPayload(
		ctx context.Context,
		req *execution.GetPayloadRequest,
	) (enginetypes.ExecutionPayload, *engine.BlobsBundleV1, bool, error)

	// NotifyForkchoiceUpdate notifies the execution client of a forkchoice
	// update.
	NotifyForkchoiceUpdate(
		ctx context.Context,
		req *execution.ForkchoiceUpdateRequest,
	) (*engine.PayloadID, *primitives.ExecutionHash, error)
}

ExecutionEngine is the interface for the execution engine.

type Service

type Service struct {
	service.BaseService
	// contains filtered or unexported fields
}

TODO: Decouple from ABCI and have this validator run on a separate thread have it configured itself and not be a service persay.

func (*Service) BuildLocalPayload

func (s *Service) BuildLocalPayload(
	ctx context.Context,
	st state.BeaconState,
	parentEth1Hash primitives.ExecutionHash,
	slot primitives.Slot,
	timestamp uint64,
	parentBlockRoot primitives.Root,
) (*engine.PayloadID, error)

BuildLocalPayload builds a payload for the given slot and returns the payload ID.

func (*Service) GetBestPayload

func (s *Service) GetBestPayload(
	ctx context.Context,
	st state.BeaconState,
	slot primitives.Slot,
	parentBlockRoot primitives.Root,
	parentEth1Hash primitives.ExecutionHash,
) (enginetypes.ExecutionPayload, *engine.BlobsBundleV1, bool, error)

GetBestPayload attempts to pull a previously built payload by reading a payloadID from the builder's cache. If it fails to retrieve a payload, it will build a new payload and wait for the execution client to return the payload.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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