Skip to content
This repository was archived by the owner on Jul 5, 2024. It is now read-only.

Commit 9b0eb3f

Browse files
committed
fix: merged code
1 parent e5c7559 commit 9b0eb3f

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

geth-utils/gethutil/mpt/witness/prepare_witness.go

+11-4
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,14 @@ func convertProofToWitness(
566566
for i := 0; i < upTo; i++ {
567567
if !isBranch(proof1[i]) {
568568
isNonExistingProof := (isAccountProof && nonExistingAccountProof) || (!isAccountProof && nonExistingStorageProof)
569-
areThereNibbles := len(extNibblesS) != 0 || len(extNibblesC) != 0
569+
var curExtNibblesS, curExtNibblesC []byte
570+
if len(extNibblesS) > i {
571+
curExtNibblesS = extNibblesS[i]
572+
}
573+
if len(extNibblesC) > i {
574+
curExtNibblesC = extNibblesC[i]
575+
}
576+
areThereNibbles := len(curExtNibblesS) != 0 || len(curExtNibblesC) != 0
570577
// If i < upTo-1, it means it's not a leaf, so it's an extension node.
571578
// There is no any special relation between isNonExistingProof and isExtension,
572579
// except that in the non-existing proof the extension node can appear in `i == upTo-1`.
@@ -577,7 +584,7 @@ func convertProofToWitness(
577584
if (i != upTo-1) || (areThereNibbles && isNonExistingProof) { // extension node
578585
var numberOfNibbles byte
579586
isExtension = true
580-
numberOfNibbles, extListRlpBytes, extValues = prepareExtensions(extNibblesS[i], proof1[i], proof2[i])
587+
numberOfNibbles, extListRlpBytes, extValues = prepareExtensions(curExtNibblesS, proof1[i], proof2[i])
581588

582589
keyIndex += int(numberOfNibbles)
583590
extensionNodeInd++
@@ -620,10 +627,10 @@ func convertProofToWitness(
620627

621628
var lastExtNibbleS, lastExtNibbleC []byte
622629
if len(extNibblesS) != 0 {
623-
lastExtNibbleS = extNibblesS[len1-1]
630+
lastExtNibbleS = extNibblesS[len(extNibblesS)-1]
624631
}
625632
if len(extNibblesC) != 0 {
626-
lastExtNibbleC = extNibblesC[len2-1]
633+
lastExtNibbleC = extNibblesC[len(extNibblesC)-1]
627634
}
628635

629636
isModifiedExtNode, _, numberOfNibbles, bNode :=

0 commit comments

Comments
 (0)