1

I created a custom function in a custom RPC call to send a raw transaction :

fn send_raw_transaction(&self, bytes: Bytes) -> FutureResult<TxHash<P>> {
        let slice = &bytes.0[..];
        if slice.len() == 0 {
            return Box::pin(future::err(internal_err("transaction data is empty")));
        }

        let extend = rlp::encode(&slice);
        let block_hash = BlockId::hash(self.client.info().best_hash);

        let ext = "05000046ebddef8cd9bb167dc30878d7113b7e168e6f0646beffd77d69d39bad76b47a30".as_bytes();
        let xt = match Decode::decode(&mut &ext[..]) {
            Ok(xt) => xt,
            Err(_) => return Box::pin(future::err(internal_err("cannot access runtime api"))),
        };
        println!("extrinsic : {:?}",ext);

        return Box::pin(
            self.pool
                .submit_one(&block_hash, TransactionSource::Local, xt)
                .map_err(|err| {
                    internal_err(format!("submit transaction to pool failed: {:?}", err))
                }),
        );
    }
}

05000046ebddef8cd9bb167dc30878d7113b7e168e6f0646beffd77d69d39bad76b47a30

This should be a balances.transfer call.

When I try to call this method I just receive an error :

submit transaction to pool failed: RuntimeApi("Execution failed: Execution aborted due to trap: wasm trap: wasm unreachable instruction executed\nWASM backtrace:\n\n 0: 0x113908 - !rust_begin_unwind\n") RpcError: -32603: submit transaction to pool failed: RuntimeApi("Execution failed: Execution aborted due to trap: wasm trap: wasm unreachable instruction executed\nWASM backtrace:\n\n 0: 0x113908 - !rust_begin_unwind\n")

Do you have an idea, where this error come from ?

thank you.

3
  • Around this error in your log you should also see the actual panic that is printed into the log as well. What does it say?
    – bkchr
    Aug 22, 2022 at 14:41
  • @bkchr the full message : 2022-08-23 10:28:36 RPC-CORE: sendRawTransaction(extrinsic: Bytes): U256:: -32603: submit transaction to pool failed: RuntimeApi("Execution failed: Execution aborted due to trap: wasm trap: wasm ``unreachable`` instruction executed\nWASM backtrace:\n\n 0: 0x113908 - <unknown>!rust_begin_unwind\n") RpcError: -32603: submit transaction to pool failed: RuntimeApi("Execution failed: Execution aborted due to trap: wasm trap: wasm ``unreachable`` instruction executed\nWASM backtrace:\n\n 0: 0x113908 - <unknown>!rust_begin_unwind\n")
    – cibou
    Aug 23, 2022 at 8:29
  • It should be somewhere before this message in the log.
    – bkchr
    Aug 23, 2022 at 9:35

1 Answer 1

6

05000046ebddef8cd9bb167dc30878d7113b7e168e6f0646beffd77d69d39bad76b47a30 is an encoded call, but it is not an encoded extrinsic. So you won't be able to submit that into the pool, the format is incorrect.

Above you have

<call index><call data>

any extrinsic is in the format of

<compact length><version><signature (if signed)><extension data><call index><call data>

Since the length is missing (and then the version flag with the signed/unsigned bit), the runtime cannot decode it to submit to the pool.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.