-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Use uint64 for Page valid bitlist + Reuse hasher and buffers #14606
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
Merged
Merged
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
95c36ef
Abstract the Merkle representation
ec2 86ec0d5
Implement asterisc's MPT
ec2 9058d7e
migrate tests for mpt
ec2 161dc8d
migrate tests for mpt
ec2 c97d345
copied benchmarks from asterisc
ec2 cf19a8a
fix failed merge
ec2 78d5295
Merge branch 'develop' into ec2/mem-abstraction
ec2 68af153
Merge branch 'develop' into ec2/mem-abstraction
ec2 7618e79
Avoid pagelookup twice during setword invalidation
ec2 8d5f0ed
Merge branch 'develop' into ec2/mem-abstraction
ec2 3260de5
fix state json codec test
ec2 28b1b61
fix for singlethread too
ec2 4c4b15c
fix op-challenger test
ec2 8e69dec
Merge branch 'develop' into ec2/mem-abstraction
ec2 f9cece4
Remove MPT implementation
ec2 c4e518f
address comments
ec2 8cc8fe0
fix benchmark
ec2 070f132
Use uint64 and also reuse hasher and buffers
ec2 5b202da
Merge branch 'develop' into ec2/bitlist
ec2 d88de8c
Merge branch 'develop' into ec2/bitlist
ec2 ffb6349
Merge branch 'develop' into ec2/bitlist
ec2 6c9ba77
rename and fix lint
ec2 56851d0
getLowHighMask method as suggested
ec2 a0f00a6
compile time assertion of pagesize
ec2 633c322
make HashPair use HashPairNodes
ec2 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| package memory | ||
|
|
||
| import ( | ||
| "sync" | ||
|
|
||
| "github.com/ethereum/go-ethereum/crypto" | ||
| ) | ||
|
|
||
| // byte32Pool is a sync.Pool for [32]byte slices | ||
| var byte32Pool = sync.Pool{ | ||
| New: func() interface{} { | ||
| var b [32]byte | ||
| return &b // Return a pointer to avoid extra allocations | ||
| }, | ||
| } | ||
|
|
||
| // GetByte32 retrieves a *[32]byte from the pool | ||
| func GetByte32() *[32]byte { | ||
| return byte32Pool.Get().(*[32]byte) | ||
| } | ||
|
|
||
| // ReleaseByte32 returns a *[32]byte to the pool | ||
| func ReleaseByte32(b *[32]byte) { | ||
| // Optional: Zero the array before putting it back | ||
| *b = [32]byte{} | ||
| byte32Pool.Put(b) | ||
| } | ||
|
|
||
| var hashPool = sync.Pool{ | ||
| New: func() interface{} { | ||
| return crypto.NewKeccakState() | ||
| }, | ||
| } | ||
|
|
||
| func GetHasher() crypto.KeccakState { | ||
| return hashPool.Get().(crypto.KeccakState) | ||
| } | ||
|
|
||
| func PutHasher(h crypto.KeccakState) { | ||
| h.Reset() | ||
| hashPool.Put(h) | ||
| } | ||
|
|
||
| func HashPairNodes(out *[32]byte, left, right *[32]byte) { | ||
| h := GetHasher() | ||
| h.Write(left[:]) | ||
| h.Write(right[:]) | ||
| _, _ = h.Read(out[:]) | ||
| PutHasher(h) | ||
| } | ||
|
|
||
| func HashData(out *[32]byte, data ...[]byte) { | ||
| h := GetHasher() | ||
| for _, b := range data { | ||
| h.Write(b) | ||
| } | ||
| _, _ = h.Read(out[:]) | ||
| PutHasher(h) | ||
| } | ||
|
|
||
| func HashPair(left, right [32]byte) (out [32]byte) { | ||
| HashPairNodes(&out, &left, &right) | ||
| //fmt.Printf("0x%x 0x%x -> 0x%x\n", left, right, out) | ||
| return out | ||
| } | ||
|
|
||
| var zeroHashes = func() [256][32]byte { | ||
| // empty parts of the tree are all zero. Precompute the hash of each full-zero range sub-tree level. | ||
| var out [256][32]byte | ||
| for i := 1; i < 256; i++ { | ||
| out[i] = HashPair(out[i-1], out[i-1]) | ||
| } | ||
| return out | ||
| }() | ||
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
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
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.
Uh oh!
There was an error while loading. Please reload this page.