-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP host tracking #136
WIP host tracking #136
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
[package] | ||
name = "kona-host" | ||
version = "0.1.0" | ||
edition.workspace = true | ||
license.workspace = true | ||
authors.workspace = true | ||
repository.workspace = true | ||
homepage.workspace = true | ||
exclude.workspace = true | ||
|
||
[dependencies] | ||
# workspace | ||
anyhow.workspace = true | ||
tracing.workspace = true | ||
alloy-primitives.workspace = true | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Activate the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can do this by just follow what the other crates do by creating a "serde" feature and a default feature that automatically enables serde. Then have that serde feature have "alloy-primitives/serde" in it's list which enables the serde feature on alloy-primitives There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah for sure - given that this is a bin crate, think we can just always enable serde. Folks shouldn't be consuming this code downstream. |
||
|
||
tokio = { version = "1.37.0", features = ["full"] } | ||
clap = { version = "4.5.4", features = ["derive", "env"] } | ||
serde = { version = "1.0.198", features = ["derive"] } | ||
tracing-subscriber = "0.3.18" | ||
|
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
@@ -0,0 +1,100 @@ | ||||
mod parser; | ||||
mod types; | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These should go below |
||||
use crate::{ | ||||
refcell marked this conversation as resolved.
Show resolved
Hide resolved
|
||||
parser::parse_b256, | ||||
types::{Network, RpcKind} | ||||
}; | ||||
|
||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||
use alloy_primitives::B256; | ||||
use anyhow::{anyhow, Result}; | ||||
use clap::{ArgAction, Parser}; | ||||
use serde::Serialize; | ||||
use std::path::PathBuf; | ||||
use tracing::Level; | ||||
|
||||
#[tokio::main] | ||||
async fn main() -> Result<()> { | ||||
let _cli = Cli::parse(); | ||||
let _ = init_tracing_subscriber(_cli.v); | ||||
tracing::info!("host telemetry initialized"); | ||||
Ok(()) | ||||
} | ||||
|
||||
/// Initializes the tracing subscriber | ||||
/// | ||||
/// # Arguments | ||||
/// * `verbosity_level` - The verbosity level (0-4) | ||||
/// | ||||
/// # Returns | ||||
/// * `Result<()>` - Ok if successful, Err otherwise. | ||||
fn init_tracing_subscriber(verbosity_level: u8) -> Result<()> { | ||||
let subscriber = tracing_subscriber::fmt() | ||||
.with_max_level(match verbosity_level { | ||||
0 => Level::ERROR, | ||||
1 => Level::WARN, | ||||
2 => Level::INFO, | ||||
3 => Level::DEBUG, | ||||
_ => Level::TRACE, | ||||
}) | ||||
.finish(); | ||||
tracing::subscriber::set_global_default(subscriber).map_err(|e| anyhow!(e)) | ||||
} | ||||
|
||||
/// The host binary CLI application arguments. | ||||
#[derive(Parser, Serialize)] | ||||
pub struct Cli { | ||||
/// Verbosity level (0-4) | ||||
#[arg(long, short, help = "Verbosity level (0-4)", action = ArgAction::Count)] | ||||
v: u8, | ||||
/// The rollup chain parameters | ||||
#[clap(long)] | ||||
pub rollup_config: PathBuf, | ||||
/// Predefined network selection. | ||||
#[clap(long)] | ||||
pub network: Network, | ||||
/// The Data Directory for preimage data storage. Default uses in-memory storage. | ||||
#[clap(long)] | ||||
pub data_dir: Option<PathBuf>, | ||||
/// Address of L2 JSON-RPC endpoint to use (eth and debug namespace required). | ||||
#[clap(long)] | ||||
pub l2_node_address: String, | ||||
/// Hash of the L1 head block. Derivation stops after this block is processed. | ||||
#[clap(long, value_parser = parse_b256)] | ||||
pub l1_head: B256, | ||||
/// Hash of the L2 block at the L2 Output Root. | ||||
#[clap(long, value_parser = parse_b256)] | ||||
pub l2_head: B256, | ||||
/// Agreed L2 Output Root to start derivation from. | ||||
#[clap(long, value_parser = parse_b256)] | ||||
pub l2_output_root: B256, | ||||
/// Claimed L2 output root to validate | ||||
#[clap(long, value_parser = parse_b256)] | ||||
pub l2_claim: B256, | ||||
/// Number of the L2 block that the claim is from. | ||||
#[clap(long)] | ||||
pub l2_block_number: u64, | ||||
//// Path to the genesis file. | ||||
#[clap(long)] | ||||
pub l2_genesis_path: PathBuf, | ||||
/// Address of L1 JSON-RPC endpoint to use (eth namespace required) | ||||
#[clap(long)] | ||||
pub l1_node_address: String, | ||||
/// Address of the L1 Beacon API endpoint to use. | ||||
#[clap(long)] | ||||
pub l1_beacon_address: String, | ||||
/// Trust the L1 RPC, sync faster at risk of malicious/buggy RPC providing bad or inconsistent | ||||
/// L1 data | ||||
#[clap(long)] | ||||
pub l1_trust_rpc: bool, | ||||
/// The kind of RPC provider, used to inform optimal transactions receipts fetching, and thus | ||||
/// reduce costs. | ||||
#[clap(long)] | ||||
pub l1_rpc_provider_kind: RpcKind, | ||||
/// Run the specified client program as a separate process detached from the host. Default is | ||||
/// to run the client program in the host process. | ||||
#[clap(long)] | ||||
pub exec: String, | ||||
/// Run in pre-image server mode without executing any client program. | ||||
#[clap(long)] | ||||
pub server: bool, | ||||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
use alloy_primitives::B256; | ||
use std::str::FromStr; | ||
|
||
pub fn parse_b256(s: &str) -> Result<B256, String> { | ||
refcell marked this conversation as resolved.
Show resolved
Hide resolved
|
||
B256::from_str(s).map_err(|_| format!("Invalid B256 value: {}", s)) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
use clap::ValueEnum; | ||
use serde::Serialize; | ||
|
||
/// Available networks. | ||
#[derive(Debug, Clone, ValueEnum, Serialize)] | ||
pub enum Network { | ||
/// Optimism Mainnet | ||
Optimism, | ||
} | ||
|
||
#[derive(Debug, Clone, ValueEnum, Serialize)] | ||
refcell marked this conversation as resolved.
Show resolved
Hide resolved
|
||
pub enum RpcKind { | ||
DebugRpc, | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This shouldn't be enabled by default in the workspace dep - should be enabled in
kona-host
'sCargo.toml