@aztec-labs/stdlib 6.1.0-nightly.20261113 → 6.1.0-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/dest/abi/utils.d.ts +1 -1
  2. package/dest/abi/utils.d.ts.map +1 -1
  3. package/dest/abi/utils.js +3 -2
  4. package/dest/block/proposal/attestations_and_signers.js +2 -2
  5. package/dest/checkpoint/checkpoint_reexecution_tracker.d.ts +18 -19
  6. package/dest/checkpoint/checkpoint_reexecution_tracker.d.ts.map +1 -1
  7. package/dest/checkpoint/checkpoint_reexecution_tracker.js +25 -24
  8. package/dest/delayed_public_mutable/delayed_public_mutable_values.d.ts +1 -1
  9. package/dest/delayed_public_mutable/delayed_public_mutable_values.d.ts.map +1 -1
  10. package/dest/delayed_public_mutable/delayed_public_mutable_values.js +2 -3
  11. package/dest/file-store/s3.d.ts +3 -4
  12. package/dest/file-store/s3.d.ts.map +1 -1
  13. package/dest/file-store/s3.js +10 -7
  14. package/dest/interfaces/allowed_element.d.ts +32 -12
  15. package/dest/interfaces/allowed_element.d.ts.map +1 -1
  16. package/dest/interfaces/allowed_element.js +9 -6
  17. package/dest/interfaces/archiver.d.ts +2 -2
  18. package/dest/interfaces/archiver.d.ts.map +1 -1
  19. package/dest/interfaces/aztec-node-admin.d.ts +49 -6
  20. package/dest/interfaces/aztec-node-admin.d.ts.map +1 -1
  21. package/dest/interfaces/aztec-node-admin.js +30 -1
  22. package/dest/interfaces/configs.d.ts +19 -5
  23. package/dest/interfaces/configs.d.ts.map +1 -1
  24. package/dest/interfaces/proving-job.d.ts +70 -70
  25. package/dest/interfaces/validator.d.ts +19 -5
  26. package/dest/interfaces/validator.d.ts.map +1 -1
  27. package/dest/logs/contract_class_log.d.ts +1 -1
  28. package/dest/logs/contract_class_log.d.ts.map +1 -1
  29. package/dest/logs/contract_class_log.js +4 -9
  30. package/dest/logs/public_log.d.ts +1 -1
  31. package/dest/logs/public_log.d.ts.map +1 -1
  32. package/dest/logs/public_log.js +2 -3
  33. package/dest/messaging/l1_to_l2_message_bundle.js +3 -7
  34. package/dest/messaging/l2_to_l1_membership.d.ts +1 -1
  35. package/dest/messaging/l2_to_l1_membership.d.ts.map +1 -1
  36. package/dest/messaging/l2_to_l1_membership.js +2 -3
  37. package/dest/note/note.d.ts +1 -1
  38. package/dest/note/note.d.ts.map +1 -1
  39. package/dest/note/note.js +2 -3
  40. package/dest/parity/inbox_parity_private_inputs.js +2 -4
  41. package/dest/rollup/checkpoint_root_rollup_private_inputs.d.ts +1 -1
  42. package/dest/rollup/checkpoint_root_rollup_private_inputs.d.ts.map +1 -1
  43. package/dest/rollup/checkpoint_root_rollup_private_inputs.js +2 -3
  44. package/dest/tests/factories.d.ts +1 -1
  45. package/dest/tests/factories.d.ts.map +1 -1
  46. package/dest/tests/factories.js +13 -16
  47. package/dest/tests/mocks.js +1 -3
  48. package/dest/tx/execution_payload.d.ts +1 -1
  49. package/dest/tx/execution_payload.d.ts.map +1 -1
  50. package/dest/tx/execution_payload.js +2 -1
  51. package/dest/tx/tx_effect.d.ts +1 -1
  52. package/dest/tx/tx_effect.d.ts.map +1 -1
  53. package/dest/tx/tx_effect.js +2 -1
  54. package/dest/tx/validator/error_texts.d.ts +3 -1
  55. package/dest/tx/validator/error_texts.d.ts.map +1 -1
  56. package/dest/tx/validator/error_texts.js +2 -0
  57. package/dest/zkpassport/index.d.ts +1 -1
  58. package/dest/zkpassport/index.d.ts.map +1 -1
  59. package/dest/zkpassport/index.js +5 -6
  60. package/package.json +5 -5
  61. package/src/abi/utils.ts +3 -2
  62. package/src/block/proposal/attestations_and_signers.ts +2 -2
  63. package/src/checkpoint/checkpoint_reexecution_tracker.ts +31 -28
  64. package/src/delayed_public_mutable/delayed_public_mutable_values.ts +2 -1
  65. package/src/file-store/s3.ts +9 -4
  66. package/src/interfaces/allowed_element.ts +23 -13
  67. package/src/interfaces/archiver.ts +1 -1
  68. package/src/interfaces/aztec-node-admin.ts +29 -2
  69. package/src/logs/contract_class_log.ts +4 -7
  70. package/src/logs/public_log.ts +2 -1
  71. package/src/messaging/l1_to_l2_message_bundle.ts +3 -3
  72. package/src/messaging/l2_to_l1_membership.ts +2 -1
  73. package/src/note/note.ts +2 -1
  74. package/src/parity/inbox_parity_private_inputs.ts +2 -2
  75. package/src/rollup/checkpoint_root_rollup_private_inputs.ts +2 -1
  76. package/src/tests/factories.ts +13 -16
  77. package/src/tests/mocks.ts +1 -1
  78. package/src/tx/execution_payload.ts +3 -6
  79. package/src/tx/tx_effect.ts +2 -1
  80. package/src/tx/validator/error_texts.ts +2 -0
  81. package/src/zkpassport/index.ts +5 -4
@@ -44,13 +44,14 @@ import {
44
44
  } from '@aztec-labs/constants';
45
45
  import { type FieldsOf, makeTuple } from '@aztec-labs/foundation/array';
46
46
  import { BlockNumber, CheckpointNumber, SlotNumber, TreeLeafIndex } from '@aztec-labs/foundation/branded-types';
47
- import { compact } from '@aztec-labs/foundation/collection';
47
+ import { compact, times } from '@aztec-labs/foundation/collection';
48
48
  import { Grumpkin } from '@aztec-labs/foundation/crypto/grumpkin';
49
49
  import { sha256 } from '@aztec-labs/foundation/crypto/sha256';
50
50
  import { Fq, Fr } from '@aztec-labs/foundation/curves/bn254';
51
51
  import { GrumpkinScalar, Point } from '@aztec-labs/foundation/curves/grumpkin';
52
52
  import { EthAddress } from '@aztec-labs/foundation/eth-address';
53
53
  import type { Bufferable, Serializable, Tuple } from '@aztec-labs/foundation/serialize';
54
+ import { bufferToHex } from '@aztec-labs/foundation/string';
54
55
  import { MembershipWitness } from '@aztec-labs/foundation/trees';
55
56
  import { Buffer } from 'buffer';
56
57
 
@@ -214,7 +215,7 @@ function makePrivateLogData(seed: number) {
214
215
  function makePublicLog(seed: number) {
215
216
  return new PublicLog(
216
217
  makeAztecAddress(seed),
217
- new Array(10).fill(null).map((_, i) => new Fr(seed + i)),
218
+ times(10, i => new Fr(seed + i)),
218
219
  );
219
220
  }
220
221
 
@@ -397,7 +398,7 @@ function makeAvmAccumulatedData(seed = 1) {
397
398
  makeTuple(MAX_NOTE_HASHES_PER_TX, fr, seed),
398
399
  makeTuple(MAX_NULLIFIERS_PER_TX, fr, seed + 0x100),
399
400
  makeTuple(MAX_L2_TO_L1_MSGS_PER_TX, makeScopedL2ToL1Message, seed + 0x200),
400
- FlatPublicLogs.fromLogs(new Array(20).fill(null).map((_, i) => makePublicLog(seed + i * 256))),
401
+ FlatPublicLogs.fromLogs(times(20, i => makePublicLog(seed + i * 256))),
401
402
  makeTuple(MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, makePublicDataWrite, seed + 0x400),
402
403
  );
403
404
  }
@@ -836,7 +837,7 @@ export function makeParityPublicInputs(seed = 0): ParityPublicInputs {
836
837
  export function makeInboxParityPrivateInputs(seed = 0): InboxParityPrivateInputs {
837
838
  const size = INBOX_PARITY_SIZE_SMALL;
838
839
  const numMsgs = seed % (size + 1);
839
- const messages = Array.from({ length: size }, (_, i) => (i < numMsgs ? fr(i + seed + 0x3000) : Fr.ZERO));
840
+ const messages = times(size, i => (i < numMsgs ? fr(i + seed + 0x3000) : Fr.ZERO));
840
841
  return new InboxParityPrivateInputs(size, messages, numMsgs, new Fr(seed + 0x3500), new Fr(seed + 0x5000));
841
842
  }
842
843
 
@@ -1174,15 +1175,11 @@ function makeContractClassPrivateFunction(seed = 0): PrivateFunction {
1174
1175
  }
1175
1176
 
1176
1177
  export function makeArray<T>(length: number, fn: (i: number) => T, offset = 0) {
1177
- return Array.from({ length }, (_: any, i: number) => fn(i + offset));
1178
+ return times(length, (i: number) => fn(i + offset));
1178
1179
  }
1179
1180
 
1180
1181
  export function makeArrayAsync<T>(length: number, fn: (i: number) => Promise<T>, offset = 0) {
1181
- return Promise.all(
1182
- Array(length)
1183
- .fill(0)
1184
- .map((_: any, i: number) => fn(i + offset)),
1185
- );
1182
+ return Promise.all(times(length, (i: number) => fn(i + offset)));
1186
1183
  }
1187
1184
 
1188
1185
  export function makeVector<T extends Bufferable>(length: number, fn: (i: number) => T, offset = 0) {
@@ -1253,7 +1250,7 @@ export async function makeContractInstanceFromClassId(
1253
1250
 
1254
1251
  export function makeAvmGetSiblingPathHint(seed = 0): AvmGetSiblingPathHint {
1255
1252
  // We want a possibly large index, but non-random.
1256
- const index = BigInt(`0x${sha256(Buffer.from(seed.toString())).toString('hex')}`) % (1n << 64n);
1253
+ const index = BigInt(bufferToHex(sha256(Buffer.from(seed.toString())))) % (1n << 64n);
1257
1254
  return new AvmGetSiblingPathHint(
1258
1255
  makeAppendOnlyTreeSnapshot(seed),
1259
1256
  /*treeId=*/ (seed + 1) % 5,
@@ -1264,8 +1261,8 @@ export function makeAvmGetSiblingPathHint(seed = 0): AvmGetSiblingPathHint {
1264
1261
 
1265
1262
  export function makeAvmGetPreviousValueIndexHint(seed = 0): AvmGetPreviousValueIndexHint {
1266
1263
  // We want a possibly large index, but non-random.
1267
- const index = BigInt(`0x${sha256(Buffer.from(seed.toString())).toString('hex')}`) % (1n << 64n);
1268
- const value = new Fr(BigInt(`0x${sha256(Buffer.from((seed + 2).toString())).toString('hex')}`) % (1n << 128n));
1264
+ const index = BigInt(bufferToHex(sha256(Buffer.from(seed.toString())))) % (1n << 64n);
1265
+ const value = new Fr(BigInt(bufferToHex(sha256(Buffer.from((seed + 2).toString())))) % (1n << 128n));
1269
1266
  return new AvmGetPreviousValueIndexHint(
1270
1267
  makeAppendOnlyTreeSnapshot(seed),
1271
1268
  /*treeId=*/ (seed + 1) % 5,
@@ -1277,7 +1274,7 @@ export function makeAvmGetPreviousValueIndexHint(seed = 0): AvmGetPreviousValueI
1277
1274
 
1278
1275
  export function makeAvmGetLeafPreimageHintPublicDataTree(seed = 0): AvmGetLeafPreimageHintPublicDataTree {
1279
1276
  // We want a possibly large index, but non-random.
1280
- const index = BigInt(`0x${sha256(Buffer.from(seed.toString())).toString('hex')}`) % (1n << 64n);
1277
+ const index = BigInt(bufferToHex(sha256(Buffer.from(seed.toString())))) % (1n << 64n);
1281
1278
  return new AvmGetLeafPreimageHintPublicDataTree(
1282
1279
  makeAppendOnlyTreeSnapshot(seed),
1283
1280
  /*index=*/ index,
@@ -1287,7 +1284,7 @@ export function makeAvmGetLeafPreimageHintPublicDataTree(seed = 0): AvmGetLeafPr
1287
1284
 
1288
1285
  export function makeAvmGetLeafPreimageHintNullifierTree(seed = 0): AvmGetLeafPreimageHintNullifierTree {
1289
1286
  // We want a possibly large index, but non-random.
1290
- const index = BigInt(`0x${sha256(Buffer.from(seed.toString())).toString('hex')}`) % (1n << 64n);
1287
+ const index = BigInt(bufferToHex(sha256(Buffer.from(seed.toString())))) % (1n << 64n);
1291
1288
  return new AvmGetLeafPreimageHintNullifierTree(
1292
1289
  makeAppendOnlyTreeSnapshot(seed),
1293
1290
  /*index=*/ index,
@@ -1297,7 +1294,7 @@ export function makeAvmGetLeafPreimageHintNullifierTree(seed = 0): AvmGetLeafPre
1297
1294
 
1298
1295
  export function makeAvmGetLeafValueHint(seed = 0): AvmGetLeafValueHint {
1299
1296
  // We want a possibly large index, but non-random.
1300
- const index = BigInt(`0x${sha256(Buffer.from(seed.toString())).toString('hex')}`) % (1n << 64n);
1297
+ const index = BigInt(bufferToHex(sha256(Buffer.from(seed.toString())))) % (1n << 64n);
1301
1298
  return new AvmGetLeafValueHint(
1302
1299
  makeAppendOnlyTreeSnapshot(seed),
1303
1300
  /*treeId=*/ (seed + 1) % 5,
@@ -416,7 +416,7 @@ export const mockSimulatedTx = async (seed = 1) => {
416
416
  };
417
417
 
418
418
  export function mockL1ToL2Messages(numL1ToL2Messages: number): Fr[] {
419
- return Array.from({ length: numL1ToL2Messages }, () => Fr.random());
419
+ return times(numL1ToL2Messages, () => Fr.random());
420
420
  }
421
421
 
422
422
  export async function mockCheckpointAndMessages(
@@ -1,3 +1,5 @@
1
+ import { compactArray } from '@aztec-labs/foundation/collection';
2
+
1
3
  import type { FunctionCall } from '../abi/function_call.js';
2
4
  import type { AuthWitness } from '../auth_witness/auth_witness.js';
3
5
  import { AztecAddress } from '../aztec-address/index.js';
@@ -41,12 +43,7 @@ export function mergeExecutionPayloads(requests: ExecutionPayload[]): ExecutionP
41
43
  const combinedExtraHashedArgs = requests.map(r => r.extraHashedArgs ?? []).flat();
42
44
 
43
45
  // Collect unique fee payers
44
- const uniqueFeePayers = new Set(
45
- requests
46
- .map(r => r.feePayer)
47
- .filter((fp): fp is AztecAddress => fp !== undefined)
48
- .map(fp => fp.toString()),
49
- );
46
+ const uniqueFeePayers = new Set(compactArray(requests.map(r => r.feePayer)).map(fp => fp.toString()));
50
47
 
51
48
  if (uniqueFeePayers.size > 1) {
52
49
  throw new Error(
@@ -18,6 +18,7 @@ import {
18
18
  MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX,
19
19
  } from '@aztec-labs/constants';
20
20
  import { type FieldsOf, makeTuple, makeTupleAsync } from '@aztec-labs/foundation/array';
21
+ import { times } from '@aztec-labs/foundation/collection';
21
22
  import { poseidon2HashWithSeparator } from '@aztec-labs/foundation/crypto/poseidon';
22
23
  import { randomInt } from '@aztec-labs/foundation/crypto/random';
23
24
  import { Fr } from '@aztec-labs/foundation/curves/bn254';
@@ -227,7 +228,7 @@ export class TxEffect {
227
228
  makeTuple(count(MAX_L2_TO_L1_MSGS_PER_TX, numL2ToL1Msgs), Fr.random),
228
229
  makeTuple(count(MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, numPublicDataWrites), PublicDataWrite.random),
229
230
  makeTuple(count(MAX_PRIVATE_LOGS_PER_TX, numPrivateLogs), () => PrivateLog.random()),
230
- await Promise.all(new Array(numPublicCallsPerTx * numPublicLogsPerCall).fill(null).map(() => PublicLog.random())),
231
+ await Promise.all(times(numPublicCallsPerTx * numPublicLogsPerCall, () => PublicLog.random())),
231
232
  await makeTupleAsync(count(MAX_CONTRACT_CLASS_LOGS_PER_TX, numContractClassLogs), ContractClassLog.random),
232
233
  );
233
234
  }
@@ -11,6 +11,8 @@ export const TX_ERROR_SETUP_FUNCTION_UNKNOWN_CONTRACT = 'Setup function targets
11
11
  export const TX_ERROR_SETUP_ONLY_SELF_WRONG_SENDER = 'Setup only_self function called with incorrect msg_sender';
12
12
  export const TX_ERROR_SETUP_NULL_MSG_SENDER = 'Setup function called with null msg sender';
13
13
  export const TX_ERROR_SETUP_WRONG_CALLDATA_LENGTH = 'Setup function called with wrong calldata length';
14
+ export const TX_ERROR_SETUP_STATIC_CALL = 'Static setup calls are not allowed';
15
+ export const TX_ERROR_SETUP_INSUFFICIENT_GAS = 'Gas limits leave setup less gas than its allowed functions need';
14
16
 
15
17
  // Nullifiers
16
18
  export const TX_ERROR_DUPLICATE_NULLIFIER_IN_TX = 'Duplicate nullifier in tx';
@@ -1,8 +1,9 @@
1
1
  import { Buffer32 } from '@aztec-labs/foundation/buffer';
2
+ import { times } from '@aztec-labs/foundation/collection';
2
3
  import { randomBytes } from '@aztec-labs/foundation/crypto/random';
3
4
  import { Fr } from '@aztec-labs/foundation/curves/bn254';
4
5
  import { BufferReader, serializeToBuffer } from '@aztec-labs/foundation/serialize';
5
- import { withoutHexPrefix } from '@aztec-labs/foundation/string';
6
+ import { bufferToHex, withoutHexPrefix } from '@aztec-labs/foundation/string';
6
7
  import { Buffer } from 'buffer';
7
8
 
8
9
  export type ViemZkPassportProofParams = {
@@ -57,7 +58,7 @@ export class ZkPassportProofParams {
57
58
  const committedInputs = randomBytes(Number(numberOfCommittedInputs) * 32);
58
59
 
59
60
  const publicInputsCount = numberOfCommittedInputs + 16n;
60
- const publicInputs = Array.from({ length: Number(publicInputsCount) }, () => Fr.random());
61
+ const publicInputs = times(Number(publicInputsCount), () => Fr.random());
61
62
 
62
63
  return new ZkPassportProofParams(
63
64
  false,
@@ -104,10 +105,10 @@ export class ZkPassportProofParams {
104
105
  version: '0x0000000000000000000000000000000000000000000000000000000000000000',
105
106
  proofVerificationData: {
106
107
  vkeyHash: this.vkeyHash.toString(),
107
- proof: `0x${this.proof.toString('hex')}`,
108
+ proof: bufferToHex(this.proof),
108
109
  publicInputs: this.publicInputs.map(input => input.toString()),
109
110
  },
110
- committedInputs: `0x${this.committedInputs.toString('hex')}`,
111
+ committedInputs: bufferToHex(this.committedInputs),
111
112
  serviceConfig: {
112
113
  devMode: this.devMode,
113
114
  validityPeriodInSeconds: this.validityPeriodInSeconds,