Skip to content

Commit

Permalink
fix examples compiling error
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason committed Sep 12, 2024
1 parent 5276661 commit f9882f3
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 47 deletions.
2 changes: 1 addition & 1 deletion crates/cli/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use delphinus_zkwasm::checksum::ImageCheckSum;
use delphinus_zkwasm::circuits::ZkWasmCircuit;
use delphinus_zkwasm::loader::ZkWasmLoader;
use delphinus_zkwasm::runtime::host::HostEnvBuilder;
use delphinus_zkwasm::runtime::monitor::plugins::table::InMemoryBackend;
use delphinus_zkwasm::runtime::monitor::table_monitor::TableMonitor;
use halo2_proofs::arithmetic::CurveAffine;
use halo2_proofs::pairing::bn256::Bn256;
Expand All @@ -23,7 +24,6 @@ use halo2_proofs::plonk::Circuit;
use halo2_proofs::plonk::CircuitData;
use halo2_proofs::poly::commitment::Params;
use specs::slice::Slice;
use specs::slice_backend::memory::InMemoryBackend;
use specs::CompilationTable;

use crate::args::HostMode;
Expand Down
4 changes: 2 additions & 2 deletions crates/playground/examples/binary_search.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use anyhow::Result;
use delphinus_zkwasm::circuits::config::MIN_K;
use delphinus_zkwasm::loader::slice::Slices;
use delphinus_zkwasm::loader::TraceBackend;
use delphinus_zkwasm::loader::ZkWasmLoader;
use delphinus_zkwasm::runtime::host::default_env::DefaultHostEnvBuilder;
use delphinus_zkwasm::runtime::host::default_env::ExecutionArg;
use delphinus_zkwasm::runtime::host::HostEnvBuilder;
use delphinus_zkwasm::runtime::monitor::plugins::table::InMemoryBackend;
use delphinus_zkwasm::runtime::monitor::table_monitor::TableMonitor;
use pairing_bn256::bn256::Fr;
use std::cell::RefCell;
Expand All @@ -29,8 +29,8 @@ fn main() -> Result<()> {
let mut monitor = TableMonitor::new(
K,
env_builder.create_flush_strategy(),
Box::<InMemoryBackend>::default(),
&vec![],
TraceBackend::Memory,
&env,
);
let loader = ZkWasmLoader::new(K, env)?;
Expand Down
38 changes: 17 additions & 21 deletions crates/playground/examples/context.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use anyhow::Result;
use delphinus_zkwasm::circuits::config::MIN_K;
use delphinus_zkwasm::loader::slice::Slices;
use delphinus_zkwasm::loader::TraceBackend;
use delphinus_zkwasm::loader::ZkWasmLoader;
use delphinus_zkwasm::runtime::host::default_env::DefaultHostEnvBuilder;
use delphinus_zkwasm::runtime::host::default_env::ExecutionArg;
use delphinus_zkwasm::runtime::host::HostEnvBuilder;
use delphinus_zkwasm::runtime::monitor::plugins::table::InMemoryBackend;
use delphinus_zkwasm::runtime::monitor::table_monitor::TableMonitor;
use pairing_bn256::bn256::Fr;
use std::cell::RefCell;
Expand All @@ -21,21 +21,19 @@ fn main() -> Result<()> {
let context_output = {
let env_builder = DefaultHostEnvBuilder::new(K);

let env = env_builder.create_env(
ExecutionArg {
public_inputs: vec![],
private_inputs: vec![],
context_inputs: vec![2, 1],
indexed_witness: Rc::new(RefCell::new(HashMap::default())),
tree_db: None,
},
);
let env = env_builder.create_env(ExecutionArg {
public_inputs: vec![],
private_inputs: vec![],
context_inputs: vec![2, 1],
indexed_witness: Rc::new(RefCell::new(HashMap::default())),
tree_db: None,
});

let mut monitor = TableMonitor::new(
K,
env_builder.create_flush_strategy(),
Box::<InMemoryBackend>::default(),
&vec![],
TraceBackend::Memory,
&env,
);
let loader = ZkWasmLoader::new(K, env)?;
Expand All @@ -52,21 +50,19 @@ fn main() -> Result<()> {
{
let env_builder = DefaultHostEnvBuilder::new(K);

let env = env_builder.create_env(
ExecutionArg {
public_inputs: vec![],
private_inputs: vec![],
context_inputs: context_output.0,
indexed_witness: Rc::new(RefCell::new(HashMap::default())),
tree_db: None,
},
);
let env = env_builder.create_env(ExecutionArg {
public_inputs: vec![],
private_inputs: vec![],
context_inputs: context_output.0,
indexed_witness: Rc::new(RefCell::new(HashMap::default())),
tree_db: None,
});

let mut monitor = TableMonitor::new(
K,
env_builder.create_flush_strategy(),
Box::<InMemoryBackend>::default(),
&vec![],
TraceBackend::Memory,
&env,
);
let loader = ZkWasmLoader::new(K, env)?;
Expand Down
20 changes: 9 additions & 11 deletions crates/playground/examples/fibonacci.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use anyhow::Result;
use delphinus_zkwasm::circuits::config::MIN_K;
use delphinus_zkwasm::loader::slice::Slices;
use delphinus_zkwasm::loader::TraceBackend;
use delphinus_zkwasm::loader::ZkWasmLoader;
use delphinus_zkwasm::runtime::host::default_env::DefaultHostEnvBuilder;
use delphinus_zkwasm::runtime::host::default_env::ExecutionArg;
use delphinus_zkwasm::runtime::host::HostEnvBuilder;
use delphinus_zkwasm::runtime::monitor::plugins::table::InMemoryBackend;
use delphinus_zkwasm::runtime::monitor::table_monitor::TableMonitor;
use pairing_bn256::bn256::Fr;
use std::cell::RefCell;
Expand All @@ -19,20 +19,18 @@ fn main() -> Result<()> {
let module = ZkWasmLoader::parse_module(&wasm)?;
let env_builder = DefaultHostEnvBuilder::new(K);

let env = env_builder.create_env(
ExecutionArg {
public_inputs: vec![5],
private_inputs: vec![],
context_inputs: vec![],
indexed_witness: Rc::new(RefCell::new(HashMap::default())),
tree_db: None,
},
);
let env = env_builder.create_env(ExecutionArg {
public_inputs: vec![5],
private_inputs: vec![],
context_inputs: vec![],
indexed_witness: Rc::new(RefCell::new(HashMap::default())),
tree_db: None,
});
let mut monitor = TableMonitor::new(
K,
env_builder.create_flush_strategy(),
Box::<InMemoryBackend>::default(),
&vec![],
TraceBackend::Memory,
&env,
);
let loader = ZkWasmLoader::new(K, env)?;
Expand Down
20 changes: 9 additions & 11 deletions crates/playground/examples/phantom.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use anyhow::Result;
use delphinus_zkwasm::circuits::config::MIN_K;
use delphinus_zkwasm::loader::slice::Slices;
use delphinus_zkwasm::loader::TraceBackend;
use delphinus_zkwasm::loader::ZkWasmLoader;
use delphinus_zkwasm::runtime::host::default_env::DefaultHostEnvBuilder;
use delphinus_zkwasm::runtime::host::default_env::ExecutionArg;
use delphinus_zkwasm::runtime::host::HostEnvBuilder;
use delphinus_zkwasm::runtime::monitor::plugins::table::InMemoryBackend;
use delphinus_zkwasm::runtime::monitor::table_monitor::TableMonitor;
use pairing_bn256::bn256::Fr;
use std::cell::RefCell;
Expand All @@ -19,20 +19,18 @@ fn main() -> Result<()> {
let module = ZkWasmLoader::parse_module(&wasm)?;
let env_builder = DefaultHostEnvBuilder::new(K);

let env = env_builder.create_env(
ExecutionArg {
public_inputs: vec![2],
private_inputs: vec![],
context_inputs: vec![],
indexed_witness: Rc::new(RefCell::new(HashMap::default())),
tree_db: None,
},
);
let env = env_builder.create_env(ExecutionArg {
public_inputs: vec![2],
private_inputs: vec![],
context_inputs: vec![],
indexed_witness: Rc::new(RefCell::new(HashMap::default())),
tree_db: None,
});
let mut monitor = TableMonitor::new(
K,
env_builder.create_flush_strategy(),
Box::<InMemoryBackend>::default(),
&vec!["search".to_string()],
TraceBackend::Memory,
&env,
);
let loader = ZkWasmLoader::new(K, env)?;
Expand Down
2 changes: 2 additions & 0 deletions crates/zkwasm/src/runtime/monitor/plugins/table/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ mod frame_table_builder;
mod instruction;
mod slice_builder;

pub use specs::slice_backend::memory::InMemoryBackend;

const DEFAULT_MEMORY_INDEX: u32 = 0;
const DEFAULT_TABLE_INDEX: u32 = 0;

Expand Down
2 changes: 1 addition & 1 deletion test_cli.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ test_continuation_cli() {
rm -rf params/*.data params/*.config output
$CLI --params ./params fibonacci setup
$CLI --params ./params fibonacci dry-run --wasm crates/zkwasm/wasm/fibonacci.wasm --public 25:i64 --output ./output
$CLI --params ./params fibonacci prove --wasm crates/zkwasm/wasm/fibonacci.wasm --public 25:i64 --output ./output
$CLI --params ./params fibonacci prove --wasm crates/zkwasm/wasm/fibonacci.wasm --public 25:i64 --output ./output --file
$CLI --params ./params fibonacci verify --output ./output
}

Expand Down

0 comments on commit f9882f3

Please sign in to comment.