AcalaNetwork / chopsticks

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

Submitting an extrinsic without `0x` prefix results in an error #305

Open kratico opened 1 year ago

kratico commented 1 year ago

It can be reproduced by getting a signed extrinsic and calling the author_submitExtrinsic endpoint.

The Polkadot RPC endpoint allows to pass the param without the 0x prefix

const ws = new WebSocket("ws://127.0.0.1:8000")

// a signed extrinsic without the 0x prefix
const extrinsic = "450284008eaf04151687736326c9fea17e25fc5287613693c912909cb226aa4794f26a48016e01fd8bb3ec174e95cc09a54ea864e20fe0d5fc609f7c3ea11acb1e79505b7c97fbc65af701124bec1b3d27d1fd50c84924f1a9fc76ab6c08552b2e3cfa04822500040005030090b5ab205c6974c9ea841be688864633dc9ca8a357843eeacf2314649965fe220b000cd809fa08"

ws.addEventListener("message", ({ data }) => console.log(JSON.parse(data)))
ws.addEventListener("open", () => {
  ws.send(JSON.stringify({
    id: 1,
    jsonrpc: "2.0",
    method: "author_submitExtrinsic",
    params: [extrinsic],
  }))
})

RPC error event

{
  id: 1,
  jsonrpc: "2.0",
  error: {
    code: 1011,
    message: "Error: Error while executing Wasm VM: wasm `unreachable` instruction executed\n" +
      `"panicked at 'Bad inpu`... 141 more characters
  }
}

Chopsticks logs

npx @acala-network/chopsticks@latest -e ws://127.0.0.1:9944
[11:22:35.465] INFO (rpc/56531): Development RPC listening on port 8000
[11:23:00.165] INFO (ws/56531): Error handling request: Error: Error: Error while executing Wasm VM: wasm `unreachable` instruction executed
"panicked at 'Bad input data provided to validate_transaction: Codec error', /Users/parity/ghq/github.com/paritytech/polkadot/runtime/polkadot/src/lib.rs:1520:1\n" 'Error: Error: Error while executing Wasm VM: wasm `unreachable` instruction executed
"panicked at 'Bad input data provided to validate_transaction: Codec error', /Users/parity/ghq/github.com/paritytech/polkadot/runtime/polkadot/src/lib.rs:1520:1\n"
    at /Users/parity/.npm/_npx/81ad9c881cb83600/node_modules/@acala-network/chopsticks/lib/rpc/substrate/author.js:12:19
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async WebSocket.<anonymous> (/Users/parity/.npm/_npx/81ad9c881cb83600/node_modules/@acala-network/chopsticks/lib/server.js:131:30)'
xlc commented 1 year ago

I will put this as "won't fix" for now until one of those happens:

dzmitry-lahoda commented 1 year ago

i have seen similar issue with wasm genesis. when some binary was not prefixed 0x - smoldot failed to load it. seems like it not only issue to fix. but anyway - fixed by using proper prefix.