Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ clap = { version = "4.5.4", features = ["derive", "env"] }
tracing-subscriber = { version = "0.3.17", features = ["env-filter"] }
dirs = "5.0.1"
ctrlc = "3.2.3"
url = "2.5.0"

helios-core = { path = "../core" }
helios-ethereum = { path = "../ethereum" }
Expand Down
25 changes: 15 additions & 10 deletions cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ use helios_opstack::{config::Config as OpStackConfig, OpStackClient, OpStackClie
use tracing::{error, info};
use tracing_subscriber::filter::{EnvFilter, LevelFilter};
use tracing_subscriber::FmtSubscriber;
use url::Url;

#[tokio::main]
async fn main() -> Result<()> {
Expand Down Expand Up @@ -129,10 +130,10 @@ struct EthereumArgs {
rpc_port: Option<u16>,
#[clap(short = 'w', long, env)]
checkpoint: Option<B256>,
#[clap(short, long, env)]
execution_rpc: Option<String>,
#[clap(short, long, env)]
consensus_rpc: Option<String>,
#[clap(short, long, env, value_parser = parse_url)]
execution_rpc: Option<Url>,
#[clap(short, long, env, value_parser = parse_url)]
consensus_rpc: Option<Url>,
#[clap(short, long, env)]
data_dir: Option<String>,
#[clap(short = 'f', long, env)]
Expand Down Expand Up @@ -187,10 +188,10 @@ struct OpStackArgs {
rpc_bind_ip: Option<IpAddr>,
#[clap(short = 'p', long, env, default_value = "8545")]
rpc_port: Option<u16>,
#[clap(short, long, env)]
execution_rpc: Option<String>,
#[clap(short, long, env)]
consensus_rpc: Option<String>,
#[clap(short, long, env, value_parser = parse_url)]
execution_rpc: Option<Url>,
#[clap(short, long, env, value_parser = parse_url)]
consensus_rpc: Option<Url>,
#[clap(
short = 'w',
long = "ethereum-checkpoint",
Expand Down Expand Up @@ -226,11 +227,11 @@ impl OpStackArgs {
let mut user_dict = HashMap::new();

if let Some(rpc) = &self.execution_rpc {
user_dict.insert("execution_rpc", Value::from(rpc.clone()));
user_dict.insert("execution_rpc", Value::from(rpc.to_string()));
}

if let Some(rpc) = &self.consensus_rpc {
user_dict.insert("consensus_rpc", Value::from(rpc.clone()));
user_dict.insert("consensus_rpc", Value::from(rpc.to_string()));
}

if self.rpc_bind_ip.is_some() && self.rpc_port.is_some() {
Expand Down Expand Up @@ -265,3 +266,7 @@ fn true_or_none(b: bool) -> Option<bool> {
None
}
}

fn parse_url(s: &str) -> Result<Url, url::ParseError> {
Url::parse(s)
}
1 change: 1 addition & 0 deletions ethereum/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ triehash-ethereum.workspace = true
figment = { version = "0.10.7", features = ["toml", "env"] }
serde_yaml = "0.9.14"
strum = { version = "0.26.2", features = ["derive"] }
url = "2.5.0"

# async/futures
tokio.workspace = true
Expand Down
9 changes: 5 additions & 4 deletions ethereum/src/config/cli.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use std::net::IpAddr;
use std::{collections::HashMap, path::PathBuf};
use url::Url;

use alloy::primitives::B256;
use figment::{providers::Serialized, value::Value};
Expand All @@ -8,8 +9,8 @@ use serde::{Deserialize, Serialize};
/// Cli Config
#[derive(Serialize, Deserialize, Debug, Clone, Default)]
pub struct CliConfig {
pub execution_rpc: Option<String>,
pub consensus_rpc: Option<String>,
pub execution_rpc: Option<Url>,
pub consensus_rpc: Option<Url>,
pub checkpoint: Option<B256>,
pub rpc_bind_ip: Option<IpAddr>,
pub rpc_port: Option<u16>,
Expand All @@ -24,11 +25,11 @@ impl CliConfig {
let mut user_dict = HashMap::new();

if let Some(rpc) = &self.execution_rpc {
user_dict.insert("execution_rpc", Value::from(rpc.clone()));
user_dict.insert("execution_rpc", Value::from(rpc.to_string()));
}

if let Some(rpc) = &self.consensus_rpc {
user_dict.insert("consensus_rpc", Value::from(rpc.clone()));
user_dict.insert("consensus_rpc", Value::from(rpc.to_string()));
}

if let Some(checkpoint) = &self.checkpoint {
Expand Down
Loading