From e3e83b7e71c7d9f6a34b9d7b407b72ca3eda9b4e Mon Sep 17 00:00:00 2001 From: Roman Krasiuk Date: Thu, 17 Oct 2024 10:03:25 +0200 Subject: [PATCH] docs(trie): revealed sparse trie invariants (#11825) --- crates/trie/sparse/src/trie.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/crates/trie/sparse/src/trie.rs b/crates/trie/sparse/src/trie.rs index 2edaaf76b2..d8f4280e87 100644 --- a/crates/trie/sparse/src/trie.rs +++ b/crates/trie/sparse/src/trie.rs @@ -69,6 +69,13 @@ impl SparseTrie { } /// The representation of revealed sparse trie. +/// +/// ## Invariants +/// +/// - The root node is always present in `nodes` collection. +/// - Each leaf entry in `nodes` collection must have a corresponding entry in `values` collection. +/// The opposite is also true. +/// - All keys in `values` collection are full leaf paths. #[derive(PartialEq, Eq)] pub struct RevealedSparseTrie { /// All trie nodes.