Documentation ¶
Index ¶
- func GetDepositCountsFromBeaconBlock(block *spec.VersionedSignedBeaconBlock) int
- func GetTransactionsCountFromBeaconBlock(block *spec.VersionedSignedBeaconBlock) int
- func GetVoluntaryExitsFromBeaconBlock(block *spec.VersionedSignedBeaconBlock) int
- type BeaconMetrics
- type BeaconSubscriptionOptions
- type Config
- type EmptySlotEvent
- type EventMetrics
- type EventTopics
- type FinalityCheckpointUpdated
- type FirstTimeHealthyEvent
- type ForkMetrics
- type GeneralMetrics
- type Health
- type HealthCheckFailedEvent
- type HealthCheckOptions
- type HealthCheckSucceededEvent
- type HealthMetrics
- type Metrics
- func (m *Metrics) Beacon() *BeaconMetrics
- func (m *Metrics) Events() *EventMetrics
- func (m *Metrics) Forks() *ForkMetrics
- func (m *Metrics) General() *GeneralMetrics
- func (m *Metrics) Health() *HealthMetrics
- func (m *Metrics) Spec() *SpecMetrics
- func (m *Metrics) Start(ctx context.Context) error
- func (m *Metrics) Stop() error
- func (m *Metrics) Sync() *SyncMetrics
- type MetricsJob
- type Node
- type NodeVersionUpdatedEvent
- type Options
- type PeersUpdatedEvent
- type ReadyEvent
- type SpecMetrics
- type SpecUpdatedEvent
- type Status
- type SyncMetrics
- type SyncStatusEvent
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetDepositCountsFromBeaconBlock ¶
func GetDepositCountsFromBeaconBlock(block *spec.VersionedSignedBeaconBlock) int
GetDepositCountsFromBeaconBlock returns the number of deposits in a beacon block
func GetTransactionsCountFromBeaconBlock ¶
func GetTransactionsCountFromBeaconBlock(block *spec.VersionedSignedBeaconBlock) int
GetTransactionsCountFromBeaconBlock returns the number of transactions in a beacon block
func GetVoluntaryExitsFromBeaconBlock ¶
func GetVoluntaryExitsFromBeaconBlock(block *spec.VersionedSignedBeaconBlock) int
GetVoluntaryExitsFromBeaconBlock returns the number of voluntary exits in a beacon block
Types ¶
type BeaconMetrics ¶
type BeaconMetrics struct { Slot prometheus.GaugeVec Transactions prometheus.GaugeVec Slashings prometheus.GaugeVec Attestations prometheus.GaugeVec Deposits prometheus.GaugeVec VoluntaryExits prometheus.GaugeVec FinalityCheckpoints prometheus.GaugeVec ReOrgs prometheus.Counter ReOrgDepth prometheus.Counter EmptySlots prometheus.Counter ProposerDelay prometheus.Histogram Withdrawals prometheus.GaugeVec WithdrawalsAmount prometheus.GaugeVec WithdrawalsIndexMax prometheus.GaugeVec WithdrawalsIndexMin prometheus.GaugeVec BlobKZGCommitments prometheus.GaugeVec // contains filtered or unexported fields }
Beacon reports Beacon information about the beacon chain.
func NewBeaconMetrics ¶
func NewBeaconMetrics(beac Node, log logrus.FieldLogger, namespace string, constLabels map[string]string) *BeaconMetrics
NewBeaconMetrics creates a new BeaconMetrics instance.
func (*BeaconMetrics) GetSignedBeaconBlock ¶
func (b *BeaconMetrics) GetSignedBeaconBlock(ctx context.Context, blockID string) error
func (*BeaconMetrics) Name ¶
func (b *BeaconMetrics) Name() string
Name returns the name of the job.
type BeaconSubscriptionOptions ¶
type BeaconSubscriptionOptions struct { Enabled bool Topics EventTopics }
BeaconSubscriptionOptions holds the options for beacon subscription.
func DefaultDisabledBeaconSubscriptionOptions ¶
func DefaultDisabledBeaconSubscriptionOptions() BeaconSubscriptionOptions
DefaultDisabledBeaconSubscriptionOptions returns the default options for a disabled beacon subscription.
func DefaultEnabledBeaconSubscriptionOptions ¶
func DefaultEnabledBeaconSubscriptionOptions() BeaconSubscriptionOptions
DefaultEnabledBeaconSubscriptionOptions returns the default options for an enabled beacon subscription.
func (*BeaconSubscriptionOptions) Disable ¶
func (b *BeaconSubscriptionOptions) Disable() *BeaconSubscriptionOptions
Disable disables the beacon subscription.
func (*BeaconSubscriptionOptions) Enable ¶
func (b *BeaconSubscriptionOptions) Enable() *BeaconSubscriptionOptions
Enable enables the beacon subscription.
type Config ¶
type Config struct { // Name is the human-readable name of the node. Name string `yaml:"name"` // Address is the address of the node. Addr string `yaml:"addr"` // Headers are the headers to send with every request. Headers map[string]string `yaml:"headers"` }
Config is the configuration for a beacon node.
type EmptySlotEvent ¶
EmptySlotEvent is emitted when an empty slot is detected.
type EventMetrics ¶
type EventMetrics struct { Count prometheus.CounterVec TimeSinceLastEvent prometheus.Gauge LastEventTime time.Time // contains filtered or unexported fields }
EventMetrics reports event counts.
func NewEventJob ¶
func NewEventJob(bc Node, log logrus.FieldLogger, namespace string, constLabels map[string]string) *EventMetrics
NewEvent creates a new Event instance.
func (*EventMetrics) HandleEvent ¶
HandleEvent handles all beacon events
type EventTopics ¶
type EventTopics []string
EventTopics is a list of topics that can be subscribed to
func (EventTopics) Exists ¶
func (e EventTopics) Exists(topic string) bool
Exists returns true if the topic exists in the list
type FinalityCheckpointUpdated ¶
FinalityCheckpointUpdated is emitted when the finality checkpoint is updated.
type FirstTimeHealthyEvent ¶ added in v0.42.0
type FirstTimeHealthyEvent struct { }
FirstTimeHealthyEvent is emitted when the node is first considered healthy.
type ForkMetrics ¶
type ForkMetrics struct { Epochs prometheus.GaugeVec Activated prometheus.GaugeVec Current prometheus.GaugeVec // contains filtered or unexported fields }
ForkMetrics reports the state of any forks (previous, active or upcoming).
func NewForksJob ¶
func NewForksJob(beac Node, log logrus.FieldLogger, namespace string, constLabels map[string]string) *ForkMetrics
NewForksJob returns a new Forks instance.
type GeneralMetrics ¶
type GeneralMetrics struct { NodeVersion prometheus.GaugeVec ClientName prometheus.GaugeVec Peers prometheus.GaugeVec // contains filtered or unexported fields }
GeneralMetrics reports general information about the node.
func NewGeneralJob ¶
func NewGeneralJob(beac Node, log logrus.FieldLogger, namespace string, constLabels map[string]string) *GeneralMetrics
NewGeneral creates a new General instance.
func (*GeneralMetrics) Name ¶
func (g *GeneralMetrics) Name() string
Name returns the name of the job.
type Health ¶
type Health struct {
// contains filtered or unexported fields
}
Health tracks the health status of the beacon node.
func (Health) FailedTotal ¶
FailedTotal returns the total number of failures.
func (Health) SuccessTotal ¶
SuccessTotal returns the total number of successes.
type HealthCheckFailedEvent ¶
HealthCheckFailedEvent is emitted when a health check fails.
type HealthCheckOptions ¶
type HealthCheckOptions struct { // Interval is the interval at which the health check will be run. Interval human.Duration // SuccessThreshold is the number of consecutive successful health checks required before the node is considered healthy. SuccessfulResponses int // FailureThreshold is the number of consecutive failed health checks required before the node is considered unhealthy. FailedResponses int }
HealthCheckOptions holds the options for the health check.
func DefaultHealthCheckOptions ¶
func DefaultHealthCheckOptions() HealthCheckOptions
DefaultHealthCheckOptions returns the default health check options.
type HealthCheckSucceededEvent ¶
HealthCheckSucceededEvent is emitted when a health check succeeds.
type HealthMetrics ¶
type HealthMetrics struct { CheckResultsTotal *prometheus.CounterVec Up prometheus.Gauge // contains filtered or unexported fields }
HealthMetrics reports metrics on the health status of the node.
func NewHealthMetrics ¶
func NewHealthMetrics(beac Node, log logrus.FieldLogger, namespace string, constLabels map[string]string) *HealthMetrics
NewHealthMetrics returns a new HealthMetrics instance.
func (*HealthMetrics) Name ¶
func (h *HealthMetrics) Name() string
Name returns the name of the job.
type Metrics ¶
type Metrics struct {
// contains filtered or unexported fields
}
Metrics contains all the metrics jobs.
func NewMetrics ¶
func NewMetrics(log logrus.FieldLogger, namespace, nodeName string, beacon Node) *Metrics
NewMetrics returns a new Metrics instance.
func (*Metrics) Beacon ¶
func (m *Metrics) Beacon() *BeaconMetrics
Beacon returns the beacon metrics job.
func (*Metrics) Events ¶
func (m *Metrics) Events() *EventMetrics
Events returns the events metrics job.
func (*Metrics) General ¶
func (m *Metrics) General() *GeneralMetrics
General returns the general metrics job.
func (*Metrics) Health ¶
func (m *Metrics) Health() *HealthMetrics
Health returns the health metrics job.
type MetricsJob ¶
MetricsJob is a job that reports metrics.
type Node ¶
type Node interface { // Lifecycle // Start starts the node. Start(ctx context.Context) error // StartAsync starts the node asynchronously. StartAsync(ctx context.Context) // Stop stops the node. Stop(ctx context.Context) error // Service returns the Service client for the node. Service() eth2client.Service // Getters // Options returns the options for the node. Options() *Options // Wallclock returns the EthWallclock instance Wallclock() *ethwallclock.EthereumBeaconChain // Eth getters. These are all cached. // Spec returns the spec for the node. Spec() (*state.Spec, error) // SyncState returns the sync state for the node. SyncState() (*v1.SyncState, error) // Genesis returns the genesis for the node. Genesis() (*v1.Genesis, error) // NodeVersion returns the node version. NodeVersion() (string, error) // Status returns the status of the ndoe. Status() *Status // Finality returns the finality checkpoint for the node. Finality() (*v1.Finality, error) // Healthy returns true if the node is healthy. Healthy() bool // Fetchers - these are not cached and will always fetch from the node. // FetchBlock fetches the block for the given state id. FetchBlock(ctx context.Context, stateID string) (*spec.VersionedSignedBeaconBlock, error) // FetchRawBlock fetches the raw, unparsed block for the given state id. FetchRawBlock(ctx context.Context, stateID string, contentType string) ([]byte, error) // FetchBlockRoot fetches the block root for the given state id. FetchBlockRoot(ctx context.Context, stateID string) (*phase0.Root, error) // FetchBeaconState fetches the beacon state for the given state id. FetchBeaconState(ctx context.Context, stateID string) (*spec.VersionedBeaconState, error) // FetchBeaconStateRoot fetches the state root for the given state id. FetchBeaconStateRoot(ctx context.Context, stateID string) (phase0.Root, error) // FetchRawBeaconState fetches the raw, unparsed beacon state for the given state id. FetchRawBeaconState(ctx context.Context, stateID string, contentType string) ([]byte, error) // FetchFinality fetches the finality checkpoint for the state id. FetchFinality(ctx context.Context, stateID string) (*v1.Finality, error) // FetchGenesis fetches the genesis configuration. FetchGenesis(ctx context.Context) (*v1.Genesis, error) // FetchPeers fetches the peers from the beacon node. FetchPeers(ctx context.Context) (*types.Peers, error) // FetchSyncStatus fetches the sync status from the beacon node. FetchSyncStatus(ctx context.Context) (*v1.SyncState, error) // FetchNodeVersion fetches the node version from the beacon node. FetchNodeVersion(ctx context.Context) (string, error) // FetchRawSpec fetches the raw, unparsed spec from the beacon node. FetchRawSpec(ctx context.Context) (map[string]any, error) // FetchSpec fetches the spec from the beacon node. FetchSpec(ctx context.Context) (*state.Spec, error) // FetchProposerDuties fetches the proposer duties from the beacon node. FetchProposerDuties(ctx context.Context, epoch phase0.Epoch) ([]*v1.ProposerDuty, error) // FetchForkChoice fetches the fork choice context. FetchForkChoice(ctx context.Context) (*v1.ForkChoice, error) // FetchDepositSnapshot fetches the deposit snapshot. FetchDepositSnapshot(ctx context.Context) (*types.DepositSnapshot, error) // FetchBeaconCommittees fetches the committees for the given epoch at the given state. FetchBeaconCommittees(ctx context.Context, state string, epoch *phase0.Epoch) ([]*v1.BeaconCommittee, error) // FetchAttestationData fetches the attestation data for the given slot and committee index. FetchAttestationData(ctx context.Context, slot phase0.Slot, committeeIndex phase0.CommitteeIndex) (*phase0.AttestationData, error) // FetchBeaconBlockBlobs fetches blob sidecars for the given block id. FetchBeaconBlockBlobs(ctx context.Context, blockID string) ([]*deneb.BlobSidecar, error) // FetchBeaconBlockHeader fetches beacon block headers. FetchBeaconBlockHeader(ctx context.Context, opts *eapi.BeaconBlockHeaderOpts) (*v1.BeaconBlockHeader, error) // FetchNodeIdentity fetches the node identity. FetchNodeIdentity(ctx context.Context) (*types.Identity, error) // Subscriptions // - Proxied Beacon events // OnEvent is called when a beacon event is received. OnEvent(ctx context.Context, handler func(ctx context.Context, ev *v1.Event) error) // OnBlock is called when a block is received. OnBlock(ctx context.Context, handler func(ctx context.Context, ev *v1.BlockEvent) error) // OnAttestation is called when an attestation is received. OnAttestation(ctx context.Context, handler func(ctx context.Context, ev *phase0.Attestation) error) // OnFinalizedCheckpoint is called when a finalized checkpoint is received. OnFinalizedCheckpoint(ctx context.Context, handler func(ctx context.Context, ev *v1.FinalizedCheckpointEvent) error) // OnHead is called when the head is received. OnHead(ctx context.Context, handler func(ctx context.Context, ev *v1.HeadEvent) error) // OnChainReOrg is called when a chain reorg is received. OnChainReOrg(ctx context.Context, handler func(ctx context.Context, ev *v1.ChainReorgEvent) error) // OnVoluntaryExit is called when a voluntary exit is received. OnVoluntaryExit(ctx context.Context, handler func(ctx context.Context, ev *phase0.SignedVoluntaryExit) error) // OnContributionAndProof is called when a contribution and proof is received. OnContributionAndProof(ctx context.Context, handler func(ctx context.Context, ev *altair.SignedContributionAndProof) error) // OnBlobSidecar is called when a blob sidecar is received. OnBlobSidecar(ctx context.Context, handler func(ctx context.Context, ev *v1.BlobSidecarEvent) error) // - Custom events // OnReady is called when the node is ready. OnReady(ctx context.Context, handler func(ctx context.Context, event *ReadyEvent) error) // OnSyncStatus is called when the sync status changes. OnSyncStatus(ctx context.Context, handler func(ctx context.Context, event *SyncStatusEvent) error) // OnNodeVersionUpdated is called when the node version is updated. OnNodeVersionUpdated(ctx context.Context, handler func(ctx context.Context, event *NodeVersionUpdatedEvent) error) // OnPeersUpdated is called when the peers are updated. OnPeersUpdated(ctx context.Context, handler func(ctx context.Context, event *PeersUpdatedEvent) error) // OnSpecUpdated is called when the spec is updated. OnSpecUpdated(ctx context.Context, handler func(ctx context.Context, event *SpecUpdatedEvent) error) // OnEmptySlot is called when an empty slot is detected. OnEmptySlot(ctx context.Context, handler func(ctx context.Context, event *EmptySlotEvent) error) // OnHealthCheckFailed is called when a health check fails. OnHealthCheckFailed(ctx context.Context, handler func(ctx context.Context, event *HealthCheckFailedEvent) error) // OnHealthCheckSucceeded is called when a health check succeeds. OnHealthCheckSucceeded(ctx context.Context, handler func(ctx context.Context, event *HealthCheckSucceededEvent) error) // OnFinalityCheckpointUpdated is called when a the head finality checkpoint is updated. OnFinalityCheckpointUpdated(ctx context.Context, handler func(ctx context.Context, event *FinalityCheckpointUpdated) error) // OnFirstTimeHealthy is called when the node is healthy for the first time. OnFirstTimeHealthy(ctx context.Context, handler func(ctx context.Context, event *FirstTimeHealthyEvent) error) }
type NodeVersionUpdatedEvent ¶
type NodeVersionUpdatedEvent struct {
Version string
}
NodeVersionUpdatedEvent is emitted when the node version is updated.
type Options ¶
type Options struct { BeaconSubscription BeaconSubscriptionOptions HealthCheck HealthCheckOptions PrometheusMetrics bool DetectEmptySlots bool }
Options holds the options for a beacon node.
func (*Options) DisableEmptySlotDetection ¶
DisableEmptySlotDetection disables empty slot detection.
func (*Options) DisablePrometheusMetrics ¶
DisablePrometheusMetrics disables Prometheus metrics.
func (*Options) EnableDefaultBeaconSubscription ¶
EnableDefaultBeaconSubscription enables the default beacon subscription.
func (*Options) EnableEmptySlotDetection ¶
EnableEmptySlotDetection enables empty slot detection.
func (*Options) EnablePrometheusMetrics ¶
EnablePrometheusMetrics enables Prometheus metrics.
type PeersUpdatedEvent ¶
PeersUpdatedEvent is emitted when the peer list is updated.
type ReadyEvent ¶
type ReadyEvent struct { }
type SpecMetrics ¶
type SpecMetrics struct { SafeSlotsToUpdateJustified prometheus.Gauge DepositChainID prometheus.Gauge ConfigName prometheus.GaugeVec MaxValidatorsPerCommittee prometheus.Gauge SecondsPerEth1Block prometheus.Gauge BaseRewardFactor prometheus.Gauge EpochsPerSyncCommitteePeriod prometheus.Gauge EffectiveBalanceIncrement prometheus.Gauge MaxAttestations prometheus.Gauge MinSyncCommitteeParticipants prometheus.Gauge GenesisDelay prometheus.Gauge SecondsPerSlot prometheus.Gauge MaxEffectiveBalance prometheus.Gauge TerminalTotalDifficulty prometheus.Gauge TerminalTotalDifficultyTrillions prometheus.Gauge MaxDeposits prometheus.Gauge MinGenesisActiveValidatorCount prometheus.Gauge TargetCommitteeSize prometheus.Gauge SyncCommitteeSize prometheus.Gauge Eth1FollowDistance prometheus.Gauge TerminalBlockHashActivationEpoch prometheus.Gauge MinDepositAmount prometheus.Gauge SlotsPerEpoch prometheus.Gauge PresetBase prometheus.GaugeVec // contains filtered or unexported fields }
SpecMetrics reports metrics about the configured consensus spec.
func NewSpecJob ¶
func NewSpecJob(bc Node, log logrus.FieldLogger, namespace string, constLabels map[string]string) *SpecMetrics
NewSpecJob returns a new Spec instance.
type SpecUpdatedEvent ¶
SpecUpdatedEvent is emitted when the spec is updated.
type Status ¶
type Status struct {
// contains filtered or unexported fields
}
Status is a beacon node status.
func (*Status) UpdateNetworkID ¶
UpdateNetworkID updates the network ID.
func (*Status) UpdateSyncState ¶
UpdateSyncState updates the sync state.
type SyncMetrics ¶
type SyncMetrics struct { Percentage prometheus.Gauge EstimatedHighestSlot prometheus.Gauge HeadSlot prometheus.Gauge Distance prometheus.Gauge IsSyncing prometheus.Gauge // contains filtered or unexported fields }
SyncMetrics reports metrics on the sync status of the node.
func NewSyncMetrics ¶
func NewSyncMetrics(beac Node, log logrus.FieldLogger, namespace string, constLabels map[string]string) *SyncMetrics
NewSyncMetrics returns a new Sync metrics instance.
type SyncStatusEvent ¶
SyncStatusEvent is emitted when the sync status is refreshed.