Skip to content

Commit 2ef0d18

Browse files
committed
feat: quic
1 parent 66e1a4a commit 2ef0d18

18 files changed

Lines changed: 318 additions & 100 deletions

Makefile

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -191,11 +191,13 @@ libbacktrace:
191191
#
192192
# REST tests:
193193
# - --base-port (REST_TEST_BASE_PORT + 0)
194-
# - --base-rest-port (REST_TEST_BASE_PORT + 1)
195-
# - --base-metrics-port (REST_TEST_BASE_PORT + 2)
194+
# - debug-quic-port (REST_TEST_BASE_PORT + 1)
195+
# - --base-rest-port (REST_TEST_BASE_PORT + 2)
196+
# - --base-metrics-port (REST_TEST_BASE_PORT + 3)
196197
#
197198
# Local testnets (entire continuous range):
198199
# - --base-port + [0, --nodes + --light-clients)
200+
# - debug-quic-port uses (--base-port + 1) + [0, --nodes + --light-clients)
199201
# - --base-rest-port + [0, --nodes)
200202
# - --base-metrics-port + [0, --nodes)
201203
# - --base-vc-keymanager-port + [0, --nodes)
@@ -216,9 +218,9 @@ MAINNET_TESTNET_BASE_PORT := 26501
216218
restapi-test:
217219
./tests/simulation/restapi.sh \
218220
--data-dir resttest0_data \
219-
--base-port $$(( $(REST_TEST_BASE_PORT) + EXECUTOR_NUMBER * 3 + 0 )) \
220-
--base-rest-port $$(( $(REST_TEST_BASE_PORT) + EXECUTOR_NUMBER * 3 + 1 )) \
221-
--base-metrics-port $$(( $(REST_TEST_BASE_PORT) + EXECUTOR_NUMBER * 3 + 2 )) \
221+
--base-port $$(( $(REST_TEST_BASE_PORT) + EXECUTOR_NUMBER * 4 + 0 )) \
222+
--base-rest-port $$(( $(REST_TEST_BASE_PORT) + EXECUTOR_NUMBER * 4 + 2 )) \
223+
--base-metrics-port $$(( $(REST_TEST_BASE_PORT) + EXECUTOR_NUMBER * 4 + 3 )) \
222224
--resttest-delay 30 \
223225
--kill-old-processes
224226

@@ -448,7 +450,7 @@ build/generate_makefile: tools/generate_makefile.nim | deps-common
448450
$(filter-out $(TOOLS_CORE_CUSTOMCOMPILE),$(TOOLS)): | build deps
449451
+ for D in $(TOOLS_DIRS); do [ -e "$${D}/$@.nim" ] && TOOL_DIR="$${D}" && break; done && \
450452
echo -e $(BUILD_MSG) "build/$@" && \
451-
MAKE="$(MAKE)" V="$(V)" $(ENV_SCRIPT) scripts/compile_nim_program.sh $@ "$${TOOL_DIR}/$@.nim" $(NIM_PARAMS) && \
453+
MAKE="$(MAKE)" V=1 $(ENV_SCRIPT) scripts/compile_nim_program.sh $@ "$${TOOL_DIR}/$@.nim" $(NIM_PARAMS) && \
452454
echo -e $(BUILD_END_MSG) "build/$@"
453455

454456
# Windows GitHub Actions CI runners, as of this writing, have around 8GB of RAM
@@ -496,6 +498,9 @@ nimbus_beacon_node: force_build_alone_tools
496498

497499
GOERLI_TESTNETS_PARAMS := \
498500
--tcp-port=$$(( $(BASE_PORT) + $(NODE_ID) )) \
501+
--tcp=true \
502+
--debug-quic=true \
503+
--debug-quic-port=$$(( $(BASE_PORT) + $(NODE_ID) + 1 )) \
499504
--udp-port=$$(( $(BASE_PORT) + $(NODE_ID) )) \
500505
--metrics \
501506
--metrics-port=$$(( $(BASE_METRICS_PORT) + $(NODE_ID) )) \

beacon_chain/conf.nim

Lines changed: 25 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,12 +302,31 @@ type
302302
defaultValueDesc: "*"
303303
name: "listen-address" .}: Option[IpAddress]
304304

305+
tcpEnabled* {.
306+
hidden
307+
desc: "Enable TCP transport"
308+
defaultValue: true
309+
name: "tcp" .}: bool
310+
305311
tcpPort* {.
306312
desc: "Listening TCP port for Ethereum LibP2P traffic"
307313
defaultValue: defaultEth2TcpPort
308314
defaultValueDesc: $defaultEth2TcpPortDesc
309315
name: "tcp-port" .}: Port
310316

317+
quicEnabled* {.
318+
hidden
319+
desc: "Enable QUIC transport"
320+
defaultValue: false
321+
name: "debug-quic" .}: bool
322+
323+
quicPort* {.
324+
hidden
325+
desc: "Listening UDP port for Ethereum LibP2P traffic over QUIC"
326+
defaultValue: defaultEth2QuicPort
327+
defaultValueDesc: $defaultEth2QuicPortDesc
328+
name: "debug-quic-port" .}: Port
329+
311330
udpPort* {.
312331
desc: "Listening UDP port for node discovery"
313332
defaultValue: defaultEth2TcpPort
@@ -812,6 +831,11 @@ type
812831
desc: "External UDP port"
813832
name: "udp-port" .}: Port
814833

834+
quicPortExt* {.
835+
hidden
836+
desc: "External QUIC port"
837+
name: "debug-quic-port" .}: Port
838+
815839
seqNumber* {.
816840
desc: "Record sequence number"
817841
defaultValue: 1,

beacon_chain/conf_light_client.nim

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,31 @@ type LightClientConf* = object
5757
desc: "Listening address for the Ethereum LibP2P and Discovery v5 traffic"
5858
name: "listen-address" .}: Option[IpAddress]
5959

60+
tcpEnabled* {.
61+
hidden
62+
desc: "Enable TCP transport"
63+
defaultValue: true
64+
name: "tcp" .}: bool
65+
6066
tcpPort* {.
6167
desc: "Listening TCP port for Ethereum LibP2P traffic"
6268
defaultValue: defaultEth2TcpPort
6369
defaultValueDesc: $defaultEth2TcpPortDesc
6470
name: "tcp-port" .}: Port
6571

72+
quicEnabled* {.
73+
hidden
74+
desc: "Enable QUIC transport"
75+
defaultValue: false
76+
name: "debug-quic" .}: bool
77+
78+
quicPort* {.
79+
hidden
80+
desc: "Listening UDP port for Ethereum LibP2P traffic over QUIC"
81+
defaultValue: defaultEth2QuicPort
82+
defaultValueDesc: $defaultEth2QuicPortDesc
83+
name: "debug-quic-port" .}: Port
84+
6685
udpPort* {.
6786
desc: "Listening UDP port for node discovery"
6887
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)