From 8e40eb1fae3b766449dd067611ad0f864eebc141 Mon Sep 17 00:00:00 2001 From: jeanmon Date: Thu, 14 Sep 2023 10:53:26 +0000 Subject: [PATCH] 2295 - removing assertMemberLength on Tuple objects --- .../kernel/combined_accumulated_data.ts | 31 ++----------------- .../structs/kernel/previous_kernel_data.ts | 6 ++-- .../src/structs/kernel/private_kernel.ts | 7 ++--- .../structs/private_circuit_public_inputs.ts | 15 ++------- .../structs/public_circuit_public_inputs.ts | 14 ++------- .../read_request_membership_witness.ts | 3 +- 6 files changed, 12 insertions(+), 64 deletions(-) diff --git a/yarn-project/circuits.js/src/structs/kernel/combined_accumulated_data.ts b/yarn-project/circuits.js/src/structs/kernel/combined_accumulated_data.ts index aa7b25af1d08..507aa13d8689 100644 --- a/yarn-project/circuits.js/src/structs/kernel/combined_accumulated_data.ts +++ b/yarn-project/circuits.js/src/structs/kernel/combined_accumulated_data.ts @@ -14,7 +14,7 @@ import { MAX_READ_REQUESTS_PER_TX, NUM_FIELDS_PER_SHA256, } from '../../cbind/constants.gen.js'; -import { assertMemberLength, makeTuple } from '../../index.js'; +import { makeTuple } from '../../index.js'; import { serializeToBuffer } from '../../utils/serialize.js'; import { AggregationObject, AztecAddress, EthAddress, Fr, FunctionData } from '../index.js'; @@ -346,21 +346,7 @@ export class CombinedAccumulatedData { * All the public data reads made in this transaction. */ public publicDataReads: Tuple, - ) { - assertMemberLength(this, 'readRequests', MAX_READ_REQUESTS_PER_TX); - assertMemberLength(this, 'newCommitments', MAX_NEW_COMMITMENTS_PER_TX); - assertMemberLength(this, 'newNullifiers', MAX_NEW_NULLIFIERS_PER_TX); - assertMemberLength(this, 'nullifiedCommitments', MAX_NEW_NULLIFIERS_PER_TX); - assertMemberLength(this, 'privateCallStack', MAX_PRIVATE_CALL_STACK_LENGTH_PER_TX); - assertMemberLength(this, 'publicCallStack', MAX_PUBLIC_CALL_STACK_LENGTH_PER_TX); - assertMemberLength(this, 'newL2ToL1Msgs', MAX_NEW_L2_TO_L1_MSGS_PER_TX); - assertMemberLength(this, 'encryptedLogsHash', NUM_FIELDS_PER_SHA256); - assertMemberLength(this, 'unencryptedLogsHash', NUM_FIELDS_PER_SHA256); - assertMemberLength(this, 'newContracts', MAX_NEW_CONTRACTS_PER_TX); - assertMemberLength(this, 'optionallyRevealedData', MAX_OPTIONALLY_REVEALED_DATA_LENGTH_PER_TX); - assertMemberLength(this, 'publicDataUpdateRequests', MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX); - assertMemberLength(this, 'publicDataReads', MAX_PUBLIC_DATA_READS_PER_TX); - } + ) {} toBuffer() { return serializeToBuffer( @@ -527,18 +513,7 @@ export class FinalAccumulatedData { * All the optionally revealed data in this transaction. */ public optionallyRevealedData: Tuple, - ) { - assertMemberLength(this, 'newCommitments', MAX_NEW_COMMITMENTS_PER_TX); - assertMemberLength(this, 'newNullifiers', MAX_NEW_NULLIFIERS_PER_TX); - assertMemberLength(this, 'nullifiedCommitments', MAX_NEW_NULLIFIERS_PER_TX); - assertMemberLength(this, 'privateCallStack', MAX_PRIVATE_CALL_STACK_LENGTH_PER_TX); - assertMemberLength(this, 'publicCallStack', MAX_PUBLIC_CALL_STACK_LENGTH_PER_TX); - assertMemberLength(this, 'newL2ToL1Msgs', MAX_NEW_L2_TO_L1_MSGS_PER_TX); - assertMemberLength(this, 'encryptedLogsHash', NUM_FIELDS_PER_SHA256); - assertMemberLength(this, 'unencryptedLogsHash', NUM_FIELDS_PER_SHA256); - assertMemberLength(this, 'newContracts', MAX_NEW_CONTRACTS_PER_TX); - assertMemberLength(this, 'optionallyRevealedData', MAX_OPTIONALLY_REVEALED_DATA_LENGTH_PER_TX); - } + ) {} toBuffer() { return serializeToBuffer( diff --git a/yarn-project/circuits.js/src/structs/kernel/previous_kernel_data.ts b/yarn-project/circuits.js/src/structs/kernel/previous_kernel_data.ts index 0b9628c7bb27..0fb608900e47 100644 --- a/yarn-project/circuits.js/src/structs/kernel/previous_kernel_data.ts +++ b/yarn-project/circuits.js/src/structs/kernel/previous_kernel_data.ts @@ -1,7 +1,7 @@ import { BufferReader, Tuple } from '@aztec/foundation/serialize'; import { privateKernelDummyPreviousKernel } from '../../cbind/circuits.gen.js'; -import { CircuitsWasm, VK_TREE_HEIGHT, assertMemberLength, makeTuple } from '../../index.js'; +import { CircuitsWasm, VK_TREE_HEIGHT, makeTuple } from '../../index.js'; import { serializeToBuffer } from '../../utils/serialize.js'; import { Fr } from '../index.js'; import { Proof, makeEmptyProof } from '../proof.js'; @@ -34,9 +34,7 @@ export class PreviousKernelData { * Sibling path of the previous kernel's vk in a tree of vks. */ public vkPath: Tuple, - ) { - assertMemberLength(this, 'vkPath', VK_TREE_HEIGHT); - } + ) {} /** * Serialize this as a buffer. diff --git a/yarn-project/circuits.js/src/structs/kernel/private_kernel.ts b/yarn-project/circuits.js/src/structs/kernel/private_kernel.ts index d75b2bca6d1d..d68f3540ac4c 100644 --- a/yarn-project/circuits.js/src/structs/kernel/private_kernel.ts +++ b/yarn-project/circuits.js/src/structs/kernel/private_kernel.ts @@ -8,7 +8,7 @@ import { MAX_READ_REQUESTS_PER_CALL, MAX_READ_REQUESTS_PER_TX, } from '../../cbind/constants.gen.js'; -import { FieldsOf, assertMemberLength } from '../../utils/jsUtils.js'; +import { FieldsOf } from '../../utils/jsUtils.js'; import { serializeToBuffer } from '../../utils/serialize.js'; import { PrivateCallStackItem } from '../call_stack_item.js'; import { Fr } from '../index.js'; @@ -62,10 +62,7 @@ export class PrivateCallData { * The hash of the ACIR of the function being invoked. */ public acirHash: Fr, - ) { - assertMemberLength(this, 'privateCallStackPreimages', MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL); - assertMemberLength(this, 'readRequestMembershipWitnesses', MAX_READ_REQUESTS_PER_CALL); - } + ) {} /** * Serialize into a field array. Low-level utility. diff --git a/yarn-project/circuits.js/src/structs/private_circuit_public_inputs.ts b/yarn-project/circuits.js/src/structs/private_circuit_public_inputs.ts index b3e79a07b6fc..c89729ee4185 100644 --- a/yarn-project/circuits.js/src/structs/private_circuit_public_inputs.ts +++ b/yarn-project/circuits.js/src/structs/private_circuit_public_inputs.ts @@ -11,7 +11,7 @@ import { NUM_FIELDS_PER_SHA256, RETURN_VALUES_LENGTH, } from '../cbind/constants.gen.js'; -import { FieldsOf, assertMemberLength, makeTuple } from '../utils/jsUtils.js'; +import { FieldsOf, makeTuple } from '../utils/jsUtils.js'; import { serializeToBuffer } from '../utils/serialize.js'; import { CallContext } from './call_context.js'; import { HistoricBlockData } from './index.js'; @@ -99,18 +99,7 @@ export class PrivateCircuitPublicInputs { * Version of the instance. */ public version: Fr, - ) { - assertMemberLength(this, 'returnValues', RETURN_VALUES_LENGTH); - assertMemberLength(this, 'readRequests', MAX_READ_REQUESTS_PER_CALL); - assertMemberLength(this, 'newCommitments', MAX_NEW_COMMITMENTS_PER_CALL); - assertMemberLength(this, 'newNullifiers', MAX_NEW_NULLIFIERS_PER_CALL); - assertMemberLength(this, 'nullifiedCommitments', MAX_NEW_NULLIFIERS_PER_CALL); - assertMemberLength(this, 'privateCallStack', MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL); - assertMemberLength(this, 'publicCallStack', MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL); - assertMemberLength(this, 'newL2ToL1Msgs', MAX_NEW_L2_TO_L1_MSGS_PER_CALL); - assertMemberLength(this, 'encryptedLogsHash', NUM_FIELDS_PER_SHA256); - assertMemberLength(this, 'unencryptedLogsHash', NUM_FIELDS_PER_SHA256); - } + ) {} /** * Create PrivateCircuitPublicInputs from a fields dictionary. * @param fields - The dictionary. diff --git a/yarn-project/circuits.js/src/structs/public_circuit_public_inputs.ts b/yarn-project/circuits.js/src/structs/public_circuit_public_inputs.ts index 523b9c225267..310323b15973 100644 --- a/yarn-project/circuits.js/src/structs/public_circuit_public_inputs.ts +++ b/yarn-project/circuits.js/src/structs/public_circuit_public_inputs.ts @@ -10,10 +10,9 @@ import { MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL, MAX_PUBLIC_DATA_READS_PER_CALL, MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL, - NUM_FIELDS_PER_SHA256, RETURN_VALUES_LENGTH, } from '../cbind/constants.gen.js'; -import { FieldsOf, assertMemberLength, makeTuple } from '../utils/jsUtils.js'; +import { FieldsOf, makeTuple } from '../utils/jsUtils.js'; import { serializeToBuffer } from '../utils/serialize.js'; import { CallContext } from './call_context.js'; import { HistoricBlockData } from './index.js'; @@ -206,16 +205,7 @@ export class PublicCircuitPublicInputs { * Address of the prover. */ public proverAddress: AztecAddress, - ) { - assertMemberLength(this, 'returnValues', RETURN_VALUES_LENGTH); - assertMemberLength(this, 'publicCallStack', MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL); - assertMemberLength(this, 'newCommitments', MAX_NEW_COMMITMENTS_PER_CALL); - assertMemberLength(this, 'newNullifiers', MAX_NEW_NULLIFIERS_PER_CALL); - assertMemberLength(this, 'newL2ToL1Msgs', MAX_NEW_L2_TO_L1_MSGS_PER_CALL); - assertMemberLength(this, 'contractStorageUpdateRequests', MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL); - assertMemberLength(this, 'contractStorageReads', MAX_PUBLIC_DATA_READS_PER_CALL); - assertMemberLength(this, 'unencryptedLogsHash', NUM_FIELDS_PER_SHA256); - } + ) {} /** * Create PublicCircuitPublicInputs from a fields dictionary. diff --git a/yarn-project/circuits.js/src/structs/read_request_membership_witness.ts b/yarn-project/circuits.js/src/structs/read_request_membership_witness.ts index f0af8311d592..4735559598f1 100644 --- a/yarn-project/circuits.js/src/structs/read_request_membership_witness.ts +++ b/yarn-project/circuits.js/src/structs/read_request_membership_witness.ts @@ -3,7 +3,7 @@ import { Fr } from '@aztec/foundation/fields'; import { BufferReader, Tuple } from '@aztec/foundation/serialize'; import { MAX_NEW_COMMITMENTS_PER_CALL, PRIVATE_DATA_TREE_HEIGHT } from '../cbind/constants.gen.js'; -import { assertMemberLength, makeTuple, range } from '../utils/jsUtils.js'; +import { makeTuple, range } from '../utils/jsUtils.js'; import { serializeToBuffer } from '../utils/serialize.js'; import { MembershipWitness } from './membership_witness.js'; @@ -33,7 +33,6 @@ export class ReadRequestMembershipWitness { */ public hintToCommitment: Fr, ) { - assertMemberLength(this, 'siblingPath', PRIVATE_DATA_TREE_HEIGHT); if (hintToCommitment.value > MAX_NEW_COMMITMENTS_PER_CALL) { throw new Error( `Expected ReadRequestMembershipWitness' hintToCommitment(${hintToCommitment}) to be <= NEW_COMMITMENTS_LENGTH(${MAX_NEW_COMMITMENTS_PER_CALL})`,