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

unsafe_moveCall: getting "Deserialization error: ULEB128-encoded integer did not fit in the target size" #20831

Closed
thousandsofthem opened this issue Jan 9, 2025 · 1 comment

Comments

@thousandsofthem
Copy link

Getting "Deserialization error: ULEB128-encoded integer did not fit in the target size" then using unsafe_moveCall result in sui_devInspectTransactionBlock

Steps to Reproduce Issue

  1. Create transaction payload with unsafe_moveCall
POST https://sui-rpc.publicnode.com/
{
  "jsonrpc": "2.0",
  "id": 100000,
  "method": "unsafe_moveCall",
  "params": [
    "0x0000000000000000000000000000000000000000000000000000000000000000",
    "0x3a5aa90ffa33d09100d7b6941ea1c0ffe6ab66e77062ddd26320c1b073aabb10",
    "fetcher_script",
    "calculate_swap_result",
    [
      "0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC",
      "0x2::sui::SUI"
    ],
    [
      "0xb8d7d9e66a60c239e7a60110efcf8de6c705580ed924d0dde141f4a0e2c90105",
      true,
      true,
      "1000"
    ],
    null,
    "100000000"
  ]
}

result:

{
  "jsonrpc": "2.0",
  "result": {
    "txBytes": "AAADAQG419nmamDCOeemARDvz43mxwVYDtkk0N3hQfSg4skBBeoIRRYAAAAAAAABAQAI6AMAAAAAAAABADpaqQ/6M9CRANe2lB6hwP/mq2bncGLd0mMgwbBzqrsQDmZldGNoZXJfc2NyaXB0FWNhbGN1bGF0ZV9zd2FwX3Jlc3VsdAIH26NGcuMMsGWx+T46tVMYdo/W/vZsFZQsn3y4RuL5AOcEdXNkYwRVU0RDAAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgNzdWkDU1VJAAQBAAABAQABAQABAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAIfO6ksW2QV5PuxDyAuF8I6kzgqNMx3+h/aMAXcdKFhdnogwAAAAAIApXjnQHH99NNqtXb47835W0lY/d9iNrTvPqRMx5Ku07AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADuAgAAAAAAAADh9QUAAAAAAA==",
...
}
  1. Use txBytes with: sui_devInspectTransactionBlock
{
  "jsonrpc": "2.0",
  "id": 2,
  "method": "sui_devInspectTransactionBlock",
  "params": [
    "0x0000000000000000000000000000000000000000000000000000000000000000",
    "AAADAQG419nmamDCOeemARDvz43mxwVYDtkk0N3hQfSg4skBBeoIRRYAAAAAAAABAQAI6AMAAAAAAAABADpaqQ/6M9CRANe2lB6hwP/mq2bncGLd0mMgwbBzqrsQDmZldGNoZXJfc2NyaXB0FWNhbGN1bGF0ZV9zd2FwX3Jlc3VsdAIH26NGcuMMsGWx+T46tVMYdo/W/vZsFZQsn3y4RuL5AOcEdXNkYwRVU0RDAAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgNzdWkDU1VJAAQBAAABAQABAQABAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAIfO6ksW2QV5PuxDyAuF8I6kzgqNMx3+h/aMAXcdKFhdnogwAAAAAIApXjnQHH99NNqtXb47835W0lY/d9iNrTvPqRMx5Ku07AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADuAgAAAAAAAADh9QUAAAAAAA==",
    null,
    null
  ]
}

result:

{
  "jsonrpc": "2.0",
  "error": {
    "code": -32602,
    "message": "Deserialization error: ULEB128-encoded integer did not fit in the target size"
  },
  "id": 2
}

Expected Result

Cetus Typescript SDK generates MoveCall result internally, and it's generated result is very different, much shorther

Typescript-generated code:

{
  "jsonrpc": "2.0",
  "id": 2,
  "method": "sui_devInspectTransactionBlock",
  "params": [
    "0x0000000000000000000000000000000000000000000000000000000000000000",
    "AAIBAbjX2eZqYMI556YBEO/PjebHBVgO2STQ3eFB9KDiyQEF6ghFFgAAAAAAAAgAAgAAAAAAAAIFAQkAADpaqQ/6M9CRANe2lB6hwP/mq2bncGLd0mMgwbBzqrsQDmZldGNoZXJfc2NyaXB0C2ZldGNoX3RpY2tzAgfbo0Zy4wywZbH5Pjq1Uxh2j9b+9mwVlCyffLhG4vkA5wR1c2RjBFVTREMABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACA3N1aQNTVUkAAwEAAAIAAAEBAA==",
    null,
    null
  ]
}

output:

{
  "jsonrpc": "2.0",
  "result": {
    "effects": {
      "messageVersion": "v1",
      "status": {
        "status": "success"
      },
...

Code inside Cetus Typescript SDK is something like this:

const tx = new import_transactions.Transaction();
const typeArguments = [params.coinTypeA, params.coinTypeB];
const args = [tx.object(params.pool.poolAddress), tx.pure.bool(params.a2b), tx.pure.bool(params.byAmountIn), tx.pure.u64(params.amount)];
tx.moveCall({
      target: `${integrate.published_at}::${ClmmFetcherModule}::calculate_swap_result`,
      arguments: args,
      typeArguments
    });  
const simulateRes = await this.sdk.fullClient.devInspectTransactionBlock({
      transactionBlock: tx,
      sender: simulationAccount.address
    });
@thousandsofthem
Copy link
Author

thousandsofthem commented Jan 9, 2025

Found another way, bypassing unsafe_moveCall via Golang SDK

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

No branches or pull requests

1 participant