@@ -391,11 +391,11 @@ export class VerkleAccessWitness implements VerkleAccessWitnessInterface {
391
391
}
392
392
393
393
export const generateExecutionWitness = async (
394
- stateManager : StatefulVerkleStateManager | StatelessVerkleStateManager ,
394
+ stateManager : StatefulVerkleStateManager ,
395
395
accessWitness : VerkleAccessWitness ,
396
396
parentStateRoot : Uint8Array ,
397
397
) => {
398
- const trie = ( stateManager as StatefulVerkleStateManager ) [ '_trie' ] as VerkleTree
398
+ const trie = stateManager [ '_trie' ] as VerkleTree
399
399
const postStateRoot = await stateManager . getStateRoot ( )
400
400
const ew : VerkleExecutionWitness = {
401
401
stateDiff : [ ] ,
@@ -419,27 +419,27 @@ export const generateExecutionWitness = async (
419
419
trie . root ( parentStateRoot )
420
420
const suffixes = accessedSuffixes . get ( stem )
421
421
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 )
423
423
trie . root ( postStateRoot )
424
- const newValues = await trie . get ( hexToBytes ( stem ) , accessedSuffixes . get ( stem ) ! )
424
+ const newValues = await trie . get ( hexToBytes ( stem ) , suffixes )
425
425
const stemStateDiff = [ ]
426
426
for ( let x = 0 ; x < suffixes . length ; x ++ ) {
427
427
// skip if both are the same
428
+ const currentValue = currentValues [ x ]
429
+ const newValue = newValues [ x ]
428
430
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 )
432
434
)
433
435
continue
434
436
stemStateDiff . push ( {
435
437
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 ,
438
440
} )
439
441
}
440
442
ew . stateDiff . push ( { stem, suffixDiffs : stemStateDiff } )
441
443
}
442
444
return ew
443
445
}
444
-
445
- const notNullish = ( value : any ) => value !== null && value !== undefined
0 commit comments