DelphinusLab/zkWasm

Program panic at etable assignment

Closed this issue · 1 comments

Running a relatively small case mem.wasm (link), around 15K.
It passes the setup, and when doing single-prove, got:

·Start:   Assign etable
thread 'main' panicked at 'assigned value 0x000000000000000000000000000000000000000000000000000000000002fed4 exceeds the limit 0x000000000000000000000000000000000000000000000000000000000001ffff', /Users/jiazhengliu/Tools/zkWasm/crates/zkwasm/src/circuits/cell.rs:136:1
stack backtrace:
...
15:        0x1044e5654 - <delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell<F> as delphinus_zkwasm::circuits::cell::CellExpression<F>>::assign::hc1d4aa78ef4d252f
  16:        0x104536468 - <delphinus_zkwasm::circuits::etable::op_configure::op_load::LoadConfig<F> as delphinus_zkwasm::circuits::etable::EventTableOpcodeConfig<F>>::assign::h7c24dbcf29010f18
  17:        0x1044d27e8 - delphinus_zkwasm::circuits::etable::assign::<impl delphinus_zkwasm::circuits::etable::EventTableChip<F>>::assign::hdc042e9a48bd1b6d
  18:        0x104485e14 - delphinus_zkwasm::circuits::test_circuit::<impl halo2_proofs::plonk::circuit::Circuit<F> for delphinus_zkwasm::circuits::TestCircuit<F>>::synthesize::{{closure}}::h77c9c470bab2fa0c
  19:        0x1044819f8 - <halo2_proofs::circuit::floor_planner::single_pass::SingleChipLayouter<F,CS> as halo2_proofs::circuit::Layouter<F>>::assign_region::hd6429f8e98b2bd94
  20:        0x104370cfc - delphinus_zkwasm::circuits::test_circuit::<impl halo2_proofs::plonk::circuit::Circuit<F> for delphinus_zkwasm::circuits::TestCircuit<F>>::synthesize::h6d29ae03f12da0f6
  21:        0x10447402c - <halo2_proofs::circuit::floor_planner::single_pass::SimpleFloorPlanner as halo2_proofs::plonk::circuit::FloorPlanner>::synthesize::hef6510d4140eff16
  22:        0x1043d3c04 - halo2_proofs::dev::MockProver<F>::run::h95826839c1d39f49
  23:        0x10439cebc - delphinus_zkwasm::loader::ZkWasmLoader<E>::mock_test::ha9ab262815f2cfa3
  24:        0x10456a1cc - delphinus_cli::exec::exec_create_proof::h3f03cfd376f7df45
  25:        0x1043cd258 - delphinus_cli::main::ha940b7a4b0bb7034
  26:        0x10450aeb8 - std::sys_common::backtrace::__rust_begin_short_backtrace::h30619b6ea1c84027
  27:        0x10455d22c - std::rt::lang_start::{{closure}}::hfaff7120401c5690

It looks like the parameter controlling how many rows to allocate.
The source code is in cell.rs:

define_cell!(
    AllocatedCommonRangeCell,
    F::from((1u64 << (zkwasm_k() - 1)) - 1)
);

I have try to set env as the code suggests:

lazy_static! {
    static ref ZKWASM_K: Mutex<u32> =
        Mutex::new(env::var("ZKWASM_K").map_or(MIN_K, |k| k.parse().unwrap()));
}

By doing export ZKWASM_K=22 it does not take it in program and returns same error above.

Then I fix the zkwasm_k() to constant 22 and gets another error in setup:

Thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: NotEnoughRowsAvailable { current_k: 18 }', /Users/jiazhengliu/Tools/zkWasm/crates/zkwasm/src/loader/mod.rs:152:41

 16:        0x10277add8 - delphinus_zkwasm::loader::ZkWasmLoader<E>::create_vkey::he246a0e08690587c
  17:        0x102949678 - delphinus_cli::exec::exec_setup::h6e8fa08b964c2acc
  18:        0x1027acbb4 - delphinus_cli::main::ha940b7a4b0bb7034
  19:        0x1028eb2bc - std::sys_common::backtrace::__rust_begin_short_backtrace::h30619b6ea1c84027
  20:        0x10293d630 - std::rt::lang_start::{{closure}}::hfaff7120401c5690

It would be appreciated if semantics of zkwasm_k could be explained and how to control those parameters to balance the rows scale.

It seems that only one-in-all solution is to specify -k in cli.
Test case passed after setting this.