@aztec/pxe 0.0.1-commit.ec5f612 → 0.0.1-commit.ec7ac5448

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 (183) hide show
  1. package/dest/bin/check_oracle_version.js +4 -4
  2. package/dest/block_synchronizer/block_synchronizer.d.ts +1 -1
  3. package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -1
  4. package/dest/block_synchronizer/block_synchronizer.js +6 -0
  5. package/dest/config/index.d.ts +2 -2
  6. package/dest/config/index.d.ts.map +1 -1
  7. package/dest/config/index.js +1 -1
  8. package/dest/contract_function_simulator/contract_function_simulator.d.ts +10 -5
  9. package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
  10. package/dest/contract_function_simulator/contract_function_simulator.js +31 -8
  11. package/dest/contract_function_simulator/ephemeral_array_service.d.ts +28 -0
  12. package/dest/contract_function_simulator/ephemeral_array_service.d.ts.map +1 -0
  13. package/dest/contract_function_simulator/ephemeral_array_service.js +78 -0
  14. package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts +5 -5
  15. package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts.map +1 -1
  16. package/dest/contract_function_simulator/execution_tagging_index_cache.js +17 -9
  17. package/dest/contract_function_simulator/index.d.ts +2 -1
  18. package/dest/contract_function_simulator/index.d.ts.map +1 -1
  19. package/dest/contract_function_simulator/index.js +1 -0
  20. package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts +4 -6
  21. package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts.map +1 -1
  22. package/dest/contract_function_simulator/noir-structs/event_validation_request.js +8 -10
  23. package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts +1 -1
  24. package/dest/contract_function_simulator/noir-structs/log_retrieval_request.js +1 -1
  25. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts +2 -2
  26. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts.map +1 -1
  27. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.js +2 -4
  28. package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +4 -7
  29. package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts.map +1 -1
  30. package/dest/contract_function_simulator/noir-structs/note_validation_request.js +6 -11
  31. package/dest/contract_function_simulator/oracle/interfaces.d.ts +61 -45
  32. package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -1
  33. package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.d.ts +9 -0
  34. package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.d.ts.map +1 -0
  35. package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.js +47 -0
  36. package/dest/contract_function_simulator/oracle/oracle.d.ts +75 -44
  37. package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
  38. package/dest/contract_function_simulator/oracle/oracle.js +281 -96
  39. package/dest/contract_function_simulator/oracle/private_execution.js +5 -3
  40. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +23 -49
  41. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
  42. package/dest/contract_function_simulator/oracle/private_execution_oracle.js +40 -63
  43. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +89 -56
  44. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
  45. package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +272 -107
  46. package/dest/contract_function_simulator/pick_notes.d.ts +1 -1
  47. package/dest/contract_function_simulator/pick_notes.d.ts.map +1 -1
  48. package/dest/contract_function_simulator/pick_notes.js +9 -2
  49. package/dest/contract_function_simulator/proxied_contract_data_source.d.ts +1 -1
  50. package/dest/contract_function_simulator/proxied_contract_data_source.d.ts.map +1 -1
  51. package/dest/contract_function_simulator/proxied_contract_data_source.js +3 -0
  52. package/dest/contract_logging.d.ts +9 -4
  53. package/dest/contract_logging.d.ts.map +1 -1
  54. package/dest/contract_logging.js +21 -6
  55. package/dest/contract_sync/contract_sync_service.d.ts +6 -5
  56. package/dest/contract_sync/contract_sync_service.d.ts.map +1 -1
  57. package/dest/contract_sync/contract_sync_service.js +44 -37
  58. package/dest/contract_sync/helpers.d.ts +2 -3
  59. package/dest/contract_sync/helpers.d.ts.map +1 -1
  60. package/dest/contract_sync/helpers.js +7 -2
  61. package/dest/debug/pxe_debug_utils.d.ts +3 -3
  62. package/dest/debug/pxe_debug_utils.d.ts.map +1 -1
  63. package/dest/entrypoints/client/bundle/index.d.ts +1 -2
  64. package/dest/entrypoints/client/bundle/index.d.ts.map +1 -1
  65. package/dest/entrypoints/client/bundle/index.js +0 -1
  66. package/dest/entrypoints/client/bundle/utils.d.ts +2 -2
  67. package/dest/entrypoints/client/bundle/utils.d.ts.map +1 -1
  68. package/dest/entrypoints/client/bundle/utils.js +2 -2
  69. package/dest/entrypoints/client/lazy/index.d.ts +1 -2
  70. package/dest/entrypoints/client/lazy/index.d.ts.map +1 -1
  71. package/dest/entrypoints/client/lazy/index.js +0 -1
  72. package/dest/entrypoints/client/lazy/utils.d.ts +2 -2
  73. package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
  74. package/dest/entrypoints/client/lazy/utils.js +2 -2
  75. package/dest/entrypoints/pxe_creation_options.d.ts +3 -1
  76. package/dest/entrypoints/pxe_creation_options.d.ts.map +1 -1
  77. package/dest/entrypoints/pxe_creation_options.js +3 -1
  78. package/dest/entrypoints/server/index.d.ts +2 -3
  79. package/dest/entrypoints/server/index.d.ts.map +1 -1
  80. package/dest/entrypoints/server/index.js +1 -2
  81. package/dest/entrypoints/server/utils.d.ts +2 -2
  82. package/dest/entrypoints/server/utils.d.ts.map +1 -1
  83. package/dest/entrypoints/server/utils.js +2 -2
  84. package/dest/events/event_service.d.ts +3 -2
  85. package/dest/events/event_service.d.ts.map +1 -1
  86. package/dest/events/event_service.js +16 -4
  87. package/dest/logs/log_service.d.ts +5 -8
  88. package/dest/logs/log_service.d.ts.map +1 -1
  89. package/dest/logs/log_service.js +24 -37
  90. package/dest/messages/message_context_service.d.ts +17 -0
  91. package/dest/messages/message_context_service.d.ts.map +1 -0
  92. package/dest/messages/message_context_service.js +36 -0
  93. package/dest/notes/note_service.d.ts +4 -5
  94. package/dest/notes/note_service.d.ts.map +1 -1
  95. package/dest/notes/note_service.js +14 -5
  96. package/dest/notes_filter.d.ts +2 -3
  97. package/dest/notes_filter.d.ts.map +1 -1
  98. package/dest/oracle_version.d.ts +4 -3
  99. package/dest/oracle_version.d.ts.map +1 -1
  100. package/dest/oracle_version.js +20 -10
  101. package/dest/pxe.d.ts +11 -8
  102. package/dest/pxe.d.ts.map +1 -1
  103. package/dest/pxe.js +45 -26
  104. package/dest/storage/capsule_store/capsule_service.d.ts +21 -0
  105. package/dest/storage/capsule_store/capsule_service.d.ts.map +1 -0
  106. package/dest/storage/capsule_store/capsule_service.js +50 -0
  107. package/dest/storage/capsule_store/capsule_store.d.ts +9 -9
  108. package/dest/storage/capsule_store/capsule_store.d.ts.map +1 -1
  109. package/dest/storage/capsule_store/capsule_store.js +33 -28
  110. package/dest/storage/capsule_store/index.d.ts +2 -1
  111. package/dest/storage/capsule_store/index.d.ts.map +1 -1
  112. package/dest/storage/capsule_store/index.js +1 -0
  113. package/dest/storage/metadata.d.ts +1 -1
  114. package/dest/storage/metadata.js +1 -1
  115. package/dest/storage/note_store/note_store.d.ts +1 -1
  116. package/dest/storage/note_store/note_store.d.ts.map +1 -1
  117. package/dest/storage/note_store/note_store.js +2 -2
  118. package/dest/storage/tagging_store/sender_tagging_store.d.ts +26 -25
  119. package/dest/storage/tagging_store/sender_tagging_store.d.ts.map +1 -1
  120. package/dest/storage/tagging_store/sender_tagging_store.js +141 -115
  121. package/dest/tagging/index.d.ts +2 -2
  122. package/dest/tagging/index.d.ts.map +1 -1
  123. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts +1 -1
  124. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts.map +1 -1
  125. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.js +10 -1
  126. package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts +4 -3
  127. package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts.map +1 -1
  128. package/dest/tagging/sender_sync/utils/get_status_change_of_pending.js +20 -10
  129. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts +2 -1
  130. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts.map +1 -1
  131. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.js +24 -11
  132. package/package.json +16 -16
  133. package/src/bin/check_oracle_version.ts +4 -4
  134. package/src/block_synchronizer/block_synchronizer.ts +6 -0
  135. package/src/config/index.ts +1 -1
  136. package/src/contract_function_simulator/contract_function_simulator.ts +44 -12
  137. package/src/contract_function_simulator/ephemeral_array_service.ts +110 -0
  138. package/src/contract_function_simulator/execution_tagging_index_cache.ts +16 -11
  139. package/src/contract_function_simulator/index.ts +1 -0
  140. package/src/contract_function_simulator/noir-structs/event_validation_request.ts +9 -9
  141. package/src/contract_function_simulator/noir-structs/log_retrieval_request.ts +1 -1
  142. package/src/contract_function_simulator/noir-structs/log_retrieval_response.ts +2 -5
  143. package/src/contract_function_simulator/noir-structs/note_validation_request.ts +4 -10
  144. package/src/contract_function_simulator/oracle/interfaces.ts +82 -54
  145. package/src/contract_function_simulator/oracle/legacy_oracle_mappings.ts +104 -0
  146. package/src/contract_function_simulator/oracle/oracle.ts +363 -139
  147. package/src/contract_function_simulator/oracle/private_execution.ts +4 -4
  148. package/src/contract_function_simulator/oracle/private_execution_oracle.ts +45 -84
  149. package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +444 -143
  150. package/src/contract_function_simulator/pick_notes.ts +9 -2
  151. package/src/contract_function_simulator/proxied_contract_data_source.ts +8 -1
  152. package/src/contract_logging.ts +18 -5
  153. package/src/contract_sync/contract_sync_service.ts +77 -59
  154. package/src/contract_sync/helpers.ts +4 -4
  155. package/src/debug/pxe_debug_utils.ts +3 -3
  156. package/src/entrypoints/client/bundle/index.ts +0 -1
  157. package/src/entrypoints/client/bundle/utils.ts +2 -3
  158. package/src/entrypoints/client/lazy/index.ts +0 -1
  159. package/src/entrypoints/client/lazy/utils.ts +2 -3
  160. package/src/entrypoints/pxe_creation_options.ts +7 -0
  161. package/src/entrypoints/server/index.ts +1 -2
  162. package/src/entrypoints/server/utils.ts +2 -3
  163. package/src/events/event_service.ts +17 -4
  164. package/src/logs/log_service.ts +52 -78
  165. package/src/messages/message_context_service.ts +44 -0
  166. package/src/notes/note_service.ts +18 -8
  167. package/src/notes_filter.ts +1 -3
  168. package/src/oracle_version.ts +20 -10
  169. package/src/pxe.ts +68 -31
  170. package/src/storage/capsule_store/capsule_service.ts +90 -0
  171. package/src/storage/capsule_store/capsule_store.ts +34 -26
  172. package/src/storage/capsule_store/index.ts +1 -0
  173. package/src/storage/metadata.ts +1 -1
  174. package/src/storage/note_store/note_store.ts +2 -5
  175. package/src/storage/tagging_store/sender_tagging_store.ts +182 -135
  176. package/src/tagging/index.ts +1 -1
  177. package/src/tagging/sender_sync/sync_sender_tagging_indexes.ts +19 -1
  178. package/src/tagging/sender_sync/utils/get_status_change_of_pending.ts +26 -11
  179. package/src/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.ts +19 -9
  180. package/dest/access_scopes.d.ts +0 -9
  181. package/dest/access_scopes.d.ts.map +0 -1
  182. package/dest/access_scopes.js +0 -6
  183. package/src/access_scopes.ts +0 -9
@@ -6,6 +6,8 @@ import { FunctionSelector, NoteSelector } from '@aztec/stdlib/abi';
6
6
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
7
7
  import { BlockHash } from '@aztec/stdlib/block';
8
8
  import { ContractClassLog, ContractClassLogFields } from '@aztec/stdlib/logs';
9
+ import { ORACLE_VERSION_MAJOR, ORACLE_VERSION_MINOR } from '../../oracle_version.js';
10
+ import { buildLegacyOracleCallbacks } from './legacy_oracle_mappings.js';
9
11
  import { packAsHintedNote } from './note_packing_utils.js';
10
12
  export class UnavailableOracleError extends Error {
11
13
  constructor(oracleName){
@@ -14,6 +16,25 @@ export class UnavailableOracleError extends Error {
14
16
  }
15
17
  /**
16
18
  * A data source that has all the apis required by Aztec.nr.
19
+ *
20
+ * ## Oracle naming conventions
21
+ *
22
+ * We try to keep oracle naming consistent, please see below the conventions we adhere to.
23
+ *
24
+ * Each oracle method name has the form `aztec_{scope}_{verb}{Object}`, where:
25
+ *
26
+ * - **Scope prefix** indicates the execution context required:
27
+ * - `aztec_prv_` — available only during private function execution.
28
+ * - `aztec_utl_` — available during both utility and private execution.
29
+ *
30
+ * - **Verb** signals the operation's semantics (verb-first, then object):
31
+ * - `get` — read / lookup / get data from oracle into contract.
32
+ * - `does`/`is`/`has` — predicate (returns boolean).
33
+ * - `emit`/`notify` — propagate data from contract to oracle.
34
+ * - `set` — contract driven oracle state mutation (capsules, execution cache, tagging, etc).
35
+ * - `call` — trigger nested execution (control flow).
36
+ * - `assert` — validate a condition, throw on failure.
37
+ * - Standalone verbs (`delete`, `copy`, `decrypt`, `log`, etc) are used when no generic verb fits.
17
38
  */ export class Oracle {
18
39
  handler;
19
40
  constructor(handler){
@@ -48,11 +69,11 @@ export class UnavailableOracleError extends Error {
48
69
  ];
49
70
  // Get all the oracle function names
50
71
  const oracleNames = Object.getOwnPropertyNames(Oracle.prototype).filter((name)=>!excludedProps.includes(name));
51
- // Validate oracle names - these must be prefixed with either "private" or "utility" to indicate their scope
72
+ // Validate oracle names - these must be prefixed with either "aztec_prv_" or "aztec_utl_" to indicate their scope
52
73
  // and must correspond to a function on the Oracle class.
53
74
  oracleNames.forEach((name)=>{
54
- if (!name.startsWith('private') && !name.startsWith('utility')) {
55
- throw new Error(`Oracle function "${name}" must be prefixed with either "private" or "utility" to indicate its scope`);
75
+ if (!name.startsWith('aztec_prv_') && !name.startsWith('aztec_utl_')) {
76
+ throw new Error(`Oracle function "${name}" must be prefixed with either "aztec_prv_" or "aztec_utl_" to indicate its scope`);
56
77
  }
57
78
  const method = this[name];
58
79
  if (typeof method !== 'function') {
@@ -60,42 +81,78 @@ export class UnavailableOracleError extends Error {
60
81
  }
61
82
  });
62
83
  // Build callback object and return it
63
- return oracleNames.reduce((acc, name)=>{
84
+ const callback = oracleNames.reduce((acc, name)=>{
64
85
  const method = this[name];
65
86
  acc[name] = method.bind(this);
66
87
  return acc;
67
88
  }, {});
89
+ const allCallbacks = {
90
+ ...callback,
91
+ ...buildLegacyOracleCallbacks(this)
92
+ };
93
+ // Wrap in a Proxy to intercept access to missing oracle names and provide enhanced error messages when the
94
+ // contract's minor version is higher than the PXE's (i.e. the contract expects oracles that were added in a newer
95
+ // minor version).
96
+ const handler = this.handler;
97
+ return new Proxy(allCallbacks, {
98
+ get (target, prop) {
99
+ if (prop in target) {
100
+ return target[prop];
101
+ }
102
+ // Return a function that throws with an enhanced error message if applicable
103
+ return ()=>{
104
+ let contractVersion = undefined;
105
+ if ('nonOracleFunctionGetContractOracleVersion' in handler) {
106
+ contractVersion = handler.nonOracleFunctionGetContractOracleVersion();
107
+ }
108
+ if (!contractVersion) {
109
+ throw new Error(`Oracle '${prop}' not found and the contract's oracle version is unknown (the version check oracle ` + `was not called before '${prop}'). This usually means the contract was not compiled with the ` + `#[aztec] macro, which injects the version check as the first oracle call in every private/utility ` + `external function. If you're using a custom entry point, ensure assert_compatible_oracle_version() ` + `is called before any other oracle calls. See https://docs.aztec.network/errors/8`);
110
+ } else if (contractVersion.minor > ORACLE_VERSION_MINOR) {
111
+ throw new Error(`Oracle '${prop}' not found.` + ` This usually means the contract requires a newer private execution environment than you have.` + ` Upgrade your private execution environment to a compatible version. The contract was compiled with` + ` Aztec.nr oracle version ${contractVersion.major}.${contractVersion.minor}, but this private` + ` execution environment only supports up to ${ORACLE_VERSION_MAJOR}.${ORACLE_VERSION_MINOR}.` + ` See https://docs.aztec.network/errors/8`);
112
+ } else {
113
+ throw new Error(`Oracle '${prop}' not found.` + ` The contract's oracle version (${contractVersion.major}.${contractVersion.minor}) is compatible` + ` with this private execution environment (${ORACLE_VERSION_MAJOR}.${ORACLE_VERSION_MINOR}), so all` + ` standard oracles should be available. This could mean the contract was compiled against a modified` + ` version of Aztec.nr, or that it references an oracle that does not exist.` + ` See https://docs.aztec.network/errors/8`);
114
+ }
115
+ };
116
+ }
117
+ });
68
118
  }
69
- utilityAssertCompatibleOracleVersion([version]) {
70
- this.handlerAsMisc().utilityAssertCompatibleOracleVersion(Fr.fromString(version).toNumber());
119
+ // eslint-disable-next-line camelcase
120
+ aztec_utl_assertCompatibleOracleVersionV2([major], [minor]) {
121
+ this.handlerAsMisc().assertCompatibleOracleVersion(Fr.fromString(major).toNumber(), Fr.fromString(minor).toNumber());
71
122
  return Promise.resolve([]);
72
123
  }
73
- utilityGetRandomField() {
74
- const val = this.handlerAsMisc().utilityGetRandomField();
124
+ // eslint-disable-next-line camelcase
125
+ aztec_utl_getRandomField() {
126
+ const val = this.handlerAsMisc().getRandomField();
75
127
  return Promise.resolve([
76
128
  toACVMField(val)
77
129
  ]);
78
130
  }
79
- privateStoreInExecutionCache(values, [hash]) {
80
- this.handlerAsPrivate().privateStoreInExecutionCache(values.map(Fr.fromString), Fr.fromString(hash));
131
+ // eslint-disable-next-line camelcase
132
+ aztec_prv_setHashPreimage(values, [hash]) {
133
+ this.handlerAsPrivate().setHashPreimage(values.map(Fr.fromString), Fr.fromString(hash));
81
134
  return Promise.resolve([]);
82
135
  }
83
- async privateLoadFromExecutionCache([returnsHash]) {
84
- const values = await this.handlerAsPrivate().privateLoadFromExecutionCache(Fr.fromString(returnsHash));
136
+ // eslint-disable-next-line camelcase
137
+ async aztec_prv_getHashPreimage([returnsHash]) {
138
+ const values = await this.handlerAsPrivate().getHashPreimage(Fr.fromString(returnsHash));
85
139
  return [
86
140
  values.map(toACVMField)
87
141
  ];
88
142
  }
89
- utilityGetUtilityContext() {
90
- const context = this.handlerAsUtility().utilityGetUtilityContext();
143
+ // eslint-disable-next-line camelcase
144
+ aztec_utl_getUtilityContext() {
145
+ const context = this.handlerAsUtility().getUtilityContext();
91
146
  return Promise.resolve(context.toNoirRepresentation());
92
147
  }
93
- async utilityGetKeyValidationRequest([pkMHash]) {
94
- const keyValidationRequest = await this.handlerAsUtility().utilityGetKeyValidationRequest(Fr.fromString(pkMHash));
148
+ // eslint-disable-next-line camelcase
149
+ async aztec_utl_getKeyValidationRequest([pkMHash]) {
150
+ const keyValidationRequest = await this.handlerAsUtility().getKeyValidationRequest(Fr.fromString(pkMHash));
95
151
  return keyValidationRequest.toFields().map(toACVMField);
96
152
  }
97
- async utilityGetContractInstance([address]) {
98
- const instance = await this.handlerAsUtility().utilityGetContractInstance(AztecAddress.fromField(Fr.fromString(address)));
153
+ // eslint-disable-next-line camelcase
154
+ async aztec_utl_getContractInstance([address]) {
155
+ const instance = await this.handlerAsUtility().getContractInstance(AztecAddress.fromField(Fr.fromString(address)));
99
156
  return [
100
157
  instance.salt,
101
158
  instance.deployer,
@@ -104,62 +161,69 @@ export class UnavailableOracleError extends Error {
104
161
  ...instance.publicKeys.toFields()
105
162
  ].map(toACVMField);
106
163
  }
107
- async utilityGetNoteHashMembershipWitness([anchorBlockHash], [noteHash]) {
164
+ // eslint-disable-next-line camelcase
165
+ async aztec_utl_getNoteHashMembershipWitness([anchorBlockHash], [noteHash]) {
108
166
  const parsedAnchorBlockHash = BlockHash.fromString(anchorBlockHash);
109
167
  const parsedNoteHash = Fr.fromString(noteHash);
110
- const witness = await this.handlerAsUtility().utilityGetNoteHashMembershipWitness(parsedAnchorBlockHash, parsedNoteHash);
168
+ const witness = await this.handlerAsUtility().getNoteHashMembershipWitness(parsedAnchorBlockHash, parsedNoteHash);
111
169
  if (!witness) {
112
170
  throw new Error(`Note hash ${noteHash} not found in the note hash tree at anchor block hash ${parsedAnchorBlockHash.toString()}.`);
113
171
  }
114
172
  return witness.toNoirRepresentation();
115
173
  }
116
- async utilityGetBlockHashMembershipWitness([anchorBlockHash], [blockHash]) {
174
+ // eslint-disable-next-line camelcase
175
+ async aztec_utl_getBlockHashMembershipWitness([anchorBlockHash], [blockHash]) {
117
176
  const parsedAnchorBlockHash = BlockHash.fromString(anchorBlockHash);
118
177
  const parsedBlockHash = BlockHash.fromString(blockHash);
119
- const witness = await this.handlerAsUtility().utilityGetBlockHashMembershipWitness(parsedAnchorBlockHash, parsedBlockHash);
178
+ const witness = await this.handlerAsUtility().getBlockHashMembershipWitness(parsedAnchorBlockHash, parsedBlockHash);
120
179
  if (!witness) {
121
180
  throw new Error(`Block hash ${parsedBlockHash.toString()} not found in the archive tree at anchor block ${parsedAnchorBlockHash.toString()}.`);
122
181
  }
123
182
  return witness.toNoirRepresentation();
124
183
  }
125
- async utilityGetNullifierMembershipWitness([blockHash], [nullifier]) {
184
+ // eslint-disable-next-line camelcase
185
+ async aztec_utl_getNullifierMembershipWitness([blockHash], [nullifier]) {
126
186
  const parsedBlockHash = BlockHash.fromString(blockHash);
127
187
  const parsedNullifier = Fr.fromString(nullifier);
128
- const witness = await this.handlerAsUtility().utilityGetNullifierMembershipWitness(parsedBlockHash, parsedNullifier);
188
+ const witness = await this.handlerAsUtility().getNullifierMembershipWitness(parsedBlockHash, parsedNullifier);
129
189
  if (!witness) {
130
190
  throw new Error(`Nullifier witness not found for nullifier ${parsedNullifier} at block hash ${parsedBlockHash.toString()}.`);
131
191
  }
132
192
  return witness.toNoirRepresentation();
133
193
  }
134
- async utilityGetLowNullifierMembershipWitness([blockHash], [nullifier]) {
194
+ // eslint-disable-next-line camelcase
195
+ async aztec_utl_getLowNullifierMembershipWitness([blockHash], [nullifier]) {
135
196
  const parsedBlockHash = BlockHash.fromString(blockHash);
136
197
  const parsedNullifier = Fr.fromString(nullifier);
137
- const witness = await this.handlerAsUtility().utilityGetLowNullifierMembershipWitness(parsedBlockHash, parsedNullifier);
198
+ const witness = await this.handlerAsUtility().getLowNullifierMembershipWitness(parsedBlockHash, parsedNullifier);
138
199
  if (!witness) {
139
200
  throw new Error(`Low nullifier witness not found for nullifier ${parsedNullifier} at block hash ${parsedBlockHash.toString()}.`);
140
201
  }
141
202
  return witness.toNoirRepresentation();
142
203
  }
143
- async utilityGetPublicDataWitness([blockHash], [leafSlot]) {
204
+ // eslint-disable-next-line camelcase
205
+ async aztec_utl_getPublicDataWitness([blockHash], [leafSlot]) {
144
206
  const parsedBlockHash = BlockHash.fromString(blockHash);
145
207
  const parsedLeafSlot = Fr.fromString(leafSlot);
146
- const witness = await this.handlerAsUtility().utilityGetPublicDataWitness(parsedBlockHash, parsedLeafSlot);
208
+ const witness = await this.handlerAsUtility().getPublicDataWitness(parsedBlockHash, parsedLeafSlot);
147
209
  if (!witness) {
148
210
  throw new Error(`Public data witness not found for slot ${parsedLeafSlot} at block hash ${parsedBlockHash.toString()}.`);
149
211
  }
150
212
  return witness.toNoirRepresentation();
151
213
  }
152
- async utilityGetBlockHeader([blockNumber]) {
214
+ // eslint-disable-next-line camelcase
215
+ async aztec_utl_getBlockHeader([blockNumber]) {
153
216
  const parsedBlockNumber = Fr.fromString(blockNumber).toNumber();
154
- const header = await this.handlerAsUtility().utilityGetBlockHeader(BlockNumber(parsedBlockNumber));
217
+ const header = await this.handlerAsUtility().getBlockHeader(BlockNumber(parsedBlockNumber));
155
218
  if (!header) {
156
219
  throw new Error(`Block header not found for block ${parsedBlockNumber}.`);
157
220
  }
158
221
  return header.toFields().map(toACVMField);
159
222
  }
160
- async utilityGetAuthWitness([messageHash]) {
223
+ // eslint-disable-next-line camelcase
224
+ async aztec_utl_getAuthWitness([messageHash]) {
161
225
  const messageHashField = Fr.fromString(messageHash);
162
- const witness = await this.handlerAsUtility().utilityGetAuthWitness(messageHashField);
226
+ const witness = await this.handlerAsUtility().getAuthWitness(messageHashField);
163
227
  if (!witness) {
164
228
  throw new Error(`Unknown auth witness for message hash ${messageHashField}`);
165
229
  }
@@ -167,9 +231,10 @@ export class UnavailableOracleError extends Error {
167
231
  witness.map(toACVMField)
168
232
  ];
169
233
  }
170
- async utilityTryGetPublicKeysAndPartialAddress([address]) {
234
+ // eslint-disable-next-line camelcase
235
+ async aztec_utl_getPublicKeysAndPartialAddress([address]) {
171
236
  const parsedAddress = AztecAddress.fromField(Fr.fromString(address));
172
- const result = await this.handlerAsUtility().utilityTryGetPublicKeysAndPartialAddress(parsedAddress);
237
+ const result = await this.handlerAsUtility().getPublicKeysAndPartialAddress(parsedAddress);
173
238
  // We are going to return a Noir Option struct to represent the possibility of null values. Options are a struct
174
239
  // with two fields: `some` (a boolean) and `value` (a field array in this case).
175
240
  if (result === undefined) {
@@ -189,10 +254,11 @@ export class UnavailableOracleError extends Error {
189
254
  ];
190
255
  }
191
256
  }
192
- async utilityGetNotes([ownerSome], [ownerValue], [storageSlot], [numSelects], selectByIndexes, selectByOffsets, selectByLengths, selectValues, selectComparators, sortByIndexes, sortByOffsets, sortByLengths, sortOrder, [limit], [offset], [status], [maxNotes], [packedHintedNoteLength]) {
257
+ // eslint-disable-next-line camelcase
258
+ async aztec_utl_getNotes([ownerSome], [ownerValue], [storageSlot], [numSelects], selectByIndexes, selectByOffsets, selectByLengths, selectValues, selectComparators, sortByIndexes, sortByOffsets, sortByLengths, sortOrder, [limit], [offset], [status], [maxNotes], [packedHintedNoteLength]) {
193
259
  // Parse Option<AztecAddress>: ownerSome is 0 for None, 1 for Some
194
260
  const owner = Fr.fromString(ownerSome).toNumber() === 1 ? AztecAddress.fromString(ownerValue) : undefined;
195
- const noteDatas = await this.handlerAsUtility().utilityGetNotes(owner, Fr.fromString(storageSlot), +numSelects, selectByIndexes.map((s)=>+s), selectByOffsets.map((s)=>+s), selectByLengths.map((s)=>+s), selectValues.map(Fr.fromString), selectComparators.map((s)=>+s), sortByIndexes.map((s)=>+s), sortByOffsets.map((s)=>+s), sortByLengths.map((s)=>+s), sortOrder.map((s)=>+s), +limit, +offset, +status);
261
+ const noteDatas = await this.handlerAsUtility().getNotes(owner, Fr.fromString(storageSlot), +numSelects, selectByIndexes.map((s)=>+s), selectByOffsets.map((s)=>+s), selectByLengths.map((s)=>+s), selectValues.map(Fr.fromString), selectComparators.map((s)=>+s), sortByIndexes.map((s)=>+s), sortByOffsets.map((s)=>+s), sortByLengths.map((s)=>+s), sortOrder.map((s)=>+s), +limit, +offset, +status);
196
262
  const returnDataAsArrayOfPackedHintedNotes = noteDatas.map((noteData)=>packAsHintedNote({
197
263
  contractAddress: noteData.contractAddress,
198
264
  owner: noteData.owner,
@@ -207,57 +273,67 @@ export class UnavailableOracleError extends Error {
207
273
  // At last we convert the array of arrays to a bounded vec of arrays
208
274
  return arrayOfArraysToBoundedVecOfArrays(returnDataAsArrayOfACVMFieldArrays, +maxNotes, +packedHintedNoteLength);
209
275
  }
210
- privateNotifyCreatedNote([owner], [storageSlot], [randomness], [noteTypeId], note, [noteHash], [counter]) {
211
- this.handlerAsPrivate().privateNotifyCreatedNote(AztecAddress.fromString(owner), Fr.fromString(storageSlot), Fr.fromString(randomness), NoteSelector.fromField(Fr.fromString(noteTypeId)), note.map(Fr.fromString), Fr.fromString(noteHash), +counter);
276
+ // eslint-disable-next-line camelcase
277
+ aztec_prv_notifyCreatedNote([owner], [storageSlot], [randomness], [noteTypeId], note, [noteHash], [counter]) {
278
+ this.handlerAsPrivate().notifyCreatedNote(AztecAddress.fromString(owner), Fr.fromString(storageSlot), Fr.fromString(randomness), NoteSelector.fromField(Fr.fromString(noteTypeId)), note.map(Fr.fromString), Fr.fromString(noteHash), +counter);
212
279
  return Promise.resolve([]);
213
280
  }
214
- async privateNotifyNullifiedNote([innerNullifier], [noteHash], [counter]) {
215
- await this.handlerAsPrivate().privateNotifyNullifiedNote(Fr.fromString(innerNullifier), Fr.fromString(noteHash), +counter);
281
+ // eslint-disable-next-line camelcase
282
+ async aztec_prv_notifyNullifiedNote([innerNullifier], [noteHash], [counter]) {
283
+ await this.handlerAsPrivate().notifyNullifiedNote(Fr.fromString(innerNullifier), Fr.fromString(noteHash), +counter);
216
284
  return [];
217
285
  }
218
- async privateNotifyCreatedNullifier([innerNullifier]) {
219
- await this.handlerAsPrivate().privateNotifyCreatedNullifier(Fr.fromString(innerNullifier));
286
+ // eslint-disable-next-line camelcase
287
+ async aztec_prv_notifyCreatedNullifier([innerNullifier]) {
288
+ await this.handlerAsPrivate().notifyCreatedNullifier(Fr.fromString(innerNullifier));
220
289
  return [];
221
290
  }
222
- async privateIsNullifierPending([innerNullifier], [contractAddress]) {
223
- const isPending = await this.handlerAsPrivate().privateIsNullifierPending(Fr.fromString(innerNullifier), AztecAddress.fromString(contractAddress));
291
+ // eslint-disable-next-line camelcase
292
+ async aztec_prv_isNullifierPending([innerNullifier], [contractAddress]) {
293
+ const isPending = await this.handlerAsPrivate().isNullifierPending(Fr.fromString(innerNullifier), AztecAddress.fromString(contractAddress));
224
294
  return [
225
295
  toACVMField(isPending)
226
296
  ];
227
297
  }
228
- async utilityCheckNullifierExists([innerNullifier]) {
229
- const exists = await this.handlerAsUtility().utilityCheckNullifierExists(Fr.fromString(innerNullifier));
298
+ // eslint-disable-next-line camelcase
299
+ async aztec_utl_doesNullifierExist([innerNullifier]) {
300
+ const exists = await this.handlerAsUtility().doesNullifierExist(Fr.fromString(innerNullifier));
230
301
  return [
231
302
  toACVMField(exists)
232
303
  ];
233
304
  }
234
- async utilityGetL1ToL2MembershipWitness([contractAddress], [messageHash], [secret]) {
235
- const message = await this.handlerAsUtility().utilityGetL1ToL2MembershipWitness(AztecAddress.fromString(contractAddress), Fr.fromString(messageHash), Fr.fromString(secret));
305
+ // eslint-disable-next-line camelcase
306
+ async aztec_utl_getL1ToL2MembershipWitness([contractAddress], [messageHash], [secret]) {
307
+ const message = await this.handlerAsUtility().getL1ToL2MembershipWitness(AztecAddress.fromString(contractAddress), Fr.fromString(messageHash), Fr.fromString(secret));
236
308
  return message.toNoirRepresentation();
237
309
  }
238
- async utilityStorageRead([blockHash], [contractAddress], [startStorageSlot], [numberOfElements]) {
239
- const values = await this.handlerAsUtility().utilityStorageRead(BlockHash.fromString(blockHash), new AztecAddress(Fr.fromString(contractAddress)), Fr.fromString(startStorageSlot), +numberOfElements);
310
+ // eslint-disable-next-line camelcase
311
+ async aztec_utl_getFromPublicStorage([blockHash], [contractAddress], [startStorageSlot], [numberOfElements]) {
312
+ const values = await this.handlerAsUtility().getFromPublicStorage(BlockHash.fromString(blockHash), new AztecAddress(Fr.fromString(contractAddress)), Fr.fromString(startStorageSlot), +numberOfElements);
240
313
  return [
241
314
  values.map(toACVMField)
242
315
  ];
243
316
  }
244
- privateNotifyCreatedContractClassLog([contractAddress], message, [length], [counter]) {
317
+ // eslint-disable-next-line camelcase
318
+ aztec_prv_notifyCreatedContractClassLog([contractAddress], message, [length], [counter]) {
245
319
  const logFields = new ContractClassLogFields(message.map(Fr.fromString));
246
320
  const log = new ContractClassLog(new AztecAddress(Fr.fromString(contractAddress)), logFields, +length);
247
- this.handlerAsPrivate().privateNotifyCreatedContractClassLog(log, +counter);
321
+ this.handlerAsPrivate().notifyCreatedContractClassLog(log, +counter);
248
322
  return Promise.resolve([]);
249
323
  }
250
- async utilityLog(level, message, _ignoredFieldsSize, fields) {
324
+ // eslint-disable-next-line camelcase
325
+ async aztec_utl_log(level, message, _ignoredFieldsSize, fields) {
251
326
  const levelFr = Fr.fromString(level[0]);
252
327
  const messageStr = message.map((acvmField)=>String.fromCharCode(Fr.fromString(acvmField).toNumber())).join('');
253
328
  const fieldsFr = fields.map(Fr.fromString);
254
- await this.handlerAsMisc().utilityLog(levelFr.toNumber(), messageStr, fieldsFr);
329
+ await this.handlerAsMisc().log(levelFr.toNumber(), messageStr, fieldsFr);
255
330
  return [];
256
331
  }
257
332
  // This function's name is directly hardcoded in `circuit_recorder.ts`. Don't forget to update it there if you
258
333
  // change the name here.
259
- async privateCallPrivateFunction([contractAddress], [functionSelector], [argsHash], [sideEffectCounter], [isStaticCall]) {
260
- const { endSideEffectCounter, returnsHash } = await this.handlerAsPrivate().privateCallPrivateFunction(AztecAddress.fromField(Fr.fromString(contractAddress)), FunctionSelector.fromField(Fr.fromString(functionSelector)), Fr.fromString(argsHash), Fr.fromString(sideEffectCounter).toNumber(), Fr.fromString(isStaticCall).toBool());
334
+ // eslint-disable-next-line camelcase
335
+ async aztec_prv_callPrivateFunction([contractAddress], [functionSelector], [argsHash], [sideEffectCounter], [isStaticCall]) {
336
+ const { endSideEffectCounter, returnsHash } = await this.handlerAsPrivate().callPrivateFunction(AztecAddress.fromField(Fr.fromString(contractAddress)), FunctionSelector.fromField(Fr.fromString(functionSelector)), Fr.fromString(argsHash), Fr.fromString(sideEffectCounter).toNumber(), Fr.fromString(isStaticCall).toBool());
261
337
  return [
262
338
  [
263
339
  endSideEffectCounter,
@@ -265,48 +341,84 @@ export class UnavailableOracleError extends Error {
265
341
  ].map(toACVMField)
266
342
  ];
267
343
  }
268
- async privateNotifyEnqueuedPublicFunctionCall([contractAddress], [calldataHash], [sideEffectCounter], [isStaticCall]) {
269
- await this.handlerAsPrivate().privateNotifyEnqueuedPublicFunctionCall(AztecAddress.fromString(contractAddress), Fr.fromString(calldataHash), Fr.fromString(sideEffectCounter).toNumber(), Fr.fromString(isStaticCall).toBool());
270
- return [];
271
- }
272
- async privateNotifySetPublicTeardownFunctionCall([contractAddress], [calldataHash], [sideEffectCounter], [isStaticCall]) {
273
- await this.handlerAsPrivate().privateNotifySetPublicTeardownFunctionCall(AztecAddress.fromString(contractAddress), Fr.fromString(calldataHash), Fr.fromString(sideEffectCounter).toNumber(), Fr.fromString(isStaticCall).toBool());
344
+ // eslint-disable-next-line camelcase
345
+ async aztec_prv_assertValidPublicCalldata([calldataHash]) {
346
+ await this.handlerAsPrivate().assertValidPublicCalldata(Fr.fromString(calldataHash));
274
347
  return [];
275
348
  }
276
- async privateNotifySetMinRevertibleSideEffectCounter([minRevertibleSideEffectCounter]) {
277
- await this.handlerAsPrivate().privateNotifySetMinRevertibleSideEffectCounter(Fr.fromString(minRevertibleSideEffectCounter).toNumber());
349
+ // eslint-disable-next-line camelcase
350
+ async aztec_prv_notifyRevertiblePhaseStart([minRevertibleSideEffectCounter]) {
351
+ await this.handlerAsPrivate().notifyRevertiblePhaseStart(Fr.fromString(minRevertibleSideEffectCounter).toNumber());
278
352
  return Promise.resolve([]);
279
353
  }
280
- async privateIsSideEffectCounterRevertible([sideEffectCounter]) {
281
- const isRevertible = await this.handlerAsPrivate().privateIsSideEffectCounterRevertible(Fr.fromString(sideEffectCounter).toNumber());
354
+ // eslint-disable-next-line camelcase
355
+ async aztec_prv_isExecutionInRevertiblePhase([sideEffectCounter]) {
356
+ const isRevertible = await this.handlerAsPrivate().isExecutionInRevertiblePhase(Fr.fromString(sideEffectCounter).toNumber());
282
357
  return Promise.resolve([
283
358
  toACVMField(isRevertible)
284
359
  ]);
285
360
  }
286
- async privateGetNextAppTagAsSender([sender], [recipient]) {
287
- const tag = await this.handlerAsPrivate().privateGetNextAppTagAsSender(AztecAddress.fromString(sender), AztecAddress.fromString(recipient));
361
+ // eslint-disable-next-line camelcase
362
+ async aztec_prv_getNextAppTagAsSender([sender], [recipient]) {
363
+ const tag = await this.handlerAsPrivate().getNextAppTagAsSender(AztecAddress.fromString(sender), AztecAddress.fromString(recipient));
288
364
  return [
289
365
  toACVMField(tag.value)
290
366
  ];
291
367
  }
292
- async utilityFetchTaggedLogs([pendingTaggedLogArrayBaseSlot]) {
293
- await this.handlerAsUtility().utilityFetchTaggedLogs(Fr.fromString(pendingTaggedLogArrayBaseSlot));
368
+ // eslint-disable-next-line camelcase
369
+ async aztec_utl_getPendingTaggedLogs([pendingTaggedLogArrayBaseSlot], [scope]) {
370
+ await this.handlerAsUtility().getPendingTaggedLogs(Fr.fromString(pendingTaggedLogArrayBaseSlot), AztecAddress.fromString(scope));
371
+ return [];
372
+ }
373
+ // eslint-disable-next-line camelcase
374
+ async aztec_utl_getPendingTaggedLogs_v2([scope]) {
375
+ const slot = await this.handlerAsUtility().getPendingTaggedLogsV2(AztecAddress.fromString(scope));
376
+ return [
377
+ toACVMField(slot)
378
+ ];
379
+ }
380
+ // eslint-disable-next-line camelcase
381
+ async aztec_utl_validateAndStoreEnqueuedNotesAndEvents([contractAddress], [noteValidationRequestsArrayBaseSlot], [eventValidationRequestsArrayBaseSlot], [maxNotePackedLen], [maxEventSerializedLen], [scope]) {
382
+ await this.handlerAsUtility().validateAndStoreEnqueuedNotesAndEvents(AztecAddress.fromString(contractAddress), Fr.fromString(noteValidationRequestsArrayBaseSlot), Fr.fromString(eventValidationRequestsArrayBaseSlot), Fr.fromString(maxNotePackedLen).toNumber(), Fr.fromString(maxEventSerializedLen).toNumber(), AztecAddress.fromString(scope));
294
383
  return [];
295
384
  }
296
- async utilityValidateAndStoreEnqueuedNotesAndEvents([contractAddress], [noteValidationRequestsArrayBaseSlot], [eventValidationRequestsArrayBaseSlot]) {
297
- await this.handlerAsUtility().utilityValidateAndStoreEnqueuedNotesAndEvents(AztecAddress.fromString(contractAddress), Fr.fromString(noteValidationRequestsArrayBaseSlot), Fr.fromString(eventValidationRequestsArrayBaseSlot));
385
+ // eslint-disable-next-line camelcase
386
+ async aztec_utl_validateAndStoreEnqueuedNotesAndEvents_v2([noteValidationRequestsArrayBaseSlot], [eventValidationRequestsArrayBaseSlot], [maxNotePackedLen], [maxEventSerializedLen], [scope]) {
387
+ await this.handlerAsUtility().validateAndStoreEnqueuedNotesAndEventsV2(Fr.fromString(noteValidationRequestsArrayBaseSlot), Fr.fromString(eventValidationRequestsArrayBaseSlot), Fr.fromString(maxNotePackedLen).toNumber(), Fr.fromString(maxEventSerializedLen).toNumber(), AztecAddress.fromString(scope));
298
388
  return [];
299
389
  }
300
- async utilityBulkRetrieveLogs([contractAddress], [logRetrievalRequestsArrayBaseSlot], [logRetrievalResponsesArrayBaseSlot]) {
301
- await this.handlerAsUtility().utilityBulkRetrieveLogs(AztecAddress.fromString(contractAddress), Fr.fromString(logRetrievalRequestsArrayBaseSlot), Fr.fromString(logRetrievalResponsesArrayBaseSlot));
390
+ // eslint-disable-next-line camelcase
391
+ async aztec_utl_getLogsByTag([contractAddress], [logRetrievalRequestsArrayBaseSlot], [logRetrievalResponsesArrayBaseSlot], [scope]) {
392
+ await this.handlerAsUtility().getLogsByTag(AztecAddress.fromString(contractAddress), Fr.fromString(logRetrievalRequestsArrayBaseSlot), Fr.fromString(logRetrievalResponsesArrayBaseSlot), AztecAddress.fromString(scope));
302
393
  return [];
303
394
  }
304
- async utilityStoreCapsule([contractAddress], [slot], capsule) {
305
- await this.handlerAsUtility().utilityStoreCapsule(AztecAddress.fromField(Fr.fromString(contractAddress)), Fr.fromString(slot), capsule.map(Fr.fromString));
395
+ // eslint-disable-next-line camelcase
396
+ async aztec_utl_getMessageContextsByTxHash([contractAddress], [messageContextRequestsArrayBaseSlot], [messageContextResponsesArrayBaseSlot], [scope]) {
397
+ await this.handlerAsUtility().getMessageContextsByTxHash(AztecAddress.fromString(contractAddress), Fr.fromString(messageContextRequestsArrayBaseSlot), Fr.fromString(messageContextResponsesArrayBaseSlot), AztecAddress.fromString(scope));
306
398
  return [];
307
399
  }
308
- async utilityLoadCapsule([contractAddress], [slot], [tSize]) {
309
- const values = await this.handlerAsUtility().utilityLoadCapsule(AztecAddress.fromField(Fr.fromString(contractAddress)), Fr.fromString(slot));
400
+ // eslint-disable-next-line camelcase
401
+ async aztec_utl_getLogsByTag_v2([requestArrayBaseSlot]) {
402
+ const responseSlot = await this.handlerAsUtility().getLogsByTagV2(Fr.fromString(requestArrayBaseSlot));
403
+ return [
404
+ toACVMField(responseSlot)
405
+ ];
406
+ }
407
+ // eslint-disable-next-line camelcase
408
+ async aztec_utl_getMessageContextsByTxHash_v2([requestArrayBaseSlot]) {
409
+ const responseSlot = await this.handlerAsUtility().getMessageContextsByTxHashV2(Fr.fromString(requestArrayBaseSlot));
410
+ return [
411
+ toACVMField(responseSlot)
412
+ ];
413
+ }
414
+ // eslint-disable-next-line camelcase
415
+ aztec_utl_setCapsule([contractAddress], [slot], capsule, [scope]) {
416
+ this.handlerAsUtility().setCapsule(AztecAddress.fromField(Fr.fromString(contractAddress)), Fr.fromString(slot), capsule.map(Fr.fromString), AztecAddress.fromField(Fr.fromString(scope)));
417
+ return Promise.resolve([]);
418
+ }
419
+ // eslint-disable-next-line camelcase
420
+ async aztec_utl_getCapsule([contractAddress], [slot], [tSize], [scope]) {
421
+ const values = await this.handlerAsUtility().getCapsule(AztecAddress.fromField(Fr.fromString(contractAddress)), Fr.fromString(slot), AztecAddress.fromField(Fr.fromString(scope)));
310
422
  // We are going to return a Noir Option struct to represent the possibility of null values. Options are a struct
311
423
  // with two fields: `some` (a boolean) and `value` (a field array in this case).
312
424
  if (values === null) {
@@ -323,35 +435,107 @@ export class UnavailableOracleError extends Error {
323
435
  ];
324
436
  }
325
437
  }
326
- async utilityDeleteCapsule([contractAddress], [slot]) {
327
- await this.handlerAsUtility().utilityDeleteCapsule(AztecAddress.fromField(Fr.fromString(contractAddress)), Fr.fromString(slot));
328
- return [];
438
+ // eslint-disable-next-line camelcase
439
+ aztec_utl_deleteCapsule([contractAddress], [slot], [scope]) {
440
+ this.handlerAsUtility().deleteCapsule(AztecAddress.fromField(Fr.fromString(contractAddress)), Fr.fromString(slot), AztecAddress.fromField(Fr.fromString(scope)));
441
+ return Promise.resolve([]);
329
442
  }
330
- async utilityCopyCapsule([contractAddress], [srcSlot], [dstSlot], [numEntries]) {
331
- await this.handlerAsUtility().utilityCopyCapsule(AztecAddress.fromField(Fr.fromString(contractAddress)), Fr.fromString(srcSlot), Fr.fromString(dstSlot), Fr.fromString(numEntries).toNumber());
443
+ // eslint-disable-next-line camelcase
444
+ async aztec_utl_copyCapsule([contractAddress], [srcSlot], [dstSlot], [numEntries], [scope]) {
445
+ await this.handlerAsUtility().copyCapsule(AztecAddress.fromField(Fr.fromString(contractAddress)), Fr.fromString(srcSlot), Fr.fromString(dstSlot), Fr.fromString(numEntries).toNumber(), AztecAddress.fromField(Fr.fromString(scope)));
332
446
  return [];
333
447
  }
334
- async utilityAes128Decrypt(ciphertextBVecStorage, [ciphertextLength], iv, symKey) {
448
+ // eslint-disable-next-line camelcase
449
+ aztec_utl_pushEphemeral([slot], elements) {
450
+ const newLen = this.handlerAsUtility().pushEphemeral(Fr.fromString(slot), elements.map(Fr.fromString));
451
+ return Promise.resolve([
452
+ toACVMField(newLen)
453
+ ]);
454
+ }
455
+ // eslint-disable-next-line camelcase
456
+ aztec_utl_popEphemeral([slot]) {
457
+ const element = this.handlerAsUtility().popEphemeral(Fr.fromString(slot));
458
+ return Promise.resolve([
459
+ element.map(toACVMField)
460
+ ]);
461
+ }
462
+ // eslint-disable-next-line camelcase
463
+ aztec_utl_getEphemeral([slot], [index]) {
464
+ const element = this.handlerAsUtility().getEphemeral(Fr.fromString(slot), Fr.fromString(index).toNumber());
465
+ return Promise.resolve([
466
+ element.map(toACVMField)
467
+ ]);
468
+ }
469
+ // eslint-disable-next-line camelcase
470
+ aztec_utl_setEphemeral([slot], [index], elements) {
471
+ this.handlerAsUtility().setEphemeral(Fr.fromString(slot), Fr.fromString(index).toNumber(), elements.map(Fr.fromString));
472
+ return Promise.resolve([]);
473
+ }
474
+ // eslint-disable-next-line camelcase
475
+ aztec_utl_getEphemeralLen([slot]) {
476
+ const len = this.handlerAsUtility().getEphemeralLen(Fr.fromString(slot));
477
+ return Promise.resolve([
478
+ toACVMField(len)
479
+ ]);
480
+ }
481
+ // eslint-disable-next-line camelcase
482
+ aztec_utl_removeEphemeral([slot], [index]) {
483
+ this.handlerAsUtility().removeEphemeral(Fr.fromString(slot), Fr.fromString(index).toNumber());
484
+ return Promise.resolve([]);
485
+ }
486
+ // eslint-disable-next-line camelcase
487
+ aztec_utl_clearEphemeral([slot]) {
488
+ this.handlerAsUtility().clearEphemeral(Fr.fromString(slot));
489
+ return Promise.resolve([]);
490
+ }
491
+ // eslint-disable-next-line camelcase
492
+ async aztec_utl_decryptAes128(ciphertextBVecStorage, [ciphertextLength], iv, symKey) {
335
493
  const ciphertext = fromUintBoundedVec(ciphertextBVecStorage, ciphertextLength, 8);
336
494
  const ivBuffer = fromUintArray(iv, 8);
337
495
  const symKeyBuffer = fromUintArray(symKey, 8);
338
- const plaintext = await this.handlerAsUtility().utilityAes128Decrypt(ciphertext, ivBuffer, symKeyBuffer);
339
- return bufferToBoundedVec(plaintext, ciphertextBVecStorage.length);
496
+ // Noir Option<BoundedVec> is encoded as [is_some: Field, storage: Field[], length: Field].
497
+ try {
498
+ const plaintext = await this.handlerAsUtility().decryptAes128(ciphertext, ivBuffer, symKeyBuffer);
499
+ const [storage, length] = bufferToBoundedVec(plaintext, ciphertextBVecStorage.length);
500
+ return [
501
+ toACVMField(1),
502
+ storage,
503
+ length
504
+ ];
505
+ } catch {
506
+ const zeroStorage = Array(ciphertextBVecStorage.length).fill(toACVMField(0));
507
+ return [
508
+ toACVMField(0),
509
+ zeroStorage,
510
+ toACVMField(0)
511
+ ];
512
+ }
340
513
  }
341
- async utilityGetSharedSecret([address], [ephPKField0], [ephPKField1], [ephPKField2]) {
342
- const secret = await this.handlerAsUtility().utilityGetSharedSecret(AztecAddress.fromField(Fr.fromString(address)), Point.fromFields([
514
+ // eslint-disable-next-line camelcase
515
+ async aztec_utl_getSharedSecret([address], [ephPKField0], [ephPKField1], [ephPKField2], [contractAddress]) {
516
+ const secret = await this.handlerAsUtility().getSharedSecret(AztecAddress.fromField(Fr.fromString(address)), Point.fromFields([
343
517
  ephPKField0,
344
518
  ephPKField1,
345
519
  ephPKField2
346
- ].map(Fr.fromString)));
347
- return secret.toFields().map(toACVMField);
520
+ ].map(Fr.fromString)), AztecAddress.fromField(Fr.fromString(contractAddress)));
521
+ return [
522
+ toACVMField(secret)
523
+ ];
524
+ }
525
+ // eslint-disable-next-line camelcase
526
+ aztec_utl_setContractSyncCacheInvalid([contractAddress], scopes, [scopeCount]) {
527
+ const scopeAddresses = scopes.slice(0, +scopeCount).map((s)=>AztecAddress.fromField(Fr.fromString(s)));
528
+ this.handlerAsUtility().setContractSyncCacheInvalid(AztecAddress.fromField(Fr.fromString(contractAddress)), scopeAddresses);
529
+ return Promise.resolve([]);
348
530
  }
349
- async utilityEmitOffchainEffect(data) {
350
- await this.handlerAsPrivate().utilityEmitOffchainEffect(data.map(Fr.fromString));
531
+ // eslint-disable-next-line camelcase
532
+ async aztec_utl_emitOffchainEffect(data) {
533
+ await this.handlerAsUtility().emitOffchainEffect(data.map(Fr.fromString));
351
534
  return [];
352
535
  }
353
- async privateGetSenderForTags() {
354
- const sender = await this.handlerAsPrivate().privateGetSenderForTags();
536
+ // eslint-disable-next-line camelcase
537
+ async aztec_prv_getSenderForTags() {
538
+ const sender = await this.handlerAsPrivate().getSenderForTags();
355
539
  // Return [1, address] for Some(address), [0, 0] for None
356
540
  return sender ? [
357
541
  toACVMField(1n),
@@ -361,8 +545,9 @@ export class UnavailableOracleError extends Error {
361
545
  toACVMField(0n)
362
546
  ];
363
547
  }
364
- async privateSetSenderForTags([senderForTags]) {
365
- await this.handlerAsPrivate().privateSetSenderForTags(AztecAddress.fromField(Fr.fromString(senderForTags)));
548
+ // eslint-disable-next-line camelcase
549
+ async aztec_prv_setSenderForTags([senderForTags]) {
550
+ await this.handlerAsPrivate().setSenderForTags(AztecAddress.fromField(Fr.fromString(senderForTags)));
366
551
  return [];
367
552
  }
368
553
  }
@@ -45,11 +45,11 @@ import { Oracle } from './oracle.js';
45
45
  appCircuitName: functionName
46
46
  });
47
47
  const contractClassLogs = privateExecutionOracle.getContractClassLogs();
48
- const rawReturnValues = await privateExecutionOracle.privateLoadFromExecutionCache(publicInputs.returnsHash);
48
+ const rawReturnValues = await privateExecutionOracle.getHashPreimage(publicInputs.returnsHash);
49
49
  const newNotes = privateExecutionOracle.getNewNotes();
50
50
  const noteHashNullifierCounterMap = privateExecutionOracle.getNoteHashNullifierCounterMap();
51
51
  const offchainEffects = privateExecutionOracle.getOffchainEffects();
52
- const preTags = privateExecutionOracle.getUsedPreTags();
52
+ const taggingIndexRanges = privateExecutionOracle.getUsedTaggingIndexRanges();
53
53
  const nestedExecutionResults = privateExecutionOracle.getNestedExecutionResults();
54
54
  let timerSubtractionList = nestedExecutionResults;
55
55
  let witgenTime = duration;
@@ -59,7 +59,9 @@ import { Oracle } from './oracle.js';
59
59
  timerSubtractionList = timerSubtractionList.flatMap((nested)=>nested.nestedExecutionResults ?? []);
60
60
  }
61
61
  log.debug(`Returning from call to ${contractAddress.toString()}:${functionSelector}`);
62
- return new PrivateCallExecutionResult(artifact.bytecode, Buffer.from(artifact.verificationKey, 'base64'), partialWitness, publicInputs, newNotes, noteHashNullifierCounterMap, rawReturnValues, offchainEffects, preTags, nestedExecutionResults, contractClassLogs, {
62
+ return new PrivateCallExecutionResult(artifact.bytecode, Buffer.from(artifact.verificationKey, 'base64'), partialWitness, publicInputs, newNotes, noteHashNullifierCounterMap, rawReturnValues, offchainEffects.map((e)=>({
63
+ data: e.data
64
+ })), taggingIndexRanges, nestedExecutionResults, contractClassLogs, {
63
65
  timings: {
64
66
  witgen: witgenTime,
65
67
  oracles: acirExecutionResult.oracles