Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 83b4037790
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
c12a37d to
43f2917
Compare
83b4037 to
16934fb
Compare
orizi
left a comment
There was a problem hiding this comment.
@orizi made 1 comment.
Reviewable status: 0 of 6 files reviewed, 2 unresolved discussions (waiting on ilyalesokhin-starkware).
ilyalesokhin-starkware
left a comment
There was a problem hiding this comment.
@ilyalesokhin-starkware reviewed 5 files and all commit messages.
Reviewable status: 5 of 6 files reviewed, 2 unresolved discussions.
43f2917 to
8b488ea
Compare
16934fb to
357be6f
Compare
orizi
left a comment
There was a problem hiding this comment.
@orizi made 1 comment and resolved 1 discussion.
Reviewable status: 5 of 6 files reviewed, 1 unresolved discussion (waiting on ilyalesokhin-starkware).
357be6f to
e35621c
Compare
8b488ea to
3814e9a
Compare
ilyalesokhin-starkware
left a comment
There was a problem hiding this comment.
@ilyalesokhin-starkware reviewed 5 files and all commit messages, and made 1 comment.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on orizi).
SIERRA_UPDATE_MINOR_CHANGE_TAG=New libfunc.
3814e9a to
da9e014
Compare
e35621c to
bc7d580
Compare
orizi
left a comment
There was a problem hiding this comment.
@orizi reviewed 2 files and all commit messages.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on orizi).


Summary
Adds a new
u128_to_u32_guaranteeslibfunc that splits a u128 value into four u32 guarantee values using iterative DivMod hints and verification.Type of change
Please check one:
Why is this change needed?
This libfunc provides an efficient way to decompose u128 values into their constituent u32 parts with mathematical guarantees, which is useful for operations that need to work with smaller integer components or for cryptographic applications that require bounded integer guarantees.
What was the behavior or documentation before?
There was no built-in way to split a u128 into guaranteed u32 components in the Sierra instruction set.
What is the behavior or documentation after?
The new
u128_to_u32_guaranteeslibfunc takes a u128 input and returns fourBoundedIntGuarantee<0, 4294967295>values representing the u32 components. The implementation uses DivMod hints to perform the splitting and verifies the reconstruction using Horner's method. The libfunc has an AP change cost of 9 and a gas cost of 7 steps.Related issue or discussion (if any)
None specified.
Additional context
The implementation includes comprehensive test coverage and the libfunc has been added to the allowed libfuncs list for Starknet classes. The verification process ensures mathematical correctness by reconstructing the original u128 value from the four u32 components.
Note
Medium Risk
Introduces a new Sierra libfunc with custom CASM generation and new AP/gas accounting, which could affect compilation determinism and cost metering if the implementation or constants are incorrect.
Overview
Adds a new Sierra libfunc,
u128_to_u32_guarantees, that decomposes au128into fourBoundedIntGuarantee<0, 2^32-1>outputs.Implements CASM lowering using iterative
DivModhints plus reconstruction asserts, wires the new variant through bounded-int libfunc specialization, and assigns fixed metering (ApChange::Known(9)andConstCost::steps(7)). The libfunc is added to Starknet’sallowed_libfuncslist and covered by a new bounded-int e2e test vector.Written by Cursor Bugbot for commit bc7d580. This will update automatically on new commits. Configure here.