Skip to content

Commit 4657f36

Browse files
MegaRedHandCopilot
andauthored
feat(l1): add CLI flag to specify P2P listening address (#5297)
**Motivation** <!-- Why does this pull request exist? What are its goals? --> **Description** This PR adds a flag to set the listening address for P2P. --------- Co-authored-by: Copilot <[email protected]>
1 parent 9fc41e7 commit 4657f36

File tree

3 files changed

+44
-24
lines changed

3 files changed

+44
-24
lines changed

cmd/ethrex/cli.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,11 +204,18 @@ pub struct Options {
204204
pub authrpc_jwtsecret: String,
205205
#[arg(long = "p2p.disabled", default_value = "false", value_name = "P2P_DISABLED", action = ArgAction::SetFalse, help_heading = "P2P options")]
206206
pub p2p_disabled: bool,
207+
#[arg(
208+
long = "p2p.addr",
209+
value_name = "ADDRESS",
210+
help = "Listening address for the P2P protocol.",
211+
help_heading = "P2P options"
212+
)]
213+
pub p2p_addr: Option<String>,
207214
#[arg(
208215
long = "p2p.port",
209216
default_value = "30303",
210217
value_name = "PORT",
211-
help = "TCP port for P2P protocol.",
218+
help = "TCP port for the P2P protocol.",
212219
help_heading = "P2P options"
213220
)]
214221
pub p2p_port: String,
@@ -308,6 +315,7 @@ impl Default for Options {
308315
authrpc_port: Default::default(),
309316
authrpc_jwtsecret: Default::default(),
310317
p2p_disabled: Default::default(),
318+
p2p_addr: None,
311319
p2p_port: Default::default(),
312320
discovery_port: Default::default(),
313321
network: Default::default(),

cmd/ethrex/initializers.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ use std::env;
3030
use std::{
3131
fs,
3232
io::IsTerminal,
33-
net::SocketAddr,
33+
net::{IpAddr, SocketAddr},
3434
path::{Path, PathBuf},
3535
sync::Arc,
3636
time::{SystemTime, UNIX_EPOCH},
@@ -299,22 +299,22 @@ pub fn get_signer(datadir: &Path) -> SecretKey {
299299
}
300300

301301
pub fn get_local_p2p_node(opts: &Options, signer: &SecretKey) -> Node {
302-
let udp_socket_addr = parse_socket_addr("::", &opts.discovery_port)
303-
.expect("Failed to parse discovery address and port");
304-
let tcp_socket_addr =
305-
parse_socket_addr("::", &opts.p2p_port).expect("Failed to parse addr and port");
306-
307-
let p2p_node_ip = local_ip()
308-
.unwrap_or_else(|_| local_ipv6().expect("Neither ipv4 nor ipv6 local address found"));
302+
let tcp_port = opts.p2p_port.parse().expect("Failed to parse p2p port");
303+
let udp_port = opts
304+
.discovery_port
305+
.parse()
306+
.expect("Failed to parse discovery port");
307+
308+
let p2p_node_ip: IpAddr = if let Some(addr) = &opts.p2p_addr {
309+
addr.parse().expect("Failed to parse p2p address")
310+
} else {
311+
local_ip()
312+
.unwrap_or_else(|_| local_ipv6().expect("Neither ipv4 nor ipv6 local address found"))
313+
};
309314

310315
let local_public_key = public_key_from_signing_key(signer);
311316

312-
let node = Node::new(
313-
p2p_node_ip,
314-
udp_socket_addr.port(),
315-
tcp_socket_addr.port(),
316-
local_public_key,
317-
);
317+
let node = Node::new(p2p_node_ip, udp_port, tcp_port, local_public_key);
318318

319319
// TODO Find a proper place to show node information
320320
// https://github.com/lambdaclass/ethrex/issues/836

docs/CLI.md

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,11 @@ P2P options:
7979
--p2p.disabled
8080
8181
82+
--p2p.addr <ADDRESS>
83+
Listening address for the P2P protocol.
84+
8285
--p2p.port <PORT>
83-
TCP port for P2P protocol.
86+
TCP port for the P2P protocol.
8487
8588
[default: 30303]
8689
@@ -176,6 +179,11 @@ Commands:
176179
help Print this message or the help of the given subcommand(s)
177180
178181
Options:
182+
--osaka-activation-time <UINT64>
183+
Block timestamp at which the Osaka fork is activated on L1. If not set, it will assume Osaka is already active.
184+
185+
[env: ETHREX_OSAKA_ACTIVATION_TIME=]
186+
179187
-t, --tick-rate <TICK_RATE>
180188
time in ms between two ticks
181189
@@ -242,8 +250,11 @@ P2P options:
242250
--p2p.disabled
243251
244252
253+
--p2p.addr <ADDRESS>
254+
Listening address for the P2P protocol.
255+
245256
--p2p.port <PORT>
246-
TCP port for P2P protocol.
257+
TCP port for the P2P protocol.
247258
248259
[default: 30303]
249260
@@ -369,6 +380,10 @@ L1 Watcher options:
369380
[default: 10]
370381
371382
Block producer options:
383+
--watcher.l1-fee-update-interval-ms <ADDRESS>
384+
[env: ETHREX_WATCHER_L1_FEE_UPDATE_INTERVAL_MS=]
385+
[default: 60000]
386+
372387
--block-producer.block-time <UINT64>
373388
How often does the sequencer produce new blocks to the L1 in milliseconds.
374389
@@ -384,11 +399,14 @@ Block producer options:
384399
--block-producer.operator-fee-vault-address <ADDRESS>
385400
[env: ETHREX_BLOCK_PRODUCER_OPERATOR_FEE_VAULT_ADDRESS=]
386401
387-
--operator-fee-per-gas <UINT64>
402+
--block-producer.operator-fee-per-gas <UINT64>
388403
Fee that the operator will receive for each unit of gas consumed in a block.
389404
390405
[env: ETHREX_BLOCK_PRODUCER_OPERATOR_FEE_PER_GAS=]
391406
407+
--block-producer.l1-fee-vault-address <ADDRESS>
408+
[env: ETHREX_BLOCK_PRODUCER_L1_FEE_VAULT_ADDRESS=]
409+
392410
--block-producer.block-gas-limit <UINT64>
393411
Maximum gas limit for the L2 blocks.
394412
@@ -553,7 +571,6 @@ L2 options:
553571
Monitor options:
554572
--no-monitor
555573
[env: ETHREX_NO_MONITOR=]
556-
557574
```
558575

559576
## ethrex l2 prover
@@ -589,11 +606,6 @@ Prover client options:
589606
590607
[default: INFO]
591608
592-
--aligned
593-
Activate aligned proving system
594-
595-
[env: PROVER_CLIENT_ALIGNED=]
596-
597609
--sp1-server <URL>
598610
Url to the moongate server to use when using sp1 backend
599611

0 commit comments

Comments
 (0)