Skip to content

test(grey-merkle): add proptests for trie root properties#823

Open
wangzishuai1987 wants to merge 2 commits into
jarchain:masterfrom
wangzishuai1987:feat/merkle-trie-proptest
Open

test(grey-merkle): add proptests for trie root properties#823
wangzishuai1987 wants to merge 2 commits into
jarchain:masterfrom
wangzishuai1987:feat/merkle-trie-proptest

Conversation

@wangzishuai1987
Copy link
Copy Markdown

Summary

Adds property-based tests for the binary Patricia Merkle trie (Appendix D.2):

  • Determinism: same KV set always produces the same root
  • Order independence: shuffling KVs yields the same root
  • Sensitivity: root changes when any value is modified, a key is added, or a key is removed
  • Non-zero: root is never Hash::ZERO for non-empty tries
  • Single-entry correctness: root matches the corresponding leaf node hash
  • Encoding determinism: TrieNode::encode() produces identical bytes on repeated calls

Refs: #229 (Merkle tree properties — "Root changes when any leaf changes")

Add property-based tests for the binary Patricia Merkle trie:
- Root is deterministic (same KVs → same root)
- Root is order-independent (shuffled KVs → same root)
- Root changes when any value is modified
- Root changes when a key is added or removed
- Root is non-zero for non-empty trie
- Single-entry trie matches corresponding leaf node hash
- TrieNode encoding is deterministic

Refs: jarchain#229
@github-actions
Copy link
Copy Markdown
Contributor

Genesis Review

Comparison targets:

How to review

Post a comment with the following format (rank from best to worst):

/review
difficulty: <commit1>, <commit2>, ..., <commitN>, currentPR
novelty: <commit1>, <commit2>, ..., <commitN>, currentPR
design: <commit1>, <commit2>, ..., <commitN>, currentPR
verdict: merge

Use the short commit hashes above and currentPR for this PR.
Each line ranks all comparison targets + this PR from best to worst.

To meta-review another reviewer's comment, react with 👍 or 👎.

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