forked from protolambda/erigon
-
Notifications
You must be signed in to change notification settings - Fork 15
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
Incorrect gas estimation #183
Comments
Hi, this issue is being tracked and fixed in upstream erigon in this issue: erigontech#10373. Once the fix is released as |
This was referenced Jun 16, 2024
yperbasis
pushed a commit
to erigontech/erigon
that referenced
this issue
Jun 24, 2024
Hi guys, we had an issue come up on our fork of erigon regarding some gas fee calculation: testinprod-io#183 We thought this would apply to upstream erigon as well, so brought the changes here too. I'd appreciate any feedbacks or concerns for this 😄 ## Problem This PR fixes gas fee calculation for rpc calls. It mostly borrows changes from geth and resolves previous issues. ```bash curl "https://localhost:8545 " -X POST -H "Content-Type: application/json" -d ' {"jsonrpc": "2.0", "id": "1", "method": "eth_estimateGas", "params": [{"from": "0xa5B8492D8223D255dB279C7c3ebdA34Be5eC9D85","data": "0x00", "to": "0xa5B8492D8223D255dB279C7c3ebdA34Be5eC9D85" }, "pending"]}' ``` Results in: ``` "code":-32000,"message":"insufficient funds for gas * price + value: address 0xa5B8492D8223D255dB279C7c3ebdA34Be5eC9D85 have 0 want 56956314575938201239799312" ``` Instead, it should return a valid RPC response. ## Detail Currently, erigon sets the gasFeeCap to header's baseFee by default. Setting gasFeeCap to baseFee will prevent calling eth_estimateGas with 0-balance accounts because the account's balance has to be bigger than the baseFee. However, in practice, many debug calls and estimateGas calls are called on 0-balance accounts, and without any gas-related fields set. Previous version of erigon and Geth allowed debug calls to be called on 0-balance accounts without setting gas parameters, so this PR attempts to bring back such behavior. ## Solution There is `evm.Config().NoBaseFee` which is used to signify that base fee is not required for this evm call. When this field is set AND gasPrice is not assigned, we set the block context's baseFee to 0. Because the baseFee is configured to 0 for these debug rpc calls, the feeCap will be always bigger than baseFee which passes the eip1599 validation. Also, 0-account balances will be able to call rpcs since the required gasFee is 0. This allows any debug calls without explicit gasPrice to also ignore the baseFee when calculating account balance/eip1559 check/etc. Also, currently, `NoBaseFee` is set to `true` for calls like `estimateGas`/`createAccessList`/`eth_call`, but not for `debug_traceCall`. This PR also sets `NoBaseFee` to `true` for `debug_traceCall` so that they can also ignore the base fee rule when needed. This PR from geth addresses similar concern: ethereum/go-ethereum#23027
Fixed in https://github.com/testinprod-io/op-erigon/releases/tag/v2.60.2-0.6.5. Thanks for your patience! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
System information
Erigon version:
erigon version 0.05.2-unstable
OS & Version: Linux/Docker
Commit hash:
Erigon Command (with flags/config):
erigon --datadir=/home/node/data --db.pagesize=4096 --ethash.dagdir=/home/node/data/dag --db.size.limit=8TB --chain=base-mainnet --networkid=8453 --authrpc.jwtsecret=/home/node/jwt-secret.txt --authrpc.vhosts=* --http --http.addr=0.0.0.0
Consensus Layer: NA
Consensus Layer Command (with flags/config): NA
Chain/Network: Base and Optimism
Expected behaviour
Returns correct gas value
Actual behaviour
Steps to reproduce the behaviour
The text was updated successfully, but these errors were encountered: