core/rawdb, trie: improve db APIs for accessing trie nodes #29362
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.
This pull request does a few things:
HasAccountTrieNode
andHasStorageTrieNode
APIs:these APIs were used to determine if the node with provided path and hash is existent in the disk or not. If the database entry is existent but with a different hash, it will also return false
ExistsAccountTrieNode
toHasAccountTrieNode
ExistsStorageTrieNode
toHasStorageTrieNode
ReadAccountTrieNode
andReadStorageTrieNode
to only return the blob (no hashing)sha3.NewLegacyKeccak256().(crypto.KeccakState)
withcrypto.NewKeccakState()
as they are equivalentThe reason for this change is that the current code uses keccak256 as the default method to compute the node hash (alternatively referred to as the unique ID of the node). While this method is suitable for merkle tree, but the approach in verkle tree is totally different.
Given that verkle tree will be integrated and the same set of database APIs will be used for verkle, it is necessary to untie the node hash method from the APIs. Callers should then be responsible for applying the respective method themselves.