Use uint64 for Page valid bitlist + Reuse hasher and buffers#14606
Merged
Inphi merged 25 commits intoethereum-optimism:developfrom Apr 30, 2025
Merged
Use uint64 for Page valid bitlist + Reuse hasher and buffers#14606Inphi merged 25 commits intoethereum-optimism:developfrom
Inphi merged 25 commits intoethereum-optimism:developfrom
Conversation
Contributor
|
/ci authorize 5b202da |
ajsutton
reviewed
Mar 4, 2025
Contributor
ajsutton
left a comment
There was a problem hiding this comment.
I think this looks good generally. Would be good to add some tests around the pooling and I'll see if I can get a second opinion from @mbaxter on the change from bools to bit mask as I'm notoriously bad at that kind of bit shift logic.
mbaxter
reviewed
Mar 4, 2025
Contributor
mbaxter
left a comment
There was a problem hiding this comment.
Generally looks good to me, though I did have to stare at the bit math 😅
Left a few suggestions. One concern is that it looks like we're silently assuming the
PageSize value is fixed at 4096.
Contributor
|
This pr has been automatically marked as stale and will be closed in 5 days if no updates |
Contributor
|
/ci authorize 633c322 |
Inphi
approved these changes
Apr 30, 2025
Contributor
Inphi
left a comment
There was a problem hiding this comment.
Sorry for the precambrian-late review. Changes look good to me. Thanks!
Merged
via the queue into
ethereum-optimism:develop
with commit Apr 30, 2025
ae6bb61
51 checks passed
iquidus
pushed a commit
to Layr-Labs/optimism
that referenced
this pull request
Jul 24, 2025
…m-optimism#14606) * Abstract the Merkle representation * Implement asterisc's MPT * migrate tests for mpt * migrate tests for mpt * copied benchmarks from asterisc * fix failed merge * Avoid pagelookup twice during setword invalidation * fix state json codec test * fix for singlethread too * fix op-challenger test * Remove MPT implementation * address comments * fix benchmark * Use uint64 and also reuse hasher and buffers * rename and fix lint * getLowHighMask method as suggested * compile time assertion of pagesize * make HashPair use HashPairNodes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
There is currently a lot of heap allocation during Merklization and just keeping track of intermediate nodes. By reclaiming and reusing buffers when marking the tree's merkle cache as well as reusing the sha256 hasher, we can save on a lot of allocations.
In addition, in CachedPage, a bitlist is managed to keep track of whether intermediate nodes are valid or not. By using integers instead of an array of bools, we can do some bit magic to branchlessly maintain this bitlist. Also by doing this, we also avoid the Go runtime's bounds checking every time we mark a bit valid or not.
Tests
Additional context
Metadata