@aztec/pxe 3.0.0-nightly.20251214 → 3.0.0-nightly.20251217

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 (121) hide show
  1. package/dest/block_synchronizer/block_synchronizer.d.ts +39 -0
  2. package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -0
  3. package/dest/{synchronizer/synchronizer.js → block_synchronizer/block_synchronizer.js} +22 -17
  4. package/dest/block_synchronizer/index.d.ts +2 -0
  5. package/dest/block_synchronizer/index.d.ts.map +1 -0
  6. package/dest/block_synchronizer/index.js +1 -0
  7. package/dest/config/index.d.ts +4 -4
  8. package/dest/config/index.d.ts.map +1 -1
  9. package/dest/contract_function_simulator/contract_function_simulator.d.ts +6 -4
  10. package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
  11. package/dest/contract_function_simulator/contract_function_simulator.js +7 -6
  12. package/dest/contract_function_simulator/execution_data_provider.d.ts +6 -26
  13. package/dest/contract_function_simulator/execution_data_provider.d.ts.map +1 -1
  14. package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts +1 -1
  15. package/dest/contract_function_simulator/execution_tagging_index_cache.js +1 -1
  16. package/dest/contract_function_simulator/oracle/interfaces.d.ts +2 -2
  17. package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -1
  18. package/dest/contract_function_simulator/oracle/oracle.d.ts +1 -1
  19. package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
  20. package/dest/contract_function_simulator/oracle/oracle.js +3 -3
  21. package/dest/contract_function_simulator/oracle/private_execution.d.ts +2 -2
  22. package/dest/contract_function_simulator/oracle/private_execution.d.ts.map +1 -1
  23. package/dest/contract_function_simulator/oracle/private_execution.js +0 -1
  24. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +2 -3
  25. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
  26. package/dest/contract_function_simulator/oracle/private_execution_oracle.js +8 -4
  27. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +4 -3
  28. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
  29. package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +8 -7
  30. package/dest/contract_function_simulator/pxe_oracle_interface.d.ts +9 -20
  31. package/dest/contract_function_simulator/pxe_oracle_interface.d.ts.map +1 -1
  32. package/dest/contract_function_simulator/pxe_oracle_interface.js +41 -106
  33. package/dest/debug/pxe_debug_utils.d.ts +30 -0
  34. package/dest/debug/pxe_debug_utils.d.ts.map +1 -0
  35. package/dest/debug/pxe_debug_utils.js +37 -0
  36. package/dest/events/private_event_filter_validator.d.ts +4 -4
  37. package/dest/events/private_event_filter_validator.d.ts.map +1 -1
  38. package/dest/events/private_event_filter_validator.js +4 -4
  39. package/dest/pxe.d.ts +19 -28
  40. package/dest/pxe.d.ts.map +1 -1
  41. package/dest/pxe.js +70 -86
  42. package/dest/storage/anchor_block_data_provider/anchor_block_data_provider.d.ts +9 -0
  43. package/dest/storage/anchor_block_data_provider/anchor_block_data_provider.d.ts.map +1 -0
  44. package/dest/storage/{sync_data_provider/sync_data_provider.js → anchor_block_data_provider/anchor_block_data_provider.js} +2 -9
  45. package/dest/storage/anchor_block_data_provider/index.d.ts +2 -0
  46. package/dest/storage/anchor_block_data_provider/index.d.ts.map +1 -0
  47. package/dest/storage/anchor_block_data_provider/index.js +1 -0
  48. package/dest/storage/contract_data_provider/contract_data_provider.d.ts +3 -2
  49. package/dest/storage/contract_data_provider/contract_data_provider.d.ts.map +1 -1
  50. package/dest/storage/contract_data_provider/contract_data_provider.js +21 -1
  51. package/dest/storage/index.d.ts +2 -2
  52. package/dest/storage/index.d.ts.map +1 -1
  53. package/dest/storage/index.js +1 -1
  54. package/dest/storage/tagging_data_provider/index.d.ts +3 -2
  55. package/dest/storage/tagging_data_provider/index.d.ts.map +1 -1
  56. package/dest/storage/tagging_data_provider/index.js +2 -1
  57. package/dest/storage/tagging_data_provider/recipient_tagging_data_provider.d.ts +31 -0
  58. package/dest/storage/tagging_data_provider/recipient_tagging_data_provider.d.ts.map +1 -0
  59. package/dest/storage/tagging_data_provider/recipient_tagging_data_provider.js +65 -0
  60. package/dest/storage/tagging_data_provider/sender_tagging_data_provider.d.ts +67 -0
  61. package/dest/storage/tagging_data_provider/sender_tagging_data_provider.d.ts.map +1 -0
  62. package/dest/storage/tagging_data_provider/sender_tagging_data_provider.js +196 -0
  63. package/dest/tagging/constants.d.ts +1 -1
  64. package/dest/tagging/constants.d.ts.map +1 -1
  65. package/dest/tagging/constants.js +1 -0
  66. package/dest/tagging/sync/sync_sender_tagging_indexes.d.ts +21 -0
  67. package/dest/tagging/sync/sync_sender_tagging_indexes.d.ts.map +1 -0
  68. package/dest/tagging/sync/sync_sender_tagging_indexes.js +89 -0
  69. package/dest/tagging/sync/utils/get_status_change_of_pending.d.ts +11 -0
  70. package/dest/tagging/sync/utils/get_status_change_of_pending.d.ts.map +1 -0
  71. package/dest/tagging/sync/utils/get_status_change_of_pending.js +32 -0
  72. package/dest/tagging/sync/utils/load_and_store_new_tagging_indexes.d.ts +18 -0
  73. package/dest/tagging/sync/utils/load_and_store_new_tagging_indexes.d.ts.map +1 -0
  74. package/dest/tagging/sync/utils/load_and_store_new_tagging_indexes.js +57 -0
  75. package/dest/tagging/utils.d.ts +2 -2
  76. package/dest/tagging/utils.d.ts.map +1 -1
  77. package/dest/tagging/utils.js +3 -2
  78. package/package.json +16 -16
  79. package/src/{synchronizer/synchronizer.ts → block_synchronizer/block_synchronizer.ts} +21 -17
  80. package/src/block_synchronizer/index.ts +1 -0
  81. package/src/config/index.ts +3 -3
  82. package/src/contract_function_simulator/contract_function_simulator.ts +21 -5
  83. package/src/contract_function_simulator/execution_data_provider.ts +7 -28
  84. package/src/contract_function_simulator/execution_tagging_index_cache.ts +1 -1
  85. package/src/contract_function_simulator/oracle/interfaces.ts +1 -1
  86. package/src/contract_function_simulator/oracle/oracle.ts +3 -3
  87. package/src/contract_function_simulator/oracle/private_execution.ts +1 -3
  88. package/src/contract_function_simulator/oracle/private_execution_oracle.ts +11 -5
  89. package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +6 -6
  90. package/src/contract_function_simulator/pxe_oracle_interface.ts +41 -114
  91. package/src/debug/pxe_debug_utils.ts +47 -0
  92. package/src/events/private_event_filter_validator.ts +3 -3
  93. package/src/pxe.ts +74 -96
  94. package/src/storage/{sync_data_provider/sync_data_provider.ts → anchor_block_data_provider/anchor_block_data_provider.ts} +2 -12
  95. package/src/storage/anchor_block_data_provider/index.ts +1 -0
  96. package/src/storage/contract_data_provider/contract_data_provider.ts +27 -0
  97. package/src/storage/index.ts +1 -1
  98. package/src/storage/tagging_data_provider/index.ts +2 -1
  99. package/src/storage/tagging_data_provider/recipient_tagging_data_provider.ts +86 -0
  100. package/src/storage/tagging_data_provider/sender_tagging_data_provider.ts +244 -0
  101. package/src/tagging/constants.ts +1 -0
  102. package/src/tagging/sync/sync_sender_tagging_indexes.ts +112 -0
  103. package/src/tagging/sync/utils/get_status_change_of_pending.ts +44 -0
  104. package/src/tagging/sync/utils/load_and_store_new_tagging_indexes.ts +74 -0
  105. package/src/tagging/utils.ts +3 -2
  106. package/dest/storage/sync_data_provider/index.d.ts +0 -2
  107. package/dest/storage/sync_data_provider/index.d.ts.map +0 -1
  108. package/dest/storage/sync_data_provider/index.js +0 -1
  109. package/dest/storage/sync_data_provider/sync_data_provider.d.ts +0 -11
  110. package/dest/storage/sync_data_provider/sync_data_provider.d.ts.map +0 -1
  111. package/dest/storage/tagging_data_provider/tagging_data_provider.d.ts +0 -40
  112. package/dest/storage/tagging_data_provider/tagging_data_provider.d.ts.map +0 -1
  113. package/dest/storage/tagging_data_provider/tagging_data_provider.js +0 -89
  114. package/dest/synchronizer/index.d.ts +0 -2
  115. package/dest/synchronizer/index.d.ts.map +0 -1
  116. package/dest/synchronizer/index.js +0 -1
  117. package/dest/synchronizer/synchronizer.d.ts +0 -36
  118. package/dest/synchronizer/synchronizer.d.ts.map +0 -1
  119. package/src/storage/sync_data_provider/index.ts +0 -1
  120. package/src/storage/tagging_data_provider/tagging_data_provider.ts +0 -120
  121. package/src/synchronizer/index.ts +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aztec/pxe",
3
- "version": "3.0.0-nightly.20251214",
3
+ "version": "3.0.0-nightly.20251217",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  "./server": "./dest/entrypoints/server/index.js",
@@ -61,19 +61,19 @@
61
61
  ]
62
62
  },
63
63
  "dependencies": {
64
- "@aztec/bb-prover": "3.0.0-nightly.20251214",
65
- "@aztec/bb.js": "3.0.0-nightly.20251214",
66
- "@aztec/builder": "3.0.0-nightly.20251214",
67
- "@aztec/constants": "3.0.0-nightly.20251214",
68
- "@aztec/ethereum": "3.0.0-nightly.20251214",
69
- "@aztec/foundation": "3.0.0-nightly.20251214",
70
- "@aztec/key-store": "3.0.0-nightly.20251214",
71
- "@aztec/kv-store": "3.0.0-nightly.20251214",
72
- "@aztec/noir-protocol-circuits-types": "3.0.0-nightly.20251214",
73
- "@aztec/noir-types": "3.0.0-nightly.20251214",
74
- "@aztec/protocol-contracts": "3.0.0-nightly.20251214",
75
- "@aztec/simulator": "3.0.0-nightly.20251214",
76
- "@aztec/stdlib": "3.0.0-nightly.20251214",
64
+ "@aztec/bb-prover": "3.0.0-nightly.20251217",
65
+ "@aztec/bb.js": "3.0.0-nightly.20251217",
66
+ "@aztec/builder": "3.0.0-nightly.20251217",
67
+ "@aztec/constants": "3.0.0-nightly.20251217",
68
+ "@aztec/ethereum": "3.0.0-nightly.20251217",
69
+ "@aztec/foundation": "3.0.0-nightly.20251217",
70
+ "@aztec/key-store": "3.0.0-nightly.20251217",
71
+ "@aztec/kv-store": "3.0.0-nightly.20251217",
72
+ "@aztec/noir-protocol-circuits-types": "3.0.0-nightly.20251217",
73
+ "@aztec/noir-types": "3.0.0-nightly.20251217",
74
+ "@aztec/protocol-contracts": "3.0.0-nightly.20251217",
75
+ "@aztec/simulator": "3.0.0-nightly.20251217",
76
+ "@aztec/stdlib": "3.0.0-nightly.20251217",
77
77
  "koa": "^2.16.1",
78
78
  "koa-router": "^13.1.1",
79
79
  "lodash.omit": "^4.5.0",
@@ -82,8 +82,8 @@
82
82
  "viem": "npm:@aztec/viem@2.38.2"
83
83
  },
84
84
  "devDependencies": {
85
- "@aztec/merkle-tree": "3.0.0-nightly.20251214",
86
- "@aztec/noir-test-contracts.js": "3.0.0-nightly.20251214",
85
+ "@aztec/merkle-tree": "3.0.0-nightly.20251217",
86
+ "@aztec/noir-test-contracts.js": "3.0.0-nightly.20251217",
87
87
  "@jest/globals": "^30.0.0",
88
88
  "@types/jest": "^30.0.0",
89
89
  "@types/lodash.omit": "^4.5.7",
@@ -5,32 +5,32 @@ import { L2BlockStream, type L2BlockStreamEvent, type L2BlockStreamEventHandler
5
5
  import type { AztecNode } from '@aztec/stdlib/interfaces/client';
6
6
 
7
7
  import type { PXEConfig } from '../config/index.js';
8
+ import type { AnchorBlockDataProvider } from '../storage/anchor_block_data_provider/anchor_block_data_provider.js';
8
9
  import type { NoteDataProvider } from '../storage/note_data_provider/note_data_provider.js';
9
- import type { SyncDataProvider } from '../storage/sync_data_provider/sync_data_provider.js';
10
- import type { TaggingDataProvider } from '../storage/tagging_data_provider/tagging_data_provider.js';
10
+ import type { RecipientTaggingDataProvider } from '../storage/tagging_data_provider/recipient_tagging_data_provider.js';
11
11
 
12
12
  /**
13
- * The Synchronizer class orchestrates synchronization between the PXE and Aztec node, maintaining an up-to-date
13
+ * The BlockSynchronizer class orchestrates synchronization between PXE and Aztec node, maintaining an up-to-date
14
14
  * view of the L2 chain state. It handles block header retrieval, chain reorganizations, and provides an interface
15
15
  * for querying sync status.
16
16
  */
17
- export class Synchronizer implements L2BlockStreamEventHandler {
17
+ export class BlockSynchronizer implements L2BlockStreamEventHandler {
18
18
  private log: Logger;
19
19
  private isSyncing: Promise<void> | undefined;
20
20
  protected readonly blockStream: L2BlockStream;
21
21
 
22
22
  constructor(
23
23
  private node: AztecNode,
24
- private syncDataProvider: SyncDataProvider,
24
+ private anchorBlockDataProvider: AnchorBlockDataProvider,
25
25
  private noteDataProvider: NoteDataProvider,
26
- private taggingDataProvider: TaggingDataProvider,
26
+ private recipientTaggingDataProvider: RecipientTaggingDataProvider,
27
27
  private l2TipsStore: L2TipsKVStore,
28
28
  config: Partial<Pick<PXEConfig, 'l2BlockBatchSize'>> = {},
29
29
  loggerOrSuffix?: string | Logger,
30
30
  ) {
31
31
  this.log =
32
32
  !loggerOrSuffix || typeof loggerOrSuffix === 'string'
33
- ? createLogger(loggerOrSuffix ? `pxe:synchronizer:${loggerOrSuffix}` : `pxe:synchronizer`)
33
+ ? createLogger(loggerOrSuffix ? `pxe:block_synchronizer:${loggerOrSuffix}` : `pxe:block_synchronizer`)
34
34
  : loggerOrSuffix;
35
35
  this.blockStream = this.createBlockStream(config);
36
36
  }
@@ -56,23 +56,26 @@ export class Synchronizer implements L2BlockStreamEventHandler {
56
56
  archive: lastBlock.archive.root.toString(),
57
57
  header: lastBlock.header.toInspect(),
58
58
  });
59
- await this.syncDataProvider.setHeader(lastBlock.getBlockHeader());
59
+ await this.anchorBlockDataProvider.setHeader(lastBlock.getBlockHeader());
60
60
  break;
61
61
  }
62
62
  case 'chain-pruned': {
63
63
  this.log.warn(`Pruning data after block ${event.block.number} due to reorg`);
64
64
  // We first unnullify and then remove so that unnullified notes that were created after the block number end up deleted.
65
- const lastSynchedBlockNumber = await this.syncDataProvider.getBlockNumber();
65
+ const lastSynchedBlockNumber = (await this.anchorBlockDataProvider.getBlockHeader()).getBlockNumber();
66
66
  await this.noteDataProvider.rollbackNotesAndNullifiers(event.block.number, lastSynchedBlockNumber);
67
67
  // Remove all note tagging indexes to force a full resync. This is suboptimal, but unless we track the
68
68
  // block number in which each index is used it's all we can do.
69
- await this.taggingDataProvider.resetNoteSyncData();
69
+ // Note: This is now unnecessary for the sender tagging data provider because the new algorithm handles reorgs.
70
+ // TODO(#17775): Once this issue is implemented we will have the index-block number mapping, so we can
71
+ // implement this more intelligently.
72
+ await this.recipientTaggingDataProvider.resetNoteSyncData();
70
73
  // Update the header to the last block.
71
74
  const newHeader = await this.node.getBlockHeader(event.block.number);
72
75
  if (!newHeader) {
73
76
  this.log.error(`Block header not found for block number ${event.block.number} during chain prune`);
74
77
  } else {
75
- await this.syncDataProvider.setHeader(newHeader);
78
+ await this.anchorBlockDataProvider.setHeader(newHeader);
76
79
  }
77
80
  break;
78
81
  }
@@ -82,6 +85,11 @@ export class Synchronizer implements L2BlockStreamEventHandler {
82
85
  /**
83
86
  * Syncs PXE and the node by downloading the metadata of the latest blocks, allowing simulations to use
84
87
  * recent data (e.g. notes), and handling any reorgs that might have occurred.
88
+ *
89
+ * Note this BlockSynchronizer is designed to let its users control when a synchronization is run,
90
+ * so this component doesn't proactively stay up to date with the blockchain.
91
+ *
92
+ * We do this so PXE can ensure data consistency.
85
93
  */
86
94
  public async sync() {
87
95
  if (this.isSyncing !== undefined) {
@@ -104,18 +112,14 @@ export class Synchronizer implements L2BlockStreamEventHandler {
104
112
  let currentHeader;
105
113
 
106
114
  try {
107
- currentHeader = await this.syncDataProvider.getBlockHeader();
115
+ currentHeader = await this.anchorBlockDataProvider.getBlockHeader();
108
116
  } catch {
109
117
  this.log.debug('Header is not set, requesting from the node');
110
118
  }
111
119
  if (!currentHeader) {
112
120
  // REFACTOR: We should know the header of the genesis block without having to request it from the node.
113
- await this.syncDataProvider.setHeader((await this.node.getBlockHeader(BlockNumber.ZERO))!);
121
+ await this.anchorBlockDataProvider.setHeader((await this.node.getBlockHeader(BlockNumber.ZERO))!);
114
122
  }
115
123
  await this.blockStream.sync();
116
124
  }
117
-
118
- public getSynchedBlockNumber() {
119
- return this.syncDataProvider.getBlockNumber();
120
- }
121
125
  }
@@ -0,0 +1 @@
1
+ export * from './block_synchronizer.js';
@@ -19,14 +19,14 @@ export interface KernelProverConfig {
19
19
  }
20
20
 
21
21
  /**
22
- * Configuration settings for the synchronizer.
22
+ * Configuration settings for the block synchronizer.
23
23
  */
24
- export interface SynchronizerConfig {
24
+ export interface BlockSynchronizerConfig {
25
25
  /** Maximum amount of blocks to pull from the stream in one request when synchronizing */
26
26
  l2BlockBatchSize: number;
27
27
  }
28
28
 
29
- export type PXEConfig = KernelProverConfig & DataStoreConfig & ChainConfig & SynchronizerConfig;
29
+ export type PXEConfig = KernelProverConfig & DataStoreConfig & ChainConfig & BlockSynchronizerConfig;
30
30
 
31
31
  export type CliPXEOptions = {
32
32
  /** Custom Aztec Node URL to connect to */
@@ -59,6 +59,7 @@ import { PrivateLog } from '@aztec/stdlib/logs';
59
59
  import { ScopedL2ToL1Message } from '@aztec/stdlib/messaging';
60
60
  import { ChonkProof } from '@aztec/stdlib/proofs';
61
61
  import {
62
+ BlockHeader,
62
63
  CallContext,
63
64
  HashedValues,
64
65
  PrivateExecutionResult,
@@ -98,6 +99,7 @@ export class ContractFunctionSimulator {
98
99
  * @param contractAddress - The address of the contract (should match request.origin)
99
100
  * @param msgSender - The address calling the function. This can be replaced to simulate a call from another contract
100
101
  * or a specific account.
102
+ * @param anchorBlockHeader - The block header to use as base state for this run.
101
103
  * @param senderForTags - The address that is used as a tagging sender when emitting private logs. Returned from
102
104
  * the `privateGetSenderForTags` oracle.
103
105
  * @param scopes - The accounts whose notes we can access in this call. Currently optional and will default to all.
@@ -108,13 +110,13 @@ export class ContractFunctionSimulator {
108
110
  contractAddress: AztecAddress,
109
111
  selector: FunctionSelector,
110
112
  msgSender = AztecAddress.fromField(Fr.MAX_FIELD_VALUE),
113
+ anchorBlockHeader: BlockHeader,
111
114
  senderForTags?: AztecAddress,
112
115
  scopes?: AztecAddress[],
113
116
  ): Promise<PrivateExecutionResult> {
114
117
  const simulatorSetupTimer = new Timer();
115
- const anchorBlockHeader = await this.executionDataProvider.getAnchorBlockHeader();
116
118
 
117
- await verifyCurrentClassId(contractAddress, this.executionDataProvider);
119
+ await verifyCurrentClassId(contractAddress, this.executionDataProvider, anchorBlockHeader);
118
120
 
119
121
  const entryPointArtifact = await this.executionDataProvider.getFunctionArtifact(contractAddress, selector);
120
122
 
@@ -213,12 +215,18 @@ export class ContractFunctionSimulator {
213
215
  * Runs a utility function.
214
216
  * @param call - The function call to execute.
215
217
  * @param authwits - Authentication witnesses required for the function call.
218
+ * @param anchorBlockHeader - The block header to use as base state for this run.
216
219
  * @param scopes - Optional array of account addresses whose notes can be accessed in this call. Defaults to all
217
220
  * accounts if not specified.
218
221
  * @returns A return value of the utility function in a form as returned by the simulator (Noir fields)
219
222
  */
220
- public async runUtility(call: FunctionCall, authwits: AuthWitness[], scopes?: AztecAddress[]): Promise<Fr[]> {
221
- await verifyCurrentClassId(call.to, this.executionDataProvider);
223
+ public async runUtility(
224
+ call: FunctionCall,
225
+ authwits: AuthWitness[],
226
+ anchorBlockHeader: BlockHeader,
227
+ scopes?: AztecAddress[],
228
+ ): Promise<Fr[]> {
229
+ await verifyCurrentClassId(call.to, this.executionDataProvider, anchorBlockHeader);
222
230
 
223
231
  const entryPointArtifact = await this.executionDataProvider.getFunctionArtifact(call.to, call.selector);
224
232
 
@@ -226,7 +234,15 @@ export class ContractFunctionSimulator {
226
234
  throw new Error(`Cannot run ${entryPointArtifact.functionType} function as utility`);
227
235
  }
228
236
 
229
- const oracle = new UtilityExecutionOracle(call.to, authwits, [], this.executionDataProvider, undefined, scopes);
237
+ const oracle = new UtilityExecutionOracle(
238
+ call.to,
239
+ authwits,
240
+ [],
241
+ anchorBlockHeader,
242
+ this.executionDataProvider,
243
+ undefined,
244
+ scopes,
245
+ );
230
246
 
231
247
  try {
232
248
  this.log.verbose(`Executing utility function ${entryPointArtifact.name}`, {
@@ -6,12 +6,14 @@ import type { FunctionArtifactWithContractName, FunctionSelector } from '@aztec/
6
6
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
7
7
  import type { L2Block } from '@aztec/stdlib/block';
8
8
  import type { CompleteAddress, ContractInstance } from '@aztec/stdlib/contract';
9
+ import type { AztecNode } from '@aztec/stdlib/interfaces/client';
9
10
  import type { KeyValidationRequest } from '@aztec/stdlib/kernel';
10
11
  import type { DirectionalAppTaggingSecret } from '@aztec/stdlib/logs';
11
12
  import type { NoteStatus } from '@aztec/stdlib/note';
12
13
  import { type MerkleTreeId, type NullifierMembershipWitness, PublicDataWitness } from '@aztec/stdlib/trees';
13
- import type { BlockHeader, NodeStats } from '@aztec/stdlib/tx';
14
+ import type { NodeStats } from '@aztec/stdlib/tx';
14
15
 
16
+ import type { SenderTaggingDataProvider } from '../storage/tagging_data_provider/sender_tagging_data_provider.js';
15
17
  import type { NoteData } from './oracle/interfaces.js';
16
18
  import type { MessageLoadOracleInputs } from './oracle/message_load_oracle_inputs.js';
17
19
 
@@ -138,14 +140,6 @@ export interface ExecutionDataProvider {
138
140
  secret: Fr,
139
141
  ): Promise<MessageLoadOracleInputs<typeof L1_TO_L2_MSG_TREE_HEIGHT>>;
140
142
 
141
- /**
142
- * Retrieve the latest block header synchronized by the execution data provider. This block header is referred
143
- * to as the anchor block header in Aztec terminology and it defines the state that is used during private function
144
- * execution.
145
- * @returns The anchor block header.
146
- */
147
- getAnchorBlockHeader(): Promise<BlockHeader>;
148
-
149
143
  /**
150
144
  * Fetches the index and sibling path of a leaf at a given block from a given tree.
151
145
  * @param blockNumber - The block number at which to get the membership witness.
@@ -227,25 +221,6 @@ export interface ExecutionDataProvider {
227
221
  recipient: AztecAddress,
228
222
  ): Promise<DirectionalAppTaggingSecret>;
229
223
 
230
- /**
231
- * Updates the local index of the shared tagging secret of a (sender, recipient, contract) tuple if a log with
232
- * a larger index is found from the node.
233
- * @param secret - The secret that's unique for (sender, recipient, contract) tuple while the direction
234
- * of sender -> recipient matters.
235
- * @param contractAddress - The address of the contract that the logs are tagged for. Needs to be provided to store
236
- * because the function performs second round of siloing which is necessary because kernels do it as well (they silo
237
- * first field of the private log which corresponds to the tag).
238
- */
239
- syncTaggedLogsAsSender(secret: DirectionalAppTaggingSecret, contractAddress: AztecAddress): Promise<void>;
240
-
241
- /**
242
- * Returns the last used index when sending a log with a given secret.
243
- * @param secret - The directional app tagging secret.
244
- * @returns The last used index for the given directional app tagging secret, or undefined if we never sent a log
245
- * from this sender to a recipient in a given contract (implicitly included in the secret).
246
- */
247
- getLastUsedIndexAsSender(secret: DirectionalAppTaggingSecret): Promise<number | undefined>;
248
-
249
224
  /**
250
225
  * Synchronizes the private logs tagged with scoped addresses and all the senders in the address book. Stores the found
251
226
  * logs in CapsuleArray ready for a later retrieval in Aztec.nr.
@@ -340,4 +315,8 @@ export interface ExecutionDataProvider {
340
315
  * @returns The execution statistics.
341
316
  */
342
317
  getStats(): ExecutionStats;
318
+
319
+ // Exposed when moving in the direction of #17776
320
+ get aztecNode(): AztecNode;
321
+ get senderTaggingDataProvider(): SenderTaggingDataProvider;
343
322
  }
@@ -21,7 +21,7 @@ export class ExecutionTaggingIndexCache {
21
21
  }
22
22
 
23
23
  /**
24
- * Returns the pre tags that were used in this execution (and that need to be stored in the db).
24
+ * Returns the pre-tags that were used in this execution (and that need to be stored in the db).
25
25
  */
26
26
  public getUsedPreTags(): PreTag[] {
27
27
  return Array.from(this.taggingIndexMap.entries()).map(([secret, index]) => ({
@@ -63,7 +63,7 @@ export interface IMiscOracle {
63
63
  export interface IUtilityExecutionOracle {
64
64
  isUtility: true;
65
65
 
66
- utilityGetUtilityContext(): Promise<UtilityContext>;
66
+ utilityGetUtilityContext(): UtilityContext;
67
67
  utilityGetKeyValidationRequest(pkMHash: Fr): Promise<KeyValidationRequest>;
68
68
  utilityGetContractInstance(address: AztecAddress): Promise<ContractInstance>;
69
69
  utilityGetMembershipWitness(blockNumber: BlockNumber, treeId: MerkleTreeId, leafValue: Fr): Promise<Fr[] | undefined>;
@@ -112,9 +112,9 @@ export class Oracle {
112
112
  return [values.map(toACVMField)];
113
113
  }
114
114
 
115
- async utilityGetUtilityContext(): Promise<(ACVMField | ACVMField[])[]> {
116
- const context = await this.handlerAsUtility().utilityGetUtilityContext();
117
- return context.toNoirRepresentation();
115
+ utilityGetUtilityContext(): Promise<(ACVMField | ACVMField[])[]> {
116
+ const context = this.handlerAsUtility().utilityGetUtilityContext();
117
+ return Promise.resolve(context.toNoirRepresentation());
118
118
  }
119
119
 
120
120
  async utilityGetKeyValidationRequest([pkMHash]: ACVMField[]): Promise<ACVMField[]> {
@@ -188,10 +188,8 @@ export async function readCurrentClassId(
188
188
  export async function verifyCurrentClassId(
189
189
  contractAddress: AztecAddress,
190
190
  executionDataProvider: ExecutionDataProvider,
191
- header?: BlockHeader,
191
+ header: BlockHeader,
192
192
  ) {
193
- header = header ?? (await executionDataProvider.getAnchorBlockHeader());
194
-
195
193
  const instance = await executionDataProvider.getContractInstance(contractAddress);
196
194
  const currentClassId = await readCurrentClassId(
197
195
  contractAddress,
@@ -26,6 +26,7 @@ import {
26
26
  type TxContext,
27
27
  } from '@aztec/stdlib/tx';
28
28
 
29
+ import { syncSenderTaggingIndexes } from '../../tagging/sync/sync_sender_tagging_indexes.js';
29
30
  import { Tag } from '../../tagging/tag.js';
30
31
  import type { ExecutionDataProvider } from '../execution_data_provider.js';
31
32
  import type { ExecutionNoteCache } from '../execution_note_cache.js';
@@ -71,7 +72,7 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
71
72
  private readonly txContext: TxContext,
72
73
  private readonly callContext: CallContext,
73
74
  /** Header of a block whose state is used during private execution (not the block the transaction is included in). */
74
- protected readonly anchorBlockHeader: BlockHeader,
75
+ protected override readonly anchorBlockHeader: BlockHeader,
75
76
  /** List of transient auth witnesses to be used during this simulation */
76
77
  authWitnesses: AuthWitness[],
77
78
  capsules: Capsule[],
@@ -86,7 +87,7 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
86
87
  private senderForTags?: AztecAddress,
87
88
  private simulator?: CircuitSimulator,
88
89
  ) {
89
- super(callContext.contractAddress, authWitnesses, capsules, executionDataProvider, log, scopes);
90
+ super(callContext.contractAddress, authWitnesses, capsules, anchorBlockHeader, executionDataProvider, log, scopes);
90
91
  }
91
92
 
92
93
  public getPrivateContextInputs(): PrivateContextInputs {
@@ -152,7 +153,7 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
152
153
  }
153
154
 
154
155
  /**
155
- * Returns the pre tags that were used in this execution (and that need to be stored in the db).
156
+ * Returns the pre-tags that were used in this execution (and that need to be stored in the db).
156
157
  */
157
158
  public getUsedPreTags(): PreTag[] {
158
159
  return this.taggingIndexCache.getUsedPreTags();
@@ -224,11 +225,16 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
224
225
  if (lastUsedIndexInTx !== undefined) {
225
226
  return lastUsedIndexInTx + 1;
226
227
  } else {
228
+ // TODO(#17776): Don't access the Aztec node and senderTaggingDataProvider via the executionDataProvider.
229
+ const aztecNode = this.executionDataProvider.aztecNode;
230
+ const senderTaggingDataProvider = this.executionDataProvider.senderTaggingDataProvider;
231
+
227
232
  // This is a tagging secret we've not yet used in this tx, so first sync our store to make sure its indices
228
233
  // are up to date. We do this here because this store is not synced as part of the global sync because
229
234
  // that'd be wasteful as most tagging secrets are not used in each tx.
230
- await this.executionDataProvider.syncTaggedLogsAsSender(secret, this.contractAddress);
231
- const lastUsedIndex = await this.executionDataProvider.getLastUsedIndexAsSender(secret);
235
+ await syncSenderTaggingIndexes(secret, this.contractAddress, aztecNode, senderTaggingDataProvider);
236
+
237
+ const lastUsedIndex = await senderTaggingDataProvider.getLastUsedIndex(secret);
232
238
  // If lastUsedIndex is undefined, we've never used this secret, so start from 0
233
239
  // Otherwise, the next index to use is one past the last used index
234
240
  return lastUsedIndex === undefined ? 0 : lastUsedIndex + 1;
@@ -31,6 +31,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
31
31
  /** List of transient auth witnesses to be used during this simulation */
32
32
  protected readonly authWitnesses: AuthWitness[],
33
33
  protected readonly capsules: Capsule[], // TODO(#12425): Rename to transientCapsules
34
+ protected readonly anchorBlockHeader: BlockHeader,
34
35
  protected readonly executionDataProvider: ExecutionDataProvider,
35
36
  protected log = createLogger('simulator:client_view_context'),
36
37
  protected readonly scopes?: AztecAddress[],
@@ -44,14 +45,13 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
44
45
  return Fr.random();
45
46
  }
46
47
 
47
- public async utilityGetUtilityContext(): Promise<UtilityContext> {
48
- const blockHeader = await this.executionDataProvider.getAnchorBlockHeader();
48
+ public utilityGetUtilityContext(): UtilityContext {
49
49
  return UtilityContext.from({
50
- blockNumber: blockHeader.globalVariables.blockNumber,
51
- timestamp: blockHeader.globalVariables.timestamp,
50
+ blockNumber: this.anchorBlockHeader.globalVariables.blockNumber,
51
+ timestamp: this.anchorBlockHeader.globalVariables.timestamp,
52
52
  contractAddress: this.contractAddress,
53
- version: blockHeader.globalVariables.version,
54
- chainId: blockHeader.globalVariables.chainId,
53
+ version: this.anchorBlockHeader.globalVariables.version,
54
+ chainId: this.anchorBlockHeader.globalVariables.chainId,
55
55
  });
56
56
  }
57
57