Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

anvil cannot fork from https://ethereum-goerli.publicnode.com #5458

Closed
2 tasks done
aathan opened this issue Jul 24, 2023 · 5 comments
Closed
2 tasks done

anvil cannot fork from https://ethereum-goerli.publicnode.com #5458

aathan opened this issue Jul 24, 2023 · 5 comments
Labels
T-bug Type: bug

Comments

@aathan
Copy link
Contributor

aathan commented Jul 24, 2023

Component

Anvil

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

  • Foundry
  • Foundryup

What version of Foundry are you on?

anvil 0.1.0 (6e09b4e 2023-07-24T00:19:12.456381803Z)

What command(s) is the bug in?

anvil

Operating System

Linux

Describe the bug

This should "just work" right? Repeated calls show a different (higher) result in the jsonrpc portion of the JsonRpcClientError, so this data does seem to indicate a proper response from publicnode.com. hardhat is able to fork from that url without a problem.

$ RUST_LOG="info" anvil --fork-url https://ethereum-goerli.publicnode.com
thread 'main' panicked at 'Failed to get fork block number: JsonRpcClientError(SerdeJson { err: Error("response must be either a success/error or notification object", line: 1, column: 71), text: "{\"jsonrpc\":\"2.0\",\"method\":\"eth_blockNumber\",\"result\":\"0x8f696c\",\"id\":1}" })', /home/runner/work/foundry/foundry/anvil/src/config.rs:841:30
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
@aathan aathan added the T-bug Type: bug label Jul 24, 2023
@gakonst gakonst added this to Foundry Jul 24, 2023
@github-project-automation github-project-automation bot moved this to Todo in Foundry Jul 24, 2023
@mattsse
Copy link
Member

mattsse commented Jul 24, 2023

for some reason this endpoint returns the method value itself in the response

{"jsonrpc":"2.0","method":"eth_blockNumber","result":"0x8f6a50","id":1}

which is invalid json rpc

@Evalir
Copy link
Member

Evalir commented Jul 24, 2023

Yep as mattsse said, this endpoint is returning invalid json rpc. It's a bit of a minor issue but we prefer to keep it strict

closing as reason is found

@Evalir Evalir closed this as completed Jul 24, 2023
@github-project-automation github-project-automation bot moved this from Todo to Done in Foundry Jul 24, 2023
@aathan
Copy link
Contributor Author

aathan commented Jul 24, 2023

Can we have a --relaxed-rpc option? It seems in other areas (I remember seeing a thread on this topic), foundry/anvil is looking to achieve parity with hardhat and it arguably should be possible to move a project between hardhat and foundry easily. This would allow devs to both test that two EVM emulators from different sources yield the same behaviors, as well as test the emulators themselves. Also, with problems stemming from upstream inaccuracies relative to standards, there's not much that users can do. Failing to process a response that returns a base 10 vs base 16, or without zero padding, for example, are problems I've reported in hardhat which were relaxed in cases deemed safe. Also relevant is that publicnode.com has a non-trivial user base.

Meanwhile I'll patch my anvil and alert publicnode.com.

@aathan
Copy link
Contributor Author

aathan commented Jul 25, 2023

For anyone else stumbling on a similar issue, you can relax ether-rs's strict json rpc response handling by making this change in ethers-providers/src/rpc/transports/common.rs ~ line 211:

                 match (id, result, error, method, params) {
                   (Some(id), Some(result), None, None, None) => {

to

                 match (id, result, error, method, params) {
                    (Some(id), Some(result), None, _, _) => {

@aathan
Copy link
Contributor Author

aathan commented Jul 27, 2023

See #5490

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-bug Type: bug
Projects
Archived in project
Development

No branches or pull requests

3 participants