From b16a94e698bfcd77ab59bcb0269711a77df632af Mon Sep 17 00:00:00 2001 From: martyall Date: Wed, 18 Dec 2024 08:21:52 -0800 Subject: [PATCH 1/4] add more robust cli framework --- Cargo.lock | 15 ++++- o1vm/Cargo.toml | 6 +- o1vm/run-vm.sh | 2 +- o1vm/src/cannon.rs | 71 +++++++++++---------- o1vm/src/cannon_cli.rs | 112 --------------------------------- o1vm/src/cli/cannon.rs | 111 ++++++++++++++++++++++++++++++++ o1vm/src/cli/mod.rs | 14 +++++ o1vm/src/legacy/main.rs | 24 +++++-- o1vm/src/lib.rs | 5 +- o1vm/src/pickles/main.rs | 29 ++++++--- o1vm/src/test_preimage_read.rs | 29 +++------ o1vm/test_preimage_read.sh | 4 +- 12 files changed, 229 insertions(+), 193 deletions(-) delete mode 100644 o1vm/src/cannon_cli.rs create mode 100644 o1vm/src/cli/cannon.rs create mode 100644 o1vm/src/cli/mod.rs diff --git a/Cargo.lock b/Cargo.lock index 917bab5d39..456d4ce2d5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -592,7 +592,7 @@ checksum = "4ea181bf566f71cb9a5d17a59e1871af638180a18fb0035c92ae62b705207123" dependencies = [ "atty", "bitflags 1.3.2", - "clap_derive", + "clap_derive 3.2.25", "clap_lex 0.2.4", "indexmap 1.9.3", "once_cell", @@ -608,6 +608,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e578d6ec4194633722ccf9544794b71b1385c3c027efe0c55db226fc880865c" dependencies = [ "clap_builder", + "clap_derive 4.4.7", ] [[package]] @@ -635,6 +636,18 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "clap_derive" +version = "4.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf9804afaaf59a91e75b022a30fb7229a7901f60c755489cc61c9b423b836442" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn 2.0.48", +] + [[package]] name = "clap_lex" version = "0.2.4" diff --git a/o1vm/Cargo.toml b/o1vm/Cargo.toml index 1e57ce7c0d..a91b75d54c 100644 --- a/o1vm/Cargo.toml +++ b/o1vm/Cargo.toml @@ -12,10 +12,6 @@ license = "Apache-2.0" [lib] path = "src/lib.rs" -[[bin]] -name = "test_optimism_preimage_read" -path = "src/test_preimage_read.rs" - [[bin]] name = "legacy_o1vm" path = "src/legacy/main.rs" @@ -35,7 +31,7 @@ ark-ec.workspace = true ark-ff.workspace = true ark-poly.workspace = true base64.workspace = true -clap.workspace = true +clap = { workspace = true, features = ["derive"] } command-fds.workspace = true elf.workspace = true env_logger.workspace = true diff --git a/o1vm/run-vm.sh b/o1vm/run-vm.sh index 34e61f4da7..bd970354cc 100755 --- a/o1vm/run-vm.sh +++ b/o1vm/run-vm.sh @@ -30,7 +30,7 @@ fi cargo run --bin ${BINARY_FLAVOR} \ --all-features \ --release \ - -p o1vm -- \ + -p o1vm cannon run -- \ --pprof.cpu \ --info-at "${INFO_AT:-%10000000}" \ --snapshot-state-at "${SNAPSHOT_STATE_AT:-%10000000}" \ diff --git a/o1vm/src/cannon.rs b/o1vm/src/cannon.rs index 1a47a3041f..e9ae23d699 100644 --- a/o1vm/src/cannon.rs +++ b/o1vm/src/cannon.rs @@ -147,33 +147,36 @@ pub enum StepFrequency { Range(u64, Option), } -// Simple parser for Cannon's "frequency format" -// A frequency input is either -// - never/always -// - = (only at step n) -// - % (every steps multiple of n) -// - n..[m] (from n on, until m excluded if specified, until the end otherwise) -pub fn step_frequency_parser(s: &str) -> std::result::Result { - use StepFrequency::*; - - let mod_re = Regex::new(r"^%([0-9]+)").unwrap(); - let eq_re = Regex::new(r"^=([0-9]+)").unwrap(); - let ival_re = Regex::new(r"^([0-9]+)..([0-9]+)?").unwrap(); - - match s { - "never" => Ok(Never), - "always" => Ok(Always), - s => { - if let Some(m) = mod_re.captures(s) { - Ok(Every(m[1].parse::().unwrap())) - } else if let Some(m) = eq_re.captures(s) { - Ok(Exactly(m[1].parse::().unwrap())) - } else if let Some(m) = ival_re.captures(s) { - let lo = m[1].parse::().unwrap(); - let hi_opt = m.get(2).map(|x| x.as_str().parse::().unwrap()); - Ok(Range(lo, hi_opt)) - } else { - Err(format!("Unknown frequency format {}", s)) +impl FromStr for StepFrequency { + type Err = String; + // Simple parser for Cannon's "frequency format" + // A frequency input is either + // - never/always + // - = (only at step n) + // - % (every steps multiple of n) + // - n..[m] (from n on, until m excluded if specified, until the end otherwise) + fn from_str(s: &str) -> std::result::Result { + use StepFrequency::*; + + let mod_re = Regex::new(r"^%([0-9]+)").unwrap(); + let eq_re = Regex::new(r"^=([0-9]+)").unwrap(); + let ival_re = Regex::new(r"^([0-9]+)..([0-9]+)?").unwrap(); + + match s { + "never" => Ok(Never), + "always" => Ok(Always), + s => { + if let Some(m) = mod_re.captures(s) { + Ok(Every(m[1].parse::().unwrap())) + } else if let Some(m) = eq_re.captures(s) { + Ok(Exactly(m[1].parse::().unwrap())) + } else if let Some(m) = ival_re.captures(s) { + let lo = m[1].parse::().unwrap(); + let hi_opt = m.get(2).map(|x| x.as_str().parse::().unwrap()); + Ok(Range(lo, hi_opt)) + } else { + Err(format!("Unknown frequency format {}", s)) + } } } } @@ -296,13 +299,13 @@ mod tests { #[test] fn sp_parser() { use StepFrequency::*; - assert_eq!(step_frequency_parser("never"), Ok(Never)); - assert_eq!(step_frequency_parser("always"), Ok(Always)); - assert_eq!(step_frequency_parser("=123"), Ok(Exactly(123))); - assert_eq!(step_frequency_parser("%123"), Ok(Every(123))); - assert_eq!(step_frequency_parser("1..3"), Ok(Range(1, Some(3)))); - assert_eq!(step_frequency_parser("1.."), Ok(Range(1, None))); - assert!(step_frequency_parser("@123").is_err()); + assert_eq!(StepFrequency::from_str("never"), Ok(Never)); + assert_eq!(StepFrequency::from_str("always"), Ok(Always)); + assert_eq!(StepFrequency::from_str("=123"), Ok(Exactly(123))); + assert_eq!(StepFrequency::from_str("%123"), Ok(Every(123))); + assert_eq!(StepFrequency::from_str("1..3"), Ok(Range(1, Some(3)))); + assert_eq!(StepFrequency::from_str("1.."), Ok(Range(1, None))); + assert!(StepFrequency::from_str("@123").is_err()); } // This sample is a subset taken from a Cannon-generated "meta.json" file diff --git a/o1vm/src/cannon_cli.rs b/o1vm/src/cannon_cli.rs deleted file mode 100644 index d894570a5f..0000000000 --- a/o1vm/src/cannon_cli.rs +++ /dev/null @@ -1,112 +0,0 @@ -use crate::cannon::*; -use clap::{arg, value_parser, Arg, ArgAction}; - -pub fn main_cli() -> clap::Command { - let app_name = "o1vm"; - clap::Command::new(app_name) - .version("0.1") - .about("o1vm - a generic purpose zero-knowledge virtual machine") - .arg(arg!(--input "initial state file").default_value("state.json")) - .arg(arg!(--output "output state file").default_value("out.json")) - .arg(arg!(--meta "metadata file").default_value("meta.json")) - // The CLI arguments below this line are ignored at this point - .arg( - Arg::new("proof-at") - .short('p') - .long("proof-at") - .value_name("FREQ") - .default_value("never") - .value_parser(step_frequency_parser), - ) - .arg( - Arg::new("proof-fmt") - .long("proof-fmt") - .value_name("FORMAT") - .default_value("proof-%d.json"), - ) - .arg( - Arg::new("snapshot-fmt") - .long("snapshot-fmt") - .value_name("FORMAT") - .default_value("state-%d.json"), - ) - .arg( - Arg::new("stop-at") - .long("stop-at") - .value_name("FREQ") - .default_value("never") - .value_parser(step_frequency_parser), - ) - .arg( - Arg::new("info-at") - .long("info-at") - .value_name("FREQ") - .default_value("never") - .value_parser(step_frequency_parser), - ) - .arg( - Arg::new("pprof-cpu") - .long("pprof.cpu") - .action(ArgAction::SetTrue), - ) - .arg( - arg!(host: [HOST] "host program specification [host program arguments]") - .num_args(1..) - .last(true) - .value_parser(value_parser!(String)), - ) - .arg( - Arg::new("snapshot-state-at") - .long("snapshot-state-at") - .value_name("FREQ") - .default_value("never") - .value_parser(step_frequency_parser), - ) -} - -pub fn read_configuration(cli: &clap::ArgMatches) -> VmConfiguration { - let input_state_file = cli.get_one::("input").unwrap(); - let output_state_file = cli.get_one::("output").unwrap(); - let metadata_file = cli.get_one::("meta").unwrap(); - - let proof_at = cli.get_one::("proof-at").unwrap(); - let info_at = cli.get_one::("info-at").unwrap(); - let stop_at = cli.get_one::("stop-at").unwrap(); - let snapshot_state_at = cli.get_one::("snapshot-state-at").unwrap(); - - let proof_fmt = cli.get_one::("proof-fmt").unwrap(); - let snapshot_fmt = cli.get_one::("snapshot-fmt").unwrap(); - let pprof_cpu = cli.get_one::("pprof-cpu").unwrap(); - - let host_spec = cli - .get_many::("host") - .map(|vals| vals.collect::>()) - .unwrap_or_default(); - - let host = if host_spec.is_empty() { - None - } else { - Some(HostProgram { - name: host_spec[0].to_string(), - arguments: host_spec[1..] - .to_vec() - .iter() - .map(|x| x.to_string()) - .collect(), - }) - }; - - VmConfiguration { - input_state_file: input_state_file.to_string(), - output_state_file: output_state_file.to_string(), - metadata_file: metadata_file.to_string(), - proof_at: proof_at.clone(), - stop_at: stop_at.clone(), - snapshot_state_at: snapshot_state_at.clone(), - info_at: info_at.clone(), - proof_fmt: proof_fmt.to_string(), - snapshot_fmt: snapshot_fmt.to_string(), - pprof_cpu: *pprof_cpu, - host, - } -} diff --git a/o1vm/src/cli/cannon.rs b/o1vm/src/cli/cannon.rs new file mode 100644 index 0000000000..58d2384375 --- /dev/null +++ b/o1vm/src/cli/cannon.rs @@ -0,0 +1,111 @@ +use crate::cannon::*; +use clap::{arg, Parser, Subcommand}; + +#[derive(Parser, Debug, Clone)] +pub struct MipsVmConfigurationArgs { + #[arg( + long, + value_name = "FILE", + default_value = "state.json", + help = "initial state file" + )] + input: String, + + #[arg( + long, + value_name = "FILE", + default_value = "out.json", + help = "output state file" + )] + output: String, + + #[arg( + long, + value_name = "FILE", + default_value = "meta.json", + help = "metadata file" + )] + meta: String, + + #[arg( + long = "proof-at", + short = 'p', + long, + value_name = "FREQ", + default_value = "never" + )] + proof_at: StepFrequency, + + #[arg( + long = "proof-fmt", + value_name = "FORMAT", + default_value = "proof-%d.json" + )] + proof_fmt: String, + + #[arg( + long = "snapshot-fmt", + value_name = "FORMAT", + default_value = "state-%d.json" + )] + snapshot_fmt: String, + + #[arg(long = "stop-at", value_name = "FREQ", default_value = "never")] + stop_at: StepFrequency, + + #[arg(long = "info-at", value_name = "FREQ", default_value = "never")] + info_at: StepFrequency, + + #[arg(long = "pprof.cpu", action = clap::ArgAction::SetTrue)] + pprof_cpu: bool, + + #[arg( + long = "snapshot-state-at", + value_name = "FREQ", + default_value = "never" + )] + snapshot_state_at: StepFrequency, + + #[arg(name = "host", value_name = "HOST", help = "host program specification [host program arguments]", num_args = 1.., last = true)] + host: Vec, +} + +impl From for VmConfiguration { + fn from(cfg: MipsVmConfigurationArgs) -> Self { + VmConfiguration { + input_state_file: cfg.input, + output_state_file: cfg.output, + metadata_file: cfg.meta, + proof_at: cfg.proof_at, + stop_at: cfg.stop_at, + snapshot_state_at: cfg.snapshot_state_at, + info_at: cfg.info_at, + proof_fmt: cfg.proof_fmt, + snapshot_fmt: cfg.snapshot_fmt, + pprof_cpu: cfg.pprof_cpu, + host: if cfg.host.is_empty() { + None + } else { + Some(HostProgram { + name: cfg.host[0].to_string(), + arguments: cfg.host[1..].to_vec(), + }) + }, + } + } +} + +#[derive(Parser, Debug, Clone)] +pub struct RunArgs { + #[command(flatten)] + pub vm_cfg: MipsVmConfigurationArgs, + #[arg(long = "preimage-db-dir", value_name = "PREIMAGE_DB_DIR")] + pub preimage_db_dir: Option, +} + +#[derive(Subcommand, Clone, Debug)] +pub enum Cannon { + Run(RunArgs), + #[command(name = "test-optimism-preimage-read")] + TestPreimageRead(RunArgs), +} diff --git a/o1vm/src/cli/mod.rs b/o1vm/src/cli/mod.rs new file mode 100644 index 0000000000..7f915aee74 --- /dev/null +++ b/o1vm/src/cli/mod.rs @@ -0,0 +1,14 @@ +use clap::Parser; + +pub mod cannon; + +#[derive(Parser, Debug, Clone)] +#[command( + name = "o1vm", + version = "0.1", + about = "o1vm - a generic purpose zero-knowledge virtual machine" +)] +pub enum Commands { + #[command(subcommand)] + Cannon(cannon::Cannon), +} diff --git a/o1vm/src/legacy/main.rs b/o1vm/src/legacy/main.rs index 749f5722b6..de34b29e80 100644 --- a/o1vm/src/legacy/main.rs +++ b/o1vm/src/legacy/main.rs @@ -1,11 +1,12 @@ use ark_ff::UniformRand; +use clap::Parser; use folding::decomposable_folding::DecomposableFoldingScheme; use kimchi::o1_utils; use kimchi_msm::{proof::ProofInputs, prover::prove, verifier::verify, witness::Witness}; use log::debug; use o1vm::{ cannon::{self, Meta, Start, State}, - cannon_cli, + cli, interpreters::{ keccak::{ column::{Steps, N_ZKVM_KECCAK_COLS, N_ZKVM_KECCAK_REL_COLS, N_ZKVM_KECCAK_SEL_COLS}, @@ -29,6 +30,7 @@ use o1vm::{ }, lookups::LookupTableIDs, preimage_oracle::PreImageOracle, + test_preimage_read, }; use poly_commitment::SRS as _; use std::{cmp::Ordering, collections::HashMap, fs::File, io::BufReader, process::ExitCode}; @@ -38,10 +40,8 @@ use strum::IntoEnumIterator; /// program. pub const DOMAIN_SIZE: usize = 1 << 15; -pub fn main() -> ExitCode { - let cli = cannon_cli::main_cli(); - - let configuration = cannon_cli::read_configuration(&cli.get_matches()); +pub fn cannon_main(args: cli::cannon::RunArgs) { + let configuration: cannon::VmConfiguration = args.vm_cfg.into(); let file = File::open(&configuration.input_state_file).expect("Error opening input state file "); @@ -327,5 +327,19 @@ pub fn main() -> ExitCode { } // TODO: Logic +} + +pub fn main() -> ExitCode { + let args = cli::Commands::parse(); + match args { + cli::Commands::Cannon(args) => match args { + cli::cannon::Cannon::Run(args) => { + cannon_main(args); + } + cli::cannon::Cannon::TestPreimageRead(args) => { + test_preimage_read::main(args); + } + }, + } ExitCode::SUCCESS } diff --git a/o1vm/src/lib.rs b/o1vm/src/lib.rs index 0ee9c5edd4..335442a57f 100644 --- a/o1vm/src/lib.rs +++ b/o1vm/src/lib.rs @@ -1,8 +1,7 @@ /// Modules mimicking the defined structures used by Cannon CLI. pub mod cannon; -/// A CLI mimicking the Cannon CLI. -pub mod cannon_cli; +pub mod cli; /// A module to load ELF files. pub mod elf_loader; @@ -28,6 +27,8 @@ pub mod ramlookup; pub mod utils; +pub mod test_preimage_read; + use kimchi::circuits::{ berkeley_columns::BerkeleyChallengeTerm, expr::{ConstantExpr, Expr}, diff --git a/o1vm/src/pickles/main.rs b/o1vm/src/pickles/main.rs index 5083d7d58d..1fca1f0d85 100644 --- a/o1vm/src/pickles/main.rs +++ b/o1vm/src/pickles/main.rs @@ -1,15 +1,16 @@ use ark_ff::UniformRand; +use clap::Parser; use kimchi::circuits::domains::EvaluationDomains; use kimchi_msm::expr::E; use log::debug; -use mina_curves::pasta::VestaParameters; +use mina_curves::pasta::{Fp, Vesta, VestaParameters}; use mina_poseidon::{ constants::PlonkSpongeConstantsKimchi, sponge::{DefaultFqSponge, DefaultFrSponge}, }; use o1vm::{ cannon::{self, Meta, Start, State}, - cannon_cli, + cli, interpreters::mips::{ column::N_MIPS_REL_COLS, constraints as mips_constraints, @@ -19,21 +20,18 @@ use o1vm::{ }, pickles::{proof::ProofInputs, prover, verifier}, preimage_oracle::PreImageOracle, + test_preimage_read, }; use poly_commitment::{ipa::SRS, SRS as _}; use std::{fs::File, io::BufReader, process::ExitCode, time::Instant}; use strum::IntoEnumIterator; -use mina_curves::pasta::{Fp, Vesta}; - pub const DOMAIN_SIZE: usize = 1 << 15; -pub fn main() -> ExitCode { - let cli = cannon_cli::main_cli(); - +pub fn cannon_main(args: cli::cannon::RunArgs) { let mut rng = rand::thread_rng(); - let configuration = cannon_cli::read_configuration(&cli.get_matches()); + let configuration: cannon::VmConfiguration = args.vm_cfg.into(); let file = File::open(&configuration.input_state_file).expect("Error opening input state file "); @@ -158,6 +156,19 @@ pub fn main() -> ExitCode { curr_proof_inputs = ProofInputs::new(DOMAIN_SIZE); } } - // TODO: Logic +} + +pub fn main() -> ExitCode { + let args = cli::Commands::parse(); + match args { + cli::Commands::Cannon(args) => match args { + cli::cannon::Cannon::Run(args) => { + cannon_main(args); + } + cli::cannon::Cannon::TestPreimageRead(args) => { + test_preimage_read::main(args); + } + }, + } ExitCode::SUCCESS } diff --git a/o1vm/src/test_preimage_read.rs b/o1vm/src/test_preimage_read.rs index 094702a8fc..ce68f0cd43 100644 --- a/o1vm/src/test_preimage_read.rs +++ b/o1vm/src/test_preimage_read.rs @@ -1,10 +1,9 @@ -use clap::Arg; -use log::{debug, error}; -use o1vm::{ - cannon::PreimageKey, - cannon_cli::{main_cli, read_configuration}, +use crate::{ + cannon::{PreimageKey, VmConfiguration}, + cli, preimage_oracle::{PreImageOracle, PreImageOracleT}, }; +use log::{debug, error}; use std::{ io::{self}, path::{Path, PathBuf}, @@ -12,25 +11,11 @@ use std::{ str::FromStr, }; -fn main() -> ExitCode { +pub fn main(args: cli::cannon::RunArgs) -> ExitCode { use rand::Rng; - env_logger::init(); - - // Add command-line parameter to read the Optimism op-program DB directory - let cli = main_cli().arg( - Arg::new("preimage-db-dir") - .long("preimage-db-dir") - .value_name("PREIMAGE_DB_DIR"), - ); - - // Now read matches with the additional argument(s) - let matches = cli.get_matches(); - - let configuration = read_configuration(&matches); - - // Get DB directory and abort if unset - let preimage_db_dir = matches.get_one::("preimage-db-dir"); + let configuration: VmConfiguration = args.vm_cfg.into(); + let preimage_db_dir = args.preimage_db_dir; if let Some(preimage_key_dir) = preimage_db_dir { let mut po = PreImageOracle::create(&configuration.host); diff --git a/o1vm/test_preimage_read.sh b/o1vm/test_preimage_read.sh index de5b68fc7e..f16303cb4c 100755 --- a/o1vm/test_preimage_read.sh +++ b/o1vm/test_preimage_read.sh @@ -2,7 +2,7 @@ # Test preimage read from VM request to server response # Usage: test_preimage_read.sh [OP_DB_DIR] [NETWORK_NAME] -source rpcs.sh +source ./rpcs.sh set +u if [ -z "${FILENAME}" ]; then @@ -36,7 +36,7 @@ NETWORK=${2:-sepolia} ################################################# # Run test with debug on -RUST_LOG=debug cargo run -r --bin test_optimism_preimage_read -- \ +RUST_LOG=debug cargo run -r --bin pickles_o1vm -- cannon test-optimism-preimage-read -- \ --preimage-db-dir ${DATADIR} -- \ op-program \ --log.level DEBUG \ From 8001eeae55d54959852488d232082abb9be7ef71 Mon Sep 17 00:00:00 2001 From: martyall Date: Wed, 18 Dec 2024 08:29:08 -0800 Subject: [PATCH 2/4] initialize logger in right place --- o1vm/src/legacy/main.rs | 3 +-- o1vm/src/pickles/main.rs | 3 +-- o1vm/test_preimage_read.sh | 2 +- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/o1vm/src/legacy/main.rs b/o1vm/src/legacy/main.rs index de34b29e80..ade183ede2 100644 --- a/o1vm/src/legacy/main.rs +++ b/o1vm/src/legacy/main.rs @@ -70,8 +70,6 @@ pub fn cannon_main(args: cli::cannon::RunArgs) { // Initialize some data used for statistical computations let start = Start::create(state.step as usize); - env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info")).init(); - let domain = kimchi::circuits::domains::EvaluationDomains::::create(DOMAIN_SIZE).unwrap(); let mut rng = o1_utils::tests::make_test_rng(None); @@ -330,6 +328,7 @@ pub fn cannon_main(args: cli::cannon::RunArgs) { } pub fn main() -> ExitCode { + env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info")).init(); let args = cli::Commands::parse(); match args { cli::Commands::Cannon(args) => match args { diff --git a/o1vm/src/pickles/main.rs b/o1vm/src/pickles/main.rs index 1fca1f0d85..03ce2c7fa8 100644 --- a/o1vm/src/pickles/main.rs +++ b/o1vm/src/pickles/main.rs @@ -60,8 +60,6 @@ pub fn cannon_main(args: cli::cannon::RunArgs) { // Initialize some data used for statistical computations let start = Start::create(state.step as usize); - env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info")).init(); - let domain_fp = EvaluationDomains::::create(DOMAIN_SIZE).unwrap(); let srs: SRS = { let srs = SRS::create(DOMAIN_SIZE); @@ -159,6 +157,7 @@ pub fn cannon_main(args: cli::cannon::RunArgs) { } pub fn main() -> ExitCode { + env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info")).init(); let args = cli::Commands::parse(); match args { cli::Commands::Cannon(args) => match args { diff --git a/o1vm/test_preimage_read.sh b/o1vm/test_preimage_read.sh index f16303cb4c..e9826e71d7 100755 --- a/o1vm/test_preimage_read.sh +++ b/o1vm/test_preimage_read.sh @@ -2,7 +2,7 @@ # Test preimage read from VM request to server response # Usage: test_preimage_read.sh [OP_DB_DIR] [NETWORK_NAME] -source ./rpcs.sh +source rpcs.sh set +u if [ -z "${FILENAME}" ]; then From 14a906fd3b7f55796147906fe71af04ca7d1556d Mon Sep 17 00:00:00 2001 From: martyall Date: Wed, 18 Dec 2024 08:55:30 -0800 Subject: [PATCH 3/4] it's important that host is last --- o1vm/src/cli/cannon.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/o1vm/src/cli/cannon.rs b/o1vm/src/cli/cannon.rs index 58d2384375..879036e083 100644 --- a/o1vm/src/cli/cannon.rs +++ b/o1vm/src/cli/cannon.rs @@ -97,10 +97,11 @@ impl From for VmConfiguration { #[derive(Parser, Debug, Clone)] pub struct RunArgs { - #[command(flatten)] - pub vm_cfg: MipsVmConfigurationArgs, #[arg(long = "preimage-db-dir", value_name = "PREIMAGE_DB_DIR")] pub preimage_db_dir: Option, + // it's important that vm_cfg is last in order to properly parse the host field + #[command(flatten)] + pub vm_cfg: MipsVmConfigurationArgs, } #[derive(Subcommand, Clone, Debug)] From cbf5b1f8d43ac8cac610e33075ea9fb70fe8e9cf Mon Sep 17 00:00:00 2001 From: martyall Date: Wed, 18 Dec 2024 14:49:08 -0800 Subject: [PATCH 4/4] remove extra -- --- o1vm/run-vm.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/o1vm/run-vm.sh b/o1vm/run-vm.sh index bd970354cc..b617ab68d3 100755 --- a/o1vm/run-vm.sh +++ b/o1vm/run-vm.sh @@ -30,7 +30,7 @@ fi cargo run --bin ${BINARY_FLAVOR} \ --all-features \ --release \ - -p o1vm cannon run -- \ + -p o1vm cannon run \ --pprof.cpu \ --info-at "${INFO_AT:-%10000000}" \ --snapshot-state-at "${SNAPSHOT_STATE_AT:-%10000000}" \