-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Adds ability to take an ABI to handle EntryFunction
JSON arguments correctly
#4190
Conversation
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.
@gupnik thanks for the PR! Please consider the following notes
Binary size comparison➡️ aarch64-apple-ios: - 12.49 MB
+ 12.52 MB +34 KB ➡️ aarch64-apple-ios-sim: - 12.49 MB
+ 12.53 MB +34 KB ➡️ aarch64-linux-android: - 16.12 MB
+ 16.17 MB +52 KB ➡️ armv7-linux-androideabi: - 13.75 MB
+ 13.79 MB +40 KB ➡️ wasm32-unknown-emscripten: - 11.43 MB
+ 11.47 MB +41 KB |
Hi @gupnik , Thanks for the PR! Aptos has its own ABI definition. For example: Abi example. Can we use the office ABI format instead? I'm concerned that the simple ABI introduced in this PR may not cover more complex cases. |
Hi @10gic, thanks for the comment. As the user needs to provide an individual payload anyways to blind sign, I am not sure if we need the complete ABI parser. The current PR just expects the types of the arguments and ensures that they are parsed to So, the caller should simply be able to retrieve the ABI json via the API: https://aptos.dev/en/build/apis/fullnode-rest-api-reference#tag/accounts/GET/accounts/{address}/modules and call the function with the respective types. |
We don't need to pass the entire ABI JSON file; it's sufficient to only pass the The
These examples are taken from: https://aptoscan.com/module/0x7e783b349d3e89cf5931af376ebeadbfab855b3fa239b7ada8f5a92fbea6b387/pyth Can you add more unit tests to improve coverage? |
Thanks @10gic for raising this. I went through
I will try to implement a similar flow and the respective unit tests for serialisation but please let me know if you would want me try to broadcast any specific transactions. CC: @satoshiotomakan |
@gupnik looks good. From my point of view, unit tests with only value parsing would be enough, if we borrow them from |
@satoshiotomakan I have added the implementation as discussed. Also, here are the tests that I have replicated as well. To note: For example, in the following case, assert_value_conversion(
&converter,
"0x1::guid::ID",
json!({"addr": "0x1", "creation_num": "1"}),
VmMoveValue::Struct(MoveStruct::Runtime(vec![
VmMoveValue::U64(1),
VmMoveValue::Address(address),
])),
); In our case, we instead are able to accept it as follows: assert_value_conversion(
"0x1::guid::ID<u64, address>",
["1", "0x1"],
MoveValue::Struct(MoveStruct::Runtime(vec![
MoveValue::U64(1),
MoveValue::Address(address),
])),
); |
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 completing the implementation!
I have several minor and a few important questions/change requests. Could you please take a look?
} else { | ||
return Err(EncodingError::InvalidInput); | ||
} |
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.
aptos-core
allows the struct tag to be a non-utf8 string, but any other.
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.
aptos-core
allows the struct tag to be a non-utf8 string, but any other.
Yeah, aptos-core
handles strings and structs with named fields, whereas we handle strings and structs with unnamed fields due to the reasoning mentioned here.
); | ||
|
||
assert_value_conversion( | ||
"0x1::guid::ID<u64, address>", // As we do not have access to the module resolver, the types of the struct should be provided as params |
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.
Does https://aptos.dev/en/build/apis/fullnode-rest-api-reference#tag/accounts/GET/accounts/{address}/modules RPC return this type argument with the type arguments like 0x1::guid::ID<u64, address>
, or it returns 0x1::guid::ID
?
If it doesn't have type arguments, then the WalletCore users won't be able to provide the full ABI required by WalletCore
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.
Does https://aptos.dev/en/build/apis/fullnode-rest-api-reference#tag/accounts/GET/accounts/{address}/modules RPC return this type argument with the type arguments like
0x1::guid::ID<u64, address>
, or it returns0x1::guid::ID
? If it doesn't have type arguments, then the WalletCore users won't be able to provide the full ABI required by WalletCore
They should be able to use https://aptos.dev/en/build/apis/fullnode-rest-api-reference#tag/accounts/GET/accounts/{address}/resource/{resource_type} to retrieve the types
Hi @satoshiotomakan, thanks for the review. I will go through each of them in my day tomorrow, but to clarify each line/conversion has only been added because it is needed. I will try to share how & where its used tomorrow. |
Hi @gupnik, Ok no problem, if they're all used, no need to post comments, thanks! I'll resolve corresponding questions
|
Description
Fixes #3899
This PR adds the ability to accept an ABI in the
SigningInput
so that we are able to parse the arguments correctly.How to test
Run Rust Tests
Types of changes
Add
abi
intw_proto::Aptos::Proto::SigningInput
.Checklist
If you're adding a new blockchain