@aztec/stdlib 0.77.0-testnet-ignition.17 → 0.77.0-testnet-ignition.21

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 (56) hide show
  1. package/dest/avm/avm.d.ts +3559 -414
  2. package/dest/avm/avm.d.ts.map +1 -1
  3. package/dest/avm/avm.js +117 -662
  4. package/dest/avm/avm_accumulated_data.d.ts +94 -0
  5. package/dest/avm/avm_accumulated_data.d.ts.map +1 -1
  6. package/dest/avm/avm_accumulated_data.js +12 -1
  7. package/dest/avm/avm_circuit_public_inputs.d.ts +1023 -0
  8. package/dest/avm/avm_circuit_public_inputs.d.ts.map +1 -1
  9. package/dest/avm/avm_circuit_public_inputs.js +30 -1
  10. package/dest/avm/avm_proving_request.d.ts +2567 -2
  11. package/dest/avm/avm_proving_request.d.ts.map +1 -1
  12. package/dest/avm/message_pack.d.ts +4 -0
  13. package/dest/avm/message_pack.d.ts.map +1 -0
  14. package/dest/avm/message_pack.js +47 -0
  15. package/dest/block/l2_block_source.d.ts +17 -0
  16. package/dest/block/l2_block_source.d.ts.map +1 -1
  17. package/dest/block/l2_block_source.js +4 -0
  18. package/dest/interfaces/proving-job.d.ts +2567 -2
  19. package/dest/interfaces/proving-job.d.ts.map +1 -1
  20. package/dest/kernel/private_to_avm_accumulated_data.d.ts +85 -0
  21. package/dest/kernel/private_to_avm_accumulated_data.d.ts.map +1 -1
  22. package/dest/kernel/private_to_avm_accumulated_data.js +17 -1
  23. package/dest/kernel/public_call_request.d.ts +26 -0
  24. package/dest/kernel/public_call_request.d.ts.map +1 -1
  25. package/dest/kernel/public_call_request.js +13 -0
  26. package/dest/messaging/l2_to_l1_message.d.ts +55 -0
  27. package/dest/messaging/l2_to_l1_message.d.ts.map +1 -1
  28. package/dest/messaging/l2_to_l1_message.js +15 -0
  29. package/dest/p2p/consensus_payload.d.ts.map +1 -1
  30. package/dest/p2p/consensus_payload.js +2 -1
  31. package/dest/tests/factories.d.ts +4 -4
  32. package/dest/tests/factories.d.ts.map +1 -1
  33. package/dest/tests/factories.js +20 -19
  34. package/dest/trees/nullifier_membership_witness.d.ts +7 -7
  35. package/dest/trees/public_data_witness.d.ts +7 -7
  36. package/dest/tx/private_execution_result.js +1 -1
  37. package/dest/tx/processed_tx.d.ts +4 -0
  38. package/dest/tx/processed_tx.d.ts.map +1 -1
  39. package/dest/tx/processed_tx.js +2 -0
  40. package/dest/tx/tree_snapshots.d.ts +94 -0
  41. package/dest/tx/tree_snapshots.d.ts.map +1 -1
  42. package/dest/tx/tree_snapshots.js +9 -0
  43. package/package.json +6 -6
  44. package/src/avm/avm.ts +208 -906
  45. package/src/avm/avm_accumulated_data.ts +27 -1
  46. package/src/avm/avm_circuit_public_inputs.ts +73 -1
  47. package/src/avm/message_pack.ts +48 -0
  48. package/src/block/l2_block_source.ts +18 -0
  49. package/src/kernel/private_to_avm_accumulated_data.ts +33 -0
  50. package/src/kernel/public_call_request.ts +16 -0
  51. package/src/messaging/l2_to_l1_message.ts +22 -0
  52. package/src/p2p/consensus_payload.ts +2 -1
  53. package/src/tests/factories.ts +38 -28
  54. package/src/tx/private_execution_result.ts +1 -1
  55. package/src/tx/processed_tx.ts +6 -0
  56. package/src/tx/tree_snapshots.ts +15 -0
@@ -8,10 +8,12 @@ import {
8
8
  import { makeTuple } from '@aztec/foundation/array';
9
9
  import { arraySerializedSizeOfNonEmpty } from '@aztec/foundation/collection';
10
10
  import { Fr } from '@aztec/foundation/fields';
11
- import { BufferReader, FieldReader, type Tuple, serializeToBuffer } from '@aztec/foundation/serialize';
11
+ import { schemas } from '@aztec/foundation/schemas';
12
+ import { BufferReader, FieldReader, type Tuple, assertLength, serializeToBuffer } from '@aztec/foundation/serialize';
12
13
  import { bufferToHex, hexToBuffer } from '@aztec/foundation/string';
13
14
 
14
15
  import { inspect } from 'util';
16
+ import { z } from 'zod';
15
17
 
16
18
  import { PublicLog } from '../logs/public_log.js';
17
19
  import { ScopedL2ToL1Message } from '../messaging/l2_to_l1_message.js';
@@ -41,6 +43,30 @@ export class AvmAccumulatedData {
41
43
  public publicDataWrites: Tuple<PublicDataWrite, typeof MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX>,
42
44
  ) {}
43
45
 
46
+ static get schema() {
47
+ return z
48
+ .object({
49
+ noteHashes: schemas.Fr.array().min(MAX_NOTE_HASHES_PER_TX).max(MAX_NOTE_HASHES_PER_TX),
50
+ nullifiers: schemas.Fr.array().min(MAX_NULLIFIERS_PER_TX).max(MAX_NULLIFIERS_PER_TX),
51
+ l2ToL1Msgs: ScopedL2ToL1Message.schema.array().min(MAX_L2_TO_L1_MSGS_PER_TX).max(MAX_L2_TO_L1_MSGS_PER_TX),
52
+ publicLogs: PublicLog.schema.array().min(MAX_PUBLIC_LOGS_PER_TX).max(MAX_PUBLIC_LOGS_PER_TX),
53
+ publicDataWrites: PublicDataWrite.schema
54
+ .array()
55
+ .min(MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX)
56
+ .max(MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX),
57
+ })
58
+ .transform(
59
+ ({ noteHashes, nullifiers, l2ToL1Msgs, publicLogs, publicDataWrites }) =>
60
+ new AvmAccumulatedData(
61
+ assertLength(noteHashes, MAX_NOTE_HASHES_PER_TX),
62
+ assertLength(nullifiers, MAX_NULLIFIERS_PER_TX),
63
+ assertLength(l2ToL1Msgs, MAX_L2_TO_L1_MSGS_PER_TX),
64
+ assertLength(publicLogs, MAX_PUBLIC_LOGS_PER_TX),
65
+ assertLength(publicDataWrites, MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX),
66
+ ),
67
+ );
68
+ }
69
+
44
70
  getSize() {
45
71
  return (
46
72
  arraySerializedSizeOfNonEmpty(this.noteHashes) +
@@ -1,10 +1,12 @@
1
1
  import { MAX_ENQUEUED_CALLS_PER_TX } from '@aztec/constants';
2
2
  import { makeTuple } from '@aztec/foundation/array';
3
3
  import { Fr } from '@aztec/foundation/fields';
4
- import { BufferReader, FieldReader, type Tuple, serializeToBuffer } from '@aztec/foundation/serialize';
4
+ import { schemas } from '@aztec/foundation/schemas';
5
+ import { BufferReader, FieldReader, type Tuple, assertLength, serializeToBuffer } from '@aztec/foundation/serialize';
5
6
  import { bufferToHex, hexToBuffer } from '@aztec/foundation/string';
6
7
 
7
8
  import { inspect } from 'util';
9
+ import { z } from 'zod';
8
10
 
9
11
  import { AztecAddress } from '../aztec-address/index.js';
10
12
  import { Gas, GasSettings } from '../gas/index.js';
@@ -16,7 +18,10 @@ import { PublicCallRequest } from '../kernel/public_call_request.js';
16
18
  import { GlobalVariables } from '../tx/global_variables.js';
17
19
  import { TreeSnapshots } from '../tx/tree_snapshots.js';
18
20
  import { AvmAccumulatedData } from './avm_accumulated_data.js';
21
+ import { serializeWithMessagePack } from './message_pack.js';
19
22
 
23
+ // Note: the {from,to}{Buffer,Fields,String} methods are needed by AvmProofData and PublicBaseRollupInputs.
24
+ // At some point it might be worth writing Zod schemas for all dependent types and get rid of that.
20
25
  export class AvmCircuitPublicInputs {
21
26
  constructor(
22
27
  public globalVariables: GlobalVariables,
@@ -38,6 +43,69 @@ export class AvmCircuitPublicInputs {
38
43
  public reverted: boolean,
39
44
  ) {}
40
45
 
46
+ static get schema() {
47
+ return z
48
+ .object({
49
+ globalVariables: GlobalVariables.schema,
50
+ startTreeSnapshots: TreeSnapshots.schema,
51
+ startGasUsed: Gas.schema,
52
+ gasSettings: GasSettings.schema,
53
+ feePayer: AztecAddress.schema,
54
+ publicSetupCallRequests: PublicCallRequest.schema.array().max(MAX_ENQUEUED_CALLS_PER_TX),
55
+ publicAppLogicCallRequests: PublicCallRequest.schema.array().max(MAX_ENQUEUED_CALLS_PER_TX),
56
+ publicTeardownCallRequest: PublicCallRequest.schema,
57
+ previousNonRevertibleAccumulatedDataArrayLengths: PrivateToAvmAccumulatedDataArrayLengths.schema,
58
+ previousRevertibleAccumulatedDataArrayLengths: PrivateToAvmAccumulatedDataArrayLengths.schema,
59
+ previousNonRevertibleAccumulatedData: PrivateToAvmAccumulatedData.schema,
60
+ previousRevertibleAccumulatedData: PrivateToAvmAccumulatedData.schema,
61
+ endTreeSnapshots: TreeSnapshots.schema,
62
+ endGasUsed: Gas.schema,
63
+ accumulatedData: AvmAccumulatedData.schema,
64
+ transactionFee: schemas.Fr,
65
+ reverted: z.boolean(),
66
+ })
67
+ .transform(
68
+ ({
69
+ globalVariables,
70
+ startTreeSnapshots,
71
+ startGasUsed,
72
+ gasSettings,
73
+ feePayer,
74
+ publicSetupCallRequests,
75
+ publicAppLogicCallRequests,
76
+ publicTeardownCallRequest,
77
+ previousNonRevertibleAccumulatedDataArrayLengths,
78
+ previousRevertibleAccumulatedDataArrayLengths,
79
+ previousNonRevertibleAccumulatedData,
80
+ previousRevertibleAccumulatedData,
81
+ endTreeSnapshots,
82
+ endGasUsed,
83
+ accumulatedData,
84
+ transactionFee,
85
+ reverted,
86
+ }) =>
87
+ new AvmCircuitPublicInputs(
88
+ globalVariables,
89
+ startTreeSnapshots,
90
+ startGasUsed,
91
+ gasSettings,
92
+ feePayer,
93
+ assertLength(publicSetupCallRequests, MAX_ENQUEUED_CALLS_PER_TX),
94
+ assertLength(publicAppLogicCallRequests, MAX_ENQUEUED_CALLS_PER_TX),
95
+ publicTeardownCallRequest,
96
+ previousNonRevertibleAccumulatedDataArrayLengths,
97
+ previousRevertibleAccumulatedDataArrayLengths,
98
+ previousNonRevertibleAccumulatedData,
99
+ previousRevertibleAccumulatedData,
100
+ endTreeSnapshots,
101
+ endGasUsed,
102
+ accumulatedData,
103
+ transactionFee,
104
+ reverted,
105
+ ),
106
+ );
107
+ }
108
+
41
109
  static fromBuffer(buffer: Buffer | BufferReader) {
42
110
  const reader = BufferReader.asReader(buffer);
43
111
  return new AvmCircuitPublicInputs(
@@ -136,6 +204,10 @@ export class AvmCircuitPublicInputs {
136
204
  );
137
205
  }
138
206
 
207
+ public serializeWithMessagePack(): Buffer {
208
+ return serializeWithMessagePack(this);
209
+ }
210
+
139
211
  [inspect.custom]() {
140
212
  return `AvmCircuitPublicInputs {
141
213
  globalVariables: ${inspect(this.globalVariables)},
@@ -0,0 +1,48 @@
1
+ import { Fq, Fr, Point } from '@aztec/foundation/fields';
2
+
3
+ import { strict as assert } from 'assert';
4
+ import { Encoder, addExtension } from 'msgpackr';
5
+
6
+ import { AztecAddress } from '../aztec-address/index.js';
7
+
8
+ export function serializeWithMessagePack(obj: any): Buffer {
9
+ setUpMessagePackExtensions();
10
+ const encoder = new Encoder({
11
+ // always encode JS objects as MessagePack maps
12
+ // this makes it compatible with other MessagePack decoders
13
+ useRecords: false,
14
+ int64AsType: 'bigint',
15
+ });
16
+ return encoder.encode(obj);
17
+ }
18
+
19
+ let messagePackWasSetUp = false;
20
+ function setUpMessagePackExtensions() {
21
+ if (messagePackWasSetUp) {
22
+ return;
23
+ }
24
+ // C++ Fr and Fq classes work well with the buffer serialization.
25
+ addExtension({
26
+ Class: Fr,
27
+ write: (fr: Fr) => fr.toBuffer(),
28
+ });
29
+ addExtension({
30
+ Class: Fq,
31
+ write: (fq: Fq) => fq.toBuffer(),
32
+ });
33
+ // AztecAddress is a class that has a field in TS, but just a field in C++.
34
+ addExtension({
35
+ Class: AztecAddress,
36
+ write: (addr: AztecAddress) => addr.toField(),
37
+ });
38
+ // Affine points are a mess, we do our best.
39
+ addExtension({
40
+ Class: Point,
41
+ write: (p: Point) => {
42
+ assert(!p.inf, 'Cannot serialize infinity');
43
+ // TODO: should these be Frs?
44
+ return { x: new Fq(p.x.toBigInt()), y: new Fq(p.y.toBigInt()) };
45
+ },
46
+ });
47
+ messagePackWasSetUp = true;
48
+ }
@@ -1,5 +1,6 @@
1
1
  import type { EthAddress } from '@aztec/foundation/eth-address';
2
2
 
3
+ import type { EventEmitter } from 'events';
3
4
  import { z } from 'zod';
4
5
 
5
6
  import type { L1RollupConstants } from '../epoch-helpers/index.js';
@@ -115,6 +116,12 @@ export interface L2BlockSource {
115
116
  getL1Constants(): Promise<L1RollupConstants>;
116
117
  }
117
118
 
119
+ /**
120
+ * L2BlockSource that emits events upon pending / proven chain changes.
121
+ * see L2BlockSourceEvents for the events emitted.
122
+ */
123
+ export interface L2BlockSourceEventEmitter extends L2BlockSource, EventEmitter {}
124
+
118
125
  /**
119
126
  * Identifier for L2 block tags.
120
127
  * - latest: Latest block pushed to L1.
@@ -146,3 +153,14 @@ export const L2TipsSchema = z.object({
146
153
  proven: L2BlockIdSchema,
147
154
  finalized: L2BlockIdSchema,
148
155
  }) satisfies z.ZodType<L2Tips>;
156
+
157
+ export enum L2BlockSourceEvents {
158
+ L2PruneDetected = 'l2PruneDetected',
159
+ }
160
+
161
+ export type L2BlockSourceEvent = {
162
+ type: 'l2PruneDetected';
163
+ blockNumber: bigint;
164
+ slotNumber: bigint;
165
+ epochNumber: bigint;
166
+ };
@@ -7,15 +7,18 @@ import {
7
7
  import { type FieldsOf, makeTuple } from '@aztec/foundation/array';
8
8
  import { arraySerializedSizeOfNonEmpty } from '@aztec/foundation/collection';
9
9
  import { Fr } from '@aztec/foundation/fields';
10
+ import { schemas } from '@aztec/foundation/schemas';
10
11
  import {
11
12
  BufferReader,
12
13
  FieldReader,
13
14
  type Tuple,
15
+ assertLength,
14
16
  serializeToBuffer,
15
17
  serializeToFields,
16
18
  } from '@aztec/foundation/serialize';
17
19
 
18
20
  import { inspect } from 'util';
21
+ import { z } from 'zod';
19
22
 
20
23
  import { ScopedL2ToL1Message } from '../messaging/l2_to_l1_message.js';
21
24
  import type { UInt32 } from '../types/shared.js';
@@ -27,6 +30,23 @@ export class PrivateToAvmAccumulatedData {
27
30
  public l2ToL1Msgs: Tuple<ScopedL2ToL1Message, typeof MAX_L2_TO_L1_MSGS_PER_TX>,
28
31
  ) {}
29
32
 
33
+ static get schema() {
34
+ return z
35
+ .object({
36
+ noteHashes: schemas.Fr.array().min(MAX_NOTE_HASHES_PER_TX).max(MAX_NOTE_HASHES_PER_TX),
37
+ nullifiers: schemas.Fr.array().min(MAX_NULLIFIERS_PER_TX).max(MAX_NULLIFIERS_PER_TX),
38
+ l2ToL1Msgs: ScopedL2ToL1Message.schema.array().min(MAX_L2_TO_L1_MSGS_PER_TX).max(MAX_L2_TO_L1_MSGS_PER_TX),
39
+ })
40
+ .transform(
41
+ ({ noteHashes, nullifiers, l2ToL1Msgs }) =>
42
+ new PrivateToAvmAccumulatedData(
43
+ assertLength(noteHashes, MAX_NOTE_HASHES_PER_TX),
44
+ assertLength(nullifiers, MAX_NULLIFIERS_PER_TX),
45
+ assertLength(l2ToL1Msgs, MAX_L2_TO_L1_MSGS_PER_TX),
46
+ ),
47
+ );
48
+ }
49
+
30
50
  getSize() {
31
51
  return (
32
52
  arraySerializedSizeOfNonEmpty(this.noteHashes) +
@@ -104,6 +124,19 @@ export class PrivateToAvmAccumulatedData {
104
124
  export class PrivateToAvmAccumulatedDataArrayLengths {
105
125
  constructor(public noteHashes: UInt32, public nullifiers: UInt32, public l2ToL1Msgs: UInt32) {}
106
126
 
127
+ static get schema() {
128
+ return z
129
+ .object({
130
+ noteHashes: schemas.UInt32,
131
+ nullifiers: schemas.UInt32,
132
+ l2ToL1Msgs: schemas.UInt32,
133
+ })
134
+ .transform(
135
+ ({ noteHashes, nullifiers, l2ToL1Msgs }) =>
136
+ new PrivateToAvmAccumulatedDataArrayLengths(noteHashes, nullifiers, l2ToL1Msgs),
137
+ );
138
+ }
139
+
107
140
  getSize() {
108
141
  return 4 * 3;
109
142
  }
@@ -1,9 +1,11 @@
1
1
  import { COUNTED_PUBLIC_CALL_REQUEST_LENGTH, PUBLIC_CALL_REQUEST_LENGTH } from '@aztec/constants';
2
2
  import { Fr } from '@aztec/foundation/fields';
3
+ import { schemas } from '@aztec/foundation/schemas';
3
4
  import { BufferReader, FieldReader, serializeToBuffer, serializeToFields } from '@aztec/foundation/serialize';
4
5
  import type { FieldsOf } from '@aztec/foundation/types';
5
6
 
6
7
  import { inspect } from 'util';
8
+ import { z } from 'zod';
7
9
 
8
10
  import { FunctionSelector } from '../abi/index.js';
9
11
  import { AztecAddress } from '../aztec-address/index.js';
@@ -33,6 +35,20 @@ export class PublicCallRequest {
33
35
  public argsHash: Fr,
34
36
  ) {}
35
37
 
38
+ static get schema() {
39
+ return z
40
+ .object({
41
+ msgSender: AztecAddress.schema,
42
+ contractAddress: AztecAddress.schema,
43
+ functionSelector: FunctionSelector.schema,
44
+ isStaticCall: z.boolean(),
45
+ argsHash: schemas.Fr,
46
+ })
47
+ .transform(({ msgSender, contractAddress, functionSelector, isStaticCall, argsHash }) => {
48
+ return new PublicCallRequest(msgSender, contractAddress, functionSelector, isStaticCall, argsHash);
49
+ });
50
+ }
51
+
36
52
  getSize() {
37
53
  return this.isEmpty() ? 0 : this.toBuffer().length;
38
54
  }
@@ -1,14 +1,27 @@
1
1
  import { L2_TO_L1_MESSAGE_LENGTH, SCOPED_L2_TO_L1_MESSAGE_LENGTH } from '@aztec/constants';
2
2
  import { EthAddress } from '@aztec/foundation/eth-address';
3
3
  import { Fr } from '@aztec/foundation/fields';
4
+ import { schemas } from '@aztec/foundation/schemas';
4
5
  import { BufferReader, FieldReader, serializeToBuffer, serializeToFields } from '@aztec/foundation/serialize';
5
6
  import type { FieldsOf } from '@aztec/foundation/types';
6
7
 
8
+ import { z } from 'zod';
9
+
7
10
  import { AztecAddress } from '../aztec-address/index.js';
8
11
 
9
12
  export class L2ToL1Message {
10
13
  constructor(public recipient: EthAddress, public content: Fr, public counter: number) {}
11
14
 
15
+ static get schema() {
16
+ return z
17
+ .object({
18
+ recipient: schemas.EthAddress,
19
+ content: schemas.Fr,
20
+ counter: z.number(),
21
+ })
22
+ .transform(({ recipient, content, counter }) => new L2ToL1Message(recipient, content, counter));
23
+ }
24
+
12
25
  /**
13
26
  * Creates an empty L2ToL1Message with default values.
14
27
  * @returns An instance of L2ToL1Message with empty fields.
@@ -86,6 +99,15 @@ export class L2ToL1Message {
86
99
  export class ScopedL2ToL1Message {
87
100
  constructor(public message: L2ToL1Message, public contractAddress: AztecAddress) {}
88
101
 
102
+ static get schema() {
103
+ return z
104
+ .object({
105
+ message: L2ToL1Message.schema,
106
+ contractAddress: AztecAddress.schema,
107
+ })
108
+ .transform(({ message, contractAddress }) => new ScopedL2ToL1Message(message, contractAddress));
109
+ }
110
+
89
111
  static getFields(fields: FieldsOf<ScopedL2ToL1Message>) {
90
112
  return [fields.message, fields.contractAddress] as const;
91
113
  }
@@ -1,4 +1,5 @@
1
1
  import { Fr } from '@aztec/foundation/fields';
2
+ import { schemas } from '@aztec/foundation/schemas';
2
3
  import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
3
4
  import { hexToBuffer } from '@aztec/foundation/string';
4
5
  import type { FieldsOf } from '@aztec/foundation/types';
@@ -26,7 +27,7 @@ export class ConsensusPayload implements Signable {
26
27
  return z
27
28
  .object({
28
29
  header: BlockHeader.schema,
29
- archive: Fr.schema,
30
+ archive: schemas.Fr,
30
31
  txHashes: z.array(TxHash.schema),
31
32
  })
32
33
  .transform(obj => new ConsensusPayload(obj.header, obj.archive, obj.txHashes));
@@ -1209,11 +1209,11 @@ function makeContractClassPrivateFunction(seed = 0): PrivateFunction {
1209
1209
  };
1210
1210
  }
1211
1211
 
1212
- export function makeArray<T extends Bufferable>(length: number, fn: (i: number) => T, offset = 0) {
1212
+ export function makeArray<T>(length: number, fn: (i: number) => T, offset = 0) {
1213
1213
  return Array.from({ length }, (_: any, i: number) => fn(i + offset));
1214
1214
  }
1215
1215
 
1216
- export function makeArrayAsync<T extends Bufferable>(length: number, fn: (i: number) => Promise<T>, offset = 0) {
1216
+ export function makeArrayAsync<T>(length: number, fn: (i: number) => Promise<T>, offset = 0) {
1217
1217
  return Promise.all(
1218
1218
  Array(length)
1219
1219
  .fill(0)
@@ -1229,15 +1229,11 @@ export async function makeVectorAsync<T extends Bufferable>(length: number, fn:
1229
1229
  return new Vector(await makeArrayAsync(length, fn, offset));
1230
1230
  }
1231
1231
 
1232
- export function makeMap<T extends Bufferable>(size: number, fn: (i: number) => [string, T], offset = 0) {
1232
+ export function makeMap<T>(size: number, fn: (i: number) => [string, T], offset = 0) {
1233
1233
  return new Map(makeArray(size, i => fn(i + offset)));
1234
1234
  }
1235
1235
 
1236
- export async function makeMapAsync<T extends Bufferable>(
1237
- size: number,
1238
- fn: (i: number) => Promise<[string, T]>,
1239
- offset = 0,
1240
- ) {
1236
+ export async function makeMapAsync<T>(size: number, fn: (i: number) => Promise<[string, T]>, offset = 0) {
1241
1237
  return new Map(await makeArrayAsync(size, i => fn(i + offset)));
1242
1238
  }
1243
1239
 
@@ -1375,10 +1371,10 @@ export async function makeAvmContractClassHint(seed = 0): Promise<AvmContractCla
1375
1371
  }
1376
1372
 
1377
1373
  export function makeAvmEnqueuedCallHint(seed = 0): AvmEnqueuedCallHint {
1378
- return AvmEnqueuedCallHint.from({
1379
- contractAddress: new AztecAddress(new Fr(seed)),
1380
- calldata: makeVector((seed % 20) + 4, i => new Fr(i), seed + 0x1000),
1381
- });
1374
+ return new AvmEnqueuedCallHint(
1375
+ new AztecAddress(new Fr(seed)),
1376
+ makeArray((seed % 20) + 4, i => new Fr(i), seed + 0x1000),
1377
+ );
1382
1378
  }
1383
1379
 
1384
1380
  /**
@@ -1394,19 +1390,32 @@ export async function makeAvmExecutionHints(
1394
1390
  const lengthSeedMod = 10;
1395
1391
  const baseLength = lengthOffset + (seed % lengthSeedMod);
1396
1392
 
1397
- return AvmExecutionHints.from({
1398
- enqueuedCalls: makeVector(baseLength, makeAvmEnqueuedCallHint, seed + 0x4100),
1399
- contractInstances: makeVector(baseLength + 5, makeAvmContractInstanceHint, seed + 0x4700),
1400
- contractClasses: await makeVectorAsync(baseLength + 5, makeAvmContractClassHint, seed + 0x4900),
1401
- publicDataReads: makeVector(baseLength + 7, makeAvmStorageReadTreeHints, seed + 0x4900),
1402
- publicDataWrites: makeVector(baseLength + 8, makeAvmStorageUpdateTreeHints, seed + 0x4a00),
1403
- nullifierReads: makeVector(baseLength + 9, makeAvmNullifierReadTreeHints, seed + 0x4b00),
1404
- nullifierWrites: makeVector(baseLength + 10, makeAvmNullifierInsertionTreeHints, seed + 0x4c00),
1405
- noteHashReads: makeVector(baseLength + 11, makeAvmTreeHints, seed + 0x4d00),
1406
- noteHashWrites: makeVector(baseLength + 12, makeAvmTreeHints, seed + 0x4e00),
1407
- l1ToL2MessageReads: makeVector(baseLength + 13, makeAvmTreeHints, seed + 0x4f00),
1393
+ const fields = {
1394
+ enqueuedCalls: makeArray(baseLength, makeAvmEnqueuedCallHint, seed + 0x4100),
1395
+ contractInstances: makeArray(baseLength + 5, makeAvmContractInstanceHint, seed + 0x4700),
1396
+ contractClasses: await makeArrayAsync(baseLength + 5, makeAvmContractClassHint, seed + 0x4900),
1397
+ publicDataReads: makeArray(baseLength + 7, makeAvmStorageReadTreeHints, seed + 0x4900),
1398
+ publicDataWrites: makeArray(baseLength + 8, makeAvmStorageUpdateTreeHints, seed + 0x4a00),
1399
+ nullifierReads: makeArray(baseLength + 9, makeAvmNullifierReadTreeHints, seed + 0x4b00),
1400
+ nullifierWrites: makeArray(baseLength + 10, makeAvmNullifierInsertionTreeHints, seed + 0x4c00),
1401
+ noteHashReads: makeArray(baseLength + 11, makeAvmTreeHints, seed + 0x4d00),
1402
+ noteHashWrites: makeArray(baseLength + 12, makeAvmTreeHints, seed + 0x4e00),
1403
+ l1ToL2MessageReads: makeArray(baseLength + 13, makeAvmTreeHints, seed + 0x4f00),
1408
1404
  ...overrides,
1409
- });
1405
+ };
1406
+
1407
+ return new AvmExecutionHints(
1408
+ fields.enqueuedCalls,
1409
+ fields.contractInstances,
1410
+ fields.contractClasses,
1411
+ fields.publicDataReads,
1412
+ fields.publicDataWrites,
1413
+ fields.nullifierReads,
1414
+ fields.nullifierWrites,
1415
+ fields.noteHashReads,
1416
+ fields.noteHashWrites,
1417
+ fields.l1ToL2MessageReads,
1418
+ );
1410
1419
  }
1411
1420
 
1412
1421
  /**
@@ -1418,13 +1427,15 @@ export async function makeAvmCircuitInputs(
1418
1427
  seed = 0,
1419
1428
  overrides: Partial<FieldsOf<AvmCircuitInputs>> = {},
1420
1429
  ): Promise<AvmCircuitInputs> {
1421
- return AvmCircuitInputs.from({
1430
+ const fields = {
1422
1431
  functionName: `function${seed}`,
1423
1432
  calldata: makeArray((seed % 100) + 10, i => new Fr(i), seed + 0x1000),
1424
1433
  avmHints: await makeAvmExecutionHints(seed + 0x3000),
1425
1434
  publicInputs: makeAvmCircuitPublicInputs(seed + 0x4000),
1426
1435
  ...overrides,
1427
- });
1436
+ };
1437
+
1438
+ return new AvmCircuitInputs(fields.functionName, fields.calldata, fields.avmHints, fields.publicInputs);
1428
1439
  }
1429
1440
 
1430
1441
  /**
@@ -1525,8 +1536,7 @@ export async function makeBloatedProcessedTx({
1525
1536
  seed + 0x2000,
1526
1537
  );
1527
1538
 
1528
- const avmCircuitInputs = new AvmCircuitInputs('', [], AvmExecutionHints.empty(), avmOutput);
1529
-
1539
+ const avmCircuitInputs = await makeAvmCircuitInputs(seed + 0x3000, { publicInputs: avmOutput });
1530
1540
  const gasUsed = {
1531
1541
  totalGas: Gas.empty(),
1532
1542
  teardownGas: Gas.empty(),
@@ -103,7 +103,7 @@ export class PrivateExecutionResult {
103
103
  return z
104
104
  .object({
105
105
  entrypoint: PrivateCallExecutionResult.schema,
106
- firstNullifier: Fr.schema,
106
+ firstNullifier: schemas.Fr,
107
107
  })
108
108
  .transform(PrivateExecutionResult.from);
109
109
  }
@@ -54,6 +54,10 @@ export type ProcessedTx = {
54
54
  * Gas used by the entire transaction.
55
55
  */
56
56
  gasUsed: GasUsed;
57
+ /**
58
+ * Code the tx was reverted (or OK).
59
+ */
60
+ revertCode: RevertCode;
57
61
  /**
58
62
  * Reason the tx was reverted.
59
63
  */
@@ -114,6 +118,7 @@ export async function makeProcessedTxFromPrivateOnlyTx(
114
118
  constants,
115
119
  txEffect,
116
120
  gasUsed,
121
+ revertCode: RevertCode.OK,
117
122
  revertReason: undefined,
118
123
  };
119
124
  }
@@ -170,6 +175,7 @@ export async function makeProcessedTxFromTxWithPublicCalls(
170
175
  constants,
171
176
  txEffect,
172
177
  gasUsed,
178
+ revertCode,
173
179
  revertReason,
174
180
  };
175
181
  }
@@ -3,6 +3,7 @@ import type { Fr } from '@aztec/foundation/fields';
3
3
  import { BufferReader, FieldReader, serializeToBuffer } from '@aztec/foundation/serialize';
4
4
 
5
5
  import { inspect } from 'util';
6
+ import { z } from 'zod';
6
7
 
7
8
  import { AppendOnlyTreeSnapshot } from '../trees/append_only_tree_snapshot.js';
8
9
 
@@ -17,6 +18,20 @@ export class TreeSnapshots {
17
18
  public readonly publicDataTree: AppendOnlyTreeSnapshot,
18
19
  ) {}
19
20
 
21
+ static get schema() {
22
+ return z
23
+ .object({
24
+ l1ToL2MessageTree: AppendOnlyTreeSnapshot.schema,
25
+ noteHashTree: AppendOnlyTreeSnapshot.schema,
26
+ nullifierTree: AppendOnlyTreeSnapshot.schema,
27
+ publicDataTree: AppendOnlyTreeSnapshot.schema,
28
+ })
29
+ .transform(
30
+ ({ l1ToL2MessageTree, noteHashTree, nullifierTree, publicDataTree }) =>
31
+ new TreeSnapshots(l1ToL2MessageTree, noteHashTree, nullifierTree, publicDataTree),
32
+ );
33
+ }
34
+
20
35
  getSize() {
21
36
  return (
22
37
  this.l1ToL2MessageTree.getSize() +