-
Notifications
You must be signed in to change notification settings - Fork 20.1k
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
JS tracer log.memory
object does not handle uninitialized memory correctly
#25169
Comments
Yes there was a change of behaviour as of this PR: #24867 where the tracer now reports memory pre-expansion. This was done for consistency reasons. Everything else the tracer emitted was for pre-opcode-execution and memory expansion. I also noticed recently this causes the Have you considered using the |
This is still technically a bug, because the bytes are defined to be 0 even before they are read/written by the EVM, right? If we don't want to modify the actual buffer, the tracer hook can just pad 0s? |
@holiman What do you say? on the one hand we have memory pre-allocation, and on the other getting a out-of-bounds slice of memory panics. My gut says padding memory in the tracer with zeros might hide user mistakes? |
I think the consensus was to allow OOB accesses (within some limits, e.g. 1MB) and pad it with zeroes. It's the simplest and is consistent with how EVM initializes memory. |
System information
Geth version:
1.10.19-stable
OS & Version: Windows/Linux/OSX
Expected behaviour
In
debug_traceTransaction
, with a custom JavaScript tracer, accessinglog.memory.slice()
on uninitialized memory should return zero'd bytes.Actual behaviour
There is an error
Tracer access out of bound memory
from https://sourcegraph.com/github.com/ethereum/go-ethereum/-/blob/eth/tracers/js/goja.go?L453.Some smart contracts make CALLs pointing to uninitialized (0) memory, but geth will not expand the memory buffer until after the CALL is executed. But the tracer needs to access the memory before the CALL, in order to extract input data (particularly in case the CALL eventually fails).
Steps to reproduce the behaviour
Here is a mainnet transaction that refers to unininitalized memory for a CALL's input data: https://etherscan.io/tx/0x65546ff3a5ff18b06226d1f1af4f9386d9dfd8a0e37afd1871ffa73a863bbd58
To reproduce, use the following simple tracer:
Result on erigon:
Result on geth:
The text was updated successfully, but these errors were encountered: