Advertise the TCP port of the bootstrap node properly
This commit is contained in:
parent
2a3e40e298
commit
b2d5aba749
|
@ -1116,7 +1116,9 @@ when isMainModule:
|
|||
networkKeys = getPersistentNetKeys(config)
|
||||
bootstrapAddress = enode.Address(
|
||||
ip: parseIpAddress(config.bootstrapAddress),
|
||||
tcpPort: Port config.bootstrapPort,
|
||||
udpPort: Port config.bootstrapPort)
|
||||
|
||||
bootstrapEnr = enr.Record.init(1, networkKeys.seckey, bootstrapAddress)
|
||||
writeFile(bootstrapFile, bootstrapEnr.toURI)
|
||||
echo "Wrote ", bootstrapFile
|
||||
|
|
|
@ -24,7 +24,7 @@ proc new*(T: type Eth2DiscoveryProtocol,
|
|||
pk = initPrivateKey(rawPrivKeyBytes)
|
||||
db = DiscoveryDB.init(newMemoryDB())
|
||||
|
||||
newProtocol(pk, db, Port conf.udpPort)
|
||||
newProtocol(pk, db, Port conf.tcpPort, Port conf.udpPort)
|
||||
|
||||
proc toENode*(a: MultiAddress): Result[ENode, cstring] =
|
||||
if not IPFS.match(a):
|
||||
|
|
|
@ -232,7 +232,7 @@ when networkBackend in [libp2p, libp2pDaemon]:
|
|||
await node.start()
|
||||
|
||||
await sleepAsync(10.seconds)
|
||||
if libp2p_peers.value == 0:
|
||||
if libp2p_successful_dials.value == 0:
|
||||
fatal "Failed to connect to any bootstrap node. Quitting"
|
||||
quit 1
|
||||
|
||||
|
|
|
@ -30,7 +30,6 @@ type
|
|||
discovery*: Eth2DiscoveryProtocol
|
||||
wantedPeers*: int
|
||||
peers*: Table[PeerID, Peer]
|
||||
peersByDiscoveryId*: Table[Eth2DiscoveryId, Peer]
|
||||
protocolStates*: seq[RootRef]
|
||||
libp2pTransportLoops*: seq[Future[void]]
|
||||
|
||||
|
@ -153,7 +152,11 @@ include libp2p_backends_common
|
|||
|
||||
proc toPeerInfo*(r: enr.TypedRecord): PeerInfo =
|
||||
if r.secp256k1.isSome:
|
||||
var peerId = PeerID.init r.secp256k1.get
|
||||
var pubKey: keys.PublicKey
|
||||
if recoverPublicKey(r.secp256k1.get, pubKey) != EthKeysStatus.Success:
|
||||
return # TODO
|
||||
|
||||
let peerId = PeerID.init crypto.PublicKey(scheme: Secp256k1, skkey: pubKey)
|
||||
var addresses = newSeq[MultiAddress]()
|
||||
|
||||
if r.ip.isSome and r.tcp.isSome:
|
||||
|
@ -184,6 +187,7 @@ proc dialPeer*(node: Eth2Node, peerInfo: PeerInfo) {.async.} =
|
|||
var peer = node.getPeer(peerInfo)
|
||||
peer.wasDialed = true
|
||||
await initializeConnection(peer)
|
||||
inc libp2p_successful_dials
|
||||
|
||||
proc runDiscoveryLoop*(node: Eth2Node) {.async.} =
|
||||
debug "Starting discovery loop"
|
||||
|
@ -202,7 +206,7 @@ proc runDiscoveryLoop*(node: Eth2Node) {.async.} =
|
|||
# TODO do this in parallel
|
||||
await node.dialPeer(peerInfo)
|
||||
except CatchableError as err:
|
||||
debug "Failed to connect to peer", peer = $peer
|
||||
debug "Failed to connect to peer", peer = $peer, err = err.msg
|
||||
except CatchableError as err:
|
||||
debug "Failure in discovery", err = err.msg
|
||||
|
||||
|
|
|
@ -25,7 +25,11 @@ const
|
|||
logScope:
|
||||
topics = "libp2p"
|
||||
|
||||
declarePublicGauge libp2p_peers, "Number of libp2p peers"
|
||||
declarePublicGauge libp2p_successful_dials,
|
||||
"Number of successfully dialed peers"
|
||||
|
||||
declarePublicGauge libp2p_peers,
|
||||
"Number of active libp2p peers"
|
||||
|
||||
template libp2pProtocol*(name: string, version: int) {.pragma.}
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit e3ced62d4ba06b7ff638f6784e782046b1fadc70
|
||||
Subproject commit a9ed7e4f3fda41f0649e9e0fe21ab00c03ec368f
|
|
@ -1 +1 @@
|
|||
Subproject commit 31a4e8f959c1ce7de0ef5544753009d3b6b46e25
|
||||
Subproject commit cfdb26db4097b078f02db172534977bd47e0e6c3
|
Loading…
Reference in New Issue