AcalaNetwork / chopsticks

Create parallel reality of your Substrate network.
Apache License 2.0
138 stars 84 forks source link

called `Result::unwrap()` on an `Err` value: RuntimeVersion(RuntimeVersionDecode) #666

Closed ntn-x2 closed 6 months ago

ntn-x2 commented 9 months ago

From the branch at: https://github.com/KILTprotocol/kilt-node/tree/aa/dip-improvements, and the runtime dip-consumer-runtime-template.

Full error:

[13:08:18.340] INFO: DIP consumer dev RPC listening on port 8000
    app: "chopsticks"
[13:08:18.340] INFO: Loading config file https://raw.githubusercontent.com/AcalaNetwork/chopsticks/master/configs/rococo.yml
    app: "chopsticks"
panicked at src/task.rs:131:6:
called `Result::unwrap()` on an `Err` value: RuntimeVersion(RuntimeVersionDecode)

Stack:

Error
    at imports.wbg.__wbg_new_abda76e883ba8a5f (/home/antonio/.npm/_npx/c1c4d257924715f9/node_modules/@acala-network/chopsticks-executor/dist/cjs/chopsticks_executor.js:748:19)
    at wasm://wasm/00966b66:wasm-function[701]:0x1269bf
    at wasm://wasm/00966b66:wasm-function[866]:0x130a13
    at wasm://wasm/00966b66:wasm-function[795]:0x12b783
    at wasm://wasm/00966b66:wasm-function[105]:0xa7664
    at wasm://wasm/00966b66:wasm-function[380]:0x10eb7c
    at wasm://wasm/00966b66:wasm-function[917]:0x1312f9
    at __wbg_adapter_48 (/home/antonio/.npm/_npx/c1c4d257924715f9/node_modules/@acala-network/chopsticks-executor/dist/cjs/chopsticks_executor.js:410:10)
    at real (/home/antonio/.npm/_npx/c1c4d257924715f9/node_modules/@acala-network/chopsticks-executor/dist/cjs/chopsticks_executor.js:394:22)
    at node:internal/process/task_queues:140:7

[13:08:19.250] INFO: Rococo RPC listening on port 8001
    app: "chopsticks"

node:internal/event_target:1033
  process.nextTick(() => { throw err; });
                           ^
Error [RuntimeError]: unreachable
    at wasm://wasm/00966b66:wasm-function[701]:0x126ad5
    at wasm://wasm/00966b66:wasm-function[866]:0x130a13
    at wasm://wasm/00966b66:wasm-function[795]:0x12b783
    at wasm://wasm/00966b66:wasm-function[105]:0xa7664
    at wasm://wasm/00966b66:wasm-function[380]:0x10eb7c
    at wasm://wasm/00966b66:wasm-function[917]:0x1312f9
    at __wbg_adapter_48 (/home/antonio/.npm/_npx/c1c4d257924715f9/node_modules/@acala-network/chopsticks-executor/dist/cjs/chopsticks_executor.js:410:10)
    at real (/home/antonio/.npm/_npx/c1c4d257924715f9/node_modules/@acala-network/chopsticks-executor/dist/cjs/chopsticks_executor.js:394:22)
    at node:internal/process/task_queues:140:7
    at AsyncResource.runInAsyncScope (node:async_hooks:203:9)
Emitted 'error' event on Worker instance at:
    at [kOnErrorMessage] (node:internal/worker:300:10)
    at [kOnMessage] (node:internal/worker:311:37)
    at MessagePort.<anonymous> (node:internal/worker:212:57)
    at [nodejs.internal.kHybridDispatch] (node:internal/event_target:757:20)
    at exports.emitMessage (node:internal/per_context/messageport:23:28)

Node.js v18.18.2

Runtime is based on Polkadot 0.9.43, attached to a Rococo local also running 0.9.43. Is there a specific version of chopsticks I should use for this, or is the error due to something else?

ermalkaleci commented 9 months ago

https://github.com/AcalaNetwork/chopsticks/issues/663

ntn-x2 commented 9 months ago

@ermalkaleci thanks for the prompt response! So I get that there is not a single source of error, but I have to try the different options tried in the issue you linked? Or do you want me to comment on that issue?

ermalkaleci commented 9 months ago

the above error is because of the wrong version

ermalkaleci commented 9 months ago

your runtime fails here https://github.com/smol-dot/smoldot/blob/210cc8bacecf5f3ea0057c80183cc9efe7f45f73/lib/src/executor/host/runtime_version.rs#L438

ntn-x2 commented 9 months ago

Ok thank you. By wrong version I assume you mean the wrong chopsticks version? What is the latest version of chopstick that works with a runtime based on Substrate 1.0.0?

ntn-x2 commented 9 months ago

I tried state_version with value 0, 1, and 5, based on the linked issues, and they all returned the same error. The runtime is a template runtime, so I can change any value and restart the chain. What value should I put in there to make it work with chopsticks? Runtime is this: https://github.com/KILTprotocol/kilt-node/blob/develop/dip-template/runtimes/dip-consumer/src/lib.rs. Is there maybe something missing in the state, that I should populate at genesis time? I don't think so, as everything is extracted from the WASM blob, right?

Plus, the only thing I am putting in the config file, for testing purposes, is the endpoint of a local node running that runtime. No WASM override yet, which I'd like to introduce once I have the fork running, for debugging reasons.

ermalkaleci commented 9 months ago

the previous issue is getting decode error because they have state_version: 5 which is invalid. I don't know what's your issue but smoldot fails to decode your runtime version. You will need to do some debugging. Also kilt seems to work with chopsticks, what endpoint are you trying to test?

ntn-x2 commented 9 months ago

@ermalkaleci yes, trying to fork Peregrine and Spiritnet work. We have a couple of "template" runtimes that showcase how to use a combination of pallets we are releasing soon. The template takes most of the code from the Peregrine runtime, so I really am not sure what the cause could be. I will try to debug it a bit more, but you confirm that state_version should be set to 0, as it is the case with our live networks?

I am spinning up a local node with the template runtime and connecting to it, which fails as soon as I open PolkadotJS Apps with the error I showed above.

ermalkaleci commented 9 months ago

upload the wasm here, I will give it a try

ntn-x2 commented 9 months ago

https://drive.google.com/file/d/1-s9lnSNjSXslS6w8n2F0-h3GajRiOhLq

ermalkaleci commented 9 months ago

in your case it seems it can't decode runtimeVersion.apis

lrazovic commented 8 months ago

We experience the same problem on Polimec (wss://rpc.polimec.org). What can we do to help solve/debug the problem?