@aztec/pxe 0.0.1-commit.b8a057fa → 0.0.1-commit.be03c316

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 (167) hide show
  1. package/dest/bin/check_oracle_version.js +3 -8
  2. package/dest/bin/index.d.ts +2 -2
  3. package/dest/bin/index.d.ts.map +1 -1
  4. package/dest/bin/index.js +1 -1
  5. package/dest/bin/oracle_version_helpers.d.ts +8 -25
  6. package/dest/bin/oracle_version_helpers.d.ts.map +1 -1
  7. package/dest/bin/oracle_version_helpers.js +11 -219
  8. package/dest/contract/helpers.d.ts +1 -1
  9. package/dest/contract/helpers.d.ts.map +1 -1
  10. package/dest/contract/helpers.js +3 -3
  11. package/dest/contract/skip_sync_contracts.d.ts +11 -0
  12. package/dest/contract/skip_sync_contracts.d.ts.map +1 -0
  13. package/dest/contract/skip_sync_contracts.js +18 -0
  14. package/dest/contract_function_simulator/aztec_node_read_cache.d.ts +39 -0
  15. package/dest/contract_function_simulator/aztec_node_read_cache.d.ts.map +1 -0
  16. package/dest/contract_function_simulator/aztec_node_read_cache.js +60 -0
  17. package/dest/contract_function_simulator/index.d.ts +3 -3
  18. package/dest/contract_function_simulator/index.d.ts.map +1 -1
  19. package/dest/contract_function_simulator/index.js +1 -2
  20. package/dest/contract_function_simulator/noir-structs/resolved_tagging_strategy.d.ts +1 -1
  21. package/dest/contract_function_simulator/noir-structs/resolved_tagging_strategy.d.ts.map +1 -1
  22. package/dest/contract_function_simulator/noir-structs/resolved_tagging_strategy.js +7 -0
  23. package/dest/contract_function_simulator/noir-structs/resolved_tx.d.ts +7 -9
  24. package/dest/contract_function_simulator/noir-structs/resolved_tx.d.ts.map +1 -1
  25. package/dest/contract_function_simulator/noir-structs/resolved_tx.js +3 -44
  26. package/dest/contract_function_simulator/noir-structs/tx_effect_data.d.ts +5 -4
  27. package/dest/contract_function_simulator/noir-structs/tx_effect_data.d.ts.map +1 -1
  28. package/dest/contract_function_simulator/noir-structs/tx_effect_data.js +2 -2
  29. package/dest/contract_function_simulator/oracle/acir_callback.js +1 -1
  30. package/dest/contract_function_simulator/oracle/legacy_oracle_registry.d.ts +3 -3
  31. package/dest/contract_function_simulator/oracle/legacy_oracle_registry.d.ts.map +1 -1
  32. package/dest/contract_function_simulator/oracle/legacy_oracle_registry.js +34 -1
  33. package/dest/contract_function_simulator/oracle/oracle_registry.d.ts +7 -4
  34. package/dest/contract_function_simulator/oracle/oracle_registry.d.ts.map +1 -1
  35. package/dest/contract_function_simulator/oracle/oracle_registry.js +40 -13
  36. package/dest/contract_function_simulator/oracle/oracle_type_mappings.d.ts +87 -35
  37. package/dest/contract_function_simulator/oracle/oracle_type_mappings.d.ts.map +1 -1
  38. package/dest/contract_function_simulator/oracle/oracle_type_mappings.js +286 -286
  39. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +1 -1
  40. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
  41. package/dest/contract_function_simulator/oracle/private_execution_oracle.js +7 -10
  42. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +14 -8
  43. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
  44. package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +61 -34
  45. package/dest/entrypoints/client/bundle/index.d.ts +2 -1
  46. package/dest/entrypoints/client/bundle/index.d.ts.map +1 -1
  47. package/dest/entrypoints/client/bundle/index.js +1 -0
  48. package/dest/entrypoints/client/bundle/utils.d.ts +1 -1
  49. package/dest/entrypoints/client/bundle/utils.d.ts.map +1 -1
  50. package/dest/entrypoints/client/bundle/utils.js +10 -4
  51. package/dest/entrypoints/client/lazy/index.d.ts +2 -1
  52. package/dest/entrypoints/client/lazy/index.d.ts.map +1 -1
  53. package/dest/entrypoints/client/lazy/index.js +1 -0
  54. package/dest/entrypoints/client/lazy/utils.d.ts +1 -1
  55. package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
  56. package/dest/entrypoints/client/lazy/utils.js +10 -4
  57. package/dest/entrypoints/client/store.d.ts +14 -0
  58. package/dest/entrypoints/client/store.d.ts.map +1 -0
  59. package/dest/entrypoints/client/store.js +42 -0
  60. package/dest/entrypoints/server/index.d.ts +2 -1
  61. package/dest/entrypoints/server/index.d.ts.map +1 -1
  62. package/dest/entrypoints/server/index.js +1 -0
  63. package/dest/entrypoints/server/store.d.ts +18 -0
  64. package/dest/entrypoints/server/store.d.ts.map +1 -0
  65. package/dest/entrypoints/server/store.js +28 -0
  66. package/dest/entrypoints/server/utils.d.ts +1 -1
  67. package/dest/entrypoints/server/utils.d.ts.map +1 -1
  68. package/dest/entrypoints/server/utils.js +8 -2
  69. package/dest/hooks/index.d.ts +2 -2
  70. package/dest/hooks/index.d.ts.map +1 -1
  71. package/dest/hooks/index.js +1 -0
  72. package/dest/hooks/resolve_tagging_secret_strategy.d.ts +3 -1
  73. package/dest/hooks/resolve_tagging_secret_strategy.d.ts.map +1 -1
  74. package/dest/hooks/resolve_tagging_secret_strategy.js +3 -3
  75. package/dest/logs/log_service.d.ts +3 -2
  76. package/dest/logs/log_service.d.ts.map +1 -1
  77. package/dest/logs/log_service.js +12 -3
  78. package/dest/messages/tx_resolver_service.d.ts +2 -2
  79. package/dest/messages/tx_resolver_service.d.ts.map +1 -1
  80. package/dest/messages/tx_resolver_service.js +7 -2
  81. package/dest/notes/note_service.d.ts +1 -1
  82. package/dest/notes/note_service.js +1 -1
  83. package/dest/oracle_version.d.ts +2 -2
  84. package/dest/oracle_version.js +3 -3
  85. package/dest/pxe.d.ts +1 -1
  86. package/dest/pxe.d.ts.map +1 -1
  87. package/dest/pxe.js +8 -5
  88. package/dest/storage/backwards_compatibility_tests/schema_tests.d.ts +1 -1
  89. package/dest/storage/backwards_compatibility_tests/schema_tests.d.ts.map +1 -1
  90. package/dest/storage/backwards_compatibility_tests/schema_tests.js +26 -2
  91. package/dest/storage/fact_store/index.d.ts +2 -2
  92. package/dest/storage/fact_store/index.d.ts.map +1 -1
  93. package/dest/storage/fact_store/index.js +1 -1
  94. package/dest/storage/fact_store/origin_state.d.ts +3 -1
  95. package/dest/storage/fact_store/origin_state.d.ts.map +1 -1
  96. package/dest/storage/fact_store/origin_state.js +7 -0
  97. package/dest/storage/metadata.d.ts +1 -1
  98. package/dest/storage/metadata.js +1 -1
  99. package/dest/storage/store_identity.d.ts +35 -0
  100. package/dest/storage/store_identity.d.ts.map +1 -0
  101. package/dest/storage/store_identity.js +44 -0
  102. package/dest/storage/tagging_store/sender_tagging_store.d.ts +19 -3
  103. package/dest/storage/tagging_store/sender_tagging_store.d.ts.map +1 -1
  104. package/dest/storage/tagging_store/sender_tagging_store.js +48 -11
  105. package/dest/tagging/constants.d.ts +3 -2
  106. package/dest/tagging/constants.d.ts.map +1 -1
  107. package/dest/tagging/constants.js +26 -5
  108. package/dest/tagging/index.d.ts +2 -2
  109. package/dest/tagging/index.d.ts.map +1 -1
  110. package/dest/tagging/index.js +1 -1
  111. package/dest/tagging/recipient_sync/sync_tagged_private_logs.d.ts +9 -4
  112. package/dest/tagging/recipient_sync/sync_tagged_private_logs.d.ts.map +1 -1
  113. package/dest/tagging/recipient_sync/sync_tagged_private_logs.js +60 -25
  114. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.js +1 -1
  115. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts +1 -1
  116. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts.map +1 -1
  117. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.js +6 -2
  118. package/dest/tagging/testing/tag_query_test_utils.d.ts +6 -0
  119. package/dest/tagging/testing/tag_query_test_utils.d.ts.map +1 -0
  120. package/dest/tagging/testing/tag_query_test_utils.js +10 -0
  121. package/package.json +17 -17
  122. package/src/bin/check_oracle_version.ts +3 -10
  123. package/src/bin/index.ts +1 -5
  124. package/src/bin/oracle_version_helpers.ts +11 -268
  125. package/src/contract/helpers.ts +3 -3
  126. package/src/contract/skip_sync_contracts.ts +23 -0
  127. package/src/contract_function_simulator/aztec_node_read_cache.ts +89 -0
  128. package/src/contract_function_simulator/index.ts +23 -3
  129. package/src/contract_function_simulator/noir-structs/resolved_tagging_strategy.ts +8 -0
  130. package/src/contract_function_simulator/noir-structs/resolved_tx.ts +11 -45
  131. package/src/contract_function_simulator/noir-structs/tx_effect_data.ts +4 -3
  132. package/src/contract_function_simulator/oracle/acir_callback.ts +1 -1
  133. package/src/contract_function_simulator/oracle/legacy_oracle_registry.ts +30 -3
  134. package/src/contract_function_simulator/oracle/oracle_registry.ts +32 -11
  135. package/src/contract_function_simulator/oracle/oracle_type_mappings.ts +285 -197
  136. package/src/contract_function_simulator/oracle/private_execution_oracle.ts +17 -12
  137. package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +92 -39
  138. package/src/entrypoints/client/bundle/index.ts +1 -0
  139. package/src/entrypoints/client/bundle/utils.ts +15 -3
  140. package/src/entrypoints/client/lazy/index.ts +1 -0
  141. package/src/entrypoints/client/lazy/utils.ts +15 -3
  142. package/src/entrypoints/client/store.ts +54 -0
  143. package/src/entrypoints/server/index.ts +1 -0
  144. package/src/entrypoints/server/store.ts +47 -0
  145. package/src/entrypoints/server/utils.ts +21 -7
  146. package/src/hooks/index.ts +1 -0
  147. package/src/hooks/resolve_tagging_secret_strategy.ts +3 -0
  148. package/src/logs/log_service.ts +11 -2
  149. package/src/messages/tx_resolver_service.ts +8 -8
  150. package/src/notes/note_service.ts +1 -1
  151. package/src/oracle_version.ts +3 -3
  152. package/src/pxe.ts +8 -5
  153. package/src/storage/backwards_compatibility_tests/__snapshots__/RecipientTaggingStore.json +11 -3
  154. package/src/storage/backwards_compatibility_tests/__snapshots__/SenderTaggingStore.json +12 -4
  155. package/src/storage/backwards_compatibility_tests/__snapshots__/opened_stores.json +1 -1
  156. package/src/storage/backwards_compatibility_tests/schema_tests.ts +30 -1
  157. package/src/storage/fact_store/index.ts +1 -0
  158. package/src/storage/fact_store/origin_state.ts +9 -0
  159. package/src/storage/metadata.ts +1 -1
  160. package/src/storage/store_identity.ts +72 -0
  161. package/src/storage/tagging_store/sender_tagging_store.ts +62 -15
  162. package/src/tagging/constants.ts +27 -5
  163. package/src/tagging/index.ts +1 -1
  164. package/src/tagging/recipient_sync/sync_tagged_private_logs.ts +103 -46
  165. package/src/tagging/sender_sync/sync_sender_tagging_indexes.ts +1 -1
  166. package/src/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.ts +6 -2
  167. package/src/tagging/testing/tag_query_test_utils.ts +11 -0
@@ -0,0 +1,23 @@
1
+ import { ProtocolContractAddress } from '@aztec/protocol-contracts';
2
+ import { STANDARD_AUTH_REGISTRY_ADDRESS } from '@aztec/standard-contracts/auth-registry/constants';
3
+ import { STANDARD_MULTI_CALL_ENTRYPOINT_ADDRESS } from '@aztec/standard-contracts/multi-call-entrypoint/constants';
4
+ import { STANDARD_PUBLIC_CHECKS_ADDRESS } from '@aztec/standard-contracts/public-checks/constants';
5
+ import type { AztecAddress } from '@aztec/stdlib/aztec-address';
6
+
7
+ /**
8
+ * Canonical contracts that hold no private state and are therefore never synced.
9
+ *
10
+ * The protocol contracts (registries, fee juice) plus the standard AuthRegistry, MultiCallEntrypoint and PublicChecks
11
+ * declare no notes and no events, so their macro-generated `sync_state` has nothing to discover.
12
+ */
13
+ export const skipSyncContracts: AztecAddress[] = [
14
+ ...Object.values(ProtocolContractAddress),
15
+ STANDARD_AUTH_REGISTRY_ADDRESS,
16
+ STANDARD_MULTI_CALL_ENTRYPOINT_ADDRESS,
17
+ STANDARD_PUBLIC_CHECKS_ADDRESS,
18
+ ];
19
+
20
+ /** Returns whether the given contract should be skipped during private state synchronization. */
21
+ export function isSkipSyncContract(address: AztecAddress): boolean {
22
+ return skipSyncContracts.some(a => a.equals(address));
23
+ }
@@ -0,0 +1,89 @@
1
+ import { Fr } from '@aztec/foundation/curves/bn254';
2
+ import type { AztecAddress } from '@aztec/stdlib/aztec-address';
3
+ import type { BlockHash, BlockParameter } from '@aztec/stdlib/block';
4
+ import type { AztecNode } from '@aztec/stdlib/interfaces/server';
5
+ import type { TxHash } from '@aztec/stdlib/tx';
6
+
7
+ /**
8
+ * Per-execution cache for immutable Aztec node reads.
9
+ */
10
+ export class AztecNodeReadCache {
11
+ private readonly cache = new Map<string, Promise<unknown>>();
12
+
13
+ constructor(private readonly aztecNode: AztecNode) {}
14
+
15
+ /** Fetches a block without reissuing the same node request. */
16
+ public getBlock(block: BlockParameter) {
17
+ return this.#cachedRead(`block:${this.#keyPart(block)}`, () => this.aztecNode.getBlock(block));
18
+ }
19
+
20
+ /** Fetches a transaction receipt with its effect attached. */
21
+ public getTxReceiptWithEffect(txHash: TxHash) {
22
+ return this.#cachedRead(`tx-receipt-with-effect:${txHash.toString()}`, () =>
23
+ this.aztecNode.getTxReceipt(txHash, { includeTxEffect: true } as const),
24
+ );
25
+ }
26
+
27
+ /** Fetches an archive-tree witness for a block hash. */
28
+ public getBlockHashMembershipWitness(referenceBlock: BlockParameter, blockHash: BlockHash) {
29
+ return this.#cachedRead(
30
+ `block-hash-membership-witness:${this.#keyPart(referenceBlock)}:${blockHash.toString()}`,
31
+ () => this.aztecNode.getBlockHashMembershipWitness(referenceBlock, blockHash),
32
+ );
33
+ }
34
+
35
+ /** Fetches a public-data-tree witness for a leaf slot. */
36
+ public getPublicDataWitness(referenceBlock: BlockParameter, leafSlot: Fr) {
37
+ return this.#cachedRead(`public-data-witness:${this.#keyPart(referenceBlock)}:${leafSlot.toString()}`, () =>
38
+ this.aztecNode.getPublicDataWitness(referenceBlock, leafSlot),
39
+ );
40
+ }
41
+
42
+ /** Fetches public storage for a single slot. */
43
+ public getPublicStorageAt(referenceBlock: BlockParameter, contractAddress: AztecAddress, storageSlot: Fr) {
44
+ return this.#cachedRead(
45
+ `public-storage:${this.#keyPart(referenceBlock)}:${contractAddress.toString()}:${storageSlot.toString()}`,
46
+ () => this.aztecNode.getPublicStorageAt(referenceBlock, contractAddress, storageSlot),
47
+ );
48
+ }
49
+
50
+ /** Fetches a contiguous public storage range, reusing cached reads for overlapping slots. */
51
+ public getPublicStorageRange(
52
+ referenceBlock: BlockParameter,
53
+ contractAddress: AztecAddress,
54
+ startStorageSlot: Fr,
55
+ numberOfElements: number,
56
+ ) {
57
+ const slots = Array(numberOfElements)
58
+ .fill(0)
59
+ .map((_, i) => new Fr(startStorageSlot.value + BigInt(i)));
60
+
61
+ return Promise.all(slots.map(storageSlot => this.getPublicStorageAt(referenceBlock, contractAddress, storageSlot)));
62
+ }
63
+
64
+ #cachedRead<T>(key: string, fetch: () => Promise<T>): Promise<T> {
65
+ const cached = this.cache.get(key);
66
+ if (cached) {
67
+ return cached as Promise<T>;
68
+ }
69
+
70
+ const promise = fetch();
71
+ promise.catch(() => this.cache.delete(key));
72
+ this.cache.set(key, promise);
73
+ return promise;
74
+ }
75
+
76
+ #keyPart(value: unknown): string {
77
+ if (['string', 'number', 'bigint', 'boolean'].includes(typeof value)) {
78
+ return String(value);
79
+ }
80
+ if (value && typeof value === 'object') {
81
+ const toString = (value as { toString?: () => string }).toString;
82
+ if (toString && toString !== Object.prototype.toString) {
83
+ return toString.call(value);
84
+ }
85
+ return JSON.stringify(value, (_key, nested) => (typeof nested === 'bigint' ? nested.toString() : nested));
86
+ }
87
+ return String(value);
88
+ }
89
+ }
@@ -6,6 +6,7 @@ export {
6
6
  type ParamTypes,
7
7
  } from './oracle/oracle_registry.js';
8
8
  export {
9
+ ALIAS,
9
10
  ARRAY,
10
11
  AZTEC_ADDRESS,
11
12
  BIGINT,
@@ -13,8 +14,7 @@ export {
13
14
  BLOCK_NUMBER,
14
15
  BOOL,
15
16
  BOUNDED_VEC,
16
- BUFFER,
17
- BYTE,
17
+ U8,
18
18
  CONTRACT_INSTANCE,
19
19
  DELIVERY_MODE,
20
20
  EPHEMERAL_ARRAY,
@@ -23,6 +23,8 @@ export {
23
23
  FIELD,
24
24
  FIXED_ARRAY,
25
25
  FUNCTION_SELECTOR,
26
+ LEAF,
27
+ LEAF_INDEX,
26
28
  LOG_RETRIEVAL_REQUEST,
27
29
  LOG_RETRIEVAL_RESPONSE,
28
30
  MEMBERSHIP_WITNESS,
@@ -32,16 +34,34 @@ export {
32
34
  PENDING_TAGGED_LOG,
33
35
  POINT,
34
36
  PROVIDED_SECRET,
37
+ SCALAR,
35
38
  SLOT_NUMBER,
36
39
  STR,
37
40
  STRUCT,
38
41
  U32,
42
+ U64,
43
+ U128,
39
44
  tryFieldWidth,
45
+ isArrayMapping,
46
+ isBoundedVecMapping,
47
+ isEphemeralArrayMapping,
48
+ isFixedArrayMapping,
49
+ isFixedBoundedVecMapping,
50
+ isOptionMapping,
51
+ isStructMapping,
52
+ type ArrayMapping,
53
+ type BoundedVecMapping,
54
+ type CompositeMapping,
55
+ type EphemeralArrayMapping,
56
+ type FixedArrayMapping,
57
+ type FixedBoundedVecMapping,
40
58
  type InputSlot,
41
59
  type MaybePromise,
60
+ type OptionMapping,
42
61
  type OutputSlot,
43
62
  type SlotShape,
44
63
  type StructField,
64
+ type StructMapping,
45
65
  type TypeMapping,
46
66
  } from './oracle/oracle_type_mappings.js';
47
67
  export { ExecutionNoteCache } from './execution_note_cache.js';
@@ -74,5 +94,5 @@ export { NoteValidationRequest } from './noir-structs/note_validation_request.js
74
94
  export type { PendingTaggedLog } from './noir-structs/pending_tagged_log.js';
75
95
  export type { TxEffectData } from './noir-structs/tx_effect_data.js';
76
96
  export type { ProvidedSecret } from './noir-structs/provided_secret.js';
77
- export { ResolvedTx } from './noir-structs/resolved_tx.js';
97
+ export type { ResolvedTx } from './noir-structs/resolved_tx.js';
78
98
  export { TransientArrayService } from './transient_array_service.js';
@@ -47,8 +47,10 @@ export function resolvedTaggingStrategyToFields(resolved: ResolvedTaggingStrateg
47
47
  export function resolvedTaggingStrategyFromFields(kind: number, secret: Fr): ResolvedTaggingStrategy {
48
48
  switch (kind) {
49
49
  case NON_INTERACTIVE_HANDSHAKE:
50
+ assertAbsentSecret(kind, secret);
50
51
  return { type: 'non-interactive-handshake' };
51
52
  case INTERACTIVE_HANDSHAKE:
53
+ assertAbsentSecret(kind, secret);
52
54
  return { type: 'interactive-handshake' };
53
55
  case UNCONSTRAINED_SECRET:
54
56
  return { type: 'unconstrained-secret', secret };
@@ -56,3 +58,9 @@ export function resolvedTaggingStrategyFromFields(kind: number, secret: Fr): Res
56
58
  throw new Error(`Unrecognized resolved tagging strategy kind: ${kind}`);
57
59
  }
58
60
  }
61
+
62
+ function assertAbsentSecret(kind: number, secret: Fr): void {
63
+ if (!secret.isZero()) {
64
+ throw new Error(`Resolved tagging strategy ${kind} must not include a secret`);
65
+ }
66
+ }
@@ -1,7 +1,5 @@
1
- import { MAX_NOTE_HASHES_PER_TX } from '@aztec/constants';
2
- import { padArrayEnd } from '@aztec/foundation/collection';
3
- import { Fr } from '@aztec/foundation/curves/bn254';
4
- import { TxHash } from '@aztec/stdlib/tx';
1
+ import type { Fr } from '@aztec/foundation/curves/bn254';
2
+ import type { TxHash } from '@aztec/stdlib/tx';
5
3
 
6
4
  /**
7
5
  * The resolved on-chain context of a transaction.
@@ -9,45 +7,13 @@ import { TxHash } from '@aztec/stdlib/tx';
9
7
  * Carries the note hashes and first nullifier needed to discover notes that originated from the transaction, plus the
10
8
  * number and hash of the block in which it was mined.
11
9
  *
12
- * A TS version of the `ResolvedTx` struct in `oracle/tx_resolution.nr`.
10
+ * A TS version of the `ResolvedTx` struct in `oracle/tx_resolution.nr`; its wire layout lives in the `RESOLVED_TX`
11
+ * type mapping.
13
12
  */
14
- export class ResolvedTx {
15
- constructor(
16
- public txHash: TxHash,
17
- public uniqueNoteHashesInTx: Fr[],
18
- public firstNullifierInTx: Fr,
19
- public blockNumber: number,
20
- public blockHash: Fr,
21
- ) {}
22
-
23
- toFields(): Fr[] {
24
- return [
25
- this.txHash.hash,
26
- ...serializeBoundedVec(this.uniqueNoteHashesInTx, MAX_NOTE_HASHES_PER_TX),
27
- this.firstNullifierInTx,
28
- new Fr(this.blockNumber),
29
- this.blockHash,
30
- ];
31
- }
32
-
33
- static empty(): ResolvedTx {
34
- return new ResolvedTx(TxHash.zero(), [], Fr.ZERO, 0, Fr.ZERO);
35
- }
36
- }
37
-
38
- /**
39
- * Helper function to serialize a bounded vector according to Noir's BoundedVec format: the storage array padded to
40
- * `maxLength`, followed by the actual length.
41
- * @param values - The values to serialize
42
- * @param maxLength - The maximum length of the bounded vector
43
- * @returns The serialized bounded vector as Fr[]
44
- */
45
- function serializeBoundedVec(values: Fr[], maxLength: number): Fr[] {
46
- const storage = padArrayEnd(
47
- values,
48
- Fr.ZERO,
49
- maxLength,
50
- `Attempted to serialize ${values} values into a BoundedVec with max length ${maxLength}`,
51
- );
52
- return [...storage, new Fr(values.length)];
53
- }
13
+ export type ResolvedTx = {
14
+ txHash: TxHash;
15
+ uniqueNoteHashesInTx: Fr[];
16
+ firstNullifierInTx: Fr;
17
+ blockNumber: number;
18
+ blockHash: Fr;
19
+ };
@@ -6,10 +6,11 @@ import type { ContractClassLogData } from './contract_class_log_data.js';
6
6
 
7
7
  /**
8
8
  * Wire form of a {@link TxEffect} as the `getTxEffect` oracle returns it: identical to the domain type except its logs
9
- * are flattened to their Noir layout. Keeping the conversion in the handler lets the `TX_EFFECT` mapping stay purely
10
- * structural.
9
+ * are flattened to their Noir layout and its revert code is the plain `u8` Noir declares. Keeping the conversion in
10
+ * the handler lets the `TX_EFFECT` mapping stay purely structural.
11
11
  */
12
- export type TxEffectData = Omit<FieldsOf<TxEffect>, 'publicLogs' | 'contractClassLogs'> & {
12
+ export type TxEffectData = Omit<FieldsOf<TxEffect>, 'revertCode' | 'publicLogs' | 'contractClassLogs'> & {
13
+ revertCode: number;
13
14
  publicLogs: FlatPublicLogs;
14
15
  contractClassLogs: ContractClassLogData[];
15
16
  };
@@ -55,7 +55,7 @@ export function buildACIRCallback(
55
55
  target[legacyKey] = async (...inputs: ACVMField[][]) => {
56
56
  assertHandlerSupportsScope(handler, scope);
57
57
  const legacyArgs = paramSource.deserializeParams(inputs).map(p => p.value);
58
- const positional = paramOverride ? paramOverride.mapping(legacyArgs) : legacyArgs;
58
+ const positional = paramOverride ? await paramOverride.mapping(legacyArgs) : legacyArgs;
59
59
  const result = await (handler as any)[methodName](...positional);
60
60
  return returnSource.serializeReturn(returnOverride ? returnOverride.mapping(result) : result);
61
61
  };
@@ -1,8 +1,10 @@
1
1
  /* eslint-disable camelcase */
2
2
  import { MAX_NOTE_HASHES_PER_TX, PRIVATE_LOG_CIPHERTEXT_LEN, PRIVATE_LOG_SIZE_IN_FIELDS } from '@aztec/constants';
3
+ import { computeFeeJuiceMessageNullifier } from '@aztec/stdlib/messaging';
3
4
 
4
5
  import type { EphemeralArray } from '../noir-structs/ephemeral_array.js';
5
6
  import type { LogRetrievalResponse } from '../noir-structs/log_retrieval_response.js';
7
+ import { Option } from '../noir-structs/option.js';
6
8
  import type { PendingTaggedLog } from '../noir-structs/pending_tagged_log.js';
7
9
  import type { ResolvedTx } from '../noir-structs/resolved_tx.js';
8
10
  import {
@@ -13,6 +15,7 @@ import {
13
15
  type RegistryParam,
14
16
  } from './oracle_registry.js';
15
17
  import {
18
+ AZTEC_ADDRESS,
16
19
  EPHEMERAL_ARRAY,
17
20
  FIELD,
18
21
  FIXED_BOUNDED_VEC,
@@ -50,6 +53,25 @@ const LEGACY_PENDING_TAGGED_LOG: TypeMapping<LegacyPendingTaggedLog> = STRUCT<Le
50
53
  * older contracts can no longer run against this environment.
51
54
  */
52
55
  export const LEGACY_ORACLE_REGISTRY: Record<string, LegacyOracleEntry> = {
56
+ aztec_utl_getL1ToL2MembershipWitness: legacyOracle({
57
+ modernOracle: 'aztec_utl_getL1ToL2MembershipWitnessV2',
58
+ // The old wire passed the contract address and secret, the modern oracle takes the unsiloed nullifier (plus the
59
+ // address to silo it with) instead. We derive it here so already-deployed contracts that still emit the old call
60
+ // keep working.
61
+ //
62
+ // This is the fee juice message nullifier derivation: only contracts using that scheme call this retired oracle.
63
+ params: {
64
+ legacyType: [
65
+ { name: 'contractAddress', type: AZTEC_ADDRESS },
66
+ { name: 'messageHash', type: FIELD },
67
+ { name: 'secret', type: FIELD },
68
+ ],
69
+ mapping: async ([contractAddress, messageHash, secret]) => [
70
+ messageHash,
71
+ Option.some({ contractAddress, nullifier: await computeFeeJuiceMessageNullifier(messageHash, secret) }),
72
+ ],
73
+ },
74
+ }),
53
75
  aztec_utl_getLogsByTag: legacyOracle({
54
76
  modernOracle: 'aztec_utl_getLogsByTagV2',
55
77
  returnType: {
@@ -98,9 +120,12 @@ export interface LegacyOracleEntry {
98
120
  modernOracle: keyof Registry;
99
121
  /**
100
122
  * Old param wire. `legacyType` deserializes the old wire; `mapping` bridges the deserialized legacy args to the
101
- * modern handler's args. Omit when the param wire is unchanged.
123
+ * modern handler's args. The mapping may be async. Omit when the param wire is unchanged.
102
124
  */
103
- params?: { legacyType: readonly RegistryParam[]; mapping: (legacyArgs: any) => readonly unknown[] };
125
+ params?: {
126
+ legacyType: readonly RegistryParam[];
127
+ mapping: (legacyArgs: any) => readonly unknown[] | Promise<readonly unknown[]>;
128
+ };
104
129
  /**
105
130
  * Old return wire. `legacyType` serializes the subset the old contract reads; `mapping` bridges the handler's
106
131
  * current result to that subset's value type. Omit when the return wire is unchanged.
@@ -112,7 +137,9 @@ function legacyOracle<K extends keyof Registry, W = never, const TLegacyParams e
112
137
  modernOracle: K;
113
138
  params?: {
114
139
  legacyType: [...TLegacyParams];
115
- mapping: (legacyArgs: ParamTypes<InferDeserializedParams<TLegacyParams>>) => HandlerArgsOf<K>;
140
+ mapping: (
141
+ legacyArgs: ParamTypes<InferDeserializedParams<TLegacyParams>>,
142
+ ) => HandlerArgsOf<K> | Promise<HandlerArgsOf<K>>;
116
143
  };
117
144
  returnType?: { legacyType: TypeMapping<W>; mapping: (result: ReturnValueOf<K>) => W };
118
145
  }): LegacyOracleEntry {
@@ -3,6 +3,7 @@ import { ARCHIVE_HEIGHT, NOTE_HASH_TREE_HEIGHT } from '@aztec/constants';
3
3
  import { Fr } from '@aztec/foundation/curves/bn254';
4
4
  import { FieldReader } from '@aztec/foundation/serialize';
5
5
  import { toACVMField } from '@aztec/simulator/client';
6
+ import type { UnsiloedMessageNullifier } from '@aztec/stdlib/messaging';
6
7
 
7
8
  import {
8
9
  ARRAY,
@@ -12,8 +13,6 @@ import {
12
13
  BLOCK_NUMBER,
13
14
  BOOL,
14
15
  BOUNDED_VEC,
15
- BUFFER,
16
- BYTE,
17
16
  CALL_PRIVATE_RESULT,
18
17
  CONTRACT_CLASS_LOG,
19
18
  CONTRACT_INSTANCE,
@@ -22,6 +21,7 @@ import {
22
21
  EVENT_VALIDATION_REQUEST,
23
22
  FACT_COLLECTION,
24
23
  FIELD,
24
+ FIXED_ARRAY,
25
25
  FUNCTION_SELECTOR,
26
26
  type InputSlot,
27
27
  KEY_VALIDATION_REQUEST,
@@ -45,9 +45,11 @@ import {
45
45
  RESOLVED_TAGGING_STRATEGY,
46
46
  RESOLVED_TX,
47
47
  STR,
48
+ STRUCT,
48
49
  TX_EFFECT,
49
50
  TX_HASH,
50
51
  type TypeMapping,
52
+ U8,
51
53
  U32,
52
54
  UTILITY_CONTEXT,
53
55
  assertReadersConsumed,
@@ -61,8 +63,7 @@ export {
61
63
  BLOCK_NUMBER,
62
64
  BOOL,
63
65
  BOUNDED_VEC,
64
- BUFFER,
65
- BYTE,
66
+ U8,
66
67
  CONTRACT_CLASS_LOG,
67
68
  DELIVERY_MODE,
68
69
  RESOLVED_TAGGING_STRATEGY,
@@ -139,6 +140,14 @@ export const ORACLE_REGISTRY = {
139
140
  returnType: OPTION(MEMBERSHIP_WITNESS(ARCHIVE_HEIGHT)),
140
141
  }),
141
142
 
143
+ aztec_utl_areBlockHashesInArchive: makeEntry({
144
+ params: [
145
+ { name: 'anchorBlockHash', type: BLOCK_HASH },
146
+ { name: 'blockHashes', type: EPHEMERAL_ARRAY(BLOCK_HASH) },
147
+ ],
148
+ returnType: EPHEMERAL_ARRAY(BOOL),
149
+ }),
150
+
142
151
  aztec_utl_getNullifierMembershipWitness: makeEntry({
143
152
  params: [
144
153
  { name: 'blockHash', type: BLOCK_HASH },
@@ -183,11 +192,18 @@ export const ORACLE_REGISTRY = {
183
192
  returnType: BOOL,
184
193
  }),
185
194
 
186
- aztec_utl_getL1ToL2MembershipWitness: makeEntry({
195
+ aztec_utl_getL1ToL2MembershipWitnessV2: makeEntry({
187
196
  params: [
188
- { name: 'contractAddress', type: AZTEC_ADDRESS },
189
197
  { name: 'messageHash', type: FIELD },
190
- { name: 'secret', type: FIELD },
198
+ {
199
+ name: 'nullifier',
200
+ type: OPTION(
201
+ STRUCT<UnsiloedMessageNullifier>([
202
+ { name: 'contractAddress', type: AZTEC_ADDRESS },
203
+ { name: 'nullifier', type: FIELD },
204
+ ]),
205
+ ),
206
+ },
191
207
  ],
192
208
  returnType: MESSAGE_LOAD_ORACLE_INPUTS,
193
209
  }),
@@ -256,6 +272,11 @@ export const ORACLE_REGISTRY = {
256
272
  returnType: OPTION(TX_EFFECT),
257
273
  }),
258
274
 
275
+ aztec_utl_getTxEffects: makeEntry({
276
+ params: [{ name: 'txHashes', type: EPHEMERAL_ARRAY(TX_HASH) }],
277
+ returnType: EPHEMERAL_ARRAY(OPTION(TX_EFFECT)),
278
+ }),
279
+
259
280
  aztec_utl_setCapsule: makeEntry({
260
281
  params: [
261
282
  { name: 'contractAddress', type: AZTEC_ADDRESS },
@@ -295,11 +316,11 @@ export const ORACLE_REGISTRY = {
295
316
 
296
317
  aztec_utl_decryptAes128: makeEntry({
297
318
  params: [
298
- { name: 'ciphertext', type: BOUNDED_VEC(BYTE) },
299
- { name: 'iv', type: BUFFER(8, 16) },
300
- { name: 'symKey', type: BUFFER(8, 16) },
319
+ { name: 'ciphertext', type: BOUNDED_VEC(U8) },
320
+ { name: 'iv', type: FIXED_ARRAY(U8, 16) },
321
+ { name: 'symKey', type: FIXED_ARRAY(U8, 16) },
301
322
  ],
302
- returnType: OPTION(BOUNDED_VEC(BYTE)),
323
+ returnType: OPTION(BOUNDED_VEC(U8)),
303
324
  }),
304
325
 
305
326
  aztec_utl_getSharedSecrets: makeEntry({