Skip to content
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

Replace panics with Results in the Rust bindings for much more descriptive failures #696

Closed
bkase opened this issue Jan 13, 2023 · 7 comments · Fixed by #872
Closed

Replace panics with Results in the Rust bindings for much more descriptive failures #696

bkase opened this issue Jan 13, 2023 · 7 comments · Fixed by #872
Assignees
Labels
error-messages Issues about making error messages better product-eng For tracking our team's issues to-discuss Issues to be discussed further

Comments

@bkase
Copy link
Member

bkase commented Jan 13, 2023

via @mrmr1993 There's a 2 line change to the WASM bindings which will give you a descriptive error instead of panicking when proving fails.

Make https://github.com/MinaProtocol/mina/blob/a3661e44e01b2c400d6eb5ac254c6ab7a91b3623/src/lib/crypto/kimchi_bindings/wasm/src/plonk_proof.rs#L551 return a Result<WasmProverProof, JSValue>
Change https://github.com/MinaProtocol/mina/blob/a3661e44e01b2c400d6eb5ac254c6ab7a91b3623/src/lib/crypto/kimchi_bindings/wasm/src/plonk_proof.rs#L612 to return maybe_proof.map_err(|str| str.into()) (or something like that), which will make it return the error as a JS exception

Additionally, https://github.com/MinaProtocol/mina/blob/a3661e44e01b2c400d6eb5ac254c6ab7a91b3623/src/lib/crypto/kimchi_bindings/wasm/src/plonk_proof.rs#L585

@bkase bkase added error-messages Issues about making error messages better to-discuss Issues to be discussed further labels Jan 13, 2023
@nicc
Copy link
Collaborator

nicc commented Jan 31, 2023

@nicc chat to Jo about whether zkApps Prod Eng. should be doing this

@nicc
Copy link
Collaborator

nicc commented Feb 10, 2023

For now zkApps Product should hold off and not implement this. It's likely to be a crypto thing. Will confirm

@jasongitmail
Copy link
Contributor

@nicc Following up on your last comment. I believe the comment is out of date and Product Eng can pursue this, is that your current understanding too?

@jasongitmail
Copy link
Contributor

@mitschabaude thinks this can likely be closed. Will confirm with crypto team first

@mitschabaude
Copy link
Member

The line Err(JsValue::from_str(err.to_string())) makes wasm-bindgen throw a string. It's definitely better to throw a JS Error, which panic! seems to do as well. So we should do something like Err(JsError::from(...))

@mitschabaude mitschabaude self-assigned this Mar 21, 2023
@mitschabaude
Copy link
Member

This is how it should be done:

return match maybe_proof {
    Ok(proof) => ...,
    Err(err) => Err(JsError::from(err))
}

@mitschabaude
Copy link
Member

Or like this:

Err(str) => Err(JsError::new(str)),

@nicc nicc added the product-eng For tracking our team's issues label Mar 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
error-messages Issues about making error messages better product-eng For tracking our team's issues to-discuss Issues to be discussed further
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants