MystenLabs / sui

Sui, a next-generation smart contract platform with high throughput, low latency, and an asset-oriented programming model powered by the Move programming language
https://sui.io
Apache License 2.0
6.1k stars 11.16k forks source link

Bug fix: TypeArguments and LocalTxnDataSerializer #5993

Closed ItasMattWebb closed 1 year ago

ItasMattWebb commented 1 year ago

Steps to Reproduce Issue

Call a function that uses a typed argument, e.g.

    signer.signAndExecuteTransactionWithRequestType({
        kind: "moveCall",
        data: {
            packageObjectId:"0xaddd98a4a0a65523d2d89ed01a395f39aaddd920",
            module:"marketplace_nofee",
            function:"list",
            typeArguments:["0x2::devnet_nft::DevNetNFT","0x2::sui::SUI"],
            arguments:["0x544f427059cd21bd64a05ac32c272c1f2520342e","0x69ce5cbe4062948347f8b1223532f0873a0bff18",1000000000],
            gasBudget:2000,
          }
    });

Expected Result

Successful transaction

Actual Result

Error: Transaction failed with the following error. Error constructing a move call: Error: Unknown call arg type {
  "TypeParameter": 0
} for value "0x69ce5cbe4062948347f8b1223532f0873a0bff18" args {"arguments":["0x544f427059cd21bd64a05ac32c272c1f2520342e","0x69ce5cbe4062948347f8b1223532f0873a0bff18",1000000000],"function":"list","gasBudget":2000,"module":"marketplace_nofee","packageObjectId":"0xaddd98a4a0a65523d2d89ed01a395f39aaddd920","typeArguments":["0x2::devnet_nft::DevNetNFT","0x2::sui::SUI"]}

If you instantiate a raw signer like this:

const signer = new RawSigner(keypair, provider, new LocalTxnDataSerializer(provider));

Then you get the error. If you instantiate it like this:

const signer = new RawSigner(keypair, provider);

Then you don't.

Thanks to @jaredcosulich for figuring this out

System Information

@mysten/sui.js: 0.15.0

3of5-IQ commented 1 year ago

Just wondering if there is any timelines on if this is going to be looked at anytime soon? Its a pretty breaking bug for us as we went from one of the only handful of fully functional dapps on Sui to, absolutely not working and our users not being able to do anything anymore

666lcz commented 1 year ago

@3of5-IQ Thanks for following up on this! I will look into this today. Do you mind sharing the source code of your Move module so that I can repro?

Meanwhile, I am curious about the reason why you can't use the RpcTxnDataSerializer instead of LocalTxnDataSerializer which does not have this bug?

3of5-IQ commented 1 year ago

The work around only applies to CLI and not the actual wallets themselves. This is something that is a bug with all wallets currently.

ItasMattWebb commented 1 year ago

Put the source code in a gist. https://gist.github.com/ItasMattWebb/77411e3de60754e2bfbc78cabdbcd0a2

You could probably make a simpler function to test to recreate it that doesn't involve making a market. Maybe something like:

public entry fun list<T: key + store>(
    item: T,
    ctx: &mut TxContext
) {
    transfer::transfer(item, tx_context::sender(ctx))
}
3of5-IQ commented 1 year ago

Hi, Just wondering if there is any more information that we can assist with providing to help increase the chances of tracking down the bug?

666lcz commented 1 year ago

Sorry for the delay - As a temporary fix, I've turned on the switch to use RpcTxnSerializer in the Sui wallet so this issue should no longer repro on Sui wallet.

Will put up a PR to fix the root issue by tomorrow