Skip to content

half-path-based on binary Merkle tree#6

Open
ping-ke wants to merge 1 commit intoqizhou:mainfrom
ping-ke:halfpath
Open

half-path-based on binary Merkle tree#6
ping-ke wants to merge 1 commit intoqizhou:mainfrom
ping-ke:halfpath

Conversation

@ping-ke
Copy link
Copy Markdown

@ping-ke ping-ke commented Jan 6, 2026

Issue: https://github.com/QuarkChain/TenGPS-research/issues/13

The half path based format is implemetn at
https://github.com/NethermindEth/nethermind/blob/master/src/Nethermind/Nethermind.Trie/NodeStorage.cs#L37

For state (total 42 byte) 
+--------------+------------------+------------------+--------------+
| section byte | 8 byte from path | path length byte | 32 byte hash |
+--------------+------------------+------------------+--------------+
For storage (total 74 byte)
+--------------+---------------------+------------------+------------------+--------------+
| section byte | 32 byte from address | 8 byte from path | path length byte | 32 byte hash |
+--------------+---------------------+------------------+------------------+--------------+

The section byte is:
- 0 if state and path length is <= 5.
- 1 if state and path length is > 5.
- 2 if storage.

To simplify the implementation, this example only retains three fields:
8 bytes from path, path length in bytes, and 32 bytes hash.

The '8 byte from path' is the first 8 bytes of the path
path.Path.BytesAsSpan[..8].CopyTo(pathSpan[1..]);
We use the top depth bits of the key here.

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.

1 participant