-
Notifications
You must be signed in to change notification settings - Fork 21.2k
eth/tracers: apply block header overrides correctly #32183
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please address the comment from matt, otherwise lgtm
made the changes matt suggested! |
@shazam8253 forgot to push the new commit? |
Noticed that the parent hash was not being set. The way we do getHash relies on the parentHash to be cached correctly, so setting the parentHash after doing makeHeader fixes the issue.
I noticed that the parent hash was not being set. The way we do getHash relies on the parentHash to be cached correctly, so setting the parentHash after doing makeHeader fixes the issue. I have also added a seperate test as well. |
Fixes ethereum#32175. This fixes the scenario where the blockhash opcode would return 0x0 during RPC simulations when using BlockOverrides with a future block number. The root cause was that BlockOverrides.Apply() only modified the vm.BlockContext, but GetHashFn() depends on the actual types.Header.Number to resolve valid historical block hashes. This caused a mismatch and resulted in incorrect behavior during trace and call simulations. --------- Co-authored-by: shantichanal <[email protected]> Co-authored-by: lightclient <[email protected]>
Fixes #32175.
This fixes the scenario where the blockhash opcode would return 0x0 during RPC simulations when using BlockOverrides with a future block number. The root cause was that BlockOverrides.Apply() only modified the vm.BlockContext, but GetHashFn() depends on the actual types.Header.Number to resolve valid historical block hashes. This caused a mismatch and resulted in incorrect behavior during trace and call simulations.
Changes:
Added a new ApplyHeader method to BlockOverrides, which mutates the *types.Header with overridden fields. Updated the RPC simulation/tracing paths to apply header overrides directly to the Header object before creating the EVM block context. This makes sure that there is consistency between BlockContext.BlockNumber and Header.Number to allow GetHashFn() to function correctly in simulations.
Tests



I reproduced the error in a dev chain on geth and ran the updated code against the issue to ensure correctness.