ethereum / go-verkle

A go implementation of Verkle trees
The Unlicense
209 stars 63 forks source link

add Getter that bypasses internal nodes #442

Open gballet opened 1 month ago

gballet commented 1 month ago

Since verkle uses the path-based storage, it is possible to read the value of a leaf directly. We only need to read the intermediate nodes for updating the commitments... which can be done by a prefetcher.

This might not be useful in most cases as the snapshot is used, but there are several cases where this can make a difference:

jsign commented 2 weeks ago

I am leaving here a summary of some side-channel discussion about this.

The way PBSS works is that each node in the tree has a deterministic key depending on where it lives in the tree. If a LeafNode has stem 0xAABBCCDDEE... then the key in the db could be 0xAA, 0xAABB, 0xAABBCC, or similar depending on the depth of its depth in the tree.

This means that at the API level, we can't fetch a leaf node directly without the client providing more information about the node's depth, which doesn't sound viable.

A potential option is that the PBSS key for a LeafNode is the full stem, which:

If reading a leaf node directly is helpful, as mentioned for FILL_COST, or when snapshots aren't available, we probably need to benchmark the mentioned options (or explore others).