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

[GatewayAPI] - Moving SuiJson to core and use it in the GatewayAPI #1652

Merged
merged 5 commits into from
May 3, 2022

Conversation

patrickkuo
Copy link
Contributor

Summary
Move SuiJson to sui_core package and use SuiJsonValue in GatewayAPI move_call to simplify the input arg.

Using SuiJsonValue instead of raw bytes inputs for move call args, making it more JSON-RPC friendly and remove needs of multiple rpc calls from client side to resolving the SuiJsonValue into pure args.

@patrickkuo patrickkuo requested a review from Clay-Mysten as a code owner April 28, 2022 17:07
"params": [
"{{owner_address}}",
"0000000000000000000000000000000000000002",
"ObjectBasics",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looks like GAS is no longer valid, is ObjectBasics the correct move module to use?

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure. But whats the error that you get?

Copy link
Contributor

Choose a reason for hiding this comment

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

If we are trying to transfer a coin object, then the module needs to be Coin.

Copy link
Contributor

Choose a reason for hiding this comment

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

ah Coin::transfer is not an entry function.
So maybe this is just not a good example (transfer coin object).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have changed the example to use Coin::transfer_ instead, looks like we have a second transfer(_) in Coin move contract....

@patrickkuo patrickkuo self-assigned this Apr 28, 2022
Copy link
Contributor

@tnowacki tnowacki left a comment

Choose a reason for hiding this comment

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

Everything here looks good to me! Just curious about that "GAS"~>"ObjectBasics" change. Maybe @lxfind will have more context here

@Clay-Mysten
Copy link
Contributor

Markdown LGTM.

@patrickkuo
Copy link
Contributor Author

Ok so SuiJson doesn't support type arg yet..... I will fix that and start the review again, converting this PR back to draft

@patrickkuo patrickkuo marked this pull request as draft April 29, 2022 00:01
@patrickkuo patrickkuo force-pushed the pat/move_sui_json_to_core branch from 1965a10 to 34e718a Compare April 30, 2022 00:35
@patrickkuo
Copy link
Contributor Author

Latest changes:

  • SuiJson now work with type arg
  • fixed a bug in adapter.rs which prevent fn<T>(T) move function working. (example move function : NFTs::SharedAuction::create_auction)
  • Changed JSON-RPC server to accept TypeTagString instead of TypeTag struct, the RPC move call method now works with the following input:
{ "jsonrpc": "2.0",
              "method": "sui_moveCall",
              "params": [
                  "78997C327D1D988AA137D58F4D1B42013417C0B2",
                  "0000000000000000000000000000000000000002",
                  "Coin",
                  "transfer_",
                  ["0x2::SUI::SUI"],
                  ["0x24A29C109C0544AF60BE8FB0AFD583E90E37346D",10000, "0x78997C327D1D988AA137D58F4D1B42013417C0B2"],
                  "72A3A6194E9584C07C5CB6226E61F91C9FBE3A4B",
                  2000
              ],
              "id": 1 }
  • TypeArg works with Wallet as well, example
sui>-$ call --package 4F19C4340079853D08343CE121A1AE100AAECF64 --module SharedAuction --function create_auction --type-args 0x2::Coin::Coin<0x2::SUI::SUI> --args "0xF0BF03BA5AF54E72DFB6A43D45915DF7C0F8852E" --gas 24A29C109C0544AF60BE8FB0AFD583E90E37346D --gas-budget 1000
----- Certificate ----
Signed Authorities : [k#d94696e0e3f442c32a1576a87598dafbfe29cf356600aee5c4827b527f69028a, k#2a3d4563387b4b17099531ce8d9f120f8e17848a49ca5e734d8aa70d66edb7cf, k#273c0b969d2d2c89edc3aaed85c0e9a8a377d18577826e735475548535960cd4]
Transaction Kind : Call
Package ID : 0x4f19c4340079853d08343ce121a1ae100aaecf64
Module : SharedAuction
Function : create_auction
Arguments : [ImmOrOwnedObject((F0BF03BA5AF54E72DFB6A43D45915DF7C0F8852E, SequenceNumber(0), o#8b46bb02cf487fc0bc98f367ca6e8e39efb769a5e2a2064a825967d894abb4ee))]
Type Arguments : [Struct(StructTag { address: 0000000000000000000000000000000000000002, module: Identifier("Coin"), name: Identifier("Coin"), type_params: [Struct(StructTag { address: 0000000000000000000000000000000000000002, module: Identifier("SUI"), name: Identifier("SUI"), type_params: [] })] })]

----- Transaction Effects ----
Status : Success { gas_cost: GasCostSummary { computation_cost: 200, storage_cost: 39, storage_rebate: 15 } }
Created Objects:
1C7D02886E78322F62CEF301BB71D58A1A86B0FF SequenceNumber(1) o#71e0c8f271a9cfae0ba4b38a83264b8b0f6436e380cb3e7be1ca9bcc12dd638f
Mutated Objects:
24A29C109C0544AF60BE8FB0AFD583E90E37346D SequenceNumber(2) o#8be5c554b64f5711957fb1218afff003da51231b5a3bc1fc2f119c553851eab5

@patrickkuo
Copy link
Contributor Author

I have also started working on inferring function type args using the argument objects, I will finish that in another PR as it's not critical for DevNet release

@patrickkuo patrickkuo marked this pull request as ready for review April 30, 2022 00:54
@patrickkuo patrickkuo requested a review from tnowacki April 30, 2022 00:54
@patrickkuo patrickkuo force-pushed the pat/move_sui_json_to_core branch from bac4855 to 5bb1480 Compare May 2, 2022 09:47
@github-actions github-actions bot added the Type: Documentation Improvements or additions to documentation label May 2, 2022
@patrickkuo patrickkuo added Status: Needs Review PR is ready for review sui-node and removed Type: Documentation Improvements or additions to documentation labels May 2, 2022
@patrickkuo patrickkuo added this to the DevNet milestone May 2, 2022
@patrickkuo
Copy link
Contributor Author

This PR need more tech review 🙏

@oxade
Copy link
Contributor

oxade commented May 2, 2022

@patrickkuo this is great, thank you. LGTM but will wait for Xun to give feedback on the adapter concern.

Is there a potential perf cost to using SuiJSON over raw bytes though?

@patrickkuo patrickkuo force-pushed the pat/move_sui_json_to_core branch from 5bb1480 to 4550f1b Compare May 2, 2022 23:07
@github-actions github-actions bot added the Type: Documentation Improvements or additions to documentation label May 2, 2022
patrickkuo added 5 commits May 3, 2022 09:51
* fixed a bug in adapter.rs which prevent fn<T>(T) move function working.
* Changed JSON-RPC server to accept TypeTagString instead of TypeTag struct
@patrickkuo patrickkuo force-pushed the pat/move_sui_json_to_core branch from 4550f1b to c3c186f Compare May 3, 2022 09:09
@patrickkuo
Copy link
Contributor Author

@patrickkuo this is great, thank you. LGTM but will wait for Xun to give feedback on the adapter concern.

Is there a potential perf cost to using SuiJSON over raw bytes though?

I think the perf impact is not huge (although I don't have perf data to back this up :) ), also the perf impact will be on the gateway, which doesn't affect the overall network perf, the SuiJsonValue -> move pure value conversion uses object data and package data, which is located on the gateway already, so we don't need to retrieve data over the network, unlike when this is done in the client side before this PR, which pulls packages and objects from gateway every time, I believe there will be a perf gain (between client and gateway) after the changes because of this.

Also I think perf of gateway can be more relax as we can always load balance.

@patrickkuo
Copy link
Contributor Author

I am keen to merge this in soon if this looks ok to everyone? @oxade , @lxfind , @tnowacki ?

Copy link
Contributor

@tnowacki tnowacki left a comment

Choose a reason for hiding this comment

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

Looks like only concern was the adapter change, which has been addressed. So, ship it!

@patrickkuo patrickkuo merged commit caaf36a into main May 3, 2022
@patrickkuo patrickkuo deleted the pat/move_sui_json_to_core branch May 3, 2022 21:07
longbowlu pushed a commit that referenced this pull request May 12, 2022
…1652)

* moving SuiJson to core and use it in the GatewayAPI

* * SuiJson now work with type arg
* fixed a bug in adapter.rs which prevent fn<T>(T) move function working.
* Changed JSON-RPC server to accept TypeTagString instead of TypeTag struct

* update rpc spec

* address PR comments

* fixup after rebase
punwai pushed a commit that referenced this pull request Jul 27, 2022
…1652)

* moving SuiJson to core and use it in the GatewayAPI

* * SuiJson now work with type arg
* fixed a bug in adapter.rs which prevent fn<T>(T) move function working.
* Changed JSON-RPC server to accept TypeTagString instead of TypeTag struct

* update rpc spec

* address PR comments

* fixup after rebase
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Needs Review PR is ready for review sui-node Type: Documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants