Skip to content
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

core/rawdb, trie: improve db APIs for accessing trie nodes #29362

Merged
merged 2 commits into from Apr 30, 2024

Conversation

rjl493456442
Copy link
Member

@rjl493456442 rjl493456442 commented Mar 27, 2024

This pull request does a few things:

  • Remove HasAccountTrieNode and HasStorageTrieNode 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

  • Rename ExistsAccountTrieNode to HasAccountTrieNode
  • Rename ExistsStorageTrieNode to HasStorageTrieNode
  • Change ReadAccountTrieNode and ReadStorageTrieNode to only return the blob (no hashing)
  • Replace sha3.NewLegacyKeccak256().(crypto.KeccakState) with crypto.NewKeccakState() as they are equivalent

The 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.

Copy link
Contributor

@holiman holiman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@rjl493456442 rjl493456442 added this to the 1.14.1 milestone Apr 24, 2024
@holiman holiman merged commit 9f96e07 into ethereum:master Apr 30, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants