Skip to content
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

internal/ethapi: fix prev hashes in eth_simulate #31122

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

s1na
Copy link
Contributor

@s1na s1na commented Feb 3, 2025

Shout-out to @Gabriel-Trintinalia for discovering this issue. The gist of it as follows:

When processing a block, we should provide the parent block as well as the last 256 block hashes. Some of these parents data (specifically the hash) was incorrect because even though during the processing of the parent block we have updated the header, that header was not updating the TransactionsRoot and ReceiptsRoot fields (types.NewBlock makes a new copy of the header and changes it only on that instance).

@s1na s1na requested review from fjl and lightclient as code owners February 3, 2025 13:42
Copy link
Member

@lightclient lightclient left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a test here would be useful as the issue is not that obvious. It seems like you could get away solving this without simBlockResult?

internal/ethapi/simulate_test.go Outdated Show resolved Hide resolved
@@ -73,6 +73,19 @@ func (r *simCallResult) MarshalJSON() ([]byte, error) {
return json.Marshal((*callResultAlias)(r))
}

// simBlockResult is the result of a simulated block.
type simBlockResult struct {
sim *simulator
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feels weird to me to include a pointer to the simulator when you really only need the config + fullTx. But even still, I don't see why you need to return these at all. execute is a method on sim so the caller will always have sim around to do the RPCMarshalBlock correctly.

// simBlockResult is the result of a simulated block.
type simBlockResult struct {
sim *simulator
Block *types.Block
Copy link
Member

@MariusVanDerWijden MariusVanDerWijden Feb 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering if storing the block here will increase the memory usage of eth simulate over a longer period of blocks significantly

@lightclient lightclient self-assigned this Feb 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants