-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
underestimates tx with function that catches reverts
#13636
Comments
eth_estimateGas
underestimates significantlyeth_estimateGas
can underestimate function that catch reverts
eth_estimateGas
can underestimate function that catch revertseth_estimateGas
underestimates tx with function that catches reverts
So, it's Oke, somebody will take a look. |
From my previous tests around this it seems like |
Phillippe requested to prioritize it because it's a considerable blocker for CoW. |
also can we get an example rpc call? so that we can reproduce it? also I think it is fixed in |
due to lack of repsonsiveness. I will move this milestone to the next beta release |
Sorry for the late response. Didn't notice the notification in my inbox.
If erigon can now simulate on historic blocks this request should be able to reproduce the bug (if it's still there):
It's the same call as the tenderly simulation linked in the description and also tied to the same block. So if erigon now correctly estimates the gas costs this should also return ~4.8M.
I don't have access to a synced |
@somnathb1 attack |
Probably need an archive node to simulate this, syncing a node. Still will be on hold for a day or two |
@MartinquaXD I do see that when I send the request with 8.5M gas, it consumes around 4.8M gas. But it also doesn't throw any issues when passed around 180K gas.
At this point, i have a small fix for the API, but i would need to understand more about your requirements, and will take a call on whether this API should be fine tuned for that |
@somnathb1 I would just compare with geth and copy the mechanism |
Needed for #13636 (But doesn't optimally achieve the requirements yet)
Needed for #13636 (But doesn't optimally achieve the requirements yet)
…ix historical (#13903), qa-tests fix (#13909), and optimize for max contract gas used (#13913) (#13916) Needed for #13636 Cherry-pick #13772, #13903, #13909 and #13913 --------- Co-authored-by: Michelangelo Riccobene <michelangelo.riccobene@gmail.com> Co-authored-by: lupin012 <58134934+lupin012@users.noreply.github.com> Co-authored-by: alex.sharov <AskAlexSharov@gmail.com>
System information
Erigon version:
v2.60.6
Also tested it later with
v3-beta1
which had the same issueOS & Version: Linux
Commit hash:
Erigon Command (with flags/config):
Copied from
kubectl describe
Consensus Layer: lighthouse
Consensus Layer Command (with flags/config):
copied from
kubectl describe
Chain/Network: gnosis chain
Expected behaviour
eth_estimateGas
computes the maximum amount of gas a transaction can consume.Actual behaviour
eth_estimateGas
under estimates the gas A LOT.Here is some context in case it's helpful. Users on CoW Protocol can specify post-hooks which get executed after their order. These user provided calls get executed via a trampoline contract to have them run in an unprivileged context. Additionally the contract enforces a maximum amount of gas that may be used by the call.
Before submitting a CoW Protocol transaction we estimate the gas for it and set this (+ a buffer) as the gas limit. Since
eth_estimateGas
underestimated the gas usage a lot the post hook reverts because it runs out of gas.I suspect the issue is that because the transaction internally catches a revert caused by too little gas the minimum amount of gas a transaction consumes without reverting completely is relatively low. However, if we allow the transaction to consume more gas it would because the call that catches the revert gets to do more overall.
So instead of returning the minimum amount a tx can consume without reverting completely
eth_estimateGas
should probably return the maximum amount of gas the tx can actually consume to ensure that all the logic that could run as part of the tx actually gets to run.Steps to reproduce the behaviour
To reproduce the behavior I took one of the transactions where the underlying trade was executed successfully but the post hook reverted. From this I stripped out the underlying trade such that the transaction would only execute the post hook.
On tenderly this produces a gas estimate of ~4.8M while
eth_estimateGas
only reports ~181K:Interestingly if I only estimate the hook without the settlement and trampoline contract around it tenderly and
erigon
agree on the estimate:The text was updated successfully, but these errors were encountered: