Skip to content

Commit 57965b0

Browse files
committed
wip: quic
1 parent bfc74ea commit 57965b0

20 files changed

+260
-85
lines changed

Makefile

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ TOOLS_CSV := $(subst $(SPACE),$(COMMA),$(TOOLS))
9191
test \
9292
clean \
9393
libbacktrace \
94+
boringssl-win64 \
9495
book \
9596
publish-book \
9697
dist-amd64 \
@@ -164,7 +165,7 @@ ifeq ($(USE_LIBBACKTRACE), 0)
164165
NIM_PARAMS += -d:disable_libbacktrace
165166
endif
166167

167-
deps: | deps-common nat-libs build/generate_makefile
168+
deps: | deps-common nat-libs build/generate_makefile boringssl-win64
168169
ifneq ($(USE_LIBBACKTRACE), 0)
169170
deps: | libbacktrace
170171
endif
@@ -178,6 +179,9 @@ update: | update-common
178179
libbacktrace:
179180
+ "$(MAKE)" -C vendor/nim-libbacktrace --no-print-directory BUILD_CXX_LIB=0
180181

182+
boringssl-win64:
183+
+ "$(MAKE)" -C vendor/nim-lsquic
184+
181185
# Make sure ports don't overlap to support concurrent execution of tests
182186
# Avoid selecting ephemeral ports that may be used by others; safe = 5001-9999
183187
# - Port 8301 is used by Consul
@@ -193,11 +197,13 @@ libbacktrace:
193197
#
194198
# REST tests:
195199
# - --base-port (REST_TEST_BASE_PORT + 0)
196-
# - --base-rest-port (REST_TEST_BASE_PORT + 1)
197-
# - --base-metrics-port (REST_TEST_BASE_PORT + 2)
200+
# - debug-quic-port (REST_TEST_BASE_PORT + 1)
201+
# - --base-rest-port (REST_TEST_BASE_PORT + 2)
202+
# - --base-metrics-port (REST_TEST_BASE_PORT + 3)
198203
#
199204
# Local testnets (entire continuous range):
200205
# - --base-port + [0, --nodes + --light-clients)
206+
# - debug-quic-port uses (--base-port + 1) + [0, --nodes + --light-clients)
201207
# - --base-rest-port + [0, --nodes)
202208
# - --base-metrics-port + [0, --nodes)
203209
# - --base-vc-keymanager-port + [0, --nodes)
@@ -218,9 +224,9 @@ MAINNET_TESTNET_BASE_PORT := 26501
218224
restapi-test:
219225
./tests/simulation/restapi.sh \
220226
--data-dir resttest0_data \
221-
--base-port $$(( $(REST_TEST_BASE_PORT) + EXECUTOR_NUMBER * 3 + 0 )) \
222-
--base-rest-port $$(( $(REST_TEST_BASE_PORT) + EXECUTOR_NUMBER * 3 + 1 )) \
223-
--base-metrics-port $$(( $(REST_TEST_BASE_PORT) + EXECUTOR_NUMBER * 3 + 2 )) \
227+
--base-port $$(( $(REST_TEST_BASE_PORT) + EXECUTOR_NUMBER * 4 + 0 )) \
228+
--base-rest-port $$(( $(REST_TEST_BASE_PORT) + EXECUTOR_NUMBER * 4 + 2 )) \
229+
--base-metrics-port $$(( $(REST_TEST_BASE_PORT) + EXECUTOR_NUMBER * 4 + 3 )) \
224230
--resttest-delay 30 \
225231
--kill-old-processes
226232

@@ -452,7 +458,7 @@ build/generate_makefile: tools/generate_makefile.nim | deps-common
452458
$(filter-out $(TOOLS_CORE_CUSTOMCOMPILE),$(TOOLS)): | build deps
453459
+ for D in $(TOOLS_DIRS); do [ -e "$${D}/$@.nim" ] && TOOL_DIR="$${D}" && break; done && \
454460
echo -e $(BUILD_MSG) "build/$@" && \
455-
MAKE="$(MAKE)" V="$(V)" $(ENV_SCRIPT) scripts/compile_nim_program.sh $@ "$${TOOL_DIR}/$@.nim" $(NIM_PARAMS) && \
461+
MAKE="$(MAKE)" V=1 $(ENV_SCRIPT) scripts/compile_nim_program.sh $@ "$${TOOL_DIR}/$@.nim" $(NIM_PARAMS) && \
456462
echo -e $(BUILD_END_MSG) "build/$@"
457463

458464
# Windows GitHub Actions CI runners, as of this writing, have around 8GB of RAM
@@ -500,6 +506,8 @@ nimbus_beacon_node: force_build_alone_tools
500506

501507
GOERLI_TESTNETS_PARAMS := \
502508
--tcp-port=$$(( $(BASE_PORT) + $(NODE_ID) )) \
509+
--debug-quic=true \
510+
--debug-quic-port=$$(( $(BASE_PORT) + $(NODE_ID) + 1 )) \
503511
--udp-port=$$(( $(BASE_PORT) + $(NODE_ID) )) \
504512
--metrics \
505513
--metrics-port=$$(( $(BASE_METRICS_PORT) + $(NODE_ID) )) \

beacon_chain/conf.nim

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ from consensus_object_pools/block_pools_types_light_client
3636

3737
export
3838
uri, nat, enr,
39-
defaultEth2TcpPort, enabledLogLevel,
39+
defaultEth2TcpPort, defaultEth2QuicPort, enabledLogLevel,
4040
defs, parseCmdArg, completeCmdArg, network_metadata,
4141
el_conf, network,
4242
confTomlDefs, confTomlNet, confTomlUri, jsnet,
@@ -302,6 +302,19 @@ type
302302
defaultValueDesc: $defaultEth2TcpPortDesc
303303
name: "tcp-port" .}: Port
304304

305+
quicEnabled* {.
306+
hidden
307+
desc: "Enable QUIC transport"
308+
defaultValue: true # TODO: set to false by default
309+
name: "debug-quic" .}: bool
310+
311+
quicPort* {.
312+
hidden
313+
desc: "Listening UDP port for Ethereum LibP2P traffic over QUIC"
314+
defaultValue: defaultEth2QuicPort
315+
defaultValueDesc: $defaultEth2QuicPortDesc
316+
name: "debug-quic-port" .}: Port
317+
305318
udpPort* {.
306319
desc: "Listening UDP port for node discovery"
307320
defaultValue: defaultEth2TcpPort
@@ -802,6 +815,11 @@ type
802815
desc: "External UDP port"
803816
name: "udp-port" .}: Port
804817

818+
quicPortExt* {.
819+
hidden
820+
desc: "External QUIC port"
821+
name: "debug-quic-port" .}: Port
822+
805823
seqNumber* {.
806824
desc: "Record sequence number"
807825
defaultValue: 1,

beacon_chain/conf_light_client.nim

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,19 @@ type LightClientConf* = object
6363
defaultValueDesc: $defaultEth2TcpPortDesc
6464
name: "tcp-port" .}: Port
6565

66+
quicEnabled* {.
67+
hidden
68+
desc: "Enable QUIC transport"
69+
defaultValue: true # TODO: set to false by default
70+
name: "debug-quic" .}: bool
71+
72+
quicPort* {.
73+
hidden
74+
desc: "Listening UDP port for Ethereum LibP2P traffic over QUIC"
75+
defaultValue: defaultEth2QuicPort
76+
defaultValueDesc: $defaultEth2QuicPortDesc
77+
name: "debug-quic-port" .}: Port
78+
6679
udpPort* {.
6780
desc: "Listening UDP port for node discovery"
6881
defaultValue: defaultEth2TcpPort

beacon_chain/networking/eth2_discovery.nim

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import
1212
chronos, chronicles,
1313
eth/p2p/discoveryv5/[protocol, node, random2],
1414
../spec/datatypes/[altair, fulu],
15+
../spec/network,
1516
../spec/eth2_ssz_serialization,
1617
".."/[conf, conf_light_client]
1718

@@ -78,7 +79,7 @@ proc loadBootstrapFile*(bootstrapFile: string,
7879

7980
proc new*(T: type Eth2DiscoveryProtocol,
8081
config: BeaconNodeConf | LightClientConf,
81-
enrIp: Opt[IpAddress], enrTcpPort, enrUdpPort: Opt[Port],
82+
enrIp: Opt[IpAddress], enrTcpPort, enrQuicPort, enrUdpPort: Opt[Port],
8283
pk: PrivateKey,
8384
enrFields: openArray[(string, seq[byte])], rng: ref HmacDrbgContext):
8485
T =
@@ -102,8 +103,8 @@ proc new*(T: type Eth2DiscoveryProtocol,
102103
else:
103104
Opt.none(IpAddress)
104105

105-
newProtocol(pk, enrIp, enrTcpPort, enrUdpPort, enrFields, bootstrapEnrs,
106-
bindPort = config.udpPort, bindIp = listenAddress,
106+
newProtocol(pk, enrIp, enrTcpPort, enrUdpPort, enrQuicPort, enrFields,
107+
bootstrapEnrs, bindPort = config.udpPort, bindIp = listenAddress,
107108
enrAutoUpdate = config.enrAutoUpdate, rng = rng)
108109

109110
func isCompatibleForkId*(discoveryForkId: ENRForkID, peerForkId: ENRForkID): bool =

0 commit comments

Comments
 (0)