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

Sidecar fails to decode Bittensor block #1513

Closed
alpay-falconx opened this issue Oct 14, 2024 · 2 comments
Closed

Sidecar fails to decode Bittensor block #1513

alpay-falconx opened this issue Oct 14, 2024 · 2 comments
Assignees

Comments

@alpay-falconx
Copy link

Description

Related issue: polkadot-js/apps#11001

When using the typesBundle from this PR, the sidecar fails to decode a block with exstrinsics containing events from the following pallet: balances, subtensorModule.

For example this testnet finney block at height 3,012,511 which contains a transferKeepAlive extrinsic fails to get decoded with the following error:

{
"code": 500,
"message": "createType(SignedBlock):: Struct: failed on block: {\"header\":\"Header\",\"extrinsics\":\"Vec<Extrinsic>\"}:: Struct: failed on extrinsics: Vec<Extrinsic>:: createType(ExtrinsicV4):: createType(Call):: Call: failed decoding system.killStorage:: Struct: failed on args: {\"keys\":\"Vec<Bytes>\"}:: decodeU8aStruct: failed at 0x0300801927120516e378941811b605fe… on keys (index 1/1): Vec<Bytes>:: Vec length 655982592 exceeds 65536",
"stack": "Error: createType(SignedBlock):: Struct: failed on block: {\"header\":\"Header\",\"extrinsics\":\"Vec<Extrinsic>\"}:: Struct: failed on extrinsics: Vec<Extrinsic>:: createType(ExtrinsicV4):: createType(Call):: Call: failed decoding system.killStorage:: Struct: failed on args: {\"keys\":\"Vec<Bytes>\"}:: decodeU8aStruct: failed at 0x0300801927120516e378941811b605fe… on keys (index 1/1): Vec<Bytes>:: Vec length 655982592 exceeds 65536\n    at createTypeUnsafe (/usr/src/app/node_modules/@polkadot/types-create/cjs/create/type.js:54:22)\n    at TypeRegistry.createTypeUnsafe (/usr/src/app/node_modules/@polkadot/types/cjs/create/registry.js:230:52)\n    at RpcCore._formatOutput (/usr/src/app/node_modules/@polkadot/rpc-core/cjs/bundle.js:331:25)\n    at RpcCore._formatResult (/usr/src/app/node_modules/@polkadot/rpc-core/cjs/bundle.js:169:20)\n    at callWithRegistry (/usr/src/app/node_modules/@polkadot/rpc-core/cjs/bundle.js:190:25)\n    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)",
"level": "error"
}

Steps to Reproduce

I pasted the typesBundle linked above into the sidecar repo as a json file and set the SAS_SUBSTRATE_TYPES_BUNDLE variable in .env.docker to the path where the json is located (./bittensorTypesBundle.json). I also set the node url with SAS_SUBSTRATE_URL=wss://test.finney.opentensor.ai:443 which points to the public bittensor node mentioned here https://docs.bittensor.com/bittensor-networks.

So the typesBundle file contains this

{
  "spec": {
    "bittensor": {
      "types": [
        {
          "minmax": [
            0,
            null
          ],
          "types": {
            "Balance": "u64",
            "NeuronMetadata": {
              "version": "u32",
              "ip": "u128",
              "port": "u16",
              "ipType": "u8",
              "uid": "u32",
              "netuid": "u16",
              "modality": "u8",
              "hotkey": "AccountId",
              "coldkey": "AccountId",
              "active": "u32",
              "lastUpdate": "u64",
              "priority": "u64",
              "stake": "u64",
              "rank": "u64",
              "trust": "u64",
              "consensus": "u64",
              "incentive": "u64",
              "dividends": "u64",
              "emission": "u64",
              "bonds": "Vec<(u32, u64)>",
              "weights": "Vec<(u32, u32)>"
            }
          }
        }
      ]
    }
  }
}

Given the above I took the following steps:

  1. build sidecar docker image with docker build -t bittensorsidecar . (run in the repo root)
  2. run the container docker run --rm -it --read-only --env-file .env.docker -p 8080:8080 bittensorsidecar
  3. perform GET http://localhost:8080/blocks/3012511 which leads to the error above

NOTE: The public node is not archival so it is likely this block will not be retrievable therefore this specific case is not reproducable. However this issue can be repro'ed when fetching any block containing extrinsics with pallet balances or subtensorModule.

Expected vs. Actual Behavior

Expected behavior is the block is fully decoded and contains the extrinsic with transferKeepAlive events (as you would see when retrieving a block for the polkadot chain).

@Imod7
Copy link
Contributor

Imod7 commented Oct 15, 2024

Hello @alpay-falconx ,
I run Sidecar locally with the URL and TYPES_BUNDLE that you specified and the block is being decoded correctly. I query the same block http://localhost:8080/blocks/3012511 and the response also contains the transferKeepAlive extrinsic that you mention :

...
...
{
      "method": {
        "pallet": "balances",
        "method": "transferKeepAlive"
      },
      "signature": {
        "signature": "0x06288cff4de6729509821af82bfd06e39628b9e1720971ab8e6a8adb19e3c67072ee877f8b588881092b17065f23f1d2f818c12760e5ecb258fb83a6bea7d881",
        "signer": {
          "id": "5DtL7b5MLxzCYMgjsULFYWFGgBPLBzP6t71Qgw2CFa7TYspX"
        }
      },
...
...

So maybe the error is how you build and run the docker image ? When you run the container, can you check that in the console you don't get any errors such as "Sidecar not being able to find the types bundle file" ? If everything runs correctly and it finds the types bundle file then In the console you should see this

...
...
  📦 SUBSTRATE:
     ✅ URL: "wss://test.finney.opentensor.ai:443"
     ✅ TYPES_BUNDLE: "../../bittensorTypesBundle.json"
...
...

and the types_bundle path should be the corresponding one for your setup.

@Imod7 Imod7 self-assigned this Oct 15, 2024
@alpay-falconx
Copy link
Author

alpay-falconx commented Oct 21, 2024

@Imod7 thanks for the sanity check. I had error level logs which were covering up some errors and also was not running the latest master branch. I now have the sidecar running locally able to decode blocks with balances pallet events and bittensorSubmodule pallet events. We can close this issue.

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

2 participants