trie: avoid rlp-encoding when trie hash is already available#20461
Closed
holiman wants to merge 2 commits intoethereum:masterfrom
Closed
trie: avoid rlp-encoding when trie hash is already available#20461holiman wants to merge 2 commits intoethereum:masterfrom
holiman wants to merge 2 commits intoethereum:masterfrom
Conversation
holiman
commented
Dec 17, 2019
| if len(h.tmp) < 32 && !force { | ||
| return n, nil // Nodes smaller than 32 bytes are stored inside their parent | ||
| } | ||
| // Larger nodes are replaced by their hash and stored in the database. |
Contributor
Author
There was a problem hiding this comment.
this doesn't work, the code below assumes h.tmp contains the rlp-encoding of the node :(
Contributor
Author
There was a problem hiding this comment.
But actually, the db.insert only cares about the size (for tracking), not the actual data
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.
I'm not sure this is correct, of if I'm missing some quirky edgecase, but what this PR does, is attempt to improve on the scenario where we first
Hashthe trie and laterCommitit.That typically happens on every block, since we call
IntermediateStateRootafter applying the block rewards, and that doesHashinternally. We need to hash it to get the state root, and we need that in order to validate against the header.If everything checks out, we then
Commit. Now, theCommitis clever enough not to re-hash everything since it already has the hashes cached for all nodes. However, we do rlp-encode everything the second time around, which this PR skips if we have thehashcached.Turns out that saves us
20%processing time: