rust-web3 icon indicating copy to clipboard operation
rust-web3 copied to clipboard

Decoding issue with failing transaction on ganache

Open palango opened this issue 2 years ago • 2 comments

I'm sending some transaction using Contract.signed_call_with_confirmations on a ganache test chain.

This transaction reverts, but web3 is unable to properly decode the error:

failed to deserialize response: data did not match any variant of untagged enum Output

This looks a bit like https://github.com/tomusdrw/rust-web3/issues/460 , but that has been fixed. Any hints?

Complete logs:

[2021-10-29T15:57:29Z DEBUG web3::transports::http] [id:4] sending request: "{\"jsonrpc\":\"2.0\",\"method\":\"eth_sendRawTransaction\",\"params\":[\"0xf9010e82010e8504a817c800830f424094e7f1725e7734ce288f8367e1bb143e90bb3f051280b8a40e0fe0eb00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000001820a96a00f4f00811f42307ccb03b40c6e68de289ce3d95de4ef079061e69ba4eca3e676a01e1a9bdb4e25f1dcfda36cfa376eb6da9e10653df43e255a9f0f9f60251734d5\"],\"id\":4}"
[2021-10-29T15:57:29Z DEBUG reqwest::async_impl::client] response '200 OK' for http://127.0.0.1:8545/
[2021-10-29T15:57:29Z DEBUG web3::transports::http] [id:4] received response: "{\"id\":4,\"jsonrpc\":\"2.0\",\"result\":\"0x4b1a874402f1a69c819222bca5e0d5fc0da6290d42cbe11fe9b5c7aee194ccc2\",\"error\":{\"message\":\"VM Exception while processing transaction: revert\",\"code\":-32000,\"data\":{\"0x4b1a874402f1a69c819222bca5e0d5fc0da6290d42cbe11fe9b5c7aee194ccc2\":{\"error\":\"revert\",\"program_counter\":481,\"return\":\"0x\"},\"stack\":\"c: VM Exception while processing transaction: revert\\n    at Function.c.fromResults (/usr/local/lib/node_modules/ganache-cli/build/ganache-core.node.cli.js:4:192416)\\n    at w.processBlock (/usr/local/lib/node_modules/ganache-cli/build/ganache-core.node.cli.js:42:50915)\\n    at runMicrotasks (<anonymous>)\\n    at processTicksAndRejections (node:internal/process/task_queues:96:5)\",\"name\":\"c\"}}}"
got tx: Err(Transport("failed to deserialize response: data did not match any variant of untagged enum Output"))

palango avatar Oct 29 '21 16:10 palango

It's because Ganache sends a response which is not a valid JSON-RPC response, since it contains both result and error. It's a bit similar to https://github.com/tomusdrw/rust-web3/issues/544

The fix would need to be implemented in jsonrpc-core library. Or we could somehow try to override that in rust-web3 level. I'd prefer to stay strict in terms of spec-adherence, so maybe there is some way to workaround that by parsing to a custom Output first.

tomusdrw avatar Oct 31 '21 17:10 tomusdrw

Yes, I see your point. Feel free to close this issue then.

palango avatar Nov 08 '21 10:11 palango