@aztec/txe 0.0.1-commit.ee80a48 → 0.0.1-commit.ef17749e1

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 (52) 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 +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 +118 -50
  12. package/dest/rpc_translator.d.ts +83 -83
  13. package/dest/rpc_translator.d.ts.map +1 -1
  14. package/dest/rpc_translator.js +259 -154
  15. package/dest/state_machine/archiver.d.ts +1 -1
  16. package/dest/state_machine/archiver.d.ts.map +1 -1
  17. package/dest/state_machine/archiver.js +2 -0
  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 +5 -5
  22. package/dest/state_machine/index.d.ts.map +1 -1
  23. package/dest/state_machine/index.js +15 -10
  24. package/dest/state_machine/mock_epoch_cache.d.ts +3 -1
  25. package/dest/state_machine/mock_epoch_cache.d.ts.map +1 -1
  26. package/dest/state_machine/mock_epoch_cache.js +4 -0
  27. package/dest/txe_session.d.ts +9 -6
  28. package/dest/txe_session.d.ts.map +1 -1
  29. package/dest/txe_session.js +82 -23
  30. package/dest/util/txe_public_contract_data_source.d.ts +2 -3
  31. package/dest/util/txe_public_contract_data_source.d.ts.map +1 -1
  32. package/dest/util/txe_public_contract_data_source.js +5 -22
  33. package/dest/utils/block_creation.d.ts +1 -1
  34. package/dest/utils/block_creation.d.ts.map +1 -1
  35. package/dest/utils/block_creation.js +3 -1
  36. package/package.json +15 -15
  37. package/src/index.ts +89 -52
  38. package/src/oracle/interfaces.ts +32 -31
  39. package/src/oracle/txe_oracle_public_context.ts +12 -12
  40. package/src/oracle/txe_oracle_top_level_context.ts +121 -103
  41. package/src/rpc_translator.ts +266 -157
  42. package/src/state_machine/archiver.ts +2 -0
  43. package/src/state_machine/dummy_p2p_client.ts +40 -22
  44. package/src/state_machine/index.ts +25 -9
  45. package/src/state_machine/mock_epoch_cache.ts +5 -0
  46. package/src/txe_session.ts +85 -71
  47. package/src/util/txe_public_contract_data_source.ts +10 -36
  48. package/src/utils/block_creation.ts +3 -1
  49. package/dest/util/txe_contract_store.d.ts +0 -12
  50. package/dest/util/txe_contract_store.d.ts.map +0 -1
  51. package/dest/util/txe_contract_store.js +0 -22
  52. 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
- utilityDebugLog(
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
- this.handlerAsMisc().utilityDebugLog(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,23 +581,37 @@ export class RPCTranslator {
545
581
  );
546
582
  }
547
583
 
548
- async utilityGetPublicKeysAndPartialAddress(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 { publicKeys, partialAddress } = await this.handlerAsUtility().utilityGetPublicKeysAndPartialAddress(address);
588
+ const result = await this.handlerAsUtility().tryGetPublicKeysAndPartialAddress(address);
552
589
 
553
- 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
+ }
554
602
  }
555
603
 
556
- async utilityGetKeyValidationRequest(foreignPkMHash: ForeignCallSingle) {
604
+ // eslint-disable-next-line camelcase
605
+ async aztec_utl_getKeyValidationRequest(foreignPkMHash: ForeignCallSingle) {
557
606
  const pkMHash = fromSingle(foreignPkMHash);
558
607
 
559
- const keyValidationRequest = await this.handlerAsUtility().utilityGetKeyValidationRequest(pkMHash);
608
+ const keyValidationRequest = await this.handlerAsUtility().getKeyValidationRequest(pkMHash);
560
609
 
561
610
  return toForeignCallResult(keyValidationRequest.toFields().map(toSingle));
562
611
  }
563
612
 
564
- privateCallPrivateFunction(
613
+ // eslint-disable-next-line camelcase
614
+ aztec_prv_callPrivateFunction(
565
615
  _foreignTargetContractAddress: ForeignCallSingle,
566
616
  _foreignFunctionSelector: ForeignCallSingle,
567
617
  _foreignArgsHash: ForeignCallSingle,
@@ -573,11 +623,15 @@ export class RPCTranslator {
573
623
  );
574
624
  }
575
625
 
576
- async utilityGetNullifierMembershipWitness(foreignBlockHash: ForeignCallSingle, foreignNullifier: ForeignCallSingle) {
626
+ // eslint-disable-next-line camelcase
627
+ async aztec_utl_getNullifierMembershipWitness(
628
+ foreignBlockHash: ForeignCallSingle,
629
+ foreignNullifier: ForeignCallSingle,
630
+ ) {
577
631
  const blockHash = new BlockHash(fromSingle(foreignBlockHash));
578
632
  const nullifier = fromSingle(foreignNullifier);
579
633
 
580
- const witness = await this.handlerAsUtility().utilityGetNullifierMembershipWitness(blockHash, nullifier);
634
+ const witness = await this.handlerAsUtility().getNullifierMembershipWitness(blockHash, nullifier);
581
635
 
582
636
  if (!witness) {
583
637
  throw new Error(`Nullifier membership witness not found at block ${blockHash}.`);
@@ -585,10 +639,11 @@ export class RPCTranslator {
585
639
  return toForeignCallResult(witness.toNoirRepresentation());
586
640
  }
587
641
 
588
- async utilityGetAuthWitness(foreignMessageHash: ForeignCallSingle) {
642
+ // eslint-disable-next-line camelcase
643
+ async aztec_utl_getAuthWitness(foreignMessageHash: ForeignCallSingle) {
589
644
  const messageHash = fromSingle(foreignMessageHash);
590
645
 
591
- const authWitness = await this.handlerAsUtility().utilityGetAuthWitness(messageHash);
646
+ const authWitness = await this.handlerAsUtility().getAuthWitness(messageHash);
592
647
 
593
648
  if (!authWitness) {
594
649
  throw new Error(`Auth witness not found for message hash ${messageHash}.`);
@@ -596,7 +651,8 @@ export class RPCTranslator {
596
651
  return toForeignCallResult([toArray(authWitness)]);
597
652
  }
598
653
 
599
- public privateNotifyEnqueuedPublicFunctionCall(
654
+ // eslint-disable-next-line camelcase
655
+ public aztec_prv_notifyEnqueuedPublicFunctionCall(
600
656
  _foreignTargetContractAddress: ForeignCallSingle,
601
657
  _foreignCalldataHash: ForeignCallSingle,
602
658
  _foreignSideEffectCounter: ForeignCallSingle,
@@ -605,7 +661,8 @@ export class RPCTranslator {
605
661
  throw new Error('Enqueueing public calls is not supported in TestEnvironment::private_context');
606
662
  }
607
663
 
608
- public privateNotifySetPublicTeardownFunctionCall(
664
+ // eslint-disable-next-line camelcase
665
+ public aztec_prv_notifySetPublicTeardownFunctionCall(
609
666
  _foreignTargetContractAddress: ForeignCallSingle,
610
667
  _foreignCalldataHash: ForeignCallSingle,
611
668
  _foreignSideEffectCounter: ForeignCallSingle,
@@ -614,26 +671,30 @@ export class RPCTranslator {
614
671
  throw new Error('Enqueueing public calls is not supported in TestEnvironment::private_context');
615
672
  }
616
673
 
617
- public privateNotifySetMinRevertibleSideEffectCounter(_foreignMinRevertibleSideEffectCounter: ForeignCallSingle) {
674
+ // eslint-disable-next-line camelcase
675
+ public aztec_prv_notifySetMinRevertibleSideEffectCounter(_foreignMinRevertibleSideEffectCounter: ForeignCallSingle) {
618
676
  throw new Error('Enqueueing public calls is not supported in TestEnvironment::private_context');
619
677
  }
620
678
 
621
- public async privateIsSideEffectCounterRevertible(foreignSideEffectCounter: ForeignCallSingle) {
679
+ // eslint-disable-next-line camelcase
680
+ public async aztec_prv_isSideEffectCounterRevertible(foreignSideEffectCounter: ForeignCallSingle) {
622
681
  const sideEffectCounter = fromSingle(foreignSideEffectCounter).toNumber();
623
- const isRevertible = await this.handlerAsPrivate().privateIsSideEffectCounterRevertible(sideEffectCounter);
682
+ const isRevertible = await this.handlerAsPrivate().isSideEffectCounterRevertible(sideEffectCounter);
624
683
  return toForeignCallResult([toSingle(new Fr(isRevertible))]);
625
684
  }
626
685
 
627
- utilityGetUtilityContext() {
628
- const context = this.handlerAsUtility().utilityGetUtilityContext();
686
+ // eslint-disable-next-line camelcase
687
+ aztec_utl_getUtilityContext() {
688
+ const context = this.handlerAsUtility().getUtilityContext();
629
689
 
630
690
  return toForeignCallResult(context.toNoirRepresentation());
631
691
  }
632
692
 
633
- async utilityGetBlockHeader(foreignBlockNumber: ForeignCallSingle) {
693
+ // eslint-disable-next-line camelcase
694
+ async aztec_utl_getBlockHeader(foreignBlockNumber: ForeignCallSingle) {
634
695
  const blockNumber = BlockNumber(fromSingle(foreignBlockNumber).toNumber());
635
696
 
636
- const header = await this.handlerAsUtility().utilityGetBlockHeader(blockNumber);
697
+ const header = await this.handlerAsUtility().getBlockHeader(blockNumber);
637
698
 
638
699
  if (!header) {
639
700
  throw new Error(`Block header not found for block ${blockNumber}.`);
@@ -641,14 +702,15 @@ export class RPCTranslator {
641
702
  return toForeignCallResult(header.toFields().map(toSingle));
642
703
  }
643
704
 
644
- async utilityGetNoteHashMembershipWitness(
705
+ // eslint-disable-next-line camelcase
706
+ async aztec_utl_getNoteHashMembershipWitness(
645
707
  foreignAnchorBlockHash: ForeignCallSingle,
646
708
  foreignNoteHash: ForeignCallSingle,
647
709
  ) {
648
710
  const blockHash = new BlockHash(fromSingle(foreignAnchorBlockHash));
649
711
  const noteHash = fromSingle(foreignNoteHash);
650
712
 
651
- const witness = await this.handlerAsUtility().utilityGetNoteHashMembershipWitness(blockHash, noteHash);
713
+ const witness = await this.handlerAsUtility().getNoteHashMembershipWitness(blockHash, noteHash);
652
714
 
653
715
  if (!witness) {
654
716
  throw new Error(`Note hash ${noteHash} not found in the note hash tree at block ${blockHash.toString()}.`);
@@ -656,14 +718,15 @@ export class RPCTranslator {
656
718
  return toForeignCallResult(witness.toNoirRepresentation());
657
719
  }
658
720
 
659
- async utilityGetBlockHashMembershipWitness(
721
+ // eslint-disable-next-line camelcase
722
+ async aztec_utl_getBlockHashMembershipWitness(
660
723
  foreignAnchorBlockHash: ForeignCallSingle,
661
724
  foreignBlockHash: ForeignCallSingle,
662
725
  ) {
663
726
  const anchorBlockHash = new BlockHash(fromSingle(foreignAnchorBlockHash));
664
727
  const blockHash = new BlockHash(fromSingle(foreignBlockHash));
665
728
 
666
- const witness = await this.handlerAsUtility().utilityGetBlockHashMembershipWitness(anchorBlockHash, blockHash);
729
+ const witness = await this.handlerAsUtility().getBlockHashMembershipWitness(anchorBlockHash, blockHash);
667
730
 
668
731
  if (!witness) {
669
732
  throw new Error(
@@ -673,14 +736,15 @@ export class RPCTranslator {
673
736
  return toForeignCallResult(witness.toNoirRepresentation());
674
737
  }
675
738
 
676
- async utilityGetLowNullifierMembershipWitness(
739
+ // eslint-disable-next-line camelcase
740
+ async aztec_utl_getLowNullifierMembershipWitness(
677
741
  foreignBlockHash: ForeignCallSingle,
678
742
  foreignNullifier: ForeignCallSingle,
679
743
  ) {
680
744
  const blockHash = new BlockHash(fromSingle(foreignBlockHash));
681
745
  const nullifier = fromSingle(foreignNullifier);
682
746
 
683
- const witness = await this.handlerAsUtility().utilityGetLowNullifierMembershipWitness(blockHash, nullifier);
747
+ const witness = await this.handlerAsUtility().getLowNullifierMembershipWitness(blockHash, nullifier);
684
748
 
685
749
  if (!witness) {
686
750
  throw new Error(`Low nullifier witness not found for nullifier ${nullifier} at block ${blockHash}.`);
@@ -688,15 +752,17 @@ export class RPCTranslator {
688
752
  return toForeignCallResult(witness.toNoirRepresentation());
689
753
  }
690
754
 
691
- async utilityFetchTaggedLogs(foreignPendingTaggedLogArrayBaseSlot: ForeignCallSingle) {
755
+ // eslint-disable-next-line camelcase
756
+ async aztec_utl_fetchTaggedLogs(foreignPendingTaggedLogArrayBaseSlot: ForeignCallSingle) {
692
757
  const pendingTaggedLogArrayBaseSlot = fromSingle(foreignPendingTaggedLogArrayBaseSlot);
693
758
 
694
- await this.handlerAsUtility().utilityFetchTaggedLogs(pendingTaggedLogArrayBaseSlot);
759
+ await this.handlerAsUtility().fetchTaggedLogs(pendingTaggedLogArrayBaseSlot);
695
760
 
696
761
  return toForeignCallResult([]);
697
762
  }
698
763
 
699
- public async utilityValidateAndStoreEnqueuedNotesAndEvents(
764
+ // eslint-disable-next-line camelcase
765
+ public async aztec_utl_validateAndStoreEnqueuedNotesAndEvents(
700
766
  foreignContractAddress: ForeignCallSingle,
701
767
  foreignNoteValidationRequestsArrayBaseSlot: ForeignCallSingle,
702
768
  foreignEventValidationRequestsArrayBaseSlot: ForeignCallSingle,
@@ -705,7 +771,7 @@ export class RPCTranslator {
705
771
  const noteValidationRequestsArrayBaseSlot = fromSingle(foreignNoteValidationRequestsArrayBaseSlot);
706
772
  const eventValidationRequestsArrayBaseSlot = fromSingle(foreignEventValidationRequestsArrayBaseSlot);
707
773
 
708
- await this.handlerAsUtility().utilityValidateAndStoreEnqueuedNotesAndEvents(
774
+ await this.handlerAsUtility().validateAndStoreEnqueuedNotesAndEvents(
709
775
  contractAddress,
710
776
  noteValidationRequestsArrayBaseSlot,
711
777
  eventValidationRequestsArrayBaseSlot,
@@ -714,7 +780,8 @@ export class RPCTranslator {
714
780
  return toForeignCallResult([]);
715
781
  }
716
782
 
717
- public async utilityBulkRetrieveLogs(
783
+ // eslint-disable-next-line camelcase
784
+ public async aztec_utl_bulkRetrieveLogs(
718
785
  foreignContractAddress: ForeignCallSingle,
719
786
  foreignLogRetrievalRequestsArrayBaseSlot: ForeignCallSingle,
720
787
  foreignLogRetrievalResponsesArrayBaseSlot: ForeignCallSingle,
@@ -723,7 +790,7 @@ export class RPCTranslator {
723
790
  const logRetrievalRequestsArrayBaseSlot = fromSingle(foreignLogRetrievalRequestsArrayBaseSlot);
724
791
  const logRetrievalResponsesArrayBaseSlot = fromSingle(foreignLogRetrievalResponsesArrayBaseSlot);
725
792
 
726
- await this.handlerAsUtility().utilityBulkRetrieveLogs(
793
+ await this.handlerAsUtility().bulkRetrieveLogs(
727
794
  contractAddress,
728
795
  logRetrievalRequestsArrayBaseSlot,
729
796
  logRetrievalResponsesArrayBaseSlot,
@@ -732,7 +799,8 @@ export class RPCTranslator {
732
799
  return toForeignCallResult([]);
733
800
  }
734
801
 
735
- async utilityStoreCapsule(
802
+ // eslint-disable-next-line camelcase
803
+ async aztec_utl_storeCapsule(
736
804
  foreignContractAddress: ForeignCallSingle,
737
805
  foreignSlot: ForeignCallSingle,
738
806
  foreignCapsule: ForeignCallArray,
@@ -741,12 +809,13 @@ export class RPCTranslator {
741
809
  const slot = fromSingle(foreignSlot);
742
810
  const capsule = fromArray(foreignCapsule);
743
811
 
744
- await this.handlerAsUtility().utilityStoreCapsule(contractAddress, slot, capsule);
812
+ await this.handlerAsUtility().storeCapsule(contractAddress, slot, capsule);
745
813
 
746
814
  return toForeignCallResult([]);
747
815
  }
748
816
 
749
- async utilityLoadCapsule(
817
+ // eslint-disable-next-line camelcase
818
+ async aztec_utl_loadCapsule(
750
819
  foreignContractAddress: ForeignCallSingle,
751
820
  foreignSlot: ForeignCallSingle,
752
821
  foreignTSize: ForeignCallSingle,
@@ -755,7 +824,7 @@ export class RPCTranslator {
755
824
  const slot = fromSingle(foreignSlot);
756
825
  const tSize = fromSingle(foreignTSize).toNumber();
757
826
 
758
- const values = await this.handlerAsUtility().utilityLoadCapsule(contractAddress, slot);
827
+ const values = await this.handlerAsUtility().loadCapsule(contractAddress, slot);
759
828
 
760
829
  // We are going to return a Noir Option struct to represent the possibility of null values. Options are a struct
761
830
  // with two fields: `some` (a boolean) and `value` (a field array in this case).
@@ -768,16 +837,18 @@ export class RPCTranslator {
768
837
  }
769
838
  }
770
839
 
771
- async utilityDeleteCapsule(foreignContractAddress: ForeignCallSingle, foreignSlot: ForeignCallSingle) {
840
+ // eslint-disable-next-line camelcase
841
+ async aztec_utl_deleteCapsule(foreignContractAddress: ForeignCallSingle, foreignSlot: ForeignCallSingle) {
772
842
  const contractAddress = AztecAddress.fromField(fromSingle(foreignContractAddress));
773
843
  const slot = fromSingle(foreignSlot);
774
844
 
775
- await this.handlerAsUtility().utilityDeleteCapsule(contractAddress, slot);
845
+ await this.handlerAsUtility().deleteCapsule(contractAddress, slot);
776
846
 
777
847
  return toForeignCallResult([]);
778
848
  }
779
849
 
780
- async utilityCopyCapsule(
850
+ // eslint-disable-next-line camelcase
851
+ async aztec_utl_copyCapsule(
781
852
  foreignContractAddress: ForeignCallSingle,
782
853
  foreignSrcSlot: ForeignCallSingle,
783
854
  foreignDstSlot: ForeignCallSingle,
@@ -788,7 +859,7 @@ export class RPCTranslator {
788
859
  const dstSlot = fromSingle(foreignDstSlot);
789
860
  const numEntries = fromSingle(foreignNumEntries).toNumber();
790
861
 
791
- await this.handlerAsUtility().utilityCopyCapsule(contractAddress, srcSlot, dstSlot, numEntries);
862
+ await this.handlerAsUtility().copyCapsule(contractAddress, srcSlot, dstSlot, numEntries);
792
863
 
793
864
  return toForeignCallResult([]);
794
865
  }
@@ -797,7 +868,8 @@ export class RPCTranslator {
797
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
798
869
  // to implement this function here. Isn't there a way to programmatically identify that this is missing, given the
799
870
  // existence of a txe_oracle method?
800
- async utilityAes128Decrypt(
871
+ // eslint-disable-next-line camelcase
872
+ async aztec_utl_aes128Decrypt(
801
873
  foreignCiphertextBVecStorage: ForeignCallArray,
802
874
  foreignCiphertextLength: ForeignCallSingle,
803
875
  foreignIv: ForeignCallArray,
@@ -807,14 +879,15 @@ export class RPCTranslator {
807
879
  const iv = fromUintArray(foreignIv, 8);
808
880
  const symKey = fromUintArray(foreignSymKey, 8);
809
881
 
810
- const plaintextBuffer = await this.handlerAsUtility().utilityAes128Decrypt(ciphertext, iv, symKey);
882
+ const plaintextBuffer = await this.handlerAsUtility().aes128Decrypt(ciphertext, iv, symKey);
811
883
 
812
884
  return toForeignCallResult(
813
885
  arrayToBoundedVec(bufferToU8Array(plaintextBuffer), foreignCiphertextBVecStorage.length),
814
886
  );
815
887
  }
816
888
 
817
- async utilityGetSharedSecret(
889
+ // eslint-disable-next-line camelcase
890
+ async aztec_utl_getSharedSecret(
818
891
  foreignAddress: ForeignCallSingle,
819
892
  foreignEphPKField0: ForeignCallSingle,
820
893
  foreignEphPKField1: ForeignCallSingle,
@@ -827,44 +900,49 @@ export class RPCTranslator {
827
900
  fromSingle(foreignEphPKField2),
828
901
  ]);
829
902
 
830
- const secret = await this.handlerAsUtility().utilityGetSharedSecret(address, ephPK);
903
+ const secret = await this.handlerAsUtility().getSharedSecret(address, ephPK);
831
904
 
832
905
  return toForeignCallResult(secret.toFields().map(toSingle));
833
906
  }
834
907
 
835
- emitOffchainEffect(_foreignData: ForeignCallArray) {
908
+ // eslint-disable-next-line camelcase
909
+ aztec_utl_emitOffchainEffect(_foreignData: ForeignCallArray) {
836
910
  throw new Error('Offchain effects are not yet supported in the TestEnvironment');
837
911
  }
838
912
 
839
913
  // AVM opcodes
840
914
 
841
- avmOpcodeEmitUnencryptedLog(_foreignMessage: ForeignCallArray) {
915
+ // eslint-disable-next-line camelcase
916
+ aztec_avm_emitPublicLog(_foreignMessage: ForeignCallArray) {
842
917
  // TODO(#8811): Implement
843
918
  return toForeignCallResult([]);
844
919
  }
845
920
 
846
- async avmOpcodeStorageRead(foreignSlot: ForeignCallSingle, foreignContractAddress: ForeignCallSingle) {
921
+ // eslint-disable-next-line camelcase
922
+ async aztec_avm_storageRead(foreignSlot: ForeignCallSingle, foreignContractAddress: ForeignCallSingle) {
847
923
  const slot = fromSingle(foreignSlot);
848
924
  const contractAddress = AztecAddress.fromField(fromSingle(foreignContractAddress));
849
925
 
850
- const value = (await this.handlerAsAvm().avmOpcodeStorageRead(slot, contractAddress)).value;
926
+ const value = (await this.handlerAsAvm().storageRead(slot, contractAddress)).value;
851
927
 
852
928
  return toForeignCallResult([toSingle(new Fr(value))]);
853
929
  }
854
930
 
855
- async avmOpcodeStorageWrite(foreignSlot: ForeignCallSingle, foreignValue: ForeignCallSingle) {
931
+ // eslint-disable-next-line camelcase
932
+ async aztec_avm_storageWrite(foreignSlot: ForeignCallSingle, foreignValue: ForeignCallSingle) {
856
933
  const slot = fromSingle(foreignSlot);
857
934
  const value = fromSingle(foreignValue);
858
935
 
859
- await this.handlerAsAvm().avmOpcodeStorageWrite(slot, value);
936
+ await this.handlerAsAvm().storageWrite(slot, value);
860
937
 
861
938
  return toForeignCallResult([]);
862
939
  }
863
940
 
864
- async avmOpcodeGetContractInstanceDeployer(foreignAddress: ForeignCallSingle) {
941
+ // eslint-disable-next-line camelcase
942
+ async aztec_avm_getContractInstanceDeployer(foreignAddress: ForeignCallSingle) {
865
943
  const address = addressFromSingle(foreignAddress);
866
944
 
867
- const instance = await this.handlerAsUtility().utilityGetContractInstance(address);
945
+ const instance = await this.handlerAsUtility().getContractInstance(address);
868
946
 
869
947
  return toForeignCallResult([
870
948
  toSingle(instance.deployer),
@@ -873,10 +951,11 @@ export class RPCTranslator {
873
951
  ]);
874
952
  }
875
953
 
876
- async avmOpcodeGetContractInstanceClassId(foreignAddress: ForeignCallSingle) {
954
+ // eslint-disable-next-line camelcase
955
+ async aztec_avm_getContractInstanceClassId(foreignAddress: ForeignCallSingle) {
877
956
  const address = addressFromSingle(foreignAddress);
878
957
 
879
- const instance = await this.handlerAsUtility().utilityGetContractInstance(address);
958
+ const instance = await this.handlerAsUtility().getContractInstance(address);
880
959
 
881
960
  return toForeignCallResult([
882
961
  toSingle(instance.currentContractClassId),
@@ -885,10 +964,11 @@ export class RPCTranslator {
885
964
  ]);
886
965
  }
887
966
 
888
- async avmOpcodeGetContractInstanceInitializationHash(foreignAddress: ForeignCallSingle) {
967
+ // eslint-disable-next-line camelcase
968
+ async aztec_avm_getContractInstanceInitializationHash(foreignAddress: ForeignCallSingle) {
889
969
  const address = addressFromSingle(foreignAddress);
890
970
 
891
- const instance = await this.handlerAsUtility().utilityGetContractInstance(address);
971
+ const instance = await this.handlerAsUtility().getContractInstance(address);
892
972
 
893
973
  return toForeignCallResult([
894
974
  toSingle(instance.initializationHash),
@@ -897,85 +977,98 @@ export class RPCTranslator {
897
977
  ]);
898
978
  }
899
979
 
900
- async avmOpcodeSender() {
901
- const sender = await this.handlerAsAvm().avmOpcodeSender();
980
+ // eslint-disable-next-line camelcase
981
+ async aztec_avm_sender() {
982
+ const sender = await this.handlerAsAvm().sender();
902
983
 
903
984
  return toForeignCallResult([toSingle(sender)]);
904
985
  }
905
986
 
906
- async avmOpcodeEmitNullifier(foreignNullifier: ForeignCallSingle) {
987
+ // eslint-disable-next-line camelcase
988
+ async aztec_avm_emitNullifier(foreignNullifier: ForeignCallSingle) {
907
989
  const nullifier = fromSingle(foreignNullifier);
908
990
 
909
- await this.handlerAsAvm().avmOpcodeEmitNullifier(nullifier);
991
+ await this.handlerAsAvm().emitNullifier(nullifier);
910
992
 
911
993
  return toForeignCallResult([]);
912
994
  }
913
995
 
914
- async avmOpcodeEmitNoteHash(foreignNoteHash: ForeignCallSingle) {
996
+ // eslint-disable-next-line camelcase
997
+ async aztec_avm_emitNoteHash(foreignNoteHash: ForeignCallSingle) {
915
998
  const noteHash = fromSingle(foreignNoteHash);
916
999
 
917
- await this.handlerAsAvm().avmOpcodeEmitNoteHash(noteHash);
1000
+ await this.handlerAsAvm().emitNoteHash(noteHash);
918
1001
 
919
1002
  return toForeignCallResult([]);
920
1003
  }
921
1004
 
922
- async avmOpcodeNullifierExists(foreignSiloedNullifier: ForeignCallSingle) {
1005
+ // eslint-disable-next-line camelcase
1006
+ async aztec_avm_nullifierExists(foreignSiloedNullifier: ForeignCallSingle) {
923
1007
  const siloedNullifier = fromSingle(foreignSiloedNullifier);
924
1008
 
925
- const exists = await this.handlerAsAvm().avmOpcodeNullifierExists(siloedNullifier);
1009
+ const exists = await this.handlerAsAvm().nullifierExists(siloedNullifier);
926
1010
 
927
1011
  return toForeignCallResult([toSingle(new Fr(exists))]);
928
1012
  }
929
1013
 
930
- async avmOpcodeAddress() {
931
- const contractAddress = await this.handlerAsAvm().avmOpcodeAddress();
1014
+ // eslint-disable-next-line camelcase
1015
+ async aztec_avm_address() {
1016
+ const contractAddress = await this.handlerAsAvm().address();
932
1017
 
933
1018
  return toForeignCallResult([toSingle(contractAddress.toField())]);
934
1019
  }
935
1020
 
936
- async avmOpcodeBlockNumber() {
937
- const blockNumber = await this.handlerAsAvm().avmOpcodeBlockNumber();
1021
+ // eslint-disable-next-line camelcase
1022
+ async aztec_avm_blockNumber() {
1023
+ const blockNumber = await this.handlerAsAvm().blockNumber();
938
1024
 
939
1025
  return toForeignCallResult([toSingle(new Fr(blockNumber))]);
940
1026
  }
941
1027
 
942
- async avmOpcodeTimestamp() {
943
- const timestamp = await this.handlerAsAvm().avmOpcodeTimestamp();
1028
+ // eslint-disable-next-line camelcase
1029
+ async aztec_avm_timestamp() {
1030
+ const timestamp = await this.handlerAsAvm().timestamp();
944
1031
 
945
1032
  return toForeignCallResult([toSingle(new Fr(timestamp))]);
946
1033
  }
947
1034
 
948
- async avmOpcodeIsStaticCall() {
949
- const isStaticCall = await this.handlerAsAvm().avmOpcodeIsStaticCall();
1035
+ // eslint-disable-next-line camelcase
1036
+ async aztec_avm_isStaticCall() {
1037
+ const isStaticCall = await this.handlerAsAvm().isStaticCall();
950
1038
 
951
1039
  return toForeignCallResult([toSingle(new Fr(isStaticCall ? 1 : 0))]);
952
1040
  }
953
1041
 
954
- async avmOpcodeChainId() {
955
- const chainId = await this.handlerAsAvm().avmOpcodeChainId();
1042
+ // eslint-disable-next-line camelcase
1043
+ async aztec_avm_chainId() {
1044
+ const chainId = await this.handlerAsAvm().chainId();
956
1045
 
957
1046
  return toForeignCallResult([toSingle(chainId)]);
958
1047
  }
959
1048
 
960
- async avmOpcodeVersion() {
961
- const version = await this.handlerAsAvm().avmOpcodeVersion();
1049
+ // eslint-disable-next-line camelcase
1050
+ async aztec_avm_version() {
1051
+ const version = await this.handlerAsAvm().version();
962
1052
 
963
1053
  return toForeignCallResult([toSingle(version)]);
964
1054
  }
965
1055
 
966
- avmOpcodeReturndataSize() {
1056
+ // eslint-disable-next-line camelcase
1057
+ aztec_avm_returndataSize() {
967
1058
  throw new Error(
968
1059
  'Contract calls are forbidden inside a `TestEnvironment::public_context`, use `public_call` instead',
969
1060
  );
970
1061
  }
971
1062
 
972
- avmOpcodeReturndataCopy(_foreignRdOffset: ForeignCallSingle, _foreignCopySize: ForeignCallSingle) {
1063
+ // eslint-disable-next-line camelcase
1064
+ aztec_avm_returndataCopy(_foreignRdOffset: ForeignCallSingle, _foreignCopySize: ForeignCallSingle) {
973
1065
  throw new Error(
974
1066
  'Contract calls are forbidden inside a `TestEnvironment::public_context`, use `public_call` instead',
975
1067
  );
976
1068
  }
977
1069
 
978
- avmOpcodeCall(
1070
+ // eslint-disable-next-line camelcase
1071
+ aztec_avm_call(
979
1072
  _foreignL2Gas: ForeignCallSingle,
980
1073
  _foreignDaGas: ForeignCallSingle,
981
1074
  _foreignAddress: ForeignCallSingle,
@@ -987,7 +1080,8 @@ export class RPCTranslator {
987
1080
  );
988
1081
  }
989
1082
 
990
- avmOpcodeStaticCall(
1083
+ // eslint-disable-next-line camelcase
1084
+ aztec_avm_staticCall(
991
1085
  _foreignL2Gas: ForeignCallSingle,
992
1086
  _foreignDaGas: ForeignCallSingle,
993
1087
  _foreignAddress: ForeignCallSingle,
@@ -999,13 +1093,15 @@ export class RPCTranslator {
999
1093
  );
1000
1094
  }
1001
1095
 
1002
- avmOpcodeSuccessCopy() {
1096
+ // eslint-disable-next-line camelcase
1097
+ aztec_avm_successCopy() {
1003
1098
  throw new Error(
1004
1099
  'Contract calls are forbidden inside a `TestEnvironment::public_context`, use `public_call` instead',
1005
1100
  );
1006
1101
  }
1007
1102
 
1008
- async txePrivateCallNewFlow(
1103
+ // eslint-disable-next-line camelcase
1104
+ async aztec_txe_privateCallNewFlow(
1009
1105
  foreignFrom: ForeignCallSingle,
1010
1106
  foreignTargetContractAddress: ForeignCallSingle,
1011
1107
  foreignFunctionSelector: ForeignCallSingle,
@@ -1020,19 +1116,23 @@ export class RPCTranslator {
1020
1116
  const argsHash = fromSingle(foreignArgsHash);
1021
1117
  const isStaticCall = fromSingle(foreignIsStaticCall).toBool();
1022
1118
 
1023
- const returnValues = await this.handlerAsTxe().txePrivateCallNewFlow(
1119
+ const returnValues = await this.handlerAsTxe().privateCallNewFlow(
1024
1120
  from,
1025
1121
  targetContractAddress,
1026
1122
  functionSelector,
1027
1123
  args,
1028
1124
  argsHash,
1029
1125
  isStaticCall,
1126
+ this.stateHandler.getCurrentJob(),
1030
1127
  );
1031
1128
 
1129
+ // TODO(F-335): Avoid doing the following call here.
1130
+ await this.stateHandler.cycleJob();
1032
1131
  return toForeignCallResult([toArray(returnValues)]);
1033
1132
  }
1034
1133
 
1035
- async txeSimulateUtilityFunction(
1134
+ // eslint-disable-next-line camelcase
1135
+ async aztec_txe_executeUtilityFunction(
1036
1136
  foreignTargetContractAddress: ForeignCallSingle,
1037
1137
  foreignFunctionSelector: ForeignCallSingle,
1038
1138
  foreignArgs: ForeignCallArray,
@@ -1041,16 +1141,20 @@ export class RPCTranslator {
1041
1141
  const functionSelector = FunctionSelector.fromField(fromSingle(foreignFunctionSelector));
1042
1142
  const args = fromArray(foreignArgs);
1043
1143
 
1044
- const returnValues = await this.handlerAsTxe().txeSimulateUtilityFunction(
1144
+ const returnValues = await this.handlerAsTxe().executeUtilityFunction(
1045
1145
  targetContractAddress,
1046
1146
  functionSelector,
1047
1147
  args,
1148
+ this.stateHandler.getCurrentJob(),
1048
1149
  );
1049
1150
 
1151
+ // TODO(F-335): Avoid doing the following call here.
1152
+ await this.stateHandler.cycleJob();
1050
1153
  return toForeignCallResult([toArray(returnValues)]);
1051
1154
  }
1052
1155
 
1053
- async txePublicCallNewFlow(
1156
+ // eslint-disable-next-line camelcase
1157
+ async aztec_txe_publicCallNewFlow(
1054
1158
  foreignFrom: ForeignCallSingle,
1055
1159
  foreignAddress: ForeignCallSingle,
1056
1160
  foreignCalldata: ForeignCallArray,
@@ -1061,13 +1165,16 @@ export class RPCTranslator {
1061
1165
  const calldata = fromArray(foreignCalldata);
1062
1166
  const isStaticCall = fromSingle(foreignIsStaticCall).toBool();
1063
1167
 
1064
- const returnValues = await this.handlerAsTxe().txePublicCallNewFlow(from, address, calldata, isStaticCall);
1168
+ const returnValues = await this.handlerAsTxe().publicCallNewFlow(from, address, calldata, isStaticCall);
1065
1169
 
1170
+ // TODO(F-335): Avoid doing the following call here.
1171
+ await this.stateHandler.cycleJob();
1066
1172
  return toForeignCallResult([toArray(returnValues)]);
1067
1173
  }
1068
1174
 
1069
- async privateGetSenderForTags() {
1070
- const sender = await this.handlerAsPrivate().privateGetSenderForTags();
1175
+ // eslint-disable-next-line camelcase
1176
+ async aztec_prv_getSenderForTags() {
1177
+ const sender = await this.handlerAsPrivate().getSenderForTags();
1071
1178
 
1072
1179
  // Return a Noir Option struct with `some` and `value` fields
1073
1180
  if (sender === undefined) {
@@ -1079,19 +1186,21 @@ export class RPCTranslator {
1079
1186
  }
1080
1187
  }
1081
1188
 
1082
- async privateSetSenderForTags(foreignSenderForTags: ForeignCallSingle) {
1189
+ // eslint-disable-next-line camelcase
1190
+ async aztec_prv_setSenderForTags(foreignSenderForTags: ForeignCallSingle) {
1083
1191
  const senderForTags = AztecAddress.fromField(fromSingle(foreignSenderForTags));
1084
1192
 
1085
- await this.handlerAsPrivate().privateSetSenderForTags(senderForTags);
1193
+ await this.handlerAsPrivate().setSenderForTags(senderForTags);
1086
1194
 
1087
1195
  return toForeignCallResult([]);
1088
1196
  }
1089
1197
 
1090
- async privateGetNextAppTagAsSender(foreignSender: ForeignCallSingle, foreignRecipient: ForeignCallSingle) {
1198
+ // eslint-disable-next-line camelcase
1199
+ async aztec_prv_getNextAppTagAsSender(foreignSender: ForeignCallSingle, foreignRecipient: ForeignCallSingle) {
1091
1200
  const sender = AztecAddress.fromField(fromSingle(foreignSender));
1092
1201
  const recipient = AztecAddress.fromField(fromSingle(foreignRecipient));
1093
1202
 
1094
- const nextAppTag = await this.handlerAsPrivate().privateGetNextAppTagAsSender(sender, recipient);
1203
+ const nextAppTag = await this.handlerAsPrivate().getNextAppTagAsSender(sender, recipient);
1095
1204
 
1096
1205
  return toForeignCallResult([toSingle(nextAppTag.value)]);
1097
1206
  }