Skip to content

Commit 459a931

Browse files
authored
feat: add debug port for ethjs (#1044)
Signed-off-by: Barnabas Busa <barnabas.busa@ethereum.org>
1 parent 34e1151 commit 459a931

3 files changed

Lines changed: 28 additions & 3 deletions

File tree

src/el/ethereumjs/ethereumjs_launcher.star

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ WS_PORT_ENGINE_NUM = 8547
1212
DISCOVERY_PORT_NUM = 30303
1313
ENGINE_RPC_PORT_NUM = 8551
1414
METRICS_PORT_NUM = 9001
15+
DEBUG_PORT_NUM = 9229
1516

1617
METRICS_PATH = "/metrics"
1718

@@ -121,6 +122,12 @@ def get_config(
121122
constants.WS_PORT_ID: public_ports_for_component[4],
122123
constants.ENGINE_WS_PORT_ID: public_ports_for_component[5],
123124
}
125+
126+
if "--inspect" in participant.el_extra_env_vars.get("NODE_OPTIONS", ""):
127+
additional_public_port_assignments[
128+
constants.DEBUG_PORT_ID
129+
] = public_ports_for_component[6]
130+
124131
public_ports.update(
125132
shared_utils.get_port_specs(additional_public_port_assignments)
126133
)
@@ -145,6 +152,10 @@ def get_config(
145152
constants.WS_PORT_ID: WS_PORT_NUM,
146153
constants.ENGINE_WS_PORT_ID: WS_PORT_ENGINE_NUM,
147154
}
155+
156+
if "--inspect" in participant.el_extra_env_vars.get("NODE_OPTIONS", ""):
157+
used_port_assignments[constants.DEBUG_PORT_ID] = DEBUG_PORT_NUM
158+
148159
used_ports = shared_utils.get_port_specs(used_port_assignments)
149160

150161
cmd = [

src/package_io/constants.star

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ VALIDATOR_HTTP_PORT_ID = "http-validator"
5757
METRICS_PORT_ID = "metrics"
5858
ENGINE_RPC_PORT_ID = "engine-rpc"
5959
ENGINE_WS_PORT_ID = "engine-ws"
60+
DEBUG_PORT_ID = "debug"
6061
ADMIN_PORT_ID = "admin"
6162
RBUILDER_PORT_ID = "rbuilder-rpc"
6263
RBUILDER_METRICS_PORT_ID = "rbuilder-metric"

src/shared_utils/shared_utils.star

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ constants = import_module("../package_io/constants.star")
33
TCP_PROTOCOL = "TCP"
44
UDP_PROTOCOL = "UDP"
55
HTTP_APPLICATION_PROTOCOL = "http"
6+
WS_APPLICATION_PROTOCOL = "ws"
67
NOT_PROVIDED_APPLICATION_PROTOCOL = ""
78
NOT_PROVIDED_WAIT = "not-provided-wait"
89

@@ -287,10 +288,20 @@ def get_port_specs(port_assignments):
287288
constants.PROFILING_PORT_ID,
288289
]:
289290
ports.update({port_id: new_port_spec(port, TCP_PROTOCOL)})
290-
elif port_id == constants.UDP_DISCOVERY_PORT_ID:
291-
ports.update({port_id: new_port_spec(port, UDP_PROTOCOL)})
292-
elif port_id == constants.QUIC_DISCOVERY_PORT_ID:
291+
elif port_id in [
292+
constants.UDP_DISCOVERY_PORT_ID,
293+
constants.QUIC_DISCOVERY_PORT_ID,
294+
constants.TORRENT_PORT_ID,
295+
]:
293296
ports.update({port_id: new_port_spec(port, UDP_PROTOCOL)})
297+
elif port_id == constants.DEBUG_PORT_ID:
298+
ports.update(
299+
{
300+
port_id: new_port_spec(
301+
port, TCP_PROTOCOL, WS_APPLICATION_PROTOCOL, wait=None
302+
)
303+
}
304+
)
294305
elif port_id in [
295306
constants.HTTP_PORT_ID,
296307
constants.METRICS_PORT_ID,
@@ -303,6 +314,8 @@ def get_port_specs(port_assignments):
303314
ports.update(
304315
{port_id: new_port_spec(port, TCP_PROTOCOL, HTTP_APPLICATION_PROTOCOL)}
305316
)
317+
else:
318+
fail("Unknown port id: {}".format(port_id))
306319
return ports
307320

308321

0 commit comments

Comments
 (0)