-
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
core/tracing: add GetCodeHash to StateDB #30784
core/tracing: add GetCodeHash to StateDB #30784
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.
SGTM
Again, is there a practical usecase which drives this, or is it just about symmetry? Do you have a tracer which does a lot of hashing and suffers from performance bottlenecks? |
Yes, there is a practical use case for Currently, hashing every new code encountered during block execution increases tracing time by a factor of 5 and overall block execution time by a factor of 2. This performance bottleneck is significant, and GetCodeHash provides a direct way to address it. |
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.
LGTM
@s1na ?
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.
LGTM
This PR extends the tracing.StateDB interface by adding a GetCodeHash function.
This PR extends tracing.StateDB by adding a GetCodeHash function.
Motivation
Currently, tracing.StateDB supports 2 out of 3 basic account data getters (GetBalance and GetNonce). Adding GetCodeHash completes the set, making it 3/3.
This addition significantly improves the performance of tracers that need to compute code hashes. Previously, the only available option was to use
crypto.Keccak256Hash(t.stateDB.GetCode(addr))
, which is less efficient.