@aztec/txe 0.0.1-commit.cd76b27 → 0.0.1-commit.ce4f8c4f2

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 (54) hide show
  1. package/dest/index.d.ts +1 -1
  2. package/dest/index.d.ts.map +1 -1
  3. package/dest/index.js +88 -54
  4. package/dest/oracle/interfaces.d.ts +29 -28
  5. package/dest/oracle/interfaces.d.ts.map +1 -1
  6. package/dest/oracle/txe_oracle_public_context.d.ts +13 -13
  7. package/dest/oracle/txe_oracle_public_context.d.ts.map +1 -1
  8. package/dest/oracle/txe_oracle_public_context.js +12 -12
  9. package/dest/oracle/txe_oracle_top_level_context.d.ts +23 -23
  10. package/dest/oracle/txe_oracle_top_level_context.d.ts.map +1 -1
  11. package/dest/oracle/txe_oracle_top_level_context.js +52 -37
  12. package/dest/rpc_translator.d.ts +87 -82
  13. package/dest/rpc_translator.d.ts.map +1 -1
  14. package/dest/rpc_translator.js +273 -151
  15. package/dest/state_machine/archiver.d.ts +3 -3
  16. package/dest/state_machine/archiver.d.ts.map +1 -1
  17. package/dest/state_machine/archiver.js +5 -7
  18. package/dest/state_machine/dummy_p2p_client.d.ts +2 -2
  19. package/dest/state_machine/dummy_p2p_client.d.ts.map +1 -1
  20. package/dest/state_machine/dummy_p2p_client.js +1 -1
  21. package/dest/state_machine/index.d.ts +4 -2
  22. package/dest/state_machine/index.d.ts.map +1 -1
  23. package/dest/state_machine/index.js +7 -3
  24. package/dest/state_machine/mock_epoch_cache.d.ts +17 -3
  25. package/dest/state_machine/mock_epoch_cache.d.ts.map +1 -1
  26. package/dest/state_machine/mock_epoch_cache.js +32 -2
  27. package/dest/state_machine/synchronizer.d.ts +5 -5
  28. package/dest/state_machine/synchronizer.d.ts.map +1 -1
  29. package/dest/state_machine/synchronizer.js +3 -3
  30. package/dest/txe_session.d.ts +10 -6
  31. package/dest/txe_session.d.ts.map +1 -1
  32. package/dest/txe_session.js +28 -19
  33. package/dest/util/encoding.d.ts +69 -1
  34. package/dest/util/encoding.d.ts.map +1 -1
  35. package/dest/util/txe_public_contract_data_source.d.ts +2 -3
  36. package/dest/util/txe_public_contract_data_source.d.ts.map +1 -1
  37. package/dest/util/txe_public_contract_data_source.js +6 -25
  38. package/package.json +15 -15
  39. package/src/index.ts +89 -52
  40. package/src/oracle/interfaces.ts +32 -31
  41. package/src/oracle/txe_oracle_public_context.ts +12 -12
  42. package/src/oracle/txe_oracle_top_level_context.ts +65 -36
  43. package/src/rpc_translator.ts +305 -173
  44. package/src/state_machine/archiver.ts +5 -5
  45. package/src/state_machine/dummy_p2p_client.ts +1 -1
  46. package/src/state_machine/index.ts +6 -1
  47. package/src/state_machine/mock_epoch_cache.ts +42 -3
  48. package/src/state_machine/synchronizer.ts +4 -4
  49. package/src/txe_session.ts +36 -19
  50. package/src/util/txe_public_contract_data_source.ts +10 -38
  51. package/dest/util/txe_contract_store.d.ts +0 -12
  52. package/dest/util/txe_contract_store.d.ts.map +0 -1
  53. package/dest/util/txe_contract_store.js +0 -22
  54. package/src/util/txe_contract_store.ts +0 -36
@@ -30,7 +30,7 @@ import {
30
30
  toSingle,
31
31
  } from './util/encoding.js';
32
32
 
33
- const MAX_EVENT_LEN = 12; // This is MAX_MESSAGE_CONTENT_LEN - PRIVATE_EVENT_RESERVED_FIELDS
33
+ const MAX_EVENT_LEN = 10; // This is MAX_MESSAGE_CONTENT_LEN - PRIVATE_EVENT_MSG_PLAINTEXT_RESERVED_FIELDS_LEN
34
34
  const MAX_PRIVATE_EVENTS_PER_TXE_QUERY = 5;
35
35
 
36
36
  export class UnavailableOracleError extends Error {
@@ -104,13 +104,15 @@ export class RPCTranslator {
104
104
 
105
105
  // TXE session state transition functions - these get handled by the state handler
106
106
 
107
- async txeSetTopLevelTXEContext() {
107
+ // eslint-disable-next-line camelcase
108
+ async aztec_txe_setTopLevelTXEContext() {
108
109
  await this.stateHandler.enterTopLevelState();
109
110
 
110
111
  return toForeignCallResult([]);
111
112
  }
112
113
 
113
- async txeSetPrivateTXEContext(
114
+ // eslint-disable-next-line camelcase
115
+ async aztec_txe_setPrivateTXEContext(
114
116
  foreignContractAddressIsSome: ForeignCallSingle,
115
117
  foreignContractAddressValue: ForeignCallSingle,
116
118
  foreignAnchorBlockNumberIsSome: ForeignCallSingle,
@@ -129,7 +131,8 @@ export class RPCTranslator {
129
131
  return toForeignCallResult(privateContextInputs.toFields().map(toSingle));
130
132
  }
131
133
 
132
- async txeSetPublicTXEContext(
134
+ // eslint-disable-next-line camelcase
135
+ async aztec_txe_setPublicTXEContext(
133
136
  foreignContractAddressIsSome: ForeignCallSingle,
134
137
  foreignContractAddressValue: ForeignCallSingle,
135
138
  ) {
@@ -142,7 +145,8 @@ export class RPCTranslator {
142
145
  return toForeignCallResult([]);
143
146
  }
144
147
 
145
- async txeSetUtilityTXEContext(
148
+ // eslint-disable-next-line camelcase
149
+ async aztec_txe_setUtilityTXEContext(
146
150
  foreignContractAddressIsSome: ForeignCallSingle,
147
151
  foreignContractAddressValue: ForeignCallSingle,
148
152
  ) {
@@ -159,44 +163,54 @@ export class RPCTranslator {
159
163
 
160
164
  // TXE-specific oracles
161
165
 
162
- txeGetDefaultAddress() {
163
- const defaultAddress = this.handlerAsTxe().txeGetDefaultAddress();
166
+ // eslint-disable-next-line camelcase
167
+ aztec_txe_getDefaultAddress() {
168
+ const defaultAddress = this.handlerAsTxe().getDefaultAddress();
164
169
 
165
170
  return toForeignCallResult([toSingle(defaultAddress)]);
166
171
  }
167
172
 
168
- async txeGetNextBlockNumber() {
169
- const nextBlockNumber = await this.handlerAsTxe().txeGetNextBlockNumber();
173
+ // eslint-disable-next-line camelcase
174
+ async aztec_txe_getNextBlockNumber() {
175
+ const nextBlockNumber = await this.handlerAsTxe().getNextBlockNumber();
170
176
 
171
177
  return toForeignCallResult([toSingle(nextBlockNumber)]);
172
178
  }
173
179
 
174
- async txeGetNextBlockTimestamp() {
175
- const nextBlockTimestamp = await this.handlerAsTxe().txeGetNextBlockTimestamp();
180
+ // eslint-disable-next-line camelcase
181
+ async aztec_txe_getNextBlockTimestamp() {
182
+ const nextBlockTimestamp = await this.handlerAsTxe().getNextBlockTimestamp();
176
183
 
177
184
  return toForeignCallResult([toSingle(nextBlockTimestamp)]);
178
185
  }
179
186
 
180
- async txeAdvanceBlocksBy(foreignBlocks: ForeignCallSingle) {
187
+ // eslint-disable-next-line camelcase
188
+ async aztec_txe_advanceBlocksBy(foreignBlocks: ForeignCallSingle) {
181
189
  const blocks = fromSingle(foreignBlocks).toNumber();
182
190
 
183
- await this.handlerAsTxe().txeAdvanceBlocksBy(blocks);
191
+ await this.handlerAsTxe().advanceBlocksBy(blocks);
184
192
 
185
193
  return toForeignCallResult([]);
186
194
  }
187
195
 
188
- txeAdvanceTimestampBy(foreignDuration: ForeignCallSingle) {
196
+ // eslint-disable-next-line camelcase
197
+ aztec_txe_advanceTimestampBy(foreignDuration: ForeignCallSingle) {
189
198
  const duration = fromSingle(foreignDuration).toBigInt();
190
199
 
191
- this.handlerAsTxe().txeAdvanceTimestampBy(duration);
200
+ this.handlerAsTxe().advanceTimestampBy(duration);
192
201
 
193
202
  return toForeignCallResult([]);
194
203
  }
195
204
 
196
- 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
+ ) {
197
211
  const secret = fromSingle(foreignSecret);
198
212
 
199
- await this.handlerAsTxe().txeDeploy(artifact, instance, secret);
213
+ await this.handlerAsTxe().deploy(artifact, instance, secret);
200
214
 
201
215
  return toForeignCallResult([
202
216
  toArray([
@@ -209,10 +223,11 @@ export class RPCTranslator {
209
223
  ]);
210
224
  }
211
225
 
212
- async txeCreateAccount(foreignSecret: ForeignCallSingle) {
226
+ // eslint-disable-next-line camelcase
227
+ async aztec_txe_createAccount(foreignSecret: ForeignCallSingle) {
213
228
  const secret = fromSingle(foreignSecret);
214
229
 
215
- const completeAddress = await this.handlerAsTxe().txeCreateAccount(secret);
230
+ const completeAddress = await this.handlerAsTxe().createAccount(secret);
216
231
 
217
232
  return toForeignCallResult([
218
233
  toSingle(completeAddress.address),
@@ -220,14 +235,15 @@ export class RPCTranslator {
220
235
  ]);
221
236
  }
222
237
 
223
- async txeAddAccount(
238
+ // eslint-disable-next-line camelcase
239
+ async aztec_txe_addAccount(
224
240
  artifact: ContractArtifact,
225
241
  instance: ContractInstanceWithAddress,
226
242
  foreignSecret: ForeignCallSingle,
227
243
  ) {
228
244
  const secret = fromSingle(foreignSecret);
229
245
 
230
- const completeAddress = await this.handlerAsTxe().txeAddAccount(artifact, instance, secret);
246
+ const completeAddress = await this.handlerAsTxe().addAccount(artifact, instance, secret);
231
247
 
232
248
  return toForeignCallResult([
233
249
  toSingle(completeAddress.address),
@@ -235,39 +251,44 @@ export class RPCTranslator {
235
251
  ]);
236
252
  }
237
253
 
238
- async txeAddAuthWitness(foreignAddress: ForeignCallSingle, foreignMessageHash: ForeignCallSingle) {
254
+ // eslint-disable-next-line camelcase
255
+ async aztec_txe_addAuthWitness(foreignAddress: ForeignCallSingle, foreignMessageHash: ForeignCallSingle) {
239
256
  const address = addressFromSingle(foreignAddress);
240
257
  const messageHash = fromSingle(foreignMessageHash);
241
258
 
242
- await this.handlerAsTxe().txeAddAuthWitness(address, messageHash);
259
+ await this.handlerAsTxe().addAuthWitness(address, messageHash);
243
260
 
244
261
  return toForeignCallResult([]);
245
262
  }
246
263
 
247
264
  // PXE oracles
248
265
 
249
- utilityAssertCompatibleOracleVersion(foreignVersion: ForeignCallSingle) {
266
+ // eslint-disable-next-line camelcase
267
+ aztec_utl_assertCompatibleOracleVersion(foreignVersion: ForeignCallSingle) {
250
268
  const version = fromSingle(foreignVersion).toNumber();
251
269
 
252
- this.handlerAsMisc().utilityAssertCompatibleOracleVersion(version);
270
+ this.handlerAsMisc().assertCompatibleOracleVersion(version);
253
271
 
254
272
  return toForeignCallResult([]);
255
273
  }
256
274
 
257
- utilityGetRandomField() {
258
- const randomField = this.handlerAsMisc().utilityGetRandomField();
275
+ // eslint-disable-next-line camelcase
276
+ aztec_utl_getRandomField() {
277
+ const randomField = this.handlerAsMisc().getRandomField();
259
278
 
260
279
  return toForeignCallResult([toSingle(randomField)]);
261
280
  }
262
281
 
263
- async txeGetLastBlockTimestamp() {
264
- const timestamp = await this.handlerAsTxe().txeGetLastBlockTimestamp();
282
+ // eslint-disable-next-line camelcase
283
+ async aztec_txe_getLastBlockTimestamp() {
284
+ const timestamp = await this.handlerAsTxe().getLastBlockTimestamp();
265
285
 
266
286
  return toForeignCallResult([toSingle(new Fr(timestamp))]);
267
287
  }
268
288
 
269
- async txeGetLastTxEffects() {
270
- const { txHash, noteHashes, nullifiers } = await this.handlerAsTxe().txeGetLastTxEffects();
289
+ // eslint-disable-next-line camelcase
290
+ async aztec_txe_getLastTxEffects() {
291
+ const { txHash, noteHashes, nullifiers } = await this.handlerAsTxe().getLastTxEffects();
271
292
 
272
293
  return toForeignCallResult([
273
294
  toSingle(txHash.hash),
@@ -276,7 +297,8 @@ export class RPCTranslator {
276
297
  ]);
277
298
  }
278
299
 
279
- async txeGetPrivateEvents(
300
+ // eslint-disable-next-line camelcase
301
+ async aztec_txe_getPrivateEvents(
280
302
  foreignSelector: ForeignCallSingle,
281
303
  foreignContractAddress: ForeignCallSingle,
282
304
  foreignScope: ForeignCallSingle,
@@ -285,7 +307,14 @@ export class RPCTranslator {
285
307
  const contractAddress = addressFromSingle(foreignContractAddress);
286
308
  const scope = addressFromSingle(foreignScope);
287
309
 
288
- const events = await this.handlerAsTxe().txeGetPrivateEvents(selector, contractAddress, scope);
310
+ // TODO(F-335): Avoid doing the following 2 calls here.
311
+ {
312
+ await this.handlerAsTxe().syncContractNonOracleMethod(contractAddress, scope, this.stateHandler.getCurrentJob());
313
+ // We cycle job to commit the stores after the contract sync.
314
+ await this.stateHandler.cycleJob();
315
+ }
316
+
317
+ const events = await this.handlerAsTxe().getPrivateEvents(selector, contractAddress, scope);
289
318
 
290
319
  if (events.length > MAX_PRIVATE_EVENTS_PER_TXE_QUERY) {
291
320
  throw new Error(`Array of length ${events.length} larger than maxLen ${MAX_PRIVATE_EVENTS_PER_TXE_QUERY}`);
@@ -309,26 +338,29 @@ export class RPCTranslator {
309
338
  return toForeignCallResult([toArray(rawArrayStorage), toArray(eventLengths), toSingle(queryLength)]);
310
339
  }
311
340
 
312
- privateStoreInExecutionCache(foreignValues: ForeignCallArray, foreignHash: ForeignCallSingle) {
341
+ // eslint-disable-next-line camelcase
342
+ aztec_prv_storeInExecutionCache(foreignValues: ForeignCallArray, foreignHash: ForeignCallSingle) {
313
343
  const values = fromArray(foreignValues);
314
344
  const hash = fromSingle(foreignHash);
315
345
 
316
- this.handlerAsPrivate().privateStoreInExecutionCache(values, hash);
346
+ this.handlerAsPrivate().storeInExecutionCache(values, hash);
317
347
 
318
348
  return toForeignCallResult([]);
319
349
  }
320
350
 
321
- async privateLoadFromExecutionCache(foreignHash: ForeignCallSingle) {
351
+ // eslint-disable-next-line camelcase
352
+ async aztec_prv_loadFromExecutionCache(foreignHash: ForeignCallSingle) {
322
353
  const hash = fromSingle(foreignHash);
323
354
 
324
- const returns = await this.handlerAsPrivate().privateLoadFromExecutionCache(hash);
355
+ const returns = await this.handlerAsPrivate().loadFromExecutionCache(hash);
325
356
 
326
357
  return toForeignCallResult([toArray(returns)]);
327
358
  }
328
359
 
329
360
  // When the argument is a slice, noir automatically adds a length field to oracle call.
330
361
  // When the argument is an array, we add the field length manually to the signature.
331
- async utilityLog(
362
+ // eslint-disable-next-line camelcase
363
+ async aztec_utl_log(
332
364
  foreignLevel: ForeignCallSingle,
333
365
  foreignMessage: ForeignCallArray,
334
366
  _foreignLength: ForeignCallSingle,
@@ -340,12 +372,13 @@ export class RPCTranslator {
340
372
  .join('');
341
373
  const fields = fromArray(foreignFields);
342
374
 
343
- await this.handlerAsMisc().utilityLog(level, message, fields);
375
+ await this.handlerAsMisc().log(level, message, fields);
344
376
 
345
377
  return toForeignCallResult([]);
346
378
  }
347
379
 
348
- async utilityStorageRead(
380
+ // eslint-disable-next-line camelcase
381
+ async aztec_utl_storageRead(
349
382
  foreignBlockHash: ForeignCallSingle,
350
383
  foreignContractAddress: ForeignCallSingle,
351
384
  foreignStartStorageSlot: ForeignCallSingle,
@@ -356,7 +389,7 @@ export class RPCTranslator {
356
389
  const startStorageSlot = fromSingle(foreignStartStorageSlot);
357
390
  const numberOfElements = fromSingle(foreignNumberOfElements).toNumber();
358
391
 
359
- const values = await this.handlerAsUtility().utilityStorageRead(
392
+ const values = await this.handlerAsUtility().storageRead(
360
393
  blockHash,
361
394
  contractAddress,
362
395
  startStorageSlot,
@@ -366,11 +399,12 @@ export class RPCTranslator {
366
399
  return toForeignCallResult([toArray(values)]);
367
400
  }
368
401
 
369
- async utilityGetPublicDataWitness(foreignBlockHash: ForeignCallSingle, foreignLeafSlot: ForeignCallSingle) {
402
+ // eslint-disable-next-line camelcase
403
+ async aztec_utl_getPublicDataWitness(foreignBlockHash: ForeignCallSingle, foreignLeafSlot: ForeignCallSingle) {
370
404
  const blockHash = new BlockHash(fromSingle(foreignBlockHash));
371
405
  const leafSlot = fromSingle(foreignLeafSlot);
372
406
 
373
- const witness = await this.handlerAsUtility().utilityGetPublicDataWitness(blockHash, leafSlot);
407
+ const witness = await this.handlerAsUtility().getPublicDataWitness(blockHash, leafSlot);
374
408
 
375
409
  if (!witness) {
376
410
  throw new Error(`Public data witness not found for slot ${leafSlot} at block ${blockHash.toString()}.`);
@@ -378,7 +412,8 @@ export class RPCTranslator {
378
412
  return toForeignCallResult(witness.toNoirRepresentation());
379
413
  }
380
414
 
381
- async utilityGetNotes(
415
+ // eslint-disable-next-line camelcase
416
+ async aztec_utl_getNotes(
382
417
  foreignOwnerIsSome: ForeignCallSingle,
383
418
  foreignOwnerValue: ForeignCallSingle,
384
419
  foreignStorageSlot: ForeignCallSingle,
@@ -419,7 +454,7 @@ export class RPCTranslator {
419
454
  const maxNotes = fromSingle(foreignMaxNotes).toNumber();
420
455
  const packedHintedNoteLength = fromSingle(foreignPackedHintedNoteLength).toNumber();
421
456
 
422
- const noteDatas = await this.handlerAsUtility().utilityGetNotes(
457
+ const noteDatas = await this.handlerAsUtility().getNotes(
423
458
  owner,
424
459
  storageSlot,
425
460
  numSelects,
@@ -460,7 +495,8 @@ export class RPCTranslator {
460
495
  );
461
496
  }
462
497
 
463
- privateNotifyCreatedNote(
498
+ // eslint-disable-next-line camelcase
499
+ aztec_prv_notifyCreatedNote(
464
500
  foreignOwner: ForeignCallSingle,
465
501
  foreignStorageSlot: ForeignCallSingle,
466
502
  foreignRandomness: ForeignCallSingle,
@@ -477,20 +513,13 @@ export class RPCTranslator {
477
513
  const noteHash = fromSingle(foreignNoteHash);
478
514
  const counter = fromSingle(foreignCounter).toNumber();
479
515
 
480
- this.handlerAsPrivate().privateNotifyCreatedNote(
481
- owner,
482
- storageSlot,
483
- randomness,
484
- noteTypeId,
485
- note,
486
- noteHash,
487
- counter,
488
- );
516
+ this.handlerAsPrivate().notifyCreatedNote(owner, storageSlot, randomness, noteTypeId, note, noteHash, counter);
489
517
 
490
518
  return toForeignCallResult([]);
491
519
  }
492
520
 
493
- async privateNotifyNullifiedNote(
521
+ // eslint-disable-next-line camelcase
522
+ async aztec_prv_notifyNullifiedNote(
494
523
  foreignInnerNullifier: ForeignCallSingle,
495
524
  foreignNoteHash: ForeignCallSingle,
496
525
  foreignCounter: ForeignCallSingle,
@@ -499,40 +528,47 @@ export class RPCTranslator {
499
528
  const noteHash = fromSingle(foreignNoteHash);
500
529
  const counter = fromSingle(foreignCounter).toNumber();
501
530
 
502
- await this.handlerAsPrivate().privateNotifyNullifiedNote(innerNullifier, noteHash, counter);
531
+ await this.handlerAsPrivate().notifyNullifiedNote(innerNullifier, noteHash, counter);
503
532
 
504
533
  return toForeignCallResult([]);
505
534
  }
506
535
 
507
- async privateNotifyCreatedNullifier(foreignInnerNullifier: ForeignCallSingle) {
536
+ // eslint-disable-next-line camelcase
537
+ async aztec_prv_notifyCreatedNullifier(foreignInnerNullifier: ForeignCallSingle) {
508
538
  const innerNullifier = fromSingle(foreignInnerNullifier);
509
539
 
510
- await this.handlerAsPrivate().privateNotifyCreatedNullifier(innerNullifier);
540
+ await this.handlerAsPrivate().notifyCreatedNullifier(innerNullifier);
511
541
 
512
542
  return toForeignCallResult([]);
513
543
  }
514
544
 
515
- async privateIsNullifierPending(foreignInnerNullifier: ForeignCallSingle, foreignContractAddress: ForeignCallSingle) {
545
+ // eslint-disable-next-line camelcase
546
+ async aztec_prv_isNullifierPending(
547
+ foreignInnerNullifier: ForeignCallSingle,
548
+ foreignContractAddress: ForeignCallSingle,
549
+ ) {
516
550
  const innerNullifier = fromSingle(foreignInnerNullifier);
517
551
  const contractAddress = addressFromSingle(foreignContractAddress);
518
552
 
519
- const isPending = await this.handlerAsPrivate().privateIsNullifierPending(innerNullifier, contractAddress);
553
+ const isPending = await this.handlerAsPrivate().isNullifierPending(innerNullifier, contractAddress);
520
554
 
521
555
  return toForeignCallResult([toSingle(new Fr(isPending))]);
522
556
  }
523
557
 
524
- async utilityCheckNullifierExists(foreignInnerNullifier: ForeignCallSingle) {
558
+ // eslint-disable-next-line camelcase
559
+ async aztec_utl_checkNullifierExists(foreignInnerNullifier: ForeignCallSingle) {
525
560
  const innerNullifier = fromSingle(foreignInnerNullifier);
526
561
 
527
- const exists = await this.handlerAsUtility().utilityCheckNullifierExists(innerNullifier);
562
+ const exists = await this.handlerAsUtility().checkNullifierExists(innerNullifier);
528
563
 
529
564
  return toForeignCallResult([toSingle(new Fr(exists))]);
530
565
  }
531
566
 
532
- async utilityGetContractInstance(foreignAddress: ForeignCallSingle) {
567
+ // eslint-disable-next-line camelcase
568
+ async aztec_utl_getContractInstance(foreignAddress: ForeignCallSingle) {
533
569
  const address = addressFromSingle(foreignAddress);
534
570
 
535
- const instance = await this.handlerAsUtility().utilityGetContractInstance(address);
571
+ const instance = await this.handlerAsUtility().getContractInstance(address);
536
572
 
537
573
  return toForeignCallResult(
538
574
  [
@@ -545,10 +581,11 @@ export class RPCTranslator {
545
581
  );
546
582
  }
547
583
 
548
- async utilityTryGetPublicKeysAndPartialAddress(foreignAddress: ForeignCallSingle) {
584
+ // eslint-disable-next-line camelcase
585
+ async aztec_utl_tryGetPublicKeysAndPartialAddress(foreignAddress: ForeignCallSingle) {
549
586
  const address = addressFromSingle(foreignAddress);
550
587
 
551
- const result = await this.handlerAsUtility().utilityTryGetPublicKeysAndPartialAddress(address);
588
+ const result = await this.handlerAsUtility().tryGetPublicKeysAndPartialAddress(address);
552
589
 
553
590
  // We are going to return a Noir Option struct to represent the possibility of null values. Options are a struct
554
591
  // with two fields: `some` (a boolean) and `value` (a field array in this case).
@@ -564,15 +601,17 @@ export class RPCTranslator {
564
601
  }
565
602
  }
566
603
 
567
- async utilityGetKeyValidationRequest(foreignPkMHash: ForeignCallSingle) {
604
+ // eslint-disable-next-line camelcase
605
+ async aztec_utl_getKeyValidationRequest(foreignPkMHash: ForeignCallSingle) {
568
606
  const pkMHash = fromSingle(foreignPkMHash);
569
607
 
570
- const keyValidationRequest = await this.handlerAsUtility().utilityGetKeyValidationRequest(pkMHash);
608
+ const keyValidationRequest = await this.handlerAsUtility().getKeyValidationRequest(pkMHash);
571
609
 
572
610
  return toForeignCallResult(keyValidationRequest.toFields().map(toSingle));
573
611
  }
574
612
 
575
- privateCallPrivateFunction(
613
+ // eslint-disable-next-line camelcase
614
+ aztec_prv_callPrivateFunction(
576
615
  _foreignTargetContractAddress: ForeignCallSingle,
577
616
  _foreignFunctionSelector: ForeignCallSingle,
578
617
  _foreignArgsHash: ForeignCallSingle,
@@ -584,11 +623,15 @@ export class RPCTranslator {
584
623
  );
585
624
  }
586
625
 
587
- async utilityGetNullifierMembershipWitness(foreignBlockHash: ForeignCallSingle, foreignNullifier: ForeignCallSingle) {
626
+ // eslint-disable-next-line camelcase
627
+ async aztec_utl_getNullifierMembershipWitness(
628
+ foreignBlockHash: ForeignCallSingle,
629
+ foreignNullifier: ForeignCallSingle,
630
+ ) {
588
631
  const blockHash = new BlockHash(fromSingle(foreignBlockHash));
589
632
  const nullifier = fromSingle(foreignNullifier);
590
633
 
591
- const witness = await this.handlerAsUtility().utilityGetNullifierMembershipWitness(blockHash, nullifier);
634
+ const witness = await this.handlerAsUtility().getNullifierMembershipWitness(blockHash, nullifier);
592
635
 
593
636
  if (!witness) {
594
637
  throw new Error(`Nullifier membership witness not found at block ${blockHash}.`);
@@ -596,10 +639,11 @@ export class RPCTranslator {
596
639
  return toForeignCallResult(witness.toNoirRepresentation());
597
640
  }
598
641
 
599
- async utilityGetAuthWitness(foreignMessageHash: ForeignCallSingle) {
642
+ // eslint-disable-next-line camelcase
643
+ async aztec_utl_getAuthWitness(foreignMessageHash: ForeignCallSingle) {
600
644
  const messageHash = fromSingle(foreignMessageHash);
601
645
 
602
- const authWitness = await this.handlerAsUtility().utilityGetAuthWitness(messageHash);
646
+ const authWitness = await this.handlerAsUtility().getAuthWitness(messageHash);
603
647
 
604
648
  if (!authWitness) {
605
649
  throw new Error(`Auth witness not found for message hash ${messageHash}.`);
@@ -607,44 +651,35 @@ export class RPCTranslator {
607
651
  return toForeignCallResult([toArray(authWitness)]);
608
652
  }
609
653
 
610
- public privateNotifyEnqueuedPublicFunctionCall(
611
- _foreignTargetContractAddress: ForeignCallSingle,
612
- _foreignCalldataHash: ForeignCallSingle,
613
- _foreignSideEffectCounter: ForeignCallSingle,
614
- _foreignIsStaticCall: ForeignCallSingle,
615
- ) {
616
- throw new Error('Enqueueing public calls is not supported in TestEnvironment::private_context');
617
- }
618
-
619
- public privateNotifySetPublicTeardownFunctionCall(
620
- _foreignTargetContractAddress: ForeignCallSingle,
621
- _foreignCalldataHash: ForeignCallSingle,
622
- _foreignSideEffectCounter: ForeignCallSingle,
623
- _foreignIsStaticCall: ForeignCallSingle,
624
- ) {
654
+ // eslint-disable-next-line camelcase
655
+ public aztec_prv_validatePublicCalldata(_foreignCalldataHash: ForeignCallSingle) {
625
656
  throw new Error('Enqueueing public calls is not supported in TestEnvironment::private_context');
626
657
  }
627
658
 
628
- public privateNotifySetMinRevertibleSideEffectCounter(_foreignMinRevertibleSideEffectCounter: ForeignCallSingle) {
659
+ // eslint-disable-next-line camelcase
660
+ public aztec_prv_notifyRevertiblePhaseStart(_foreignMinRevertibleSideEffectCounter: ForeignCallSingle) {
629
661
  throw new Error('Enqueueing public calls is not supported in TestEnvironment::private_context');
630
662
  }
631
663
 
632
- public async privateIsSideEffectCounterRevertible(foreignSideEffectCounter: ForeignCallSingle) {
664
+ // eslint-disable-next-line camelcase
665
+ public async aztec_prv_inRevertiblePhase(foreignSideEffectCounter: ForeignCallSingle) {
633
666
  const sideEffectCounter = fromSingle(foreignSideEffectCounter).toNumber();
634
- const isRevertible = await this.handlerAsPrivate().privateIsSideEffectCounterRevertible(sideEffectCounter);
667
+ const isRevertible = await this.handlerAsPrivate().inRevertiblePhase(sideEffectCounter);
635
668
  return toForeignCallResult([toSingle(new Fr(isRevertible))]);
636
669
  }
637
670
 
638
- utilityGetUtilityContext() {
639
- const context = this.handlerAsUtility().utilityGetUtilityContext();
671
+ // eslint-disable-next-line camelcase
672
+ aztec_utl_getUtilityContext() {
673
+ const context = this.handlerAsUtility().getUtilityContext();
640
674
 
641
675
  return toForeignCallResult(context.toNoirRepresentation());
642
676
  }
643
677
 
644
- async utilityGetBlockHeader(foreignBlockNumber: ForeignCallSingle) {
678
+ // eslint-disable-next-line camelcase
679
+ async aztec_utl_getBlockHeader(foreignBlockNumber: ForeignCallSingle) {
645
680
  const blockNumber = BlockNumber(fromSingle(foreignBlockNumber).toNumber());
646
681
 
647
- const header = await this.handlerAsUtility().utilityGetBlockHeader(blockNumber);
682
+ const header = await this.handlerAsUtility().getBlockHeader(blockNumber);
648
683
 
649
684
  if (!header) {
650
685
  throw new Error(`Block header not found for block ${blockNumber}.`);
@@ -652,14 +687,15 @@ export class RPCTranslator {
652
687
  return toForeignCallResult(header.toFields().map(toSingle));
653
688
  }
654
689
 
655
- async utilityGetNoteHashMembershipWitness(
690
+ // eslint-disable-next-line camelcase
691
+ async aztec_utl_getNoteHashMembershipWitness(
656
692
  foreignAnchorBlockHash: ForeignCallSingle,
657
693
  foreignNoteHash: ForeignCallSingle,
658
694
  ) {
659
695
  const blockHash = new BlockHash(fromSingle(foreignAnchorBlockHash));
660
696
  const noteHash = fromSingle(foreignNoteHash);
661
697
 
662
- const witness = await this.handlerAsUtility().utilityGetNoteHashMembershipWitness(blockHash, noteHash);
698
+ const witness = await this.handlerAsUtility().getNoteHashMembershipWitness(blockHash, noteHash);
663
699
 
664
700
  if (!witness) {
665
701
  throw new Error(`Note hash ${noteHash} not found in the note hash tree at block ${blockHash.toString()}.`);
@@ -667,14 +703,15 @@ export class RPCTranslator {
667
703
  return toForeignCallResult(witness.toNoirRepresentation());
668
704
  }
669
705
 
670
- async utilityGetBlockHashMembershipWitness(
706
+ // eslint-disable-next-line camelcase
707
+ async aztec_utl_getBlockHashMembershipWitness(
671
708
  foreignAnchorBlockHash: ForeignCallSingle,
672
709
  foreignBlockHash: ForeignCallSingle,
673
710
  ) {
674
711
  const anchorBlockHash = new BlockHash(fromSingle(foreignAnchorBlockHash));
675
712
  const blockHash = new BlockHash(fromSingle(foreignBlockHash));
676
713
 
677
- const witness = await this.handlerAsUtility().utilityGetBlockHashMembershipWitness(anchorBlockHash, blockHash);
714
+ const witness = await this.handlerAsUtility().getBlockHashMembershipWitness(anchorBlockHash, blockHash);
678
715
 
679
716
  if (!witness) {
680
717
  throw new Error(
@@ -684,14 +721,15 @@ export class RPCTranslator {
684
721
  return toForeignCallResult(witness.toNoirRepresentation());
685
722
  }
686
723
 
687
- async utilityGetLowNullifierMembershipWitness(
724
+ // eslint-disable-next-line camelcase
725
+ async aztec_utl_getLowNullifierMembershipWitness(
688
726
  foreignBlockHash: ForeignCallSingle,
689
727
  foreignNullifier: ForeignCallSingle,
690
728
  ) {
691
729
  const blockHash = new BlockHash(fromSingle(foreignBlockHash));
692
730
  const nullifier = fromSingle(foreignNullifier);
693
731
 
694
- const witness = await this.handlerAsUtility().utilityGetLowNullifierMembershipWitness(blockHash, nullifier);
732
+ const witness = await this.handlerAsUtility().getLowNullifierMembershipWitness(blockHash, nullifier);
695
733
 
696
734
  if (!witness) {
697
735
  throw new Error(`Low nullifier witness not found for nullifier ${nullifier} at block ${blockHash}.`);
@@ -699,33 +737,42 @@ export class RPCTranslator {
699
737
  return toForeignCallResult(witness.toNoirRepresentation());
700
738
  }
701
739
 
702
- async utilityFetchTaggedLogs(foreignPendingTaggedLogArrayBaseSlot: ForeignCallSingle) {
740
+ // eslint-disable-next-line camelcase
741
+ async aztec_utl_fetchTaggedLogs(foreignPendingTaggedLogArrayBaseSlot: ForeignCallSingle) {
703
742
  const pendingTaggedLogArrayBaseSlot = fromSingle(foreignPendingTaggedLogArrayBaseSlot);
704
743
 
705
- await this.handlerAsUtility().utilityFetchTaggedLogs(pendingTaggedLogArrayBaseSlot);
744
+ await this.handlerAsUtility().fetchTaggedLogs(pendingTaggedLogArrayBaseSlot);
706
745
 
707
746
  return toForeignCallResult([]);
708
747
  }
709
748
 
710
- public async utilityValidateAndStoreEnqueuedNotesAndEvents(
749
+ // eslint-disable-next-line camelcase
750
+ public async aztec_utl_validateAndStoreEnqueuedNotesAndEvents(
711
751
  foreignContractAddress: ForeignCallSingle,
712
752
  foreignNoteValidationRequestsArrayBaseSlot: ForeignCallSingle,
713
753
  foreignEventValidationRequestsArrayBaseSlot: ForeignCallSingle,
754
+ foreignMaxNotePackedLen: ForeignCallSingle,
755
+ foreignMaxEventSerializedLen: ForeignCallSingle,
714
756
  ) {
715
757
  const contractAddress = AztecAddress.fromField(fromSingle(foreignContractAddress));
716
758
  const noteValidationRequestsArrayBaseSlot = fromSingle(foreignNoteValidationRequestsArrayBaseSlot);
717
759
  const eventValidationRequestsArrayBaseSlot = fromSingle(foreignEventValidationRequestsArrayBaseSlot);
760
+ const maxNotePackedLen = fromSingle(foreignMaxNotePackedLen).toNumber();
761
+ const maxEventSerializedLen = fromSingle(foreignMaxEventSerializedLen).toNumber();
718
762
 
719
- await this.handlerAsUtility().utilityValidateAndStoreEnqueuedNotesAndEvents(
763
+ await this.handlerAsUtility().validateAndStoreEnqueuedNotesAndEvents(
720
764
  contractAddress,
721
765
  noteValidationRequestsArrayBaseSlot,
722
766
  eventValidationRequestsArrayBaseSlot,
767
+ maxNotePackedLen,
768
+ maxEventSerializedLen,
723
769
  );
724
770
 
725
771
  return toForeignCallResult([]);
726
772
  }
727
773
 
728
- public async utilityBulkRetrieveLogs(
774
+ // eslint-disable-next-line camelcase
775
+ public async aztec_utl_bulkRetrieveLogs(
729
776
  foreignContractAddress: ForeignCallSingle,
730
777
  foreignLogRetrievalRequestsArrayBaseSlot: ForeignCallSingle,
731
778
  foreignLogRetrievalResponsesArrayBaseSlot: ForeignCallSingle,
@@ -734,7 +781,7 @@ export class RPCTranslator {
734
781
  const logRetrievalRequestsArrayBaseSlot = fromSingle(foreignLogRetrievalRequestsArrayBaseSlot);
735
782
  const logRetrievalResponsesArrayBaseSlot = fromSingle(foreignLogRetrievalResponsesArrayBaseSlot);
736
783
 
737
- await this.handlerAsUtility().utilityBulkRetrieveLogs(
784
+ await this.handlerAsUtility().bulkRetrieveLogs(
738
785
  contractAddress,
739
786
  logRetrievalRequestsArrayBaseSlot,
740
787
  logRetrievalResponsesArrayBaseSlot,
@@ -743,7 +790,27 @@ export class RPCTranslator {
743
790
  return toForeignCallResult([]);
744
791
  }
745
792
 
746
- async utilityStoreCapsule(
793
+ // eslint-disable-next-line camelcase
794
+ public async aztec_utl_utilityResolveMessageContexts(
795
+ foreignContractAddress: ForeignCallSingle,
796
+ foreignMessageContextRequestsArrayBaseSlot: ForeignCallSingle,
797
+ foreignMessageContextResponsesArrayBaseSlot: ForeignCallSingle,
798
+ ) {
799
+ const contractAddress = AztecAddress.fromField(fromSingle(foreignContractAddress));
800
+ const messageContextRequestsArrayBaseSlot = fromSingle(foreignMessageContextRequestsArrayBaseSlot);
801
+ const messageContextResponsesArrayBaseSlot = fromSingle(foreignMessageContextResponsesArrayBaseSlot);
802
+
803
+ await this.handlerAsUtility().utilityResolveMessageContexts(
804
+ contractAddress,
805
+ messageContextRequestsArrayBaseSlot,
806
+ messageContextResponsesArrayBaseSlot,
807
+ );
808
+
809
+ return toForeignCallResult([]);
810
+ }
811
+
812
+ // eslint-disable-next-line camelcase
813
+ async aztec_utl_storeCapsule(
747
814
  foreignContractAddress: ForeignCallSingle,
748
815
  foreignSlot: ForeignCallSingle,
749
816
  foreignCapsule: ForeignCallArray,
@@ -752,12 +819,13 @@ export class RPCTranslator {
752
819
  const slot = fromSingle(foreignSlot);
753
820
  const capsule = fromArray(foreignCapsule);
754
821
 
755
- await this.handlerAsUtility().utilityStoreCapsule(contractAddress, slot, capsule);
822
+ await this.handlerAsUtility().storeCapsule(contractAddress, slot, capsule);
756
823
 
757
824
  return toForeignCallResult([]);
758
825
  }
759
826
 
760
- async utilityLoadCapsule(
827
+ // eslint-disable-next-line camelcase
828
+ async aztec_utl_loadCapsule(
761
829
  foreignContractAddress: ForeignCallSingle,
762
830
  foreignSlot: ForeignCallSingle,
763
831
  foreignTSize: ForeignCallSingle,
@@ -766,7 +834,7 @@ export class RPCTranslator {
766
834
  const slot = fromSingle(foreignSlot);
767
835
  const tSize = fromSingle(foreignTSize).toNumber();
768
836
 
769
- const values = await this.handlerAsUtility().utilityLoadCapsule(contractAddress, slot);
837
+ const values = await this.handlerAsUtility().loadCapsule(contractAddress, slot);
770
838
 
771
839
  // We are going to return a Noir Option struct to represent the possibility of null values. Options are a struct
772
840
  // with two fields: `some` (a boolean) and `value` (a field array in this case).
@@ -779,16 +847,18 @@ export class RPCTranslator {
779
847
  }
780
848
  }
781
849
 
782
- async utilityDeleteCapsule(foreignContractAddress: ForeignCallSingle, foreignSlot: ForeignCallSingle) {
850
+ // eslint-disable-next-line camelcase
851
+ async aztec_utl_deleteCapsule(foreignContractAddress: ForeignCallSingle, foreignSlot: ForeignCallSingle) {
783
852
  const contractAddress = AztecAddress.fromField(fromSingle(foreignContractAddress));
784
853
  const slot = fromSingle(foreignSlot);
785
854
 
786
- await this.handlerAsUtility().utilityDeleteCapsule(contractAddress, slot);
855
+ await this.handlerAsUtility().deleteCapsule(contractAddress, slot);
787
856
 
788
857
  return toForeignCallResult([]);
789
858
  }
790
859
 
791
- async utilityCopyCapsule(
860
+ // eslint-disable-next-line camelcase
861
+ async aztec_utl_copyCapsule(
792
862
  foreignContractAddress: ForeignCallSingle,
793
863
  foreignSrcSlot: ForeignCallSingle,
794
864
  foreignDstSlot: ForeignCallSingle,
@@ -799,7 +869,7 @@ export class RPCTranslator {
799
869
  const dstSlot = fromSingle(foreignDstSlot);
800
870
  const numEntries = fromSingle(foreignNumEntries).toNumber();
801
871
 
802
- await this.handlerAsUtility().utilityCopyCapsule(contractAddress, srcSlot, dstSlot, numEntries);
872
+ await this.handlerAsUtility().copyCapsule(contractAddress, srcSlot, dstSlot, numEntries);
803
873
 
804
874
  return toForeignCallResult([]);
805
875
  }
@@ -808,7 +878,8 @@ export class RPCTranslator {
808
878
  // 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
809
879
  // to implement this function here. Isn't there a way to programmatically identify that this is missing, given the
810
880
  // existence of a txe_oracle method?
811
- async utilityAes128Decrypt(
881
+ // eslint-disable-next-line camelcase
882
+ async aztec_utl_tryAes128Decrypt(
812
883
  foreignCiphertextBVecStorage: ForeignCallArray,
813
884
  foreignCiphertextLength: ForeignCallSingle,
814
885
  foreignIv: ForeignCallArray,
@@ -818,14 +889,22 @@ export class RPCTranslator {
818
889
  const iv = fromUintArray(foreignIv, 8);
819
890
  const symKey = fromUintArray(foreignSymKey, 8);
820
891
 
821
- const plaintextBuffer = await this.handlerAsUtility().utilityAes128Decrypt(ciphertext, iv, symKey);
822
-
823
- return toForeignCallResult(
824
- arrayToBoundedVec(bufferToU8Array(plaintextBuffer), foreignCiphertextBVecStorage.length),
825
- );
892
+ // Noir Option<BoundedVec> is encoded as [is_some: Field, storage: Field[], length: Field].
893
+ try {
894
+ const plaintextBuffer = await this.handlerAsUtility().aes128Decrypt(ciphertext, iv, symKey);
895
+ const [storage, length] = arrayToBoundedVec(
896
+ bufferToU8Array(plaintextBuffer),
897
+ foreignCiphertextBVecStorage.length,
898
+ );
899
+ return toForeignCallResult([toSingle(new Fr(1)), storage, length]);
900
+ } catch {
901
+ const zeroStorage = toArray(Array(foreignCiphertextBVecStorage.length).fill(new Fr(0)));
902
+ return toForeignCallResult([toSingle(new Fr(0)), zeroStorage, toSingle(new Fr(0))]);
903
+ }
826
904
  }
827
905
 
828
- async utilityGetSharedSecret(
906
+ // eslint-disable-next-line camelcase
907
+ async aztec_utl_getSharedSecret(
829
908
  foreignAddress: ForeignCallSingle,
830
909
  foreignEphPKField0: ForeignCallSingle,
831
910
  foreignEphPKField1: ForeignCallSingle,
@@ -838,44 +917,66 @@ export class RPCTranslator {
838
917
  fromSingle(foreignEphPKField2),
839
918
  ]);
840
919
 
841
- const secret = await this.handlerAsUtility().utilityGetSharedSecret(address, ephPK);
920
+ const secret = await this.handlerAsUtility().getSharedSecret(address, ephPK);
842
921
 
843
922
  return toForeignCallResult(secret.toFields().map(toSingle));
844
923
  }
845
924
 
846
- emitOffchainEffect(_foreignData: ForeignCallArray) {
925
+ // eslint-disable-next-line camelcase
926
+ aztec_utl_invalidateContractSyncCache(
927
+ foreignContractAddress: ForeignCallSingle,
928
+ foreignScopes: ForeignCallArray,
929
+ foreignScopeCount: ForeignCallSingle,
930
+ ) {
931
+ const contractAddress = addressFromSingle(foreignContractAddress);
932
+ const count = fromSingle(foreignScopeCount).toNumber();
933
+ const scopes = fromArray(foreignScopes)
934
+ .slice(0, count)
935
+ .map(f => new AztecAddress(f));
936
+
937
+ this.handlerAsUtility().invalidateContractSyncCache(contractAddress, scopes);
938
+
939
+ return Promise.resolve(toForeignCallResult([]));
940
+ }
941
+
942
+ // eslint-disable-next-line camelcase
943
+ aztec_utl_emitOffchainEffect(_foreignData: ForeignCallArray) {
847
944
  throw new Error('Offchain effects are not yet supported in the TestEnvironment');
848
945
  }
849
946
 
850
947
  // AVM opcodes
851
948
 
852
- avmOpcodeEmitPublicLog(_foreignMessage: ForeignCallArray) {
949
+ // eslint-disable-next-line camelcase
950
+ aztec_avm_emitPublicLog(_foreignMessage: ForeignCallArray) {
853
951
  // TODO(#8811): Implement
854
952
  return toForeignCallResult([]);
855
953
  }
856
954
 
857
- async avmOpcodeStorageRead(foreignSlot: ForeignCallSingle, foreignContractAddress: ForeignCallSingle) {
955
+ // eslint-disable-next-line camelcase
956
+ async aztec_avm_storageRead(foreignSlot: ForeignCallSingle, foreignContractAddress: ForeignCallSingle) {
858
957
  const slot = fromSingle(foreignSlot);
859
958
  const contractAddress = AztecAddress.fromField(fromSingle(foreignContractAddress));
860
959
 
861
- const value = (await this.handlerAsAvm().avmOpcodeStorageRead(slot, contractAddress)).value;
960
+ const value = (await this.handlerAsAvm().storageRead(slot, contractAddress)).value;
862
961
 
863
962
  return toForeignCallResult([toSingle(new Fr(value))]);
864
963
  }
865
964
 
866
- async avmOpcodeStorageWrite(foreignSlot: ForeignCallSingle, foreignValue: ForeignCallSingle) {
965
+ // eslint-disable-next-line camelcase
966
+ async aztec_avm_storageWrite(foreignSlot: ForeignCallSingle, foreignValue: ForeignCallSingle) {
867
967
  const slot = fromSingle(foreignSlot);
868
968
  const value = fromSingle(foreignValue);
869
969
 
870
- await this.handlerAsAvm().avmOpcodeStorageWrite(slot, value);
970
+ await this.handlerAsAvm().storageWrite(slot, value);
871
971
 
872
972
  return toForeignCallResult([]);
873
973
  }
874
974
 
875
- async avmOpcodeGetContractInstanceDeployer(foreignAddress: ForeignCallSingle) {
975
+ // eslint-disable-next-line camelcase
976
+ async aztec_avm_getContractInstanceDeployer(foreignAddress: ForeignCallSingle) {
876
977
  const address = addressFromSingle(foreignAddress);
877
978
 
878
- const instance = await this.handlerAsUtility().utilityGetContractInstance(address);
979
+ const instance = await this.handlerAsUtility().getContractInstance(address);
879
980
 
880
981
  return toForeignCallResult([
881
982
  toSingle(instance.deployer),
@@ -884,10 +985,11 @@ export class RPCTranslator {
884
985
  ]);
885
986
  }
886
987
 
887
- async avmOpcodeGetContractInstanceClassId(foreignAddress: ForeignCallSingle) {
988
+ // eslint-disable-next-line camelcase
989
+ async aztec_avm_getContractInstanceClassId(foreignAddress: ForeignCallSingle) {
888
990
  const address = addressFromSingle(foreignAddress);
889
991
 
890
- const instance = await this.handlerAsUtility().utilityGetContractInstance(address);
992
+ const instance = await this.handlerAsUtility().getContractInstance(address);
891
993
 
892
994
  return toForeignCallResult([
893
995
  toSingle(instance.currentContractClassId),
@@ -896,10 +998,11 @@ export class RPCTranslator {
896
998
  ]);
897
999
  }
898
1000
 
899
- async avmOpcodeGetContractInstanceInitializationHash(foreignAddress: ForeignCallSingle) {
1001
+ // eslint-disable-next-line camelcase
1002
+ async aztec_avm_getContractInstanceInitializationHash(foreignAddress: ForeignCallSingle) {
900
1003
  const address = addressFromSingle(foreignAddress);
901
1004
 
902
- const instance = await this.handlerAsUtility().utilityGetContractInstance(address);
1005
+ const instance = await this.handlerAsUtility().getContractInstance(address);
903
1006
 
904
1007
  return toForeignCallResult([
905
1008
  toSingle(instance.initializationHash),
@@ -908,85 +1011,98 @@ export class RPCTranslator {
908
1011
  ]);
909
1012
  }
910
1013
 
911
- async avmOpcodeSender() {
912
- const sender = await this.handlerAsAvm().avmOpcodeSender();
1014
+ // eslint-disable-next-line camelcase
1015
+ async aztec_avm_sender() {
1016
+ const sender = await this.handlerAsAvm().sender();
913
1017
 
914
1018
  return toForeignCallResult([toSingle(sender)]);
915
1019
  }
916
1020
 
917
- async avmOpcodeEmitNullifier(foreignNullifier: ForeignCallSingle) {
1021
+ // eslint-disable-next-line camelcase
1022
+ async aztec_avm_emitNullifier(foreignNullifier: ForeignCallSingle) {
918
1023
  const nullifier = fromSingle(foreignNullifier);
919
1024
 
920
- await this.handlerAsAvm().avmOpcodeEmitNullifier(nullifier);
1025
+ await this.handlerAsAvm().emitNullifier(nullifier);
921
1026
 
922
1027
  return toForeignCallResult([]);
923
1028
  }
924
1029
 
925
- async avmOpcodeEmitNoteHash(foreignNoteHash: ForeignCallSingle) {
1030
+ // eslint-disable-next-line camelcase
1031
+ async aztec_avm_emitNoteHash(foreignNoteHash: ForeignCallSingle) {
926
1032
  const noteHash = fromSingle(foreignNoteHash);
927
1033
 
928
- await this.handlerAsAvm().avmOpcodeEmitNoteHash(noteHash);
1034
+ await this.handlerAsAvm().emitNoteHash(noteHash);
929
1035
 
930
1036
  return toForeignCallResult([]);
931
1037
  }
932
1038
 
933
- async avmOpcodeNullifierExists(foreignSiloedNullifier: ForeignCallSingle) {
1039
+ // eslint-disable-next-line camelcase
1040
+ async aztec_avm_nullifierExists(foreignSiloedNullifier: ForeignCallSingle) {
934
1041
  const siloedNullifier = fromSingle(foreignSiloedNullifier);
935
1042
 
936
- const exists = await this.handlerAsAvm().avmOpcodeNullifierExists(siloedNullifier);
1043
+ const exists = await this.handlerAsAvm().nullifierExists(siloedNullifier);
937
1044
 
938
1045
  return toForeignCallResult([toSingle(new Fr(exists))]);
939
1046
  }
940
1047
 
941
- async avmOpcodeAddress() {
942
- const contractAddress = await this.handlerAsAvm().avmOpcodeAddress();
1048
+ // eslint-disable-next-line camelcase
1049
+ async aztec_avm_address() {
1050
+ const contractAddress = await this.handlerAsAvm().address();
943
1051
 
944
1052
  return toForeignCallResult([toSingle(contractAddress.toField())]);
945
1053
  }
946
1054
 
947
- async avmOpcodeBlockNumber() {
948
- const blockNumber = await this.handlerAsAvm().avmOpcodeBlockNumber();
1055
+ // eslint-disable-next-line camelcase
1056
+ async aztec_avm_blockNumber() {
1057
+ const blockNumber = await this.handlerAsAvm().blockNumber();
949
1058
 
950
1059
  return toForeignCallResult([toSingle(new Fr(blockNumber))]);
951
1060
  }
952
1061
 
953
- async avmOpcodeTimestamp() {
954
- const timestamp = await this.handlerAsAvm().avmOpcodeTimestamp();
1062
+ // eslint-disable-next-line camelcase
1063
+ async aztec_avm_timestamp() {
1064
+ const timestamp = await this.handlerAsAvm().timestamp();
955
1065
 
956
1066
  return toForeignCallResult([toSingle(new Fr(timestamp))]);
957
1067
  }
958
1068
 
959
- async avmOpcodeIsStaticCall() {
960
- const isStaticCall = await this.handlerAsAvm().avmOpcodeIsStaticCall();
1069
+ // eslint-disable-next-line camelcase
1070
+ async aztec_avm_isStaticCall() {
1071
+ const isStaticCall = await this.handlerAsAvm().isStaticCall();
961
1072
 
962
1073
  return toForeignCallResult([toSingle(new Fr(isStaticCall ? 1 : 0))]);
963
1074
  }
964
1075
 
965
- async avmOpcodeChainId() {
966
- const chainId = await this.handlerAsAvm().avmOpcodeChainId();
1076
+ // eslint-disable-next-line camelcase
1077
+ async aztec_avm_chainId() {
1078
+ const chainId = await this.handlerAsAvm().chainId();
967
1079
 
968
1080
  return toForeignCallResult([toSingle(chainId)]);
969
1081
  }
970
1082
 
971
- async avmOpcodeVersion() {
972
- const version = await this.handlerAsAvm().avmOpcodeVersion();
1083
+ // eslint-disable-next-line camelcase
1084
+ async aztec_avm_version() {
1085
+ const version = await this.handlerAsAvm().version();
973
1086
 
974
1087
  return toForeignCallResult([toSingle(version)]);
975
1088
  }
976
1089
 
977
- avmOpcodeReturndataSize() {
1090
+ // eslint-disable-next-line camelcase
1091
+ aztec_avm_returndataSize() {
978
1092
  throw new Error(
979
1093
  'Contract calls are forbidden inside a `TestEnvironment::public_context`, use `public_call` instead',
980
1094
  );
981
1095
  }
982
1096
 
983
- avmOpcodeReturndataCopy(_foreignRdOffset: ForeignCallSingle, _foreignCopySize: ForeignCallSingle) {
1097
+ // eslint-disable-next-line camelcase
1098
+ aztec_avm_returndataCopy(_foreignRdOffset: ForeignCallSingle, _foreignCopySize: ForeignCallSingle) {
984
1099
  throw new Error(
985
1100
  'Contract calls are forbidden inside a `TestEnvironment::public_context`, use `public_call` instead',
986
1101
  );
987
1102
  }
988
1103
 
989
- avmOpcodeCall(
1104
+ // eslint-disable-next-line camelcase
1105
+ aztec_avm_call(
990
1106
  _foreignL2Gas: ForeignCallSingle,
991
1107
  _foreignDaGas: ForeignCallSingle,
992
1108
  _foreignAddress: ForeignCallSingle,
@@ -998,7 +1114,8 @@ export class RPCTranslator {
998
1114
  );
999
1115
  }
1000
1116
 
1001
- avmOpcodeStaticCall(
1117
+ // eslint-disable-next-line camelcase
1118
+ aztec_avm_staticCall(
1002
1119
  _foreignL2Gas: ForeignCallSingle,
1003
1120
  _foreignDaGas: ForeignCallSingle,
1004
1121
  _foreignAddress: ForeignCallSingle,
@@ -1010,13 +1127,15 @@ export class RPCTranslator {
1010
1127
  );
1011
1128
  }
1012
1129
 
1013
- avmOpcodeSuccessCopy() {
1130
+ // eslint-disable-next-line camelcase
1131
+ aztec_avm_successCopy() {
1014
1132
  throw new Error(
1015
1133
  'Contract calls are forbidden inside a `TestEnvironment::public_context`, use `public_call` instead',
1016
1134
  );
1017
1135
  }
1018
1136
 
1019
- async txePrivateCallNewFlow(
1137
+ // eslint-disable-next-line camelcase
1138
+ async aztec_txe_privateCallNewFlow(
1020
1139
  foreignFrom: ForeignCallSingle,
1021
1140
  foreignTargetContractAddress: ForeignCallSingle,
1022
1141
  foreignFunctionSelector: ForeignCallSingle,
@@ -1031,19 +1150,23 @@ export class RPCTranslator {
1031
1150
  const argsHash = fromSingle(foreignArgsHash);
1032
1151
  const isStaticCall = fromSingle(foreignIsStaticCall).toBool();
1033
1152
 
1034
- const returnValues = await this.handlerAsTxe().txePrivateCallNewFlow(
1153
+ const returnValues = await this.handlerAsTxe().privateCallNewFlow(
1035
1154
  from,
1036
1155
  targetContractAddress,
1037
1156
  functionSelector,
1038
1157
  args,
1039
1158
  argsHash,
1040
1159
  isStaticCall,
1160
+ this.stateHandler.getCurrentJob(),
1041
1161
  );
1042
1162
 
1163
+ // TODO(F-335): Avoid doing the following call here.
1164
+ await this.stateHandler.cycleJob();
1043
1165
  return toForeignCallResult([toArray(returnValues)]);
1044
1166
  }
1045
1167
 
1046
- async txeExecuteUtilityFunction(
1168
+ // eslint-disable-next-line camelcase
1169
+ async aztec_txe_executeUtilityFunction(
1047
1170
  foreignTargetContractAddress: ForeignCallSingle,
1048
1171
  foreignFunctionSelector: ForeignCallSingle,
1049
1172
  foreignArgs: ForeignCallArray,
@@ -1052,16 +1175,20 @@ export class RPCTranslator {
1052
1175
  const functionSelector = FunctionSelector.fromField(fromSingle(foreignFunctionSelector));
1053
1176
  const args = fromArray(foreignArgs);
1054
1177
 
1055
- const returnValues = await this.handlerAsTxe().txeExecuteUtilityFunction(
1178
+ const returnValues = await this.handlerAsTxe().executeUtilityFunction(
1056
1179
  targetContractAddress,
1057
1180
  functionSelector,
1058
1181
  args,
1182
+ this.stateHandler.getCurrentJob(),
1059
1183
  );
1060
1184
 
1185
+ // TODO(F-335): Avoid doing the following call here.
1186
+ await this.stateHandler.cycleJob();
1061
1187
  return toForeignCallResult([toArray(returnValues)]);
1062
1188
  }
1063
1189
 
1064
- async txePublicCallNewFlow(
1190
+ // eslint-disable-next-line camelcase
1191
+ async aztec_txe_publicCallNewFlow(
1065
1192
  foreignFrom: ForeignCallSingle,
1066
1193
  foreignAddress: ForeignCallSingle,
1067
1194
  foreignCalldata: ForeignCallArray,
@@ -1072,13 +1199,16 @@ export class RPCTranslator {
1072
1199
  const calldata = fromArray(foreignCalldata);
1073
1200
  const isStaticCall = fromSingle(foreignIsStaticCall).toBool();
1074
1201
 
1075
- const returnValues = await this.handlerAsTxe().txePublicCallNewFlow(from, address, calldata, isStaticCall);
1202
+ const returnValues = await this.handlerAsTxe().publicCallNewFlow(from, address, calldata, isStaticCall);
1076
1203
 
1204
+ // TODO(F-335): Avoid doing the following call here.
1205
+ await this.stateHandler.cycleJob();
1077
1206
  return toForeignCallResult([toArray(returnValues)]);
1078
1207
  }
1079
1208
 
1080
- async privateGetSenderForTags() {
1081
- const sender = await this.handlerAsPrivate().privateGetSenderForTags();
1209
+ // eslint-disable-next-line camelcase
1210
+ async aztec_prv_getSenderForTags() {
1211
+ const sender = await this.handlerAsPrivate().getSenderForTags();
1082
1212
 
1083
1213
  // Return a Noir Option struct with `some` and `value` fields
1084
1214
  if (sender === undefined) {
@@ -1090,19 +1220,21 @@ export class RPCTranslator {
1090
1220
  }
1091
1221
  }
1092
1222
 
1093
- async privateSetSenderForTags(foreignSenderForTags: ForeignCallSingle) {
1223
+ // eslint-disable-next-line camelcase
1224
+ async aztec_prv_setSenderForTags(foreignSenderForTags: ForeignCallSingle) {
1094
1225
  const senderForTags = AztecAddress.fromField(fromSingle(foreignSenderForTags));
1095
1226
 
1096
- await this.handlerAsPrivate().privateSetSenderForTags(senderForTags);
1227
+ await this.handlerAsPrivate().setSenderForTags(senderForTags);
1097
1228
 
1098
1229
  return toForeignCallResult([]);
1099
1230
  }
1100
1231
 
1101
- async privateGetNextAppTagAsSender(foreignSender: ForeignCallSingle, foreignRecipient: ForeignCallSingle) {
1232
+ // eslint-disable-next-line camelcase
1233
+ async aztec_prv_getNextAppTagAsSender(foreignSender: ForeignCallSingle, foreignRecipient: ForeignCallSingle) {
1102
1234
  const sender = AztecAddress.fromField(fromSingle(foreignSender));
1103
1235
  const recipient = AztecAddress.fromField(fromSingle(foreignRecipient));
1104
1236
 
1105
- const nextAppTag = await this.handlerAsPrivate().privateGetNextAppTagAsSender(sender, recipient);
1237
+ const nextAppTag = await this.handlerAsPrivate().getNextAppTagAsSender(sender, recipient);
1106
1238
 
1107
1239
  return toForeignCallResult([toSingle(nextAppTag.value)]);
1108
1240
  }