fil

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: 42 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GossipScoreThreshold             = -500
	PublishScoreThreshold            = -1000
	GraylistScoreThreshold           = -2500
	AcceptPXScoreThreshold           = 1000
	OpportunisticGraftScoreThreshold = 3.5
)

Borrowed from lotus

Variables

View Source
var (
	GPBFTMessageIdFn         = pubsubMsgIdHashData
	ChainExchangeMessageIdFn = pubsubMsgIdHashData
)
View Source
var PubsubPeerScoreParams = &pubsub.PeerScoreParams{
	AppSpecificScore:  func(p peer.ID) float64 { return 0 },
	AppSpecificWeight: 1,

	IPColocationFactorThreshold: 5,
	IPColocationFactorWeight:    -100,
	IPColocationFactorWhitelist: nil,

	BehaviourPenaltyThreshold: 6,
	BehaviourPenaltyWeight:    -10,
	BehaviourPenaltyDecay:     pubsub.ScoreParameterDecay(time.Hour),

	DecayInterval: pubsub.DefaultDecayInterval,
	DecayToZero:   pubsub.DefaultDecayToZero,

	RetainScore: 6 * time.Hour,

	Topics: make(map[string]*pubsub.TopicScoreParams),
}

Borrowed from lotus

View Source
var PubsubPeerScoreThresholds = &pubsub.PeerScoreThresholds{
	GossipThreshold:             GossipScoreThreshold,
	PublishThreshold:            PublishScoreThreshold,
	GraylistThreshold:           GraylistScoreThreshold,
	AcceptPXThreshold:           AcceptPXScoreThreshold,
	OpportunisticGraftThreshold: OpportunisticGraftScoreThreshold,
}
View Source
var PubsubTopicScoreParams = &pubsub.TopicScoreParams{

	TopicWeight: 0.1,

	TimeInMeshWeight:  0.0002778,
	TimeInMeshQuantum: time.Second,
	TimeInMeshCap:     1,

	FirstMessageDeliveriesWeight: 0.5,
	FirstMessageDeliveriesDecay:  pubsub.ScoreParameterDecay(10 * time.Minute),
	FirstMessageDeliveriesCap:    100,

	InvalidMessageDeliveriesWeight: -1000,
	InvalidMessageDeliveriesDecay:  pubsub.ScoreParameterDecay(time.Hour),
}

Borrowed from lotus

Functions

This section is empty.

Types

type CBOR

type CBOR[T CBORMarshalUnmarshaler] struct{}

func NewCBOR

func NewCBOR[T CBORMarshalUnmarshaler]() *CBOR[T]

func (*CBOR[T]) Decode

func (c *CBOR[T]) Decode(v []byte, t T) (_err error)

func (*CBOR[T]) Encode

func (c *CBOR[T]) Encode(m T) (_ []byte, _err error)

type CBORMarshalUnmarshaler

type CBORMarshalUnmarshaler interface {
	cbg.CBORMarshaler
	cbg.CBORUnmarshaler
}

type Discovery

type Discovery struct {

	// Metrics
	MeterLookups metric.Int64Counter
	// contains filtered or unexported fields
}

func NewDiscovery

func NewDiscovery(h host.Host, cfg *DiscoveryConfig) (*Discovery, error)

func (*Discovery) Serve

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

type DiscoveryConfig

type DiscoveryConfig struct {
	Interval time.Duration
	Tracer   trace.Tracer
	Meter    metric.Meter
}

type EncodeDecoder

type EncodeDecoder[T CBORMarshalUnmarshaler] interface {
	Encode(v T) ([]byte, error)
	Decode([]byte, T) 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

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) Connected

func (n *Node) Connected(net network.Network, c network.Conn)

func (*Node) Disconnected

func (n *Node) Disconnected(net network.Network, c network.Conn)

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) Listen

func (n *Node) Listen(net network.Network, maddr ma.Multiaddr)

func (*Node) ListenClose

func (n *Node) ListenClose(net network.Network, maddr ma.Multiaddr)

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

	Bootstrappers []peer.AddrInfo

	// General timeout when communicating with other network participants
	DialTimeout time.Duration

	// Topic configurations to subscribe to
	TopicConfigs map[string]*TopicConfig

	// The address information of the local libp2p host
	Libp2pHost                  string
	Libp2pPort                  int
	Libp2pPeerscoreSnapshotFreq time.Duration

	// The size of the validate queue
	PubSubValidateQueueSize int

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

	DirectConnections []string

	// Whether to enable the periodic lookups
	DiscoveryActorEnabled bool

	// 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 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 {
	TopicConfigs map[string]*TopicConfig
	DataStream   host.DataStream
}

func (PubSubConfig) Validate

func (p PubSubConfig) Validate() error

type TopicConfig

type TopicConfig struct {
	ScoreParams *pubsub.TopicScoreParams
	Options     []pubsub.TopicOpt
}

type ZSTD

type ZSTD[T CBORMarshalUnmarshaler] struct {
	// contains filtered or unexported fields
}

func NewZSTD

func NewZSTD[T CBORMarshalUnmarshaler]() (*ZSTD[T], error)

func (*ZSTD[T]) Decode

func (c *ZSTD[T]) Decode(compressed []byte, t T) (_err error)

func (*ZSTD[T]) Encode

func (c *ZSTD[T]) Encode(t T) (_ []byte, _err error)

Jump to

Keyboard shortcuts

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