Not quic related.
We were using
FROM nimlang/nim:2.0.14 as build
as a base image for compiling the docker images. For some reason, in dockerhub now all base images are for arm64, and in the vaclab we have x86. It took us a bit to understand what was happening. Now we are using a debian base image to build ourselves nim/nimble.
Looks like the node implementation with quic is facing some issues to connect to other nodes.
First, we will list the differences in the code. The code is basically the same when it comes to yamux and mplex, the only difference is one line in the switch creation, such as:
switch =
SwitchBuilder
.new()
.withAddress(MultiAddress.init("0.0.0.0:5000").tryGet())
.withRng(rng)
.withYamux()
#.withMplex() <- depending on the multiplexer, we comment one line or the other
.withMaxConnections(250)
.withTcpTransport(flags = {ServerFlags.TcpNoDelay})
.withNoise()
.build()
When it comes to quic, as it uses udp, we needed to change the switch creation to:
switch =
SwitchBuilder
.new()
.withAddress(MultiAddress.init("/ip4/0.0.0.0/udp/5000/quic-v1").tryGet())
.withRng(rng)
#.withYamux()
#.withMplex()
.withQuicTransport()
.withMaxConnections(250)
#.withTcpTransport(flags = {ServerFlags.TcpNoDelay})
.withNoise()
.build()
Then, when it comes to the node connectivity part, with mplex and yamux the code looks like the following block for both of them. The idea is to resolve a Kubernetes service to obtain a list of nodes, randomize it, until a certain number of connections is reached:
let tAddress = "nimp2p-service:5000"
var addrs: seq[MultiAddress]
echo "Trying to resolve ", tAddress
while true:
try:
addrs = resolveTAddress(tAddress).mapIt(MultiAddress.init(it).tryGet())
echo tAddress, " resolved: ", addrs
break # Break out of the loop on successful resolution
except CatchableError as exc:
echo "Failed to resolve address:", exc.msg
echo "Waiting 15 seconds..."
await sleepAsync(15.seconds)
rng.shuffle(addrs)
var index = 0
while true:
if connected >= connectTo: break
while true:
try:
echo "Trying to connect to ", addrs[index]
let peerId = await switch.connect(addrs[index], allowUnknownPeerId=true).wait(5.seconds)
connected.inc()
index.inc()
echo "Connected!"
break
except CatchableError as exc:
echo "Failed to dial", exc.msg
echo "Waiting 15 seconds..."
await sleepAsync(15.seconds)
To use quic, the resolving part has been changed to:
let quicV1 = MultiAddress.init("/quic-v1").tryGet()
addrs = resolveTAddress(tAddress).mapIt(MultiAddress.init(it, IPPROTO_UDP).tryGet().concat(quicV1).tryGet())
# addrs = resolveTAddress(tAddress).mapIt(MultiAddress.init(it).tryGet())
This lead us to the following behavior, with yamux/mplex we obtaing the expected connectivity flow: