From b12954230f02e80131ae8a7d9d0164785380b445 Mon Sep 17 00:00:00 2001 From: fcarreiro Date: Thu, 4 Apr 2024 09:07:04 +0000 Subject: [PATCH] wip --- .../contracts/avm_test_contract/src/main.nr | 5 +++++ .../end-to-end/src/e2e_avm_simulator.test.ts | 15 +++++++++++++-- .../src/avm/temporary_executor_migration.ts | 6 ++++-- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/noir-projects/noir-contracts/contracts/avm_test_contract/src/main.nr b/noir-projects/noir-contracts/contracts/avm_test_contract/src/main.nr index 442d6c2fdfbc..96930588e654 100644 --- a/noir-projects/noir-contracts/contracts/avm_test_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/avm_test_contract/src/main.nr @@ -316,6 +316,11 @@ contract AvmTest { context.nullifier_exists(nullifier) } + #[aztec(public-vm)] + fn assert_nullifier_exists(nullifier: Field) { + assert(context.nullifier_exists(nullifier)); + } + // Use the standard context interface to emit a new nullifier #[aztec(public-vm)] fn emit_nullifier_and_check(nullifier: Field) { diff --git a/yarn-project/end-to-end/src/e2e_avm_simulator.test.ts b/yarn-project/end-to-end/src/e2e_avm_simulator.test.ts index 2edb2328a20f..1f774835b374 100644 --- a/yarn-project/end-to-end/src/e2e_avm_simulator.test.ts +++ b/yarn-project/end-to-end/src/e2e_avm_simulator.test.ts @@ -1,4 +1,4 @@ -import { AztecAddress, TxStatus, type Wallet } from '@aztec/aztec.js'; +import { AztecAddress, Fr, TxStatus, type Wallet } from '@aztec/aztec.js'; import { AvmTestContract } from '@aztec/noir-contracts.js'; import { jest } from '@jest/globals'; @@ -51,9 +51,20 @@ describe('e2e_avm_simulator', () => { }); describe('Nullifiers', () => { - it('Emit and check', async () => { + // Nullifier will not yet be siloed by the kernel. + it('Emit and check in the same tx', async () => { const tx = await avmContact.methods.emit_nullifier_and_check(123456).send().wait(); expect(tx.status).toEqual(TxStatus.MINED); }); + + // Nullifier will have been siloed by the kernel, but we check against the unsiloed one. + it('Emit and check in separate tx', async () => { + const nullifier = new Fr(123456); + let tx = await avmContact.methods.new_nullifier(nullifier).send().wait(); + expect(tx.status).toEqual(TxStatus.MINED); + + tx = await avmContact.methods.assert_nullifier_exists(nullifier).send().wait(); + expect(tx.status).toEqual(TxStatus.MINED); + }); }); }); diff --git a/yarn-project/simulator/src/avm/temporary_executor_migration.ts b/yarn-project/simulator/src/avm/temporary_executor_migration.ts index a5cc697761ed..86748d2635b4 100644 --- a/yarn-project/simulator/src/avm/temporary_executor_migration.ts +++ b/yarn-project/simulator/src/avm/temporary_executor_migration.ts @@ -7,7 +7,7 @@ import { L2ToL1Message, type ReadRequest, SideEffect, - type SideEffectLinkedToNoteHash, + SideEffectLinkedToNoteHash, } from '@aztec/circuits.js'; import { Fr } from '@aztec/foundation/fields'; @@ -96,7 +96,9 @@ export function temporaryConvertAvmResults( const nestedExecutions: PublicExecutionResult[] = []; const nullifierReadRequests: ReadRequest[] = []; const nullifierNonExistentReadRequests: ReadRequest[] = []; - const newNullifiers: SideEffectLinkedToNoteHash[] = []; + const newNullifiers: SideEffectLinkedToNoteHash[] = newWorldState.newNullifiers.map( + (nullifier, i) => new SideEffectLinkedToNoteHash(nullifier.toField(), Fr.zero(), new Fr(i + 1)), + ); const unencryptedLogs = UnencryptedFunctionL2Logs.empty(); const newL2ToL1Messages = newWorldState.newL1Messages.map(() => L2ToL1Message.empty()); // TODO keep track of side effect counters