foundry: RPC call getBlockByNumber behaves different than Ganache

Component

Anvil

Have you ensured that all of these are up to date?

  • Foundry
  • Foundryup

What version of Foundry are you on?

forge 0.2.0 (e6f2bc6 2022-06-07T00:05:25.119456Z)

What command(s) is the bug in?

anvil

Operating System

Linux

Describe the bug

I’m trying to run a Graph node against a local Anvil instance in a docker compose setup. The Graph node errors with the following errors:

Jun 07 19:10:06.455 WARN Trying again after eth_getBlockByNumber(0, false) RPC call failed (attempt #10) with result Err(Decoder error: Error("invalid length 1, expected a (both 0x-prefixed or not) hex string with length of 16", line: 0, column: 0)), provider: mainnet-rpc-0

I investigated and I get an error if I call the JSON-RPC request against Anvil:

curl --request POST \
  --url http://localhost:8545/ \
  --header 'content-type: application/json' \
  --data '{"jsonrpc":"2.0","method":"eth_getBlockByNumber","params":[0,  false],"id":1}'

However, this works when the param “0” is a string.

In ganache-cli I can query with that same cURL and get a proper response. I’d like this functionality to be able to run full E2E tests using Anvil.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 20 (12 by maintainers)

Most upvoted comments

OK given this affects more people and the ecosystem’s reliance on ganache’s (wrong) implementation am convinced that it’s OK to deviate from spec here.

Let’s add a big fat warning in the code and try to get the graph to implement a proper fix so that it works with Geth.