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

Feat/move ether #476

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open

Feat/move ether #476

wants to merge 8 commits into from

Conversation

Eikix
Copy link
Member

@Eikix Eikix commented Jan 17, 2025

  • move ether
  • add utils to add and sub with panics for overflow/underflow for U256 type
  • add state deep copy util in test_state

close #461

Comment on lines 192 to 193
let fp_and_pc = get_fp_and_pc();
local __fp__: felt* = fp_and_pc.fp_val;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this necessary ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no thx nice catch

Comment on lines 146 to 148
# 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)
Copy link
Contributor

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

Copy link
Collaborator

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.

Copy link
Member Author

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

Copy link
Member Author

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

Comment on lines 152 to 136
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
Copy link
Contributor

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

Copy link
Collaborator

@enitrat enitrat left a 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

@Eikix
Copy link
Member Author

Eikix commented Jan 17, 2025

try with #474 now

thanks that's way better

}

func U256_le{range_check_ptr}(a: U256, b: U256) -> bool {
let (result) = uint256_le(cast([a.value], Uint256), cast([b.value], Uint256));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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)

Copy link
Member Author

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

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.

move_ether
3 participants