p2p

package
v0.0.0-...-7ef1159 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2024 License: Apache-2.0 Imports: 39 Imported by: 18

Documentation

Index

Constants

View Source
const DefaultPort = 8999
View Source
const DevnetNetworkId = "/wormhole/dev"

The Devnet bootstrap peers are derived from the guardian key so we can't include them here.

View Source
const HighWaterMarkDefault = 400
View Source
const LowWaterMarkDefault = 100
View Source
const MainnetBootstrapPeers = "" /* 332-byte string literal not displayed */
View Source
const MainnetCcqBootstrapPeers = "" /* 332-byte string literal not displayed */
View Source
const MainnetNetworkId = "/wormhole/mainnet/2"

This is the definitive source for the default network parameters. Please reference these (or use the methods below), but avoid copying them!

View Source
const MaxObservationBatchDelay = time.Second

MaxObservationBatchDelay is the longest we will wait before publishing any queued up observations.

View Source
const MaxObservationBatchSize = 4000

MaxObservationBatchSize is the maximum number of observations that will fit in a single `SignedObservationBatch` message.

View Source
const P2P_SUBSCRIPTION_BUFFER_SIZE = 1024
View Source
const P2P_VALIDATE_QUEUE_SIZE = 1024
View Source
const TESTNET_BOOTSTRAP_DHI = 350

TESTNET_BOOTSTRAP_DHI configures how many nodes may connect to the testnet bootstrap node. This number should not exceed HighWaterMark.

View Source
const TestnetBootstrapPeers = "" /* 332-byte string literal not displayed */
View Source
const TestnetCcqBootstrapPeers = "" /* 332-byte string literal not displayed */
View Source
const TestnetNetworkId = "/wormhole/testnet/2/1"

Variables

View Source
var (
	DefaultRegistry = NewRegistry()
)

Functions

func BootstrapAddrs

func BootstrapAddrs(logger *zap.Logger, bootstrapPeers string, self peer.ID) (bootstrappers []peer.AddrInfo, isBootstrapNode bool)

BootstrapAddrs takes a comma-separated string of multi-address strings and returns an array of []peer.AddrInfo that does not include `self`. if `self` is part of `bootstrapPeers`, return isBootstrapNode=true

func ConnectToPeers

func ConnectToPeers(ctx context.Context, logger *zap.Logger, h host.Host, peers []peer.AddrInfo) (successes int)

ConnectToPeers connects `h` to `peers` and returns the number of successful connections.

func DefaultConnectionManager

func DefaultConnectionManager() (*connmgr.BasicConnMgr, error)

func GetBootstrapPeers

func GetBootstrapPeers(env common.Environment) (string, error)

GetBootstrapPeers returns the default p2p bootstrap peers for mainnet and testnet. For any other environment, it returns an error.

func GetCcqBootstrapPeers

func GetCcqBootstrapPeers(env common.Environment) (string, error)

GetCcqBootstrapPeers returns the default ccq bootstrap peers for mainnet and testnet. For any other environment, it returns an error.

func GetNetworkId

func GetNetworkId(env common.Environment) string

GetNetworkId returns the default network ID.

func NewHost

func NewHost(logger *zap.Logger, ctx context.Context, networkID string, bootstrapPeers string, components *Components, priv crypto.PrivKey) (host.Host, error)

func NewRegistry

func NewRegistry() *registry

func Run

func Run(params *RunParams) func(ctx context.Context) error

Types

type Components

type Components struct {
	// P2PIDInHeartbeat determines if the guardian will put it's libp2p node ID in the authenticated heartbeat payload
	P2PIDInHeartbeat           bool
	ListeningAddressesPatterns []string
	// Port on which the Guardian is going to bind
	Port uint
	// ConnMgr is the ConnectionManager that the Guardian is going to use
	ConnMgr *connmgr.BasicConnMgr
	// ProtectedHostByGuardianKey is used to ensure that only one p2p peer can be protected by any given known guardian key
	ProtectedHostByGuardianKey map[eth_common.Address]peer.ID
	// ProtectedHostByGuardianKeyLock is only useful to prevent a race condition in test as ProtectedHostByGuardianKey
	// is only accessed by a single routine at any given time in a running Guardian.
	ProtectedHostByGuardianKeyLock sync.Mutex
	// WarnChannelOverflow: If true, errors due to overflowing channels will produce logger.Warn
	// WARNING: This should not be enabled in production. It is only used in node tests to watch for overflows.
	WarnChannelOverflow bool
	// SignedHeartbeatLogLevel is the log level at which SignedHeartbeatReceived events will be logged.
	SignedHeartbeatLogLevel zapcore.Level
	// GossipParams is used to configure the GossipSub instance used by the Guardian.
	GossipParams pubsub.GossipSubParams
	// GossipAdvertiseAddress is an override for the external IP advertised via p2p to other peers.
	GossipAdvertiseAddress string
}

func DefaultComponents

func DefaultComponents() *Components

func (*Components) ListeningAddresses

func (f *Components) ListeningAddresses() []string

type RunOpt

type RunOpt func(p *RunParams) error

RunOpt is used to specify optional parameters.

func WithChainGovernorConfigListener

func WithChainGovernorConfigListener(signedGovCfgRecvC chan *gossipv1.SignedChainGovernorConfig) RunOpt

WithChainGovernorConfigListener is used to set the channel to receive `SignedChainGovernorConfig` messages.

func WithChainGovernorStatusListener

func WithChainGovernorStatusListener(signedGovStatusRecvC chan *gossipv1.SignedChainGovernorStatus) RunOpt

WithChainGovernorStatusListener is used to set the channel to receive `SignedChainGovernorStatus` messages.

func WithComponents

func WithComponents(components *Components) RunOpt

WithComponents is used to set the components if you need something other than the defaults.

func WithDisableHeartbeatVerify

func WithDisableHeartbeatVerify(disableHeartbeatVerify bool) RunOpt

WithDisableHeartbeatVerify is used to set disableHeartbeatVerify.

func WithGuardianOptions

func WithGuardianOptions(
	nodeName string,
	guardianSigner guardiansigner.GuardianSigner,
	obsvRecvC chan<- *common.MsgWithTimeStamp[gossipv1.SignedObservation],
	batchObsvRecvC chan<- *common.MsgWithTimeStamp[gossipv1.SignedObservationBatch],
	signedIncomingVaaRecvC chan<- *gossipv1.SignedVAAWithQuorum,
	obsvReqRecvC chan<- *gossipv1.ObservationRequest,
	gossipControlSendC chan []byte,
	gossipAttestationSendC chan []byte,
	gossipVaaSendC chan []byte,
	obsvReqSendC <-chan *gossipv1.ObservationRequest,
	acct *accountant.Accountant,
	gov *governor.ChainGovernor,
	disableHeartbeatVerify bool,
	components *Components,
	ibcFeaturesFunc func() string,
	gatewayRelayerEnabled bool,
	ccqEnabled bool,
	signedQueryReqC chan<- *gossipv1.SignedQueryRequest,
	queryResponseReadC <-chan *query.QueryResponsePublication,
	ccqBootstrapPeers string,
	ccqPort uint,
	ccqAllowedPeers string,
) RunOpt

WithGuardianOptions is used to set options that are only meaningful to the guardian.

func WithObservationRequestListener

func WithObservationRequestListener(obsvReqRecvC chan<- *gossipv1.ObservationRequest) RunOpt

WithObservationRequestListener is used to set the channel to receive `ObservationRequest` messages.

func WithProcessorFeaturesFunc

func WithProcessorFeaturesFunc(processorFeaturesFunc func() string) RunOpt

WithProcessorFeaturesFunc is used to set the processor features function.

func WithSignedObservationBatchListener

func WithSignedObservationBatchListener(batchObsvC chan<- *common.MsgWithTimeStamp[gossipv1.SignedObservationBatch]) RunOpt

WithSignedObservationBatchListener is used to set the channel to receive `SignedObservationBatch` messages.

func WithSignedObservationListener

func WithSignedObservationListener(obsvRecvC chan<- *common.MsgWithTimeStamp[gossipv1.SignedObservation]) RunOpt

WithSignedObservationListener is used to set the channel to receive `SignedObservation` messages.

func WithSignedVAAListener

func WithSignedVAAListener(signedIncomingVaaRecvC chan<- *gossipv1.SignedVAAWithQuorum) RunOpt

WithSignedVAAListener is used to set the channel to receive `SignedVAAWithQuorum messages`.

type RunParams

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

RunParams is used to pass parameters into `p2p.Run()`. It allows applications to specify only what they need.

func NewRunParams

func NewRunParams(
	bootstrapPeers string,
	networkID string,
	priv crypto.PrivKey,
	gst *common.GuardianSetState,
	rootCtxCancel context.CancelFunc,
	opts ...RunOpt,
) (*RunParams, error)

NewRunParams is used to create the `RunParams` which gets passed into `p2p.Run()`. It takes the required parameters, plus any desired optional ones, which can be set using the various `With` functions defined below.

Jump to

Keyboard shortcuts

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