Documentation ¶
Index ¶
- Variables
- func FetchBootnodeENRsFromURL(ctx context.Context, url string) ([]string, error)
- func FetchConfigFromURL(ctx context.Context, url string) (*params.BeaconChainConfig, error)
- func FetchDepositContractBlockFromURL(ctx context.Context, url string) (uint64, error)
- func FetchGenesisDetailsFromURL(ctx context.Context, url string) (uint64, [32]byte, error)
- func GetCurrentForkVersion(epoch primitives.Epoch, beaconConfg *params.BeaconChainConfig) ([4]byte, error)
- func NewFullOutput(cfg *PubSubConfig) host.DataStreamRenderer
- func NewKinesisOutput(cfg *PubSubConfig) host.DataStreamRenderer
- type AddrWatcher
- type ContextStreamHandler
- type DevnetOptions
- type DiscoveredPeer
- type Discovery
- type DiscoveryConfig
- type ForkVersion
- type FullOutput
- type GenesisConfig
- type KinesisOutput
- type NetworkConfig
- 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) OnEvent(cb func(ctx context.Context, event *host.TraceEvent))
- 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) BlocksByRangeV2(ctx context.Context, pid peer.ID, firstSlot, lastSlot uint64) ([]interfaces.ReadOnlySignedBeaconBlock, error)
- 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
- type TraceEventAltairBlock
- type TraceEventAttestation
- type TraceEventAttesterSlashing
- type TraceEventBLSToExecutionChange
- type TraceEventBellatrixBlock
- type TraceEventBlobSidecar
- type TraceEventCapellaBlock
- type TraceEventDenebBlock
- type TraceEventPhase0Block
- type TraceEventProposerSlashing
- type TraceEventSignedAggregateAttestationAndProof
- type TraceEventSignedContributionAndProof
- type TraceEventSyncCommitteeMessage
- type TraceEventVoluntaryExit
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.HoleskyName: { GenesisValidatorRoot: hexToBytes("9143aa7c615a7f7115e2b6aac319c03529df8242ae705fba9df39b79c59fa8b1"), GenesisTime: time.Unix(1695902400, 0), }, }
Functions ¶
func FetchBootnodeENRsFromURL ¶
FetchBootnodeENRsFromURL fetches the bootnode ENRs from a given URL.
func FetchConfigFromURL ¶
FetchConfigFromURL fetches the beacon chain config from a given URL.
func FetchDepositContractBlockFromURL ¶
FetchDepositContractBlockFromURL fetches the deposit contract block from a given URL.
func FetchGenesisDetailsFromURL ¶
FetchGenesisDetailsFromURL fetches the genesis time and validators root from a given URL.
func GetCurrentForkVersion ¶
func GetCurrentForkVersion(epoch primitives.Epoch, beaconConfg *params.BeaconChainConfig) ([4]byte, error)
func NewFullOutput ¶
func NewFullOutput(cfg *PubSubConfig) host.DataStreamRenderer
NewFullOutput creates a new instance of FullOutput.
func NewKinesisOutput ¶
func NewKinesisOutput(cfg *PubSubConfig) host.DataStreamRenderer
NewKinesisOutput creates a new instance of KinesisOutput.
Types ¶
type AddrWatcher ¶
type AddrWatcher struct {
// contains filtered or unexported fields
}
type ContextStreamHandler ¶
type DevnetOptions ¶
type DevnetOptions struct { ConfigURL string BootnodesURL string DepositContractBlockURL string GenesisSSZURL string }
func (*DevnetOptions) Validate ¶
func (o *DevnetOptions) Validate() error
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 GetForkVersionFromForkDigest ¶
func GetForkVersionFromForkDigest(forkD [4]byte) (forkV ForkVersion, err error)
func (ForkVersion) String ¶
func (fv ForkVersion) String() string
type FullOutput ¶
type FullOutput struct {
// contains filtered or unexported fields
}
FullOutput is a renderer for full output.
func (*FullOutput) RenderPayload ¶
func (t *FullOutput) RenderPayload(evt *host.TraceEvent, msg *pubsub.Message, dst ssz.Unmarshaler) (*host.TraceEvent, error)
RenderPayload renders message into the destination.
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.
type KinesisOutput ¶
type KinesisOutput struct {
// contains filtered or unexported fields
}
KinesisOutput is a renderer for Kinesis output.
func (*KinesisOutput) RenderPayload ¶
func (k *KinesisOutput) RenderPayload(evt *host.TraceEvent, msg *pubsub.Message, dst ssz.Unmarshaler) (*host.TraceEvent, error)
RenderPayload renders message into the destination.
type NetworkConfig ¶
type NetworkConfig struct { Genesis *GenesisConfig Network *params.NetworkConfig Beacon *params.BeaconChainConfig }
func DeriveDevnetConfig ¶
func DeriveDevnetConfig(ctx context.Context, options DevnetOptions) (*NetworkConfig, error)
func DeriveKnownNetworkConfig ¶
func DeriveKnownNetworkConfig(ctx context.Context, network string) (*NetworkConfig, error)
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 LocalTrustedAddr bool PrysmHost string PrysmPortHTTP int PrysmPortGRPC int // The Data Stream configuration DataStreamType host.DataStreamType AWSConfig *aws.Config 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].
func NewPeerer ¶
func NewPeerer(h *host.Host, pryClient *PrysmClient, localTrustedAddr bool) *Peerer
NewPeerer creates a new instance of the Peerer struct. It takes a pointer to a *host.Host and a [PeererClient] implementation as parameters. It returns a pointer to the newly created Peerer instance.
type PrysmClient ¶
type PrysmClient struct {
// contains filtered or unexported fields
}
PrysmClient is an HTTP client for Prysm's JSON RPC API.
func NewPrysmClient ¶
func NewPrysmClient(host string, portHTTP int, portGRPC int, timeout time.Duration, genesis *GenesisConfig) (*PrysmClient, error)
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) BlocksByRangeV2 ¶
func (r *ReqResp) BlocksByRangeV2(ctx context.Context, pid peer.ID, firstSlot, lastSlot uint64) ([]interfaces.ReadOnlySignedBeaconBlock, 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 }
type TraceEventAltairBlock ¶
type TraceEventAltairBlock struct { host.TraceEventPayloadMetaData Block *ethtypes.SignedBeaconBlockAltair }
type TraceEventAttestation ¶
type TraceEventAttestation struct { host.TraceEventPayloadMetaData Attestation *ethtypes.Attestation }
type TraceEventAttesterSlashing ¶
type TraceEventAttesterSlashing struct { host.TraceEventPayloadMetaData AttesterSlashing *ethtypes.AttesterSlashing }
type TraceEventBLSToExecutionChange ¶
type TraceEventBLSToExecutionChange struct { host.TraceEventPayloadMetaData BLSToExecutionChange *ethtypes.BLSToExecutionChange }
type TraceEventBellatrixBlock ¶
type TraceEventBellatrixBlock struct { host.TraceEventPayloadMetaData Block *ethtypes.SignedBeaconBlockBellatrix }
type TraceEventBlobSidecar ¶
type TraceEventBlobSidecar struct { host.TraceEventPayloadMetaData BlobSidecar *ethtypes.BlobSidecar }
type TraceEventCapellaBlock ¶
type TraceEventCapellaBlock struct { host.TraceEventPayloadMetaData Block *ethtypes.SignedBeaconBlockCapella }
type TraceEventDenebBlock ¶
type TraceEventDenebBlock struct { host.TraceEventPayloadMetaData Block *ethtypes.SignedBeaconBlockDeneb }
type TraceEventPhase0Block ¶
type TraceEventPhase0Block struct { host.TraceEventPayloadMetaData Block *ethtypes.SignedBeaconBlock }
type TraceEventProposerSlashing ¶
type TraceEventProposerSlashing struct { host.TraceEventPayloadMetaData ProposerSlashing *ethtypes.ProposerSlashing }
type TraceEventSignedAggregateAttestationAndProof ¶
type TraceEventSignedAggregateAttestationAndProof struct { host.TraceEventPayloadMetaData SignedAggregateAttestationAndProof *ethtypes.SignedAggregateAttestationAndProof }
type TraceEventSignedContributionAndProof ¶
type TraceEventSignedContributionAndProof struct { host.TraceEventPayloadMetaData SignedContributionAndProof *ethtypes.SignedContributionAndProof }
type TraceEventSyncCommitteeMessage ¶
type TraceEventSyncCommitteeMessage struct { host.TraceEventPayloadMetaData SyncCommitteeMessage *ethtypes.SyncCommitteeMessage }
type TraceEventVoluntaryExit ¶
type TraceEventVoluntaryExit struct { host.TraceEventPayloadMetaData VoluntaryExit *ethtypes.VoluntaryExit }