Skip to content

Commit 41bef9d

Browse files
authored
chore: reenable e2e test (#263)
* chore: reenable e2e test Signed-off-by: Sacha Froment <[email protected]> * fix: all Signed-off-by: Sacha Froment <[email protected]> * chore: use the correct ip Signed-off-by: Sacha Froment <[email protected]> * chore: add new rex flag Signed-off-by: Sacha Froment <[email protected]> * chore: fix Signed-off-by: Sacha Froment <[email protected]> * chore: fix Signed-off-by: Sacha Froment <[email protected]> * chore: fix Signed-off-by: Sacha Froment <[email protected]> * fix: test if ip cmd is existing Signed-off-by: Sacha Froment <[email protected]> --------- Signed-off-by: Sacha Froment <[email protected]>
1 parent c50e5cd commit 41bef9d

File tree

10 files changed

+242
-159
lines changed

10 files changed

+242
-159
lines changed

.github/workflows/task.dev-smoke.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,13 @@ jobs:
109109
echo "$bins" | grep -x "$b" >/dev/null || { echo "Missing bin target: $b"; exit 1; }
110110
done
111111
112-
# - name: Install rex CLI
113-
# run: |
114-
# set -euo pipefail
115-
# git clone --depth 1 https://github.com/lambdaclass/rex /tmp/rex
116-
# make -C /tmp/rex cli
117-
# echo "$HOME/.cargo/bin" >> "$GITHUB_PATH"
118-
# rex --version
112+
- name: Install rex CLI
113+
run: |
114+
set -euo pipefail
115+
git clone --depth 1 https://github.com/lambdaclass/rex /tmp/rex
116+
make -C /tmp/rex cli
117+
echo "$HOME/.cargo/bin" >> "$GITHUB_PATH"
118+
rex --version
119119
120120
- name: Run dev command smoke
121121
run: |

cmd/node/src/cli.rs

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -175,11 +175,11 @@ pub struct Options {
175175
impl From<&Options> for mojave_node_lib::types::NodeOptions {
176176
fn from(options: &Options) -> Self {
177177
Self {
178-
http_addr: options.http_addr.clone(),
179-
http_port: options.http_port.clone(),
180-
authrpc_addr: options.authrpc_addr.clone(),
181-
authrpc_port: options.authrpc_port.clone(),
182-
authrpc_jwtsecret: options.authrpc_jwtsecret.clone(),
178+
http_addr: Some(options.http_addr.clone()),
179+
http_port: Some(options.http_port.clone()),
180+
authrpc_addr: Some(options.authrpc_addr.clone()),
181+
authrpc_port: Some(options.authrpc_port.clone()),
182+
authrpc_jwtsecret: Some(options.authrpc_jwtsecret.clone()),
183183
p2p_enabled: options.p2p_enabled,
184184
p2p_addr: options.p2p_addr.clone(),
185185
p2p_port: options.p2p_port.clone(),
@@ -314,11 +314,14 @@ mod tests {
314314
assert_eq!(cli.datadir, ".mojave/node");
315315

316316
let node_opts: NodeOptions = options.into();
317-
assert_eq!(node_opts.http_addr, options.http_addr);
318-
assert_eq!(node_opts.http_port, options.http_port);
319-
assert_eq!(node_opts.authrpc_addr, options.authrpc_addr);
320-
assert_eq!(node_opts.authrpc_port, options.authrpc_port);
321-
assert_eq!(node_opts.authrpc_jwtsecret, options.authrpc_jwtsecret);
317+
assert_eq!(node_opts.http_addr, Some(options.http_addr.clone()));
318+
assert_eq!(node_opts.http_port, Some(options.http_port.clone()));
319+
assert_eq!(node_opts.authrpc_addr, Some(options.authrpc_addr.clone()));
320+
assert_eq!(node_opts.authrpc_port, Some(options.authrpc_port.clone()));
321+
assert_eq!(
322+
node_opts.authrpc_jwtsecret,
323+
Some(options.authrpc_jwtsecret.clone())
324+
);
322325
assert_eq!(node_opts.p2p_enabled, options.p2p_enabled);
323326
assert_eq!(node_opts.p2p_addr, options.p2p_addr);
324327
assert_eq!(node_opts.p2p_port, options.p2p_port);

cmd/sequencer/src/cli.rs

Lines changed: 29 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ pub struct Options {
1010
#[arg(
1111
long = "network",
1212
default_value_t = Network::default(),
13-
value_name = "GENESIS_FILE_PATH",
13+
value_name = "GENESIS_FILE_PATH",
1414
help = "Receives a `Genesis` struct in json format. This is the only argument which is required. You can look at some example genesis files at `test_data/genesis*`.",
1515
long_help = "Alternatively, the name of a known network can be provided instead to use its preset genesis file and include its preset bootnodes. The networks currently supported include holesky, sepolia, hoodi and mainnet.",
1616
help_heading = "Node options",
@@ -20,10 +20,10 @@ pub struct Options {
2020
pub network: Network,
2121

2222
#[arg(
23-
long = "bootnodes",
24-
value_parser = clap::value_parser!(Node),
25-
value_name = "BOOTNODE_LIST",
26-
value_delimiter = ',',
23+
long = "bootnodes",
24+
value_parser = clap::value_parser!(Node),
25+
value_name = "BOOTNODE_LIST",
26+
value_delimiter = ',',
2727
num_args = 1..,
2828
help = "Comma separated enode URLs for P2P discovery bootstrap.",
2929
help_heading = "P2P options"
@@ -84,57 +84,10 @@ pub struct Options {
8484
pub metrics_enabled: bool,
8585

8686
#[arg(
87-
long = "http.addr",
88-
default_value = "0.0.0.0",
89-
value_name = "ADDRESS",
90-
help = "Listening address for the http rpc server.",
91-
help_heading = "RPC options",
92-
env = "ETHREX_HTTP_ADDR"
93-
)]
94-
pub http_addr: String,
95-
96-
#[arg(
97-
long = "http.port",
98-
default_value = "8545",
99-
value_name = "PORT",
100-
help = "Listening port for the http rpc server.",
101-
help_heading = "RPC options",
102-
env = "ETHREX_HTTP_PORT"
103-
)]
104-
pub http_port: String,
105-
106-
#[arg(
107-
long = "authrpc.addr",
108-
default_value = "localhost",
109-
value_name = "ADDRESS",
110-
help = "Listening address for the authenticated rpc server.",
111-
help_heading = "RPC options"
112-
)]
113-
pub authrpc_addr: String,
114-
115-
#[arg(
116-
long = "authrpc.port",
117-
default_value = "8551",
118-
value_name = "PORT",
119-
help = "Listening port for the authenticated rpc server.",
120-
help_heading = "RPC options"
121-
)]
122-
pub authrpc_port: String,
123-
124-
#[arg(
125-
long = "authrpc.jwtsecret",
126-
default_value = "jwt.hex",
127-
value_name = "JWTSECRET_PATH",
128-
help = "Receives the jwt secret used for authenticated rpc requests.",
129-
help_heading = "RPC options"
130-
)]
131-
pub authrpc_jwtsecret: String,
132-
133-
#[arg(
134-
long = "p2p.enabled",
135-
default_value = "true",
136-
value_name = "P2P_ENABLED",
137-
action = ArgAction::SetTrue,
87+
long = "p2p.enabled",
88+
default_value = "true",
89+
value_name = "P2P_ENABLED",
90+
action = ArgAction::SetTrue,
13891
help_heading = "P2P options"
13992
)]
14093
pub p2p_enabled: bool,
@@ -184,11 +137,11 @@ pub struct Options {
184137
impl From<&Options> for mojave_node_lib::types::NodeOptions {
185138
fn from(options: &Options) -> Self {
186139
Self {
187-
http_addr: options.http_addr.clone(),
188-
http_port: options.http_port.clone(),
189-
authrpc_addr: options.authrpc_addr.clone(),
190-
authrpc_port: options.authrpc_port.clone(),
191-
authrpc_jwtsecret: options.authrpc_jwtsecret.clone(),
140+
http_addr: None,
141+
http_port: None,
142+
authrpc_addr: None,
143+
authrpc_port: None,
144+
authrpc_jwtsecret: None,
192145
p2p_enabled: options.p2p_enabled,
193146
p2p_addr: options.p2p_addr.clone(),
194147
p2p_port: options.p2p_port.clone(),
@@ -345,11 +298,11 @@ mod tests {
345298
};
346299

347300
// Node Options defaults
348-
assert_eq!(options.http_addr, "0.0.0.0");
349-
assert_eq!(options.http_port, "8545");
350-
assert_eq!(options.authrpc_addr, "localhost");
351-
assert_eq!(options.authrpc_port, "8551");
352-
assert_eq!(options.authrpc_jwtsecret, "jwt.hex");
301+
//assert_eq!(options.http_addr, "0.0.0.0");
302+
//assert_eq!(options.http_port, "8545");
303+
//assert_eq!(options.authrpc_addr, "localhost");
304+
//assert_eq!(options.authrpc_port, "8551");
305+
//assert_eq!(options.authrpc_jwtsecret, "jwt.hex");
353306
assert!(options.p2p_enabled, "p2p.enabled default should be true");
354307
assert_eq!(options.p2p_addr, "0.0.0.0");
355308
assert_eq!(options.p2p_port, "30303");
@@ -380,16 +333,6 @@ mod tests {
380333
"2500",
381334
"--private_key",
382335
"0xmojave",
383-
"--http.addr",
384-
"127.0.0.1",
385-
"--http.port",
386-
"9000",
387-
"--authrpc.addr",
388-
"127.0.0.1",
389-
"--authrpc.port",
390-
"9001",
391-
"--authrpc.jwtsecret",
392-
"custom.jwt",
393336
"--p2p.addr",
394337
"127.0.0.1",
395338
"--p2p.port",
@@ -422,11 +365,11 @@ mod tests {
422365
assert_eq!(sequencer_options.block_time, 2500);
423366
assert_eq!(sequencer_options.private_key, "0xmojave");
424367

425-
assert_eq!(options.http_addr, "127.0.0.1");
426-
assert_eq!(options.http_port, "9000");
427-
assert_eq!(options.authrpc_addr, "127.0.0.1");
428-
assert_eq!(options.authrpc_port, "9001");
429-
assert_eq!(options.authrpc_jwtsecret, "custom.jwt");
368+
//assert_eq!(options.http_addr, "127.0.0.1");
369+
//assert_eq!(options.http_port, "9000");
370+
//assert_eq!(options.authrpc_addr, "127.0.0.1");
371+
//assert_eq!(options.authrpc_port, "9001");
372+
//assert_eq!(options.authrpc_jwtsecret, "custom.jwt");
430373
assert_eq!(options.p2p_addr, "127.0.0.1");
431374
assert_eq!(options.p2p_port, "30304");
432375
assert_eq!(options.discovery_addr, "127.0.0.1");
@@ -483,16 +426,6 @@ mod tests {
483426
"init",
484427
"--private_key",
485428
"0xabc",
486-
"--http.addr",
487-
"1.2.3.4",
488-
"--http.port",
489-
"9999",
490-
"--authrpc.addr",
491-
"8.8.8.8",
492-
"--authrpc.port",
493-
"8552",
494-
"--authrpc.jwtsecret",
495-
"jwt2.hex",
496429
"--p2p.addr",
497430
"127.0.0.1",
498431
"--p2p.port",
@@ -522,11 +455,11 @@ mod tests {
522455
_ => panic!("expected Start"),
523456
};
524457

525-
assert_eq!(node_opts.http_addr, "1.2.3.4");
526-
assert_eq!(node_opts.http_port, "9999");
527-
assert_eq!(node_opts.authrpc_addr, "8.8.8.8");
528-
assert_eq!(node_opts.authrpc_port, "8552");
529-
assert_eq!(node_opts.authrpc_jwtsecret, "jwt2.hex");
458+
//assert_eq!(node_opts.http_addr, "1.2.3.4");
459+
//assert_eq!(node_opts.http_port, "9999");
460+
//assert_eq!(node_opts.authrpc_addr, "8.8.8.8");
461+
//assert_eq!(node_opts.authrpc_port, "8552");
462+
//assert_eq!(node_opts.authrpc_jwtsecret, "jwt2.hex");
530463
assert_eq!(node_opts.p2p_addr, "127.0.0.1");
531464
assert_eq!(node_opts.p2p_port, "30306");
532465
assert_eq!(node_opts.discovery_addr, "127.0.0.1");

crates/node/src/node.rs

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,37 @@ impl MojaveNode {
124124
registry: RpcRegistry<RpcApiContext>,
125125
) -> Result<()> {
126126
let rpc_shutdown = self.cancel_token.child_token();
127-
let jwt_secret = read_jwtsecret_file(&options.authrpc_jwtsecret).await?;
127+
128+
let jwt_secret = read_jwtsecret_file(
129+
options
130+
.authrpc_jwtsecret
131+
.as_deref()
132+
.ok_or_else(|| Error::Config("missing authrpc_jwtsecret".to_string()))?,
133+
)
134+
.await?;
128135
let api_task = start_api(
129-
get_http_socket_addr(&options.http_addr, &options.http_port).await?,
130-
get_authrpc_socket_addr(&options.authrpc_addr, &options.authrpc_port).await?,
136+
get_http_socket_addr(
137+
options
138+
.http_addr
139+
.as_deref()
140+
.ok_or_else(|| Error::Config("missing http_addr".to_string()))?,
141+
options
142+
.http_port
143+
.as_deref()
144+
.ok_or_else(|| Error::Config("missing http_port".to_string()))?,
145+
)
146+
.await?,
147+
get_authrpc_socket_addr(
148+
options
149+
.authrpc_addr
150+
.as_deref()
151+
.ok_or_else(|| Error::Config("missing authrpc_addr".to_string()))?,
152+
options
153+
.authrpc_port
154+
.as_deref()
155+
.ok_or_else(|| Error::Config("missing authrpc_port".to_string()))?,
156+
)
157+
.await?,
131158
self.store,
132159
self.blockchain,
133160
jwt_secret,
@@ -168,8 +195,12 @@ impl MojaveNode {
168195

169196
pub async fn validate_node_options(options: &NodeOptions) -> Result<()> {
170197
ensure_udp_port_available(&options.p2p_addr, &options.p2p_port).await?;
171-
ensure_tcp_port_available(&options.http_addr, &options.http_port).await?;
172-
ensure_tcp_port_available(&options.authrpc_addr, &options.authrpc_port).await?;
198+
if let (Some(addr), Some(port)) = (&options.http_addr, &options.http_port) {
199+
ensure_tcp_port_available(addr, port).await?;
200+
}
201+
if let (Some(addr), Some(port)) = (&options.authrpc_addr, &options.authrpc_port) {
202+
ensure_tcp_port_available(addr, port).await?;
203+
}
173204
ensure_udp_port_available(&options.discovery_addr, &options.discovery_port).await?;
174205

175206
if options.metrics_enabled {

crates/node/src/types.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,11 @@ pub struct NodeOptions {
5151
pub metrics_addr: String,
5252
pub metrics_port: String,
5353
pub metrics_enabled: bool,
54-
pub http_addr: String,
55-
pub http_port: String,
56-
pub authrpc_addr: String,
57-
pub authrpc_port: String,
58-
pub authrpc_jwtsecret: String,
54+
pub http_addr: Option<String>,
55+
pub http_port: Option<String>,
56+
pub authrpc_addr: Option<String>,
57+
pub authrpc_port: Option<String>,
58+
pub authrpc_jwtsecret: Option<String>,
5959
pub p2p_enabled: bool,
6060
pub p2p_addr: String,
6161
pub p2p_port: String,

0 commit comments

Comments
 (0)