Skip to content

Commit 4454abd

Browse files
committed
Fix logic in building suffix diffs
1 parent b92efed commit 4454abd

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

packages/evm/src/verkleAccessWitness.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -417,22 +417,24 @@ export const generateExecutionWitness = async (
417417
// Get values
418418
for (const stem of accessedSuffixes.keys()) {
419419
trie.root(parentStateRoot)
420+
const suffixes = accessedSuffixes.get(stem)
421+
if (suffixes === undefined || suffixes.length === 0) continue
420422
const currentValues = await trie.get(hexToBytes(stem), accessedSuffixes.get(stem)!)
421423
trie.root(postStateRoot)
422424
const newValues = await trie.get(hexToBytes(stem), accessedSuffixes.get(stem)!)
423425
const stemStateDiff = []
424-
for (const suffix of accessedSuffixes.get(stem)!) {
426+
for (let x = 0; x < suffixes.length; x++) {
425427
// skip if both are the same
426428
if (
427-
notNullish(currentValues[suffix]) &&
428-
notNullish(newValues[suffix]) &&
429-
equalsBytes(currentValues[suffix]!, newValues[suffix]!)
429+
notNullish(currentValues[x]) &&
430+
notNullish(newValues[x]) &&
431+
equalsBytes(currentValues[x]!, newValues[x]!)
430432
)
431433
continue
432434
stemStateDiff.push({
433-
suffix,
434-
currentValue: currentValues[suffix] ? bytesToHex(currentValues[suffix]!) : null,
435-
newValue: newValues[suffix] ? bytesToHex(newValues[suffix]!) : null,
435+
suffix: suffixes[x],
436+
currentValue: currentValues[x] ? bytesToHex(currentValues[x]!) : null,
437+
newValue: newValues[x] ? bytesToHex(newValues[x]!) : null,
436438
})
437439
}
438440
ew.stateDiff.push({ stem, suffixDiffs: stemStateDiff })

0 commit comments

Comments
 (0)