-
Notifications
You must be signed in to change notification settings - Fork 118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
investigate chunking bug #1806
Comments
Observations after preliminary exploration of chunking bug in o1js with potential relations with Pickles code. TODO's throughout Pickles code
Domain size of wrap circuit
Verifier
ZK rows
Exceptions
/workspace_root/src/bindings/ocaml/overrides.js:45
if (err instanceof Error) throw err;
RuntimeError: unreachable
at __rg_oom (wasm://wasm/011a91aa:wasm-function[4848]:0x3e27c2)
at __rust_alloc_error_handler (wasm://wasm/011a91aa:wasm-function[4998]:0x3e3251)
at alloc::alloc::handle_alloc_error::rt_error::h6c30faefac1fefed (wasm://wasm/011a91aa:wasm-function[5056]:0x3e355f)
at alloc::alloc::handle_alloc_error::h6289c616c1280e38 (wasm://wasm/011a91aa:wasm-function[5055]:0x3e3554)
at alloc::raw_vec::RawVec<T,A>::reserve::do_reserve_and_handle::h41bc9aef765cae77 (wasm://wasm/011a91aa:wasm-function[3755]:0x3c27a7)
at <o1_utils::serialization::SerdeAs as serde_with::ser::SerializeAs<T>>::serialize_as::h1da92fe6ae712792 (wasm://wasm/011a91aa:wasm-function[2483]:0x366fca)
at serde_with::ser::const_arrays::<impl serde_with::ser::SerializeAs<[T; N]> for [As; N]>::serialize_as::h1233a3b3efbeac4b (wasm://wasm/011a91aa:wasm-function[1484]:0x2f0683)
at kimchi::circuits::constraints::_::<impl serde::ser::Serialize for kimchi::circuits::constraints::ColumnEvaluations<F>>::serialize::h2627bc77795152ac (wasm://wasm/011a91aa:wasm-function[1126]:0x2ad0c6)
at kimchi::prover_index::_::<impl serde::ser::Serialize for kimchi::prover_index::ProverIndex<G,OpeningProof>>::serialize::hf0dd2bc7ae7d95f7 (wasm://wasm/011a91aa:wasm-function[1589]:0x300c01)
at caml_pasta_fp_plonk_index_encode (wasm://wasm/011a91aa:wasm-function[1909]:0x32b28c)
at module.exports.caml_pasta_fp_plonk_index_encode (o1js/dist/node/bindings/compiled/_node_bindings/plonk_wasm.cjs:1475:14)
at encodeProverKey (o1js/src/lib/proof-system/prover-keys.ts:105:26)
at write_ (o1js/src/lib/proof-system/zkprogram.ts:1017:48)
at write$0 (src/bindings/ocaml/lib/pickles_bindings.ml:470:7)
at spec (src/bindings/ocaml/lib/pickles_bindings.ml:421:40)
at filter_map$1 (ocaml/base/list.ml:812:14)
at write$1 (src/bindings/ocaml/lib/pickles_bindings.ml:417:9)
at write$0 (src/mina/src/lib/key_cache/key_cache.ml:140:5)
at _iCZ_ (src/mina/src/lib/pickles/cache.ml:114:18)
at <anonymous> (src/mina/src/lib/promise/js/promise.js:25:37)
/workspace_root/src/bindings/ocaml/jsoo_exports/overrides.js:45
if (err instanceof Error) throw err;
^
Error: there are not enough random rows to achieve zero-knowledge (expected: 8, got: 3)
at module.exports.__wbindgen_error_new (o1js/dist/node/bindings/compiled/_node_bindings/plonk_wasm.cjs:9723:17)
at <wasm_bindgen::JsError as core::convert::From<E>>::from::he54f4fac6a715911 (wasm://wasm/01276de2:wasm-function[4435]:0x4041cf)
at caml_pasta_fp_plonk_proof_create (wasm://wasm/01276de2:wasm-function[660]:0x2496fd)
at module.exports.caml_pasta_fp_plonk_proof_create (o1js/dist/node/bindings/compiled/_node_bindings/plonk_wasm.cjs:2937:14)
at caml_pasta_fp_plonk_proof_create (src/mina/src/lib/crypto/kimchi_bindings/js/bindings.js:789:15)
at <anonymous> (src/mina/src/lib/crypto/kimchi_backend/pasta/vesta_based_plonk.ml:120:15)
HardcodedThe codebase is full of places where a hardcoded
ProposalsPR16057
PR16092
PR2590
## Wrap circuit As chunks increase, the number of commitments and verifier complexity also grows. That means the step circuit grows to fit the verifier computation. Then, the wrap circuit derived from it also grows. We would need to measure how much it grows to automatically overwrite the wrap circuit size. And when that circuit exceeds 2^16, chunk accordingly. This needs further engineering work, to replicate the same behavior in step circuits. Worst case, I would start by setting the number of chunks required in the wrap circuit to be the number of chunks of the step circuit. But it should be smaller (plus, I wonder if it would be a problem to set the chunks higher than actually needed, leaving "empty" chunks). |
Nice investigation @querolita!!
Judging from the trace, this is an out of memory error (" We might have to investigate and improve memory usage in Kimchi/Wasm! |
As originally suspected, the process runs out of memory before it can finish proving a circuit with even 2 chunks (or 2^17 constraints), as a result, we need to decide what approach we want to take next:
The current wasm memory limit is 4gb, which the process reaches quickly when trying to compile and prove a circuit of size 2^17 constraints (even slightly above 2^16 constraints). I estimate we would need at least 6 to 8gb for 2^17 constraints |
Memory64 can be used in Node.js with a flag, also in some nightly browsers behind a flag but you can't expect users to set those. Not sure about the state of the Rust compilation pipeline to wasm64. |
Rust can target wasm64 (memory64) as a compile target, but I am unsure if the rest of our stack is compatible with it. Either way, it would still be worth to investigate further. I could even see a world where we release chunking in an experimental state that only works with the correct node flags set, until memory64 lands in an official capacity |
Problem: Chunking is implemented in Kimchi and Pickles. However, some specific circuit configuration seem to cause a bug in Pickles. A prior RFC talks about these specific issues, which seem to be part of the wrap circuit (which needs to implement chunking as well)
Goal: Figure out what would need to be done in order to fully support chunking in o1js. Is it a relatively small engineering task or does it require further research?
The text was updated successfully, but these errors were encountered: