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 with blobs fails when capped by limited funds #29702

Closed
nand2 opened this issue May 3, 2024 · 1 comment
Closed

eth_estimateGas with blobs fails when capped by limited funds #29702

nand2 opened this issue May 3, 2024 · 1 comment
Labels

Comments

@nand2
Copy link
Contributor

nand2 commented May 3, 2024

System information

Geth version: 1.14.1-unstable-86a1f0c3-20240502
CL client & version: e.g. prysm@v5.0.3
OS & Version: Ubuntu 23.04
Commit hash : 86a1f0c

Expected behaviour

When doing an eth_estimateGas call of an eip4844 tx with blobs, with the account holding enough ETH but not too much (not multiple of what is necessary), it should work.

The call includes maxFeePerBlobGas, maxFeePerGas, maxPriorityFeePerGas.

{"jsonrpc":"2.0","id":5,"method":"eth_estimateGas","params":[{"blobVersionedHashes":["0x01728b8444295cdd28e4dde23e352a4dc5aefa1a5a2cfec522fb3fe04af56732"],"blobs":["0x0068656c6c6f20776f726c642066726f6d20657468657265756d20737461746500800000..."],"data":"0xdb93dcef00000000000000000000000000000000....","from":"0x79E374Babb092590eD82f9A7cA5631aEAd710dea","maxFeePerBlobGas":"0xb44997e62","maxFeePerGas":"0x62fc7c875","maxPriorityFeePerGas":"0x3b9aca00","nonce":"0x3","to":"0xbe78dc6a57dfd9f8898C8C8edd5Bc1C9571E391E","value":"0x0"}]}

Actual behaviour

The call fails with Failed with XXX gas: insufficient funds for gas * price + value: address 0x79E374Babb092590eD82f9A7cA5631aEAd710dea have YYY want ZZZ, with XXX looking random and way above the necessary gas, ZZZ being always a bit above YYY.

In the above example, the message was Failed with 2853958 gas: insufficient funds for gas * price + value: address 0x79E374Babb092590eD82f9A7cA5631aEAd710dea have 75833739893214239 want 82177035114105854

Steps to reproduce the behaviour

Calling eth_estimateGas with blobs with the account holding enough ETH, but not too much (not multiple of what is necessary), will trigger the bug.

Reason

I think I have identified the bug. In the gasestimator.go code, when computing the highest gas limit with the account available balance, it does not take into account the gas used to pay for blobs.

It can be seen with the example above : account has 75833739893214239 wei, maxFeePerGas is 26571425909 wei, the code compute an allowance (max gas limit) of 75833739893214239 / 26571425909 = 2853958 gas (which match the error message).

But then it tries to execute the code with a gas fee of 2853958 * 26571425909 + 131072 (blob gas) * 48395550306 (blog gas fee) = 82177035114105854 wei, which match the error message.

A PR will follow shortly.

@nand2
Copy link
Contributor Author

nand2 commented May 3, 2024

Using the attached PR, the bug no longer appears.
I'm new to the go-ethereum codebase, so my code may be wrong, please let me know :-)

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

1 participant