Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Incorrect RPC response when eth_call fails #59

Closed
area opened this issue Jan 25, 2018 · 1 comment · May be fixed by cleancoindev/macaron-core#2
Closed

Incorrect RPC response when eth_call fails #59

area opened this issue Jan 25, 2018 · 1 comment · May be fixed by cleancoindev/macaron-core#2

Comments

@area
Copy link
Contributor

area commented Jan 25, 2018

Expected Behavior

When an eth_call is made, and the call fails, a valid JSON response should be received, with the default ('empty') values for the return types in the result field. with a result field of 0x.

Current Behavior

Currently, the JSON response is of the form:

{"id":284,"jsonrpc":"2.0"}

This is missing the result field, as defined in the spec, and so web3 rejects it with Error: Invalid JSON RPC response.

Possible Solution

I think this is because result is undefined when the response is serialized, and gets removed entirely. I don't think returning undefined would be appropriate either though.

Steps to Reproduce (for bugs)

Deploy a contract with the below function, and run eth_call against it:

    function someFunction() public view returns (bool){
        require(false);
        return true;
    }

Your Environment

EthereumJS TestRPC v6.0.3 (ganache-core: 2.0.2) on OSX 10.13.2, Node v8.4.0

@area area changed the title Incorrect response when eth_call fails Incorrect RPC response when eth_call fails Jan 25, 2018
@area area changed the title Incorrect RPC response when eth_call fails Incorrect RPC response when eth_call fails Jan 25, 2018
@area
Copy link
Contributor Author

area commented Jan 26, 2018

In this scenario, Parity responds with 0x in the response field. Introducing something like

	if (newResponse.result === undefined) {
		newResponse.result = '0x';
	}

to reportErrorInResponse appears to fix the issue for me.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants