op

package
v0.0.0-...-b1a9763 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 4, 2025 License: Apache-2.0, MIT Imports: 44 Imported by: 0

Documentation

Index

Constants

View Source
const DecayToZero = 0.01

DecayToZero is the decay factor for a peer's score to zero.

Variables

View Source
var MessageDomainInvalidSnappy = [4]byte{0, 0, 0, 0}
View Source
var MessageDomainValidSnappy = [4]byte{1, 0, 0, 0}

Functions

func MsgID

func MsgID(pmsg *pubsubpb.Message) string

func ScoreDecay

func ScoreDecay(duration time.Duration, slot time.Duration) float64

ScoreDecay returns the decay factor for a given duration.

Types

type DiscoveredPeer

type DiscoveredPeer struct {
	AddrInfo peer.AddrInfo
	ENR      *enode.Node
}

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)

func (*Discovery) Serve

func (d *Discovery) Serve(ctx context.Context) (err error)

type DiscoveryConfig

type DiscoveryConfig struct {
	ChainID uint64
	Addr    string
	UDPPort int
	TCPPort int
	Seeds   []*enode.Node
	Tracer  trace.Tracer
	Meter   metric.Meter
}

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

func (n *Node) CanSubscribe(topic string) bool

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.

func (*Node) OnEvent

func (n *Node) OnEvent(cb func(ctx context.Context, event *host.TraceEvent))

OnEvent registers a callback that is executed when an event is received.

func (*Node) Start

func (n *Node) Start(ctx context.Context) error

Start starts the listening process.

type NodeConfig

type NodeConfig struct {
	// The private key for the libp2p host and local enode in hex format
	PrivateKeyStr string

	ChainID       int
	BlockTopics   []string
	Bootstrappers []*enode.Node

	// 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
	PubSubValidateQueueSize     int
	DirectConnections           []string

	// PeerFilter configuration for filtering peers (passed to host)
	PeerFilter *host.FilterConfig

	// Pause between two discovery lookups
	LookupInterval time.Duration

	// The Data Stream configuration
	DataStreamType host.DataStreamType
	AWSConfig      *aws.Config
	S3Config       *host.S3DSConfig
	KinesisRegion  string
	KinesisStream  string

	// Telemetry accessors
	Tracer trace.Tracer
	Meter  metric.Meter
	// contains filtered or unexported fields
}

func (*NodeConfig) DirectMultiaddrs

func (n *NodeConfig) DirectMultiaddrs() []peer.AddrInfo

DirectMultiaddrs returns the []peer.AddrInfo for the given direct connction peers

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 OpStackENRData

type OpStackENRData struct {
	// contains filtered or unexported fields
}

func (*OpStackENRData) DecodeRLP

func (o *OpStackENRData) DecodeRLP(s *rlp.Stream) error

func (*OpStackENRData) ENRKey

func (o *OpStackENRData) ENRKey() string

func (*OpStackENRData) EncodeRLP

func (o *OpStackENRData) EncodeRLP(w io.Writer) error

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.

func (*PeerDialer) Serve

func (p *PeerDialer) Serve(ctx context.Context) error

type PubSub

type PubSub struct {
	// contains filtered or unexported fields
}

func NewPubSub

func NewPubSub(h *host.Host, cfg *PubSubConfig) (*PubSub, error)

func (*PubSub) Serve

func (p *PubSub) Serve(ctx context.Context) error

type PubSubConfig

type PubSubConfig struct {
	ChainID     int
	BlockTopics []string
	DataStream  host.DataStream
}

func (PubSubConfig) Validate

func (p PubSubConfig) Validate() error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL