Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // MetricsAllConnectedPeers counts all connected peers MetricsAllConnectedPeers = promauto.NewGauge(prometheus.GaugeOpts{ Name: "ssv_p2p_all_connected_peers", Help: "Count connected peers", }) // MetricsConnectedPeers counts connected peers for a topic MetricsConnectedPeers = promauto.NewGaugeVec(prometheus.GaugeOpts{ Name: "ssv_p2p_connected_peers", Help: "Count connected peers for a validator", }, []string{"pubKey"}) // MetricsPeersIdentity tracks peers identity MetricsPeersIdentity = promauto.NewGaugeVec(prometheus.GaugeOpts{ Name: "ssv:network:peers_identity", Help: "Peers identity", }, []string{"pubKey", "operatorID", "v", "pid", "type"}) )
Functions ¶
Types ¶
type Config ¶
type Config struct { Ctx context.Context Bootnodes string `yaml:"Bootnodes" env:"BOOTNODES" env-description:"Bootnodes to use to start discovery, seperated with ';'" env-default:""` Discovery string `yaml:"Discovery" env:"P2P_DISCOVERY" env-description:"Discovery system to use" env-default:"discv5"` TCPPort int `yaml:"TcpPort" env:"TCP_PORT" env-default:"13001" env-description:"TCP port for p2p transport"` UDPPort int `yaml:"UdpPort" env:"UDP_PORT" env-default:"12001" env-description:"UDP port for discovery"` HostAddress string `yaml:"HostAddress" env:"HOST_ADDRESS" env-description:"External ip node is exposed for discovery"` HostDNS string `yaml:"HostDNS" env:"HOST_DNS" env-description:"External DNS node is exposed for discovery"` RequestTimeout time.Duration `yaml:"RequestTimeout" env:"P2P_REQUEST_TIMEOUT" env-default:"10s"` MaxBatchResponse uint64 `` /* 133-byte string literal not displayed */ MaxPeers int `yaml:"MaxPeers" env:"P2P_MAX_PEERS" env-default:"60" env-description:"Connected peers limit for connections"` TopicMaxPeers int `yaml:"TopicMaxPeers" env:"P2P_TOPIC_MAX_PEERS" env-default:"10" env-description:"Connected peers limit per pubsub topic"` // Subnets is a static bit list of subnets that this node will register upon start. Subnets string `yaml:"Subnets" env:"SUBNETS" env-description:"Hex string that represents the subnets that this node will join upon start"` // PubSubScoring is a flag to turn on/off pubsub scoring PubSubScoring bool `yaml:"PubSubScoring" env:"PUBSUB_SCORING" env-default:"true" env-description:"Flag to turn on/off pubsub scoring"` // PubSubTrace is a flag to turn on/off pubsub tracing in logs PubSubTrace bool `yaml:"PubSubTrace" env:"PUBSUB_TRACE" env-description:"Flag to turn on/off pubsub tracing in logs"` // DiscoveryTrace is a flag to turn on/off discovery tracing in logs DiscoveryTrace bool `yaml:"DiscoveryTrace" env:"DISCOVERY_TRACE" env-description:"Flag to turn on/off discovery tracing in logs"` // NetworkPrivateKey is used for network identity, MUST be injected NetworkPrivateKey *ecdsa.PrivateKey // OperatorPrivateKey is used for operator identity, MUST be injected OperatorPrivateKey *rsa.PrivateKey // OperatorPubKeyHash is hash of operator public key, used for identity, optional OperatorPubKeyHash string // OperatorID contains numeric operator ID OperatorID func() spectypes.OperatorID // Router propagate incoming network messages to the responsive components Router network.MessageRouter // UserAgent to use by libp2p identify protocol UserAgent string // NodeStorage is used to get operator metadata. NodeStorage storage.Storage // Network defines a network configuration. Network networkconfig.NetworkConfig // MessageValidator validates incoming messages. MessageValidator validation.MessageValidator // Metrics report metrics. Metrics metricsreporter.MetricsReporter PubsubMsgCacheTTL time.Duration `yaml:"PubsubMsgCacheTTL" env:"PUBSUB_MSG_CACHE_TTL" env-description:"How long a message ID will be remembered as seen"` PubsubOutQueueSize int `` /* 128-byte string literal not displayed */ PubsubValidationQueueSize int `` /* 129-byte string literal not displayed */ PubsubValidateThrottle int `` /* 135-byte string literal not displayed */ // FullNode determines whether the network should sync decided history from peers. // If false, SyncDecidedByRange becomes a no-op. FullNode bool GetValidatorStats network.GetValidatorStats Permissioned func() bool // this is not loaded from config file but set up in full node setup // PeerScoreInspector is called periodically to inspect the peer scores. PeerScoreInspector func(peerMap map[peer.ID]*pubsub.PeerScoreSnapshot) // PeerScoreInspectorInterval is the interval at which the PeerScoreInspector is called. PeerScoreInspectorInterval time.Duration }
Config holds the configuration options for p2p network
func NewNetConfig ¶ added in v0.2.0
func NewNetConfig(keys testing.NodeKeys, operatorPubKeyHash string, bn *discovery.Bootnode, tcpPort, udpPort, maxPeers int) *Config
NewNetConfig creates a new config for tests
func (*Config) Libp2pOptions ¶ added in v0.2.0
Libp2pOptions creates options list for the libp2p host these are the most basic options required to start a network instance, other options and libp2p components can be configured on top
func (*Config) TransformBootnodes ¶ added in v0.2.0
TransformBootnodes converts bootnodes string and convert it to slice
type HostProvider ¶ added in v0.2.0
HostProvider holds host instance
type LocalNet ¶ added in v0.2.0
type LocalNet struct { NodeKeys []testing.NodeKeys Bootnode *discovery.Bootnode Nodes []network.P2PNetwork // contains filtered or unexported fields }
LocalNet holds the nodes in the local network
func CreateAndStartLocalNet ¶ added in v0.2.0
func CreateAndStartLocalNet(pCtx context.Context, logger *zap.Logger, options LocalNetOptions) (*LocalNet, error)
CreateAndStartLocalNet creates a new local network and starts it if any errors occurs during starting local network CreateAndStartLocalNet trying to create and start local net one more time until pCtx is not Done()
func NewLocalNet ¶ added in v0.2.0
func NewLocalNet(ctx context.Context, logger *zap.Logger, options LocalNetOptions) (*LocalNet, error)
NewLocalNet creates a new mdns network
func (*LocalNet) NewTestP2pNetwork ¶ added in v0.2.0
func (ln *LocalNet) NewTestP2pNetwork(ctx context.Context, nodeIndex int, keys testing.NodeKeys, logger *zap.Logger, options LocalNetOptions) (network.P2PNetwork, error)
NewTestP2pNetwork creates a new network.P2PNetwork instance
type LocalNetOptions ¶ added in v1.2.0
type LocalNetOptions struct { MessageValidatorProvider func(int) validation.MessageValidator Nodes int MinConnected int UseDiscv5 bool TotalValidators, ActiveValidators, MyValidators int PeerScoreInspector func(selfPeer peer.ID, peerMap map[peer.ID]*pubsub.PeerScoreSnapshot) PeerScoreInspectorInterval time.Duration }
type PeersIndexProvider ¶ added in v1.1.0
PeersIndexProvider holds peers index instance