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 0d4c707 commit ec97a69
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 64 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 @@ -346,21 +346,7 @@ export class CombinedAccumulatedData {
* All the public data reads made in this transaction.
*/
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() {
return serializeToBuffer(
Expand Down Expand Up @@ -527,18 +513,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 @@ -34,9 +34,7 @@ export class PreviousKernelData {
* Sibling path of the previous kernel's vk in a tree of vks.
*/
public vkPath: Tuple<Fr, typeof VK_TREE_HEIGHT>,
) {
assertMemberLength(this, 'vkPath', VK_TREE_HEIGHT);
}
) {}

/**
* Serialize this as a buffer.
Expand Down
7 changes: 2 additions & 5 deletions yarn-project/circuits.js/src/structs/kernel/private_kernel.ts
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 @@ -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.
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 @@ -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.
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 ec97a69

Please sign in to comment.