From 55e981a15b944dbbabe567f6ef893615166e3556 Mon Sep 17 00:00:00 2001 From: dbanks12 Date: Fri, 3 Jan 2025 21:44:06 +0000 Subject: [PATCH 1/2] chore: new test that you can register, deploy, and call a public function on a contract all in one tx --- .../e2e_deploy_contract/deploy_method.test.ts | 29 ++++++++++++++++--- ...ild_private_kernel_reset_private_inputs.ts | 2 +- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/yarn-project/end-to-end/src/e2e_deploy_contract/deploy_method.test.ts b/yarn-project/end-to-end/src/e2e_deploy_contract/deploy_method.test.ts index 5f2fe0781b4..1c91fae35b3 100644 --- a/yarn-project/end-to-end/src/e2e_deploy_contract/deploy_method.test.ts +++ b/yarn-project/end-to-end/src/e2e_deploy_contract/deploy_method.test.ts @@ -1,5 +1,13 @@ import { getDeployedTestAccountsWallets } from '@aztec/accounts/testing'; -import { AztecAddress, type Logger, type PXE, type Wallet, createPXEClient, makeFetch } from '@aztec/aztec.js'; +import { + AztecAddress, + BatchCall, + type Logger, + type PXE, + type Wallet, + createPXEClient, + makeFetch, +} from '@aztec/aztec.js'; import { CounterContract } from '@aztec/noir-contracts.js/Counter'; import { StatefulTestContract } from '@aztec/noir-contracts.js/StatefulTest'; import { TestContract } from '@aztec/noir-contracts.js/Test'; @@ -89,9 +97,22 @@ describe('e2e_deploy_contract deploy method', () => { await expect(TestContract.deploy(wallet).prove(opts)).rejects.toThrow(/no function calls needed/i); }); - it.skip('publicly deploys and calls a public function in the same batched call', async () => { - // TODO(@spalladino): Requires being able to read a nullifier on the same tx it was emitted. - }); + it('publicly deploys and calls a public contract in the same batched call', async () => { + const owner = wallet.getAddress(); + // Create a contract instance and make the PXE aware of it + logger.warn(`Initializing deploy method`); + const deployMethod = StatefulTestContract.deploy(wallet, owner, owner, 42); + logger.warn(`Creating request/calls to register and deploy contract`); + const deploy = await deployMethod.request(); + logger.warn(`Getting an instance of the not-yet-deployed contract to batch calls to`); + const contract = await StatefulTestContract.at(deployMethod.getInstance().address, wallet); + + // Batch registration, deployment, and public call into same TX + logger.warn(`Creating public calls to run in same batch as deployment`); + const init = contract.methods.increment_public_value(owner, 84).request(); + logger.warn(`Deploying a contract and calling a public function in the same batched call`); + await new BatchCall(wallet, [...deploy.calls, init]).send().wait(); + }, 300_000); it.skip('publicly deploys and calls a public function in a tx in the same block', async () => { // TODO(@spalladino): Requires being able to read a nullifier on the same block it was emitted. diff --git a/yarn-project/pxe/src/kernel_prover/hints/build_private_kernel_reset_private_inputs.ts b/yarn-project/pxe/src/kernel_prover/hints/build_private_kernel_reset_private_inputs.ts index b7435a4483b..fde4074171d 100644 --- a/yarn-project/pxe/src/kernel_prover/hints/build_private_kernel_reset_private_inputs.ts +++ b/yarn-project/pxe/src/kernel_prover/hints/build_private_kernel_reset_private_inputs.ts @@ -57,7 +57,7 @@ function getNullifierMembershipWitnessResolver(oracle: ProvingDataOracle) { return async (nullifier: Fr) => { const res = await oracle.getNullifierMembershipWitness(nullifier); if (!res) { - throw new Error(`Cannot find the leaf for nullifier ${nullifier.toBigInt()}.`); + throw new Error(`Cannot find the leaf for nullifier ${nullifier}.`); } const { index, siblingPath, leafPreimage } = res; From 8c6b67e8763f0908900e9993273b377608689a73 Mon Sep 17 00:00:00 2001 From: dbanks12 Date: Fri, 3 Jan 2025 21:55:49 +0000 Subject: [PATCH 2/2] no warns --- .../src/e2e_deploy_contract/deploy_method.test.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/yarn-project/end-to-end/src/e2e_deploy_contract/deploy_method.test.ts b/yarn-project/end-to-end/src/e2e_deploy_contract/deploy_method.test.ts index 1c91fae35b3..443ea035333 100644 --- a/yarn-project/end-to-end/src/e2e_deploy_contract/deploy_method.test.ts +++ b/yarn-project/end-to-end/src/e2e_deploy_contract/deploy_method.test.ts @@ -100,17 +100,17 @@ describe('e2e_deploy_contract deploy method', () => { it('publicly deploys and calls a public contract in the same batched call', async () => { const owner = wallet.getAddress(); // Create a contract instance and make the PXE aware of it - logger.warn(`Initializing deploy method`); + logger.debug(`Initializing deploy method`); const deployMethod = StatefulTestContract.deploy(wallet, owner, owner, 42); - logger.warn(`Creating request/calls to register and deploy contract`); + logger.debug(`Creating request/calls to register and deploy contract`); const deploy = await deployMethod.request(); - logger.warn(`Getting an instance of the not-yet-deployed contract to batch calls to`); + logger.debug(`Getting an instance of the not-yet-deployed contract to batch calls to`); const contract = await StatefulTestContract.at(deployMethod.getInstance().address, wallet); // Batch registration, deployment, and public call into same TX - logger.warn(`Creating public calls to run in same batch as deployment`); + logger.debug(`Creating public calls to run in same batch as deployment`); const init = contract.methods.increment_public_value(owner, 84).request(); - logger.warn(`Deploying a contract and calling a public function in the same batched call`); + logger.debug(`Deploying a contract and calling a public function in the same batched call`); await new BatchCall(wallet, [...deploy.calls, init]).send().wait(); }, 300_000);