-
Notifications
You must be signed in to change notification settings - Fork 14
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/move ether #476
base: main
Are you sure you want to change the base?
Feat/move ether #476
Conversation
cairo/ethereum/cancun/state.cairo
Outdated
let fp_and_pc = get_fp_and_pc(); | ||
local __fp__: felt* = fp_and_pc.fp_val; |
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.
is this necessary ?
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.
no thx nice catch
# We need to create a deep copy of the state to avoid mutating the original state | ||
# We can refactor it into a deep_copy State util if we ever need to do this again | ||
python_state = _state_deep_copy(state) |
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.
I do not understand why doing this
To avoid having doing a copy you first execute the cairo code, then the python one like other tests, unless I miss something?
Also if there is any need you can use https://docs.python.org/3/library/copy.html to copy objects if not mistaken
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.
yes, run the cairo operation before the python one.
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.
previously if i ran the cairo operation before the python one, then i'm not able to know which error will be thrown
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.
I do not understand why doing this To avoid having doing a copy you first execute the cairo code, then the python one like other tests, unless I miss something? Also if there is any need you can use https://docs.python.org/3/library/copy.html to copy objects if not mistaken
you can't copy state because Account is a frozen type, at least that's the error i was getting when trying to just use deepcopy
from copy
library
except AssertionError: | ||
with pytest.raises(AssertionError): | ||
cairo_run( | ||
"move_ether", state, sender_address, recipient_address, amount | ||
) | ||
return | ||
except OverflowError: | ||
with cairo_error("OverflowError"): | ||
cairo_run( | ||
"move_ether", state, sender_address, recipient_address, amount | ||
) | ||
return |
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.
I think the PR on error assertion from @enitrat will help with this
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.
try with #474 now
e4efe7f
to
f0c2646
Compare
thanks that's way better |
ebd4e80
to
ba5addd
Compare
cairo/ethereum/utils/numeric.cairo
Outdated
} | ||
|
||
func U256_le{range_check_ptr}(a: U256, b: U256) -> bool { | ||
let (result) = uint256_le(cast([a.value], Uint256), cast([b.value], Uint256)); |
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.
let (result) = uint256_le(cast([a.value], Uint256), cast([b.value], Uint256)); | |
let (result) = uint256_le([a.value], [b.value]); |
You should not have to cast: a.value is a Uint256*
(to apply in all functions above)
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.
I thought it'd be clearer that we're using U256Struct as a Uint256 here by casting it, even though U256Struct is just a type alias for Uint256
close #461