From 73c7f5fbbe533e669b1eaea2dd2752713c35731c Mon Sep 17 00:00:00 2001 From: Hoon <48665813+sh-cha@users.noreply.github.com> Date: Tue, 10 Dec 2024 14:00:39 +0900 Subject: [PATCH] Update merkle/db.go Co-authored-by: beer-1 <147697694+beer-1@users.noreply.github.com> --- merkle/db.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/merkle/db.go b/merkle/db.go index 61f7d52..79a2351 100644 --- a/merkle/db.go +++ b/merkle/db.go @@ -115,6 +115,8 @@ func GetProofs(db types.DB, leafIndex uint64) (proofs [][]byte, treeIndex uint64 height := uint8(0) localNodeIndex := leafIndex - treeInfo.StartLeafIndex for height < treeInfo.TreeHeight { + // In `FinalizeWorkingTree`, we ensure that the leaf count of the tree is always a power of two by filling the leaves as needed. + // This ensures that there is always a sibling for each leaf node. siblingIndex := localNodeIndex ^ 1 // flip the last bit to find the sibling sibling, err := GetNodeBytes(db, treeInfo.TreeIndex, height, siblingIndex) if err != nil {