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_estimateGas returns gas is different from reth and returns a larger value #31048

Open
moyishizhe opened this issue Jan 20, 2025 · 3 comments
Labels

Comments

@moyishizhe
Copy link

System information

Geth version: geth version
CL client & version: e.g. lighthouse/nimbus/[email protected]
OS & Version: Windows/Linux/OSX
Commit hash : (if develop)

Actual behaviour

reth:

curl --location 'https://ethereum-rpc.publicnode.com/' \
--header 'Content-Type: application/json' \
--data '{"method":"eth_estimateGas","params":[{"from":"0x53c26a4e5b698940c3a0c520821544f7a48ade5b","to":"0xeb9bf100225c214efc3e7c651ebbadcf85177607","value":"0x186a0", "data":"0xe11013dd00000000000000000000000053c26a4e5b698940c3a0c520821544f7a48ade5b0000000000000000000000000000000000000000000000000000000000030d400000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000b7375706572627269646765000000000000000000000000000000000000000000"}],"id":1,"jsonrpc":"2.0"}'
{"jsonrpc":"2.0","id":1,"result":"0x234e2"}

geth:

curl --location 'https://api.zan.top/eth-mainnet' \
--header 'Content-Type: application/json' \
--data '{"method":"eth_estimateGas","params":[{"from":"0x53c26a4e5b698940c3a0c520821544f7a48ade5b","to":"0xeb9bf100225c214efc3e7c651ebbadcf85177607","value":"0x186a0", "data":"0xe11013dd00000000000000000000000053c26a4e5b698940c3a0c520821544f7a48ade5b0000000000000000000000000000000000000000000000000000000000030d400000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000b7375706572627269646765000000000000000000000000000000000000000000"}],"id":1,"jsonrpc":"2.0"}'
{"result":"0x9ba0e","id":1,"jsonrpc":"2.0"}
@ChanHongMing
Copy link

Tracing inside the call,
we found that it is due to a delegate call from 0x88e529a6ccd302c948689cd5156c83d4614fae92 to 0xe2f826324b2faf99e513d16d266c3f80ae87832b
This is due to opcode BASEFEE return a 0 in geth, while reth return something "0x6624359bf" at certain block
This is Geth
Image
This is Reth
Image

@MariusVanDerWijden
Copy link
Member

Looks like we manually set it to 0 to avoid something breaking here:

evmContext.BaseFee = new(big.Int)

Maybe @s1na knows more, if I understand the code correctly, we could also take min(basefee, feecap) to solve the same issue

@s1na
Copy link
Contributor

s1na commented Jan 20, 2025

Right base fee is set to 0 because by default eth_call and eth_estimateGas have a gas price (fee cap) of 0 and it is a protocol violation to have baseFee > fee cap. (see context: #28470)

Setting a realistic gas price in eth_estimateGas should return the correct response.

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

No branches or pull requests

4 participants