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

Commit

Permalink
fix: drifted pos cal.
Browse files Browse the repository at this point in the history
  • Loading branch information
KimiWu123 committed Apr 15, 2024
1 parent c46f309 commit 85cfe2d
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions geth-utils/gethutil/mpt/witness/branch.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,12 +203,15 @@ func getNibbles(leafKeyRow []byte) []byte {
nibbles = append(nibbles, leafKeyRow[1]-16)
}
} else {
keyLen := int(leafKeyRow[2] - 128)
if (leafKeyRow[3] != 32) && (leafKeyRow[3] != 0) { // second term is for extension node
if leafKeyRow[3] < 32 { // extension node
nibbles = append(nibbles, leafKeyRow[3]-16)
// [248 202 48 184 199 248 197 128 131 4 147 224 98 148 0 ...]
// `202` (leafKeyRow[1]) is the length of the payload
// `48` (leafKeyRow[2]) is the first byte of the payload
keyLen := int(leafKeyRow[1] - 128)
if (leafKeyRow[2] != 32) && (leafKeyRow[2] != 0) { // second term is for extension node
if leafKeyRow[2] < 32 { // extension node
nibbles = append(nibbles, leafKeyRow[2]-16)
} else { // leaf
nibbles = append(nibbles, leafKeyRow[3]-48)
nibbles = append(nibbles, leafKeyRow[2]-48)
}
}
for i := 0; i < keyLen-1; i++ { // -1 because the first byte doesn't have any nibbles
Expand Down

0 comments on commit 85cfe2d

Please sign in to comment.