foundry icon indicating copy to clipboard operation
foundry copied to clipboard

Eth fee estimation broken for recent clients

Open bearpebble opened this issue 9 months ago • 0 comments

Component

Forge, Cast

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

  • [X] Foundry
  • [X] Foundryup

What version of Foundry are you on?

forge 0.2.0 (a470d63 2024-05-16T00:17:19.757926135Z)

What command(s) is the bug in?

forge script, cast send, likely more

Operating System

Linux

Describe the bug

When using a recent version of geth, the data returned by eth_feeHistory can't be parsed due to using hex notation for the baseFeePerBlobGas field. I tried running a forge script invocation with RUST_LOG=trace and received the following error:

2024-05-16T09:49:41.972125Z TRACE ReqwestTransport{url=http://localhost:2323/}: alloy_transport_http::reqwest_transport: response body body={"jsonrpc":"2.0","id":1,"error":{"code":-32603,"message":"Fork Error: DeserError { err: Error(\"invalid number\", line: 1, column: 485), text: \"{\\\"oldestBlock\\\":\\\"0x22\\\",\\\"reward\\\":[[\\\"0x0\\\"],[\\\"0x0\\\"],[\\\"0x0\\\"],[\\\"0x3b9aca00\\\"],[\\\"0x3b9aca00\\\"],[\\\"0x3b9aca00\\\"],[\\\"0x3b9aca00\\\"],[\\\"0x3b9aca00\\\"],[\\\"0x3b9aca00\\\"],[\\\"0x3b9aca00\\\"]],\\\"baseFeePerGas\\\":[\\\"0xa2da33\\\",\\\"0x8e7eed\\\",\\\"0x7caf10\\\",\\\"0x6d192e\\\",\\\"0x5f9713\\\",\\\"0x53ae54\\\",\\\"0x495107\\\",\\\"0x402b0c\\\",\\\"0x383675\\\",\\\"0x3132d5\\\",\\\"0x2b1954\\\"],\\\"gasUsedRatio\\\":[0,0,0,0.0047321333333333335,0.0016569333333333333,0.004572766666666667,0.0008834666666666667,0.004088366666666667,0.0008836,0.004081066666666667],\\\"baseFeePerBlobGas\\\":[\\\"0x1\\\",\\\"0x1\\\",\\\"0x1\\\",\\\"0x1\\\",\\\"0x1\\\",\\\"0x1\\\",\\\"0x1\\\",\\\"0x1\\\",\\\"0x1\\\",\\\"0x1\\\",\\\"0x1\\\"],\\\"blobGasUsedRatio\\\":[0,0,0,0,0,0,0,0,0,0]}\" }"}}

This was fixed in alloy recently, so updating the dependencies should be good enough https://github.com/alloy-rs/alloy/pull/722

Reproducible by running a recent version of geth (geth version 1.14.2-stable-35b2d07f in my case).

#!/bin/sh

# start geth in the background so that we can prefund our dev account
geth --http --http.port 8545 --dev --http.api eth,web3,net,debug --gcmode=archive &

sleep 10
# prefund our dev account
geth attach --exec 'eth.sendTransaction({from: eth.accounts[0], to: "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", value: web3.toWei(50, "ether")})' /tmp/geth.ipc

cast send $(cast address-zero) --value 1 --mnemonic "test test test test test test test test test test test junk"
wait

Fails with

Error:
deserialization error: invalid number at line 1 column 168

Context:
- invalid number at line 1 column 168

bearpebble avatar May 16 '24 11:05 bearpebble