beacon

package
v0.25.0 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2024 License: GPL-3.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// FinalityHaltedServingPeriod defines how long we will happily serve finality data for after the chain has stopped finality.
	// TODO(sam.calder-mason): Derive from weak subjectivity period.
	FinalityHaltedServingPeriod = 14 * 24 * time.Hour
)

Variables

This section is empty.

Functions

func CalculateSlotExpiration

func CalculateSlotExpiration(slot phase0.Slot, slotsOfHistory int) phase0.Slot

func GetSlotTime

func GetSlotTime(slot phase0.Slot, secondsPerSlot time.Duration, genesis time.Time) time.Time

Types

type CacheConfig

type CacheConfig struct {
	// Blocks holds the block cache configuration.
	Blocks store.Config `yaml:"blocks" default:"{\"MaxItems\": 30}"`
	// States holds the state cache configuration.
	States store.Config `yaml:"states" default:"{\"MaxItems\": 5}"`
	// DepositSnapshots holds the deposit snapshot cache configuration.
	DepositSnapshots store.Config `yaml:"deposit_snapshots" default:"{\"MaxItems\": 30}"`
	// BlobSidecars holds the blob sidecar cache configuration.
	BlobSidecars store.Config `yaml:"blob_sidecars" default:"{\"MaxItems\": 30}"`
}

Cache configuration holds configuration for the caches.

func (*CacheConfig) Validate

func (c *CacheConfig) Validate() error

type Config

type Config struct {
	// Mode sets the operational mode of the provider.
	Mode OperatingMode `yaml:"mode" default:"light"`
	// Cache holds configuration for the caches.
	Caches CacheConfig `yaml:"caches"`

	// HistoricalEpochCount determines how many historical epochs the provider will cache.
	HistoricalEpochCount int `yaml:"historical_epoch_count" default:"20"`

	// Cache holds configuration for the caches.
	Frontend FrontendConfig `yaml:"frontend"`
}

Config holds configuration for running a FinalityProvider config

func (*Config) Validate

func (c *Config) Validate() error

type Default

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

func (*Default) Finalized

func (d *Default) Finalized(ctx context.Context) (*v1.Finality, error)

func (*Default) Genesis

func (d *Default) Genesis(ctx context.Context) (*v1.Genesis, error)

func (*Default) GetBeaconStateByRoot

func (d *Default) GetBeaconStateByRoot(ctx context.Context, root phase0.Root) (*spec.VersionedBeaconState, error)

func (*Default) GetBeaconStateBySlot

func (d *Default) GetBeaconStateBySlot(ctx context.Context, slot phase0.Slot) (*spec.VersionedBeaconState, error)

func (*Default) GetBeaconStateByStateRoot

func (d *Default) GetBeaconStateByStateRoot(ctx context.Context, stateRoot phase0.Root) (*spec.VersionedBeaconState, error)

func (*Default) GetBlobSidecarsBySlot added in v0.20.0

func (d *Default) GetBlobSidecarsBySlot(ctx context.Context, slot phase0.Slot) ([]*deneb.BlobSidecar, error)

func (*Default) GetBlockByRoot

func (d *Default) GetBlockByRoot(ctx context.Context, root phase0.Root) (*spec.VersionedSignedBeaconBlock, error)

func (*Default) GetBlockBySlot

func (d *Default) GetBlockBySlot(ctx context.Context, slot phase0.Slot) (*spec.VersionedSignedBeaconBlock, error)

func (*Default) GetBlockByStateRoot

func (d *Default) GetBlockByStateRoot(ctx context.Context, stateRoot phase0.Root) (*spec.VersionedSignedBeaconBlock, error)

func (*Default) GetDepositSnapshot added in v0.15.0

func (d *Default) GetDepositSnapshot(ctx context.Context, epoch phase0.Epoch) (*types.DepositSnapshot, error)

func (*Default) GetEpochBySlot

func (d *Default) GetEpochBySlot(ctx context.Context, slot phase0.Slot) (phase0.Epoch, error)

func (*Default) GetSlotTime

func (d *Default) GetSlotTime(ctx context.Context, slot phase0.Slot) (eth.SlotTime, error)

func (*Default) Head

func (d *Default) Head(ctx context.Context) (*v1.Finality, error)

func (*Default) Healthy

func (d *Default) Healthy(ctx context.Context) (bool, error)

func (*Default) ListFinalizedSlots

func (d *Default) ListFinalizedSlots(ctx context.Context) ([]phase0.Slot, error)

func (*Default) OnFinalityCheckpointHeadUpdated

func (d *Default) OnFinalityCheckpointHeadUpdated(ctx context.Context, cb func(ctx context.Context, checkpoint *v1.Finality) error)

func (*Default) OperatingMode

func (d *Default) OperatingMode() OperatingMode

func (*Default) PeerCount

func (d *Default) PeerCount(ctx context.Context) (uint64, error)

func (*Default) Peers

func (d *Default) Peers(ctx context.Context) (types.Peers, error)

func (*Default) Spec

func (d *Default) Spec() (*state.Spec, error)

func (*Default) Start

func (d *Default) Start(ctx context.Context) error

func (*Default) StartAsync

func (d *Default) StartAsync(ctx context.Context)

func (*Default) Syncing

func (d *Default) Syncing(ctx context.Context) (*v1.SyncState, error)

func (*Default) UpstreamsStatus

func (d *Default) UpstreamsStatus(ctx context.Context) (map[string]*UpstreamStatus, error)

type FinalityProvider

type FinalityProvider interface {
	// Start starts the provider.
	Start(ctx context.Context) error
	// StartAsync starts the provider in a goroutine.
	StartAsync(ctx context.Context)
	// Healthy returns true if the provider is healthy.
	Healthy(ctx context.Context) (bool, error)
	// Peers returns the peers the provider is connected to).
	Peers(ctx context.Context) (types.Peers, error)
	// PeerCount returns the amount of peers the provider is connected to (the amount of healthy upstreams).
	PeerCount(ctx context.Context) (uint64, error)
	// Syncing returns the sync state of the provider.
	Syncing(ctx context.Context) (*v1.SyncState, error)
	// Head returns the head finality.
	Head(ctx context.Context) (*v1.Finality, error)
	// Finalized returns the finalized finality.
	Finalized(ctx context.Context) (*v1.Finality, error)
	// Genesis returns the chain genesis.
	Genesis(ctx context.Context) (*v1.Genesis, error)
	// Spec returns the chain spec.
	Spec() (*state.Spec, error)
	// UpstreamsStatus returns the status of all the upstreams.
	UpstreamsStatus(ctx context.Context) (map[string]*UpstreamStatus, error)
	// GetBlockBySlot returns the block at the given slot.
	GetBlockBySlot(ctx context.Context, slot phase0.Slot) (*spec.VersionedSignedBeaconBlock, error)
	// GetBlockByRoot returns the block with the given root.
	GetBlockByRoot(ctx context.Context, root phase0.Root) (*spec.VersionedSignedBeaconBlock, error)
	// GetBlockByStateRoot returns the block with the given root.
	GetBlockByStateRoot(ctx context.Context, root phase0.Root) (*spec.VersionedSignedBeaconBlock, error)
	// GetBeaconStateBySlot returns the beacon sate with the given slot.
	GetBeaconStateBySlot(ctx context.Context, slot phase0.Slot) (*spec.VersionedBeaconState, error)
	// GetBeaconStateByStateRoot returns the beacon sate with the given state root.
	GetBeaconStateByStateRoot(ctx context.Context, root phase0.Root) (*spec.VersionedBeaconState, error)
	// GetBeaconStateByRoot returns the beacon sate with the given root.
	GetBeaconStateByRoot(ctx context.Context, root phase0.Root) (*spec.VersionedBeaconState, error)
	// GetBlobSidecarsBySlot returns the blob sidecars for the given slot.
	GetBlobSidecarsBySlot(ctx context.Context, slot phase0.Slot) ([]*deneb.BlobSidecar, error)
	// ListFinalizedSlots returns a slice of finalized slots.
	ListFinalizedSlots(ctx context.Context) ([]phase0.Slot, error)
	// GetEpochBySlot returns the epoch for the given slot.
	GetEpochBySlot(ctx context.Context, slot phase0.Slot) (phase0.Epoch, error)
	// OperatingMode returns the mode of operation for the instance.
	OperatingMode() OperatingMode
	// GetSlotTime returns the wall clock for the given slot.
	GetSlotTime(ctx context.Context, slot phase0.Slot) (eth.SlotTime, error)
	// GetDepositSnapshot returns the deposit snapshot at the given epoch.
	GetDepositSnapshot(ctx context.Context, epoch phase0.Epoch) (*types.DepositSnapshot, error)
}

FinalityProvider is a provider of finality information.

func NewDefaultProvider

func NewDefaultProvider(namespace string, log logrus.FieldLogger, nodes []node.Config, config *Config) FinalityProvider

type FrontendConfig

type FrontendConfig struct {
	// Enabled flag enables the frontend assets to be served
	Enabled bool `yaml:"enabled" default:"true"`

	// PublicURL is the public URL where checkpointz will be served from
	PublicURL string `yaml:"public_url"`

	// BrandName is the name of the brand to display in the frontend
	BrandName string `yaml:"brand_name"`

	// BrandImageURL is the URL of the brand image to be displayed on the frontend
	BrandImageURL string `yaml:"brand_image_url"`
}

type Metrics

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

func NewMetrics

func NewMetrics(namespace string) *Metrics

func (*Metrics) ObserveHeadEpoch

func (m *Metrics) ObserveHeadEpoch(epoch phase0.Epoch)

func (*Metrics) ObserveOperatingMode

func (m *Metrics) ObserveOperatingMode(mode OperatingMode)

func (*Metrics) ObserveServingEpoch

func (m *Metrics) ObserveServingEpoch(epoch phase0.Epoch)

type Node

type Node struct {
	Config node.Config
	Beacon sbeacon.Node
}

type Nodes

type Nodes []*Node

func NewNodesFromConfig

func NewNodesFromConfig(log logrus.FieldLogger, configs []node.Config, namespace string) Nodes

func (Nodes) DataProviders

func (n Nodes) DataProviders(ctx context.Context) Nodes

func (Nodes) Filter

func (n Nodes) Filter(ctx context.Context, f func(*Node) bool) Nodes

func (Nodes) Healthy

func (n Nodes) Healthy(ctx context.Context) Nodes

func (Nodes) NotSyncing

func (n Nodes) NotSyncing(ctx context.Context) Nodes

func (Nodes) PastFinalizedCheckpoint

func (n Nodes) PastFinalizedCheckpoint(ctx context.Context, checkpoint *v1.Finality) Nodes

func (Nodes) RandomNode

func (n Nodes) RandomNode(ctx context.Context) (*Node, error)

func (Nodes) Ready

func (n Nodes) Ready(ctx context.Context) Nodes

func (Nodes) StartAll

func (n Nodes) StartAll(ctx context.Context) error

func (Nodes) Syncing

func (n Nodes) Syncing(ctx context.Context) Nodes

type OperatingMode

type OperatingMode string
const (
	OperatingModeFull  OperatingMode = "full"
	OperatingModeLight OperatingMode = "light"
)

type UpstreamStatus

type UpstreamStatus struct {
	Name        string       `json:"name"`
	Healthy     bool         `json:"healthy"`
	Finality    *v1.Finality `json:"finality"`
	NetworkName string       `json:"network_name,omitempty"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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