Skip to content

Commit ae81ce0

Browse files
Illustrate the resulting Merkle-Patricia tree: (#1001)
Illustrate the structure of an MPT that is formed when the entries, produced by this method, are added to the ProofMap.
1 parent 705a1ab commit ae81ce0

2 files changed

Lines changed: 26 additions & 1 deletion

File tree

exonum-java-binding/core/checkstyle-suppressions.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
<!-- Do not require Javadoc for native adapters -->
1616
<suppress files="service/adapters.+.java" checks="JavadocMethod"/>
1717

18+
<suppress files="ProofMapIndexProxyIntegrationTest\.java"
19+
checks="Javadoc.*"/>
20+
1821
<!-- Allow `aBlock` name -->
1922
<suppress files="BlockchainIntegrationTest\.java" checks="MethodName"/>
2023
<suppress files="BlockTest\.java" checks="MethodName"/>

exonum-java-binding/core/src/test/java/com/exonum/binding/core/storage/indices/ProofMapIndexProxyIntegrationTest.java

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -861,7 +861,11 @@ private List<MapEntry<HashCode, String>> createMapEntries(Stream<HashCode> proof
861861
}
862862

863863
/**
864-
* Keys:
864+
* Creates 257 entries for a ProofMap that, when added to it, will make the underlying
865+
* Merkle-Patricia tree of the maximum height (256). Leaf nodes will be at depths
866+
* ranging from 1 to 256.
867+
*
868+
* Bits of 32-byte keys:
865869
* 00…0000
866870
* 100…000
867871
* 0100…00
@@ -870,6 +874,24 @@ private List<MapEntry<HashCode, String>> createMapEntries(Stream<HashCode> proof
870874
* 00…0100
871875
* 00…0010
872876
* 00…0001.
877+
*
878+
* When all the keys above are added to the ProofMap, the underlying Merkle-Patricia tree
879+
* has the following structure (only key bits in leaf nodes are shown; the intermediate
880+
* nodes are shown as 'o' character):
881+
*
882+
* o — the root node
883+
* / \
884+
* o 100…000 — a leaf node
885+
* / \
886+
* o 0100…00
887+
* / \
888+
* o 00100…0
889+
* / \
890+
* … 00010…0
891+
* /
892+
* o — an intermediate node with key prefix 00…0 of size 255 bits.
893+
* / \
894+
* 00…0000 00…0001 — leaf nodes at depth 256 with a common prefix of 255 bits.
873895
*/
874896
private static List<MapEntry<HashCode, String>> createEntriesForRightLeaningMpt() {
875897
int numKeyBits = Byte.SIZE * PROOF_MAP_KEY_SIZE;

0 commit comments

Comments
 (0)