Skip to content

Commit

Permalink
refactor: bumping up to Miden v0.7 to clean up a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
Domi1999 authored and Dominik1999 committed Jan 4, 2024
1 parent b38e5f5 commit d70e990
Show file tree
Hide file tree
Showing 10 changed files with 46 additions and 321 deletions.
5 changes: 3 additions & 2 deletions benchmarking-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ edition = "2021"
[dependencies]
clap = { version = "4.0.0", features = ["derive"] }
hex = { version = "0.4.0", default-features = false }
miden-stdlib = { version = "0.5.0", package = "miden-stdlib", default-features = false }
miden_vm = { version = "0.6.0", package = "miden-vm", features = ["concurrent"]}
miden-air = { version = "0.7.0", package = "miden-air", default-features = false }
miden-stdlib = { version = "0.6.0", package = "miden-stdlib", default-features = false }
miden_vm = { version = "0.7.0", package = "miden-vm", features = ["concurrent"]}
serde = { version = "1", features = ["derive"] } # You only need this if you want app persistence
serde_json = "1.0.48"
19 changes: 14 additions & 5 deletions benchmarking-cli/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
mod utils_input;
mod utils_program;
use clap::Parser;
use miden_vm::ProofOptions;
use miden_vm::{ProvingOptions, DefaultHost, MemAdviceProvider};
use miden_air::ExecutionOptions;
use std::fs;
use std::time::Instant;

Expand Down Expand Up @@ -73,12 +74,18 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {

let program_to_run = program.program.clone().unwrap();

let host = DefaultHost::new(MemAdviceProvider::from(inputs.advice_provider.clone()));

let execution_options = ExecutionOptions::new(None, 64)
.map_err(|err| format!("{err}"))?;

// Execution time
let now = Instant::now();
let trace = miden_vm::execute(
&program_to_run,
inputs.stack_inputs.clone(),
inputs.advice_provider.clone(),
host,
execution_options,
)
.map_err(|err| format!("Failed to generate exection trace = {:?}", err))
.unwrap();
Expand All @@ -87,16 +94,18 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {

// Proving time
let proof_options = if args.security == "high" {
ProofOptions::with_128_bit_security(false)
ProvingOptions::with_128_bit_security(false)
} else {
ProofOptions::with_96_bit_security(false)
ProvingOptions::with_96_bit_security(false)
};

let host = DefaultHost::new(MemAdviceProvider::from(inputs.advice_provider));

let now = Instant::now();
let (output, proof) = miden_vm::prove(
&program.program.unwrap(),
inputs.stack_inputs.clone(),
inputs.advice_provider,
host,
proof_options,
)
.expect("Proving failed");
Expand Down
4 changes: 2 additions & 2 deletions benchmarking-cli/src/utils_input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ impl Inputs {
Self {
stack_inputs: StackInputs::new(vec![]),
advice_provider: MemAdviceProvider::default(),
stack_outputs: StackOutputs::new(vec![], vec![]),
stack_outputs: StackOutputs::new(vec![], vec![]).unwrap(),
}
}

Expand Down Expand Up @@ -252,7 +252,7 @@ fn test_parse_output() {
}"#;

let mut inputs: Inputs = Inputs::new();
inputs.deserialize_outputs(output_str).unwrap();
inputs.deserialize_inputs(output_str).unwrap();

let output: StackOutputs = inputs.stack_outputs;

Expand Down
10 changes: 4 additions & 6 deletions playground/miden-wasm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,11 @@ edition = "2021"
crate-type = ["cdylib", "rlib"]

[dependencies]
assembly = { package = "miden-assembly", git = "https://github.com/0xPolygonMiden/miden-vm.git", branch = "frisitano-tx-result", default-features = false }
assembly = { package = "miden-assembly", version = "0.7.0", default-features = false }
hex = { version = "0.4", default-features = false }
miden-vm = { package = "miden-vm", git = "https://github.com/0xPolygonMiden/miden-vm.git", branch = "frisitano-tx-result", default-features = false }
miden-tx = { git = "https://github.com/0xPolygonMiden/miden-base.git", branch = "frisitano-prover-tx", features = ["testing"], default-features = false }
miden-stdlib = { package = "miden-stdlib", git = "https://github.com/0xPolygonMiden/miden-vm.git", branch = "frisitano-tx-result", default-features = false }
miden-objects = { git = "https://github.com/0xPolygonMiden/miden-base.git", branch = "frisitano-prover-tx", features = ["testing"], default-features = false }
miden-lib = { git = "https://github.com/0xPolygonMiden/miden-base.git", branch = "frisitano-prover-tx", default-features = false }
miden-air = { package = "miden-air", version = "0.7.0", default-features = false }
miden-vm = { package = "miden-vm", version = "0.7.0", default-features = false }
miden-stdlib = { package = "miden-stdlib", version = "0.6.0", default-features = false }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
serde-wasm-bindgen = "0.4"
Expand Down
18 changes: 13 additions & 5 deletions playground/miden-wasm/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
mod transaction;
mod utils_debug;
mod utils_input;
mod utils_program;
use miden_vm::{ExecutionProof, ProofOptions};
use miden_vm::{ExecutionProof, ProvingOptions, DefaultHost, MemAdviceProvider};
use miden_air::ExecutionOptions;
use serde::{Deserialize, Serialize};
use wasm_bindgen::prelude::*;

Expand All @@ -28,10 +28,16 @@ pub fn run_program(code_frontend: &str, inputs_frontend: &str) -> Result<Outputs
.deserialize_inputs(inputs_frontend)
.map_err(|err| format!("Failed to deserialize inputs - {:?}", err))?;

let host = DefaultHost::new(MemAdviceProvider::from(inputs.advice_provider));

let execution_options = ExecutionOptions::new(None, 64 as u32)
.map_err(|err| format!("{err}"))?;

let trace = miden_vm::execute(
&program.program.unwrap(),
inputs.stack_inputs,
inputs.advice_provider,
host,
execution_options,
)
.map_err(|err| format!("Failed to generate execution trace - {:?}", err))?;

Expand Down Expand Up @@ -59,13 +65,15 @@ pub fn prove_program(code_frontend: &str, inputs_frontend: &str) -> Result<Outpu
.map_err(|err| format!("Failed to deserialize inputs - {:?}", err))?;

// default (96 bits of security)
let proof_options = ProofOptions::default();
let proof_options = ProvingOptions::default();

let host = DefaultHost::new(MemAdviceProvider::from(inputs.advice_provider));

let stack_input_cloned = inputs.stack_inputs.clone();
let (output, proof) = miden_vm::prove(
&program.program.unwrap(),
stack_input_cloned,
inputs.advice_provider,
host,
proof_options,
)
.map_err(|err| format!("Failed to prove execution - {:?}", err))?;
Expand Down
Loading

0 comments on commit d70e990

Please sign in to comment.