Documentation
¶
Overview ¶
Package bootnode implements an Ethereum beacon chain bootnode.
This package provides a specialized discv5 bootnode implementation with:
- Fork digest filtering for Ethereum consensus layer
- Node database and persistence
- Routing table management with IP limits
- Discovery and ping services
Index ¶
- type Config
- type HandlerStats
- type Service
- func (s *Service) CheckAndAddNode(n *node.Node) bool
- func (s *Service) Discv5Service() *discv5.Service
- func (s *Service) ForkFilter() *config.ForkDigestFilter
- func (s *Service) GetAcceptedCurrent() int
- func (s *Service) GetAcceptedOld() int
- func (s *Service) GetActiveNodes() []*node.Node
- func (s *Service) GetCurrentDigest() string
- func (s *Service) GetCurrentFork() string
- func (s *Service) GetGracePeriod() string
- func (s *Service) GetNetworkName() string
- func (s *Service) GetOldDigests() map[string]time.Duration
- func (s *Service) GetRejectedExpired() int
- func (s *Service) GetRejectedInvalid() int
- func (s *Service) GetStats() ServiceStats
- func (s *Service) GetTotalChecks() int
- func (s *Service) LocalNode() *node.Node
- func (s *Service) Lookup(ctx context.Context, target node.ID) ([]*node.Node, error)
- func (s *Service) LookupWithFilter(ctx context.Context, target node.ID, k int, filter enr.ENRFilter) ([]*node.Node, error)
- func (s *Service) NodeDB() *nodedb.NodeDB
- func (s *Service) Ping(n *node.Node) (bool, time.Duration, error)
- func (s *Service) PingMultiple(nodes []*node.Node) map[node.ID]bool
- func (s *Service) RandomWalk(ctx context.Context) ([]*node.Node, error)
- func (s *Service) Start() error
- func (s *Service) Stop() error
- func (s *Service) Table() *table.FlatTable
- type ServiceStats
- type SessionStats
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// PrivateKey is the node's private key (required)
PrivateKey *ecdsa.PrivateKey
// BindIP is the IP address to bind to
BindIP net.IP
// BindPort is the UDP port to bind to
BindPort int
// ENRIP is the IPv4 address to advertise in the ENR (optional, uses BindIP if nil)
ENRIP net.IP
// ENRIP6 is the IPv6 address to advertise in the ENR (optional)
ENRIP6 net.IP
// ENRPort is the UDP port to advertise in the ENR (0 = use BindPort)
ENRPort int
// CLConfig is the consensus layer configuration for fork digest filtering
CLConfig *config.Config
// GracePeriod is how long to accept old fork digests (default 60 minutes)
GracePeriod time.Duration
// BootNodes are the initial nodes to connect to
BootNodes []*node.Node
// NodeDB is the database for storing discovered nodes (required)
NodeDB *nodedb.NodeDB
// MaxNodesPerIP is the maximum nodes allowed per IP address (default 100)
MaxNodesPerIP int
// SessionLifetime is how long sessions remain valid (default 12 hours)
SessionLifetime time.Duration
// MaxSessions is the maximum number of cached sessions (default 1000)
MaxSessions int
// PingInterval is how often to ping nodes (default 30 seconds)
PingInterval time.Duration
// MaxNodeAge is the maximum time since last seen (default 24 hours)
MaxNodeAge time.Duration
// MaxFailures is the maximum consecutive failures (default 3)
MaxFailures int
// EnableIPDiscovery enables automatic IP discovery from PONG responses (default false)
EnableIPDiscovery bool
// Logger for debug messages
Logger logrus.FieldLogger
}
Config contains configuration for the beacon bootnode.
func DefaultConfig ¶
func DefaultConfig() *Config
DefaultConfig returns a default bootnode configuration.
type HandlerStats ¶
type HandlerStats struct {
PacketsReceived int
PacketsSent int
InvalidPackets int
FilteredResponses int
FindNodeReceived int
PendingHandshakes int
PendingChallenges int
}
HandlerStats contains protocol handler statistics.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service is the beacon chain bootnode service.
It wraps the generic discv5 library with beacon chain specific features:
- Fork digest filtering
- Node database and persistence
- Routing table with IP limits
- Discovery and ping services
func New ¶
New creates a new beacon bootnode service.
Example:
config := bootnode.DefaultConfig()
config.PrivateKey = privKey
config.CLConfig = clConfig
service, err := bootnode.New(config)
if err != nil {
log.Fatal(err)
}
defer service.Stop()
func (*Service) CheckAndAddNode ¶
CheckAndAddNode performs all admission checks and adds node to table if it passes.
This method handles:
- Admission filter validation (fork digest)
- DB existence check for updates
- IP limit validation
- Ping-before-add for new nodes when pool is full
- Adding to routing table if all checks pass
func (*Service) Discv5Service ¶
Discv5Service returns the underlying discv5 service.
func (*Service) ForkFilter ¶
func (s *Service) ForkFilter() *config.ForkDigestFilter
ForkFilter returns the fork digest filter.
func (*Service) GetAcceptedCurrent ¶
func (*Service) GetAcceptedOld ¶
func (*Service) GetActiveNodes ¶
GetActiveNodes returns the active nodes from the routing table. Only active nodes are returned (inactive nodes in DB are not shown).
func (*Service) GetCurrentDigest ¶
func (*Service) GetCurrentFork ¶
func (*Service) GetGracePeriod ¶
func (*Service) GetNetworkName ¶
func (*Service) GetRejectedExpired ¶
func (*Service) GetRejectedInvalid ¶
func (*Service) GetStats ¶
func (s *Service) GetStats() ServiceStats
GetStats returns service statistics for display.
func (*Service) GetTotalChecks ¶
func (*Service) LookupWithFilter ¶
func (s *Service) LookupWithFilter(ctx context.Context, target node.ID, k int, filter enr.ENRFilter) ([]*node.Node, error)
LookupWithFilter performs a lookup with an ENR filter.
func (*Service) PingMultiple ¶
PingMultiple sends PINGs to multiple nodes in parallel.
func (*Service) RandomWalk ¶
RandomWalk performs a random walk to discover new nodes.
func (*Service) Start ¶
Start starts the bootnode service.
This starts all background tasks:
- Discv5 protocol handler
- Fork digest periodic updates
- Node discovery and maintenance
type ServiceStats ¶
type ServiceStats struct {
PeerID string
BindAddress string
Uptime time.Duration
TableSize int
BucketsFilled int // Deprecated for FlatTable
ActiveNodes int
InactiveNodes int
TableStats table.TableStats
LookupStats discover.LookupStats
PingStats discover.PingStats
SessionStats SessionStats
HandlerStats HandlerStats
ForkFilter *config.ForkFilterStats
NodeDBStats nodedb.NodeDBStats
}
ServiceStats contains statistics about the bootnode service.
type SessionStats ¶
SessionStats contains session-related statistics.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package clconfig provides Ethereum Consensus Layer configuration parsing.
|
Package clconfig provides Ethereum Consensus Layer configuration parsing. |
|
Package discover implements node discovery operations for discv5.
|
Package discover implements node discovery operations for discv5. |