mirror of https://github.com/waku-org/nwaku.git
WIP try to fix port shift and multiple address mismatch
This commit is contained in:
parent
a229e910a0
commit
c5fa3543ff
|
@ -19,12 +19,12 @@ type
|
||||||
|
|
||||||
tcpPort* {.
|
tcpPort* {.
|
||||||
desc: "TCP listening port."
|
desc: "TCP listening port."
|
||||||
defaultValue: 30303
|
defaultValue: 60000
|
||||||
name: "tcp-port" }: uint16
|
name: "tcp-port" }: uint16
|
||||||
|
|
||||||
udpPort* {.
|
udpPort* {.
|
||||||
desc: "UDP listening port."
|
desc: "UDP listening port."
|
||||||
defaultValue: 30303
|
defaultValue: 60000
|
||||||
name: "udp-port" }: uint16
|
name: "udp-port" }: uint16
|
||||||
|
|
||||||
portsShift* {.
|
portsShift* {.
|
||||||
|
|
|
@ -36,10 +36,13 @@ proc initNodeCmd(shift: int, staticNodes: seq[string] = @[], master = false, lab
|
||||||
pubkey = privKey.getKey()[] #assumes ok
|
pubkey = privKey.getKey()[] #assumes ok
|
||||||
keys = KeyPair(seckey: privKey, pubkey: pubkey)
|
keys = KeyPair(seckey: privKey, pubkey: pubkey)
|
||||||
peerInfo = PeerInfo.init(privKey)
|
peerInfo = PeerInfo.init(privKey)
|
||||||
# XXX
|
port = 60000 + shift
|
||||||
DefaultAddr = "/ip4/127.0.0.1/tcp/55505"
|
#DefaultAddr = "/ip4/127.0.0.1/tcp/55505"
|
||||||
hostAddress = MultiAddress.init(DefaultAddr)
|
address = "/ip4/127.0.0.1/tcp/" & $port
|
||||||
|
hostAddress = MultiAddress.init(address)
|
||||||
|
|
||||||
|
echo "ADDRESS", address
|
||||||
|
# TODO: Need to port shift
|
||||||
peerInfo.addrs.add(hostAddress)
|
peerInfo.addrs.add(hostAddress)
|
||||||
let id = peerInfo.id
|
let id = peerInfo.id
|
||||||
|
|
||||||
|
@ -85,15 +88,24 @@ when isMainModule:
|
||||||
of FullMesh:
|
of FullMesh:
|
||||||
nodes = fullMeshNetwork(amount)
|
nodes = fullMeshNetwork(amount)
|
||||||
|
|
||||||
|
var staticnodes: seq[string]
|
||||||
|
for i in 0..<amount:
|
||||||
|
# TODO: could also select nodes randomly
|
||||||
|
staticnodes.add(nodes[i].address)
|
||||||
|
|
||||||
|
# TODO: Here we could add a light node, but not clear thats what we want to test?
|
||||||
|
|
||||||
var commandStr = "multitail -s 2 -M 0 -x \"Waku Simulation\""
|
var commandStr = "multitail -s 2 -M 0 -x \"Waku Simulation\""
|
||||||
var count = 0
|
var count = 0
|
||||||
var sleepDuration = 0
|
var sleepDuration = 0
|
||||||
for node in nodes:
|
for node in nodes:
|
||||||
#if conf.topology in {Star, DiscoveryBased}:
|
if topology in {Star}: #DiscoveryBased
|
||||||
sleepDuration = if node.master: 0
|
sleepDuration = if node.master: 0
|
||||||
else: 1
|
else: 1
|
||||||
commandStr &= &" -cT ansi -t 'node #{count} {node.label}' -l 'sleep {sleepDuration}; {node.cmd}; echo [node execution completed]; while true; do sleep 100; done'"
|
commandStr &= &" -cT ansi -t 'node #{count} {node.label}' -l 'sleep {sleepDuration}; {node.cmd}; echo [node execution completed]; while true; do sleep 100; done'"
|
||||||
|
if topology == FullMesh:
|
||||||
|
sleepDuration += 1
|
||||||
|
count += 1
|
||||||
|
|
||||||
let errorCode = execCmd(commandStr)
|
let errorCode = execCmd(commandStr)
|
||||||
if errorCode != 0:
|
if errorCode != 0:
|
||||||
|
|
|
@ -125,13 +125,13 @@ proc run(config: WakuNodeConf) =
|
||||||
let
|
let
|
||||||
# External TCP and UDP ports
|
# External TCP and UDP ports
|
||||||
(ip, tcpPort, udpPort) = setupNat(config)
|
(ip, tcpPort, udpPort) = setupNat(config)
|
||||||
address = Address(ip: ip, tcpPort: tcpPort, udpPort: udpPort)
|
nat_address = Address(ip: ip, tcpPort: tcpPort, udpPort: udpPort)
|
||||||
|
#port = 60000 + tcpPort
|
||||||
port = tcpPort
|
#DefaultAddr = "/ip4/127.0.0.1/tcp/55505"
|
||||||
# Using this for now
|
address = "/ip4/127.0.0.1/tcp/" & $tcpPort
|
||||||
DefaultAddr = "/ip4/127.0.0.1/tcp/55505"
|
hostAddress = MultiAddress.init(address)
|
||||||
hostAddress = MultiAddress.init(DefaultAddr)
|
|
||||||
|
|
||||||
|
# XXX: Address and hostAddress usage needs more clarity
|
||||||
# Difference between announced and host address relevant for running behind NAT, however doesn't seem like nim-libp2p supports this. GHI?
|
# Difference between announced and host address relevant for running behind NAT, however doesn't seem like nim-libp2p supports this. GHI?
|
||||||
# NOTE: This is a privatekey
|
# NOTE: This is a privatekey
|
||||||
nodekey = config.nodekey
|
nodekey = config.nodekey
|
||||||
|
@ -141,28 +141,10 @@ proc run(config: WakuNodeConf) =
|
||||||
|
|
||||||
peerInfo = PeerInfo.init(nodekey)
|
peerInfo = PeerInfo.init(nodekey)
|
||||||
|
|
||||||
info "Initializing networking (host address and announced same)", address
|
#INF 2020-05-28 11:15:50+08:00 Initializing networking (host address and announced same) tid=15555 address=192.168.1.101:30305:30305
|
||||||
|
info "Initializing networking (nat address unused)", nat_address, address
|
||||||
|
peerInfo.addrs.add(Multiaddress.init(address))
|
||||||
|
|
||||||
peerInfo.addrs.add(Multiaddress.init(DefaultAddr))
|
|
||||||
|
|
||||||
# TODO: Here setup a libp2p node
|
|
||||||
# Essentially something like this in nbc/eth2_network:
|
|
||||||
# proc createEth2Node*(conf: BeaconNodeConf): Future[Eth2Node]
|
|
||||||
# TODO: Also see beacon_chain/beaconnode, RPC server etc
|
|
||||||
# Also probably start with floodsub for simplicity
|
|
||||||
# Slice it up only minimal parts here
|
|
||||||
# HERE ATM
|
|
||||||
# config.nodekey = KeyPair.random().tryGet()
|
|
||||||
# address = set above; ip, tcp and udp port (incl NAT)
|
|
||||||
# clientId = "Nimbus waku node"
|
|
||||||
#let network = await createLibP2PNode(conf) # doing in-line
|
|
||||||
# let rpcServer ...
|
|
||||||
|
|
||||||
# Is it a "Standard" Switch? Assume it is for now
|
|
||||||
# NOTE: This should be WakuSub here
|
|
||||||
|
|
||||||
# XXX: Do we want to use this wakuProto? Or Switch?
|
|
||||||
# We need access to the WakuSub thing
|
|
||||||
# switch.pubsub = wakusub, plus all the peer info etc
|
# switch.pubsub = wakusub, plus all the peer info etc
|
||||||
# And it has wakuProto lets use wakuProto maybe, cause it has switch
|
# And it has wakuProto lets use wakuProto maybe, cause it has switch
|
||||||
var switch = newStandardSwitch(some keys.seckey, hostAddress, triggerSelf = true, gossip = false)
|
var switch = newStandardSwitch(some keys.seckey, hostAddress, triggerSelf = true, gossip = false)
|
||||||
|
|
Loading…
Reference in New Issue