Skip to content

Commit

Permalink
refactor: initializer nullifier read in the kernel (#7876)
Browse files Browse the repository at this point in the history
  • Loading branch information
benesjan authored Aug 9, 2024
1 parent 043e219 commit fda7c3e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 13 deletions.
12 changes: 2 additions & 10 deletions noir-projects/aztec-nr/aztec/src/initializer.nr
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,8 @@ pub fn assert_is_initialized_public(context: &mut PublicContext) {
}

pub fn assert_is_initialized_private(context: &mut PrivateContext) {
let init_nullifier = compute_contract_initialization_nullifier(context.this_address());
let header = context.get_header();
header.prove_nullifier_inclusion(init_nullifier);
}

fn compute_contract_initialization_nullifier(address: AztecAddress) -> Field {
compute_siloed_nullifier(
address,
compute_unsiloed_contract_initialization_nullifier(address)
)
let init_nullifier = compute_unsiloed_contract_initialization_nullifier(context.this_address());
context.push_nullifier_read_request(init_nullifier);
}

fn compute_unsiloed_contract_initialization_nullifier(address: AztecAddress) -> Field {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ describe('e2e_deploy_contract private initialization', () => {
expect(await contracts[1].methods.summed_values(owner).simulate()).toEqual(52n);
});

// TODO(@spalladino): This won't work until we can read a nullifier in the same tx in which it was emitted.
it.skip('initializes and calls a private function in a single tx', async () => {
it('initializes and calls a private function in a single tx', async () => {
const owner = await t.registerRandomAccount();
const initArgs: StatefulContractCtorArgs = [owner, owner, 42];
const contract = await t.registerContract(wallet, StatefulTestContract, { initArgs });
Expand Down Expand Up @@ -104,7 +103,7 @@ describe('e2e_deploy_contract private initialization', () => {
// TODO(@spalladino): It'd be nicer to be able to fail the assert with a more descriptive message.
const outgoingViewer = owner;
await expect(contract.methods.create_note(owner, outgoingViewer, 10).send().wait()).rejects.toThrow(
/nullifier witness not found/i,
/Cannot find the leaf for nullifier/i,
);
});

Expand Down

0 comments on commit fda7c3e

Please sign in to comment.