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

Support args #29

Merged
merged 1 commit into from
Oct 18, 2024
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
5 changes: 5 additions & 0 deletions host-program/src/bin/zkm-prove.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
private_inputstream: "".into(),
seg_size: 0,
execute_only: false,
args: "".into(),
}
}
};
Expand Down Expand Up @@ -164,6 +165,7 @@ fn set_sha2_rust_input(seg_size_u: u32, execute_only_b: bool) -> anyhow::Result<
private_inputstream: pri_buf,
seg_size: seg_size_u,
execute_only: execute_only_b,
args: "".into(),
};

Ok(input)
Expand Down Expand Up @@ -236,6 +238,7 @@ fn set_sha2_go_input(seg_size_u: u32, execute_only_b: bool) -> anyhow::Result<Pr
private_inputstream: "".into(),
seg_size: seg_size_u,
execute_only: execute_only_b,
args: "".into(),
};

Ok(input)
Expand All @@ -249,6 +252,7 @@ fn set_mem_alloc_vec_input(seg_size_u: u32, execute_only_b: bool) -> anyhow::Res
private_inputstream: "".into(),
seg_size: seg_size_u,
execute_only: execute_only_b,
args: "".into(),
};

Ok(input)
Expand All @@ -263,6 +267,7 @@ fn set_revme_input(seg_size_u: u32, execute_only_b: bool) -> anyhow::Result<Prov
private_inputstream: "".into(),
seg_size: seg_size_u,
execute_only: execute_only_b,
args: "".into(),
};

Ok(input)
Expand Down
7 changes: 6 additions & 1 deletion sdk/src/local/stark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,14 @@ pub fn prove_stark(
let seg_size = input.seg_size as usize;
let file = ElfBytes::<AnyEndian>::minimal_parse(input.elf.as_slice())
.expect("opening elf file failed");
let mut args: Vec<&str> = input.args.split_whitespace().collect();
if args.len() > 2 {
args.truncate(2);
}
log::info!("args: {:?}", args);
let mut state = State::load_elf(&file);
state.patch_elf(&file);
state.patch_stack(vec![]);
state.patch_stack(args);

state.input_stream.push(input.public_inputstream.clone());
state.input_stream.push(input.private_inputstream.clone());
Expand Down
1 change: 1 addition & 0 deletions sdk/src/network/prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ impl Prover for NetworkProver {
public_input_stream: input.public_inputstream.clone(),
private_input_stream: input.private_inputstream.clone(),
execute_only: input.execute_only,
args: input.args.clone(),
..Default::default()
};
self.sign_ecdsa(&mut request).await;
Expand Down
1 change: 1 addition & 0 deletions sdk/src/prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ pub struct ProverInput {
pub private_inputstream: Vec<u8>,
pub seg_size: u32,
pub execute_only: bool,
pub args: String,
}

#[derive(Debug, Default, Deserialize, Serialize, Clone)]
Expand Down
Loading