Open Otto-AA opened 1 month ago
FYI, Geth has the same behaviour (see mentioned issue above).
Another minimal example:
We use the state overrides to set slot 0x00 to 0x1111 and then execute the following code:
PUSH4 0x12345678
PUSH1 0x00
SSTORE
This should create gas costs 5000 (2100 + 2900) for the SSTORE:
However, it outputs the gas costs 2200 (2100 + 100) for the SSTORE:
My hunch is that the state overrides result in the slot being marked as changed, thus in the gas costs calculation it thinks it was already previously changed.
Here is the request to reproduce this example (| python3 -m json.tool
is optional for legibility):
curl https://eth-pokt.nodies.app/ \
-X POST \
-H "Content-Type: application/json" \
--data '{
"method": "debug_traceCall",
"params": [
{
"from": null,
"to": "0x1234567812345678123456781234567812345678"
},
"latest",
{
"stateOverrides": {
"0x1234567812345678123456781234567812345678": {
"code": "0x6312345678600055",
"stateDiff": {
"0x0000000000000000000000000000000000000000000000000000000000000000": "0x0000000000000000000000000000000000000000000000000000000000001111"
}
}
}
}
],
"id":1,
"jsonrpc":"2.0"
}' | python3 -m json.tool
And on a side note, I'm not sure if Geth has the same behaviour (see their issue, it was probably my mistake). So it may be specific to Erigon.
System information
Erigon version:
cast client -r https://eth-pokt.nodies.app/
-> erigon/2.59.3/linux-amd64/go1.21.5I don't have access to this instance.
Expected behaviour
Running
debug_traceTransaction
should produce the samegasCost
for each instruction, as runningdebug_traceCall
, if we provide the prestate as stateOverrides.Actual behaviour
debug_traceCall
shows a lowergasCost
for addresses, that were modified by the stateOverrides.Note, that the
prestateTracer
results fordebug_traceTransaction
anddebug_traceCall
were equal, showing that they really operated on the same prestate.Steps to reproduce the behaviour
I've created a demo script (repro.py.txt). You will need to modify the provider variable inside it, the rest should work. If you uncomment a part of the code, you can also let it output the traces as JSON files for comparison with git.
For the transaction 0x0947c75d6f6a65d121f214910ab23826226c414b63af37a54a647cf26201285c, we create vmTraces for both scenarios and compare them:
debug_traceTransaction
and the prestateTracerdebug_traceTransaction
debug_traceCall
with prestate as stateOverrides and the same blockNumberBacktrace
Traces for comparison: