Skip to content

Commit 2251c2c

Browse files
committed
Address feedback
1 parent b1380bc commit 2251c2c

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

packages/evm/src/verkleAccessWitness.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -391,11 +391,11 @@ export class VerkleAccessWitness implements VerkleAccessWitnessInterface {
391391
}
392392

393393
export const generateExecutionWitness = async (
394-
stateManager: StatefulVerkleStateManager | StatelessVerkleStateManager,
394+
stateManager: StatefulVerkleStateManager,
395395
accessWitness: VerkleAccessWitness,
396396
parentStateRoot: Uint8Array,
397397
) => {
398-
const trie = (stateManager as StatefulVerkleStateManager)['_trie'] as VerkleTree
398+
const trie = stateManager['_trie'] as VerkleTree
399399
const postStateRoot = await stateManager.getStateRoot()
400400
const ew: VerkleExecutionWitness = {
401401
stateDiff: [],
@@ -419,27 +419,27 @@ export const generateExecutionWitness = async (
419419
trie.root(parentStateRoot)
420420
const suffixes = accessedSuffixes.get(stem)
421421
if (suffixes === undefined || suffixes.length === 0) continue
422-
const currentValues = await trie.get(hexToBytes(stem), accessedSuffixes.get(stem)!)
422+
const currentValues = await trie.get(hexToBytes(stem), suffixes)
423423
trie.root(postStateRoot)
424-
const newValues = await trie.get(hexToBytes(stem), accessedSuffixes.get(stem)!)
424+
const newValues = await trie.get(hexToBytes(stem), suffixes)
425425
const stemStateDiff = []
426426
for (let x = 0; x < suffixes.length; x++) {
427427
// skip if both are the same
428+
const currentValue = currentValues[x]
429+
const newValue = newValues[x]
428430
if (
429-
notNullish(currentValues[x]) &&
430-
notNullish(newValues[x]) &&
431-
equalsBytes(currentValues[x]!, newValues[x]!)
431+
currentValue instanceof Uint8Array &&
432+
newValue instanceof Uint8Array &&
433+
equalsBytes(currentValue, newValue)
432434
)
433435
continue
434436
stemStateDiff.push({
435437
suffix: suffixes[x],
436-
currentValue: currentValues[x] ? bytesToHex(currentValues[x]!) : null,
437-
newValue: newValues[x] ? bytesToHex(newValues[x]!) : null,
438+
currentValue: currentValue ? bytesToHex(currentValue) : null,
439+
newValue: newValue ? bytesToHex(newValue) : null,
438440
})
439441
}
440442
ew.stateDiff.push({ stem, suffixDiffs: stemStateDiff })
441443
}
442444
return ew
443445
}
444-
445-
const notNullish = (value: any) => value !== null && value !== undefined

0 commit comments

Comments
 (0)