Skip to content

Commit

Permalink
fix bytecode input (#179)
Browse files Browse the repository at this point in the history
  • Loading branch information
Leo authored Dec 29, 2023
1 parent aa1db5c commit 45b08c3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
2 changes: 1 addition & 1 deletion zkvm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ backend = { git = "https://github.com/powdr-labs/powdr.git", branch = "main", pa

[dev-dependencies]
env_logger = "0.10"

hex = "0.4.3"
23 changes: 16 additions & 7 deletions zkvm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ mod tests {
};
use std::path::PathBuf;

static BYTECODE: &str = "61029a60005260206000f3";

#[test]
fn compile_rust_riscv() {
env_logger::try_init().unwrap_or_default();
Expand All @@ -23,24 +25,31 @@ mod tests {
// Compile REVM to powdr asm
let powdr_asm = compile_rust(case, &temp_dir, true, &coprocessors, true).unwrap();

let bytes = hex::decode(BYTECODE).unwrap();

let length: GoldilocksField = (bytes.len() as u64).into();
let mut bytecode: Vec<GoldilocksField> = vec![length];
bytecode.extend(bytes.into_iter().map(|x| GoldilocksField::from(x as u64)));

// Load the powdr asm
let pipeline_factory =
|| Pipeline::default().from_asm_string(powdr_asm.1.clone(), Some(PathBuf::from(case)));
let pipeline_factory = || {
Pipeline::default()
.from_asm_string(powdr_asm.1.clone(), Some(PathBuf::from(case)))
.with_prover_inputs(bytecode.clone())
};

// Execute the evm and generate inputs for segment
let bootloader_inputs = rust_continuations_dry_run::<GoldilocksField>(
pipeline_factory(),
[11, 97, 2, 154, 96, 0, 82, 96, 32, 96, 0, 243]
.map(GoldilocksField::from)
.into(),
bytecode.clone()
);

// Build the wtns and proof
let prove_with = Some(BackendType::EStark);
//let prove_with = Some(BackendType::EStark);
let generate_witness_and_prove_maybe =
|mut pipeline: Pipeline<F>| -> Result<(), Vec<String>> {
pipeline.advance_to(Stage::GeneratedWitness).unwrap();
prove_with.map(|backend| pipeline.with_backend(backend).proof().unwrap());
//prove_with.map(|backend| pipeline.with_backend(backend).proof().unwrap());
Ok(())
};

Expand Down

0 comments on commit 45b08c3

Please sign in to comment.