-
Notifications
You must be signed in to change notification settings - Fork 20.5k
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
base: master
Are you sure you want to change the base?
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.
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
?
@@ -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 |
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.
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 |
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.
I'm wondering if storing the block here will increase the memory usage of eth simulate over a longer period of blocks significantly
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).