@aztec/txe 3.0.0-rc.5 → 4.0.0-nightly.20260107

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 (66) hide show
  1. package/dest/constants.d.ts +3 -0
  2. package/dest/constants.d.ts.map +1 -0
  3. package/dest/constants.js +2 -0
  4. package/dest/index.d.ts +1 -1
  5. package/dest/index.d.ts.map +1 -1
  6. package/dest/index.js +3 -2
  7. package/dest/oracle/interfaces.d.ts +4 -2
  8. package/dest/oracle/interfaces.d.ts.map +1 -1
  9. package/dest/oracle/txe_oracle_public_context.d.ts +2 -2
  10. package/dest/oracle/txe_oracle_public_context.d.ts.map +1 -1
  11. package/dest/oracle/txe_oracle_public_context.js +3 -5
  12. package/dest/oracle/txe_oracle_top_level_context.d.ts +18 -10
  13. package/dest/oracle/txe_oracle_top_level_context.d.ts.map +1 -1
  14. package/dest/oracle/txe_oracle_top_level_context.js +83 -52
  15. package/dest/rpc_translator.d.ts +9 -3
  16. package/dest/rpc_translator.d.ts.map +1 -1
  17. package/dest/rpc_translator.js +33 -3
  18. package/dest/state_machine/archiver.d.ts +19 -7
  19. package/dest/state_machine/archiver.d.ts.map +1 -1
  20. package/dest/state_machine/archiver.js +93 -15
  21. package/dest/state_machine/dummy_p2p_client.d.ts +1 -1
  22. package/dest/state_machine/dummy_p2p_client.d.ts.map +1 -1
  23. package/dest/state_machine/dummy_p2p_client.js +3 -1
  24. package/dest/state_machine/global_variable_builder.d.ts +3 -2
  25. package/dest/state_machine/global_variable_builder.d.ts.map +1 -1
  26. package/dest/state_machine/global_variable_builder.js +12 -0
  27. package/dest/state_machine/index.d.ts +5 -5
  28. package/dest/state_machine/index.d.ts.map +1 -1
  29. package/dest/state_machine/index.js +13 -19
  30. package/dest/txe_session.d.ts +15 -9
  31. package/dest/txe_session.d.ts.map +1 -1
  32. package/dest/txe_session.js +72 -42
  33. package/dest/util/encoding.d.ts +601 -2
  34. package/dest/util/encoding.d.ts.map +1 -1
  35. package/dest/util/txe_account_store.d.ts +10 -0
  36. package/dest/util/txe_account_store.d.ts.map +1 -0
  37. package/dest/util/{txe_account_data_provider.js → txe_account_store.js} +1 -1
  38. package/dest/util/txe_contract_store.d.ts +12 -0
  39. package/dest/util/txe_contract_store.d.ts.map +1 -0
  40. package/dest/util/{txe_contract_data_provider.js → txe_contract_store.js} +3 -3
  41. package/dest/util/txe_public_contract_data_source.d.ts +4 -4
  42. package/dest/util/txe_public_contract_data_source.d.ts.map +1 -1
  43. package/dest/util/txe_public_contract_data_source.js +10 -10
  44. package/dest/utils/block_creation.d.ts +16 -2
  45. package/dest/utils/block_creation.d.ts.map +1 -1
  46. package/dest/utils/block_creation.js +22 -1
  47. package/package.json +15 -15
  48. package/src/constants.ts +3 -0
  49. package/src/index.ts +15 -12
  50. package/src/oracle/interfaces.ts +3 -1
  51. package/src/oracle/txe_oracle_public_context.ts +3 -8
  52. package/src/oracle/txe_oracle_top_level_context.ts +125 -76
  53. package/src/rpc_translator.ts +45 -3
  54. package/src/state_machine/archiver.ts +119 -21
  55. package/src/state_machine/dummy_p2p_client.ts +3 -1
  56. package/src/state_machine/global_variable_builder.ts +18 -1
  57. package/src/state_machine/index.ts +18 -17
  58. package/src/txe_session.ts +157 -69
  59. package/src/util/{txe_account_data_provider.ts → txe_account_store.ts} +1 -1
  60. package/src/util/{txe_contract_data_provider.ts → txe_contract_store.ts} +3 -3
  61. package/src/util/txe_public_contract_data_source.ts +9 -9
  62. package/src/utils/block_creation.ts +31 -1
  63. package/dest/util/txe_account_data_provider.d.ts +0 -10
  64. package/dest/util/txe_account_data_provider.d.ts.map +0 -1
  65. package/dest/util/txe_contract_data_provider.d.ts +0 -12
  66. package/dest/util/txe_contract_data_provider.d.ts.map +0 -1
@@ -5,12 +5,14 @@ import { KeyStore } from '@aztec/key-store';
5
5
  import { openTmpStore } from '@aztec/kv-store/lmdb-v2';
6
6
  import type { ProtocolContract } from '@aztec/protocol-contracts';
7
7
  import {
8
- AddressDataProvider,
9
- CapsuleDataProvider,
10
- NoteDataProvider,
11
- PXEOracleInterface,
12
- PrivateEventDataProvider,
13
- TaggingDataProvider,
8
+ AddressStore,
9
+ CapsuleStore,
10
+ NoteService,
11
+ NoteStore,
12
+ PrivateEventStore,
13
+ RecipientTaggingStore,
14
+ SenderAddressBookStore,
15
+ SenderTaggingStore,
14
16
  } from '@aztec/pxe/server';
15
17
  import {
16
18
  ExecutionNoteCache,
@@ -18,34 +20,39 @@ import {
18
20
  HashedValuesCache,
19
21
  type IPrivateExecutionOracle,
20
22
  type IUtilityExecutionOracle,
23
+ Oracle,
21
24
  PrivateExecutionOracle,
22
25
  UtilityExecutionOracle,
23
26
  } from '@aztec/pxe/simulator';
24
- import { FunctionSelector } from '@aztec/stdlib/abi';
27
+ import {
28
+ ExecutionError,
29
+ WASMSimulator,
30
+ createSimulationError,
31
+ extractCallStack,
32
+ resolveAssertionMessageFromError,
33
+ toACVMWitness,
34
+ } from '@aztec/simulator/client';
35
+ import { FunctionCall, FunctionSelector, FunctionType } from '@aztec/stdlib/abi';
25
36
  import type { AuthWitness } from '@aztec/stdlib/auth-witness';
26
37
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
27
- import { Body, L2Block } from '@aztec/stdlib/block';
28
38
  import { GasSettings } from '@aztec/stdlib/gas';
29
39
  import { computeProtocolNullifier } from '@aztec/stdlib/hash';
30
40
  import { PrivateContextInputs } from '@aztec/stdlib/kernel';
31
- import { makeAppendOnlyTreeSnapshot, makeGlobalVariables } from '@aztec/stdlib/testing';
41
+ import { makeGlobalVariables } from '@aztec/stdlib/testing';
32
42
  import { CallContext, GlobalVariables, TxContext } from '@aztec/stdlib/tx';
33
43
 
34
44
  import { z } from 'zod';
35
45
 
46
+ import { DEFAULT_ADDRESS } from './constants.js';
36
47
  import type { IAvmExecutionOracle, ITxeExecutionOracle } from './oracle/interfaces.js';
37
48
  import { TXEOraclePublicContext } from './oracle/txe_oracle_public_context.js';
38
49
  import { TXEOracleTopLevelContext } from './oracle/txe_oracle_top_level_context.js';
39
50
  import { RPCTranslator } from './rpc_translator.js';
40
51
  import { TXEStateMachine } from './state_machine/index.js';
41
52
  import type { ForeignCallArgs, ForeignCallResult } from './util/encoding.js';
42
- import { TXEAccountDataProvider } from './util/txe_account_data_provider.js';
43
- import { TXEContractDataProvider } from './util/txe_contract_data_provider.js';
44
- import {
45
- getSingleTxBlockRequestHash,
46
- insertTxEffectIntoWorldTrees,
47
- makeTXEBlockHeader,
48
- } from './utils/block_creation.js';
53
+ import { TXEAccountStore } from './util/txe_account_store.js';
54
+ import { TXEContractStore } from './util/txe_contract_store.js';
55
+ import { getSingleTxBlockRequestHash, insertTxEffectIntoWorldTrees, makeTXEBlock } from './utils/block_creation.js';
49
56
  import { makeTxEffect } from './utils/tx_effect_creation.js';
50
57
 
51
58
  /**
@@ -106,8 +113,6 @@ export interface TXESessionStateHandler {
106
113
  enterUtilityState(contractAddress?: AztecAddress): Promise<void>;
107
114
  }
108
115
 
109
- const DEFAULT_ADDRESS = AztecAddress.fromNumber(42);
110
-
111
116
  /**
112
117
  * A `TXESession` corresponds to a Noir `#[test]` function, and handles all of its oracle calls, stores test-specific
113
118
  * state, etc., independent of all other tests running in parallel.
@@ -124,32 +129,39 @@ export class TXESession implements TXESessionStateHandler {
124
129
  | IPrivateExecutionOracle
125
130
  | IAvmExecutionOracle
126
131
  | ITxeExecutionOracle,
127
- private contractDataProvider: TXEContractDataProvider,
132
+ private contractStore: TXEContractStore,
133
+ private noteStore: NoteStore,
128
134
  private keyStore: KeyStore,
129
- private addressDataProvider: AddressDataProvider,
130
- private accountDataProvider: TXEAccountDataProvider,
135
+ private addressStore: AddressStore,
136
+ private accountStore: TXEAccountStore,
137
+ private senderTaggingStore: SenderTaggingStore,
138
+ private recipientTaggingStore: RecipientTaggingStore,
139
+ private senderAddressBookStore: SenderAddressBookStore,
140
+ private capsuleStore: CapsuleStore,
141
+ private privateEventStore: PrivateEventStore,
131
142
  private chainId: Fr,
132
143
  private version: Fr,
133
144
  private nextBlockTimestamp: bigint,
134
- private pxeOracleInterface: PXEOracleInterface,
135
145
  ) {}
136
146
 
137
147
  static async init(protocolContracts: ProtocolContract[]) {
138
148
  const store = await openTmpStore('txe-session');
139
149
 
140
- const addressDataProvider = new AddressDataProvider(store);
141
- const privateEventDataProvider = new PrivateEventDataProvider(store);
142
- const contractDataProvider = new TXEContractDataProvider(store);
143
- const noteDataProvider = await NoteDataProvider.create(store);
144
- const taggingDataProvider = new TaggingDataProvider(store);
145
- const capsuleDataProvider = new CapsuleDataProvider(store);
150
+ const addressStore = new AddressStore(store);
151
+ const privateEventStore = new PrivateEventStore(store);
152
+ const contractStore = new TXEContractStore(store);
153
+ const noteStore = await NoteStore.create(store);
154
+ const senderTaggingStore = new SenderTaggingStore(store);
155
+ const recipientTaggingStore = new RecipientTaggingStore(store);
156
+ const senderAddressBookStore = new SenderAddressBookStore(store);
157
+ const capsuleStore = new CapsuleStore(store);
146
158
  const keyStore = new KeyStore(store);
147
- const accountDataProvider = new TXEAccountDataProvider(store);
159
+ const accountStore = new TXEAccountStore(store);
148
160
 
149
161
  // Register protocol contracts.
150
162
  for (const { contractClass, instance, artifact } of protocolContracts) {
151
- await contractDataProvider.addContractArtifact(contractClass.id, artifact);
152
- await contractDataProvider.addContractInstance(instance);
163
+ await contractStore.addContractArtifact(contractClass.id, artifact);
164
+ await contractStore.addContractInstance(instance);
153
165
  }
154
166
 
155
167
  const stateMachine = await TXEStateMachine.create(store);
@@ -158,25 +170,18 @@ export class TXESession implements TXESessionStateHandler {
158
170
  const version = new Fr(await stateMachine.node.getVersion());
159
171
  const chainId = new Fr(await stateMachine.node.getChainId());
160
172
 
161
- const pxeOracleInterface = new PXEOracleInterface(
162
- stateMachine.node,
163
- keyStore,
164
- contractDataProvider,
165
- noteDataProvider,
166
- capsuleDataProvider,
167
- stateMachine.syncDataProvider,
168
- taggingDataProvider,
169
- addressDataProvider,
170
- privateEventDataProvider,
171
- );
172
-
173
173
  const topLevelOracleHandler = new TXEOracleTopLevelContext(
174
174
  stateMachine,
175
- contractDataProvider,
175
+ contractStore,
176
+ noteStore,
176
177
  keyStore,
177
- addressDataProvider,
178
- accountDataProvider,
179
- pxeOracleInterface,
178
+ addressStore,
179
+ accountStore,
180
+ senderTaggingStore,
181
+ recipientTaggingStore,
182
+ senderAddressBookStore,
183
+ capsuleStore,
184
+ privateEventStore,
180
185
  nextBlockTimestamp,
181
186
  version,
182
187
  chainId,
@@ -188,14 +193,19 @@ export class TXESession implements TXESessionStateHandler {
188
193
  createLogger('txe:session'),
189
194
  stateMachine,
190
195
  topLevelOracleHandler,
191
- contractDataProvider,
196
+ contractStore,
197
+ noteStore,
192
198
  keyStore,
193
- addressDataProvider,
194
- accountDataProvider,
199
+ addressStore,
200
+ accountStore,
201
+ senderTaggingStore,
202
+ recipientTaggingStore,
203
+ senderAddressBookStore,
204
+ capsuleStore,
205
+ privateEventStore,
195
206
  version,
196
207
  chainId,
197
208
  nextBlockTimestamp,
198
- pxeOracleInterface,
199
209
  );
200
210
  }
201
211
 
@@ -254,11 +264,16 @@ export class TXESession implements TXESessionStateHandler {
254
264
 
255
265
  this.oracleHandler = new TXEOracleTopLevelContext(
256
266
  this.stateMachine,
257
- this.contractDataProvider,
267
+ this.contractStore,
268
+ this.noteStore,
258
269
  this.keyStore,
259
- this.addressDataProvider,
260
- this.accountDataProvider,
261
- this.pxeOracleInterface,
270
+ this.addressStore,
271
+ this.accountStore,
272
+ this.senderTaggingStore,
273
+ this.recipientTaggingStore,
274
+ this.senderAddressBookStore,
275
+ this.capsuleStore,
276
+ this.privateEventStore,
262
277
  this.nextBlockTimestamp,
263
278
  this.version,
264
279
  this.chainId,
@@ -275,12 +290,11 @@ export class TXESession implements TXESessionStateHandler {
275
290
  ): Promise<PrivateContextInputs> {
276
291
  this.exitTopLevelState();
277
292
 
278
- // There is no automatic message discovery and contract-driven syncing process in inlined private or utility
279
- // contexts, which means that known nullifiers are also not searched for, since it is during the tagging sync that
280
- // we perform this. We therefore search for known nullifiers now, as otherwise notes that were nullified would not
281
- // be removed from the database.
282
- // TODO(#12553): make the synchronizer sync here instead and remove this
283
- await this.pxeOracleInterface.syncNoteNullifiers(contractAddress);
293
+ await new NoteService(
294
+ this.noteStore,
295
+ this.stateMachine.node,
296
+ this.stateMachine.anchorBlockStore,
297
+ ).syncNoteNullifiers(contractAddress);
284
298
 
285
299
  // Private execution has two associated block numbers: the anchor block (i.e. the historical block that is used to
286
300
  // build the proof), and the *next* block, i.e. the one we'll create once the execution ends, and which will contain
@@ -300,17 +314,29 @@ export class TXESession implements TXESessionStateHandler {
300
314
  const noteCache = new ExecutionNoteCache(protocolNullifier);
301
315
  const taggingIndexCache = new ExecutionTaggingIndexCache();
302
316
 
317
+ const utilityExecutor = this.utilityExecutorForContractSync(anchorBlock);
303
318
  this.oracleHandler = new PrivateExecutionOracle(
304
319
  Fr.ZERO,
305
320
  new TxContext(this.chainId, this.version, GasSettings.empty()),
306
321
  new CallContext(AztecAddress.ZERO, contractAddress, FunctionSelector.empty(), false),
307
322
  anchorBlock!,
323
+ utilityExecutor,
308
324
  [],
309
325
  [],
310
326
  new HashedValuesCache(),
311
327
  noteCache,
312
328
  taggingIndexCache,
313
- this.pxeOracleInterface,
329
+ this.contractStore,
330
+ this.noteStore,
331
+ this.keyStore,
332
+ this.addressStore,
333
+ this.stateMachine.node,
334
+ this.stateMachine.anchorBlockStore,
335
+ this.senderTaggingStore,
336
+ this.recipientTaggingStore,
337
+ this.senderAddressBookStore,
338
+ this.capsuleStore,
339
+ this.privateEventStore,
314
340
  );
315
341
 
316
342
  // We store the note and tagging index caches fed into the PrivateExecutionOracle (along with some other auxiliary
@@ -356,9 +382,30 @@ export class TXESession implements TXESessionStateHandler {
356
382
  // we perform this. We therefore search for known nullifiers now, as otherwise notes that were nullified would not
357
383
  // be removed from the database.
358
384
  // TODO(#12553): make the synchronizer sync here instead and remove this
359
- await this.pxeOracleInterface.syncNoteNullifiers(contractAddress);
385
+ await new NoteService(
386
+ this.noteStore,
387
+ this.stateMachine.node,
388
+ this.stateMachine.anchorBlockStore,
389
+ ).syncNoteNullifiers(contractAddress);
390
+
391
+ const anchorBlockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
360
392
 
361
- this.oracleHandler = new UtilityExecutionOracle(contractAddress, [], [], this.pxeOracleInterface);
393
+ this.oracleHandler = new UtilityExecutionOracle(
394
+ contractAddress,
395
+ [],
396
+ [],
397
+ anchorBlockHeader,
398
+ this.contractStore,
399
+ this.noteStore,
400
+ this.keyStore,
401
+ this.addressStore,
402
+ this.stateMachine.node,
403
+ this.stateMachine.anchorBlockStore,
404
+ this.recipientTaggingStore,
405
+ this.senderAddressBookStore,
406
+ this.capsuleStore,
407
+ this.privateEventStore,
408
+ );
362
409
 
363
410
  this.state = { name: 'UTILITY' };
364
411
  this.logger.debug(`Entered state ${this.state.name}`);
@@ -392,6 +439,7 @@ export class TXESession implements TXESessionStateHandler {
392
439
 
393
440
  // We rely on the note cache to determine the effects of the transaction. This is incomplete as it doesn't private
394
441
  // logs (other effects like enqueued public calls don't need to be considered since those are not allowed).
442
+
395
443
  const txEffect = await makeTxEffect(
396
444
  this.state.noteCache,
397
445
  this.state.protocolNullifier,
@@ -402,11 +450,7 @@ export class TXESession implements TXESessionStateHandler {
402
450
  const forkedWorldTrees = await this.stateMachine.synchronizer.nativeWorldStateService.fork();
403
451
  await insertTxEffectIntoWorldTrees(txEffect, forkedWorldTrees);
404
452
 
405
- const block = new L2Block(
406
- makeAppendOnlyTreeSnapshot(),
407
- await makeTXEBlockHeader(forkedWorldTrees, this.state.nextBlockGlobalVariables),
408
- new Body([txEffect]),
409
- );
453
+ const block = await makeTXEBlock(forkedWorldTrees, this.state.nextBlockGlobalVariables, [txEffect]);
410
454
  await this.stateMachine.handleL2Block(block);
411
455
 
412
456
  await forkedWorldTrees.close();
@@ -431,4 +475,48 @@ export class TXESession implements TXESessionStateHandler {
431
475
  throw new Error(`Expected to be in state 'UTILITY', but got '${this.state.name}' instead`);
432
476
  }
433
477
  }
478
+
479
+ private utilityExecutorForContractSync(anchorBlock: any) {
480
+ return async (call: FunctionCall) => {
481
+ const entryPointArtifact = await this.contractStore.getFunctionArtifactWithDebugMetadata(call.to, call.selector);
482
+ if (entryPointArtifact.functionType !== FunctionType.UTILITY) {
483
+ throw new Error(`Cannot run ${entryPointArtifact.functionType} function as utility`);
484
+ }
485
+
486
+ try {
487
+ const oracle = new UtilityExecutionOracle(
488
+ call.to,
489
+ [],
490
+ [],
491
+ anchorBlock!,
492
+ this.contractStore,
493
+ this.noteStore,
494
+ this.keyStore,
495
+ this.addressStore,
496
+ this.stateMachine.node,
497
+ this.stateMachine.anchorBlockStore,
498
+ this.recipientTaggingStore,
499
+ this.senderAddressBookStore,
500
+ this.capsuleStore,
501
+ this.privateEventStore,
502
+ );
503
+ await new WASMSimulator()
504
+ .executeUserCircuit(toACVMWitness(0, call.args), entryPointArtifact, new Oracle(oracle).toACIRCallback())
505
+ .catch((err: Error) => {
506
+ err.message = resolveAssertionMessageFromError(err, entryPointArtifact);
507
+ throw new ExecutionError(
508
+ err.message,
509
+ {
510
+ contractAddress: call.to,
511
+ functionSelector: call.selector,
512
+ },
513
+ extractCallStack(err, entryPointArtifact.debug),
514
+ { cause: err },
515
+ );
516
+ });
517
+ } catch (err) {
518
+ throw createSimulationError(err instanceof Error ? err : new Error('Unknown error contract data sync'));
519
+ }
520
+ };
521
+ }
434
522
  }
@@ -2,7 +2,7 @@ import type { AztecAsyncKVStore, AztecAsyncMap } from '@aztec/kv-store';
2
2
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
3
3
  import { CompleteAddress } from '@aztec/stdlib/contract';
4
4
 
5
- export class TXEAccountDataProvider {
5
+ export class TXEAccountStore {
6
6
  #accounts: AztecAsyncMap<string, Buffer>;
7
7
 
8
8
  constructor(store: AztecAsyncKVStore) {
@@ -1,15 +1,15 @@
1
1
  import type { ContractArtifact } from '@aztec/aztec.js/abi';
2
2
  import { Fr } from '@aztec/aztec.js/fields';
3
- import { ContractDataProvider } from '@aztec/pxe/server';
3
+ import { ContractStore } from '@aztec/pxe/server';
4
4
 
5
5
  export type ContractArtifactWithHash = ContractArtifact & { artifactHash: Fr };
6
6
 
7
7
  /*
8
- * A contract data provider that stores contract artifacts with their hashes. Since
8
+ * A contract store that stores contract artifacts with their hashes. Since
9
9
  * TXE typically deploys the same contract again and again for multiple tests, caching
10
10
  * the *very* expensive artifact hash computation improves testing speed significantly.
11
11
  */
12
- export class TXEContractDataProvider extends ContractDataProvider {
12
+ export class TXEContractStore extends ContractStore {
13
13
  #artifactHashes: Map<string, Buffer> = new Map();
14
14
 
15
15
  public override async addContractArtifact(
@@ -1,6 +1,6 @@
1
1
  import { BlockNumber } from '@aztec/foundation/branded-types';
2
2
  import { Fr } from '@aztec/foundation/curves/bn254';
3
- import type { ContractDataProvider } from '@aztec/pxe/server';
3
+ import type { ContractStore } from '@aztec/pxe/server';
4
4
  import { type ContractArtifact, FunctionSelector, FunctionType } from '@aztec/stdlib/abi';
5
5
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
6
6
  import {
@@ -16,7 +16,7 @@ export class TXEPublicContractDataSource implements ContractDataSource {
16
16
  #privateFunctionsRoot: Map<string, Buffer> = new Map();
17
17
  constructor(
18
18
  private blockNumber: BlockNumber,
19
- private contractDataProvider: ContractDataProvider,
19
+ private contractStore: ContractStore,
20
20
  ) {}
21
21
 
22
22
  getBlockNumber(): Promise<BlockNumber> {
@@ -24,11 +24,11 @@ export class TXEPublicContractDataSource implements ContractDataSource {
24
24
  }
25
25
 
26
26
  async getContractClass(id: Fr): Promise<ContractClassPublic | undefined> {
27
- const contractClass = await this.contractDataProvider.getContractClass(id);
27
+ const contractClass = await this.contractStore.getContractClass(id);
28
28
  if (!contractClass) {
29
29
  return;
30
30
  }
31
- const artifact = await this.contractDataProvider.getContractArtifact(id);
31
+ const artifact = await this.contractStore.getContractArtifact(id);
32
32
  if (!artifact) {
33
33
  return;
34
34
  }
@@ -58,12 +58,12 @@ export class TXEPublicContractDataSource implements ContractDataSource {
58
58
  }
59
59
 
60
60
  async getBytecodeCommitment(id: Fr): Promise<Fr | undefined> {
61
- const contractClass = await this.contractDataProvider.getContractClass(id);
61
+ const contractClass = await this.contractStore.getContractClass(id);
62
62
  return contractClass && computePublicBytecodeCommitment(contractClass.packedBytecode);
63
63
  }
64
64
 
65
65
  async getContract(address: AztecAddress): Promise<ContractInstanceWithAddress | undefined> {
66
- const instance = await this.contractDataProvider.getContractInstance(address);
66
+ const instance = await this.contractStore.getContractInstance(address);
67
67
  return instance && { ...instance, address };
68
68
  }
69
69
 
@@ -72,12 +72,12 @@ export class TXEPublicContractDataSource implements ContractDataSource {
72
72
  }
73
73
 
74
74
  async getContractArtifact(address: AztecAddress): Promise<ContractArtifact | undefined> {
75
- const instance = await this.contractDataProvider.getContractInstance(address);
76
- return instance && this.contractDataProvider.getContractArtifact(instance.currentContractClassId);
75
+ const instance = await this.contractStore.getContractInstance(address);
76
+ return instance && this.contractStore.getContractArtifact(instance.currentContractClassId);
77
77
  }
78
78
 
79
79
  async getDebugFunctionName(address: AztecAddress, selector: FunctionSelector): Promise<string | undefined> {
80
- return await this.contractDataProvider.getDebugFunctionName(address, selector);
80
+ return await this.contractStore.getDebugFunctionName(address, selector);
81
81
  }
82
82
 
83
83
  registerContractFunctionSignatures(_signatures: []): Promise<void> {
@@ -7,7 +7,7 @@ import {
7
7
  import { BlockNumber } from '@aztec/foundation/branded-types';
8
8
  import { padArrayEnd } from '@aztec/foundation/collection';
9
9
  import { Fr } from '@aztec/foundation/curves/bn254';
10
- import { L2BlockHeader } from '@aztec/stdlib/block';
10
+ import { Body, L2Block, L2BlockHeader } from '@aztec/stdlib/block';
11
11
  import { makeContentCommitment } from '@aztec/stdlib/testing';
12
12
  import { AppendOnlyTreeSnapshot, MerkleTreeId, type MerkleTreeWriteOperations } from '@aztec/stdlib/trees';
13
13
  import { GlobalVariables, TxEffect } from '@aztec/stdlib/tx';
@@ -62,3 +62,33 @@ export async function makeTXEBlockHeader(
62
62
  Fr.ZERO,
63
63
  );
64
64
  }
65
+
66
+ /**
67
+ * Creates an L2Block with proper archive chaining.
68
+ * This function:
69
+ * 1. Gets the current archive state as lastArchive for the header
70
+ * 2. Creates the block header
71
+ * 3. Updates the archive tree with the header hash
72
+ * 4. Gets the new archive state for the block's archive
73
+ *
74
+ * @param worldTrees - The world trees to read/write from
75
+ * @param globalVariables - Global variables for the block
76
+ * @param txEffects - Transaction effects to include in the block
77
+ * @returns The created L2Block with proper archive chaining
78
+ */
79
+ export async function makeTXEBlock(
80
+ worldTrees: MerkleTreeWriteOperations,
81
+ globalVariables: GlobalVariables,
82
+ txEffects: TxEffect[],
83
+ ): Promise<L2Block> {
84
+ const header = await makeTXEBlockHeader(worldTrees, globalVariables);
85
+
86
+ // Update the archive tree with this block's header hash
87
+ await worldTrees.updateArchive(header.toBlockHeader());
88
+
89
+ // Get the new archive state after updating
90
+ const newArchiveInfo = await worldTrees.getTreeInfo(MerkleTreeId.ARCHIVE);
91
+ const newArchive = new AppendOnlyTreeSnapshot(new Fr(newArchiveInfo.root), Number(newArchiveInfo.size));
92
+
93
+ return new L2Block(newArchive, header, new Body(txEffects));
94
+ }
@@ -1,10 +0,0 @@
1
- import type { AztecAsyncKVStore } from '@aztec/kv-store';
2
- import type { AztecAddress } from '@aztec/stdlib/aztec-address';
3
- import { CompleteAddress } from '@aztec/stdlib/contract';
4
- export declare class TXEAccountDataProvider {
5
- #private;
6
- constructor(store: AztecAsyncKVStore);
7
- getAccount(key: AztecAddress): Promise<CompleteAddress>;
8
- setAccount(key: AztecAddress, value: CompleteAddress): Promise<void>;
9
- }
10
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHhlX2FjY291bnRfZGF0YV9wcm92aWRlci5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3V0aWwvdHhlX2FjY291bnRfZGF0YV9wcm92aWRlci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxpQkFBaUIsRUFBaUIsTUFBTSxpQkFBaUIsQ0FBQztBQUN4RSxPQUFPLEtBQUssRUFBRSxZQUFZLEVBQUUsTUFBTSw2QkFBNkIsQ0FBQztBQUNoRSxPQUFPLEVBQUUsZUFBZSxFQUFFLE1BQU0sd0JBQXdCLENBQUM7QUFFekQscUJBQWEsc0JBQXNCOztJQUdqQyxZQUFZLEtBQUssRUFBRSxpQkFBaUIsRUFFbkM7SUFFSyxVQUFVLENBQUMsR0FBRyxFQUFFLFlBQVksNEJBTWpDO0lBRUssVUFBVSxDQUFDLEdBQUcsRUFBRSxZQUFZLEVBQUUsS0FBSyxFQUFFLGVBQWUsaUJBRXpEO0NBQ0YifQ==
@@ -1 +0,0 @@
1
- {"version":3,"file":"txe_account_data_provider.d.ts","sourceRoot":"","sources":["../../src/util/txe_account_data_provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAiB,MAAM,iBAAiB,CAAC;AACxE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD,qBAAa,sBAAsB;;IAGjC,YAAY,KAAK,EAAE,iBAAiB,EAEnC;IAEK,UAAU,CAAC,GAAG,EAAE,YAAY,4BAMjC;IAEK,UAAU,CAAC,GAAG,EAAE,YAAY,EAAE,KAAK,EAAE,eAAe,iBAEzD;CACF"}
@@ -1,12 +0,0 @@
1
- import type { ContractArtifact } from '@aztec/aztec.js/abi';
2
- import { Fr } from '@aztec/aztec.js/fields';
3
- import { ContractDataProvider } from '@aztec/pxe/server';
4
- export type ContractArtifactWithHash = ContractArtifact & {
5
- artifactHash: Fr;
6
- };
7
- export declare class TXEContractDataProvider extends ContractDataProvider {
8
- #private;
9
- addContractArtifact(id: Fr, artifact: ContractArtifact | ContractArtifactWithHash): Promise<void>;
10
- getContractArtifact(contractClassId: Fr): Promise<ContractArtifact | ContractArtifactWithHash | undefined>;
11
- }
12
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHhlX2NvbnRyYWN0X2RhdGFfcHJvdmlkZXIuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy91dGlsL3R4ZV9jb250cmFjdF9kYXRhX3Byb3ZpZGVyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sS0FBSyxFQUFFLGdCQUFnQixFQUFFLE1BQU0scUJBQXFCLENBQUM7QUFDNUQsT0FBTyxFQUFFLEVBQUUsRUFBRSxNQUFNLHdCQUF3QixDQUFDO0FBQzVDLE9BQU8sRUFBRSxvQkFBb0IsRUFBRSxNQUFNLG1CQUFtQixDQUFDO0FBRXpELE1BQU0sTUFBTSx3QkFBd0IsR0FBRyxnQkFBZ0IsR0FBRztJQUFFLFlBQVksRUFBRSxFQUFFLENBQUE7Q0FBRSxDQUFDO0FBTy9FLHFCQUFhLHVCQUF3QixTQUFRLG9CQUFvQjs7SUFHekMsbUJBQW1CLENBQ3ZDLEVBQUUsRUFBRSxFQUFFLEVBQ04sUUFBUSxFQUFFLGdCQUFnQixHQUFHLHdCQUF3QixHQUNwRCxPQUFPLENBQUMsSUFBSSxDQUFDLENBS2Y7SUFFcUIsbUJBQW1CLENBQ3ZDLGVBQWUsRUFBRSxFQUFFLEdBQ2xCLE9BQU8sQ0FBQyxnQkFBZ0IsR0FBRyx3QkFBd0IsR0FBRyxTQUFTLENBQUMsQ0FRbEU7Q0FDRiJ9
@@ -1 +0,0 @@
1
- {"version":3,"file":"txe_contract_data_provider.d.ts","sourceRoot":"","sources":["../../src/util/txe_contract_data_provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,EAAE,EAAE,MAAM,wBAAwB,CAAC;AAC5C,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAEzD,MAAM,MAAM,wBAAwB,GAAG,gBAAgB,GAAG;IAAE,YAAY,EAAE,EAAE,CAAA;CAAE,CAAC;AAO/E,qBAAa,uBAAwB,SAAQ,oBAAoB;;IAGzC,mBAAmB,CACvC,EAAE,EAAE,EAAE,EACN,QAAQ,EAAE,gBAAgB,GAAG,wBAAwB,GACpD,OAAO,CAAC,IAAI,CAAC,CAKf;IAEqB,mBAAmB,CACvC,eAAe,EAAE,EAAE,GAClB,OAAO,CAAC,gBAAgB,GAAG,wBAAwB,GAAG,SAAS,CAAC,CAQlE;CACF"}