@aztec/pxe 5.0.0-rc.2 → 5.0.0

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 (188) hide show
  1. package/dest/block_synchronizer/block_synchronizer.d.ts +5 -3
  2. package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -1
  3. package/dest/block_synchronizer/block_synchronizer.js +7 -1
  4. package/dest/contract/contract_class_service.d.ts +31 -0
  5. package/dest/contract/contract_class_service.d.ts.map +1 -0
  6. package/dest/contract/contract_class_service.js +68 -0
  7. package/dest/{contract_sync → contract}/contract_sync_service.d.ts +7 -6
  8. package/dest/contract/contract_sync_service.d.ts.map +1 -0
  9. package/dest/{contract_sync → contract}/contract_sync_service.js +10 -30
  10. package/dest/contract/helpers.d.ts +7 -0
  11. package/dest/contract/helpers.d.ts.map +1 -0
  12. package/dest/contract/helpers.js +20 -0
  13. package/dest/contract_function_simulator/anchored_contract_data.d.ts +36 -0
  14. package/dest/contract_function_simulator/anchored_contract_data.d.ts.map +1 -0
  15. package/dest/contract_function_simulator/anchored_contract_data.js +54 -0
  16. package/dest/contract_function_simulator/aztec_node_read_cache.d.ts +39 -0
  17. package/dest/contract_function_simulator/aztec_node_read_cache.d.ts.map +1 -0
  18. package/dest/contract_function_simulator/aztec_node_read_cache.js +60 -0
  19. package/dest/contract_function_simulator/contract_function_simulator.d.ts +9 -3
  20. package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
  21. package/dest/contract_function_simulator/contract_function_simulator.js +31 -14
  22. package/dest/contract_function_simulator/execution_note_cache.d.ts +3 -9
  23. package/dest/contract_function_simulator/execution_note_cache.d.ts.map +1 -1
  24. package/dest/contract_function_simulator/execution_note_cache.js +8 -28
  25. package/dest/contract_function_simulator/index.d.ts +4 -2
  26. package/dest/contract_function_simulator/index.d.ts.map +1 -1
  27. package/dest/contract_function_simulator/index.js +2 -1
  28. package/dest/contract_function_simulator/noir-structs/fact.d.ts +5 -5
  29. package/dest/contract_function_simulator/noir-structs/fact.d.ts.map +1 -1
  30. package/dest/contract_function_simulator/noir-structs/fact.js +2 -2
  31. package/dest/contract_function_simulator/noir-structs/fact_collection.d.ts +3 -3
  32. package/dest/contract_function_simulator/noir-structs/fact_collection.d.ts.map +1 -1
  33. package/dest/contract_function_simulator/noir-structs/fact_collection.js +3 -1
  34. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts +7 -1
  35. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts.map +1 -1
  36. package/dest/contract_function_simulator/noir-structs/pending_tagged_log.d.ts +11 -0
  37. package/dest/contract_function_simulator/noir-structs/pending_tagged_log.d.ts.map +1 -0
  38. package/dest/contract_function_simulator/noir-structs/pending_tagged_log.js +4 -0
  39. package/dest/contract_function_simulator/noir-structs/provided_secret.d.ts +2 -2
  40. package/dest/contract_function_simulator/noir-structs/provided_secret.d.ts.map +1 -1
  41. package/dest/contract_function_simulator/noir-structs/provided_secret.js +1 -1
  42. package/dest/contract_function_simulator/noir-structs/resolved_tagging_strategy.d.ts +8 -1
  43. package/dest/contract_function_simulator/noir-structs/resolved_tagging_strategy.d.ts.map +1 -1
  44. package/dest/contract_function_simulator/noir-structs/resolved_tagging_strategy.js +17 -0
  45. package/dest/contract_function_simulator/oracle/acir_callback.d.ts +7 -2
  46. package/dest/contract_function_simulator/oracle/acir_callback.d.ts.map +1 -1
  47. package/dest/contract_function_simulator/oracle/acir_callback.js +55 -11
  48. package/dest/contract_function_simulator/oracle/legacy_oracle_registry.d.ts +39 -0
  49. package/dest/contract_function_simulator/oracle/legacy_oracle_registry.d.ts.map +1 -0
  50. package/dest/contract_function_simulator/oracle/legacy_oracle_registry.js +107 -0
  51. package/dest/contract_function_simulator/oracle/oracle_registry.d.ts +10 -7
  52. package/dest/contract_function_simulator/oracle/oracle_registry.d.ts.map +1 -1
  53. package/dest/contract_function_simulator/oracle/oracle_registry.js +41 -10
  54. package/dest/contract_function_simulator/oracle/oracle_type_mappings.d.ts +48 -9
  55. package/dest/contract_function_simulator/oracle/oracle_type_mappings.d.ts.map +1 -1
  56. package/dest/contract_function_simulator/oracle/oracle_type_mappings.js +51 -30
  57. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +10 -2
  58. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
  59. package/dest/contract_function_simulator/oracle/private_execution_oracle.js +73 -32
  60. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +20 -16
  61. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
  62. package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +68 -47
  63. package/dest/debug/pxe_debug_utils.d.ts +2 -2
  64. package/dest/debug/pxe_debug_utils.d.ts.map +1 -1
  65. package/dest/entrypoints/client/bundle/utils.js +2 -2
  66. package/dest/entrypoints/client/lazy/utils.js +2 -2
  67. package/dest/entrypoints/server/index.d.ts +5 -2
  68. package/dest/entrypoints/server/index.d.ts.map +1 -1
  69. package/dest/entrypoints/server/index.js +3 -1
  70. package/dest/error_enriching.d.ts +5 -3
  71. package/dest/error_enriching.d.ts.map +1 -1
  72. package/dest/error_enriching.js +12 -10
  73. package/dest/hooks/execution_hooks.d.ts +15 -4
  74. package/dest/hooks/execution_hooks.d.ts.map +1 -1
  75. package/dest/hooks/index.d.ts +3 -2
  76. package/dest/hooks/index.d.ts.map +1 -1
  77. package/dest/hooks/index.js +1 -0
  78. package/dest/hooks/resolve_custom_request.d.ts +23 -0
  79. package/dest/hooks/resolve_custom_request.d.ts.map +1 -0
  80. package/dest/hooks/resolve_custom_request.js +3 -0
  81. package/dest/hooks/resolve_tagging_secret_strategy.d.ts +10 -1
  82. package/dest/hooks/resolve_tagging_secret_strategy.d.ts.map +1 -1
  83. package/dest/hooks/resolve_tagging_secret_strategy.js +3 -3
  84. package/dest/logs/log_service.d.ts +3 -2
  85. package/dest/logs/log_service.d.ts.map +1 -1
  86. package/dest/logs/log_service.js +33 -16
  87. package/dest/oracle_version.d.ts +2 -2
  88. package/dest/oracle_version.js +2 -2
  89. package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts +1 -1
  90. package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts.map +1 -1
  91. package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.js +6 -2
  92. package/dest/private_kernel/private_kernel_execution_prover.d.ts +1 -1
  93. package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -1
  94. package/dest/private_kernel/private_kernel_execution_prover.js +17 -36
  95. package/dest/private_kernel/private_kernel_oracle.d.ts +4 -2
  96. package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -1
  97. package/dest/private_kernel/private_kernel_oracle.js +17 -5
  98. package/dest/pxe.d.ts +81 -46
  99. package/dest/pxe.d.ts.map +1 -1
  100. package/dest/pxe.js +135 -104
  101. package/dest/storage/backwards_compatibility_tests/schema_tests.d.ts +1 -1
  102. package/dest/storage/backwards_compatibility_tests/schema_tests.d.ts.map +1 -1
  103. package/dest/storage/backwards_compatibility_tests/schema_tests.js +31 -7
  104. package/dest/storage/contract_store/contract_store.d.ts +27 -24
  105. package/dest/storage/contract_store/contract_store.d.ts.map +1 -1
  106. package/dest/storage/contract_store/contract_store.js +63 -74
  107. package/dest/storage/fact_store/fact_service.d.ts +6 -4
  108. package/dest/storage/fact_store/fact_service.d.ts.map +1 -1
  109. package/dest/storage/fact_store/fact_service.js +19 -4
  110. package/dest/storage/fact_store/fact_store.d.ts +1 -1
  111. package/dest/storage/fact_store/fact_store.js +1 -1
  112. package/dest/storage/fact_store/index.d.ts +2 -1
  113. package/dest/storage/fact_store/index.d.ts.map +1 -1
  114. package/dest/storage/fact_store/index.js +1 -0
  115. package/dest/storage/fact_store/origin_state.d.ts +57 -0
  116. package/dest/storage/fact_store/origin_state.d.ts.map +1 -0
  117. package/dest/storage/fact_store/origin_state.js +53 -0
  118. package/dest/storage/metadata.d.ts +2 -2
  119. package/dest/storage/metadata.d.ts.map +1 -1
  120. package/dest/storage/metadata.js +1 -1
  121. package/dest/storage/tagging_store/tagging_secret_sources_store.d.ts +17 -6
  122. package/dest/storage/tagging_store/tagging_secret_sources_store.d.ts.map +1 -1
  123. package/dest/storage/tagging_store/tagging_secret_sources_store.js +24 -11
  124. package/dest/tagging/constants.d.ts +2 -2
  125. package/dest/tagging/constants.d.ts.map +1 -1
  126. package/dest/tagging/constants.js +18 -9
  127. package/package.json +17 -17
  128. package/src/block_synchronizer/block_synchronizer.ts +9 -1
  129. package/src/contract/contract_class_service.ts +83 -0
  130. package/src/{contract_sync → contract}/contract_sync_service.ts +18 -37
  131. package/src/contract/helpers.ts +35 -0
  132. package/src/contract_function_simulator/anchored_contract_data.ts +74 -0
  133. package/src/contract_function_simulator/aztec_node_read_cache.ts +89 -0
  134. package/src/contract_function_simulator/contract_function_simulator.ts +56 -14
  135. package/src/contract_function_simulator/execution_note_cache.ts +7 -28
  136. package/src/contract_function_simulator/index.ts +7 -1
  137. package/src/contract_function_simulator/noir-structs/fact.ts +4 -4
  138. package/src/contract_function_simulator/noir-structs/fact_collection.ts +9 -4
  139. package/src/contract_function_simulator/noir-structs/log_retrieval_response.ts +6 -0
  140. package/src/contract_function_simulator/noir-structs/pending_tagged_log.ts +12 -0
  141. package/src/contract_function_simulator/noir-structs/provided_secret.ts +1 -1
  142. package/src/contract_function_simulator/noir-structs/resolved_tagging_strategy.ts +21 -0
  143. package/src/contract_function_simulator/oracle/acir_callback.ts +58 -12
  144. package/src/contract_function_simulator/oracle/legacy_oracle_registry.ts +147 -0
  145. package/src/contract_function_simulator/oracle/oracle_registry.ts +32 -7
  146. package/src/contract_function_simulator/oracle/oracle_type_mappings.ts +49 -32
  147. package/src/contract_function_simulator/oracle/private_execution_oracle.ts +92 -41
  148. package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +104 -59
  149. package/src/debug/pxe_debug_utils.ts +1 -1
  150. package/src/entrypoints/client/bundle/utils.ts +2 -2
  151. package/src/entrypoints/client/lazy/utils.ts +2 -2
  152. package/src/entrypoints/server/index.ts +5 -1
  153. package/src/error_enriching.ts +26 -10
  154. package/src/hooks/execution_hooks.ts +14 -3
  155. package/src/hooks/index.ts +2 -0
  156. package/src/hooks/resolve_custom_request.ts +24 -0
  157. package/src/hooks/resolve_tagging_secret_strategy.ts +14 -0
  158. package/src/logs/log_service.ts +31 -11
  159. package/src/oracle_version.ts +2 -2
  160. package/src/private_kernel/hints/private_kernel_reset_private_inputs_builder.ts +11 -1
  161. package/src/private_kernel/private_kernel_execution_prover.ts +22 -52
  162. package/src/private_kernel/private_kernel_oracle.ts +23 -4
  163. package/src/pxe.ts +209 -143
  164. package/src/storage/backwards_compatibility_tests/__snapshots__/AddressStore.json +6 -6
  165. package/src/storage/backwards_compatibility_tests/__snapshots__/ContractStore.json +1 -1
  166. package/src/storage/backwards_compatibility_tests/__snapshots__/KeyStore.json +12 -12
  167. package/src/storage/backwards_compatibility_tests/__snapshots__/RecipientTaggingStore.json +11 -3
  168. package/src/storage/backwards_compatibility_tests/__snapshots__/SenderTaggingStore.json +12 -4
  169. package/src/storage/backwards_compatibility_tests/__snapshots__/TaggingSecretSourcesStore.json +3 -3
  170. package/src/storage/backwards_compatibility_tests/__snapshots__/opened_stores.json +1 -1
  171. package/src/storage/backwards_compatibility_tests/schema_tests.ts +38 -4
  172. package/src/storage/contract_store/contract_store.ts +85 -92
  173. package/src/storage/fact_store/fact_service.ts +29 -5
  174. package/src/storage/fact_store/fact_store.ts +1 -1
  175. package/src/storage/fact_store/index.ts +10 -0
  176. package/src/storage/fact_store/origin_state.ts +75 -0
  177. package/src/storage/metadata.ts +1 -1
  178. package/src/storage/tagging_store/tagging_secret_sources_store.ts +36 -15
  179. package/src/tagging/constants.ts +19 -9
  180. package/dest/contract_function_simulator/proxied_contract_data_source.d.ts +0 -6
  181. package/dest/contract_function_simulator/proxied_contract_data_source.d.ts.map +0 -1
  182. package/dest/contract_function_simulator/proxied_contract_data_source.js +0 -51
  183. package/dest/contract_sync/contract_sync_service.d.ts.map +0 -1
  184. package/dest/contract_sync/helpers.d.ts +0 -28
  185. package/dest/contract_sync/helpers.d.ts.map +0 -1
  186. package/dest/contract_sync/helpers.js +0 -48
  187. package/src/contract_function_simulator/proxied_contract_data_source.ts +0 -60
  188. package/src/contract_sync/helpers.ts +0 -79
@@ -1,6 +1,6 @@
1
1
  import { BBLazyPrivateKernelProver } from '@aztec/bb-prover/client/lazy';
2
2
  import { createLogger } from '@aztec/foundation/log';
3
- import { createStore } from '@aztec/kv-store/indexeddb';
3
+ import { createStore } from '@aztec/kv-store/sqlite-opfs';
4
4
  import { LazyProtocolContractsProvider } from '@aztec/protocol-contracts/providers/lazy';
5
5
  import { WASMSimulator } from '@aztec/simulator/client';
6
6
  import { getStandardAuthRegistry } from '@aztec/standard-contracts/auth-registry/lazy';
@@ -37,7 +37,7 @@ export async function createPXE(
37
37
 
38
38
  const loggers = options.loggers ?? {};
39
39
 
40
- const storeLogger = loggers.store ?? createLogger('pxe:data:idb', { actor });
40
+ const storeLogger = loggers.store ?? createLogger('pxe:data', { actor });
41
41
 
42
42
  const store =
43
43
  options.store ?? (await createStore('pxe_data', configWithContracts, PXE_DATA_SCHEMA_VERSION, storeLogger));
@@ -1,3 +1,5 @@
1
+ export { type AccountPrivacyKeys, type AccountPrivacySecretKeys } from '@aztec/key-store';
2
+
1
3
  export * from '../../notes_filter.js';
2
4
  export * from '../../pxe.js';
3
5
  export * from '../../config/index.js';
@@ -8,4 +10,6 @@ export { NoteService } from '../../notes/note_service.js';
8
10
  export { ORACLE_VERSION_MAJOR, ORACLE_VERSION_MINOR } from '../../oracle_version.js';
9
11
  export { type PXECreationOptions } from '../pxe_creation_options.js';
10
12
  export { JobCoordinator } from '../../job_coordinator/job_coordinator.js';
11
- export { ContractSyncService } from '../../contract_sync/contract_sync_service.js';
13
+ export { ContractSyncService } from '../../contract/contract_sync_service.js';
14
+ export { ContractClassService } from '../../contract/contract_class_service.js';
15
+ export { AnchoredContractData } from '../../contract_function_simulator/anchored_contract_data.js';
@@ -3,7 +3,9 @@ import { resolveAssertionMessageFromRevertData, resolveOpcodeLocations } from '@
3
3
  import { FunctionSelector } from '@aztec/stdlib/abi';
4
4
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
5
5
  import { type SimulationError, isNoirCallStackUnresolved } from '@aztec/stdlib/errors';
6
+ import type { BlockHeader } from '@aztec/stdlib/tx';
6
7
 
8
+ import type { ContractClassService } from './contract/contract_class_service.js';
7
9
  import type { ContractStore } from './storage/contract_store/contract_store.js';
8
10
 
9
11
  /**
@@ -11,7 +13,13 @@ import type { ContractStore } from './storage/contract_store/contract_store.js';
11
13
  * can be found in the PXE database
12
14
  * @param err - The error to enrich.
13
15
  */
14
- export async function enrichSimulationError(err: SimulationError, contractStore: ContractStore, logger: Logger) {
16
+ export async function enrichSimulationError(
17
+ err: SimulationError,
18
+ contractStore: ContractStore,
19
+ contractClassService: ContractClassService,
20
+ anchorHeader: BlockHeader,
21
+ logger: Logger,
22
+ ) {
15
23
  // Maps contract addresses to the set of function selectors that were in error.
16
24
  // Map and Set do reference equality for their keys instead of value equality, so we store the string
17
25
  // representation to get e.g. different contract address objects with the same address value to match.
@@ -30,13 +38,14 @@ export async function enrichSimulationError(err: SimulationError, contractStore:
30
38
  await Promise.all(
31
39
  [...mentionedFunctions.entries()].map(async ([contractAddress, fnSelectors]) => {
32
40
  const parsedContractAddress = AztecAddress.fromStringUnsafe(contractAddress);
33
- const contract = await contractStore.getContract(parsedContractAddress);
34
- if (contract) {
35
- err.enrichWithContractName(parsedContractAddress, contract.name);
41
+ const classId = await contractClassService.getCurrentClassId(parsedContractAddress, anchorHeader);
42
+ const artifact = classId && (await contractStore.getContractArtifact(classId));
43
+ if (artifact) {
44
+ err.enrichWithContractName(parsedContractAddress, artifact.name);
36
45
  // Map from function selector to function name. It uses a stringified key for the same reason as mentionedFunctions.
37
46
  const selectorToNameMap: Map<string, string> = new Map();
38
47
  await Promise.all(
39
- contract.functions.map(async fn => {
48
+ artifact.functions.map(async fn => {
40
49
  const selector = await FunctionSelector.fromNameAndParameters(fn);
41
50
  selectorToNameMap.set(selector.toString(), fn.name);
42
51
  }),
@@ -51,7 +60,7 @@ export async function enrichSimulationError(err: SimulationError, contractStore:
51
60
  );
52
61
  } else {
53
62
  logger.warn(
54
- `Could not find function artifact in contract ${contract.name} for function '${fnSelector}' when enriching error callstack`,
63
+ `Could not find function artifact in contract ${artifact.name} for function '${fnSelector}' when enriching error callstack`,
55
64
  );
56
65
  }
57
66
  }
@@ -64,7 +73,13 @@ export async function enrichSimulationError(err: SimulationError, contractStore:
64
73
  );
65
74
  }
66
75
 
67
- export async function enrichPublicSimulationError(err: SimulationError, contractStore: ContractStore, logger: Logger) {
76
+ export async function enrichPublicSimulationError(
77
+ err: SimulationError,
78
+ contractStore: ContractStore,
79
+ contractClassService: ContractClassService,
80
+ anchorHeader: BlockHeader,
81
+ logger: Logger,
82
+ ) {
68
83
  const callStack = err.getCallStack();
69
84
  const originalFailingFunction = callStack[callStack.length - 1];
70
85
 
@@ -72,7 +87,8 @@ export async function enrichPublicSimulationError(err: SimulationError, contract
72
87
  throw new Error(`Original failing function not found when enriching public simulation, missing callstack`);
73
88
  }
74
89
 
75
- const artifact = await contractStore.getPublicFunctionArtifact(originalFailingFunction.contractAddress);
90
+ const classId = await contractClassService.getCurrentClassId(originalFailingFunction.contractAddress, anchorHeader);
91
+ const artifact = classId && (await contractStore.getPublicFunctionArtifact(classId));
76
92
  if (!artifact) {
77
93
  throw new Error(
78
94
  `Artifact not found when enriching public simulation error. Contract address: ${originalFailingFunction.contractAddress}.`,
@@ -84,7 +100,7 @@ export async function enrichPublicSimulationError(err: SimulationError, contract
84
100
  err.setOriginalMessage(err.getOriginalMessage() + `${assertionMessage}`);
85
101
  }
86
102
 
87
- const debugInfo = await contractStore.getPublicFunctionDebugMetadata(originalFailingFunction.contractAddress);
103
+ const debugInfo = await contractStore.getPublicFunctionDebugMetadata(classId);
88
104
 
89
105
  const noirCallStack = err.getNoirCallStack();
90
106
  if (debugInfo) {
@@ -102,6 +118,6 @@ export async function enrichPublicSimulationError(err: SimulationError, contract
102
118
  );
103
119
  }
104
120
  }
105
- await enrichSimulationError(err, contractStore, logger);
121
+ await enrichSimulationError(err, contractStore, contractClassService, anchorHeader, logger);
106
122
  }
107
123
  }
@@ -1,4 +1,5 @@
1
1
  import type { AuthorizeUtilityCall } from './authorize_utility_call.js';
2
+ import type { ResolveCustomRequest } from './resolve_custom_request.js';
2
3
  import type { ResolveTaggingSecretStrategy } from './resolve_tagging_secret_strategy.js';
3
4
 
4
5
  /**
@@ -28,8 +29,12 @@ import type { ResolveTaggingSecretStrategy } from './resolve_tagging_secret_stra
28
29
  * ? { authorized: true }
29
30
  * : { authorized: false, reason: 'Unknown target' };
30
31
  * },
31
- * // When there's no established way to reach the recipient, fall back to a non-interactive handshake.
32
- * resolveTaggingSecretStrategy: async () => ({ type: 'non-interactive-handshake' }),
32
+ * // Apply per-recipient policy: reach a known contact via their address keys (no onchain trace) and use a
33
+ * // non-interactive handshake for everyone else.
34
+ * resolveTaggingSecretStrategy: async ({ recipient }) =>
35
+ * knownContacts.has(recipient.toString())
36
+ * ? { type: 'address-derived' }
37
+ * : { type: 'non-interactive-handshake' },
33
38
  * },
34
39
  * });
35
40
  * ```
@@ -39,10 +44,16 @@ export interface ExecutionHooks {
39
44
  authorizeUtilityCall?: AuthorizeUtilityCall;
40
45
  /**
41
46
  * Resolves a message's tagging secret when none is already established for the sender/recipient pair, letting the
42
- * wallet apply per-recipient policy. PXE applies a privacy-safe default when absent.
47
+ * wallet apply per-recipient policy. PXE applies a default when absent.
43
48
  * See {@link ResolveTaggingSecretStrategy} for the request shape and defaults.
44
49
  */
45
50
  resolveTaggingSecretStrategy?: ResolveTaggingSecretStrategy;
51
+ /**
52
+ * Resolves a custom, caller-defined request a circuit cannot serve from local state. Any contract can issue one, so
53
+ * an implementor should verify both the request `kind` and the issuing contract (its address and class ID) before
54
+ * fulfilling it. Rejected when absent; see {@link ResolveCustomRequest}.
55
+ */
56
+ resolveCustomRequest?: ResolveCustomRequest;
46
57
  }
47
58
 
48
59
  /**
@@ -4,7 +4,9 @@ export type {
4
4
  UtilityCallAuthorizationResponse,
5
5
  } from './authorize_utility_call.js';
6
6
  export { type ExecutionHooks, composeHooks } from './execution_hooks.js';
7
+ export { type CustomRequest, type ResolveCustomRequest } from './resolve_custom_request.js';
7
8
  export {
9
+ DEFAULT_TAGGING_SECRET_STRATEGY,
8
10
  type ResolveTaggingSecretStrategy,
9
11
  type TaggingSecretStrategy,
10
12
  type TaggingSecretStrategyRequest,
@@ -0,0 +1,24 @@
1
+ import type { Fr } from '@aztec/foundation/curves/bn254';
2
+ import type { AztecAddress } from '@aztec/stdlib/aztec-address';
3
+
4
+ /**
5
+ * A custom, caller-defined request resolved via the {@link ResolveCustomRequest} hook. It carries no fixed meaning:
6
+ * `kind` selects the request type so one hook can serve many such types, and `payload` holds the opaque,
7
+ * request-specific arguments. The resolver answers by whatever means it needs (local state, a third party,
8
+ * offchain data).
9
+ */
10
+ export type CustomRequest = {
11
+ /** The address of the contract issuing the request. */
12
+ contractAddress: AztecAddress;
13
+ /** The issuing contract's class ID, so resolvers can apply class-level (not just per-address) policy. */
14
+ contractClassId: Fr;
15
+ /** Discriminates the request type, letting one hook serve many such types. */
16
+ kind: Fr;
17
+ /** Opaque, request-specific arguments. */
18
+ payload: Fr[];
19
+ };
20
+
21
+ /**
22
+ * Hook resolving a {@link CustomRequest}. The resolver produces the response however it needs to.
23
+ */
24
+ export type ResolveCustomRequest = (request: CustomRequest) => Promise<Fr[]>;
@@ -3,6 +3,9 @@ import type { Point } from '@aztec/foundation/curves/grumpkin';
3
3
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
4
4
  import type { AppTaggingSecretKind } from '@aztec/stdlib/logs';
5
5
 
6
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars -- only referenced by a {@link} doc tag
7
+ import type { ResolveCustomRequest } from './resolve_custom_request.js';
8
+
6
9
  /**
7
10
  * How a message's tagging secret is chosen: the wallet's strategy, returned by the `resolveTaggingSecretStrategy` hook
8
11
  * when no onchain handshake has been registered for the sender/recipient pair. This is intent (plus, for an arbitrary
@@ -13,6 +16,14 @@ export type TaggingSecretStrategy =
13
16
  /** Establish a fresh non-interactive handshake via the onchain registry; reveals the recipient onchain. */
14
17
  type: 'non-interactive-handshake';
15
18
  }
19
+ | {
20
+ /**
21
+ * Establish a fresh interactive handshake via the onchain registry. Reveals nothing about the recipient
22
+ * onchain, but requires the recipient to answer the registry's signed-authorization request (served through
23
+ * the {@link ResolveCustomRequest} hook), so the send fails when it cannot be served.
24
+ */
25
+ type: 'interactive-handshake';
26
+ }
16
27
  | {
17
28
  /** Derive the secret from the sender's and recipient's address keys via ECDH. PXE computes and silos it. */
18
29
  type: 'address-derived';
@@ -28,6 +39,9 @@ export type TaggingSecretStrategy =
28
39
  secret: Point;
29
40
  };
30
41
 
42
+ /** The strategy PXE applies to both delivery modes when no `resolveTaggingSecretStrategy` hook is configured. */
43
+ export const DEFAULT_TAGGING_SECRET_STRATEGY: TaggingSecretStrategy = { type: 'non-interactive-handshake' };
44
+
31
45
  /** Information about the message delivery requesting a tagging secret strategy. */
32
46
  export type TaggingSecretStrategyRequest = {
33
47
  contractAddress: AztecAddress;
@@ -9,8 +9,8 @@ import type { CompleteAddress } from '@aztec/stdlib/contract';
9
9
  import type { AztecNode } from '@aztec/stdlib/interfaces/server';
10
10
  import {
11
11
  AppTaggingSecret,
12
+ AppTaggingSecretKind,
12
13
  type LogResult,
13
- type PendingTaggedLog,
14
14
  SiloedTag,
15
15
  computeSharedTaggingSecret,
16
16
  } from '@aztec/stdlib/logs';
@@ -21,6 +21,8 @@ import {
21
21
  LogSource,
22
22
  } from '../contract_function_simulator/noir-structs/log_retrieval_request.js';
23
23
  import type { LogRetrievalResponse } from '../contract_function_simulator/noir-structs/log_retrieval_response.js';
24
+ import type { PendingTaggedLog } from '../contract_function_simulator/noir-structs/pending_tagged_log.js';
25
+ import { ResolvedTx } from '../contract_function_simulator/noir-structs/resolved_tx.js';
24
26
  import { AddressStore } from '../storage/address_store/address_store.js';
25
27
  import type { RecipientTaggingStore } from '../storage/tagging_store/recipient_tagging_store.js';
26
28
  import type { TaggingSecretSourcesStore } from '../storage/tagging_store/tagging_secret_sources_store.js';
@@ -176,6 +178,9 @@ export class LogService {
176
178
  txHash: log.txHash,
177
179
  uniqueNoteHashesInTx: noteHashes,
178
180
  firstNullifierInTx: nullifiers[0],
181
+ blockNumber: log.blockNumber,
182
+ blockTimestamp: log.blockTimestamp,
183
+ blockHash: log.blockHash,
179
184
  };
180
185
  }
181
186
 
@@ -216,17 +221,17 @@ export class LogService {
216
221
  }
217
222
  return {
218
223
  log: log.logData,
219
- context: { txHash: log.txHash, uniqueNoteHashesInTx: noteHashes, firstNullifierInTx: nullifiers[0] },
224
+ context: new ResolvedTx(log.txHash, noteHashes, nullifiers[0], log.blockNumber, log.blockHash.toFr()),
220
225
  };
221
226
  });
222
227
  }
223
228
 
224
229
  /**
225
230
  * Computes the tagging secrets PXE can enumerate for a recipient: one per known sender (via ECDH) plus any
226
- * pre-shared secret points registered directly for the recipient, each siloed to `contractAddress` and directed to
227
- * `recipient`. These require knowing the recipient's address preimage and keys, so returns an empty array when those
228
- * are unavailable. App-supplied secrets (e.g. handshake-derived) are handled separately by the caller and do not go
229
- * through here.
231
+ * pre-shared secrets registered directly for the recipient. Each registered secret is scanned under the tag
232
+ * streams its kind can back. Deriving the sender-based secrets requires the recipient's address preimage and keys,
233
+ * so returns an empty array when those are unavailable. App-supplied secrets (e.g. derived from discovered
234
+ * handshakes) are handled separately by the caller and do not go through here.
230
235
  */
231
236
  async #getPointDerivedSecrets(contractAddress: AztecAddress, recipient: AztecAddress): Promise<AppTaggingSecret[]> {
232
237
  const recipientCompleteAddress = await this.addressStore.getCompleteAddress(recipient);
@@ -238,11 +243,26 @@ export class LogService {
238
243
  }
239
244
  const recipientIvsk = await this.keyStore.getMasterIncomingViewingSecretKey(recipient);
240
245
 
241
- const points = [
242
- ...(await this.#getSecretsForSenders(recipientCompleteAddress, recipientIvsk)),
243
- ...(await this.taggingSecretSourcesStore.getSharedSecretsForRecipient(recipient)),
244
- ];
245
- return Promise.all(points.map(secret => AppTaggingSecret.compute(secret, contractAddress, recipient)));
246
+ const [senderPoints, registeredSecrets] = await Promise.all([
247
+ this.#getSecretsForSenders(recipientCompleteAddress, recipientIvsk),
248
+ this.taggingSecretSourcesStore.getSharedSecretsForRecipient(recipient),
249
+ ]);
250
+ return Promise.all([
251
+ ...senderPoints.map(secret => AppTaggingSecret.computeDirectional(secret, contractAddress, recipient)),
252
+ ...registeredSecrets.flatMap(({ kind, secret }) => {
253
+ switch (kind) {
254
+ case 'arbitrary-secret':
255
+ return [AppTaggingSecret.computeDirectional(secret, contractAddress, recipient)];
256
+ case 'handshake':
257
+ // A handshake-backed sender tags messages with the bare app-siloed secret, one tag domain per delivery
258
+ // mode.
259
+ return [
260
+ AppTaggingSecret.computeAppSiloed(secret, contractAddress, AppTaggingSecretKind.UNCONSTRAINED),
261
+ AppTaggingSecret.computeAppSiloed(secret, contractAddress, AppTaggingSecretKind.CONSTRAINED),
262
+ ];
263
+ }
264
+ }),
265
+ ]);
246
266
  }
247
267
 
248
268
  async #getSecretsForSenders(
@@ -11,7 +11,7 @@
11
11
  /// if AZTEC_NR_MINOR > PXE_MINOR because if a contract is updated to use a newer Aztec.nr dependency without actually
12
12
  /// using any of the new oracles then there is no reason to throw.
13
13
  export const ORACLE_VERSION_MAJOR = 30;
14
- export const ORACLE_VERSION_MINOR = 1;
14
+ export const ORACLE_VERSION_MINOR = 7;
15
15
 
16
16
  /// This hash is computed from the `ORACLE_REGISTRY` declaration (each oracle's name, ordered parameter names and
17
17
  /// types, and return type) and is used to detect when the oracle interface changes. When it does, you need to either:
@@ -19,4 +19,4 @@ export const ORACLE_VERSION_MINOR = 1;
19
19
  /// - increment only `ORACLE_VERSION_MINOR` if the change is additive (a new oracle was added).
20
20
  ///
21
21
  /// These constants must be kept in sync between this file and `noir-projects/aztec-nr/aztec/src/oracle/version.nr`.
22
- export const ORACLE_INTERFACE_HASH = '2a441f29ab01b252bc74b91b07fc2514891c28bffdfa0042d80494271b75edee';
22
+ export const ORACLE_INTERFACE_HASH = '416b0e7d3e6dca5803ebe2a65ea93f1e79759dc39ef8ec4c52eeba5e2b0f3fca';
@@ -35,6 +35,7 @@ import {
35
35
  findPrivateKernelResetDimensions,
36
36
  getNoteHashReadRequestResetActions,
37
37
  getNullifierReadRequestResetActions,
38
+ kernelStateIsForPublic,
38
39
  privateKernelResetDimensionNames,
39
40
  } from '@aztec/stdlib/kernel';
40
41
  import { type PrivateCallExecutionResult, collectNested } from '@aztec/stdlib/tx';
@@ -138,10 +139,19 @@ export class PrivateKernelResetPrivateInputsBuilder {
138
139
  // The dimensions found must be big enough to reset all values, i.e. empty remainder.
139
140
  const allowRemainder = isInner;
140
141
 
142
+ // Terminal reset picks from the finalTail / finalTailToPublic catalogs; mid-tx resets always
143
+ // use the inner catalog. The public/private decision must match `kernelStateIsForPublic` - the
144
+ // same predicate the circuit inputs and the orchestrator use.
145
+ const mode = isInner
146
+ ? ('inner' as const)
147
+ : kernelStateIsForPublic(this.previousKernel)
148
+ ? ('finalTailToPublic' as const)
149
+ : ('finalTail' as const);
150
+
141
151
  const dimensions = findPrivateKernelResetDimensions(
142
152
  this.requestedDimensions,
143
153
  privateKernelResetDimensionsConfig,
144
- isInner,
154
+ mode,
145
155
  allowRemainder,
146
156
  );
147
157
 
@@ -24,8 +24,8 @@ import {
24
24
  PrivateKernelInner2CircuitPrivateInputs,
25
25
  PrivateKernelInner3CircuitPrivateInputs,
26
26
  PrivateKernelInnerCircuitPrivateInputs,
27
+ PrivateKernelResetTailCircuitPrivateInputs,
27
28
  type PrivateKernelSimulateOutput,
28
- PrivateKernelTailCircuitPrivateInputs,
29
29
  type PrivateKernelTailCircuitPublicInputs,
30
30
  PrivateVerificationKeyHints,
31
31
  type UpdatedClassIdHints,
@@ -170,7 +170,6 @@ export class PrivateKernelExecutionProver {
170
170
  previousOutput: output,
171
171
  txRequest,
172
172
  isPrivateOnlyTx,
173
- firstNullifierHint: executionResult.firstNullifier,
174
173
  minRevertibleSideEffectCounter,
175
174
  executionSteps,
176
175
  generateWitnesses,
@@ -179,7 +178,8 @@ export class PrivateKernelExecutionProver {
179
178
  firstIteration = false;
180
179
  }
181
180
 
182
- // Final reset: include siloing of note hashes, nullifiers and private logs.
181
+ // Terminal reset+tail. The final reset must be performed exactly once because each tx has at
182
+ // least one nullifier that requires siloing, and siloing cannot be done multiple times.
183
183
  const finalResetBuilder = new PrivateKernelResetPrivateInputsBuilder(
184
184
  output,
185
185
  [],
@@ -187,29 +187,9 @@ export class PrivateKernelExecutionProver {
187
187
  splitCounter,
188
188
  );
189
189
  if (!finalResetBuilder.needsReset()) {
190
- // The final reset must be performed exactly once, because each tx has at least one nullifier that requires
191
- // siloing, and siloing cannot be done multiple times.
192
- // While, in theory, it might be possible to silo note hashes first and then run another reset to silo nullifiers
193
- // and/or private logs, we currently don't have standalone dimensions for the arrays that require siloing. As a
194
- // result, all necessary siloing must be done together in a single reset.
190
+ // Siloing for note hashes, nullifiers, and private logs is dimensioned as one terminal reset.
195
191
  // Refer to the possible combinations of dimensions in private_kernel_reset_config.json.
196
192
  throw new Error('Nothing to reset for the final reset.');
197
- } else {
198
- const witgenTimer = new Timer();
199
- const privateInputs = await finalResetBuilder.build(this.oracle);
200
- output = generateWitnesses
201
- ? await this.proofCreator.generateResetOutput(privateInputs)
202
- : await this.proofCreator.simulateReset(privateInputs);
203
-
204
- executionSteps.push({
205
- functionName: 'private_kernel_reset',
206
- bytecode: output.bytecode,
207
- witness: output.outputWitness,
208
- vk: output.verificationKey.keyAsBytes,
209
- timings: {
210
- witgen: witgenTimer.ms(),
211
- },
212
- });
213
193
  }
214
194
 
215
195
  if (output.publicInputs.feePayer.isZero() && skipFeeEnforcement) {
@@ -218,34 +198,35 @@ export class PrivateKernelExecutionProver {
218
198
  }
219
199
  output.publicInputs.feePayer = new AztecAddress(Fr.MAX_FIELD_VALUE);
220
200
  }
221
- // Private tail.
222
- const vkData = await this.getVkData(output.verificationKey);
223
- const previousKernelData = new PrivateKernelData(output.publicInputs, vkData);
224
-
225
- this.log.debug(
226
- `Calling private kernel tail with hwm ${previousKernelData.publicInputs.minRevertibleSideEffectCounter}`,
227
- );
228
201
 
229
202
  // TODO: Enable padding once we better understand the final amounts to pad to.
230
203
  const paddedSideEffectAmounts = PaddedSideEffectAmounts.empty();
231
204
 
232
205
  // Round the aggregated expirationTimestamp down to reduce precision and avoid leaking which private
233
206
  // functions were called via their exact expiration offsets.
234
- const expirationTimestampUpperBound = computeTxExpirationTimestamp(previousKernelData.publicInputs);
235
-
236
- const privateInputs = new PrivateKernelTailCircuitPrivateInputs(
237
- previousKernelData,
207
+ const expirationTimestampUpperBound = computeTxExpirationTimestamp(output.publicInputs);
208
+
209
+ const resetInputs = await finalResetBuilder.build(this.oracle);
210
+ const mergedInputs = new PrivateKernelResetTailCircuitPrivateInputs(
211
+ resetInputs.previousKernel,
212
+ resetInputs.paddedSideEffects,
213
+ resetInputs.hints,
214
+ resetInputs.dimensions,
238
215
  paddedSideEffectAmounts,
239
216
  expirationTimestampUpperBound,
240
217
  );
241
218
 
219
+ this.log.debug(
220
+ `Calling terminal private kernel reset+tail (${mergedInputs.isForPublic() ? 'to-public' : 'to-rollup'}) with hwm ${output.publicInputs.minRevertibleSideEffectCounter}`,
221
+ );
222
+
242
223
  const witgenTimer = new Timer();
243
224
  const tailOutput = generateWitnesses
244
- ? await this.proofCreator.generateTailOutput(privateInputs)
245
- : await this.proofCreator.simulateTail(privateInputs);
225
+ ? await this.proofCreator.generateResetTailOutput(mergedInputs)
226
+ : await this.proofCreator.simulateResetTail(mergedInputs);
246
227
 
247
228
  executionSteps.push({
248
- functionName: 'private_kernel_tail',
229
+ functionName: mergedInputs.isForPublic() ? 'private_kernel_reset_tail_to_public' : 'private_kernel_reset_tail',
249
230
  bytecode: tailOutput.bytecode,
250
231
  witness: tailOutput.outputWitness,
251
232
  vk: tailOutput.verificationKey.keyAsBytes,
@@ -457,7 +438,6 @@ export class PrivateKernelExecutionProver {
457
438
  previousOutput: PrivateKernelSimulateOutput<PrivateKernelCircuitPublicInputs>;
458
439
  txRequest: TxRequest;
459
440
  isPrivateOnlyTx: boolean;
460
- firstNullifierHint: Fr;
461
441
  minRevertibleSideEffectCounter: number;
462
442
  executionSteps: PrivateExecutionStep[];
463
443
  generateWitnesses: boolean;
@@ -468,7 +448,6 @@ export class PrivateKernelExecutionProver {
468
448
  previousOutput,
469
449
  txRequest,
470
450
  isPrivateOnlyTx,
471
- firstNullifierHint,
472
451
  minRevertibleSideEffectCounter,
473
452
  executionSteps,
474
453
  generateWitnesses,
@@ -488,12 +467,9 @@ export class PrivateKernelExecutionProver {
488
467
  ProtocolContractsList,
489
468
  apps[0],
490
469
  isPrivateOnlyTx,
491
- firstNullifierHint,
492
470
  minRevertibleSideEffectCounter,
493
471
  );
494
- this.log.debug(
495
- `Calling private kernel init with isPrivateOnly ${isPrivateOnlyTx} and firstNullifierHint ${proofInput.firstNullifierHint}`,
496
- );
472
+ this.log.debug(`Calling private kernel init with isPrivateOnly ${isPrivateOnlyTx}`);
497
473
  pushTestData('private-kernel-inputs-init', proofInput);
498
474
  output = generateWitnesses
499
475
  ? await this.proofCreator.generateInitOutput(proofInput)
@@ -509,12 +485,9 @@ export class PrivateKernelExecutionProver {
509
485
  apps[0],
510
486
  apps[1],
511
487
  isPrivateOnlyTx,
512
- firstNullifierHint,
513
488
  minRevertibleSideEffectCounter,
514
489
  );
515
- this.log.debug(
516
- `Calling private kernel init_2 with isPrivateOnly ${isPrivateOnlyTx} and firstNullifierHint ${proofInput.firstNullifierHint}`,
517
- );
490
+ this.log.debug(`Calling private kernel init_2 with isPrivateOnly ${isPrivateOnlyTx}`);
518
491
  pushTestData('private-kernel-inputs-init-2', proofInput);
519
492
  output = generateWitnesses
520
493
  ? await this.proofCreator.generateInit2Output(proofInput)
@@ -531,12 +504,9 @@ export class PrivateKernelExecutionProver {
531
504
  apps[1],
532
505
  apps[2],
533
506
  isPrivateOnlyTx,
534
- firstNullifierHint,
535
507
  minRevertibleSideEffectCounter,
536
508
  );
537
- this.log.debug(
538
- `Calling private kernel init_3 with isPrivateOnly ${isPrivateOnlyTx} and firstNullifierHint ${proofInput.firstNullifierHint}`,
539
- );
509
+ this.log.debug(`Calling private kernel init_3 with isPrivateOnly ${isPrivateOnlyTx}`);
540
510
  pushTestData('private-kernel-inputs-init-3', proofInput);
541
511
  output = generateWitnesses
542
512
  ? await this.proofCreator.generateInit3Output(proofInput)
@@ -22,30 +22,45 @@ import type { NullifierMembershipWitness } from '@aztec/stdlib/trees';
22
22
  import type { BlockHeader } from '@aztec/stdlib/tx';
23
23
  import type { VerificationKeyAsFields } from '@aztec/stdlib/vks';
24
24
 
25
+ import type { ContractClassService } from '../contract/contract_class_service.js';
26
+ import { AnchoredContractData } from '../contract_function_simulator/anchored_contract_data.js';
25
27
  import type { ContractStore } from '../storage/contract_store/contract_store.js';
26
28
 
27
29
  /**
28
30
  * Provides functionality needed by the private kernel for interacting with our state trees.
29
31
  */
30
32
  export class PrivateKernelOracle {
33
+ private readonly anchoredContractData: AnchoredContractData;
34
+
31
35
  constructor(
32
36
  private contractStore: ContractStore,
37
+ contractClassService: ContractClassService,
33
38
  private keyStore: KeyStore,
34
39
  private node: AztecNode,
35
40
  private blockHeader: BlockHeader,
36
- ) {}
41
+ ) {
42
+ // Kernels never use contract overrides (those are confined to simulations, which skip proving), so this view is
43
+ // built without them.
44
+ this.anchoredContractData = new AnchoredContractData(contractStore, contractClassService, blockHeader);
45
+ }
37
46
 
38
47
  /** Retrieves the preimage of a contract address from the registered contract instances db. */
39
48
  public async getContractAddressPreimage(
40
49
  address: AztecAddress,
41
50
  ): Promise<ContractInstanceWithAddress & { saltedInitializationHash: Fr }> {
42
- const instance = await this.contractStore.getContractInstance(address);
51
+ const instance = await this.anchoredContractData.getContractInstance(address);
43
52
  if (!instance) {
44
53
  throw new Error(`Contract instance not found when getting address preimage. Contract address: ${address}.`);
45
54
  }
55
+ // Local instance existence was checked above, so resolution below cannot come back empty.
56
+ const currentContractClassId = await this.anchoredContractData.getCurrentClassId(address);
57
+ if (!currentContractClassId) {
58
+ throw new Error(`Could not resolve the current class id for registered contract ${address}.`);
59
+ }
46
60
  return {
47
61
  saltedInitializationHash: await computeSaltedInitializationHash(instance),
48
62
  ...instance,
63
+ currentContractClassId,
49
64
  };
50
65
  }
51
66
 
@@ -114,8 +129,12 @@ export class PrivateKernelOracle {
114
129
  }
115
130
 
116
131
  /** Use debug data to get the function name corresponding to a selector. */
117
- public getDebugFunctionName(contractAddress: AztecAddress, selector: FunctionSelector): Promise<string | undefined> {
118
- return this.contractStore.getDebugFunctionName(contractAddress, selector);
132
+ public async getDebugFunctionName(
133
+ contractAddress: AztecAddress,
134
+ selector: FunctionSelector,
135
+ ): Promise<string | undefined> {
136
+ const classId = await this.anchoredContractData.getCurrentClassId(contractAddress);
137
+ return classId ? this.contractStore.getDebugFunctionName(classId, selector) : undefined;
119
138
  }
120
139
 
121
140
  /**