-
Notifications
You must be signed in to change notification settings - Fork 210
chore(vm): unify Uint256 usage across u256 hints and split quotient via Uint512 #2237
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: main
Are you sure you want to change the base?
Conversation
JulianGCalderon
left a comment
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.
Hey @Forostovec, thanks for the contribution! Could you also update the changelog?
| let a = Uint256::from_var_name("a", vm, ids_data, ap_tracking)?; | ||
| let a_high = a.high; | ||
| //Main logic | ||
| //memory[ap] = 1 if 0 <= (ids.a.high % PRIME) < 2 ** 127 else 0 | ||
| let result: Felt252 = | ||
| if *a_high >= Felt252::ZERO && a_high.as_ref() <= &Felt252::from(i128::MAX) { | ||
| if *a_high.as_ref() >= Felt252::ZERO && a_high.as_ref() <= &Felt252::from(i128::MAX) { |
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.
This would imply fetching a.low, but not using it, right?
| let div = if div_offset_low == 0 && div_offset_high == 1 { | ||
| // Standard Uint256 layout | ||
| Uint256::from_var_name("div", vm, ids_data, ap_tracking)? | ||
| } else { | ||
| let div_addr = get_relocatable_from_var_name("div", vm, ids_data, ap_tracking)?; | ||
| Uint256::from_base_addr_with_offsets(div_addr, "div", vm, div_offset_low, div_offset_high)? | ||
| }; | ||
| let div_low = div.low.as_ref(); | ||
| let div_high = div.high.as_ref(); |
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.
Here could we call from_base_addr_with_offsets directly and avoid the conditional? It would make the function easier to read.
Also, in this function we are packing the U256 into a bigint manually. Could you modify it to call pack? Given that this PR is for unifying U256 usage in general, we can include it.
|
Hi, @Forostovec, what's the status of this PR? |
Ohh, I'm sorry, gonna make chamges and update changelog |
These changes remove duplicated packing logic, standardize error paths, and align uint256 hint implementations with the existing UintNNN helper patterns