core/state, trie: improve parallelization of account and storage trie hashing #33022
+125
−49
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.


closes #32922
This PR makes a modification so that the value of a leaf trie node is not needed at insertion: a resolver (function which returns the leaf value) is provided at insertion, and the resolver is invoked later when the value is needed (e.g. hashing or value retrieval). This enables the account and storage tries to be hashed simultaneously: if an account's storage trie is still being hashed, an attempt to hash that leaf node in the account trie will block until the value can be resolved.
It has an additional benefit for BAL:
For any account that is modified, only the mutated fields will appear in the access list. To update the account in the trie, all state account fields must be written. Parallelizing the fetching of the intermediate nodes from the trie and the fetching of prestate values from the snapshot will be useful for speeding up the update of the state trie.
The changes in this PR lay the initial groundwork that is required to implement this optimization.
It's WIP: