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

Uint256Add hinter #212

Merged
merged 11 commits into from
Feb 29, 2024
Merged

Uint256Add hinter #212

merged 11 commits into from
Feb 29, 2024

Conversation

cicr99
Copy link
Contributor

@cicr99 cicr99 commented Feb 22, 2024

Fixes #187
Fixes #219

@cicr99 cicr99 marked this pull request as ready for review February 28, 2024 10:42
@cicr99 cicr99 requested a review from quasilyte February 28, 2024 10:42
@cicr99
Copy link
Contributor Author

cicr99 commented Feb 28, 2024

I added a few modifications to the implementation of Uint256Add hint in the last commit, so we could use the same one for Uint256AddLow hint, as most of the logic is the same for both

@quasilyte
Copy link
Contributor

Doesn't the current 1 field per operander approach work in this case?

@cicr99
Copy link
Contributor Author

cicr99 commented Feb 29, 2024

Doesn't the current 1 field per operander approach work in this case?

Unfortunately no. The hint uses a and b as the parameters for the addition, and they are both of type Uint256, so it's actually two felts each one.

@quasilyte
Copy link
Contributor

Take a look at https://github.com/NethermindEth/cairo-vm-go/tree/quasilyte_uint256_hint_review

I treat operanders list as a memory initializer: the "name" doesn't need to store an entire object, if you want to pass an object as a parameter, passing its beginning is enough since we can then resolve its address to read consecutive felts from the memory.

@cicr99
Copy link
Contributor Author

cicr99 commented Feb 29, 2024

Mmmm, that's true. It's certainly more comfortable to write the tests that way, and also I think it's more readable than just passing an array full of values. Yep, I like it. Will change

pkg/hintrunner/hinter/operand.go Outdated Show resolved Hide resolved
pkg/hintrunner/hinter/operand.go Outdated Show resolved Hide resolved
@quasilyte
Copy link
Contributor

I've left a couple of comments, but nothing that keeps this PR from being merged.

@cicr99 cicr99 merged commit 22c93d2 into main Feb 29, 2024
4 checks passed
@cicr99 cicr99 deleted the uint256add_hint branch February 29, 2024 13:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Uint256AddLow Implement Uint256Add Cairo 0 Hint
2 participants