-
Notifications
You must be signed in to change notification settings - Fork 627
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
implement meta txn arg parsing, eip-712 msg encoding for meta txn and add a ecrecover test #3534
Conversation
@ilblackdragon prepare_meta_call_args fully works now, testing these cases in I noticed prepare_meta_call_args took encoded "function call args" and encode it to meta_txn msg. There lacks a encode_args function that:
However, what type of the second argument we give to rust function encode_args (PetObj{petName: ...} above)? Seems i understand why it's given as a json string in eip-712 crate, didn't think of a good solution, maybe
? |
@ilblackdragon For encoding args looks we did with
However, this encoded form is not convenient to decode back to a format similar to:
so that:
So an easier way is both encode_meta_call_function_args and encode_args takes args similar to:
In metamask, this format is json. In our node, This probably should be borsh, replace Encodable in above comment. |
@evgenykuzyakov ptal, do we merge this to evm-precompile or wait evm-precompile merge first? |
The test input is console logged from following js snippet:
Test Plan
Without the fix, the test test_ecrecover failed (doesn't give same result as metamask's ecrecover). After the fix, this test passed. Also after fix test_meta_call_sig_recover pass and gives same result in rust and in eth-sig-util. To see that, println from rust, get msg
0xfb453835cc8bc460affc6070c1859b77ed26957e5152bd2a1d9a2b83d460f149
, then test this msg and sig in eth-sig-util, by settingin
function recoverTypedSignature_v4(msgParams) {
and run above snippet
Update:
The ecrecover in rust is actually good, just not in same format of eth-sig-util. With move
sig[0] + 27
in , sig[64]<>sig[0] it's actually same. So the move+27
to encode_meta_call_function_args is just for test directly with eth-sig-util output, not mean ecrecover is wrong. The thing wrong is eip-712 sig is constructed manually (the construction was wrong, 2bb96b2 gives a correct manual contruct to make test passes & behaves exact as eth-sig-util), TODO: need to write a parser to parse eip-712, encode general meta call type parameters in this PR