@aztec/txe 0.0.1-commit.9b94fc1 → 0.0.1-commit.9badcec54

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 (78) hide show
  1. package/dest/constants.d.ts +3 -0
  2. package/dest/constants.d.ts.map +1 -0
  3. package/dest/constants.js +2 -0
  4. package/dest/index.d.ts +1 -1
  5. package/dest/index.d.ts.map +1 -1
  6. package/dest/index.js +91 -56
  7. package/dest/oracle/interfaces.d.ts +33 -29
  8. package/dest/oracle/interfaces.d.ts.map +1 -1
  9. package/dest/oracle/txe_oracle_public_context.d.ts +16 -16
  10. package/dest/oracle/txe_oracle_public_context.d.ts.map +1 -1
  11. package/dest/oracle/txe_oracle_public_context.js +20 -22
  12. package/dest/oracle/txe_oracle_top_level_context.d.ts +42 -27
  13. package/dest/oracle/txe_oracle_top_level_context.d.ts.map +1 -1
  14. package/dest/oracle/txe_oracle_top_level_context.js +232 -107
  15. package/dest/rpc_translator.d.ts +129 -79
  16. package/dest/rpc_translator.d.ts.map +1 -1
  17. package/dest/rpc_translator.js +465 -176
  18. package/dest/state_machine/archiver.d.ts +21 -52
  19. package/dest/state_machine/archiver.d.ts.map +1 -1
  20. package/dest/state_machine/archiver.js +67 -99
  21. package/dest/state_machine/dummy_p2p_client.d.ts +21 -15
  22. package/dest/state_machine/dummy_p2p_client.d.ts.map +1 -1
  23. package/dest/state_machine/dummy_p2p_client.js +45 -25
  24. package/dest/state_machine/global_variable_builder.d.ts +11 -5
  25. package/dest/state_machine/global_variable_builder.d.ts.map +1 -1
  26. package/dest/state_machine/global_variable_builder.js +21 -3
  27. package/dest/state_machine/index.d.ts +9 -7
  28. package/dest/state_machine/index.d.ts.map +1 -1
  29. package/dest/state_machine/index.js +45 -24
  30. package/dest/state_machine/mock_epoch_cache.d.ts +26 -8
  31. package/dest/state_machine/mock_epoch_cache.d.ts.map +1 -1
  32. package/dest/state_machine/mock_epoch_cache.js +49 -9
  33. package/dest/state_machine/synchronizer.d.ts +6 -5
  34. package/dest/state_machine/synchronizer.d.ts.map +1 -1
  35. package/dest/state_machine/synchronizer.js +8 -7
  36. package/dest/txe_session.d.ts +27 -15
  37. package/dest/txe_session.d.ts.map +1 -1
  38. package/dest/txe_session.js +173 -55
  39. package/dest/util/encoding.d.ts +688 -19
  40. package/dest/util/encoding.d.ts.map +1 -1
  41. package/dest/util/encoding.js +5 -1
  42. package/dest/util/txe_account_store.d.ts +10 -0
  43. package/dest/util/txe_account_store.d.ts.map +1 -0
  44. package/dest/util/{txe_account_data_provider.js → txe_account_store.js} +1 -1
  45. package/dest/util/txe_public_contract_data_source.d.ts +8 -8
  46. package/dest/util/txe_public_contract_data_source.d.ts.map +1 -1
  47. package/dest/util/txe_public_contract_data_source.js +13 -32
  48. package/dest/utils/block_creation.d.ts +21 -6
  49. package/dest/utils/block_creation.d.ts.map +1 -1
  50. package/dest/utils/block_creation.js +38 -4
  51. package/dest/utils/tx_effect_creation.d.ts +3 -3
  52. package/dest/utils/tx_effect_creation.d.ts.map +1 -1
  53. package/dest/utils/tx_effect_creation.js +4 -7
  54. package/package.json +18 -18
  55. package/src/constants.ts +3 -0
  56. package/src/index.ts +103 -63
  57. package/src/oracle/interfaces.ts +36 -32
  58. package/src/oracle/txe_oracle_public_context.ts +21 -28
  59. package/src/oracle/txe_oracle_top_level_context.ts +285 -149
  60. package/src/rpc_translator.ts +552 -193
  61. package/src/state_machine/archiver.ts +63 -117
  62. package/src/state_machine/dummy_p2p_client.ts +62 -33
  63. package/src/state_machine/global_variable_builder.ts +38 -6
  64. package/src/state_machine/index.ts +67 -22
  65. package/src/state_machine/mock_epoch_cache.ts +61 -14
  66. package/src/state_machine/synchronizer.ts +9 -8
  67. package/src/txe_session.ts +239 -104
  68. package/src/util/encoding.ts +6 -1
  69. package/src/util/{txe_account_data_provider.ts → txe_account_store.ts} +1 -1
  70. package/src/util/txe_public_contract_data_source.ts +20 -47
  71. package/src/utils/block_creation.ts +49 -15
  72. package/src/utils/tx_effect_creation.ts +5 -12
  73. package/dest/util/txe_account_data_provider.d.ts +0 -10
  74. package/dest/util/txe_account_data_provider.d.ts.map +0 -1
  75. package/dest/util/txe_contract_data_provider.d.ts +0 -12
  76. package/dest/util/txe_contract_data_provider.d.ts.map +0 -1
  77. package/dest/util/txe_contract_data_provider.js +0 -22
  78. package/src/util/txe_contract_data_provider.ts +0 -36
@@ -1,15 +1,15 @@
1
1
  import type { ContractInstanceWithAddress } from '@aztec/aztec.js/contracts';
2
2
  import { Fr, Point } from '@aztec/aztec.js/fields';
3
3
  import { MAX_NOTE_HASHES_PER_TX, MAX_NULLIFIERS_PER_TX } from '@aztec/constants';
4
+ import { BlockNumber } from '@aztec/foundation/branded-types';
4
5
  import {
5
6
  type IMiscOracle,
6
7
  type IPrivateExecutionOracle,
7
8
  type IUtilityExecutionOracle,
8
- packAsRetrievedNote,
9
+ packAsHintedNote,
9
10
  } from '@aztec/pxe/simulator';
10
- import { type ContractArtifact, FunctionSelector, NoteSelector } from '@aztec/stdlib/abi';
11
+ import { type ContractArtifact, EventSelector, FunctionSelector, NoteSelector } from '@aztec/stdlib/abi';
11
12
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
12
- import { MerkleTreeId } from '@aztec/stdlib/trees';
13
13
 
14
14
  import type { IAvmExecutionOracle, ITxeExecutionOracle } from './oracle/interfaces.js';
15
15
  import type { TXESessionStateHandler } from './txe_session.js';
@@ -19,6 +19,7 @@ import {
19
19
  addressFromSingle,
20
20
  arrayOfArraysToBoundedVecOfArrays,
21
21
  arrayToBoundedVec,
22
+ blockHashFromSingle,
22
23
  bufferToU8Array,
23
24
  fromArray,
24
25
  fromSingle,
@@ -29,6 +30,9 @@ import {
29
30
  toSingle,
30
31
  } from './util/encoding.js';
31
32
 
33
+ const MAX_EVENT_LEN = 10; // This is MAX_MESSAGE_CONTENT_LEN - PRIVATE_EVENT_MSG_PLAINTEXT_RESERVED_FIELDS_LEN
34
+ const MAX_PRIVATE_EVENTS_PER_TXE_QUERY = 5;
35
+
32
36
  export class UnavailableOracleError extends Error {
33
37
  constructor(oracleName: string) {
34
38
  super(`${oracleName} oracles not available with the current handler`);
@@ -100,13 +104,15 @@ export class RPCTranslator {
100
104
 
101
105
  // TXE session state transition functions - these get handled by the state handler
102
106
 
103
- async txeSetTopLevelTXEContext() {
107
+ // eslint-disable-next-line camelcase
108
+ async aztec_txe_setTopLevelTXEContext() {
104
109
  await this.stateHandler.enterTopLevelState();
105
110
 
106
111
  return toForeignCallResult([]);
107
112
  }
108
113
 
109
- async txeSetPrivateTXEContext(
114
+ // eslint-disable-next-line camelcase
115
+ async aztec_txe_setPrivateTXEContext(
110
116
  foreignContractAddressIsSome: ForeignCallSingle,
111
117
  foreignContractAddressValue: ForeignCallSingle,
112
118
  foreignAnchorBlockNumberIsSome: ForeignCallSingle,
@@ -117,7 +123,7 @@ export class RPCTranslator {
117
123
  : undefined;
118
124
 
119
125
  const anchorBlockNumber = fromSingle(foreignAnchorBlockNumberIsSome).toBool()
120
- ? fromSingle(foreignAnchorBlockNumberValue).toNumber()
126
+ ? BlockNumber(fromSingle(foreignAnchorBlockNumberValue).toNumber())
121
127
  : undefined;
122
128
 
123
129
  const privateContextInputs = await this.stateHandler.enterPrivateState(contractAddress, anchorBlockNumber);
@@ -125,7 +131,8 @@ export class RPCTranslator {
125
131
  return toForeignCallResult(privateContextInputs.toFields().map(toSingle));
126
132
  }
127
133
 
128
- async txeSetPublicTXEContext(
134
+ // eslint-disable-next-line camelcase
135
+ async aztec_txe_setPublicTXEContext(
129
136
  foreignContractAddressIsSome: ForeignCallSingle,
130
137
  foreignContractAddressValue: ForeignCallSingle,
131
138
  ) {
@@ -138,7 +145,8 @@ export class RPCTranslator {
138
145
  return toForeignCallResult([]);
139
146
  }
140
147
 
141
- async txeSetUtilityTXEContext(
148
+ // eslint-disable-next-line camelcase
149
+ async aztec_txe_setUtilityTXEContext(
142
150
  foreignContractAddressIsSome: ForeignCallSingle,
143
151
  foreignContractAddressValue: ForeignCallSingle,
144
152
  ) {
@@ -155,38 +163,54 @@ export class RPCTranslator {
155
163
 
156
164
  // TXE-specific oracles
157
165
 
158
- async txeGetNextBlockNumber() {
159
- const nextBlockNumber = await this.handlerAsTxe().txeGetNextBlockNumber();
166
+ // eslint-disable-next-line camelcase
167
+ aztec_txe_getDefaultAddress() {
168
+ const defaultAddress = this.handlerAsTxe().getDefaultAddress();
169
+
170
+ return toForeignCallResult([toSingle(defaultAddress)]);
171
+ }
172
+
173
+ // eslint-disable-next-line camelcase
174
+ async aztec_txe_getNextBlockNumber() {
175
+ const nextBlockNumber = await this.handlerAsTxe().getNextBlockNumber();
160
176
 
161
177
  return toForeignCallResult([toSingle(nextBlockNumber)]);
162
178
  }
163
179
 
164
- async txeGetNextBlockTimestamp() {
165
- const nextBlockTimestamp = await this.handlerAsTxe().txeGetNextBlockTimestamp();
180
+ // eslint-disable-next-line camelcase
181
+ async aztec_txe_getNextBlockTimestamp() {
182
+ const nextBlockTimestamp = await this.handlerAsTxe().getNextBlockTimestamp();
166
183
 
167
184
  return toForeignCallResult([toSingle(nextBlockTimestamp)]);
168
185
  }
169
186
 
170
- async txeAdvanceBlocksBy(foreignBlocks: ForeignCallSingle) {
187
+ // eslint-disable-next-line camelcase
188
+ async aztec_txe_advanceBlocksBy(foreignBlocks: ForeignCallSingle) {
171
189
  const blocks = fromSingle(foreignBlocks).toNumber();
172
190
 
173
- await this.handlerAsTxe().txeAdvanceBlocksBy(blocks);
191
+ await this.handlerAsTxe().advanceBlocksBy(blocks);
174
192
 
175
193
  return toForeignCallResult([]);
176
194
  }
177
195
 
178
- txeAdvanceTimestampBy(foreignDuration: ForeignCallSingle) {
196
+ // eslint-disable-next-line camelcase
197
+ aztec_txe_advanceTimestampBy(foreignDuration: ForeignCallSingle) {
179
198
  const duration = fromSingle(foreignDuration).toBigInt();
180
199
 
181
- this.handlerAsTxe().txeAdvanceTimestampBy(duration);
200
+ this.handlerAsTxe().advanceTimestampBy(duration);
182
201
 
183
202
  return toForeignCallResult([]);
184
203
  }
185
204
 
186
- async txeDeploy(artifact: ContractArtifact, instance: ContractInstanceWithAddress, foreignSecret: ForeignCallSingle) {
205
+ // eslint-disable-next-line camelcase
206
+ async aztec_txe_deploy(
207
+ artifact: ContractArtifact,
208
+ instance: ContractInstanceWithAddress,
209
+ foreignSecret: ForeignCallSingle,
210
+ ) {
187
211
  const secret = fromSingle(foreignSecret);
188
212
 
189
- await this.handlerAsTxe().txeDeploy(artifact, instance, secret);
213
+ await this.handlerAsTxe().deploy(artifact, instance, secret);
190
214
 
191
215
  return toForeignCallResult([
192
216
  toArray([
@@ -199,10 +223,11 @@ export class RPCTranslator {
199
223
  ]);
200
224
  }
201
225
 
202
- async txeCreateAccount(foreignSecret: ForeignCallSingle) {
226
+ // eslint-disable-next-line camelcase
227
+ async aztec_txe_createAccount(foreignSecret: ForeignCallSingle) {
203
228
  const secret = fromSingle(foreignSecret);
204
229
 
205
- const completeAddress = await this.handlerAsTxe().txeCreateAccount(secret);
230
+ const completeAddress = await this.handlerAsTxe().createAccount(secret);
206
231
 
207
232
  return toForeignCallResult([
208
233
  toSingle(completeAddress.address),
@@ -210,14 +235,15 @@ export class RPCTranslator {
210
235
  ]);
211
236
  }
212
237
 
213
- async txeAddAccount(
238
+ // eslint-disable-next-line camelcase
239
+ async aztec_txe_addAccount(
214
240
  artifact: ContractArtifact,
215
241
  instance: ContractInstanceWithAddress,
216
242
  foreignSecret: ForeignCallSingle,
217
243
  ) {
218
244
  const secret = fromSingle(foreignSecret);
219
245
 
220
- const completeAddress = await this.handlerAsTxe().txeAddAccount(artifact, instance, secret);
246
+ const completeAddress = await this.handlerAsTxe().addAccount(artifact, instance, secret);
221
247
 
222
248
  return toForeignCallResult([
223
249
  toSingle(completeAddress.address),
@@ -225,39 +251,45 @@ export class RPCTranslator {
225
251
  ]);
226
252
  }
227
253
 
228
- async txeAddAuthWitness(foreignAddress: ForeignCallSingle, foreignMessageHash: ForeignCallSingle) {
254
+ // eslint-disable-next-line camelcase
255
+ async aztec_txe_addAuthWitness(foreignAddress: ForeignCallSingle, foreignMessageHash: ForeignCallSingle) {
229
256
  const address = addressFromSingle(foreignAddress);
230
257
  const messageHash = fromSingle(foreignMessageHash);
231
258
 
232
- await this.handlerAsTxe().txeAddAuthWitness(address, messageHash);
259
+ await this.handlerAsTxe().addAuthWitness(address, messageHash);
233
260
 
234
261
  return toForeignCallResult([]);
235
262
  }
236
263
 
237
264
  // PXE oracles
238
265
 
239
- utilityAssertCompatibleOracleVersion(foreignVersion: ForeignCallSingle) {
240
- const version = fromSingle(foreignVersion).toNumber();
266
+ // eslint-disable-next-line camelcase
267
+ aztec_utl_assertCompatibleOracleVersionV2(foreignMajor: ForeignCallSingle, foreignMinor: ForeignCallSingle) {
268
+ const major = fromSingle(foreignMajor).toNumber();
269
+ const minor = fromSingle(foreignMinor).toNumber();
241
270
 
242
- this.handlerAsMisc().utilityAssertCompatibleOracleVersion(version);
271
+ this.handlerAsMisc().assertCompatibleOracleVersion(major, minor);
243
272
 
244
273
  return toForeignCallResult([]);
245
274
  }
246
275
 
247
- utilityGetRandomField() {
248
- const randomField = this.handlerAsMisc().utilityGetRandomField();
276
+ // eslint-disable-next-line camelcase
277
+ aztec_utl_getRandomField() {
278
+ const randomField = this.handlerAsMisc().getRandomField();
249
279
 
250
280
  return toForeignCallResult([toSingle(randomField)]);
251
281
  }
252
282
 
253
- async txeGetLastBlockTimestamp() {
254
- const timestamp = await this.handlerAsTxe().txeGetLastBlockTimestamp();
283
+ // eslint-disable-next-line camelcase
284
+ async aztec_txe_getLastBlockTimestamp() {
285
+ const timestamp = await this.handlerAsTxe().getLastBlockTimestamp();
255
286
 
256
287
  return toForeignCallResult([toSingle(new Fr(timestamp))]);
257
288
  }
258
289
 
259
- async txeGetLastTxEffects() {
260
- const { txHash, noteHashes, nullifiers } = await this.handlerAsTxe().txeGetLastTxEffects();
290
+ // eslint-disable-next-line camelcase
291
+ async aztec_txe_getLastTxEffects() {
292
+ const { txHash, noteHashes, nullifiers } = await this.handlerAsTxe().getLastTxEffects();
261
293
 
262
294
  return toForeignCallResult([
263
295
  toSingle(txHash.hash),
@@ -266,26 +298,70 @@ export class RPCTranslator {
266
298
  ]);
267
299
  }
268
300
 
269
- privateStoreInExecutionCache(foreignValues: ForeignCallArray, foreignHash: ForeignCallSingle) {
301
+ // eslint-disable-next-line camelcase
302
+ async aztec_txe_getPrivateEvents(
303
+ foreignSelector: ForeignCallSingle,
304
+ foreignContractAddress: ForeignCallSingle,
305
+ foreignScope: ForeignCallSingle,
306
+ ) {
307
+ const selector = EventSelector.fromField(fromSingle(foreignSelector));
308
+ const contractAddress = addressFromSingle(foreignContractAddress);
309
+ const scope = addressFromSingle(foreignScope);
310
+
311
+ // TODO(F-335): Avoid doing the following 2 calls here.
312
+ {
313
+ await this.handlerAsTxe().syncContractNonOracleMethod(contractAddress, scope, this.stateHandler.getCurrentJob());
314
+ // We cycle job to commit the stores after the contract sync.
315
+ await this.stateHandler.cycleJob();
316
+ }
317
+
318
+ const events = await this.handlerAsTxe().getPrivateEvents(selector, contractAddress, scope);
319
+
320
+ if (events.length > MAX_PRIVATE_EVENTS_PER_TXE_QUERY) {
321
+ throw new Error(`Array of length ${events.length} larger than maxLen ${MAX_PRIVATE_EVENTS_PER_TXE_QUERY}`);
322
+ }
323
+
324
+ if (events.some(e => e.length > MAX_EVENT_LEN)) {
325
+ throw new Error(`Some private event has length larger than maxLen ${MAX_EVENT_LEN}`);
326
+ }
327
+
328
+ // This is a workaround as Noir does not currently let us return nested structs with arrays. We instead return a raw
329
+ // multidimensional array in get_private_events_oracle and create the BoundedVecs here.
330
+ const rawArrayStorage = events
331
+ .map(e => e.concat(Array(MAX_EVENT_LEN - e.length).fill(new Fr(0))))
332
+ .concat(Array(MAX_PRIVATE_EVENTS_PER_TXE_QUERY - events.length).fill(Array(MAX_EVENT_LEN).fill(new Fr(0))))
333
+ .flat();
334
+ const eventLengths = events
335
+ .map(e => new Fr(e.length))
336
+ .concat(Array(MAX_PRIVATE_EVENTS_PER_TXE_QUERY - events.length).fill(new Fr(0)));
337
+ const queryLength = new Fr(events.length);
338
+
339
+ return toForeignCallResult([toArray(rawArrayStorage), toArray(eventLengths), toSingle(queryLength)]);
340
+ }
341
+
342
+ // eslint-disable-next-line camelcase
343
+ aztec_prv_setHashPreimage(foreignValues: ForeignCallArray, foreignHash: ForeignCallSingle) {
270
344
  const values = fromArray(foreignValues);
271
345
  const hash = fromSingle(foreignHash);
272
346
 
273
- this.handlerAsPrivate().privateStoreInExecutionCache(values, hash);
347
+ this.handlerAsPrivate().setHashPreimage(values, hash);
274
348
 
275
349
  return toForeignCallResult([]);
276
350
  }
277
351
 
278
- async privateLoadFromExecutionCache(foreignHash: ForeignCallSingle) {
352
+ // eslint-disable-next-line camelcase
353
+ async aztec_prv_getHashPreimage(foreignHash: ForeignCallSingle) {
279
354
  const hash = fromSingle(foreignHash);
280
355
 
281
- const returns = await this.handlerAsPrivate().privateLoadFromExecutionCache(hash);
356
+ const returns = await this.handlerAsPrivate().getHashPreimage(hash);
282
357
 
283
358
  return toForeignCallResult([toArray(returns)]);
284
359
  }
285
360
 
286
361
  // When the argument is a slice, noir automatically adds a length field to oracle call.
287
362
  // When the argument is an array, we add the field length manually to the signature.
288
- utilityDebugLog(
363
+ // eslint-disable-next-line camelcase
364
+ async aztec_utl_log(
289
365
  foreignLevel: ForeignCallSingle,
290
366
  foreignMessage: ForeignCallArray,
291
367
  _foreignLength: ForeignCallSingle,
@@ -297,45 +373,50 @@ export class RPCTranslator {
297
373
  .join('');
298
374
  const fields = fromArray(foreignFields);
299
375
 
300
- this.handlerAsMisc().utilityDebugLog(level, message, fields);
376
+ await this.handlerAsMisc().log(level, message, fields);
301
377
 
302
378
  return toForeignCallResult([]);
303
379
  }
304
380
 
305
- async utilityStorageRead(
381
+ // eslint-disable-next-line camelcase
382
+ async aztec_utl_getFromPublicStorage(
383
+ foreignBlockHash: ForeignCallSingle,
306
384
  foreignContractAddress: ForeignCallSingle,
307
385
  foreignStartStorageSlot: ForeignCallSingle,
308
- foreignBlockNumber: ForeignCallSingle,
309
386
  foreignNumberOfElements: ForeignCallSingle,
310
387
  ) {
388
+ const blockHash = blockHashFromSingle(foreignBlockHash);
311
389
  const contractAddress = addressFromSingle(foreignContractAddress);
312
390
  const startStorageSlot = fromSingle(foreignStartStorageSlot);
313
- const blockNumber = fromSingle(foreignBlockNumber).toNumber();
314
391
  const numberOfElements = fromSingle(foreignNumberOfElements).toNumber();
315
392
 
316
- const values = await this.handlerAsUtility().utilityStorageRead(
393
+ const values = await this.handlerAsUtility().getFromPublicStorage(
394
+ blockHash,
317
395
  contractAddress,
318
396
  startStorageSlot,
319
- blockNumber,
320
397
  numberOfElements,
321
398
  );
322
399
 
323
400
  return toForeignCallResult([toArray(values)]);
324
401
  }
325
402
 
326
- async utilityGetPublicDataWitness(foreignBlockNumber: ForeignCallSingle, foreignLeafSlot: ForeignCallSingle) {
327
- const blockNumber = fromSingle(foreignBlockNumber).toNumber();
403
+ // eslint-disable-next-line camelcase
404
+ async aztec_utl_getPublicDataWitness(foreignBlockHash: ForeignCallSingle, foreignLeafSlot: ForeignCallSingle) {
405
+ const blockHash = blockHashFromSingle(foreignBlockHash);
328
406
  const leafSlot = fromSingle(foreignLeafSlot);
329
407
 
330
- const witness = await this.handlerAsUtility().utilityGetPublicDataWitness(blockNumber, leafSlot);
408
+ const witness = await this.handlerAsUtility().getPublicDataWitness(blockHash, leafSlot);
331
409
 
332
410
  if (!witness) {
333
- throw new Error(`Public data witness not found for slot ${leafSlot} at block ${blockNumber}.`);
411
+ throw new Error(`Public data witness not found for slot ${leafSlot} at block ${blockHash.toString()}.`);
334
412
  }
335
413
  return toForeignCallResult(witness.toNoirRepresentation());
336
414
  }
337
415
 
338
- async utilityGetNotes(
416
+ // eslint-disable-next-line camelcase
417
+ async aztec_utl_getNotes(
418
+ foreignOwnerIsSome: ForeignCallSingle,
419
+ foreignOwnerValue: ForeignCallSingle,
339
420
  foreignStorageSlot: ForeignCallSingle,
340
421
  foreignNumSelects: ForeignCallSingle,
341
422
  foreignSelectByIndexes: ForeignCallArray,
@@ -351,8 +432,12 @@ export class RPCTranslator {
351
432
  foreignOffset: ForeignCallSingle,
352
433
  foreignStatus: ForeignCallSingle,
353
434
  foreignMaxNotes: ForeignCallSingle,
354
- foreignPackedRetrievedNoteLength: ForeignCallSingle,
435
+ foreignPackedHintedNoteLength: ForeignCallSingle,
355
436
  ) {
437
+ // Parse Option<AztecAddress>: ownerIsSome is 0 for None, 1 for Some
438
+ const owner = fromSingle(foreignOwnerIsSome).toBool()
439
+ ? AztecAddress.fromField(fromSingle(foreignOwnerValue))
440
+ : undefined;
356
441
  const storageSlot = fromSingle(foreignStorageSlot);
357
442
  const numSelects = fromSingle(foreignNumSelects).toNumber();
358
443
  const selectByIndexes = fromArray(foreignSelectByIndexes).map(fr => fr.toNumber());
@@ -368,9 +453,10 @@ export class RPCTranslator {
368
453
  const offset = fromSingle(foreignOffset).toNumber();
369
454
  const status = fromSingle(foreignStatus).toNumber();
370
455
  const maxNotes = fromSingle(foreignMaxNotes).toNumber();
371
- const packedRetrievedNoteLength = fromSingle(foreignPackedRetrievedNoteLength).toNumber();
456
+ const packedHintedNoteLength = fromSingle(foreignPackedHintedNoteLength).toNumber();
372
457
 
373
- const noteDatas = await this.handlerAsUtility().utilityGetNotes(
458
+ const noteDatas = await this.handlerAsUtility().getNotes(
459
+ owner,
374
460
  storageSlot,
375
461
  numSelects,
376
462
  selectByIndexes,
@@ -387,7 +473,17 @@ export class RPCTranslator {
387
473
  status,
388
474
  );
389
475
 
390
- const returnDataAsArrayOfArrays = noteDatas.map(packAsRetrievedNote);
476
+ const returnDataAsArrayOfArrays = noteDatas.map(noteData =>
477
+ packAsHintedNote({
478
+ contractAddress: noteData.contractAddress,
479
+ owner: noteData.owner,
480
+ randomness: noteData.randomness,
481
+ storageSlot: noteData.storageSlot,
482
+ noteNonce: noteData.noteNonce,
483
+ isPending: noteData.isPending,
484
+ note: noteData.note,
485
+ }),
486
+ );
391
487
 
392
488
  // Now we convert each sub-array to an array of ForeignCallSingles
393
489
  const returnDataAsArrayOfForeignCallSingleArrays = returnDataAsArrayOfArrays.map(subArray =>
@@ -396,15 +492,13 @@ export class RPCTranslator {
396
492
 
397
493
  // At last we convert the array of arrays to a bounded vec of arrays
398
494
  return toForeignCallResult(
399
- arrayOfArraysToBoundedVecOfArrays(
400
- returnDataAsArrayOfForeignCallSingleArrays,
401
- maxNotes,
402
- packedRetrievedNoteLength,
403
- ),
495
+ arrayOfArraysToBoundedVecOfArrays(returnDataAsArrayOfForeignCallSingleArrays, maxNotes, packedHintedNoteLength),
404
496
  );
405
497
  }
406
498
 
407
- privateNotifyCreatedNote(
499
+ // eslint-disable-next-line camelcase
500
+ aztec_prv_notifyCreatedNote(
501
+ foreignOwner: ForeignCallSingle,
408
502
  foreignStorageSlot: ForeignCallSingle,
409
503
  foreignRandomness: ForeignCallSingle,
410
504
  foreignNoteTypeId: ForeignCallSingle,
@@ -412,6 +506,7 @@ export class RPCTranslator {
412
506
  foreignNoteHash: ForeignCallSingle,
413
507
  foreignCounter: ForeignCallSingle,
414
508
  ) {
509
+ const owner = addressFromSingle(foreignOwner);
415
510
  const storageSlot = fromSingle(foreignStorageSlot);
416
511
  const randomness = fromSingle(foreignRandomness);
417
512
  const noteTypeId = NoteSelector.fromField(fromSingle(foreignNoteTypeId));
@@ -419,12 +514,13 @@ export class RPCTranslator {
419
514
  const noteHash = fromSingle(foreignNoteHash);
420
515
  const counter = fromSingle(foreignCounter).toNumber();
421
516
 
422
- this.handlerAsPrivate().privateNotifyCreatedNote(storageSlot, randomness, noteTypeId, note, noteHash, counter);
517
+ this.handlerAsPrivate().notifyCreatedNote(owner, storageSlot, randomness, noteTypeId, note, noteHash, counter);
423
518
 
424
519
  return toForeignCallResult([]);
425
520
  }
426
521
 
427
- async privateNotifyNullifiedNote(
522
+ // eslint-disable-next-line camelcase
523
+ async aztec_prv_notifyNullifiedNote(
428
524
  foreignInnerNullifier: ForeignCallSingle,
429
525
  foreignNoteHash: ForeignCallSingle,
430
526
  foreignCounter: ForeignCallSingle,
@@ -433,31 +529,47 @@ export class RPCTranslator {
433
529
  const noteHash = fromSingle(foreignNoteHash);
434
530
  const counter = fromSingle(foreignCounter).toNumber();
435
531
 
436
- await this.handlerAsPrivate().privateNotifyNullifiedNote(innerNullifier, noteHash, counter);
532
+ await this.handlerAsPrivate().notifyNullifiedNote(innerNullifier, noteHash, counter);
437
533
 
438
534
  return toForeignCallResult([]);
439
535
  }
440
536
 
441
- async privateNotifyCreatedNullifier(foreignInnerNullifier: ForeignCallSingle) {
537
+ // eslint-disable-next-line camelcase
538
+ async aztec_prv_notifyCreatedNullifier(foreignInnerNullifier: ForeignCallSingle) {
442
539
  const innerNullifier = fromSingle(foreignInnerNullifier);
443
540
 
444
- await this.handlerAsPrivate().privateNotifyCreatedNullifier(innerNullifier);
541
+ await this.handlerAsPrivate().notifyCreatedNullifier(innerNullifier);
445
542
 
446
543
  return toForeignCallResult([]);
447
544
  }
448
545
 
449
- async utilityCheckNullifierExists(foreignInnerNullifier: ForeignCallSingle) {
546
+ // eslint-disable-next-line camelcase
547
+ async aztec_prv_isNullifierPending(
548
+ foreignInnerNullifier: ForeignCallSingle,
549
+ foreignContractAddress: ForeignCallSingle,
550
+ ) {
551
+ const innerNullifier = fromSingle(foreignInnerNullifier);
552
+ const contractAddress = addressFromSingle(foreignContractAddress);
553
+
554
+ const isPending = await this.handlerAsPrivate().isNullifierPending(innerNullifier, contractAddress);
555
+
556
+ return toForeignCallResult([toSingle(new Fr(isPending))]);
557
+ }
558
+
559
+ // eslint-disable-next-line camelcase
560
+ async aztec_utl_doesNullifierExist(foreignInnerNullifier: ForeignCallSingle) {
450
561
  const innerNullifier = fromSingle(foreignInnerNullifier);
451
562
 
452
- const exists = await this.handlerAsUtility().utilityCheckNullifierExists(innerNullifier);
563
+ const exists = await this.handlerAsUtility().doesNullifierExist(innerNullifier);
453
564
 
454
565
  return toForeignCallResult([toSingle(new Fr(exists))]);
455
566
  }
456
567
 
457
- async utilityGetContractInstance(foreignAddress: ForeignCallSingle) {
568
+ // eslint-disable-next-line camelcase
569
+ async aztec_utl_getContractInstance(foreignAddress: ForeignCallSingle) {
458
570
  const address = addressFromSingle(foreignAddress);
459
571
 
460
- const instance = await this.handlerAsUtility().utilityGetContractInstance(address);
572
+ const instance = await this.handlerAsUtility().getContractInstance(address);
461
573
 
462
574
  return toForeignCallResult(
463
575
  [
@@ -470,23 +582,37 @@ export class RPCTranslator {
470
582
  );
471
583
  }
472
584
 
473
- async utilityGetPublicKeysAndPartialAddress(foreignAddress: ForeignCallSingle) {
585
+ // eslint-disable-next-line camelcase
586
+ async aztec_utl_getPublicKeysAndPartialAddress(foreignAddress: ForeignCallSingle) {
474
587
  const address = addressFromSingle(foreignAddress);
475
588
 
476
- const { publicKeys, partialAddress } = await this.handlerAsUtility().utilityGetPublicKeysAndPartialAddress(address);
589
+ const result = await this.handlerAsUtility().getPublicKeysAndPartialAddress(address);
477
590
 
478
- return toForeignCallResult([toArray([...publicKeys.toFields(), partialAddress])]);
591
+ // We are going to return a Noir Option struct to represent the possibility of null values. Options are a struct
592
+ // with two fields: `some` (a boolean) and `value` (a field array in this case).
593
+ if (result === undefined) {
594
+ // No data was found so we set `some` to 0 and pad `value` with zeros get the correct return size.
595
+ return toForeignCallResult([toSingle(new Fr(0)), toArray(Array(13).fill(new Fr(0)))]);
596
+ } else {
597
+ // Data was found so we set `some` to 1 and return it along with `value`.
598
+ return toForeignCallResult([
599
+ toSingle(new Fr(1)),
600
+ toArray([...result.publicKeys.toFields(), result.partialAddress]),
601
+ ]);
602
+ }
479
603
  }
480
604
 
481
- async utilityGetKeyValidationRequest(foreignPkMHash: ForeignCallSingle) {
605
+ // eslint-disable-next-line camelcase
606
+ async aztec_utl_getKeyValidationRequest(foreignPkMHash: ForeignCallSingle) {
482
607
  const pkMHash = fromSingle(foreignPkMHash);
483
608
 
484
- const keyValidationRequest = await this.handlerAsUtility().utilityGetKeyValidationRequest(pkMHash);
609
+ const keyValidationRequest = await this.handlerAsUtility().getKeyValidationRequest(pkMHash);
485
610
 
486
611
  return toForeignCallResult(keyValidationRequest.toFields().map(toSingle));
487
612
  }
488
613
 
489
- privateCallPrivateFunction(
614
+ // eslint-disable-next-line camelcase
615
+ aztec_prv_callPrivateFunction(
490
616
  _foreignTargetContractAddress: ForeignCallSingle,
491
617
  _foreignFunctionSelector: ForeignCallSingle,
492
618
  _foreignArgsHash: ForeignCallSingle,
@@ -498,25 +624,27 @@ export class RPCTranslator {
498
624
  );
499
625
  }
500
626
 
501
- async utilityGetNullifierMembershipWitness(
502
- foreignBlockNumber: ForeignCallSingle,
627
+ // eslint-disable-next-line camelcase
628
+ async aztec_utl_getNullifierMembershipWitness(
629
+ foreignBlockHash: ForeignCallSingle,
503
630
  foreignNullifier: ForeignCallSingle,
504
631
  ) {
505
- const blockNumber = fromSingle(foreignBlockNumber).toNumber();
632
+ const blockHash = blockHashFromSingle(foreignBlockHash);
506
633
  const nullifier = fromSingle(foreignNullifier);
507
634
 
508
- const witness = await this.handlerAsUtility().utilityGetNullifierMembershipWitness(blockNumber, nullifier);
635
+ const witness = await this.handlerAsUtility().getNullifierMembershipWitness(blockHash, nullifier);
509
636
 
510
637
  if (!witness) {
511
- throw new Error(`Nullifier membership witness not found at block ${blockNumber}.`);
638
+ throw new Error(`Nullifier membership witness not found at block ${blockHash}.`);
512
639
  }
513
640
  return toForeignCallResult(witness.toNoirRepresentation());
514
641
  }
515
642
 
516
- async utilityGetAuthWitness(foreignMessageHash: ForeignCallSingle) {
643
+ // eslint-disable-next-line camelcase
644
+ async aztec_utl_getAuthWitness(foreignMessageHash: ForeignCallSingle) {
517
645
  const messageHash = fromSingle(foreignMessageHash);
518
646
 
519
- const authWitness = await this.handlerAsUtility().utilityGetAuthWitness(messageHash);
647
+ const authWitness = await this.handlerAsUtility().getAuthWitness(messageHash);
520
648
 
521
649
  if (!authWitness) {
522
650
  throw new Error(`Auth witness not found for message hash ${messageHash}.`);
@@ -524,44 +652,35 @@ export class RPCTranslator {
524
652
  return toForeignCallResult([toArray(authWitness)]);
525
653
  }
526
654
 
527
- public privateNotifyEnqueuedPublicFunctionCall(
528
- _foreignTargetContractAddress: ForeignCallSingle,
529
- _foreignCalldataHash: ForeignCallSingle,
530
- _foreignSideEffectCounter: ForeignCallSingle,
531
- _foreignIsStaticCall: ForeignCallSingle,
532
- ) {
655
+ // eslint-disable-next-line camelcase
656
+ public aztec_prv_assertValidPublicCalldata(_foreignCalldataHash: ForeignCallSingle) {
533
657
  throw new Error('Enqueueing public calls is not supported in TestEnvironment::private_context');
534
658
  }
535
659
 
536
- public privateNotifySetPublicTeardownFunctionCall(
537
- _foreignTargetContractAddress: ForeignCallSingle,
538
- _foreignCalldataHash: ForeignCallSingle,
539
- _foreignSideEffectCounter: ForeignCallSingle,
540
- _foreignIsStaticCall: ForeignCallSingle,
541
- ) {
660
+ // eslint-disable-next-line camelcase
661
+ public aztec_prv_notifyRevertiblePhaseStart(_foreignMinRevertibleSideEffectCounter: ForeignCallSingle) {
542
662
  throw new Error('Enqueueing public calls is not supported in TestEnvironment::private_context');
543
663
  }
544
664
 
545
- public privateNotifySetMinRevertibleSideEffectCounter(_foreignMinRevertibleSideEffectCounter: ForeignCallSingle) {
546
- throw new Error('Enqueueing public calls is not supported in TestEnvironment::private_context');
547
- }
548
-
549
- public async privateIsSideEffectCounterRevertible(foreignSideEffectCounter: ForeignCallSingle) {
665
+ // eslint-disable-next-line camelcase
666
+ public async aztec_prv_isExecutionInRevertiblePhase(foreignSideEffectCounter: ForeignCallSingle) {
550
667
  const sideEffectCounter = fromSingle(foreignSideEffectCounter).toNumber();
551
- const isRevertible = await this.handlerAsPrivate().privateIsSideEffectCounterRevertible(sideEffectCounter);
668
+ const isRevertible = await this.handlerAsPrivate().isExecutionInRevertiblePhase(sideEffectCounter);
552
669
  return toForeignCallResult([toSingle(new Fr(isRevertible))]);
553
670
  }
554
671
 
555
- async utilityGetUtilityContext() {
556
- const context = await this.handlerAsUtility().utilityGetUtilityContext();
672
+ // eslint-disable-next-line camelcase
673
+ aztec_utl_getUtilityContext() {
674
+ const context = this.handlerAsUtility().getUtilityContext();
557
675
 
558
676
  return toForeignCallResult(context.toNoirRepresentation());
559
677
  }
560
678
 
561
- async utilityGetBlockHeader(foreignBlockNumber: ForeignCallSingle) {
562
- const blockNumber = fromSingle(foreignBlockNumber).toNumber();
679
+ // eslint-disable-next-line camelcase
680
+ async aztec_utl_getBlockHeader(foreignBlockNumber: ForeignCallSingle) {
681
+ const blockNumber = BlockNumber(fromSingle(foreignBlockNumber).toNumber());
563
682
 
564
- const header = await this.handlerAsUtility().utilityGetBlockHeader(blockNumber);
683
+ const header = await this.handlerAsUtility().getBlockHeader(blockNumber);
565
684
 
566
685
  if (!header) {
567
686
  throw new Error(`Block header not found for block ${blockNumber}.`);
@@ -569,108 +688,217 @@ export class RPCTranslator {
569
688
  return toForeignCallResult(header.toFields().map(toSingle));
570
689
  }
571
690
 
572
- async utilityGetMembershipWitness(
573
- foreignBlockNumber: ForeignCallSingle,
574
- foreignTreeId: ForeignCallSingle,
575
- foreignLeafValue: ForeignCallSingle,
691
+ // eslint-disable-next-line camelcase
692
+ async aztec_utl_getNoteHashMembershipWitness(
693
+ foreignAnchorBlockHash: ForeignCallSingle,
694
+ foreignNoteHash: ForeignCallSingle,
695
+ ) {
696
+ const blockHash = blockHashFromSingle(foreignAnchorBlockHash);
697
+ const noteHash = fromSingle(foreignNoteHash);
698
+
699
+ const witness = await this.handlerAsUtility().getNoteHashMembershipWitness(blockHash, noteHash);
700
+
701
+ if (!witness) {
702
+ throw new Error(`Note hash ${noteHash} not found in the note hash tree at block ${blockHash.toString()}.`);
703
+ }
704
+ return toForeignCallResult(witness.toNoirRepresentation());
705
+ }
706
+
707
+ // eslint-disable-next-line camelcase
708
+ async aztec_utl_getBlockHashMembershipWitness(
709
+ foreignAnchorBlockHash: ForeignCallSingle,
710
+ foreignBlockHash: ForeignCallSingle,
576
711
  ) {
577
- const blockNumber = fromSingle(foreignBlockNumber).toNumber();
578
- const treeId = fromSingle(foreignTreeId).toNumber();
579
- const leafValue = fromSingle(foreignLeafValue);
712
+ const anchorBlockHash = blockHashFromSingle(foreignAnchorBlockHash);
713
+ const blockHash = blockHashFromSingle(foreignBlockHash);
580
714
 
581
- const witness = await this.handlerAsUtility().utilityGetMembershipWitness(blockNumber, treeId, leafValue);
715
+ const witness = await this.handlerAsUtility().getBlockHashMembershipWitness(anchorBlockHash, blockHash);
582
716
 
583
717
  if (!witness) {
584
718
  throw new Error(
585
- `Membership witness in tree ${MerkleTreeId[treeId]} not found for value ${leafValue} at block ${blockNumber}.`,
719
+ `Block hash ${blockHash.toString()} not found in the archive tree at anchor block ${anchorBlockHash.toString()}.`,
586
720
  );
587
721
  }
588
- return toForeignCallResult([toSingle(witness[0]), toArray(witness.slice(1))]);
722
+ return toForeignCallResult(witness.toNoirRepresentation());
589
723
  }
590
724
 
591
- async utilityGetLowNullifierMembershipWitness(
592
- foreignBlockNumber: ForeignCallSingle,
725
+ // eslint-disable-next-line camelcase
726
+ async aztec_utl_getLowNullifierMembershipWitness(
727
+ foreignBlockHash: ForeignCallSingle,
593
728
  foreignNullifier: ForeignCallSingle,
594
729
  ) {
595
- const blockNumber = fromSingle(foreignBlockNumber).toNumber();
730
+ const blockHash = blockHashFromSingle(foreignBlockHash);
596
731
  const nullifier = fromSingle(foreignNullifier);
597
732
 
598
- const witness = await this.handlerAsUtility().utilityGetLowNullifierMembershipWitness(blockNumber, nullifier);
733
+ const witness = await this.handlerAsUtility().getLowNullifierMembershipWitness(blockHash, nullifier);
599
734
 
600
735
  if (!witness) {
601
- throw new Error(`Low nullifier witness not found for nullifier ${nullifier} at block ${blockNumber}.`);
736
+ throw new Error(`Low nullifier witness not found for nullifier ${nullifier} at block ${blockHash}.`);
602
737
  }
603
738
  return toForeignCallResult(witness.toNoirRepresentation());
604
739
  }
605
740
 
606
- async utilityFetchTaggedLogs(foreignPendingTaggedLogArrayBaseSlot: ForeignCallSingle) {
741
+ // eslint-disable-next-line camelcase
742
+ async aztec_utl_getPendingTaggedLogs(
743
+ foreignPendingTaggedLogArrayBaseSlot: ForeignCallSingle,
744
+ foreignScope: ForeignCallSingle,
745
+ ) {
607
746
  const pendingTaggedLogArrayBaseSlot = fromSingle(foreignPendingTaggedLogArrayBaseSlot);
747
+ const scope = AztecAddress.fromField(fromSingle(foreignScope));
608
748
 
609
- await this.handlerAsUtility().utilityFetchTaggedLogs(pendingTaggedLogArrayBaseSlot);
749
+ await this.handlerAsUtility().getPendingTaggedLogs(pendingTaggedLogArrayBaseSlot, scope);
610
750
 
611
751
  return toForeignCallResult([]);
612
752
  }
613
753
 
614
- public async utilityValidateEnqueuedNotesAndEvents(
754
+ // eslint-disable-next-line camelcase
755
+ async aztec_utl_getPendingTaggedLogs_v2(foreignScope: ForeignCallSingle) {
756
+ const scope = AztecAddress.fromField(fromSingle(foreignScope));
757
+ const slot = await this.handlerAsUtility().getPendingTaggedLogsV2(scope);
758
+ return toForeignCallResult([toSingle(slot)]);
759
+ }
760
+
761
+ // eslint-disable-next-line camelcase
762
+ public async aztec_utl_validateAndStoreEnqueuedNotesAndEvents(
615
763
  foreignContractAddress: ForeignCallSingle,
616
764
  foreignNoteValidationRequestsArrayBaseSlot: ForeignCallSingle,
617
765
  foreignEventValidationRequestsArrayBaseSlot: ForeignCallSingle,
766
+ foreignMaxNotePackedLen: ForeignCallSingle,
767
+ foreignMaxEventSerializedLen: ForeignCallSingle,
768
+ foreignScope: ForeignCallSingle,
618
769
  ) {
619
770
  const contractAddress = AztecAddress.fromField(fromSingle(foreignContractAddress));
620
771
  const noteValidationRequestsArrayBaseSlot = fromSingle(foreignNoteValidationRequestsArrayBaseSlot);
621
772
  const eventValidationRequestsArrayBaseSlot = fromSingle(foreignEventValidationRequestsArrayBaseSlot);
773
+ const maxNotePackedLen = fromSingle(foreignMaxNotePackedLen).toNumber();
774
+ const maxEventSerializedLen = fromSingle(foreignMaxEventSerializedLen).toNumber();
775
+ const scope = AztecAddress.fromField(fromSingle(foreignScope));
622
776
 
623
- await this.handlerAsUtility().utilityValidateEnqueuedNotesAndEvents(
777
+ await this.handlerAsUtility().validateAndStoreEnqueuedNotesAndEvents(
624
778
  contractAddress,
625
779
  noteValidationRequestsArrayBaseSlot,
626
780
  eventValidationRequestsArrayBaseSlot,
781
+ maxNotePackedLen,
782
+ maxEventSerializedLen,
783
+ scope,
784
+ );
785
+
786
+ return toForeignCallResult([]);
787
+ }
788
+
789
+ // eslint-disable-next-line camelcase
790
+ public async aztec_utl_validateAndStoreEnqueuedNotesAndEvents_v2(
791
+ foreignNoteValidationRequestsArrayBaseSlot: ForeignCallSingle,
792
+ foreignEventValidationRequestsArrayBaseSlot: ForeignCallSingle,
793
+ foreignMaxNotePackedLen: ForeignCallSingle,
794
+ foreignMaxEventSerializedLen: ForeignCallSingle,
795
+ foreignScope: ForeignCallSingle,
796
+ ) {
797
+ const noteValidationRequestsArrayBaseSlot = fromSingle(foreignNoteValidationRequestsArrayBaseSlot);
798
+ const eventValidationRequestsArrayBaseSlot = fromSingle(foreignEventValidationRequestsArrayBaseSlot);
799
+ const maxNotePackedLen = fromSingle(foreignMaxNotePackedLen).toNumber();
800
+ const maxEventSerializedLen = fromSingle(foreignMaxEventSerializedLen).toNumber();
801
+ const scope = AztecAddress.fromField(fromSingle(foreignScope));
802
+
803
+ await this.handlerAsUtility().validateAndStoreEnqueuedNotesAndEventsV2(
804
+ noteValidationRequestsArrayBaseSlot,
805
+ eventValidationRequestsArrayBaseSlot,
806
+ maxNotePackedLen,
807
+ maxEventSerializedLen,
808
+ scope,
627
809
  );
628
810
 
629
811
  return toForeignCallResult([]);
630
812
  }
631
813
 
632
- public async utilityBulkRetrieveLogs(
814
+ // eslint-disable-next-line camelcase
815
+ public async aztec_utl_getLogsByTag(
633
816
  foreignContractAddress: ForeignCallSingle,
634
817
  foreignLogRetrievalRequestsArrayBaseSlot: ForeignCallSingle,
635
818
  foreignLogRetrievalResponsesArrayBaseSlot: ForeignCallSingle,
819
+ foreignScope: ForeignCallSingle,
636
820
  ) {
637
821
  const contractAddress = AztecAddress.fromField(fromSingle(foreignContractAddress));
638
822
  const logRetrievalRequestsArrayBaseSlot = fromSingle(foreignLogRetrievalRequestsArrayBaseSlot);
639
823
  const logRetrievalResponsesArrayBaseSlot = fromSingle(foreignLogRetrievalResponsesArrayBaseSlot);
824
+ const scope = AztecAddress.fromField(fromSingle(foreignScope));
640
825
 
641
- await this.handlerAsUtility().utilityBulkRetrieveLogs(
826
+ await this.handlerAsUtility().getLogsByTag(
642
827
  contractAddress,
643
828
  logRetrievalRequestsArrayBaseSlot,
644
829
  logRetrievalResponsesArrayBaseSlot,
830
+ scope,
831
+ );
832
+
833
+ return toForeignCallResult([]);
834
+ }
835
+
836
+ // eslint-disable-next-line camelcase
837
+ public async aztec_utl_getMessageContextsByTxHash(
838
+ foreignContractAddress: ForeignCallSingle,
839
+ foreignMessageContextRequestsArrayBaseSlot: ForeignCallSingle,
840
+ foreignMessageContextResponsesArrayBaseSlot: ForeignCallSingle,
841
+ foreignScope: ForeignCallSingle,
842
+ ) {
843
+ const contractAddress = AztecAddress.fromField(fromSingle(foreignContractAddress));
844
+ const messageContextRequestsArrayBaseSlot = fromSingle(foreignMessageContextRequestsArrayBaseSlot);
845
+ const messageContextResponsesArrayBaseSlot = fromSingle(foreignMessageContextResponsesArrayBaseSlot);
846
+ const scope = AztecAddress.fromField(fromSingle(foreignScope));
847
+
848
+ await this.handlerAsUtility().getMessageContextsByTxHash(
849
+ contractAddress,
850
+ messageContextRequestsArrayBaseSlot,
851
+ messageContextResponsesArrayBaseSlot,
852
+ scope,
645
853
  );
646
854
 
647
855
  return toForeignCallResult([]);
648
856
  }
649
857
 
650
- async utilityStoreCapsule(
858
+ // eslint-disable-next-line camelcase
859
+ async aztec_utl_getLogsByTag_v2(foreignRequestArrayBaseSlot: ForeignCallSingle) {
860
+ const requestArrayBaseSlot = fromSingle(foreignRequestArrayBaseSlot);
861
+ const responseSlot = await this.handlerAsUtility().getLogsByTagV2(requestArrayBaseSlot);
862
+ return toForeignCallResult([toSingle(responseSlot)]);
863
+ }
864
+
865
+ // eslint-disable-next-line camelcase
866
+ async aztec_utl_getMessageContextsByTxHash_v2(foreignRequestArrayBaseSlot: ForeignCallSingle) {
867
+ const requestArrayBaseSlot = fromSingle(foreignRequestArrayBaseSlot);
868
+ const responseSlot = await this.handlerAsUtility().getMessageContextsByTxHashV2(requestArrayBaseSlot);
869
+ return toForeignCallResult([toSingle(responseSlot)]);
870
+ }
871
+
872
+ // eslint-disable-next-line camelcase
873
+ aztec_utl_setCapsule(
651
874
  foreignContractAddress: ForeignCallSingle,
652
875
  foreignSlot: ForeignCallSingle,
653
876
  foreignCapsule: ForeignCallArray,
877
+ foreignScope: ForeignCallSingle,
654
878
  ) {
655
879
  const contractAddress = AztecAddress.fromField(fromSingle(foreignContractAddress));
656
880
  const slot = fromSingle(foreignSlot);
657
881
  const capsule = fromArray(foreignCapsule);
882
+ const scope = AztecAddress.fromField(fromSingle(foreignScope));
658
883
 
659
- await this.handlerAsUtility().utilityStoreCapsule(contractAddress, slot, capsule);
884
+ this.handlerAsUtility().setCapsule(contractAddress, slot, capsule, scope);
660
885
 
661
886
  return toForeignCallResult([]);
662
887
  }
663
888
 
664
- async utilityLoadCapsule(
889
+ // eslint-disable-next-line camelcase
890
+ async aztec_utl_getCapsule(
665
891
  foreignContractAddress: ForeignCallSingle,
666
892
  foreignSlot: ForeignCallSingle,
667
893
  foreignTSize: ForeignCallSingle,
894
+ foreignScope: ForeignCallSingle,
668
895
  ) {
669
896
  const contractAddress = AztecAddress.fromField(fromSingle(foreignContractAddress));
670
897
  const slot = fromSingle(foreignSlot);
671
898
  const tSize = fromSingle(foreignTSize).toNumber();
899
+ const scope = AztecAddress.fromField(fromSingle(foreignScope));
672
900
 
673
- const values = await this.handlerAsUtility().utilityLoadCapsule(contractAddress, slot);
901
+ const values = await this.handlerAsUtility().getCapsule(contractAddress, slot, scope);
674
902
 
675
903
  // We are going to return a Noir Option struct to represent the possibility of null values. Options are a struct
676
904
  // with two fields: `some` (a boolean) and `value` (a field array in this case).
@@ -683,28 +911,95 @@ export class RPCTranslator {
683
911
  }
684
912
  }
685
913
 
686
- async utilityDeleteCapsule(foreignContractAddress: ForeignCallSingle, foreignSlot: ForeignCallSingle) {
914
+ // eslint-disable-next-line camelcase
915
+ aztec_utl_deleteCapsule(
916
+ foreignContractAddress: ForeignCallSingle,
917
+ foreignSlot: ForeignCallSingle,
918
+ foreignScope: ForeignCallSingle,
919
+ ) {
687
920
  const contractAddress = AztecAddress.fromField(fromSingle(foreignContractAddress));
688
921
  const slot = fromSingle(foreignSlot);
922
+ const scope = AztecAddress.fromField(fromSingle(foreignScope));
689
923
 
690
- await this.handlerAsUtility().utilityDeleteCapsule(contractAddress, slot);
924
+ this.handlerAsUtility().deleteCapsule(contractAddress, slot, scope);
691
925
 
692
926
  return toForeignCallResult([]);
693
927
  }
694
928
 
695
- async utilityCopyCapsule(
929
+ // eslint-disable-next-line camelcase
930
+ async aztec_utl_copyCapsule(
696
931
  foreignContractAddress: ForeignCallSingle,
697
932
  foreignSrcSlot: ForeignCallSingle,
698
933
  foreignDstSlot: ForeignCallSingle,
699
934
  foreignNumEntries: ForeignCallSingle,
935
+ foreignScope: ForeignCallSingle,
700
936
  ) {
701
937
  const contractAddress = AztecAddress.fromField(fromSingle(foreignContractAddress));
702
938
  const srcSlot = fromSingle(foreignSrcSlot);
703
939
  const dstSlot = fromSingle(foreignDstSlot);
704
940
  const numEntries = fromSingle(foreignNumEntries).toNumber();
941
+ const scope = AztecAddress.fromField(fromSingle(foreignScope));
942
+
943
+ await this.handlerAsUtility().copyCapsule(contractAddress, srcSlot, dstSlot, numEntries, scope);
944
+
945
+ return toForeignCallResult([]);
946
+ }
947
+
948
+ // eslint-disable-next-line camelcase
949
+ aztec_utl_pushEphemeral(foreignSlot: ForeignCallSingle, foreignElements: ForeignCallArray) {
950
+ const slot = fromSingle(foreignSlot);
951
+ const elements = fromArray(foreignElements);
952
+ const newLen = this.handlerAsUtility().pushEphemeral(slot, elements);
953
+ return toForeignCallResult([toSingle(new Fr(newLen))]);
954
+ }
955
+
956
+ // eslint-disable-next-line camelcase
957
+ aztec_utl_popEphemeral(foreignSlot: ForeignCallSingle) {
958
+ const slot = fromSingle(foreignSlot);
959
+ const element = this.handlerAsUtility().popEphemeral(slot);
960
+ return toForeignCallResult([toArray(element)]);
961
+ }
962
+
963
+ // eslint-disable-next-line camelcase
964
+ aztec_utl_getEphemeral(foreignSlot: ForeignCallSingle, foreignIndex: ForeignCallSingle) {
965
+ const slot = fromSingle(foreignSlot);
966
+ const index = fromSingle(foreignIndex).toNumber();
967
+ const element = this.handlerAsUtility().getEphemeral(slot, index);
968
+ return toForeignCallResult([toArray(element)]);
969
+ }
705
970
 
706
- await this.handlerAsUtility().utilityCopyCapsule(contractAddress, srcSlot, dstSlot, numEntries);
971
+ // eslint-disable-next-line camelcase
972
+ aztec_utl_setEphemeral(
973
+ foreignSlot: ForeignCallSingle,
974
+ foreignIndex: ForeignCallSingle,
975
+ foreignElements: ForeignCallArray,
976
+ ) {
977
+ const slot = fromSingle(foreignSlot);
978
+ const index = fromSingle(foreignIndex).toNumber();
979
+ const elements = fromArray(foreignElements);
980
+ this.handlerAsUtility().setEphemeral(slot, index, elements);
981
+ return toForeignCallResult([]);
982
+ }
983
+
984
+ // eslint-disable-next-line camelcase
985
+ aztec_utl_getEphemeralLen(foreignSlot: ForeignCallSingle) {
986
+ const slot = fromSingle(foreignSlot);
987
+ const len = this.handlerAsUtility().getEphemeralLen(slot);
988
+ return toForeignCallResult([toSingle(new Fr(len))]);
989
+ }
990
+
991
+ // eslint-disable-next-line camelcase
992
+ aztec_utl_removeEphemeral(foreignSlot: ForeignCallSingle, foreignIndex: ForeignCallSingle) {
993
+ const slot = fromSingle(foreignSlot);
994
+ const index = fromSingle(foreignIndex).toNumber();
995
+ this.handlerAsUtility().removeEphemeral(slot, index);
996
+ return toForeignCallResult([]);
997
+ }
707
998
 
999
+ // eslint-disable-next-line camelcase
1000
+ aztec_utl_clearEphemeral(foreignSlot: ForeignCallSingle) {
1001
+ const slot = fromSingle(foreignSlot);
1002
+ this.handlerAsUtility().clearEphemeral(slot);
708
1003
  return toForeignCallResult([]);
709
1004
  }
710
1005
 
@@ -712,7 +1007,8 @@ export class RPCTranslator {
712
1007
  // The compiler didn't throw an error, so it took me a while to learn of the existence of this file, and that I need
713
1008
  // to implement this function here. Isn't there a way to programmatically identify that this is missing, given the
714
1009
  // existence of a txe_oracle method?
715
- async utilityAes128Decrypt(
1010
+ // eslint-disable-next-line camelcase
1011
+ async aztec_utl_decryptAes128(
716
1012
  foreignCiphertextBVecStorage: ForeignCallArray,
717
1013
  foreignCiphertextLength: ForeignCallSingle,
718
1014
  foreignIv: ForeignCallArray,
@@ -722,18 +1018,27 @@ export class RPCTranslator {
722
1018
  const iv = fromUintArray(foreignIv, 8);
723
1019
  const symKey = fromUintArray(foreignSymKey, 8);
724
1020
 
725
- const plaintextBuffer = await this.handlerAsUtility().utilityAes128Decrypt(ciphertext, iv, symKey);
726
-
727
- return toForeignCallResult(
728
- arrayToBoundedVec(bufferToU8Array(plaintextBuffer), foreignCiphertextBVecStorage.length),
729
- );
1021
+ // Noir Option<BoundedVec> is encoded as [is_some: Field, storage: Field[], length: Field].
1022
+ try {
1023
+ const plaintextBuffer = await this.handlerAsUtility().decryptAes128(ciphertext, iv, symKey);
1024
+ const [storage, length] = arrayToBoundedVec(
1025
+ bufferToU8Array(plaintextBuffer),
1026
+ foreignCiphertextBVecStorage.length,
1027
+ );
1028
+ return toForeignCallResult([toSingle(new Fr(1)), storage, length]);
1029
+ } catch {
1030
+ const zeroStorage = toArray(Array(foreignCiphertextBVecStorage.length).fill(new Fr(0)));
1031
+ return toForeignCallResult([toSingle(new Fr(0)), zeroStorage, toSingle(new Fr(0))]);
1032
+ }
730
1033
  }
731
1034
 
732
- async utilityGetSharedSecret(
1035
+ // eslint-disable-next-line camelcase
1036
+ async aztec_utl_getSharedSecret(
733
1037
  foreignAddress: ForeignCallSingle,
734
1038
  foreignEphPKField0: ForeignCallSingle,
735
1039
  foreignEphPKField1: ForeignCallSingle,
736
1040
  foreignEphPKField2: ForeignCallSingle,
1041
+ foreignContractAddress: ForeignCallSingle,
737
1042
  ) {
738
1043
  const address = AztecAddress.fromField(fromSingle(foreignAddress));
739
1044
  const ephPK = Point.fromFields([
@@ -741,44 +1046,68 @@ export class RPCTranslator {
741
1046
  fromSingle(foreignEphPKField1),
742
1047
  fromSingle(foreignEphPKField2),
743
1048
  ]);
1049
+ const contractAddress = AztecAddress.fromField(fromSingle(foreignContractAddress));
744
1050
 
745
- const secret = await this.handlerAsUtility().utilityGetSharedSecret(address, ephPK);
1051
+ const secret = await this.handlerAsUtility().getSharedSecret(address, ephPK, contractAddress);
746
1052
 
747
- return toForeignCallResult(secret.toFields().map(toSingle));
1053
+ return toForeignCallResult([toSingle(secret)]);
748
1054
  }
749
1055
 
750
- emitOffchainEffect(_foreignData: ForeignCallArray) {
1056
+ // eslint-disable-next-line camelcase
1057
+ aztec_utl_setContractSyncCacheInvalid(
1058
+ foreignContractAddress: ForeignCallSingle,
1059
+ foreignScopes: ForeignCallArray,
1060
+ foreignScopeCount: ForeignCallSingle,
1061
+ ) {
1062
+ const contractAddress = addressFromSingle(foreignContractAddress);
1063
+ const count = fromSingle(foreignScopeCount).toNumber();
1064
+ const scopes = fromArray(foreignScopes)
1065
+ .slice(0, count)
1066
+ .map(f => new AztecAddress(f));
1067
+
1068
+ this.handlerAsUtility().setContractSyncCacheInvalid(contractAddress, scopes);
1069
+
1070
+ return Promise.resolve(toForeignCallResult([]));
1071
+ }
1072
+
1073
+ // eslint-disable-next-line camelcase
1074
+ aztec_utl_emitOffchainEffect(_foreignData: ForeignCallArray) {
751
1075
  throw new Error('Offchain effects are not yet supported in the TestEnvironment');
752
1076
  }
753
1077
 
754
1078
  // AVM opcodes
755
1079
 
756
- avmOpcodeEmitUnencryptedLog(_foreignMessage: ForeignCallArray) {
1080
+ // eslint-disable-next-line camelcase
1081
+ aztec_avm_emitPublicLog(_foreignMessage: ForeignCallArray) {
757
1082
  // TODO(#8811): Implement
758
1083
  return toForeignCallResult([]);
759
1084
  }
760
1085
 
761
- async avmOpcodeStorageRead(foreignSlot: ForeignCallSingle) {
1086
+ // eslint-disable-next-line camelcase
1087
+ async aztec_avm_storageRead(foreignSlot: ForeignCallSingle, foreignContractAddress: ForeignCallSingle) {
762
1088
  const slot = fromSingle(foreignSlot);
1089
+ const contractAddress = AztecAddress.fromField(fromSingle(foreignContractAddress));
763
1090
 
764
- const value = (await this.handlerAsAvm().avmOpcodeStorageRead(slot)).value;
1091
+ const value = (await this.handlerAsAvm().storageRead(slot, contractAddress)).value;
765
1092
 
766
1093
  return toForeignCallResult([toSingle(new Fr(value))]);
767
1094
  }
768
1095
 
769
- async avmOpcodeStorageWrite(foreignSlot: ForeignCallSingle, foreignValue: ForeignCallSingle) {
1096
+ // eslint-disable-next-line camelcase
1097
+ async aztec_avm_storageWrite(foreignSlot: ForeignCallSingle, foreignValue: ForeignCallSingle) {
770
1098
  const slot = fromSingle(foreignSlot);
771
1099
  const value = fromSingle(foreignValue);
772
1100
 
773
- await this.handlerAsAvm().avmOpcodeStorageWrite(slot, value);
1101
+ await this.handlerAsAvm().storageWrite(slot, value);
774
1102
 
775
1103
  return toForeignCallResult([]);
776
1104
  }
777
1105
 
778
- async avmOpcodeGetContractInstanceDeployer(foreignAddress: ForeignCallSingle) {
1106
+ // eslint-disable-next-line camelcase
1107
+ async aztec_avm_getContractInstanceDeployer(foreignAddress: ForeignCallSingle) {
779
1108
  const address = addressFromSingle(foreignAddress);
780
1109
 
781
- const instance = await this.handlerAsUtility().utilityGetContractInstance(address);
1110
+ const instance = await this.handlerAsUtility().getContractInstance(address);
782
1111
 
783
1112
  return toForeignCallResult([
784
1113
  toSingle(instance.deployer),
@@ -787,10 +1116,11 @@ export class RPCTranslator {
787
1116
  ]);
788
1117
  }
789
1118
 
790
- async avmOpcodeGetContractInstanceClassId(foreignAddress: ForeignCallSingle) {
1119
+ // eslint-disable-next-line camelcase
1120
+ async aztec_avm_getContractInstanceClassId(foreignAddress: ForeignCallSingle) {
791
1121
  const address = addressFromSingle(foreignAddress);
792
1122
 
793
- const instance = await this.handlerAsUtility().utilityGetContractInstance(address);
1123
+ const instance = await this.handlerAsUtility().getContractInstance(address);
794
1124
 
795
1125
  return toForeignCallResult([
796
1126
  toSingle(instance.currentContractClassId),
@@ -799,10 +1129,11 @@ export class RPCTranslator {
799
1129
  ]);
800
1130
  }
801
1131
 
802
- async avmOpcodeGetContractInstanceInitializationHash(foreignAddress: ForeignCallSingle) {
1132
+ // eslint-disable-next-line camelcase
1133
+ async aztec_avm_getContractInstanceInitializationHash(foreignAddress: ForeignCallSingle) {
803
1134
  const address = addressFromSingle(foreignAddress);
804
1135
 
805
- const instance = await this.handlerAsUtility().utilityGetContractInstance(address);
1136
+ const instance = await this.handlerAsUtility().getContractInstance(address);
806
1137
 
807
1138
  return toForeignCallResult([
808
1139
  toSingle(instance.initializationHash),
@@ -811,86 +1142,98 @@ export class RPCTranslator {
811
1142
  ]);
812
1143
  }
813
1144
 
814
- async avmOpcodeSender() {
815
- const sender = await this.handlerAsAvm().avmOpcodeSender();
1145
+ // eslint-disable-next-line camelcase
1146
+ async aztec_avm_sender() {
1147
+ const sender = await this.handlerAsAvm().sender();
816
1148
 
817
1149
  return toForeignCallResult([toSingle(sender)]);
818
1150
  }
819
1151
 
820
- async avmOpcodeEmitNullifier(foreignNullifier: ForeignCallSingle) {
1152
+ // eslint-disable-next-line camelcase
1153
+ async aztec_avm_emitNullifier(foreignNullifier: ForeignCallSingle) {
821
1154
  const nullifier = fromSingle(foreignNullifier);
822
1155
 
823
- await this.handlerAsAvm().avmOpcodeEmitNullifier(nullifier);
1156
+ await this.handlerAsAvm().emitNullifier(nullifier);
824
1157
 
825
1158
  return toForeignCallResult([]);
826
1159
  }
827
1160
 
828
- async avmOpcodeEmitNoteHash(foreignNoteHash: ForeignCallSingle) {
1161
+ // eslint-disable-next-line camelcase
1162
+ async aztec_avm_emitNoteHash(foreignNoteHash: ForeignCallSingle) {
829
1163
  const noteHash = fromSingle(foreignNoteHash);
830
1164
 
831
- await this.handlerAsAvm().avmOpcodeEmitNoteHash(noteHash);
1165
+ await this.handlerAsAvm().emitNoteHash(noteHash);
832
1166
 
833
1167
  return toForeignCallResult([]);
834
1168
  }
835
1169
 
836
- async avmOpcodeNullifierExists(foreignInnerNullifier: ForeignCallSingle, foreignTargetAddress: ForeignCallSingle) {
837
- const innerNullifier = fromSingle(foreignInnerNullifier);
838
- const targetAddress = AztecAddress.fromField(fromSingle(foreignTargetAddress));
1170
+ // eslint-disable-next-line camelcase
1171
+ async aztec_avm_nullifierExists(foreignSiloedNullifier: ForeignCallSingle) {
1172
+ const siloedNullifier = fromSingle(foreignSiloedNullifier);
839
1173
 
840
- const exists = await this.handlerAsAvm().avmOpcodeNullifierExists(innerNullifier, targetAddress);
1174
+ const exists = await this.handlerAsAvm().nullifierExists(siloedNullifier);
841
1175
 
842
1176
  return toForeignCallResult([toSingle(new Fr(exists))]);
843
1177
  }
844
1178
 
845
- async avmOpcodeAddress() {
846
- const contractAddress = await this.handlerAsAvm().avmOpcodeAddress();
1179
+ // eslint-disable-next-line camelcase
1180
+ async aztec_avm_address() {
1181
+ const contractAddress = await this.handlerAsAvm().address();
847
1182
 
848
1183
  return toForeignCallResult([toSingle(contractAddress.toField())]);
849
1184
  }
850
1185
 
851
- async avmOpcodeBlockNumber() {
852
- const blockNumber = await this.handlerAsAvm().avmOpcodeBlockNumber();
1186
+ // eslint-disable-next-line camelcase
1187
+ async aztec_avm_blockNumber() {
1188
+ const blockNumber = await this.handlerAsAvm().blockNumber();
853
1189
 
854
1190
  return toForeignCallResult([toSingle(new Fr(blockNumber))]);
855
1191
  }
856
1192
 
857
- async avmOpcodeTimestamp() {
858
- const timestamp = await this.handlerAsAvm().avmOpcodeTimestamp();
1193
+ // eslint-disable-next-line camelcase
1194
+ async aztec_avm_timestamp() {
1195
+ const timestamp = await this.handlerAsAvm().timestamp();
859
1196
 
860
1197
  return toForeignCallResult([toSingle(new Fr(timestamp))]);
861
1198
  }
862
1199
 
863
- async avmOpcodeIsStaticCall() {
864
- const isStaticCall = await this.handlerAsAvm().avmOpcodeIsStaticCall();
1200
+ // eslint-disable-next-line camelcase
1201
+ async aztec_avm_isStaticCall() {
1202
+ const isStaticCall = await this.handlerAsAvm().isStaticCall();
865
1203
 
866
1204
  return toForeignCallResult([toSingle(new Fr(isStaticCall ? 1 : 0))]);
867
1205
  }
868
1206
 
869
- async avmOpcodeChainId() {
870
- const chainId = await this.handlerAsAvm().avmOpcodeChainId();
1207
+ // eslint-disable-next-line camelcase
1208
+ async aztec_avm_chainId() {
1209
+ const chainId = await this.handlerAsAvm().chainId();
871
1210
 
872
1211
  return toForeignCallResult([toSingle(chainId)]);
873
1212
  }
874
1213
 
875
- async avmOpcodeVersion() {
876
- const version = await this.handlerAsAvm().avmOpcodeVersion();
1214
+ // eslint-disable-next-line camelcase
1215
+ async aztec_avm_version() {
1216
+ const version = await this.handlerAsAvm().version();
877
1217
 
878
1218
  return toForeignCallResult([toSingle(version)]);
879
1219
  }
880
1220
 
881
- avmOpcodeReturndataSize() {
1221
+ // eslint-disable-next-line camelcase
1222
+ aztec_avm_returndataSize() {
882
1223
  throw new Error(
883
1224
  'Contract calls are forbidden inside a `TestEnvironment::public_context`, use `public_call` instead',
884
1225
  );
885
1226
  }
886
1227
 
887
- avmOpcodeReturndataCopy(_foreignRdOffset: ForeignCallSingle, _foreignCopySize: ForeignCallSingle) {
1228
+ // eslint-disable-next-line camelcase
1229
+ aztec_avm_returndataCopy(_foreignRdOffset: ForeignCallSingle, _foreignCopySize: ForeignCallSingle) {
888
1230
  throw new Error(
889
1231
  'Contract calls are forbidden inside a `TestEnvironment::public_context`, use `public_call` instead',
890
1232
  );
891
1233
  }
892
1234
 
893
- avmOpcodeCall(
1235
+ // eslint-disable-next-line camelcase
1236
+ aztec_avm_call(
894
1237
  _foreignL2Gas: ForeignCallSingle,
895
1238
  _foreignDaGas: ForeignCallSingle,
896
1239
  _foreignAddress: ForeignCallSingle,
@@ -902,7 +1245,8 @@ export class RPCTranslator {
902
1245
  );
903
1246
  }
904
1247
 
905
- avmOpcodeStaticCall(
1248
+ // eslint-disable-next-line camelcase
1249
+ aztec_avm_staticCall(
906
1250
  _foreignL2Gas: ForeignCallSingle,
907
1251
  _foreignDaGas: ForeignCallSingle,
908
1252
  _foreignAddress: ForeignCallSingle,
@@ -914,13 +1258,15 @@ export class RPCTranslator {
914
1258
  );
915
1259
  }
916
1260
 
917
- avmOpcodeSuccessCopy() {
1261
+ // eslint-disable-next-line camelcase
1262
+ aztec_avm_successCopy() {
918
1263
  throw new Error(
919
1264
  'Contract calls are forbidden inside a `TestEnvironment::public_context`, use `public_call` instead',
920
1265
  );
921
1266
  }
922
1267
 
923
- async txePrivateCallNewFlow(
1268
+ // eslint-disable-next-line camelcase
1269
+ async aztec_txe_privateCallNewFlow(
924
1270
  foreignFrom: ForeignCallSingle,
925
1271
  foreignTargetContractAddress: ForeignCallSingle,
926
1272
  foreignFunctionSelector: ForeignCallSingle,
@@ -935,19 +1281,23 @@ export class RPCTranslator {
935
1281
  const argsHash = fromSingle(foreignArgsHash);
936
1282
  const isStaticCall = fromSingle(foreignIsStaticCall).toBool();
937
1283
 
938
- const returnValues = await this.handlerAsTxe().txePrivateCallNewFlow(
1284
+ const returnValues = await this.handlerAsTxe().privateCallNewFlow(
939
1285
  from,
940
1286
  targetContractAddress,
941
1287
  functionSelector,
942
1288
  args,
943
1289
  argsHash,
944
1290
  isStaticCall,
1291
+ this.stateHandler.getCurrentJob(),
945
1292
  );
946
1293
 
1294
+ // TODO(F-335): Avoid doing the following call here.
1295
+ await this.stateHandler.cycleJob();
947
1296
  return toForeignCallResult([toArray(returnValues)]);
948
1297
  }
949
1298
 
950
- async txeSimulateUtilityFunction(
1299
+ // eslint-disable-next-line camelcase
1300
+ async aztec_txe_executeUtilityFunction(
951
1301
  foreignTargetContractAddress: ForeignCallSingle,
952
1302
  foreignFunctionSelector: ForeignCallSingle,
953
1303
  foreignArgs: ForeignCallArray,
@@ -956,16 +1306,20 @@ export class RPCTranslator {
956
1306
  const functionSelector = FunctionSelector.fromField(fromSingle(foreignFunctionSelector));
957
1307
  const args = fromArray(foreignArgs);
958
1308
 
959
- const returnValues = await this.handlerAsTxe().txeSimulateUtilityFunction(
1309
+ const returnValues = await this.handlerAsTxe().executeUtilityFunction(
960
1310
  targetContractAddress,
961
1311
  functionSelector,
962
1312
  args,
1313
+ this.stateHandler.getCurrentJob(),
963
1314
  );
964
1315
 
1316
+ // TODO(F-335): Avoid doing the following call here.
1317
+ await this.stateHandler.cycleJob();
965
1318
  return toForeignCallResult([toArray(returnValues)]);
966
1319
  }
967
1320
 
968
- async txePublicCallNewFlow(
1321
+ // eslint-disable-next-line camelcase
1322
+ async aztec_txe_publicCallNewFlow(
969
1323
  foreignFrom: ForeignCallSingle,
970
1324
  foreignAddress: ForeignCallSingle,
971
1325
  foreignCalldata: ForeignCallArray,
@@ -976,13 +1330,16 @@ export class RPCTranslator {
976
1330
  const calldata = fromArray(foreignCalldata);
977
1331
  const isStaticCall = fromSingle(foreignIsStaticCall).toBool();
978
1332
 
979
- const returnValues = await this.handlerAsTxe().txePublicCallNewFlow(from, address, calldata, isStaticCall);
1333
+ const returnValues = await this.handlerAsTxe().publicCallNewFlow(from, address, calldata, isStaticCall);
980
1334
 
1335
+ // TODO(F-335): Avoid doing the following call here.
1336
+ await this.stateHandler.cycleJob();
981
1337
  return toForeignCallResult([toArray(returnValues)]);
982
1338
  }
983
1339
 
984
- async privateGetSenderForTags() {
985
- const sender = await this.handlerAsPrivate().privateGetSenderForTags();
1340
+ // eslint-disable-next-line camelcase
1341
+ async aztec_prv_getSenderForTags() {
1342
+ const sender = await this.handlerAsPrivate().getSenderForTags();
986
1343
 
987
1344
  // Return a Noir Option struct with `some` and `value` fields
988
1345
  if (sender === undefined) {
@@ -994,19 +1351,21 @@ export class RPCTranslator {
994
1351
  }
995
1352
  }
996
1353
 
997
- async privateSetSenderForTags(foreignSenderForTags: ForeignCallSingle) {
1354
+ // eslint-disable-next-line camelcase
1355
+ async aztec_prv_setSenderForTags(foreignSenderForTags: ForeignCallSingle) {
998
1356
  const senderForTags = AztecAddress.fromField(fromSingle(foreignSenderForTags));
999
1357
 
1000
- await this.handlerAsPrivate().privateSetSenderForTags(senderForTags);
1358
+ await this.handlerAsPrivate().setSenderForTags(senderForTags);
1001
1359
 
1002
1360
  return toForeignCallResult([]);
1003
1361
  }
1004
1362
 
1005
- async privateGetNextAppTagAsSender(foreignSender: ForeignCallSingle, foreignRecipient: ForeignCallSingle) {
1363
+ // eslint-disable-next-line camelcase
1364
+ async aztec_prv_getNextAppTagAsSender(foreignSender: ForeignCallSingle, foreignRecipient: ForeignCallSingle) {
1006
1365
  const sender = AztecAddress.fromField(fromSingle(foreignSender));
1007
1366
  const recipient = AztecAddress.fromField(fromSingle(foreignRecipient));
1008
1367
 
1009
- const nextAppTag = await this.handlerAsPrivate().privateGetNextAppTagAsSender(sender, recipient);
1368
+ const nextAppTag = await this.handlerAsPrivate().getNextAppTagAsSender(sender, recipient);
1010
1369
 
1011
1370
  return toForeignCallResult([toSingle(nextAppTag.value)]);
1012
1371
  }