Documentation ¶
Index ¶
- Variables
- func GetCurrentForkVersion(epoch primitives.Epoch, beaconConfg *params.BeaconChainConfig) ([4]byte, error)
- type AddrWatcher
- type ContextStreamHandler
- type DiscoveredPeer
- type Discovery
- type DiscoveryConfig
- type ForkVersion
- type GenericBeaconBlock
- type GenericSignedBeaconBlock
- type GenesisConfig
- type Node
- func (n *Node) CanSubscribe(topic string) bool
- func (n *Node) Connected(net network.Network, c network.Conn)
- func (n *Node) Disconnected(net network.Network, c network.Conn)
- func (n *Node) FilterIncomingSubscriptions(id peer.ID, subs []*pubsubpb.RPC_SubOpts) ([]*pubsubpb.RPC_SubOpts, error)
- func (n *Node) Listen(net network.Network, maddr ma.Multiaddr)
- func (n *Node) ListenClose(net network.Network, maddr ma.Multiaddr)
- func (n *Node) Start(ctx context.Context) error
- type NodeConfig
- type PeerDialer
- type Peerer
- type PrysmClient
- func (p *PrysmClient) AddTrustedPeer(ctx context.Context, pid peer.ID, maddr ma.Multiaddr) (err error)
- func (p *PrysmClient) ChainHead(ctx context.Context) (chainHead *eth.ChainHead, err error)
- func (p *PrysmClient) Identity(ctx context.Context) (addrInfo *peer.AddrInfo, err error)
- func (p *PrysmClient) ListTrustedPeers(ctx context.Context) (peers map[peer.ID]*structs.Peer, err error)
- func (p *PrysmClient) RemoveTrustedPeer(ctx context.Context, pid peer.ID) (err error)
- type PubSub
- type PubSubConfig
- type ReqResp
- func (r *ReqResp) MetaData(ctx context.Context, pid peer.ID) (resp *pb.MetaDataV1, err error)
- func (r *ReqResp) Ping(ctx context.Context, pid peer.ID) (err error)
- func (r *ReqResp) RegisterHandlers(ctx context.Context) error
- func (r *ReqResp) SetMetaData(seq uint64)
- func (r *ReqResp) SetStatus(status *pb.Status)
- func (r *ReqResp) Status(ctx context.Context, pid peer.ID) (status *pb.Status, err error)
- type ReqRespConfig
Constants ¶
This section is empty.
Variables ¶
var GenesisConfigs = map[string]*GenesisConfig{ params.MainnetName: { GenesisValidatorRoot: hexToBytes("4b363db94e286120d76eb905340fdd4e54bfe9f06bf33ff6cf5ad27f511bfe95"), GenesisTime: time.Unix(1606824023, 0), }, params.SepoliaName: { GenesisValidatorRoot: hexToBytes("d8ea171f3c94aea21ebc42a1ed61052acf3f9209c00e4efbaaddac09ed9b8078"), GenesisTime: time.Unix(1655733600, 0), }, params.PraterName: { GenesisValidatorRoot: hexToBytes("043db0d9a83813551ee2f33450d23797757d430911a9320530ad8a0eabc43efb"), GenesisTime: time.Unix(1616508000, 0), }, params.HoleskyName: { GenesisValidatorRoot: hexToBytes("9143aa7c615a7f7115e2b6aac319c03529df8242ae705fba9df39b79c59fa8b1"), GenesisTime: time.Unix(1695902400, 0), }, }
Functions ¶
func GetCurrentForkVersion ¶
func GetCurrentForkVersion(epoch primitives.Epoch, beaconConfg *params.BeaconChainConfig) ([4]byte, error)
Types ¶
type AddrWatcher ¶
type AddrWatcher struct {
// contains filtered or unexported fields
}
type ContextStreamHandler ¶
type DiscoveredPeer ¶
func NewDiscoveredPeer ¶
func NewDiscoveredPeer(node *enode.Node) (*DiscoveredPeer, error)
type Discovery ¶
type Discovery struct { // Metrics MeterDiscoveredPeers metric.Int64Counter // contains filtered or unexported fields }
Discovery is a suture service that periodically queries the discv5 DHT for random peers and publishes the discovered peers on the `out` channel. Users of this Discovery service are required to read from the channel. Otherwise, the discovery will block forever.
func NewDiscovery ¶
func NewDiscovery(privKey *ecdsa.PrivateKey, cfg *DiscoveryConfig) (*Discovery, error)
type DiscoveryConfig ¶
type DiscoveryConfig struct { GenesisConfig *GenesisConfig NetworkConfig *params.NetworkConfig Addr string UDPPort int TCPPort int Tracer trace.Tracer Meter metric.Meter }
func (*DiscoveryConfig) BootstrapNodes ¶
func (d *DiscoveryConfig) BootstrapNodes() ([]*enode.Node, error)
type ForkVersion ¶
type ForkVersion [4]byte
list of ForkVersions 1st byte trick
var ( Phase0ForkVersion ForkVersion AltairForkVersion ForkVersion BellatrixForkVersion ForkVersion CapellaForkVersion ForkVersion DenebForkVersion ForkVersion )
func (ForkVersion) String ¶
func (fv ForkVersion) String() string
type GenericBeaconBlock ¶
type GenericBeaconBlock interface { GetSlot() primitives.Slot GetProposerIndex() primitives.ValidatorIndex }
type GenericSignedBeaconBlock ¶
type GenericSignedBeaconBlock interface {
GetBlock() GenericBeaconBlock
}
type GenesisConfig ¶
type GenesisConfig struct { GenesisValidatorRoot []byte // Merkle Root at Genesis GenesisTime time.Time // Time at Genesis }
GenesisConfig represents the Genesis configuration with the Merkle Root at Genesis and the Time at Genesis.
func GetConfigsByNetworkName ¶
func GetConfigsByNetworkName(net string) (*GenesisConfig, *params.NetworkConfig, *params.BeaconChainConfig, error)
GetConfigsByNetworkName returns the GenesisConfig, NetworkConfig, BeaconChainConfig and any error based on the input network name
type Node ¶
type Node struct {
// contains filtered or unexported fields
}
Node is the main entry point to listening to the Ethereum GossipSub mesh.
func NewNode ¶
func NewNode(cfg *NodeConfig) (*Node, error)
NewNode initializes a new Node using the provided configuration. It first validates the node configuration. Then it initializes the libp2p host using the libp2p options from the given configuration object. Next, it initializes the Ethereum node by extracting the ECDSA private key, creating a new discovery service, creating a new ReqResp server, creating a new PubSub server, and creating a new Prysm client. Finally, it initializes the Hermes node by setting the configuration and dependencies.
func (*Node) CanSubscribe ¶
CanSubscribe originally returns true if the topic is of interest, and we could subscribe to it.
func (*Node) FilterIncomingSubscriptions ¶
func (n *Node) FilterIncomingSubscriptions(id peer.ID, subs []*pubsubpb.RPC_SubOpts) ([]*pubsubpb.RPC_SubOpts, error)
FilterIncomingSubscriptions is invoked for all RPCs containing subscription notifications. This method returns only the topics of interest and may return an error if the subscription request contains too many topics.
type NodeConfig ¶
type NodeConfig struct { // A custom struct that holds information about the GenesisTime and GenesisValidatorRoot hash GenesisConfig *GenesisConfig // The beacon network config which holds, e.g., information about certain // ENR keys and the list of bootstrap nodes NetworkConfig *params.NetworkConfig // The beacon chain configuration that holds tons of information. Check out its definition BeaconConfig *params.BeaconChainConfig // The fork digest of the network Hermes participates in ForkDigest [4]byte ForkVersion ForkVersion // The private key for the libp2p host and local enode in hex format PrivateKeyStr string // General timeout when communicating with other network participants DialTimeout time.Duration // The address information of the local ethereuem [enode.Node]. Devp2pHost string Devp2pPort int // The address information of the local libp2p host Libp2pHost string Libp2pPort int Libp2pPeerscoreSnapshotFreq time.Duration // Message encoders GossipSubMessageEncoder encoder.NetworkEncoding RPCEncoder encoder.NetworkEncoding // The address information where the Beacon API or Prysm's custom API is accessible at PrysmHost string PrysmPortHTTP int PrysmPortGRPC int // The AWS Kinesis Data Stream configuration AWSConfig *aws.Config // if set, we consider Kinesis to be enabled KinesisRegion string KinesisStream string // The maximum number of peers our libp2p host can be connected to. MaxPeers int // Limits the number of concurrent connection establishment routines. When // we discover peers over discv5 and are not at our MaxPeers limit we try // to establish a connection to a peer. However, we limit the concurrency to // this DialConcurrency value. DialConcurrency int // It is set at this limit to handle the possibility // of double topic subscriptions at fork boundaries. // -> 64 Attestation Subnets * 2. // -> 4 Sync Committee Subnets * 2. // -> Block,Aggregate,ProposerSlashing,AttesterSlashing,Exits,SyncContribution * 2. PubSubSubscriptionRequestLimit int PubSubQueueSize int // Telemetry accessors Tracer trace.Tracer Meter metric.Meter // contains filtered or unexported fields }
func (*NodeConfig) ECDSAPrivateKey ¶
func (n *NodeConfig) ECDSAPrivateKey() (*ecdsa.PrivateKey, error)
ECDSAPrivateKey returns the ECDSA private key associated with the NodeConfig. It retrieves the private key using the PrivateKey method and then converts it to ECDSA format. If there is an error retrieving the private key or converting it to ECDSA format, an error is returned.
func (*NodeConfig) PrivateKey ¶
func (n *NodeConfig) PrivateKey() (*crypto.Secp256k1PrivateKey, error)
PrivateKey returns a parsed Secp256k1 private key from the given PrivateKeyStr. If that's unset, a new one will be generated. In any case, the result will be cached, so that the private key won't be generated twice.
func (*NodeConfig) Validate ¶
func (n *NodeConfig) Validate() error
Validate validates the NodeConfig Node configuration.
type PeerDialer ¶
type PeerDialer struct {
// contains filtered or unexported fields
}
PeerDialer is a suture service that reads peers from the peerChan (which is filled by the Discovery service until that peerChan channel is closed. When PeerDialer sees a new peer, it does a few sanity checks and tries to establish a connection.
type Peerer ¶
type Peerer struct {
// contains filtered or unexported fields
}
Peerer is a suture service that ensures Hermes' registration as a trusted peer with the beacon node. Based on the type of beacon node, different [PeererClient] implementations can be used. In the case of Prysm, use the PrysmClient implementation as it implements [PeererClient].
type PrysmClient ¶
type PrysmClient struct {
// contains filtered or unexported fields
}
PrysmClient is an HTTP client for Prysm's JSON RPC API.
func NewPrysmClient ¶
func (*PrysmClient) AddTrustedPeer ¶
func (*PrysmClient) ListTrustedPeers ¶
func (*PrysmClient) RemoveTrustedPeer ¶
type PubSubConfig ¶
type PubSubConfig struct { Topics []string ForkVersion ForkVersion Encoder encoder.NetworkEncoding SecondsPerSlot time.Duration GenesisTime time.Time DataStream host.DataStream }
func (PubSubConfig) Validate ¶
func (p PubSubConfig) Validate() error
type ReqResp ¶
type ReqResp struct {
// contains filtered or unexported fields
}
ReqResp implements the request response domain of the eth2 RPC spec: https://github.com/ethereum/consensus-specs/blob/dev/specs/phase0/p2p-interface.md
func NewReqResp ¶
func NewReqResp(h host.Host, cfg *ReqRespConfig) (*ReqResp, error)
func (*ReqResp) RegisterHandlers ¶
RegisterHandlers registers all RPC handlers. It checks first if all preconditions are met. This includes valid initial status and metadata values.
func (*ReqResp) SetMetaData ¶
type ReqRespConfig ¶
type ReqRespConfig struct { ForkDigest [4]byte Encoder encoder.NetworkEncoding DataStream hermeshost.DataStream ReadTimeout time.Duration WriteTimeout time.Duration // Telemetry accessors Tracer trace.Tracer Meter metric.Meter }