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: recover_sender #614

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

feat: recover_sender #614

wants to merge 11 commits into from

Conversation

Eikix
Copy link
Member

@Eikix Eikix commented Jan 30, 2025

closes #563

@Eikix Eikix marked this pull request as ready for review January 30, 2025 13:17
@enitrat enitrat changed the title Feat/recover sender feat: recover_sender Jan 30, 2025
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.

💪💪

cairo/ethereum/cancun/fork_types.cairo Outdated Show resolved Hide resolved
cairo/ethereum/cancun/fork_types.cairo Outdated Show resolved Hide resolved
cairo/ethereum/crypto/elliptic_curve.cairo Outdated Show resolved Hide resolved
cairo/ethereum/crypto/elliptic_curve.cairo Show resolved Hide resolved
Comment on lines +245 to +246
let r = tx.value.legacy_transaction.value.r;
let s = tx.value.legacy_transaction.value.s;
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it would be acceptable to do a TxImpl, in which you have a function get_signature_components that returns (r, s, v) supporting all transaction types.

Once this is done you can move out the r, s checks step (which is copy/pasted in each tx variant) to be done right before. it's a very small overhead to pay for simplicity. Open to discuss

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'd vote to do this only if another function requires r, s, v to be extracted from Transaction

Copy link
Member Author

Choose a reason for hiding this comment

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

ok i'll do some utils for check_transaction pr

Comment on lines +258 to +259
tempvar err = new EthereumException(InvalidSignatureError);
return (Address(0), err);
Copy link
Collaborator

Choose a reason for hiding this comment

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

considering that the error is never caught and acted upon, we can assert 1 = 0 and wrap in a with_attr (for all errors in this function).

Copy link
Collaborator

Choose a reason for hiding this comment

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

and change the signature to return only the address

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 tried it like this but it didn't work in the runner / serde for strict_raises

Copy link
Member Author

Choose a reason for hiding this comment

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

since in unit tests, python will raise the ethereumexception in python, and in cairo an assert_eq

Copy link
Member Author

Choose a reason for hiding this comment

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

hm, otherwise we can do with_attr error_message(name of the ethereum exception which will never be caught and acted upon) and reverse the test order to catch the python ethereum exception and match on name

Copy link
Collaborator

Choose a reason for hiding this comment

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

would work now

cairo/tests/ethereum/cancun/test_transactions.py Outdated Show resolved Hide resolved
cairo/tests/ethereum/cancun/test_transactions.py Outdated Show resolved Hide resolved
@enitrat
Copy link
Collaborator

enitrat commented Jan 30, 2025

test_U256_to_le_bytes20 has an endianess issue

@Eikix Eikix mentioned this pull request Jan 30, 2025
1 task
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.

Implement recover_sender
2 participants