NomicFoundation / hardhat

Hardhat is a development environment to compile, deploy, test, and debug your Ethereum software.
https://hardhat.org
Other
7.22k stars 1.38k forks source link

RSK fork full support #3772

Open fruiz08 opened 1 year ago

fruiz08 commented 1 year ago

Describe the feature

RSK fork is not currently working well. When a call to a contract should return 0 or nothing we get the following error:

eth_call

  Invalid JSON-RPC response's result.

  Errors: Invalid value "0x0" supplied to : DATA

Search terms

fork rsk

fvictorio commented 1 year ago

@fruiz08 can you tell us how to reproduce this? Is this just, for example, calling a method that returns 0?

fruiz08 commented 1 year ago

Yes, in my case was calling a ERC20.balanceOf(someAddress). If someAddress's balance is 0 i have that error I found a workaround adding this line in hardhat/node_modules/hardhat/internal/core/jsonrpc/types/output/decodeJsonRpcResponse.js

function decodeJsonRpcResponse(value, codec) {
    // this line 
    if (value === "0x0" && codec.name === 'DATA') value = "0x00";
    const result = codec.decode(value);
    if (result.isLeft()) {
        throw new errors_1.InvalidResponseError(`Invalid JSON-RPC response's result.

Errors: ${PathReporter_1.PathReporter.report(result).join(", ")}`);
    }
    return result.value;
}

but I'm still not sure if I may have other problems

fvictorio commented 1 year ago

Ok, the problem is that the RSK node returns 0x0 for eth_getStorageAt calls while most nodes return 0x000...000. But according to the spec, we should accept 0x0 too.