Error decoding contract event deployed with fuels-rs `v0.66.3`

Hi guys! We deployed our contract with this dependencies:

Fuel Dependencies:
forc v0.63.3
fuel-core v0.35.0
fuels-rs v0.66.3

But i got this error while decoding the event with 0.94.1 ts-sdk version:

[11:36:02.387] ERROR (55613): error decoding event
    chainId: 0
    logType: "Block Range Query"
    workerType: "HyperFuel"
    fromBlock: 0
    toBlock: 9908314
    addresses: [
      "0x976466c40b3d4a6c744a97c9e2b53cf10150a9eb5681406db4a981c4d8493625"
    ]
    fetchStateRegister: "root"
    blockNumber: 9908305
    logIndex: 1
    responsible event: {
      "blockHeight": 9908305,
      "blockTimestamp": 1725870950,
      "contractId": "0x976466c40b3d4a6c744a97c9e2b53cf10150a9eb5681406db4a981c4d8493625",
      "receipt": {
        "blockHeight": 9908305,
        "data": "0x000000000098968038e4ca985b22625fff93205e997bfc5cc8453a953da638ad297ca60a9f2600bc0000000000000000f41240303a49ad42855c65136a64015bcac8b9b85f4a77818048ebc5850d9a5500003faa252260000000000000000000d1ebb551a2d58f024875bcc6798e4e2f8c8feec9da718a9f29d362f14531a3ef",
        "ra": 0,
        "rb": 7812135309850120000,
        "receiptIndex": 1,
        "receiptType": 6,
        "rootContractId": "0x976466c40b3d4a6c744a97c9e2b53cf10150a9eb5681406db4a981c4d8493625",
        "txId": "0xb28d927e5a1ad473e0e0e139ec6b9c23640e4ae0f2b7162f0dd51380b7e57e5a",
        "txStatus": 0
      },
      "receiptIndex": 1,
      "receiptType": 6,
      "transactionId": "0xb28d927e5a1ad473e0e0e139ec6b9c23640e4ae0f2b7162f0dd51380b7e57e5a"
    }
[11:36:02.388] ERROR (55613): Failed to parse event with Fuel, please double check your ABI.
    chainId: 0
    logType: "Block Range Query"
    workerType: "HyperFuel"
    fromBlock: 0
    toBlock: 9908314
    addresses: [
      "0x976466c40b3d4a6c744a97c9e2b53cf10150a9eb5681406db4a981c4d8493625"
    ]
    fetchStateRegister: "root"
    blockNumber: 9908305
    logIndex: 1
    err: {
      "type": "_FuelError",
      "message": "Invalid caseIndex \"70000000000000\". Valid cases: Address,ContractId.",
      "stack":
          FuelError: Invalid caseIndex "70000000000000". Valid cases: Address,ContractId.
              at _b.decode (/Users/master/spark-envio-indexer/generated/src/bindings/vendored-fuel-abi-coder.js:639:13)
              at /Users/master/spark-envio-indexer/generated/src/bindings/vendored-fuel-abi-coder.js:955:41
              at Array.reduce (<anonymous>)
              at _c.decode (/Users/master/spark-envio-indexer/generated/src/bindings/vendored-fuel-abi-coder.js:952:51)
              at /Users/master/spark-envio-indexer/generated/src/bindings/vendored-fuel-abi-coder.js:1443:36
              at /Users/master/spark-envio-indexer/generated/src/bindings/Fuel.bs.js:30:12
              at convertOpenOrderEvent (/Users/master/spark-envio-indexer/generated/src/Converters.bs.js:90:32)
              at Object.parseHyperFuelItem (/Users/master/spark-envio-indexer/generated/src/Converters.bs.js:249:17)
              at /Users/master/spark-envio-indexer/generated/src/eventFetching/chainWorkers/HyperFuelWorker.bs.js:189:37
              at mapU (/Users/master/spark-envio-indexer/node_modules/.pnpm/rescript@11.1.3/node_modules/rescript/lib/js/belt_Array.js:301:12)
      "VERSIONS": {
        "FORC": "0.63.1",
        "FUEL_CORE": "0.33.0",
        "FUELS": "0.94.1"
      },
      "metadata": {},
      "rawError": {},
      "code": "invalid-decode-value",
      "name": "FuelError"
    }

Please help me to understand if fuels-rs v0.66.3 is compatible with ts-sdk “0.94.1”. Thanks!

2 Likes

I am also pretty sure the same issue exists with fuels-ts v0.94.4. The newest version v0.94.5 was released a few days ago. Not sure if it solves this issue.

Can you please try using forc and fuel-core versions to these versions:

  • forc v0.63.1
  • fuel-core v0.34.0

You can also try using the latest versions of the TypeScript SDK, which supports the versions you are using.

The indexer will work with smart contracts that were developed / deployed using forc v0.63.1 & fuel-core v0.34.0, however, then we’d be using old version of forc and fuel core.

We have a specific branch where we purposefully use and older version of forc and fuels-rs so that the indexer works. However, this is not an option to use in production since there were security vulnerabilities in these older versions, and we were told specifically to use only the newest versions of fuels-rs & forc for development.

Also the issue is that we can’t clone envio’s indexer repo and use the latest version of fuels-ts since envio’s codebase is closed source afaik

@naz3eh @david when we can expect compatibility with
fuels-rs v0.66.3
forc v0.63.3
fuel-core v0.35.0?

will make sure the team looks into it

1 Like

Hey @PaulZhemanov :wave:

Could you share the log in Sway that is responsible for this event?

A minimum reproduction of this issue would also be ideal - seeing as it’s closed source.

@p.s Here is the log that is not being decoded correctly: https://github.com/compolabs/orderbook-contract/blob/27b5745710265000b248ead8c0f656ba100052a9/spark-market/src/main.sw#L655-#L674

minimum reproduction: https://codesandbox.io/p/live/73212d0a-55d1-49e6-80b2-b45c4ef225e5 . Open the link, click fork in the top right corner, restart the terminal and run

npm run start

We copy the abi, and paste it into the codesand box. Then we get the error:

test at src/index.ts:11:25
✖️ invalid (2.374773ms)
  _FuelError: Invalid caseIndex "70000000000000". Valid cases: Address,ContractId.
      at EnumCoder.decode (/project/workspace/node_modules/@fuel-ts/abi-coder/src/encoding/coders/EnumCoder.ts:100:13)
      at /project/workspace/node_modules/@fuel-ts/abi-coder/src/encoding/coders/StructCoder.ts:63:41
      at Array.reduce (<anonymous>)
      at StructCoder.decode (/project/workspace/node_modules/@fuel-ts/abi-coder/src/encoding/coders/StructCoder.ts:60:51)
      at Function.decode (/project/workspace/node_modules/@fuel-ts/abi-coder/src/AbiCoder.ts:35:50)
      at Interface.decodeLog (/project/workspace/node_modules/@fuel-ts/abi-coder/src/Interface.ts:72:21)
      at TestContext.<anonymous> (/project/workspace/src/index.ts:10:27)
      at Test.runInAsyncScope (node:async_hooks:206:9)
      at Test.run (node:internal/test_runner/test:631:25)
      at Test.start (node:internal/test_runner/test:542:17) {
    VERSIONS: { FORC: '0.63.5', FUEL_CORE: '0.35.0', FUELS: '0.94.5' },
    metadata: {},
    rawError: null,
    code: 'invalid-decode-value'
  }
Failed running 'src/index.ts'

I’m getting a page not found error from the CodeSandbox link (see image).

Could share you share a repository of the reproduction please?

@p.s GitHub - PaulZhemanov/abi-checker

@PaulZhemanov In short, contracts deployed using these old SDK versions:

  • Rust SDK v0.66.3
  • Typescript SDK v0.94.0 ~ v0.94.4

Must be re-deployed using the latest versions:

This is required because the latest versions introduced bugfixes ( #1503, #3122) that will probably not work with contracts deployed using the abovementioned old versions.

Could you please try that and let us know if it works for you?

If the problem persists, we can revisit it and try to assist you further.

Thanks.

@anderson @p.s @naz3eh We are using the latest version of fuels-rs 0.66.4 & forc 63.5 to generate the ABI: orderbook-contract/Cargo.toml at 4010009cdc880d3cea466995cf6b1b8d011795c1 · compolabs/orderbook-contract · GitHub

We get an error when decoding the ABI with fuels-ts 94.5: abi-checker/package.json at ff30d34a2ea0913382430f3eece5701273a381ae · PaulZhemanov/abi-checker · GitHub

@PaulZhemanov Got it; thanks for the info.

  1. Just to confirm, did you redeploy the contract using v0.66.4?
  2. Also, have you been able to reproduce the problem with a local node?

I’m asking because the first post in this thread says it was initially deployed using v0.66.3, which could be problematic.

yes, we use the latest versions of every package, what more can we do to overcome this problem?

Hey @PaulZhemanov :wave:

Apologies for the slow response from me.

I have done a deep dive on the issue and believe I have found the underlying problem. A fix is imminent and I’ll reply here once available.

3 Likes

@p.s thanks for feedback! we looking forward the solution!

@PaulZhemanov

Just deployed the fix to NPM and I can successfully decode the log from the reproduction.

You can use the tag 0.0.0-pr-3162-20240913112142 to unblock your development.

Please let me know if you run into any issues :slight_smile:

thanks! when can we expect a fuels-ts update?

We generally release every Wednesday, so the 18th of September.

Edit: we’re looking to release this later today.

1 Like