-
Notifications
You must be signed in to change notification settings - Fork 13
feat(rln): extend error handling for rln module #358
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
base: master
Are you sure you want to change the base?
Conversation
… error types and propagate errors in calc_witness function
Benchmark for 4d261f4Click to view benchmark
|
Benchmark for 4d261f4Click to view benchmark
|
…it, and hasher modules, add PoseidonError type
Benchmark for 1f7375dClick to view benchmark
|
Benchmark for 1f7375dClick to view benchmark
|
Benchmark for d9ce2d9Click to view benchmark
|
Benchmark for d9ce2d9Click to view benchmark
|
…oduce HashError type
Benchmark for 38bb2d9Click to view benchmark
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR extends error handling throughout the RLN module by converting hash and witness calculation functions from panic-based error handling to proper Result types. The key changes include introducing structured error types (PoseidonError, HashError, WitnessCalcError), updating all hash function signatures to return Result, and propagating errors through the call chain.
Key Changes:
- Introduced structured error types for Poseidon hashing, general hashing, and witness calculation operations
- Converted
poseidon_hash,hash_to_field_le,hash_to_field_be, and keygen functions to returnResultinstead of panicking - Updated the
Hashertrait to include an associatedErrortype and modified thehashmethod to returnResult - Propagated error handling changes through Merkle tree operations, proof generation/verification, and FFI interfaces
- Restructured module exports in
utilscrate, removing wildcard re-exports (breaking API change) - Updated error messages for consistency and capitalization
- Made several internal modules public (
rln/src/protocolsubmodules,rln-wasm/srcmodules)
Reviewed changes
Copilot reviewed 47 out of 47 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
utils/src/error.rs |
Introduced new HashError enum wrapping Poseidon and generic hash errors |
utils/src/poseidon/error.rs |
Added PoseidonError enum for input validation errors |
utils/src/poseidon/poseidon_hash.rs |
Updated hash() to return Result<F, PoseidonError> with improved error handling |
utils/src/merkle_tree/merkle_tree.rs |
Extended Hasher trait with Error associated type and fallible hash() method |
utils/src/merkle_tree/error.rs |
Added HashError variant to ZerokitMerkleTreeError |
utils/src/merkle_tree/optimal_merkle_tree.rs |
Propagated hash errors through tree operations and proof computation |
utils/src/merkle_tree/full_merkle_tree.rs |
Updated hash operations to handle errors with parallel processing support |
rln/src/hashers.rs |
Converted hash functions to return Result types with proper error handling |
rln/src/protocol/keygen.rs |
Updated all keygen functions to return Result types |
rln/src/protocol/witness.rs |
Propagated errors through witness and tree root computation |
rln/src/protocol/proof.rs |
Added error handling for witness calculation |
rln/src/circuit/error.rs |
Added WitnessCalcError enum for witness calculation failures |
rln/src/circuit/iden3calc.rs |
Converted witness calculation to proper error handling |
rln/src/error.rs |
Enhanced error types with better documentation and error message formatting |
rln/src/ffi/ffi_utils.rs |
Updated FFI functions to return CResult for proper error propagation to C/foreign interfaces |
rln/src/pm_tree_adapter.rs |
Added TODOs for pmtree error handling limitations |
utils/src/lib.rs |
Removed wildcard re-exports (breaking change) |
rln/src/protocol/mod.rs |
Made submodules public (API surface expansion) |
rln/src/prelude.rs |
Changed to wildcard import (potential naming conflicts) |
| Tests and examples | Updated all call sites to handle new Result types with .unwrap() or proper error handling |
| FFI examples (C/Nim) | Updated to handle new CResult return types |
| WASM bindings | Updated functions to return Result<T, String> |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Benchmark for 38bb2d9Click to view benchmark
|
Benchmark for 99963c3Click to view benchmark
|
Benchmark for 99963c3Click to view benchmark
|
Benchmark for 6e359ecClick to view benchmark
|
Benchmark for 6e359ecClick to view benchmark
|
|
@vinhtc27 could you please also change expect to proper error handle? Because expect return panic if something going wrong |
No description provided.