diff --git a/circuits b/circuits index fdd7a3577de..5ae96a0f8dc 160000 --- a/circuits +++ b/circuits @@ -1 +1 @@ -Subproject commit fdd7a3577deb2bc6fd90bb68b16c654695331d08 +Subproject commit 5ae96a0f8dc01618c0100903023c40904089985a diff --git a/yarn-project/aztec-rpc/src/account_state/account_state.ts b/yarn-project/aztec-rpc/src/account_state/account_state.ts index e650ecfda6b..f137539f155 100644 --- a/yarn-project/aztec-rpc/src/account_state/account_state.ts +++ b/yarn-project/aztec-rpc/src/account_state/account_state.ts @@ -2,7 +2,7 @@ import { AcirSimulator } from '@aztec/acir-simulator'; import { AztecNode } from '@aztec/aztec-node'; import { Grumpkin } from '@aztec/barretenberg.js/crypto'; import { KERNEL_NEW_COMMITMENTS_LENGTH, OldTreeRoots, TxRequest } from '@aztec/circuits.js'; -import { AztecAddress, Fr, Point, createDebugLogger } from '@aztec/foundation'; +import { AztecAddress, Fr, Point, keccak, createDebugLogger } from '@aztec/foundation'; import { INITIAL_L2_BLOCK_NUM } from '@aztec/l1-contracts'; import { L2BlockContext } from '@aztec/types'; import { UnverifiedData } from '@aztec/types'; @@ -63,6 +63,7 @@ export class AccountState { if (!functionDao) { throw new Error('Unknown function.'); } + const acirHash = keccak(Buffer.from(functionDao.bytecode, 'hex')); const oldRoots = new OldTreeRoots(Fr.ZERO, Fr.ZERO, Fr.ZERO, Fr.ZERO); // TODO - get old roots from the database/node @@ -76,7 +77,7 @@ export class AccountState { oldRoots, ); - return { contract, oldRoots, executionResult }; + return { contract, oldRoots, executionResult, acirHash }; } public createUnverifiedData(contract: AztecAddress, newNotes: { preimage: Fr[]; storageSlot: Fr }[]): UnverifiedData { diff --git a/yarn-project/aztec-rpc/src/aztec_rpc_server/aztec_rpc_server.ts b/yarn-project/aztec-rpc/src/aztec_rpc_server/aztec_rpc_server.ts index cf11fff6637..f366337304d 100644 --- a/yarn-project/aztec-rpc/src/aztec_rpc_server/aztec_rpc_server.ts +++ b/yarn-project/aztec-rpc/src/aztec_rpc_server/aztec_rpc_server.ts @@ -201,7 +201,7 @@ export class AztecRPCServer implements AztecRPCClient { public async createTx(txRequest: TxRequest, signature: EcdsaSignature) { const accountState = this.ensureAccount(txRequest.from); - const { executionResult, oldRoots, contract } = await accountState.simulate(txRequest); + const { executionResult, oldRoots, contract, acirHash } = await accountState.simulate(txRequest); this.log(`Executing Prover...`); const { publicInputs } = await this.kernelProver.prove( @@ -215,6 +215,7 @@ export class AztecRPCServer implements AztecRPCClient { (committment: Buffer) => { return this.getContractSiblingPath(committment); }, + acirHash, ); this.log(`Proof completed!`); diff --git a/yarn-project/circuits.js/src/structs/__snapshots__/kernel.test.ts.snap b/yarn-project/circuits.js/src/structs/__snapshots__/kernel.test.ts.snap index 48ed0d967d2..9e13822bd2e 100644 --- a/yarn-project/circuits.js/src/structs/__snapshots__/kernel.test.ts.snap +++ b/yarn-project/circuits.js/src/structs/__snapshots__/kernel.test.ts.snap @@ -459,6 +459,7 @@ leaf_index: 8225 sibling_path: [ 0x2021 0x2022 0x2023 0x2024 ] portal_contract_address: 0x4141414141414141414141414141414141414141 +acir_hash: 0x2061 " `; diff --git a/yarn-project/circuits.js/src/structs/kernel.test.ts b/yarn-project/circuits.js/src/structs/kernel.test.ts index c0a6a979a2c..d1082873a8d 100644 --- a/yarn-project/circuits.js/src/structs/kernel.test.ts +++ b/yarn-project/circuits.js/src/structs/kernel.test.ts @@ -1,6 +1,5 @@ import { expectSerializeToMatchSnapshot } from '../tests/expectSerialize.js'; import { makePreviousKernelData, makePrivateKernelInputs, makePrivateKernelPublicInputs } from '../tests/factories.js'; -import { CircuitsWasm } from '../wasm/circuits_wasm.js'; describe('structs/kernel', () => { it(`serializes and prints previous_kernel_data`, async () => { @@ -19,8 +18,7 @@ describe('structs/kernel', () => { ); }); - // TODO: Reenable once we can move back to circuits master and have this c_bind available - it.skip(`serializes and prints private_kernel_public_inputs`, async () => { + it(`serializes and prints private_kernel_public_inputs`, async () => { const kernelInputs = makePrivateKernelPublicInputs(); await expectSerializeToMatchSnapshot( kernelInputs.toBuffer(), diff --git a/yarn-project/circuits.js/src/structs/kernel.ts b/yarn-project/circuits.js/src/structs/kernel.ts index 09f3af9d53e..42aee2cae25 100644 --- a/yarn-project/circuits.js/src/structs/kernel.ts +++ b/yarn-project/circuits.js/src/structs/kernel.ts @@ -299,6 +299,7 @@ export class PrivateCallData { public functionLeafMembershipWitness: MembershipWitness, public contractLeafMembershipWitness: MembershipWitness, public portalContractAddress: EthAddress, + public acirHash: Fr, ) { assertLength(this, 'privateCallStackPreimages', PRIVATE_CALL_STACK_LENGTH); } @@ -318,6 +319,7 @@ export class PrivateCallData { fields.functionLeafMembershipWitness, fields.contractLeafMembershipWitness, fields.portalContractAddress, + fields.acirHash, ] as const; } diff --git a/yarn-project/circuits.js/src/tests/factories.ts b/yarn-project/circuits.js/src/tests/factories.ts index cb7fd4ed344..3c94b69ed2b 100644 --- a/yarn-project/circuits.js/src/tests/factories.ts +++ b/yarn-project/circuits.js/src/tests/factories.ts @@ -188,11 +188,12 @@ export function makePrivateCallData(seed = 1): PrivateCallData { return PrivateCallData.from({ callStackItem: makeCallStackItem(seed), privateCallStackPreimages: range(PRIVATE_CALL_STACK_LENGTH, seed + 0x10).map(makeCallStackItem), - contractLeafMembershipWitness: makeMembershipWitness(CONTRACT_TREE_HEIGHT, seed + 0x20), - functionLeafMembershipWitness: makeMembershipWitness(FUNCTION_TREE_HEIGHT, seed + 0x30), - portalContractAddress: makeEthAddress(seed + 0x40), proof: makeDynamicSizeBuffer(16, seed + 0x50), vk: makeVerificationKey(), + functionLeafMembershipWitness: makeMembershipWitness(FUNCTION_TREE_HEIGHT, seed + 0x30), + contractLeafMembershipWitness: makeMembershipWitness(CONTRACT_TREE_HEIGHT, seed + 0x20), + portalContractAddress: makeEthAddress(seed + 0x40), + acirHash: fr(seed + 0x60), }); } diff --git a/yarn-project/foundation/src/wasm/wasm/async_call_state.ts b/yarn-project/foundation/src/wasm/wasm/async_call_state.ts index 17554f4889d..68ce83e28f6 100644 --- a/yarn-project/foundation/src/wasm/wasm/async_call_state.ts +++ b/yarn-project/foundation/src/wasm/wasm/async_call_state.ts @@ -37,6 +37,8 @@ export class AsyncCallState { private ASYNCIFY_DATA_SIZE = 16 * 1024; private asyncifyDataAddr!: number; private asyncPromise?: Promise; + // For debug purposes, the last running function + private debugLastFuncName?: string; private wasm!: WasmModule; private state?: AsyncFnState; private callExport!: (...args: any[]) => number; @@ -84,9 +86,12 @@ export class AsyncCallState { */ public async call(name: string, ...args: any) { if (this.state) { - throw new Error(`Can only handle one async call at a time: ${name}(${args})`); + throw new Error( + `Can only handle one async call at a time: Can't run ${name}(${args}) because we are still running ${this.debugLastFuncName}`, + ); } this.state = { continuation: false }; + this.debugLastFuncName = name; let result = this.callExport(name, ...args); while (this.asyncPromise) { diff --git a/yarn-project/kernel-prover/src/index.ts b/yarn-project/kernel-prover/src/index.ts index 95659001faa..4dd9df422db 100644 --- a/yarn-project/kernel-prover/src/index.ts +++ b/yarn-project/kernel-prover/src/index.ts @@ -37,6 +37,7 @@ export class KernelProver { oldRoots: OldTreeRoots, getFunctionTreeInfo: (callStackItem: PrivateCallStackItem) => Promise, getContractSiblingPath: (committment: Buffer) => Promise>, + acirHash: Buffer, ): Promise<{ publicInputs: PrivateKernelPublicInputs; proof: Buffer }> { const wasm = await CircuitsWasm.get(); // TODO: implement this @@ -63,6 +64,7 @@ export class KernelProver { functionTreeInfo.membershipWitness, contractLeafMembershipWitness, txRequest.txContext.contractDeploymentData.portalContractAddress, + Fr.fromBuffer(Buffer.alloc(32, 0)),//acirHash, // FIXME: https://github.com/AztecProtocol/aztec3-packages/issues/262 ); const previousKernelData: PreviousKernelData = await DummyPreviousKernelData.getDummyPreviousKernelData(wasm); diff --git a/yarn-project/package.json b/yarn-project/package.json index 60f5a29f103..56284aa5888 100644 --- a/yarn-project/package.json +++ b/yarn-project/package.json @@ -8,7 +8,7 @@ "docs": "typedoc --out docs/dist && cd docs && yarn serve", "formatting": "yarn workspaces foreach -v run formatting", "formatting:fix": "yarn workspaces foreach -v run formatting:fix", - "test": "yarn workspaces foreach -v run test", + "test": "yarn build && yarn workspaces foreach -v run test", "build": "tsc -b tsconfig.json", "build:dev": "tsc -b tsconfig.json --watch", "clean": "yarn workspaces foreach -v run clean"