@aztec/txe 0.0.1-commit.d431d1c → 0.0.1-commit.db765a8

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