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

[Go] [Rust] update language bindings to return value API #417

Merged
merged 26 commits into from
Jul 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
205ede8
refactor(Rust): start refactoring to idiomatic Rust API)
mratsim Jun 28, 2024
f04cb82
refactor(Go): start refactoring to idiomatic Go API
mratsim Jun 28, 2024
151f11c
refactor(C): ptrdiff_t -> size_t
mratsim Jun 28, 2024
d94518a
[Go] make Go API more statically typed, out param -> return value API
Vindaar Jun 29, 2024
37398d4
add helper function returning required size for EVM modexp, C API
Vindaar Jun 29, 2024
1350bcc
[Go] update all BLS sig tests for new API
Vindaar Jun 29, 2024
4bcb3e6
[Go] fix copy paste typo in EVM FP2 to G2
Vindaar Jun 29, 2024
daaec82
[Go] update Go EVM precompiles test for new API
Vindaar Jun 29, 2024
787454b
[rust] change Rust BLS signature API to return values, add missing
Vindaar Jul 2, 2024
b034d65
[rust] update tests for BLS signatures with new API
Vindaar Jul 2, 2024
d6534e7
[Go] add overlooked valid return value for unchecked deserialization
Vindaar Jul 2, 2024
19c9d93
[rust] update EVM precompiles API to return values
Vindaar Jul 2, 2024
46c372b
[rust] regenerate Rust bindings w/ modexp result alloc helper
Vindaar Jul 2, 2024
9d4e9d3
[rust] fix up tests for EVM precompiles
Vindaar Jul 2, 2024
f6639a5
[rust] add missing inline, add must_use, fix sha256 API isize -> usize
Vindaar Jul 3, 2024
282dd6f
[go] explicitly return `nil` in EvmSha256 for non error case
Vindaar Jul 3, 2024
1aaa392
[go] remove TODO comment
Vindaar Jul 3, 2024
83b6a92
[rust] fix naming of EVM precompiles test cases
Vindaar Jul 3, 2024
c20bb7c
[rust] simplify EVM precompiles tests using IntoIterator trait
Vindaar Jul 3, 2024
599fb40
add `eth_evm` prefix to EVM modexp result size helper
Vindaar Jul 3, 2024
9276171
[rust] update BLS sig API for ptrdiff_t -> csize_t change
Vindaar Jul 5, 2024
282dded
[rust] remove some warnings from BLS sig rust test
Vindaar Jul 5, 2024
6ea6efd
[rust] fix wrong size for FP2 to G2
Vindaar Jul 5, 2024
b1a9121
[rust] remove unused imports in EVM precompiles (and test)
Vindaar Jul 5, 2024
9a03e99
[rust] fix name of EVM precompiles test fn
Vindaar Jul 5, 2024
a4c8b68
[rust] minor clean up, also assert expected error given if fail
Vindaar Jul 5, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,23 @@ subroutines.
- https://github.com/rust-lang/rust/pull/76986
- https://github.com/rust-lang/rfcs/pull/2884

### Error codes, and Result

In low-level C, everything is return through status codes.

In Rust, status is communicated through `Result<Output, Error>`
In particular for verification, Errors are used if the protocol is not followed:
- wrong input length
- point not on curve
- point not in subgroup
- zero point

However if all those exceptional rules are followed, but verification still fails,
the failure is communicated through a boolean.

Similarly in Go, errors are used to communicate breaking protocol rules
and the result of verification is communicated through a bool.

## Code organization

TBD
8 changes: 4 additions & 4 deletions bindings/c_typedefs.nim
Original file line number Diff line number Diff line change
Expand Up @@ -175,18 +175,18 @@ proc toCparam*(name: string, typ: NimNode): string =
typ.treeRepr()
let sTyp = $typ[2]
if sTyp in TypeMap:
"const " & TypeMap[sTyp] & " " & name & "[], ptrdiff_t " & name & "_len"
"const " & TypeMap[sTyp] & " " & name & "[], size_t " & name & "_len"
else:
"const " & sTyp & " " & name & "[], ptrdiff_t " & name & "_len"
"const " & sTyp & " " & name & "[], size_t " & name & "_len"
elif typ.kind == nnkVarTy and typ[0].kind == nnkCall:
typ[0][0].expectKind(nnkOpenSymChoice)
doAssert typ[0][0][0].eqIdent"[]"
doAssert typ[0][1].eqIdent"openArray"
let sTyp = $typ[0][2]
if sTyp in TypeMap:
TypeMap[sTyp] & " " & name & "[], ptrdiff_t " & name & "_len"
TypeMap[sTyp] & " " & name & "[], size_t " & name & "_len"
else:
sTyp & " " & name & "[], ptrdiff_t " & name & "_len"
sTyp & " " & name & "[], size_t " & name & "_len"
elif typ.kind == nnkPtrTy and typ[0].kind == nnkCall:
typ[0][0].expectKind(nnkOpenSymChoice)
doAssert typ[0][0][0].eqIdent"[]"
Expand Down
Loading
Loading