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.
Faster root hash
This pr introduces option to use sparse merkle trie implementation for the root hash calculation.
This implementation fetches relevant pieces of the trie into memory making subsequent root hash calculations faster.
On my PC reference implementation takes about 150ms to calculate hash and the new one when everything is prefetched around 5ms.
Fetching proof for data for one uncached account takes about 0.25ms.
There are things to improve in implementation itself but the basic interface for the integration into the builder will be the same.
debug-bench-machine
This PR also redoes debug-bench-machine. Now you need to stop reth node and provide external rpc for it to work.
The reason is that reth has trie only for the last block. Previous implementation used last block to generate changes and it applied that changes to the trie after the last block. Trie would already have these changes but default reth root hash does not care about that discrepancy and it would evaluate anyway, this was used as a hack to benchmark trie even though it would give incorrect results.
Sparse trie implemenation would not work like that because it would detect errors such as removing key that was already removed from the trie.
The benefit of this is that we can actually check correctness of the root hash on historical block.
✅ I have completed the following steps:
make lint
make test