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

eth_call stateDiff incompatible with geth and other clients. #8345

Closed
ape-dev-cs opened this issue Oct 2, 2023 · 3 comments
Closed

eth_call stateDiff incompatible with geth and other clients. #8345

ape-dev-cs opened this issue Oct 2, 2023 · 3 comments
Labels
imp2 Medium importance

Comments

@ape-dev-cs
Copy link

ape-dev-cs commented Oct 2, 2023

When calling eth_call with a 3rd parameter / stateDiff, Erigon errors out with a format that geth accepts, and geth errors when you give it a format that Erigon accepts. I've only reproduced this as a consumer of Erigon over various 3rd party APIs, however I've reproduced it on mainnet and gnosis chain, across several providers which offer Erigon as an option.

Geth expects padded hex, but Erigon wants unpadded hex.

The following stateDiff format will work for Geth, but if you change the URL to an Erigon endpoint, you'll get invalid argument 2: hex number with leading zero digits

curl --location '<geth rpc url>' \
--header 'Content-Type: application/json' \
--data '{"method":"eth_call","params":[
  {
    "to": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
    "data": "0x70a08231000000000000000000000000cee284f754e854890e311e3280b767f80797180d"
  },
  "latest",
  {
    "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48": {
      "stateDiff": {
        "0xe662039a65ca5042e7bf9cd555c85673904cb7f77f060e9932ce299a47545319": "0x000000000000000000000000000000000000000000000000000000003b9aca00"
      }
    }
  }
],"id":50,"jsonrpc":"2.0"}'

Conversely, if you hit Erigon with the following (identical but with statediff value zero pading removed), you'll get a correct response:

curl --location '<erigon rpc url>' \
--header 'Content-Type: application/json' \
--data '{"method":"eth_call","params":[
  {
    "to": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
    "data": "0x70a08231000000000000000000000000cee284f754e854890e311e3280b767f80797180d"
  },
  "latest",
  {
    "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48": {
      "stateDiff": {
        "0xe662039a65ca5042e7bf9cd555c85673904cb7f77f060e9932ce299a47545319": "0x3b9aca00"
      }
    }
  }
],"id":50,"jsonrpc":"2.0"}'

But if you fire this request at Geth, you get invalid argument 2: hex string has length 8, want 64 for common.Hash

Root cause of this seems to be Account.State and Account.StateDiff in api.go being implemented as map of Hash -> uint64, rather than in geth's implementation where it's a map of Hash -> Hash.

I'm guessing this could be fixed with either more permissive marshalling/unmarshalling, or changing the underlying type, but I don't want to submit a PR until I've had some guidance from someone more experienced with the codebase.

Copy link

This issue is stale because it has been open for 40 days with no activity. Remove stale label or comment, or this will be closed in 7 days.

@github-actions github-actions bot added the Stale label Nov 12, 2023
@yperbasis yperbasis removed the Stale label Nov 13, 2023
@soos3d
Copy link

soos3d commented Jan 18, 2024

This is affecting debug_traceCall as well.

@AskAlexSharov
Copy link
Collaborator

fixed by #10531 and #10531

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
imp2 Medium importance
Projects
None yet
Development

No branches or pull requests

4 participants