diff --git a/yarn-project/circuits.js/src/kernel/public_kernel.test.ts b/yarn-project/circuits.js/src/kernel/public_kernel.test.ts index 7bf12b129421..c8b28c2daa79 100644 --- a/yarn-project/circuits.js/src/kernel/public_kernel.test.ts +++ b/yarn-project/circuits.js/src/kernel/public_kernel.test.ts @@ -1,15 +1,17 @@ import { CircuitError, + Fr, + MAX_PRIVATE_CALL_STACK_LENGTH_PER_TX, MAX_PUBLIC_DATA_READS_PER_CALL, MAX_PUBLIC_DATA_READS_PER_TX, makeTuple, simulatePublicKernelCircuit, } from '../index.js'; -import { makePublicDataRead, makePublicKernelInputsWithEmptyOutput } from '../tests/factories.js'; +import { makePublicDataRead, makePublicKernelInputsWithTweak } from '../tests/factories.js'; describe('kernel/public_kernel', () => { it('simulates public kernel circuit with previous public kernel', async function () { - const input = await makePublicKernelInputsWithEmptyOutput(1, input => { + const input = await makePublicKernelInputsWithTweak(1, input => { input.publicCall.callStackItem.functionData.isConstructor = false; input.publicCall.callStackItem.functionData.isPrivate = false; input.previousKernel.publicInputs.isPrivate = false; @@ -19,15 +21,16 @@ describe('kernel/public_kernel', () => { }); it('simulates public kernel circuit with previous private kernel', async function () { - const input = await makePublicKernelInputsWithEmptyOutput(1, input => { + const input = await makePublicKernelInputsWithTweak(1, input => { input.previousKernel.publicInputs.isPrivate = true; + input.previousKernel.publicInputs.end.privateCallStack = makeTuple(MAX_PRIVATE_CALL_STACK_LENGTH_PER_TX, Fr.zero); }); const result = await simulatePublicKernelCircuit(input); expect(result).toBeDefined(); }); it('simulating public kernel circuit fails when aggregating proofs will overflow', async function () { - const input = await makePublicKernelInputsWithEmptyOutput(1, input => { + const input = await makePublicKernelInputsWithTweak(1, input => { input.publicCall.callStackItem.functionData.isConstructor = false; input.publicCall.callStackItem.functionData.isPrivate = false; input.previousKernel.publicInputs.isPrivate = false; diff --git a/yarn-project/circuits.js/src/structs/kernel/__snapshots__/index.test.ts.snap b/yarn-project/circuits.js/src/structs/kernel/__snapshots__/index.test.ts.snap index c7172ce66505..6791a7073b4a 100644 --- a/yarn-project/circuits.js/src/structs/kernel/__snapshots__/index.test.ts.snap +++ b/yarn-project/circuits.js/src/structs/kernel/__snapshots__/index.test.ts.snap @@ -1773,7 +1773,7 @@ is_private: 1 " `; -exports[`structs/kernel serializes and prints private_kernel_public_inputs_final 1`] = ` +exports[`structs/kernel serializes and prints private_kernel_public_inputs for ordering circuit 1`] = ` "end: aggregation_object: P0: { 0x1, 0x2 } diff --git a/yarn-project/circuits.js/src/structs/kernel/index.test.ts b/yarn-project/circuits.js/src/structs/kernel/index.test.ts index 6f88383f5801..23d14a579b9e 100644 --- a/yarn-project/circuits.js/src/structs/kernel/index.test.ts +++ b/yarn-project/circuits.js/src/structs/kernel/index.test.ts @@ -62,7 +62,7 @@ describe('structs/kernel', () => { ); }); - it(`serializes and prints private_kernel_public_inputs_final`, async () => { + it(`serializes and prints private_kernel_public_inputs for ordering circuit`, async () => { const kernelInputs = makeKernelPublicInputsFinal(); await expectSerializeToMatchSnapshot( kernelInputs.toBuffer(), diff --git a/yarn-project/circuits.js/src/tests/factories.ts b/yarn-project/circuits.js/src/tests/factories.ts index dadab826aa27..fe611904b952 100644 --- a/yarn-project/circuits.js/src/tests/factories.ts +++ b/yarn-project/circuits.js/src/tests/factories.ts @@ -193,35 +193,6 @@ export function makeContractStorageRead(seed = 1): ContractStorageRead { return new ContractStorageRead(fr(seed), fr(seed + 1)); } -/** - * Creates empty accumulated data. - * @param seed - The seed to use for generating the accumulated data. - * @returns An empty accumulated data. - */ -export function makeEmptyAccumulatedData(seed = 1, full = false): CombinedAccumulatedData { - const tupleGenerator = full ? makeTuple : makeHalfFullTuple; - - return new CombinedAccumulatedData( - makeAggregationObject(seed), - tupleGenerator(MAX_READ_REQUESTS_PER_TX, fr, seed + 0x80), - tupleGenerator(MAX_READ_REQUESTS_PER_TX, i => makeReadRequestMembershipWitness(i * 123), seed + 0x90), - tupleGenerator(MAX_NEW_COMMITMENTS_PER_TX, fr, seed + 0x100), - tupleGenerator(MAX_NEW_NULLIFIERS_PER_TX, fr, seed + 0x200), - tupleGenerator(MAX_NEW_NULLIFIERS_PER_TX, fr, seed + 0x300), - tupleGenerator(MAX_PRIVATE_CALL_STACK_LENGTH_PER_TX, Fr.zero), // private call stack must be empty - tupleGenerator(MAX_PUBLIC_CALL_STACK_LENGTH_PER_TX, fr, seed + 0x500), - tupleGenerator(MAX_NEW_L2_TO_L1_MSGS_PER_TX, fr, seed + 0x600), - tupleGenerator(2, fr, seed + 0x700), // encrypted logs hash - tupleGenerator(2, fr, seed + 0x800), // unencrypted logs hash - fr(seed + 0x900), // encrypted_log_preimages_length - fr(seed + 0xa00), // unencrypted_log_preimages_length - tupleGenerator(MAX_NEW_CONTRACTS_PER_TX, makeNewContractData, seed + 0xb00), - tupleGenerator(MAX_OPTIONALLY_REVEALED_DATA_LENGTH_PER_TX, makeOptionallyRevealedData, seed + 0xc00), - tupleGenerator(MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, makeEmptyPublicDataUpdateRequest, seed + 0xd00), - tupleGenerator(MAX_PUBLIC_DATA_READS_PER_TX, makeEmptyPublicDataRead, seed + 0xe00), - ); -} - /** * Creates arbitrary accumulated data. * @param seed - The seed to use for generating the accumulated data. @@ -251,31 +222,6 @@ export function makeAccumulatedData(seed = 1, full = false): CombinedAccumulated ); } -/** - * Creates empty final accumulated data. - * @param seed - The seed to use for generating the final accumulated data. - * @returns An empty final accumulated data. - */ -export function makeEmptyFinalAccumulatedData(seed = 1, full = false): FinalAccumulatedData { - const tupleGenerator = full ? makeTuple : makeHalfFullTuple; - - return new FinalAccumulatedData( - makeAggregationObject(seed), - tupleGenerator(MAX_NEW_COMMITMENTS_PER_TX, fr, seed + 0x100), - tupleGenerator(MAX_NEW_NULLIFIERS_PER_TX, fr, seed + 0x200), - tupleGenerator(MAX_NEW_NULLIFIERS_PER_TX, fr, seed + 0x300), - tupleGenerator(MAX_PRIVATE_CALL_STACK_LENGTH_PER_TX, Fr.zero), // private call stack must be empty - tupleGenerator(MAX_PUBLIC_CALL_STACK_LENGTH_PER_TX, fr, seed + 0x500), - tupleGenerator(MAX_NEW_L2_TO_L1_MSGS_PER_TX, fr, seed + 0x600), - tupleGenerator(2, fr, seed + 0x700), // encrypted logs hash - tupleGenerator(2, fr, seed + 0x800), // unencrypted logs hash - fr(seed + 0x900), // encrypted_log_preimages_length - fr(seed + 0xa00), // unencrypted_log_preimages_length - tupleGenerator(MAX_NEW_CONTRACTS_PER_TX, makeNewContractData, seed + 0xb00), - tupleGenerator(MAX_OPTIONALLY_REVEALED_DATA_LENGTH_PER_TX, makeOptionallyRevealedData, seed + 0xc00), - ); -} - /** * Creates arbitrary final accumulated data. * @param seed - The seed to use for generating the final accumulated data. @@ -382,31 +328,13 @@ export function makePublicCircuitPublicInputs( ); } -/** - * Creates empty kernel circuit public inputs. - * @param seed - The seed to use for generating the kernel circuit public inputs. - * @returns Empty kernel circuit public inputs. - */ -export function makeEmptyKernelPublicInputs(seed = 1): KernelCircuitPublicInputs { - return new KernelCircuitPublicInputs(makeEmptyAccumulatedData(seed), makeConstantData(seed + 0x100), true); -} - /** * Creates arbitrary kernel circuit public inputs. * @param seed - The seed to use for generating the kernel circuit public inputs. * @returns Kernel circuit public inputs. */ export function makeKernelPublicInputs(seed = 1): KernelCircuitPublicInputs { - return new KernelCircuitPublicInputs(makeAccumulatedData(seed, true), makeConstantData(seed + 0x100), true); -} - -/** - * Creates empty final ordering kernel circuit public inputs. - * @param seed - The seed to use for generating the final ordering kernel circuit public inputs. - * @returns Empty final ordering kernel circuit public inputs. - */ -export function makeEmptyKernelPublicInputsFinal(seed = 1): KernelCircuitPublicInputsFinal { - return new KernelCircuitPublicInputsFinal(makeEmptyFinalAccumulatedData(seed), makeConstantData(seed + 0x100), true); + return new KernelCircuitPublicInputs(makeAccumulatedData(seed, false), makeConstantData(seed + 0x100), true); } /** @@ -627,16 +555,16 @@ export async function makePublicKernelInputs(seed = 1): Promise void, ): Promise { - const kernelCircuitPublicInputs = makeEmptyKernelPublicInputs(seed); + const kernelCircuitPublicInputs = makeKernelPublicInputs(seed); const publicKernelInputs = new PublicKernelInputs( makePreviousKernelData(seed, kernelCircuitPublicInputs), await makePublicCallData(seed + 0x1000),