-
Notifications
You must be signed in to change notification settings - Fork 25
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
feat(blockifier): add Secp256r1 cairo native syscalls #1675
Conversation
Artifacts upload triggered. View details here |
Artifacts upload triggered. View details here |
Benchmark movements: |
60e2392
to
538df34
Compare
538df34
to
861b3c2
Compare
4b482f6
to
5f5b7f3
Compare
Artifacts upload triggered. View details here |
35610ac
to
c24bf02
Compare
Artifacts upload triggered. View details here |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1675 +/- ##
===========================================
+ Coverage 40.10% 68.89% +28.79%
===========================================
Files 26 109 +83
Lines 1895 13899 +12004
Branches 1895 13899 +12004
===========================================
+ Hits 760 9576 +8816
- Misses 1100 3914 +2814
- Partials 35 409 +374 ☔ View full report in Codecov by Sentry. 🚨 Try these New Features:
|
c24bf02
to
8a05ee8
Compare
Artifacts upload triggered. View details here |
c2d4d1e
to
ae66958
Compare
8a05ee8
to
5b6eb87
Compare
Artifacts upload triggered. View details here |
ae66958
to
36304b7
Compare
5b6eb87
to
ef31a7b
Compare
Artifacts upload triggered. View details here |
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.
Reviewed 2 of 2 files at r3, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @meship-starkware and @Yoni-Starkware)
crates/blockifier/src/execution/native/syscall_handler.rs
line 740 at r1 (raw file):
Previously, xrvdg (Xander van der Goot) wrote…
Based on a quick scan the conversion don't do any signed/unsigned conversion, just like Pearson said. Still I would be in favour of changing
u256_to_biguint
tou256_to_bigint
, that should only require using bigint's constructor. There was no reason to use the biguint over the bigint, I overlooked this.
Okay, I understand. So the type for Secp256Point
coordinates is supposed to be BigInt<4>
according to the definition of the curve.
Two further comments:
- I think we shouldn't go through
BigUint
. To getSecp256r1Point
fromSecp256Point
, our current conversion isU256
->BigUint
->BigInt<4>
. We should do a direct conversion, as Xander suggested. - Is it good practice to use functions from
starknet_stub.rs
? It is a module containing a mock syscall handler for tests. It might not be the most well-maintained module. These helper functions are very short. Why not have a version of them in our repo? WDYT @Yoni-Starkware @meship-starkware ?
crates/blockifier/src/execution/syscalls/syscall_tests/secp.rs
line 32 at r3 (raw file):
Previously, meship-starkware (Meshi Peled) wrote…
Note to self: this is the only syscalls that is affected by the builtins gas cost, meaning that the fact that this gas cost is right means that the builtins costs are right :)
Note that they are not the same though. Native costs 10,000 more.
Even if they were the same, the fact that this gas cost is correct doesn't necessarily mean that the builtin costs are correct. It just means that our current tests don't catch any mistakes.
e79c663
to
d1de975
Compare
Artifacts upload triggered. View details here |
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.
Reviewable status: 1 of 2 files reviewed, 2 unresolved discussions (waiting on @avi-starkware, @meship-starkware, and @Yoni-Starkware)
crates/blockifier/src/execution/native/syscall_handler.rs
line 740 at r1 (raw file):
Previously, avi-starkware wrote…
Okay, I understand. So the type for
Secp256Point
coordinates is supposed to beBigInt<4>
according to the definition of the curve.
Two further comments:
- I think we shouldn't go through
BigUint
. To getSecp256r1Point
fromSecp256Point
, our current conversion isU256
->BigUint
->BigInt<4>
. We should do a direct conversion, as Xander suggested.- Is it good practice to use functions from
starknet_stub.rs
? It is a module containing a mock syscall handler for tests. It might not be the most well-maintained module. These helper functions are very short. Why not have a version of them in our repo? WDYT @Yoni-Starkware @meship-starkware ?
Added u256_to_big4int
and used that.
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.
Reviewable status: 1 of 2 files reviewed, 2 unresolved discussions (waiting on @avi-starkware and @meship-starkware)
crates/blockifier/src/execution/native/syscall_handler.rs
line 740 at r1 (raw file):
Previously, PearsonWhite wrote…
Added
u256_to_big4int
and used that.
As Avi said, can we please avoid using starknet_stub.rs
?
d1de975
to
68d9518
Compare
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.
Reviewable status: 1 of 2 files reviewed, 2 unresolved discussions (waiting on @avi-starkware and @meship-starkware)
crates/blockifier/src/execution/native/syscall_handler.rs
line 740 at r1 (raw file):
Previously, Yoni-Starkware (Yoni) wrote…
As Avi said, can we please avoid using
starknet_stub.rs
?
I moved the helpers into crates/blockifier/src/execution/native/syscall_handler.rs
now.
Artifacts upload triggered. View details here |
68d9518
to
a5c6ab0
Compare
Artifacts upload triggered. View details here |
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.
Reviewed 1 of 2 files at r3, 1 of 1 files at r6, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @meship-starkware and @PearsonWhite)
crates/blockifier/src/execution/native/syscall_handler.rs
line 867 at r6 (raw file):
(hi << 128) + lo }
Not needed anymore, right?
a5c6ab0
to
7278639
Compare
Artifacts upload triggered. View details here |
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.
Reviewable status: 1 of 2 files reviewed, 2 unresolved discussions (waiting on @avi-starkware, @PearsonWhite, and @Yoni-Starkware)
crates/blockifier/src/execution/syscalls/syscall_tests/secp.rs
line 32 at r3 (raw file):
Previously, avi-starkware wrote…
Note that they are not the same though. Native costs 10,000 more.
Even if they were the same, the fact that this gas cost is correct doesn't necessarily mean that the builtin costs are correct. It just means that our current tests don't catch any mistakes.
The 10K is a known issue. We double charge on entry point
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.
Reviewed 1 of 1 files at r7, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @avi-starkware and @PearsonWhite)
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.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @avi-starkware and @Yoni-Starkware)
crates/blockifier/src/execution/native/syscall_handler.rs
line 867 at r6 (raw file):
Previously, Yoni-Starkware (Yoni) wrote…
Not needed anymore, right?
ark_ff
uses BigUint
in places like PrimeField
, so I think we're better off keeping it in. Otherwise we will have a Uint in the form of BigInt<4>, which would be confusing and only exist for the purposes of avoiding the conversion.
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.
Reviewed 1 of 1 files at r7, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @avi-starkware)
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.
Dismissed @avi-starkware from a discussion.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @PearsonWhite)
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.
Reviewable status: complete! all files reviewed, all discussions resolved (waiting on @PearsonWhite)
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.
Reviewable status: complete! all files reviewed, all discussions resolved (waiting on @PearsonWhite)
a discussion (no related file):
Please rebase and resolve the conflicts.
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.
Reviewed 1 of 1 files at r7, all commit messages.
Reviewable status: complete! all files reviewed, all discussions resolved (waiting on @PearsonWhite)
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.
Reviewable status: complete! all files reviewed, all discussions resolved (waiting on @PearsonWhite)
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.
Reviewable status: complete! all files reviewed, all discussions resolved (waiting on @PearsonWhite)
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.
Reviewable status: complete! all files reviewed, all discussions resolved (waiting on @PearsonWhite)
7278639
to
3d40fd2
Compare
Artifacts upload triggered. View details here |
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.
Reviewed 2 of 2 files at r8, all commit messages.
Reviewable status: complete! all files reviewed, all discussions resolved (waiting on @PearsonWhite)
Currently waiting for other changes before proceeding with this.
This is currently a Draft. It requires some other Secp logic that will come in another issue. Then, this branch will be rebased on top of it and the overlapping logic will be removed.