Description
System information
geth version 1.15.12-unstable-3f7b8bc9-20250526
Lighthouse v7.0.1-e42406d
Ubuntu 24.04
Expected behaviour
debug_traceCall is expected to accurately predict gasUsed for any transaction.
Actual behaviour
debug_traceCall inaccurately estimates gasUsed for transactions that change the state of Uniswap pools and possibly other similar contracts.
Steps to reproduce the behaviour
-
Choose any of the latest transactions of this MEV bot: https://etherscan.io/address/0x1f2f10d1c40777ae1da742455c65828ff36df387
-
execute this Python script replacing the data, example for tx 0xc07b3b748f960d5f7bd8697de816393ecdeaa5f988f531824488719f9951cebd
import requests
tx = {
"from": "0xae2Fc483527B8EF99EB5D9B44875F005ba1FaE13",
"to": "0x1f2F10D1C40777AE1Da742455c65828FF36Df387",
"input": "0x7f3866bff695f3b16a824869a8018a3a6e368524126901391a168b3c61113d7e6c2e6c1f0a9f2f313cf24c830bc325e1066003133d70a8c19306" ,
"value": hex(19662101395),
"maxFeePerGas": hex(1018223283),
"gas": hex(242077)
}
block_base = hex(22665900)
payload = {
"jsonrpc": "2.0",
"method": "debug_traceCall",
"id": 1,
"params": [
tx,
block_base,
{
"tracer": "callTracer",
"txIndex": hex(0)
}
]
}
r = requests.post("http://localhost:8545", json=payload)
print(r.json())
print(int(r.json()["result"]["gasUsed"], 16))
Output:
{'jsonrpc': '2.0', 'id': 1, 'result': {'from': '0xae2fc483527b8ef99eb5d9b44875f005ba1fae13', 'gas': '0x3b19d', 'gasUsed': '0x2a39a', 'to': '0x1f2f10d1c40777ae1da742455c65828ff36df387', 'input': '0x7f3866bff695f3b16a824869a8018a3a6e368524126901391a168b3c61113d7e6c2e6c1f0a9f2f313cf24c830bc325e1066003133d70a8c19306', 'calls': [{'from': '0x1f2f10d1c40777ae1da742455c65828ff36df387', 'gas': '0x3434e', 'gasUsed': '0x345e', 'to': '0x66bff695f3b16a824869a8018a3a6e3685241269', 'input': '0xa9059cbb0000000000000000000000006df064f04ddfb2bb53da21af9d56701726700145000000000000000000000000000000000000000001391a160000000000000000', 'output': '0x0000000000000000000000000000000000000000000000000000000000000001', 'value': '0x0', 'type': 'CALL'}, {'from': '0x1f2f10d1c40777ae1da742455c65828ff36df387', 'gas': '0x30594', 'gasUsed': '0xc3c3', 'to': '0x6df064f04ddfb2bb53da21af9d56701726700145', 'input': '0x022c0d9f00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000493f3db930000000000000000000000000000001f2f10d1c40777ae1da742455c65828ff36df38700000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000', 'calls': [{'from': '0x6df064f04ddfb2bb53da21af9d56701726700145', 'gas': '0x2be41', 'gasUsed': '0x323e', 'to': '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', 'input': '0xa9059cbb0000000000000000000000001f2f10d1c40777ae1da742455c65828ff36df3870000000000000000000000000000000000000000000000000493f3db93000000', 'output': '0x0000000000000000000000000000000000000000000000000000000000000001', 'value': '0x0', 'type': 'CALL'}, {'from': '0x6df064f04ddfb2bb53da21af9d56701726700145', 'gas': '0x28a72', 'gasUsed': '0x380', 'to': '0x66bff695f3b16a824869a8018a3a6e3685241269', 'input': '0x70a082310000000000000000000000006df064f04ddfb2bb53da21af9d56701726700145', 'output': '0x0000000000000000000000000000000000000000c9f123430fd894063d48b198', 'type': 'STATICCALL'}, {'from': '0x6df064f04ddfb2bb53da21af9d56701726700145', 'gas': '0x2856b', 'gasUsed': '0x216', 'to': '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', 'input': '0x70a082310000000000000000000000006df064f04ddfb2bb53da21af9d56701726700145', 'output': '0x000000000000000000000000000000000000000000000002f18f3353abca8a6e', 'type': 'STATICCALL'}], 'value': '0x0', 'type': 'CALL'}, {'from': '0x1f2f10d1c40777ae1da742455c65828ff36df387', 'gas': '0x239c2', 'gasUsed': '0x99d8', 'to': '0x61113d7e6c2e6c1f0a9f2f313cf24c830bc325e1', 'input': '0xa9059cbb0000000000000000000000002697cc8ebd4774db94747c8b4988a1aa41e12de90000000000000000000000000000000000000000000000000660031300000000', 'output': '0x0000000000000000000000000000000000000000000000000000000000000001', 'value': '0x0', 'type': 'CALL'}, {'from': '0x1f2f10d1c40777ae1da742455c65828ff36df387', 'gas': '0x1980f', 'gasUsed': '0xa63e', 'to': '0x2697cc8ebd4774db94747c8b4988a1aa41e12de9', 'input': '0x022c0d9f00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000070a8c1930000000000000000000000000000001f2f10d1c40777ae1da742455c65828ff36df38700000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000', 'calls': [{'from': '0x2697cc8ebd4774db94747c8b4988a1aa41e12de9', 'gas': '0x1600f', 'gasUsed': '0x1f7e', 'to': '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', 'input': '0xa9059cbb0000000000000000000000001f2f10d1c40777ae1da742455c65828ff36df3870000000000000000000000000000000000000000000000000070a8c193000000', 'output': '0x0000000000000000000000000000000000000000000000000000000000000001', 'value': '0x0', 'type': 'CALL'}, {'from': '0x2697cc8ebd4774db94747c8b4988a1aa41e12de9', 'gas': '0x13eb5', 'gasUsed': '0x27f', 'to': '0x61113d7e6c2e6c1f0a9f2f313cf24c830bc325e1', 'input': '0x70a082310000000000000000000000002697cc8ebd4774db94747c8b4988a1aa41e12de9', 'output': '0x000000000000000000000000000000000000000000000004d700a982c6797aa7', 'type': 'STATICCALL'}, {'from': '0x2697cc8ebd4774db94747c8b4988a1aa41e12de9', 'gas': '0x13aab', 'gasUsed': '0x216', 'to': '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', 'input': '0x70a082310000000000000000000000002697cc8ebd4774db94747c8b4988a1aa41e12de9', 'output': '0x00000000000000000000000000000000000000000000000055586c371f4194cb', 'type': 'STATICCALL'}], 'value': '0x0', 'type': 'CALL'}], 'value': '0x493f3db93', 'type': 'CALL'}}
Which indicates gasUsed 172954 (0x2a39a)
Actual gasUsed is 169454
Backtrace
[backtrace]