-
Notifications
You must be signed in to change notification settings - Fork 204
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6361 from multiversx/light-client-network
New p2p network messenger for the light clients and suppliers.
- Loading branch information
Showing
19 changed files
with
381 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
# LightClientP2P config file | ||
|
||
# NodeConfig holds the P2P settings | ||
[Node] | ||
# Port is the port that will be opened by the node on all interfaces so other peers can connect to it | ||
# If the port = 0, the node will search for a free port on the machine and use it | ||
Port = "37373-38383" | ||
|
||
# ThresholdMinConnectedPeers represents the minimum number of connections a node should have before it can start | ||
# the sync and consensus mechanisms | ||
ThresholdMinConnectedPeers = 3 | ||
|
||
# MinNumPeersToWaitForOnBootstrap is the minimum number of peers to wait on bootstrap or the node will wait the default | ||
# time which is now set to ~20 seconds (the const defined in the common package named TimeToWaitForP2PBootstrap) | ||
MinNumPeersToWaitForOnBootstrap = 10 | ||
|
||
# available transports. All defined addresses contains a single '%d' markup that is mandatory and will | ||
# be replaced at runtime with the actual port value | ||
[Node.Transports] | ||
QUICAddress = "" # optional QUIC address. If this transport should be activated, should be in this format: /ip4/0.0.0.0/udp/%d/quic-v1 | ||
WebSocketAddress = "" # optional WebSocket address. If this transport should be activated, should be in this format: /ip4/0.0.0.0/tcp/%d/ws | ||
WebTransportAddress = "" # optional WebTransport address. If this transport should be activated, should be in this format: /ip4/0.0.0.0/udp/%d/quic-v1/webtransport | ||
[Node.Transports.TCP] | ||
ListenAddress = "/ip4/0.0.0.0/tcp/%d" # TCP listen address | ||
PreventPortReuse = false | ||
|
||
[Node.ResourceLimiter] | ||
Type = "default autoscale" #available options "default autoscale", "infinite", "default with manual scale". | ||
ManualSystemMemoryInMB = 0 # not taken into account if the type is not "default with manual scale" | ||
ManualMaximumFD = 0 # not taken into account if the type is not "default with manual scale" | ||
|
||
# P2P peer discovery section | ||
|
||
# The following sections correspond to the way new peers will be discovered | ||
# If all config types are disabled then the peer will run in single mode (will not try to find other peers) | ||
# If more than one peer discovery mechanism is enabled, the application will output an error and will not start | ||
|
||
[KadDhtPeerDiscovery] | ||
# Enabled: true/false to enable/disable this discovery mechanism | ||
Enabled = true | ||
|
||
# Type represents the kad-dht glue code implementation. | ||
# "legacy" will define the first implementation. | ||
# "optimized" represents the new variant able to connect to multiple seeders at once. This implementation also has | ||
# a built-in timer that will try to automatically reconnect to the seeders (in case the seeders recover after a | ||
# premature shutdown) | ||
Type = "optimized" | ||
|
||
# RefreshIntervalInSec represents the time in seconds between querying for new peers | ||
RefreshIntervalInSec = 10 | ||
|
||
# ProtocolIDs represents the protocols that this node will advertise to other peers | ||
# To connect to other nodes, those nodes should have at least one common protocol string | ||
ProtocolIDs = [ | ||
"/mvx/light/1.0.0", | ||
] | ||
|
||
# InitialPeerList represents the list of strings of some known nodes that will bootstrap this node | ||
# The address will be in a self-describing addressing format. | ||
# More can be found here: https://github.com/libp2p/specs/blob/master/3-requirements.md#34-transport-agnostic | ||
# Example: | ||
# /ip6/fe80::8823:6dff:fee7:f172/tcp/4001/p2p/QmYJyUMAcXEw1b5bFfbBbzYu5wyyjLMRHXGUkCXpag74Fu | ||
# /ip4/162.246.145.218/udp/4001/utp/ipfs/QmYJyUMAcXEw1b5bFfbBbzYu5wyyjLMRHXGUkCXpag74Fu | ||
# | ||
# If the initial peers list is left empty, the node will not try to connect to other peers during initial bootstrap | ||
# phase but will accept connections and will do the network discovery if another peer connects to it | ||
InitialPeerList = ["/ip4/127.0.0.1/tcp/9999/p2p/16Uiu2HAkw5SNNtSvH1zJiQ6Gc3WoGNSxiyNueRKe6fuAuh57G3Bk"] | ||
|
||
# kademlia's routing table bucket size | ||
BucketSize = 100 | ||
|
||
# RoutingTableRefreshIntervalInSec defines how many seconds should pass between 2 kad routing table auto refresh calls | ||
RoutingTableRefreshIntervalInSec = 300 | ||
|
||
[Sharding] | ||
# The targeted number of peer connections | ||
TargetPeerCount = 41 | ||
MaxIntraShardValidators = 7 | ||
MaxCrossShardValidators = 15 | ||
MaxIntraShardObservers = 7 | ||
MaxCrossShardObservers = 3 | ||
MaxSeeders = 2 | ||
|
||
# available options: | ||
# `ListsSharder` will split the peers based on the shard membership (intra, cross or unknown) | ||
# `OneListSharder` will do just the connection triming (upto TargetPeerCount value) not taking into account | ||
# the shard membership of the connected peers | ||
# `NilListSharder` will disable conection trimming (sharder is off) | ||
Type = "ListsSharder" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package common | ||
|
||
// Contains returns true if the specified value is contained in a slice. | ||
func Contains[T comparable](s []T, e ...T) bool { | ||
for _, v := range s { | ||
for _, v2 := range e { | ||
if v == v2 { | ||
return true | ||
} | ||
} | ||
} | ||
return false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.