Skip to content
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

feat(host): Setup CLI Arguments #133

Closed
Tracked by #132
refcell opened this issue Apr 24, 2024 · 1 comment
Closed
Tracked by #132

feat(host): Setup CLI Arguments #133

refcell opened this issue Apr 24, 2024 · 1 comment
Labels
A-host Area: host binary K-feature Kind: feature M-bin Meta: Touches application binaries

Comments

@refcell
Copy link
Collaborator

refcell commented Apr 24, 2024

Description

Once the #131 sets up the programatic entrypoint for the host binary, a clap application can be setup with cli arguments that match the reference implementation.

See the op-program's flags.go.

Output

The host Cargo.toml will need to be updated with clap, tokio, and alloy-primitives as dependencies.

e.g.

[dependencies]
tokio = { version = "1.28.0", features = ["full"] }
clap = { version = "3.2.18", features = ["derive", "env"] }

The host binary main.rs should look something like this.

use std::path::PathBuf;
use std::vec::Vec;
use std::{env::current_dir, process};
use clap::Parser;
use alloy_primitives::B256;

#[tokio::main]
async fn main() -> Result<()> {
    let _cli = Cli::parse();

    Ok(())
}

/// Available networks.
#[derive(Debug)]
pub enum Network {
	/// Optimism Mainnet
    Optimism,
}

/// The host binary CLI application arguments.
#[derive(Parser, Serialize)]
pub struct Cli {
    /// 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)]
	pub l1_head: B256,
	/// Hash of the L2 block at the L2 Output Root.
	#[clap(long)]
	pub l2_head: B256,
	/// Agreed L2 Output Root to start derivation from.
	#[clap(long)]
	pub l2_output_root: B256,
	/// Claimed L2 output root to validate
	#[clap(long)]
	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: Vec<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
}
@refcell refcell added K-feature Kind: feature M-bin Meta: Touches application binaries A-host Area: host binary labels Apr 24, 2024
@refcell refcell added this to the Life is Good milestone Apr 24, 2024
@refcell refcell closed this as completed Apr 25, 2024
@refcell refcell reopened this Apr 25, 2024
@refcell
Copy link
Collaborator Author

refcell commented Apr 26, 2024

Implemented in #143

@refcell refcell closed this as completed Apr 26, 2024
@clabby clabby modified the milestones: Phase 4: Multi Program Test Suite, Phase 3: Kona Client & Host Jul 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-host Area: host binary K-feature Kind: feature M-bin Meta: Touches application binaries
Projects
None yet
Development

No branches or pull requests

2 participants