WIP try to fix port shift and multiple address mismatch

This commit is contained in:
Oskar Thoren 2020-05-28 11:28:44 +08:00
parent a229e910a0
commit c5fa3543ff
No known key found for this signature in database
GPG Key ID: B2ECCFD3BC2EF77E
3 changed files with 29 additions and 35 deletions

View File

@ -19,12 +19,12 @@ type
tcpPort* {.
desc: "TCP listening port."
defaultValue: 30303
defaultValue: 60000
name: "tcp-port" }: uint16
udpPort* {.
desc: "UDP listening port."
defaultValue: 30303
defaultValue: 60000
name: "udp-port" }: uint16
portsShift* {.

View File

@ -36,10 +36,13 @@ proc initNodeCmd(shift: int, staticNodes: seq[string] = @[], master = false, lab
pubkey = privKey.getKey()[] #assumes ok
keys = KeyPair(seckey: privKey, pubkey: pubkey)
peerInfo = PeerInfo.init(privKey)
# XXX
DefaultAddr = "/ip4/127.0.0.1/tcp/55505"
hostAddress = MultiAddress.init(DefaultAddr)
port = 60000 + shift
#DefaultAddr = "/ip4/127.0.0.1/tcp/55505"
address = "/ip4/127.0.0.1/tcp/" & $port
hostAddress = MultiAddress.init(address)
echo "ADDRESS", address
# TODO: Need to port shift
peerInfo.addrs.add(hostAddress)
let id = peerInfo.id
@ -85,15 +88,24 @@ when isMainModule:
of FullMesh:
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 count = 0
var sleepDuration = 0
for node in nodes:
#if conf.topology in {Star, DiscoveryBased}:
sleepDuration = if node.master: 0
else: 1
if topology in {Star}: #DiscoveryBased
sleepDuration = if node.master: 0
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'"
if topology == FullMesh:
sleepDuration += 1
count += 1
let errorCode = execCmd(commandStr)
if errorCode != 0:

View File

@ -125,13 +125,13 @@ proc run(config: WakuNodeConf) =
let
# External TCP and UDP ports
(ip, tcpPort, udpPort) = setupNat(config)
address = Address(ip: ip, tcpPort: tcpPort, udpPort: udpPort)
port = tcpPort
# Using this for now
DefaultAddr = "/ip4/127.0.0.1/tcp/55505"
hostAddress = MultiAddress.init(DefaultAddr)
nat_address = Address(ip: ip, tcpPort: tcpPort, udpPort: udpPort)
#port = 60000 + tcpPort
#DefaultAddr = "/ip4/127.0.0.1/tcp/55505"
address = "/ip4/127.0.0.1/tcp/" & $tcpPort
hostAddress = MultiAddress.init(address)
# 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?
# NOTE: This is a privatekey
nodekey = config.nodekey
@ -141,28 +141,10 @@ proc run(config: WakuNodeConf) =
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
# And it has wakuProto lets use wakuProto maybe, cause it has switch
var switch = newStandardSwitch(some keys.seckey, hostAddress, triggerSelf = true, gossip = false)