Skip to content

Commit 0247b85

Browse files
authored
chore(circuits): removing assertMemberLength on Tuple objects (#2296)
Resolves #2295 # Checklist: Remove the checklist to signal you've completed it. Enable auto-merge if the PR is ready to merge. - [x] If the pull request requires a cryptography review (e.g. cryptographic algorithm implementations) I have added the 'crypto' tag. - [x] I have reviewed my diff in github, line by line and removed unexpected formatting changes, testing logs, or commented-out code. - [x] Every change is related to the PR description. - [x] I have [linked](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue) this pull request to relevant issues (if any exist).
1 parent 0d4c707 commit 0247b85

6 files changed

+12
-64
lines changed

yarn-project/circuits.js/src/structs/kernel/combined_accumulated_data.ts

+3-28
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {
1414
MAX_READ_REQUESTS_PER_TX,
1515
NUM_FIELDS_PER_SHA256,
1616
} from '../../cbind/constants.gen.js';
17-
import { assertMemberLength, makeTuple } from '../../index.js';
17+
import { makeTuple } from '../../index.js';
1818
import { serializeToBuffer } from '../../utils/serialize.js';
1919
import { AggregationObject, AztecAddress, EthAddress, Fr, FunctionData } from '../index.js';
2020

@@ -346,21 +346,7 @@ export class CombinedAccumulatedData {
346346
* All the public data reads made in this transaction.
347347
*/
348348
public publicDataReads: Tuple<PublicDataRead, typeof MAX_PUBLIC_DATA_READS_PER_TX>,
349-
) {
350-
assertMemberLength(this, 'readRequests', MAX_READ_REQUESTS_PER_TX);
351-
assertMemberLength(this, 'newCommitments', MAX_NEW_COMMITMENTS_PER_TX);
352-
assertMemberLength(this, 'newNullifiers', MAX_NEW_NULLIFIERS_PER_TX);
353-
assertMemberLength(this, 'nullifiedCommitments', MAX_NEW_NULLIFIERS_PER_TX);
354-
assertMemberLength(this, 'privateCallStack', MAX_PRIVATE_CALL_STACK_LENGTH_PER_TX);
355-
assertMemberLength(this, 'publicCallStack', MAX_PUBLIC_CALL_STACK_LENGTH_PER_TX);
356-
assertMemberLength(this, 'newL2ToL1Msgs', MAX_NEW_L2_TO_L1_MSGS_PER_TX);
357-
assertMemberLength(this, 'encryptedLogsHash', NUM_FIELDS_PER_SHA256);
358-
assertMemberLength(this, 'unencryptedLogsHash', NUM_FIELDS_PER_SHA256);
359-
assertMemberLength(this, 'newContracts', MAX_NEW_CONTRACTS_PER_TX);
360-
assertMemberLength(this, 'optionallyRevealedData', MAX_OPTIONALLY_REVEALED_DATA_LENGTH_PER_TX);
361-
assertMemberLength(this, 'publicDataUpdateRequests', MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX);
362-
assertMemberLength(this, 'publicDataReads', MAX_PUBLIC_DATA_READS_PER_TX);
363-
}
349+
) {}
364350

365351
toBuffer() {
366352
return serializeToBuffer(
@@ -527,18 +513,7 @@ export class FinalAccumulatedData {
527513
* All the optionally revealed data in this transaction.
528514
*/
529515
public optionallyRevealedData: Tuple<OptionallyRevealedData, typeof MAX_OPTIONALLY_REVEALED_DATA_LENGTH_PER_TX>,
530-
) {
531-
assertMemberLength(this, 'newCommitments', MAX_NEW_COMMITMENTS_PER_TX);
532-
assertMemberLength(this, 'newNullifiers', MAX_NEW_NULLIFIERS_PER_TX);
533-
assertMemberLength(this, 'nullifiedCommitments', MAX_NEW_NULLIFIERS_PER_TX);
534-
assertMemberLength(this, 'privateCallStack', MAX_PRIVATE_CALL_STACK_LENGTH_PER_TX);
535-
assertMemberLength(this, 'publicCallStack', MAX_PUBLIC_CALL_STACK_LENGTH_PER_TX);
536-
assertMemberLength(this, 'newL2ToL1Msgs', MAX_NEW_L2_TO_L1_MSGS_PER_TX);
537-
assertMemberLength(this, 'encryptedLogsHash', NUM_FIELDS_PER_SHA256);
538-
assertMemberLength(this, 'unencryptedLogsHash', NUM_FIELDS_PER_SHA256);
539-
assertMemberLength(this, 'newContracts', MAX_NEW_CONTRACTS_PER_TX);
540-
assertMemberLength(this, 'optionallyRevealedData', MAX_OPTIONALLY_REVEALED_DATA_LENGTH_PER_TX);
541-
}
516+
) {}
542517

543518
toBuffer() {
544519
return serializeToBuffer(

yarn-project/circuits.js/src/structs/kernel/previous_kernel_data.ts

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { BufferReader, Tuple } from '@aztec/foundation/serialize';
22

33
import { privateKernelDummyPreviousKernel } from '../../cbind/circuits.gen.js';
4-
import { CircuitsWasm, VK_TREE_HEIGHT, assertMemberLength, makeTuple } from '../../index.js';
4+
import { CircuitsWasm, VK_TREE_HEIGHT, makeTuple } from '../../index.js';
55
import { serializeToBuffer } from '../../utils/serialize.js';
66
import { Fr } from '../index.js';
77
import { Proof, makeEmptyProof } from '../proof.js';
@@ -34,9 +34,7 @@ export class PreviousKernelData {
3434
* Sibling path of the previous kernel's vk in a tree of vks.
3535
*/
3636
public vkPath: Tuple<Fr, typeof VK_TREE_HEIGHT>,
37-
) {
38-
assertMemberLength(this, 'vkPath', VK_TREE_HEIGHT);
39-
}
37+
) {}
4038

4139
/**
4240
* Serialize this as a buffer.

yarn-project/circuits.js/src/structs/kernel/private_kernel.ts

+2-5
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
MAX_READ_REQUESTS_PER_CALL,
99
MAX_READ_REQUESTS_PER_TX,
1010
} from '../../cbind/constants.gen.js';
11-
import { FieldsOf, assertMemberLength } from '../../utils/jsUtils.js';
11+
import { FieldsOf } from '../../utils/jsUtils.js';
1212
import { serializeToBuffer } from '../../utils/serialize.js';
1313
import { PrivateCallStackItem } from '../call_stack_item.js';
1414
import { Fr } from '../index.js';
@@ -62,10 +62,7 @@ export class PrivateCallData {
6262
* The hash of the ACIR of the function being invoked.
6363
*/
6464
public acirHash: Fr,
65-
) {
66-
assertMemberLength(this, 'privateCallStackPreimages', MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL);
67-
assertMemberLength(this, 'readRequestMembershipWitnesses', MAX_READ_REQUESTS_PER_CALL);
68-
}
65+
) {}
6966

7067
/**
7168
* Serialize into a field array. Low-level utility.

yarn-project/circuits.js/src/structs/private_circuit_public_inputs.ts

+2-13
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
NUM_FIELDS_PER_SHA256,
1212
RETURN_VALUES_LENGTH,
1313
} from '../cbind/constants.gen.js';
14-
import { FieldsOf, assertMemberLength, makeTuple } from '../utils/jsUtils.js';
14+
import { FieldsOf, makeTuple } from '../utils/jsUtils.js';
1515
import { serializeToBuffer } from '../utils/serialize.js';
1616
import { CallContext } from './call_context.js';
1717
import { HistoricBlockData } from './index.js';
@@ -99,18 +99,7 @@ export class PrivateCircuitPublicInputs {
9999
* Version of the instance.
100100
*/
101101
public version: Fr,
102-
) {
103-
assertMemberLength(this, 'returnValues', RETURN_VALUES_LENGTH);
104-
assertMemberLength(this, 'readRequests', MAX_READ_REQUESTS_PER_CALL);
105-
assertMemberLength(this, 'newCommitments', MAX_NEW_COMMITMENTS_PER_CALL);
106-
assertMemberLength(this, 'newNullifiers', MAX_NEW_NULLIFIERS_PER_CALL);
107-
assertMemberLength(this, 'nullifiedCommitments', MAX_NEW_NULLIFIERS_PER_CALL);
108-
assertMemberLength(this, 'privateCallStack', MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL);
109-
assertMemberLength(this, 'publicCallStack', MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL);
110-
assertMemberLength(this, 'newL2ToL1Msgs', MAX_NEW_L2_TO_L1_MSGS_PER_CALL);
111-
assertMemberLength(this, 'encryptedLogsHash', NUM_FIELDS_PER_SHA256);
112-
assertMemberLength(this, 'unencryptedLogsHash', NUM_FIELDS_PER_SHA256);
113-
}
102+
) {}
114103
/**
115104
* Create PrivateCircuitPublicInputs from a fields dictionary.
116105
* @param fields - The dictionary.

yarn-project/circuits.js/src/structs/public_circuit_public_inputs.ts

+2-12
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,9 @@ import {
1010
MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL,
1111
MAX_PUBLIC_DATA_READS_PER_CALL,
1212
MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL,
13-
NUM_FIELDS_PER_SHA256,
1413
RETURN_VALUES_LENGTH,
1514
} from '../cbind/constants.gen.js';
16-
import { FieldsOf, assertMemberLength, makeTuple } from '../utils/jsUtils.js';
15+
import { FieldsOf, makeTuple } from '../utils/jsUtils.js';
1716
import { serializeToBuffer } from '../utils/serialize.js';
1817
import { CallContext } from './call_context.js';
1918
import { HistoricBlockData } from './index.js';
@@ -206,16 +205,7 @@ export class PublicCircuitPublicInputs {
206205
* Address of the prover.
207206
*/
208207
public proverAddress: AztecAddress,
209-
) {
210-
assertMemberLength(this, 'returnValues', RETURN_VALUES_LENGTH);
211-
assertMemberLength(this, 'publicCallStack', MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL);
212-
assertMemberLength(this, 'newCommitments', MAX_NEW_COMMITMENTS_PER_CALL);
213-
assertMemberLength(this, 'newNullifiers', MAX_NEW_NULLIFIERS_PER_CALL);
214-
assertMemberLength(this, 'newL2ToL1Msgs', MAX_NEW_L2_TO_L1_MSGS_PER_CALL);
215-
assertMemberLength(this, 'contractStorageUpdateRequests', MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL);
216-
assertMemberLength(this, 'contractStorageReads', MAX_PUBLIC_DATA_READS_PER_CALL);
217-
assertMemberLength(this, 'unencryptedLogsHash', NUM_FIELDS_PER_SHA256);
218-
}
208+
) {}
219209

220210
/**
221211
* Create PublicCircuitPublicInputs from a fields dictionary.

yarn-project/circuits.js/src/structs/read_request_membership_witness.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Fr } from '@aztec/foundation/fields';
33
import { BufferReader, Tuple } from '@aztec/foundation/serialize';
44

55
import { MAX_NEW_COMMITMENTS_PER_CALL, PRIVATE_DATA_TREE_HEIGHT } from '../cbind/constants.gen.js';
6-
import { assertMemberLength, makeTuple, range } from '../utils/jsUtils.js';
6+
import { makeTuple, range } from '../utils/jsUtils.js';
77
import { serializeToBuffer } from '../utils/serialize.js';
88
import { MembershipWitness } from './membership_witness.js';
99

@@ -33,7 +33,6 @@ export class ReadRequestMembershipWitness {
3333
*/
3434
public hintToCommitment: Fr,
3535
) {
36-
assertMemberLength(this, 'siblingPath', PRIVATE_DATA_TREE_HEIGHT);
3736
if (hintToCommitment.value > MAX_NEW_COMMITMENTS_PER_CALL) {
3837
throw new Error(
3938
`Expected ReadRequestMembershipWitness' hintToCommitment(${hintToCommitment}) to be <= NEW_COMMITMENTS_LENGTH(${MAX_NEW_COMMITMENTS_PER_CALL})`,

0 commit comments

Comments
 (0)