Skip to content

Commit

Permalink
Always call console_error_panic_hook::set_once and remove ad-hoc us…
Browse files Browse the repository at this point in the history
…es of it

The WASM module now exports `console_error_panic_hook_set_once` which is an alias
for `console_error_panic_hook::set_once` to be called from the JS side.
It is always called when loading the module in the wrapper JS module.
  • Loading branch information
L-as committed Jun 29, 2023
1 parent a884c1f commit 9421672
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 3 deletions.
2 changes: 2 additions & 0 deletions js/wrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ export { getSnarky, getWasm, withThreadPool };

let getSnarky = () => snarky;

wasm.console_error_panic_hook_set_once();

function getWasm() {
return wasm;
}
5 changes: 5 additions & 0 deletions kimchi/wasm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ pub fn wait_until_non_zero(ptr: *const u32) -> u32 {
unreachable!();
}

#[wasm_bindgen]
pub fn console_error_panic_hook_set_once() {
console_error_panic_hook::set_once();
}

pub mod rayon;

/// Arkworks types
Expand Down
1 change: 0 additions & 1 deletion kimchi/wasm/src/pasta_fp_plonk_index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ pub fn caml_pasta_fp_plonk_index_create(
prev_challenges: i32,
srs: &WasmSrs,
) -> Result<WasmPastaFpPlonkIndex, JsError> {
console_error_panic_hook::set_once();
let index = crate::rayon::run_in_pool(|| {
// flatten the permutation information (because OCaml has a different way of keeping track of permutations)
let gates: Vec<_> = gates
Expand Down
1 change: 0 additions & 1 deletion kimchi/wasm/src/pasta_fq_plonk_index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ pub fn caml_pasta_fq_plonk_index_create(
prev_challenges: i32,
srs: &WasmSrs,
) -> Result<WasmPastaFqPlonkIndex, JsError> {
console_error_panic_hook::set_once();
let index = crate::rayon::run_in_pool(|| {
// flatten the permutation information (because OCaml has a different way of keeping track of permutations)
let gates: Vec<_> = gates
Expand Down
1 change: 0 additions & 1 deletion kimchi/wasm/src/plonk_proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,6 @@ macro_rules! impl_proof {
prev_challenges: WasmFlatVector<$WasmF>,
prev_sgs: WasmVector<$WasmG>,
) -> Result<WasmProverProof, JsError> {
console_error_panic_hook::set_once();
let (maybe_proof, public_input) = crate::rayon::run_in_pool(|| {
{
let ptr: &mut poly_commitment::srs::SRS<$G> =
Expand Down

0 comments on commit 9421672

Please sign in to comment.