Skip to content

Commit

Permalink
2295 - removing assertMemberLength on Tuple objects
Browse files Browse the repository at this point in the history
  • Loading branch information
jeanmon committed Sep 14, 2023
1 parent cd8f349 commit fd83c9d
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 56 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -347,19 +347,6 @@ export class CombinedAccumulatedData {
*/
public publicDataReads: Tuple<PublicDataRead, typeof MAX_PUBLIC_DATA_READS_PER_TX>,
) {
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() {
Expand Down Expand Up @@ -527,18 +514,7 @@ export class FinalAccumulatedData {
* All the optionally revealed data in this transaction.
*/
public optionallyRevealedData: Tuple<OptionallyRevealedData, typeof MAX_OPTIONALLY_REVEALED_DATA_LENGTH_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);
}
) { }

toBuffer() {
return serializeToBuffer(
Expand Down
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -35,7 +35,6 @@ export class PreviousKernelData {
*/
public vkPath: Tuple<Fr, typeof VK_TREE_HEIGHT>,
) {
assertMemberLength(this, 'vkPath', VK_TREE_HEIGHT);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -63,8 +63,6 @@ export class PrivateCallData {
*/
public acirHash: Fr,
) {
assertMemberLength(this, 'privateCallStackPreimages', MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL);
assertMemberLength(this, 'readRequestMembershipWitnesses', MAX_READ_REQUESTS_PER_CALL);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -207,14 +206,6 @@ export class PublicCircuitPublicInputs {
*/
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);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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})`,
Expand Down

0 comments on commit fd83c9d

Please sign in to comment.