-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2882 from o1-labs/martin/cannon-cli-improvements
More robust o1vm cli
- Loading branch information
Showing
12 changed files
with
231 additions
and
196 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
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> [host program arguments]", num_args = 1.., last = true)] | ||
host: Vec<String>, | ||
} | ||
|
||
impl From<MipsVmConfigurationArgs> 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 { | ||
#[arg(long = "preimage-db-dir", value_name = "PREIMAGE_DB_DIR")] | ||
pub preimage_db_dir: Option<String>, | ||
// 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)] | ||
pub enum Cannon { | ||
Run(RunArgs), | ||
#[command(name = "test-optimism-preimage-read")] | ||
TestPreimageRead(RunArgs), | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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), | ||
} |
Oops, something went wrong.