-
Notifications
You must be signed in to change notification settings - Fork 20
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(wasm(host)): Add AddMod and MulMod to host functions #283
Conversation
@clearloop this should be done |
nice! you already got how it works! btw could you please check my template implementation in issue-275-template, especially the commit 339daeb
feel free to copy my previous code to your PR! |
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.
The key point of this issue is implementing addmod
& mumod
for number types, you got a correct implementation for U256, congratulations!
However, you missed adding these functions to the U256 type, and other primitive number types, you are in the correct direction, just need common rust impls and tests in contracts then!
a macro would be good for this tbh |
@clearloop didn't really get the test tbh |
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.
Almost there! when you run the tests, you can do
RUST_LOG=trace cargo nextest run --example addmod --nocapture
so you will see error failed to load contract addmod_i32
- You should load
addmod
which is the name of the example, we're compiling each example as a contract, and with the logging you actually can debug what happened in the compiler - add
addmod
&mulmod
branches to HostFunc::TryFrom then we can emitADDMOD
&MULMOD
instead ofNOOP
, feel free to optimize theTryFrom
since our functions are increasing!
see also my workaround based on your commits: c6a1e38
yeah just looked at it, that would be messy a bit |
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.
Why the test is still ignored, we need to pass the contract test to confirm that our implementation is correct
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.
Thanks for the contribution!
Please fix the format check in CI btw, everything looks nice now! will transfer the budget once the CI pass!
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.
Looks good though! Thanks!
https://polygonscan.com/tx/0xe348c4a8736d951d0d893e7f1ccba6c0e3262a8db2eacceabff56abb761e775c
Resolves #275
0x30bE4D758d86cfb1Ae74Ae698f2CF4BA7dC8d693