From 416557de8e59242b1427fc43569782a2a39e0584 Mon Sep 17 00:00:00 2001 From: Rahul Kothari Date: Thu, 4 May 2023 11:00:51 +0000 Subject: [PATCH] address PR comments --- circuits/cpp/barretenberg | 2 +- .../circuits.js/src/tests/factories.ts | 29 +++++++------------ .../src/sequencer/public_processor.test.ts | 10 ++++--- yarn-project/types/src/tx.ts | 3 -- 4 files changed, 18 insertions(+), 26 deletions(-) diff --git a/circuits/cpp/barretenberg b/circuits/cpp/barretenberg index 27f5f8bb9aa..af243b20ebf 160000 --- a/circuits/cpp/barretenberg +++ b/circuits/cpp/barretenberg @@ -1 +1 @@ -Subproject commit 27f5f8bb9aa41c4099f520e7cb25e448c189657e +Subproject commit af243b20ebf38b27e79a1631cc056eab66573fd3 diff --git a/yarn-project/circuits.js/src/tests/factories.ts b/yarn-project/circuits.js/src/tests/factories.ts index 8e89a6e34db..e855ad38f05 100644 --- a/yarn-project/circuits.js/src/tests/factories.ts +++ b/yarn-project/circuits.js/src/tests/factories.ts @@ -78,7 +78,6 @@ import { CommitmentMap, G1AffineElement, VerificationKey } from '../structs/veri import { range } from '../utils/jsUtils.js'; import { numToUInt32BE } from '../utils/serialize.js'; import { computeCallStackItemHash } from '../abis/abis.js'; -import { WasmWrapper } from '@aztec/foundation/wasm'; export function makeTxContext(seed: number): TxContext { const deploymentData = new ContractDeploymentData(fr(seed), fr(seed + 1), fr(seed + 2), makeEthAddress(seed + 3)); @@ -188,21 +187,17 @@ export function makeAggregationObject(seed = 1): AggregationObject { ); } -export function makeCallContext(seed = 0): CallContext { - return new CallContext( - makeAztecAddress(seed), - makeAztecAddress(seed + 1), - makeEthAddress(seed + 2), - false, - false, - false, - ); +export function makeCallContext(seed = 0, storageContractAddress = makeAztecAddress(seed + 1)): CallContext { + return new CallContext(makeAztecAddress(seed), storageContractAddress, makeEthAddress(seed + 2), false, false, false); } -export function makePublicCircuitPublicInputs(seed = 0): PublicCircuitPublicInputs { +export function makePublicCircuitPublicInputs( + seed = 0, + storageContractAddress?: AztecAddress, +): PublicCircuitPublicInputs { const frArray = (num: number, seed: number) => range(num, seed).map(fr); return new PublicCircuitPublicInputs( - makeCallContext(seed), + makeCallContext(seed, storageContractAddress), frArray(ARGS_LENGTH, seed + 0x100), frArray(RETURN_VALUES_LENGTH, seed + 0x200), frArray(EMITTED_EVENTS_LENGTH, seed + 0x300), @@ -277,7 +272,7 @@ export function makePublicCallStackItem(seed = 1): PublicCallStackItem { return callStackItem; } -export async function makePublicCallData(seed = 1, wasm?: WasmWrapper) { +export async function makePublicCallData(seed = 1) { const publicCallData = new PublicCallData( makePublicCallStackItem(seed), range(PUBLIC_CALL_STACK_LENGTH, seed + 0x300).map(makePublicCallStackItem), @@ -286,9 +281,7 @@ export async function makePublicCallData(seed = 1, wasm?: WasmWrapper) { fr(seed + 2), ); // publicCallStack should be a hash of the preimages: - if (!wasm) { - wasm = await CircuitsWasm.get(); - } + const wasm = await CircuitsWasm.get(); publicCallData.callStackItem.publicInputs.publicCallStack = []; publicCallData.publicCallStackPreimages.forEach(preimage => { publicCallData.callStackItem.publicInputs.publicCallStack.push(computeCallStackItemHash(wasm!, preimage)); @@ -327,13 +320,13 @@ export async function makePublicKernelInputs(seed = 1): Promise { - const wasm = await CircuitsWasm.get(); const kernelCircuitPublicInputs = makeEmptyKernelPublicInputs(seed); const publicKernelInputs = new PublicKernelInputs( makePreviousKernelData(seed, kernelCircuitPublicInputs), - await makePublicCallData(seed + 0x1000, wasm), + await makePublicCallData(seed + 0x1000), ); //Set the call stack item for this circuit iteration at the top of the call stack + const wasm = await CircuitsWasm.get(); publicKernelInputs.previousKernel.publicInputs.end.publicCallStack[KERNEL_PUBLIC_CALL_STACK_LENGTH - 1] = computeCallStackItemHash(wasm, publicKernelInputs.publicCallData.callStackItem); return publicKernelInputs; diff --git a/yarn-project/sequencer-client/src/sequencer/public_processor.test.ts b/yarn-project/sequencer-client/src/sequencer/public_processor.test.ts index 02ce1b3592b..fd33d2adcac 100644 --- a/yarn-project/sequencer-client/src/sequencer/public_processor.test.ts +++ b/yarn-project/sequencer-client/src/sequencer/public_processor.test.ts @@ -97,11 +97,13 @@ describe('public_processor', () => { db.getSiblingPath.mockResolvedValue(new SiblingPath(path)); const tx = makePublicTx(); - // mock Public Circuit output - const publicCircuitOutput = makePublicCircuitPublicInputs(); + // public transactions shouldn't be constructors or private: + tx.txRequest.txRequest.functionData.isConstructor = false; + tx.txRequest.txRequest.functionData.isPrivate = false; + + // mock Public Circuit output (also set storageContractAddress to txRequest.to) + const publicCircuitOutput = makePublicCircuitPublicInputs(0, tx.txRequest.txRequest.to); publicCircuitOutput.publicCallStack = new Array(PUBLIC_CALL_STACK_LENGTH).fill(Fr.ZERO); - // set storageContractAddress to txRequest.to - publicCircuitOutput.callContext.storageContractAddress = tx.txRequest.txRequest.to; publicCircuit.publicCircuit.mockResolvedValue(publicCircuitOutput); diff --git a/yarn-project/types/src/tx.ts b/yarn-project/types/src/tx.ts index 7606ff0df33..82cb8d60b2b 100644 --- a/yarn-project/types/src/tx.ts +++ b/yarn-project/types/src/tx.ts @@ -70,9 +70,6 @@ export class Tx { * @returns New public tx instance. */ public static createPublic(txRequest: SignedTxRequest): PublicTx { - // public transactions can't be constructors or private: - txRequest.txRequest.functionData.isConstructor = false; - txRequest.txRequest.functionData.isPrivate = false; return new this(undefined, undefined, undefined, txRequest) as PublicTx; }