Skip to content

Commit c733370

Browse files
committed
fix: fixed log squashing in kernelless simulations
Use the correct hint to remove logs from squashed notes Co-authored-by: thunkar <gregojquiros@gmail.com>
1 parent caf0b5d commit c733370

File tree

1 file changed

+8
-16
lines changed

1 file changed

+8
-16
lines changed

yarn-project/pxe/src/contract_function_simulator/contract_function_simulator.ts

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ import {
5959
type PrivateExecutionStep,
6060
type PrivateKernelExecutionProofOutput,
6161
PrivateKernelTailCircuitPublicInputs,
62+
PrivateLogData,
6263
PrivateToPublicAccumulatedData,
6364
PrivateToRollupAccumulatedData,
6465
PublicCallRequest,
@@ -413,7 +414,7 @@ export async function generateSimulatedProvingResult(
413414
node: AztecNode,
414415
minRevertibleSideEffectCounterOverride?: number,
415416
): Promise<PrivateKernelExecutionProofOutput<PrivateKernelTailCircuitPublicInputs>> {
416-
const taggedPrivateLogs: OrderedSideEffect<PrivateLog>[] = [];
417+
const taggedPrivateLogs: OrderedSideEffect<PrivateLogData>[] = [];
417418
const l2ToL1Messages: OrderedSideEffect<ScopedL2ToL1Message>[] = [];
418419
const contractClassLogsHashes: OrderedSideEffect<ScopedLogHash>[] = [];
419420
const publicCallRequests: OrderedSideEffect<PublicCallRequest>[] = [];
@@ -449,9 +450,8 @@ export async function generateSimulatedProvingResult(
449450
taggedPrivateLogs.push(
450451
...(await Promise.all(
451452
execution.publicInputs.privateLogs.getActiveItems().map(async metadata => {
452-
const log = PrivateLog.fromFields(metadata.log.toFields());
453-
log.fields[0] = await computeSiloedPrivateLogFirstField(contractAddress, log.fields[0]);
454-
return new OrderedSideEffect(log, metadata.counter);
453+
metadata.log.fields[0] = await computeSiloedPrivateLogFirstField(contractAddress, metadata.log.fields[0]);
454+
return new OrderedSideEffect(metadata, metadata.counter);
455455
}),
456456
)),
457457
);
@@ -672,7 +672,7 @@ export async function generateSimulatedProvingResult(
672672
* of the reset kernels. Returns the filtered (surviving) scoped items and private logs.
673673
*/
674674
function squashTransientSideEffects(
675-
taggedPrivateLogs: OrderedSideEffect<PrivateLog>[],
675+
taggedPrivateLogs: OrderedSideEffect<PrivateLogData>[],
676676
scopedNoteHashesCLA: ClaimedLengthArray<ScopedNoteHash, typeof MAX_NOTE_HASHES_PER_TX>,
677677
scopedNullifiersCLA: ClaimedLengthArray<ScopedNullifier, typeof MAX_NULLIFIERS_PER_TX>,
678678
noteHashNullifierCounterMap: Map<number, number>,
@@ -698,17 +698,9 @@ function squashTransientSideEffects(
698698
return {
699699
filteredNoteHashes: scopedNoteHashesCLA.getActiveItems().filter(nh => !squashedNoteHashCounters.has(nh.counter)),
700700
filteredNullifiers: scopedNullifiersCLA.getActiveItems().filter(n => !squashedNullifierCounters.has(n.counter)),
701-
filteredPrivateLogs: taggedPrivateLogs.filter(log => {
702-
for (let i = 0; i < numTransientData; i++) {
703-
const hint = transientDataHints[i];
704-
const noteHashCounter = scopedNoteHashesCLA.array[hint.noteHashIndex].counter;
705-
const nullifierCounter = scopedNullifiersCLA.array[hint.nullifierIndex].counter;
706-
if (log.counter > noteHashCounter && log.counter < nullifierCounter) {
707-
return false;
708-
}
709-
}
710-
return true;
711-
}),
701+
filteredPrivateLogs: taggedPrivateLogs
702+
.filter(item => !squashedNoteHashCounters.has(item.sideEffect.noteHashCounter))
703+
.map(item => new OrderedSideEffect(item.sideEffect.log, item.counter)),
712704
};
713705
}
714706

0 commit comments

Comments
 (0)