Documentation
¶
Index ¶
- Constants
- func GetDefaultAllTopics() []string
- func GetOptInTopics() []string
- func ParseAttnetsBitmask(attnets string) ([]int, error)
- type BeaconFactory
- type BeaconNodeAPI
- type BeaconOptions
- type BeaconWrapper
- func (w *BeaconWrapper) GetEpoch(epoch uint64) ethwallclock.Epoch
- func (w *BeaconWrapper) GetEpochFromSlot(slot uint64) ethwallclock.Epoch
- func (w *BeaconWrapper) GetSlot(slot uint64) ethwallclock.Slot
- func (w *BeaconWrapper) GetTopicManager() TopicManager
- func (w *BeaconWrapper) IsActiveSubnet(subnetID uint64) bool
- func (b *BeaconWrapper) IsSlotFromUnexpectedNetwork(eventSlot uint64) bool
- func (w *BeaconWrapper) NeedsReconnection() <-chan struct{}
- func (w *BeaconWrapper) RecordSeenSubnet(subnetID uint64, slot uint64)
- func (w *BeaconWrapper) Start(ctx context.Context) error
- func (w *BeaconWrapper) Stop(ctx context.Context) error
- type Config
- type NodeIdentity
- type NodeIdentityData
- type NodeIdentityMetadata
- type SubnetConfig
- type TopicCondition
- type TopicConfig
- type TopicManager
Constants ¶
const ( TopicBlock = "block" TopicBlockGossip = "block_gossip" TopicHead = "head" TopicFinalizedCheckpoint = "finalized_checkpoint" TopicBlobSidecar = "blob_sidecar" TopicChainReorg = "chain_reorg" TopicSingleAttestation = "single_attestation" TopicDataColumnSidecar = "data_column_sidecar" )
const MaxReasonableSlotDifference uint64 = 10000
MaxReasonableSlotDifference is the maximum number of slots that can be between the event slot and the current slot before we consider the event to be from a different network.
Variables ¶
This section is empty.
Functions ¶
func GetDefaultAllTopics ¶ added in v0.0.69
func GetDefaultAllTopics() []string
GetDefaultAllTopics returns all available topics.
func GetOptInTopics ¶ added in v0.0.69
func GetOptInTopics() []string
GetOptInTopics returns opt-in topics.
func ParseAttnetsBitmask ¶ added in v0.0.69
ParseAttnetsBitmask parses the attnets hex string into a slice of active subnet IDs. Each bit in the attnets bitfield corresponds to a subnet (0–63), with bits ordered LSB-first. That is, bit 0 of byte 0 = subnet 0, bit 7 of byte 0 = subnet 7, bit 0 of byte 1 = subnet 8, etc. Do not incorrectly treat bits as MSB-first (bit 7 first), this will result in the subnet IDs and cause you a world of fucking pain.
Types ¶
type BeaconFactory ¶ added in v0.0.69
type BeaconFactory struct {
// contains filtered or unexported fields
}
BeaconFactory creates beacon instances with consistent configuration.
func NewBeaconFactory ¶ added in v0.0.69
func NewBeaconFactory(log logrus.FieldLogger, clockDrift clockdrift.ClockDrift) *BeaconFactory
NewBeaconFactory creates a new beacon factory.
func (*BeaconFactory) CreateBeacon ¶ added in v0.0.69
func (bf *BeaconFactory) CreateBeacon(ctx context.Context, opts *BeaconOptions) (*BeaconWrapper, error)
CreateBeacon creates a new beacon instance with the given options.
type BeaconNodeAPI ¶ added in v0.0.55
type BeaconNodeAPI interface {
// Start starts the beacon node and blocks until it is healthy.
Start(ctx context.Context) error
// Stop stops the beacon node.
Stop(ctx context.Context) error
// Synced checks if the beacon node is synced and ready.
Synced(ctx context.Context) error
}
BeaconNodeAPI is the interface for the BeaconNode.
type BeaconOptions ¶ added in v0.0.69
type BeaconOptions struct {
TraceID string
Config *Config
Sinks []sinks.ContributoorSink
Cache *events.DuplicateCache
Summary *events.Summary
Metrics *events.Metrics
TopicManager TopicManager
ExcludeTopics []string
}
BeaconOptions contains all parameters for beacon creation.
type BeaconWrapper ¶ added in v0.0.69
type BeaconWrapper struct {
*ethcore.BeaconNode // Embed ethcore beacon
// contains filtered or unexported fields
}
BeaconWrapper wraps ethcore beacon with additional contributoor functionality.
func (*BeaconWrapper) GetEpoch ¶ added in v0.0.69
func (w *BeaconWrapper) GetEpoch(epoch uint64) ethwallclock.Epoch
GetEpoch returns the wallclock epoch for a given epoch number.
func (*BeaconWrapper) GetEpochFromSlot ¶ added in v0.0.69
func (w *BeaconWrapper) GetEpochFromSlot(slot uint64) ethwallclock.Epoch
GetEpochFromSlot returns the wallclock epoch for a given slot number.
func (*BeaconWrapper) GetSlot ¶ added in v0.0.69
func (w *BeaconWrapper) GetSlot(slot uint64) ethwallclock.Slot
GetSlot returns the wallclock slot for a given slot number.
func (*BeaconWrapper) GetTopicManager ¶ added in v0.0.69
func (w *BeaconWrapper) GetTopicManager() TopicManager
GetTopicManager returns the topic manager for this beacon wrapper.
func (*BeaconWrapper) IsActiveSubnet ¶ added in v0.0.69
func (w *BeaconWrapper) IsActiveSubnet(subnetID uint64) bool
IsActiveSubnet checks if the given subnet ID is in the node's active subnets.
func (*BeaconWrapper) IsSlotFromUnexpectedNetwork ¶ added in v0.0.69
func (b *BeaconWrapper) IsSlotFromUnexpectedNetwork(eventSlot uint64) bool
IsSlotFromUnexpectedNetwork checks if a slot appears to be from an unexpected network by comparing it with the current wallclock slot.
func (*BeaconWrapper) NeedsReconnection ¶ added in v0.0.69
func (w *BeaconWrapper) NeedsReconnection() <-chan struct{}
NeedsReconnection returns a channel that signals when reconnection is needed.
func (*BeaconWrapper) RecordSeenSubnet ¶ added in v0.0.69
func (w *BeaconWrapper) RecordSeenSubnet(subnetID uint64, slot uint64)
RecordSeenSubnet records that we've seen an attestation from a specific subnet.
type Config ¶
type Config struct {
// The address of the Beacon node to connect to.
BeaconNodeAddress string `yaml:"beaconNodeAddress"`
// BeaconNodeHeaders is a map of headers to send to the beacon node.
BeaconNodeHeaders map[string]string `yaml:"beaconNodeHeaders"`
// NetworkOverride is an optional network name to use instead of what's reported by the beacon node.
NetworkOverride string `yaml:"networkOverride,omitempty"`
// AttestationSubnetConfig controls attestation subnet-based subscription filtering.
AttestationSubnetConfig SubnetConfig `yaml:"attestationSubnet"`
}
Config defines the configuration for the Ethereum beacon node.
func NewDefaultConfig ¶ added in v0.0.69
func NewDefaultConfig() *Config
NewDefaultConfig returns a new config with default values.
type NodeIdentity ¶ added in v0.0.69
type NodeIdentity interface {
// Start fetches and stores the node identity.
Start(ctx context.Context) error
// Stop performs cleanup.
Stop() error
// GetAttnets returns the list of subscribed attestation subnet IDs.
GetAttnets() []int
}
NodeIdentity provides access to beacon node identity information.
func NewNodeIdentity ¶ added in v0.0.69
func NewNodeIdentity(log logrus.FieldLogger, address string, headers map[string]string) NodeIdentity
NewNodeIdentity creates a new NodeIdentity service.
type NodeIdentityData ¶ added in v0.0.69
type NodeIdentityData struct {
PeerID string `json:"peer_id"` //nolint:tagliatelle // beacon API uses snake_case
ENR string `json:"enr"`
P2PAddresses []string `json:"p2p_addresses"` //nolint:tagliatelle // beacon API uses snake_case
DiscoveryAddresses []string `json:"discovery_addresses"` //nolint:tagliatelle // beacon API uses snake_case
Metadata NodeIdentityMetadata `json:"metadata"`
}
NodeIdentityData represents the beacon node identity response.
type NodeIdentityMetadata ¶ added in v0.0.69
type NodeIdentityMetadata struct {
SeqNumber string `json:"seq_number"` //nolint:tagliatelle // beacon API uses snake_case
Attnets string `json:"attnets"`
Syncnets string `json:"syncnets"`
CustodyGroupCount string `json:"custody_group_count"` //nolint:tagliatelle // beacon API uses snake_case
}
NodeIdentityMetadata contains the node's metadata.
type SubnetConfig ¶ added in v0.0.69
type SubnetConfig struct {
// Enabled controls whether to check subnet participation at startup.
Enabled bool `yaml:"enabled"`
// MaxSubnets is the maximum number of subnets the node participates in.
MaxSubnets int `yaml:"maxSubnets"`
// MismatchDetectionWindow is the number of slots to track for subnet activity.
MismatchDetectionWindow int `yaml:"mismatchDetectionWindow"`
// MismatchThreshold is the number of mismatches required before triggering reconnection.
MismatchThreshold int `yaml:"mismatchThreshold"`
// MismatchCooldownSeconds is the cooldown period between reconnections in seconds.
MismatchCooldownSeconds int `yaml:"mismatchCooldownSeconds"`
// SubnetHighWaterMark allows temporary participation in additional subnets
// without triggering a restart. This accommodates validators temporarily
// joining subnets to submit attestations while protecting privacy.
SubnetHighWaterMark int `yaml:"subnetHighWaterMark"`
}
SubnetConfig controls subnet-based subscription filtering and mismatch detection.
type TopicCondition ¶ added in v0.0.69
TopicCondition is a function that determines if a topic should be subscribed to.
func CreateAttestationSubnetCondition ¶ added in v0.0.69
func CreateAttestationSubnetCondition(nodeSubnetCount int, maxSubnets int) TopicCondition
CreateAttestationSubnetCondition creates a condition based on attestation subnet participation.
type TopicConfig ¶ added in v0.0.69
type TopicConfig struct {
// AllTopics
AllTopics []string
// OptInTopics
OptInTopics []string
// AttestationEnabled controls if attestation subnet checking is enabled.
AttestationEnabled bool
// AttestationMaxSubnets is the max subnets before disabling single_attestation.
AttestationMaxSubnets int
// MismatchDetectionWindow is the number of slots to track.
MismatchDetectionWindow int
// MismatchThreshold is the number of mismatches before reconnection.
MismatchThreshold int
// MismatchCooldown is the cooldown period between reconnections.
MismatchCooldown time.Duration
// SubnetHighWaterMark is the threshold for temporary subnet participation.
SubnetHighWaterMark int
}
TopicConfig configures topic manager behavior including subnet tracking.
type TopicManager ¶ added in v0.0.69
type TopicManager interface {
RegisterCondition(topic string, condition TopicCondition)
ShouldSubscribe(ctx context.Context, topic string) bool
GetEnabledTopics(ctx context.Context) []string
ExcludeTopic(topic string)
IsExcluded(topic string) bool
SetAdvertisedSubnets(subnets []int)
RecordAttestation(subnetID uint64, slot phase0.Slot)
IsActiveSubnet(subnetID uint64) bool
NeedsReconnection() <-chan struct{}
ResetAfterReconnection()
GetCooldownPeriod() time.Duration
StartSubnetRefresh(ctx context.Context, refreshInterval time.Duration, nodeIdentityFetcher func() []int)
StopSubnetRefresh()
}
TopicManager manages topic subscriptions and tracks attestation subnets.
func NewTopicManager ¶ added in v0.0.69
func NewTopicManager(log logrus.FieldLogger, config *TopicConfig) TopicManager
NewTopicManager creates a new topic manager with subnet configuration.