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

Commit 85cfe2d

Browse files
committed
fix: drifted pos cal.
1 parent c46f309 commit 85cfe2d

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

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

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -203,12 +203,15 @@ func getNibbles(leafKeyRow []byte) []byte {
203203
nibbles = append(nibbles, leafKeyRow[1]-16)
204204
}
205205
} else {
206-
keyLen := int(leafKeyRow[2] - 128)
207-
if (leafKeyRow[3] != 32) && (leafKeyRow[3] != 0) { // second term is for extension node
208-
if leafKeyRow[3] < 32 { // extension node
209-
nibbles = append(nibbles, leafKeyRow[3]-16)
206+
// [248 202 48 184 199 248 197 128 131 4 147 224 98 148 0 ...]
207+
// `202` (leafKeyRow[1]) is the length of the payload
208+
// `48` (leafKeyRow[2]) is the first byte of the payload
209+
keyLen := int(leafKeyRow[1] - 128)
210+
if (leafKeyRow[2] != 32) && (leafKeyRow[2] != 0) { // second term is for extension node
211+
if leafKeyRow[2] < 32 { // extension node
212+
nibbles = append(nibbles, leafKeyRow[2]-16)
210213
} else { // leaf
211-
nibbles = append(nibbles, leafKeyRow[3]-48)
214+
nibbles = append(nibbles, leafKeyRow[2]-48)
212215
}
213216
}
214217
for i := 0; i < keyLen-1; i++ { // -1 because the first byte doesn't have any nibbles

0 commit comments

Comments
 (0)