Skip to content

Commit

Permalink
add a mechanism to flush slice (#284)
Browse files Browse the repository at this point in the history
* feat: support external host table slices

* add a mechanism to flush slice

* bump zkwasm-host-circuits

* bump ecc related dependences

* bump halo2aggregator

---------

Co-authored-by: sinka <[email protected]>
  • Loading branch information
junyu0312 and xgaozoyoe authored Aug 29, 2024
1 parent ff37c96 commit eec516c
Show file tree
Hide file tree
Showing 27 changed files with 1,335 additions and 737 deletions.
150 changes: 109 additions & 41 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@ rayon = "1.8.0"
regex = "1.10.2"
static_assertions = "1.1.0"
wasmi = { path = "third-party/wasmi" }
zkwasm-host-circuits = { git = "https://github.com/DelphinusLab/zkWasm-host-circuits.git" }
circuits-batcher = { git = "https://github.com/DelphinusLab/continuation-batcher.git" }
zkwasm-host-circuits = { git = "https://github.com/DelphinusLab/zkWasm-host-circuits.git", branch="host-op-1.8" }
circuits-batcher = { git = "https://github.com/DelphinusLab/continuation-batcher.git", tag="on-prove-pairing-2.2" }
poseidon = { git = "https://github.com/DelphinusLab/poseidon" }

[profile.dev]
opt-level = 3

11 changes: 8 additions & 3 deletions crates/cli/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,14 @@ impl SetupArg {
}
};

let env = env_builder.create_env_without_value(self.k);
let mut monitor =
TableMonitor::new(self.k, &self.phantom_functions, TraceBackend::Memory, &env);
let env = env_builder.create_env_without_value();
let mut monitor = TableMonitor::new(
self.k,
env_builder.create_flush_strategy(),
&self.phantom_functions,
TraceBackend::Memory,
&env,
);

let loader = ZkWasmLoader::new(self.k, env)?;

Expand Down
12 changes: 9 additions & 3 deletions crates/cli/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ impl Config {
) -> Result<()> {
let module = self.read_wasm_image(wasm_image)?;

let env = env_builder.create_env(self.k, arg);
let env = env_builder.create_env(arg);

let mut monitor = StatisticMonitor::new(&self.phantom_functions, &env, instruction_limit);

Expand Down Expand Up @@ -256,9 +256,15 @@ impl Config {
println!("{} Load params...", style("[2/8]").bold().dim(),);
let params = self.read_params(params_dir)?;

let env = env_builder.create_env(self.k, arg);
let env = env_builder.create_env(arg);

let mut monitor = TableMonitor::new(self.k, &self.phantom_functions, table_backend, &env);
let mut monitor = TableMonitor::new(
self.k,
env_builder.create_flush_strategy(),
&self.phantom_functions,
table_backend,
&env,
);

let (result, tables) = {
println!("{} Executing...", style("[3/8]").bold().dim(),);
Expand Down
12 changes: 6 additions & 6 deletions crates/cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ fn main() -> Result<()> {
match cli.subcommand {
Subcommands::Setup(arg) => {
let env_builder: Box<dyn HostEnvBuilder> = match arg.host_mode {
HostMode::Default => Box::new(DefaultHostEnvBuilder),
HostMode::Standard => Box::<StandardHostEnvBuilder>::default(),
HostMode::Default => Box::new(DefaultHostEnvBuilder::new(arg.k)),
HostMode::Standard => Box::new(StandardHostEnvBuilder::new(arg.k)),
};

arg.setup(&*env_builder, &cli.name, &cli.params_dir)?;
Expand All @@ -73,8 +73,8 @@ fn main() -> Result<()> {
let context_inputs = parse_args(&arg.running_arg.context_inputs);

let env_builder: Box<dyn HostEnvBuilder> = match config.host_mode {
HostMode::Default => Box::new(DefaultHostEnvBuilder),
HostMode::Standard => Box::<StandardHostEnvBuilder>::default(),
HostMode::Default => Box::new(DefaultHostEnvBuilder::new(config.k)),
HostMode::Standard => Box::new(StandardHostEnvBuilder::new(config.k)),
};

config.dry_run(
Expand Down Expand Up @@ -144,8 +144,8 @@ fn main() -> Result<()> {
};

let env_builder: Box<dyn HostEnvBuilder> = match config.host_mode {
HostMode::Default => Box::new(DefaultHostEnvBuilder),
HostMode::Standard => Box::<StandardHostEnvBuilder>::default(),
HostMode::Default => Box::new(DefaultHostEnvBuilder::new(config.k)),
HostMode::Standard => Box::new(StandardHostEnvBuilder::new(config.k)),
};

config.prove(
Expand Down
2 changes: 1 addition & 1 deletion crates/host/src/host/merkle_helper/merkle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use zkwasm_host_circuits::host::ForeignInst::MerkleSetRoot;
use zkwasm_host_circuits::host::Reduce;
use zkwasm_host_circuits::host::ReduceRule;

const MERKLE_TREE_HEIGHT: usize = 32;
use crate::MERKLE_TREE_HEIGHT;

pub struct MerkleContext {
pub k: u32,
Expand Down
Loading

0 comments on commit eec516c

Please sign in to comment.