-
Notifications
You must be signed in to change notification settings - Fork 94
Create a binary version of hex_patricia_hashed - bin_patricia_hashes #288
Comments
Finished implementation of bin patricia trie. Goals of that implementation are following:
First issue were resolved simply by using same hash approach as used in go-eth implementation . That approach uses node paths (here and after node path is a prefix you need to follow from root to that node) as well as node values, which requires more hash re-evaluations on insertion. E.g. in case when we insert new node which splits existing node path - we should re-evaluate all hashes from that node to it's leaves, then re-evaluate hashes for all parental nodes up to the root. IMO, that approach is discussable, but for now, we use it. Second issue required a bit more complex approach. To produce artifacts, aggregator uses binary branch updates, rewrites them on the fly (replacing hashed keys with stored
During insertion i do not update any hashes, they should be evaluated after Next, hex branch updates with same prefix could be merged with each other, for binary trie i decided instead of merge just use new version for provided prefix. That implementation currently does not support:
|
My humble test on
Met an issue with decompressor (out out bound error) both on hex\bin impelmentation, so decided to rebase branch on erigon devel and erigon-lib main branches. After update, hex commitment seems to proceed correctly, while bin implementation seems quite incorrectly performing valTransform:
|
hex_patricia_hashed
in thecommitment
package is the implementation of the commitment that is currently used in Ethereum - Hexadecimal Patricia Merkle tree with pre-hashes keys.hex
means that the Merkle tree is hexadecimal (rather than binary), i.e. each node has up to 16 childrenpatricia
means it follows PATRICIA design (Practical Algorithm to Retrieve Information Coded in Alphanumeric). Notable feature is compressing the runs of nodes having just 1 child, into a single node (extension and leaf nodes).hashed
means that state keys are not directly used as paths in the tree (as it would be in a conventional radix tree), but they are first pre-processed by Keccak hash function, to resist the creation of specific structures of node to trigger worst-case performances of radix trees.We need to create a variant of this called
bin_patricia_hashed
, with difference that instead of 16, any node may have up to 2 children. This also means that instead of using 4 bits of the hashed key per level of the tree, we need to use 1 bit per level.Integrating this into prototype and running two variants alongside each other, would give us information about the overhead of binary variant in terms of number of nodes, and consequently, size of commitment files.
The text was updated successfully, but these errors were encountered: