Skip to content

Commit

Permalink
extend ExecutionArg
Browse files Browse the repository at this point in the history
  • Loading branch information
junyu0312 committed Aug 1, 2024
1 parent 0860174 commit e3a9cd7
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 23 deletions.
7 changes: 7 additions & 0 deletions crates/cli/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
#![deny(warnings)]
#![allow(clippy::too_many_arguments, clippy::while_let_on_iterator)]

use std::cell::RefCell;
use std::collections::HashMap;
use std::fs;
use std::path::PathBuf;
use std::rc::Rc;

use anyhow::Result;
use app_builder::app;
Expand Down Expand Up @@ -82,6 +85,8 @@ fn main() -> Result<()> {
public_inputs,
private_inputs,
context_inputs,
indexed_witness: Rc::new(RefCell::new(HashMap::default())),
tree_db: None,
},
arg.running_arg.context_output,
arg.instruction_limit,
Expand Down Expand Up @@ -152,6 +157,8 @@ fn main() -> Result<()> {
public_inputs,
private_inputs,
context_inputs,
indexed_witness: Rc::new(RefCell::new(HashMap::default())),
tree_db: None,
},
arg.running_arg.context_output,
arg.mock_test,
Expand Down
21 changes: 0 additions & 21 deletions crates/host/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,8 @@ use delphinus_zkwasm::runtime::host::HostEnvBuilder;
use serde::Deserialize;
use serde::Serialize;
use std::collections::HashMap;
use zkwasm_host_circuits::host::db::TreeDB;
use zkwasm_host_circuits::proof::OpType;

pub struct StandardExecutionArg {
/// Public inputs for `wasm_input(1)`
pub public_inputs: Vec<u64>,
/// Private inputs for `wasm_input(0)`
pub private_inputs: Vec<u64>,
/// Context inputs for `wasm_read_context()`
pub context_inputs: Vec<u64>,
/// indexed witness context
pub indexed_witness: Rc<RefCell<HashMap<u64, Vec<u64>>>>,
/// db src
pub tree_db: Option<Rc<RefCell<dyn TreeDB>>>,
}

#[derive(Serialize, Deserialize, Debug)]
pub struct HostEnvConfig {
pub ops: Vec<OpType>,
Expand Down Expand Up @@ -104,13 +90,6 @@ impl HostEnvBuilder for StandardHostEnvBuilder {
let host_env_config = HostEnvConfig {
ops: self.ops.clone(),
};
let arg = StandardExecutionArg {
public_inputs: arg.public_inputs,
private_inputs: arg.private_inputs,
context_inputs: arg.context_inputs,
indexed_witness: Rc::new(RefCell::new(HashMap::new())),
tree_db: None,
};

register_wasm_input_foreign(&mut env, arg.public_inputs, arg.private_inputs);
register_require_foreign(&mut env);
Expand Down
12 changes: 10 additions & 2 deletions crates/zkwasm/src/runtime/host/default_env.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
use std::cell::RefCell;
use std::collections::HashMap;
use std::rc::Rc;

use zkwasm_host_circuits::host::db::TreeDB;

use crate::foreign::context::runtime::register_context_foreign;
use crate::foreign::log_helper::register_log_foreign;
use crate::foreign::require_helper::register_require_foreign;
Expand All @@ -6,15 +12,17 @@ use crate::foreign::wasm_input_helper::runtime::register_wasm_input_foreign;
use super::host_env::HostEnv;
use super::HostEnvBuilder;

// TODO: remove me after refine tracer
#[derive(Clone)]
pub struct ExecutionArg {
/// Public inputs for `wasm_input(1)`
pub public_inputs: Vec<u64>,
/// Private inputs for `wasm_input(0)`
pub private_inputs: Vec<u64>,
/// Context inputs for `wasm_read_context()`
pub context_inputs: Vec<u64>,
/// indexed witness context
pub indexed_witness: Rc<RefCell<HashMap<u64, Vec<u64>>>>,
/// db src
pub tree_db: Option<Rc<RefCell<dyn TreeDB>>>,
}

pub struct DefaultHostEnvBuilder;
Expand Down

0 comments on commit e3a9cd7

Please sign in to comment.