@aztec/txe 0.0.1-commit.03f7ef2 → 0.0.1-commit.08c5969dc

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 (73) 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/oracle/interfaces.d.ts +3 -3
  5. package/dest/oracle/interfaces.d.ts.map +1 -1
  6. package/dest/oracle/txe_oracle_public_context.d.ts +3 -3
  7. package/dest/oracle/txe_oracle_public_context.d.ts.map +1 -1
  8. package/dest/oracle/txe_oracle_public_context.js +6 -6
  9. package/dest/oracle/txe_oracle_top_level_context.d.ts +17 -14
  10. package/dest/oracle/txe_oracle_top_level_context.d.ts.map +1 -1
  11. package/dest/oracle/txe_oracle_top_level_context.js +144 -67
  12. package/dest/rpc_translator.d.ts +19 -13
  13. package/dest/rpc_translator.d.ts.map +1 -1
  14. package/dest/rpc_translator.js +75 -50
  15. package/dest/state_machine/archiver.d.ts +20 -67
  16. package/dest/state_machine/archiver.d.ts.map +1 -1
  17. package/dest/state_machine/archiver.js +59 -178
  18. package/dest/state_machine/dummy_p2p_client.d.ts +16 -12
  19. package/dest/state_machine/dummy_p2p_client.d.ts.map +1 -1
  20. package/dest/state_machine/dummy_p2p_client.js +32 -20
  21. package/dest/state_machine/global_variable_builder.d.ts +2 -2
  22. package/dest/state_machine/global_variable_builder.d.ts.map +1 -1
  23. package/dest/state_machine/global_variable_builder.js +1 -1
  24. package/dest/state_machine/index.d.ts +6 -6
  25. package/dest/state_machine/index.d.ts.map +1 -1
  26. package/dest/state_machine/index.js +36 -13
  27. package/dest/state_machine/mock_epoch_cache.d.ts +9 -6
  28. package/dest/state_machine/mock_epoch_cache.d.ts.map +1 -1
  29. package/dest/state_machine/mock_epoch_cache.js +14 -7
  30. package/dest/state_machine/synchronizer.d.ts +3 -3
  31. package/dest/state_machine/synchronizer.d.ts.map +1 -1
  32. package/dest/txe_session.d.ts +17 -14
  33. package/dest/txe_session.d.ts.map +1 -1
  34. package/dest/txe_session.js +144 -49
  35. package/dest/util/encoding.d.ts +17 -17
  36. package/dest/util/txe_account_store.d.ts +10 -0
  37. package/dest/util/txe_account_store.d.ts.map +1 -0
  38. package/dest/util/{txe_account_data_provider.js → txe_account_store.js} +1 -1
  39. package/dest/util/txe_contract_store.d.ts +12 -0
  40. package/dest/util/txe_contract_store.d.ts.map +1 -0
  41. package/dest/util/{txe_contract_data_provider.js → txe_contract_store.js} +3 -3
  42. package/dest/util/txe_public_contract_data_source.d.ts +4 -4
  43. package/dest/util/txe_public_contract_data_source.d.ts.map +1 -1
  44. package/dest/util/txe_public_contract_data_source.js +10 -10
  45. package/dest/utils/block_creation.d.ts +4 -4
  46. package/dest/utils/block_creation.d.ts.map +1 -1
  47. package/dest/utils/block_creation.js +18 -5
  48. package/dest/utils/tx_effect_creation.d.ts +2 -3
  49. package/dest/utils/tx_effect_creation.d.ts.map +1 -1
  50. package/dest/utils/tx_effect_creation.js +3 -6
  51. package/package.json +16 -16
  52. package/src/constants.ts +3 -0
  53. package/src/index.ts +1 -1
  54. package/src/oracle/interfaces.ts +2 -2
  55. package/src/oracle/txe_oracle_public_context.ts +6 -8
  56. package/src/oracle/txe_oracle_top_level_context.ts +171 -108
  57. package/src/rpc_translator.ts +78 -52
  58. package/src/state_machine/archiver.ts +54 -220
  59. package/src/state_machine/dummy_p2p_client.ts +45 -26
  60. package/src/state_machine/global_variable_builder.ts +1 -1
  61. package/src/state_machine/index.ts +49 -12
  62. package/src/state_machine/mock_epoch_cache.ts +15 -11
  63. package/src/state_machine/synchronizer.ts +2 -2
  64. package/src/txe_session.ts +188 -109
  65. package/src/util/{txe_account_data_provider.ts → txe_account_store.ts} +1 -1
  66. package/src/util/{txe_contract_data_provider.ts → txe_contract_store.ts} +3 -3
  67. package/src/util/txe_public_contract_data_source.ts +9 -9
  68. package/src/utils/block_creation.ts +19 -16
  69. package/src/utils/tx_effect_creation.ts +3 -11
  70. package/dest/util/txe_account_data_provider.d.ts +0 -10
  71. package/dest/util/txe_account_data_provider.d.ts.map +0 -1
  72. package/dest/util/txe_contract_data_provider.d.ts +0 -12
  73. package/dest/util/txe_contract_data_provider.d.ts.map +0 -1
@@ -3,24 +3,26 @@ import { Fr } from '@aztec/foundation/curves/bn254';
3
3
  import { createLogger } from '@aztec/foundation/log';
4
4
  import { KeyStore } from '@aztec/key-store';
5
5
  import { openTmpStore } from '@aztec/kv-store/lmdb-v2';
6
- import { AddressDataProvider, CapsuleDataProvider, NoteDataProvider, NoteService, PrivateEventDataProvider, RecipientTaggingDataProvider, SenderTaggingDataProvider } from '@aztec/pxe/server';
7
- import { ExecutionNoteCache, ExecutionTaggingIndexCache, HashedValuesCache, PrivateExecutionOracle, UtilityExecutionOracle } from '@aztec/pxe/simulator';
8
- import { FunctionSelector } from '@aztec/stdlib/abi';
6
+ import { AddressStore, AnchorBlockStore, CapsuleStore, JobCoordinator, NoteService, NoteStore, PrivateEventStore, RecipientTaggingStore, SenderAddressBookStore, SenderTaggingStore } from '@aztec/pxe/server';
7
+ import { ExecutionNoteCache, ExecutionTaggingIndexCache, HashedValuesCache, Oracle, PrivateExecutionOracle, UtilityExecutionOracle } from '@aztec/pxe/simulator';
8
+ import { ExecutionError, WASMSimulator, createSimulationError, extractCallStack, resolveAssertionMessageFromError, toACVMWitness } from '@aztec/simulator/client';
9
+ import { FunctionSelector, FunctionType } from '@aztec/stdlib/abi';
9
10
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
10
11
  import { GasSettings } from '@aztec/stdlib/gas';
11
12
  import { computeProtocolNullifier } from '@aztec/stdlib/hash';
12
13
  import { makeGlobalVariables } from '@aztec/stdlib/testing';
13
14
  import { CallContext, TxContext } from '@aztec/stdlib/tx';
14
15
  import { z } from 'zod';
16
+ import { DEFAULT_ADDRESS } from './constants.js';
15
17
  import { TXEOraclePublicContext } from './oracle/txe_oracle_public_context.js';
16
18
  import { TXEOracleTopLevelContext } from './oracle/txe_oracle_top_level_context.js';
17
19
  import { RPCTranslator } from './rpc_translator.js';
20
+ import { TXEArchiver } from './state_machine/archiver.js';
18
21
  import { TXEStateMachine } from './state_machine/index.js';
19
- import { TXEAccountDataProvider } from './util/txe_account_data_provider.js';
20
- import { TXEContractDataProvider } from './util/txe_contract_data_provider.js';
22
+ import { TXEAccountStore } from './util/txe_account_store.js';
23
+ import { TXEContractStore } from './util/txe_contract_store.js';
21
24
  import { getSingleTxBlockRequestHash, insertTxEffectIntoWorldTrees, makeTXEBlock } from './utils/block_creation.js';
22
25
  import { makeTxEffect } from './utils/tx_effect_creation.js';
23
- export const DEFAULT_ADDRESS = AztecAddress.fromNumber(42);
24
26
  /**
25
27
  * A `TXESession` corresponds to a Noir `#[test]` function, and handles all of its oracle calls, stores test-specific
26
28
  * state, etc., independent of all other tests running in parallel.
@@ -28,33 +30,39 @@ export const DEFAULT_ADDRESS = AztecAddress.fromNumber(42);
28
30
  logger;
29
31
  stateMachine;
30
32
  oracleHandler;
31
- contractDataProvider;
32
- noteDataProvider;
33
+ contractStore;
34
+ noteStore;
33
35
  keyStore;
34
- addressDataProvider;
35
- accountDataProvider;
36
- senderTaggingDataProvider;
37
- recipientTaggingDataProvider;
38
- capsuleDataProvider;
39
- privateEventDataProvider;
36
+ addressStore;
37
+ accountStore;
38
+ senderTaggingStore;
39
+ recipientTaggingStore;
40
+ senderAddressBookStore;
41
+ capsuleStore;
42
+ privateEventStore;
43
+ jobCoordinator;
44
+ currentJobId;
40
45
  chainId;
41
46
  version;
42
47
  nextBlockTimestamp;
43
48
  state;
44
49
  authwits;
45
- constructor(logger, stateMachine, oracleHandler, contractDataProvider, noteDataProvider, keyStore, addressDataProvider, accountDataProvider, senderTaggingDataProvider, recipientTaggingDataProvider, capsuleDataProvider, privateEventDataProvider, chainId, version, nextBlockTimestamp){
50
+ constructor(logger, stateMachine, oracleHandler, contractStore, noteStore, keyStore, addressStore, accountStore, senderTaggingStore, recipientTaggingStore, senderAddressBookStore, capsuleStore, privateEventStore, jobCoordinator, currentJobId, chainId, version, nextBlockTimestamp){
46
51
  this.logger = logger;
47
52
  this.stateMachine = stateMachine;
48
53
  this.oracleHandler = oracleHandler;
49
- this.contractDataProvider = contractDataProvider;
50
- this.noteDataProvider = noteDataProvider;
54
+ this.contractStore = contractStore;
55
+ this.noteStore = noteStore;
51
56
  this.keyStore = keyStore;
52
- this.addressDataProvider = addressDataProvider;
53
- this.accountDataProvider = accountDataProvider;
54
- this.senderTaggingDataProvider = senderTaggingDataProvider;
55
- this.recipientTaggingDataProvider = recipientTaggingDataProvider;
56
- this.capsuleDataProvider = capsuleDataProvider;
57
- this.privateEventDataProvider = privateEventDataProvider;
57
+ this.addressStore = addressStore;
58
+ this.accountStore = accountStore;
59
+ this.senderTaggingStore = senderTaggingStore;
60
+ this.recipientTaggingStore = recipientTaggingStore;
61
+ this.senderAddressBookStore = senderAddressBookStore;
62
+ this.capsuleStore = capsuleStore;
63
+ this.privateEventStore = privateEventStore;
64
+ this.jobCoordinator = jobCoordinator;
65
+ this.currentJobId = currentJobId;
58
66
  this.chainId = chainId;
59
67
  this.version = version;
60
68
  this.nextBlockTimestamp = nextBlockTimestamp;
@@ -65,27 +73,40 @@ export const DEFAULT_ADDRESS = AztecAddress.fromNumber(42);
65
73
  }
66
74
  static async init(protocolContracts) {
67
75
  const store = await openTmpStore('txe-session');
68
- const addressDataProvider = new AddressDataProvider(store);
69
- const privateEventDataProvider = new PrivateEventDataProvider(store);
70
- const contractDataProvider = new TXEContractDataProvider(store);
71
- const noteDataProvider = await NoteDataProvider.create(store);
72
- const senderTaggingDataProvider = new SenderTaggingDataProvider(store);
73
- const recipientTaggingDataProvider = new RecipientTaggingDataProvider(store);
74
- const capsuleDataProvider = new CapsuleDataProvider(store);
76
+ const addressStore = new AddressStore(store);
77
+ const privateEventStore = new PrivateEventStore(store);
78
+ const contractStore = new TXEContractStore(store);
79
+ const noteStore = new NoteStore(store);
80
+ const senderTaggingStore = new SenderTaggingStore(store);
81
+ const recipientTaggingStore = new RecipientTaggingStore(store);
82
+ const senderAddressBookStore = new SenderAddressBookStore(store);
83
+ const capsuleStore = new CapsuleStore(store);
75
84
  const keyStore = new KeyStore(store);
76
- const accountDataProvider = new TXEAccountDataProvider(store);
85
+ const accountStore = new TXEAccountStore(store);
86
+ // Create job coordinator and register staged stores
87
+ const jobCoordinator = new JobCoordinator(store);
88
+ jobCoordinator.registerStores([
89
+ capsuleStore,
90
+ senderTaggingStore,
91
+ recipientTaggingStore,
92
+ privateEventStore,
93
+ noteStore
94
+ ]);
77
95
  // Register protocol contracts.
78
96
  for (const { contractClass, instance, artifact } of protocolContracts){
79
- await contractDataProvider.addContractArtifact(contractClass.id, artifact);
80
- await contractDataProvider.addContractInstance(instance);
97
+ await contractStore.addContractArtifact(contractClass.id, artifact);
98
+ await contractStore.addContractInstance(instance);
81
99
  }
82
- const stateMachine = await TXEStateMachine.create(store);
100
+ const archiver = new TXEArchiver(store);
101
+ const anchorBlockStore = new AnchorBlockStore(store);
102
+ const stateMachine = await TXEStateMachine.create(archiver, anchorBlockStore, contractStore, noteStore);
83
103
  const nextBlockTimestamp = BigInt(Math.floor(new Date().getTime() / 1000));
84
104
  const version = new Fr(await stateMachine.node.getVersion());
85
105
  const chainId = new Fr(await stateMachine.node.getChainId());
86
- const topLevelOracleHandler = new TXEOracleTopLevelContext(stateMachine, contractDataProvider, noteDataProvider, keyStore, addressDataProvider, accountDataProvider, senderTaggingDataProvider, recipientTaggingDataProvider, capsuleDataProvider, privateEventDataProvider, nextBlockTimestamp, version, chainId, new Map());
106
+ const initialJobId = jobCoordinator.beginJob();
107
+ const topLevelOracleHandler = new TXEOracleTopLevelContext(stateMachine, contractStore, noteStore, keyStore, addressStore, accountStore, senderTaggingStore, recipientTaggingStore, senderAddressBookStore, capsuleStore, privateEventStore, initialJobId, nextBlockTimestamp, version, chainId, new Map());
87
108
  await topLevelOracleHandler.txeAdvanceBlocksBy(1);
88
- return new TXESession(createLogger('txe:session'), stateMachine, topLevelOracleHandler, contractDataProvider, noteDataProvider, keyStore, addressDataProvider, accountDataProvider, senderTaggingDataProvider, recipientTaggingDataProvider, capsuleDataProvider, privateEventDataProvider, version, chainId, nextBlockTimestamp);
109
+ return new TXESession(createLogger('txe:session'), stateMachine, topLevelOracleHandler, contractStore, noteStore, keyStore, addressStore, accountStore, senderTaggingStore, recipientTaggingStore, senderAddressBookStore, capsuleStore, privateEventStore, jobCoordinator, initialJobId, version, chainId, nextBlockTimestamp);
89
110
  }
90
111
  /**
91
112
  * Processes an oracle function invoked by the Noir test associated to this session.
@@ -134,7 +155,10 @@ export const DEFAULT_ADDRESS = AztecAddress.fromNumber(42);
134
155
  this.state;
135
156
  }
136
157
  }
137
- this.oracleHandler = new TXEOracleTopLevelContext(this.stateMachine, this.contractDataProvider, this.noteDataProvider, this.keyStore, this.addressDataProvider, this.accountDataProvider, this.senderTaggingDataProvider, this.recipientTaggingDataProvider, this.capsuleDataProvider, this.privateEventDataProvider, this.nextBlockTimestamp, this.version, this.chainId, this.authwits);
158
+ // Commit all staged stores from the job that was just completed, then begin a new job
159
+ await this.jobCoordinator.commitJob(this.currentJobId);
160
+ this.currentJobId = this.jobCoordinator.beginJob();
161
+ this.oracleHandler = new TXEOracleTopLevelContext(this.stateMachine, this.contractStore, this.noteStore, this.keyStore, this.addressStore, this.accountStore, this.senderTaggingStore, this.recipientTaggingStore, this.senderAddressBookStore, this.capsuleStore, this.privateEventStore, this.currentJobId, this.nextBlockTimestamp, this.version, this.chainId, this.authwits);
138
162
  this.state = {
139
163
  name: 'TOP_LEVEL'
140
164
  };
@@ -142,16 +166,11 @@ export const DEFAULT_ADDRESS = AztecAddress.fromNumber(42);
142
166
  }
143
167
  async enterPrivateState(contractAddress = DEFAULT_ADDRESS, anchorBlockNumber) {
144
168
  this.exitTopLevelState();
145
- // There is no automatic message discovery and contract-driven syncing process in inlined private or utility
146
- // contexts, which means that known nullifiers are also not searched for, since it is during the tagging sync that
147
- // we perform this. We therefore search for known nullifiers now, as otherwise notes that were nullified would not
148
- // be removed from the database.
149
- // TODO(#12553): make the synchronizer sync here instead and remove this
150
- await new NoteService(this.noteDataProvider, this.stateMachine.node, this.stateMachine.anchorBlockDataProvider).syncNoteNullifiers(contractAddress);
151
169
  // Private execution has two associated block numbers: the anchor block (i.e. the historical block that is used to
152
170
  // build the proof), and the *next* block, i.e. the one we'll create once the execution ends, and which will contain
153
171
  // a single transaction with the effects of what was done in the test.
154
172
  const anchorBlock = await this.stateMachine.node.getBlockHeader(anchorBlockNumber ?? 'latest');
173
+ await new NoteService(this.noteStore, this.stateMachine.node, anchorBlock, this.currentJobId).syncNoteNullifiers(contractAddress);
155
174
  const latestBlock = await this.stateMachine.node.getBlockHeader('latest');
156
175
  const nextBlockGlobalVariables = makeGlobalVariables(undefined, {
157
176
  blockNumber: BlockNumber(latestBlock.globalVariables.blockNumber + 1),
@@ -163,7 +182,31 @@ export const DEFAULT_ADDRESS = AztecAddress.fromNumber(42);
163
182
  const protocolNullifier = await computeProtocolNullifier(txRequestHash);
164
183
  const noteCache = new ExecutionNoteCache(protocolNullifier);
165
184
  const taggingIndexCache = new ExecutionTaggingIndexCache();
166
- this.oracleHandler = new PrivateExecutionOracle(Fr.ZERO, new TxContext(this.chainId, this.version, GasSettings.empty()), new CallContext(AztecAddress.ZERO, contractAddress, FunctionSelector.empty(), false), anchorBlock, [], [], new HashedValuesCache(), noteCache, taggingIndexCache, this.contractDataProvider, this.noteDataProvider, this.keyStore, this.addressDataProvider, this.stateMachine.node, this.stateMachine.anchorBlockDataProvider, this.senderTaggingDataProvider, this.recipientTaggingDataProvider, this.capsuleDataProvider, this.privateEventDataProvider);
185
+ const utilityExecutor = this.utilityExecutorForContractSync(anchorBlock);
186
+ this.oracleHandler = new PrivateExecutionOracle({
187
+ argsHash: Fr.ZERO,
188
+ txContext: new TxContext(this.chainId, this.version, GasSettings.empty()),
189
+ callContext: new CallContext(AztecAddress.ZERO, contractAddress, FunctionSelector.empty(), false),
190
+ anchorBlockHeader: anchorBlock,
191
+ utilityExecutor,
192
+ authWitnesses: [],
193
+ capsules: [],
194
+ executionCache: new HashedValuesCache(),
195
+ noteCache,
196
+ taggingIndexCache,
197
+ contractStore: this.contractStore,
198
+ noteStore: this.noteStore,
199
+ keyStore: this.keyStore,
200
+ addressStore: this.addressStore,
201
+ aztecNode: this.stateMachine.node,
202
+ senderTaggingStore: this.senderTaggingStore,
203
+ recipientTaggingStore: this.recipientTaggingStore,
204
+ senderAddressBookStore: this.senderAddressBookStore,
205
+ capsuleStore: this.capsuleStore,
206
+ privateEventStore: this.privateEventStore,
207
+ contractSyncService: this.stateMachine.contractSyncService,
208
+ jobId: this.currentJobId
209
+ });
167
210
  // We store the note and tagging index caches fed into the PrivateExecutionOracle (along with some other auxiliary
168
211
  // data) in order to refer to it later, mimicking the way this object is used by the ContractFunctionSimulator. The
169
212
  // difference resides in that the simulator has all information needed in order to run the simulation, while ours
@@ -172,7 +215,6 @@ export const DEFAULT_ADDRESS = AztecAddress.fromNumber(42);
172
215
  this.state = {
173
216
  name: 'PRIVATE',
174
217
  nextBlockGlobalVariables,
175
- protocolNullifier,
176
218
  noteCache,
177
219
  taggingIndexCache
178
220
  };
@@ -198,14 +240,29 @@ export const DEFAULT_ADDRESS = AztecAddress.fromNumber(42);
198
240
  }
199
241
  async enterUtilityState(contractAddress = DEFAULT_ADDRESS) {
200
242
  this.exitTopLevelState();
243
+ const anchorBlockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
201
244
  // There is no automatic message discovery and contract-driven syncing process in inlined private or utility
202
245
  // contexts, which means that known nullifiers are also not searched for, since it is during the tagging sync that
203
246
  // we perform this. We therefore search for known nullifiers now, as otherwise notes that were nullified would not
204
247
  // be removed from the database.
205
248
  // TODO(#12553): make the synchronizer sync here instead and remove this
206
- await new NoteService(this.noteDataProvider, this.stateMachine.node, this.stateMachine.anchorBlockDataProvider).syncNoteNullifiers(contractAddress);
207
- const anchorBlockHeader = await this.stateMachine.anchorBlockDataProvider.getBlockHeader();
208
- this.oracleHandler = new UtilityExecutionOracle(contractAddress, [], [], anchorBlockHeader, this.contractDataProvider, this.noteDataProvider, this.keyStore, this.addressDataProvider, this.stateMachine.node, this.stateMachine.anchorBlockDataProvider, this.senderTaggingDataProvider, this.recipientTaggingDataProvider, this.capsuleDataProvider, this.privateEventDataProvider);
249
+ await new NoteService(this.noteStore, this.stateMachine.node, anchorBlockHeader, this.currentJobId).syncNoteNullifiers(contractAddress);
250
+ this.oracleHandler = new UtilityExecutionOracle({
251
+ contractAddress,
252
+ authWitnesses: [],
253
+ capsules: [],
254
+ anchorBlockHeader,
255
+ contractStore: this.contractStore,
256
+ noteStore: this.noteStore,
257
+ keyStore: this.keyStore,
258
+ addressStore: this.addressStore,
259
+ aztecNode: this.stateMachine.node,
260
+ recipientTaggingStore: this.recipientTaggingStore,
261
+ senderAddressBookStore: this.senderAddressBookStore,
262
+ capsuleStore: this.capsuleStore,
263
+ privateEventStore: this.privateEventStore,
264
+ jobId: this.currentJobId
265
+ });
209
266
  this.state = {
210
267
  name: 'UTILITY'
211
268
  };
@@ -235,7 +292,7 @@ export const DEFAULT_ADDRESS = AztecAddress.fromNumber(42);
235
292
  });
236
293
  // We rely on the note cache to determine the effects of the transaction. This is incomplete as it doesn't private
237
294
  // logs (other effects like enqueued public calls don't need to be considered since those are not allowed).
238
- const txEffect = await makeTxEffect(this.state.noteCache, this.state.protocolNullifier, this.state.nextBlockGlobalVariables.blockNumber);
295
+ const txEffect = await makeTxEffect(this.state.noteCache, this.state.nextBlockGlobalVariables.blockNumber);
239
296
  // We build a block holding just this transaction
240
297
  const forkedWorldTrees = await this.stateMachine.synchronizer.nativeWorldStateService.fork();
241
298
  await insertTxEffectIntoWorldTrees(txEffect, forkedWorldTrees);
@@ -261,4 +318,42 @@ export const DEFAULT_ADDRESS = AztecAddress.fromNumber(42);
261
318
  throw new Error(`Expected to be in state 'UTILITY', but got '${this.state.name}' instead`);
262
319
  }
263
320
  }
321
+ utilityExecutorForContractSync(anchorBlock) {
322
+ return async (call, scopes)=>{
323
+ const entryPointArtifact = await this.contractStore.getFunctionArtifactWithDebugMetadata(call.to, call.selector);
324
+ if (entryPointArtifact.functionType !== FunctionType.UTILITY) {
325
+ throw new Error(`Cannot run ${entryPointArtifact.functionType} function as utility`);
326
+ }
327
+ try {
328
+ const oracle = new UtilityExecutionOracle({
329
+ contractAddress: call.to,
330
+ authWitnesses: [],
331
+ capsules: [],
332
+ anchorBlockHeader: anchorBlock,
333
+ contractStore: this.contractStore,
334
+ noteStore: this.noteStore,
335
+ keyStore: this.keyStore,
336
+ addressStore: this.addressStore,
337
+ aztecNode: this.stateMachine.node,
338
+ recipientTaggingStore: this.recipientTaggingStore,
339
+ senderAddressBookStore: this.senderAddressBookStore,
340
+ capsuleStore: this.capsuleStore,
341
+ privateEventStore: this.privateEventStore,
342
+ jobId: this.currentJobId,
343
+ scopes
344
+ });
345
+ await new WASMSimulator().executeUserCircuit(toACVMWitness(0, call.args), entryPointArtifact, new Oracle(oracle).toACIRCallback()).catch((err)=>{
346
+ err.message = resolveAssertionMessageFromError(err, entryPointArtifact);
347
+ throw new ExecutionError(err.message, {
348
+ contractAddress: call.to,
349
+ functionSelector: call.selector
350
+ }, extractCallStack(err, entryPointArtifact.debug), {
351
+ cause: err
352
+ });
353
+ });
354
+ } catch (err) {
355
+ throw createSimulationError(err instanceof Error ? err : new Error('Unknown error contract data sync'));
356
+ }
357
+ };
358
+ }
264
359
  }
@@ -150,7 +150,7 @@ export declare const ForeignCallArgsSchema: z.ZodArray<z.ZodUnion<[z.ZodString,
150
150
  error_kind: "custom";
151
151
  } & import("@aztec/stdlib/abi").AbiType) | undefined>;
152
152
  }>, z.ZodObject<{
153
- bytecode: import("../../../foundation/dest/schemas/types.js").ZodFor<Buffer<ArrayBufferLike>>;
153
+ bytecode: import("@aztec/foundation/schemas").ZodFor<Buffer<ArrayBufferLike>>;
154
154
  verificationKey: z.ZodOptional<z.ZodString>;
155
155
  debugSymbols: z.ZodString;
156
156
  debug: z.ZodOptional<z.ZodObject<{
@@ -656,27 +656,27 @@ export declare const ForeignCallArgsSchema: z.ZodArray<z.ZodUnion<[z.ZodString,
656
656
  }>;
657
657
  }>, z.ZodIntersection<z.ZodObject<{
658
658
  version: z.ZodLiteral<1>;
659
- salt: import("../../../foundation/dest/schemas/types.js").ZodFor<Fr>;
660
- deployer: import("../../../foundation/dest/schemas/types.js").ZodFor<AztecAddress>;
661
- currentContractClassId: import("../../../foundation/dest/schemas/types.js").ZodFor<Fr>;
662
- originalContractClassId: import("../../../foundation/dest/schemas/types.js").ZodFor<Fr>;
663
- initializationHash: import("../../../foundation/dest/schemas/types.js").ZodFor<Fr>;
659
+ salt: import("@aztec/foundation/schemas").ZodFor<Fr>;
660
+ deployer: import("@aztec/foundation/schemas").ZodFor<AztecAddress>;
661
+ currentContractClassId: import("@aztec/foundation/schemas").ZodFor<Fr>;
662
+ originalContractClassId: import("@aztec/foundation/schemas").ZodFor<Fr>;
663
+ initializationHash: import("@aztec/foundation/schemas").ZodFor<Fr>;
664
664
  publicKeys: z.ZodEffects<z.ZodObject<{
665
- masterNullifierPublicKey: z.ZodType<import("../../../foundation/dest/schemas/schemas.js").Point, any, string>;
666
- masterIncomingViewingPublicKey: z.ZodType<import("../../../foundation/dest/schemas/schemas.js").Point, any, string>;
667
- masterOutgoingViewingPublicKey: z.ZodType<import("../../../foundation/dest/schemas/schemas.js").Point, any, string>;
668
- masterTaggingPublicKey: z.ZodType<import("../../../foundation/dest/schemas/schemas.js").Point, any, string>;
665
+ masterNullifierPublicKey: z.ZodType<import("@aztec/foundation/schemas").Point, any, string>;
666
+ masterIncomingViewingPublicKey: z.ZodType<import("@aztec/foundation/schemas").Point, any, string>;
667
+ masterOutgoingViewingPublicKey: z.ZodType<import("@aztec/foundation/schemas").Point, any, string>;
668
+ masterTaggingPublicKey: z.ZodType<import("@aztec/foundation/schemas").Point, any, string>;
669
669
  }, "strip", z.ZodTypeAny, {
670
- masterNullifierPublicKey: import("../../../foundation/dest/schemas/schemas.js").Point;
671
- masterIncomingViewingPublicKey: import("../../../foundation/dest/schemas/schemas.js").Point;
672
- masterOutgoingViewingPublicKey: import("../../../foundation/dest/schemas/schemas.js").Point;
673
- masterTaggingPublicKey: import("../../../foundation/dest/schemas/schemas.js").Point;
670
+ masterNullifierPublicKey: import("@aztec/foundation/schemas").Point;
671
+ masterIncomingViewingPublicKey: import("@aztec/foundation/schemas").Point;
672
+ masterOutgoingViewingPublicKey: import("@aztec/foundation/schemas").Point;
673
+ masterTaggingPublicKey: import("@aztec/foundation/schemas").Point;
674
674
  }, {
675
675
  masterNullifierPublicKey: string;
676
676
  masterIncomingViewingPublicKey: string;
677
677
  masterOutgoingViewingPublicKey: string;
678
678
  masterTaggingPublicKey: string;
679
- }>, import("../../../stdlib/dest/keys/public_keys.js").PublicKeys, {
679
+ }>, import("@aztec/stdlib/keys").PublicKeys, {
680
680
  masterNullifierPublicKey: string;
681
681
  masterIncomingViewingPublicKey: string;
682
682
  masterOutgoingViewingPublicKey: string;
@@ -689,7 +689,7 @@ export declare const ForeignCallArgsSchema: z.ZodArray<z.ZodUnion<[z.ZodString,
689
689
  currentContractClassId: Fr;
690
690
  originalContractClassId: Fr;
691
691
  initializationHash: Fr;
692
- publicKeys: import("../../../stdlib/dest/keys/public_keys.js").PublicKeys;
692
+ publicKeys: import("@aztec/stdlib/keys").PublicKeys;
693
693
  }, {
694
694
  version: 1;
695
695
  salt?: any;
@@ -704,7 +704,7 @@ export declare const ForeignCallArgsSchema: z.ZodArray<z.ZodUnion<[z.ZodString,
704
704
  masterTaggingPublicKey: string;
705
705
  };
706
706
  }>, z.ZodObject<{
707
- address: import("../../../foundation/dest/schemas/types.js").ZodFor<AztecAddress>;
707
+ address: import("@aztec/foundation/schemas").ZodFor<AztecAddress>;
708
708
  }, "strip", z.ZodTypeAny, {
709
709
  address: AztecAddress;
710
710
  }, {
@@ -0,0 +1,10 @@
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 TXEAccountStore {
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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHhlX2FjY291bnRfc3RvcmUuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy91dGlsL3R4ZV9hY2NvdW50X3N0b3JlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sS0FBSyxFQUFFLGlCQUFpQixFQUFpQixNQUFNLGlCQUFpQixDQUFDO0FBQ3hFLE9BQU8sS0FBSyxFQUFFLFlBQVksRUFBRSxNQUFNLDZCQUE2QixDQUFDO0FBQ2hFLE9BQU8sRUFBRSxlQUFlLEVBQUUsTUFBTSx3QkFBd0IsQ0FBQztBQUV6RCxxQkFBYSxlQUFlOztJQUcxQixZQUFZLEtBQUssRUFBRSxpQkFBaUIsRUFFbkM7SUFFSyxVQUFVLENBQUMsR0FBRyxFQUFFLFlBQVksNEJBTWpDO0lBRUssVUFBVSxDQUFDLEdBQUcsRUFBRSxZQUFZLEVBQUUsS0FBSyxFQUFFLGVBQWUsaUJBRXpEO0NBQ0YifQ==
@@ -0,0 +1 @@
1
+ {"version":3,"file":"txe_account_store.d.ts","sourceRoot":"","sources":["../../src/util/txe_account_store.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,eAAe;;IAG1B,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,5 +1,5 @@
1
1
  import { CompleteAddress } from '@aztec/stdlib/contract';
2
- export class TXEAccountDataProvider {
2
+ export class TXEAccountStore {
3
3
  #accounts;
4
4
  constructor(store){
5
5
  this.#accounts = store.openMap('accounts');
@@ -0,0 +1,12 @@
1
+ import type { ContractArtifact } from '@aztec/aztec.js/abi';
2
+ import { Fr } from '@aztec/aztec.js/fields';
3
+ import { ContractStore } from '@aztec/pxe/server';
4
+ export type ContractArtifactWithHash = ContractArtifact & {
5
+ artifactHash: Fr;
6
+ };
7
+ export declare class TXEContractStore extends ContractStore {
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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHhlX2NvbnRyYWN0X3N0b3JlLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvdXRpbC90eGVfY29udHJhY3Rfc3RvcmUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxLQUFLLEVBQUUsZ0JBQWdCLEVBQUUsTUFBTSxxQkFBcUIsQ0FBQztBQUM1RCxPQUFPLEVBQUUsRUFBRSxFQUFFLE1BQU0sd0JBQXdCLENBQUM7QUFDNUMsT0FBTyxFQUFFLGFBQWEsRUFBRSxNQUFNLG1CQUFtQixDQUFDO0FBRWxELE1BQU0sTUFBTSx3QkFBd0IsR0FBRyxnQkFBZ0IsR0FBRztJQUFFLFlBQVksRUFBRSxFQUFFLENBQUE7Q0FBRSxDQUFDO0FBTy9FLHFCQUFhLGdCQUFpQixTQUFRLGFBQWE7O0lBRzNCLG1CQUFtQixDQUN2QyxFQUFFLEVBQUUsRUFBRSxFQUNOLFFBQVEsRUFBRSxnQkFBZ0IsR0FBRyx3QkFBd0IsR0FDcEQsT0FBTyxDQUFDLElBQUksQ0FBQyxDQUtmO0lBRXFCLG1CQUFtQixDQUN2QyxlQUFlLEVBQUUsRUFBRSxHQUNsQixPQUFPLENBQUMsZ0JBQWdCLEdBQUcsd0JBQXdCLEdBQUcsU0FBUyxDQUFDLENBUWxFO0NBQ0YifQ==
@@ -0,0 +1 @@
1
+ {"version":3,"file":"txe_contract_store.d.ts","sourceRoot":"","sources":["../../src/util/txe_contract_store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,EAAE,EAAE,MAAM,wBAAwB,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAElD,MAAM,MAAM,wBAAwB,GAAG,gBAAgB,GAAG;IAAE,YAAY,EAAE,EAAE,CAAA;CAAE,CAAC;AAO/E,qBAAa,gBAAiB,SAAQ,aAAa;;IAG3B,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"}
@@ -1,10 +1,10 @@
1
1
  import { Fr } from '@aztec/aztec.js/fields';
2
- import { ContractDataProvider } from '@aztec/pxe/server';
2
+ import { ContractStore } from '@aztec/pxe/server';
3
3
  /*
4
- * A contract data provider that stores contract artifacts with their hashes. Since
4
+ * A contract store that stores contract artifacts with their hashes. Since
5
5
  * TXE typically deploys the same contract again and again for multiple tests, caching
6
6
  * the *very* expensive artifact hash computation improves testing speed significantly.
7
- */ export class TXEContractDataProvider extends ContractDataProvider {
7
+ */ export class TXEContractStore extends ContractStore {
8
8
  #artifactHashes = new Map();
9
9
  async addContractArtifact(id, artifact) {
10
10
  if ('artifactHash' in artifact) {
@@ -1,14 +1,14 @@
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 } from '@aztec/stdlib/abi';
5
5
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
6
6
  import { type ContractClassPublic, type ContractDataSource, type ContractInstanceWithAddress } from '@aztec/stdlib/contract';
7
7
  export declare class TXEPublicContractDataSource implements ContractDataSource {
8
8
  #private;
9
9
  private blockNumber;
10
- private contractDataProvider;
11
- constructor(blockNumber: BlockNumber, contractDataProvider: ContractDataProvider);
10
+ private contractStore;
11
+ constructor(blockNumber: BlockNumber, contractStore: ContractStore);
12
12
  getBlockNumber(): Promise<BlockNumber>;
13
13
  getContractClass(id: Fr): Promise<ContractClassPublic | undefined>;
14
14
  getBytecodeCommitment(id: Fr): Promise<Fr | undefined>;
@@ -18,4 +18,4 @@ export declare class TXEPublicContractDataSource implements ContractDataSource {
18
18
  getDebugFunctionName(address: AztecAddress, selector: FunctionSelector): Promise<string | undefined>;
19
19
  registerContractFunctionSignatures(_signatures: []): Promise<void>;
20
20
  }
21
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHhlX3B1YmxpY19jb250cmFjdF9kYXRhX3NvdXJjZS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3V0aWwvdHhlX3B1YmxpY19jb250cmFjdF9kYXRhX3NvdXJjZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsV0FBVyxF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UFDbkIsT0FBTyxDQUFDLGFBQWE7SUFGdkIsWUFDVSxXQUFXLEVBQUUsV0FBVyxFQUN4QixhQUFhLEVBQUUsYUFBYSxFQUNsQztJQUVKLGNBQWMsSUFBSSxPQUFPLENBQUMsV0FBVyxDQUFDLENBRXJDO0lBRUssZ0JBQWdCLENBQUMsRUFBRSxFQUFFLEVBQUUsR0FBRyxPQUFPLENBQUMsbUJBQW1CLEdBQUcsU0FBUyxDQUFDLENBZ0N2RTtJQUVLLHFCQUFxQixDQUFDLEVBQUUsRUFBRSxFQUFFLEdBQUcsT0FBTyxDQUFDLEVBQUUsR0FBRyxTQUFTLENBQUMsQ0FHM0Q7SUFFSyxXQUFXLENBQUMsT0FBTyxFQUFFLFlBQVksR0FBRyxPQUFPLENBQUMsMkJBQTJCLEdBQUcsU0FBUyxDQUFDLENBR3pGO0lBRUQsbUJBQW1CLElBQUksT0FBTyxDQUFDLEVBQUUsRUFBRSxDQUFDLENBRW5DO0lBRUssbUJBQW1CLENBQUMsT0FBTyxFQUFFLFlBQVksR0FBRyxPQUFPLENBQUMsZ0JBQWdCLEdBQUcsU0FBUyxDQUFDLENBR3RGO0lBRUssb0JBQW9CLENBQUMsT0FBTyxFQUFFLFlBQVksRUFBRSxRQUFRLEVBQUUsZ0JBQWdCLEdBQUcsT0FBTyxDQUFDLE1BQU0sR0FBRyxTQUFTLENBQUMsQ0FFekc7SUFFRCxrQ0FBa0MsQ0FBQyxXQUFXLEVBQUUsRUFBRSxHQUFHLE9BQU8sQ0FBQyxJQUFJLENBQUMsQ0FFakU7Q0FDRiJ9
@@ -1 +1 @@
1
- {"version":3,"file":"txe_public_contract_data_source.d.ts","sourceRoot":"","sources":["../../src/util/txe_public_contract_data_source.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACpD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAA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FromArtifact } from '@aztec/stdlib/contract';
4
4
  export class TXEPublicContractDataSource {
5
5
  blockNumber;
6
- contractDataProvider;
6
+ contractStore;
7
7
  #privateFunctionsRoot;
8
- constructor(blockNumber, contractDataProvider){
8
+ constructor(blockNumber, contractStore){
9
9
  this.blockNumber = blockNumber;
10
- this.contractDataProvider = contractDataProvider;
10
+ this.contractStore = contractStore;
11
11
  this.#privateFunctionsRoot = new Map();
12
12
  }
13
13
  getBlockNumber() {
14
14
  return Promise.resolve(this.blockNumber);
15
15
  }
16
16
  async getContractClass(id) {
17
- const contractClass = await this.contractDataProvider.getContractClass(id);
17
+ const contractClass = await this.contractStore.getContractClass(id);
18
18
  if (!contractClass) {
19
19
  return;
20
20
  }
21
- const artifact = await this.contractDataProvider.getContractArtifact(id);
21
+ const artifact = await this.contractStore.getContractArtifact(id);
22
22
  if (!artifact) {
23
23
  return;
24
24
  }
@@ -41,11 +41,11 @@ export class TXEPublicContractDataSource {
41
41
  };
42
42
  }
43
43
  async getBytecodeCommitment(id) {
44
- const contractClass = await this.contractDataProvider.getContractClass(id);
44
+ const contractClass = await this.contractStore.getContractClass(id);
45
45
  return contractClass && computePublicBytecodeCommitment(contractClass.packedBytecode);
46
46
  }
47
47
  async getContract(address) {
48
- const instance = await this.contractDataProvider.getContractInstance(address);
48
+ const instance = await this.contractStore.getContractInstance(address);
49
49
  return instance && {
50
50
  ...instance,
51
51
  address
@@ -55,11 +55,11 @@ export class TXEPublicContractDataSource {
55
55
  throw new Error('Method not implemented.');
56
56
  }
57
57
  async getContractArtifact(address) {
58
- const instance = await this.contractDataProvider.getContractInstance(address);
59
- return instance && this.contractDataProvider.getContractArtifact(instance.currentContractClassId);
58
+ const instance = await this.contractStore.getContractInstance(address);
59
+ return instance && this.contractStore.getContractArtifact(instance.currentContractClassId);
60
60
  }
61
61
  async getDebugFunctionName(address, selector) {
62
- return await this.contractDataProvider.getDebugFunctionName(address, selector);
62
+ return await this.contractStore.getDebugFunctionName(address, selector);
63
63
  }
64
64
  registerContractFunctionSignatures(_signatures) {
65
65
  return Promise.resolve();
@@ -1,8 +1,8 @@
1
1
  import { BlockNumber } from '@aztec/foundation/branded-types';
2
2
  import { Fr } from '@aztec/foundation/curves/bn254';
3
- import { L2Block, L2BlockHeader } from '@aztec/stdlib/block';
3
+ import { L2Block } from '@aztec/stdlib/block';
4
4
  import { type MerkleTreeWriteOperations } from '@aztec/stdlib/trees';
5
- import { GlobalVariables, TxEffect } from '@aztec/stdlib/tx';
5
+ import { BlockHeader, GlobalVariables, TxEffect } from '@aztec/stdlib/tx';
6
6
  /**
7
7
  * Returns a transaction request hash that is valid for transactions that are the only ones in a block.
8
8
  * @param blockNumber The number for the block in which there is a single transaction.
@@ -10,7 +10,7 @@ import { GlobalVariables, TxEffect } from '@aztec/stdlib/tx';
10
10
  */
11
11
  export declare function getSingleTxBlockRequestHash(blockNumber: BlockNumber): Fr;
12
12
  export declare function insertTxEffectIntoWorldTrees(txEffect: TxEffect, worldTrees: MerkleTreeWriteOperations): Promise<void>;
13
- export declare function makeTXEBlockHeader(worldTrees: MerkleTreeWriteOperations, globalVariables: GlobalVariables): Promise<L2BlockHeader>;
13
+ export declare function makeTXEBlockHeader(worldTrees: MerkleTreeWriteOperations, globalVariables: GlobalVariables): Promise<BlockHeader>;
14
14
  /**
15
15
  * Creates an L2Block with proper archive chaining.
16
16
  * This function:
@@ -25,4 +25,4 @@ export declare function makeTXEBlockHeader(worldTrees: MerkleTreeWriteOperations
25
25
  * @returns The created L2Block with proper archive chaining
26
26
  */
27
27
  export declare function makeTXEBlock(worldTrees: MerkleTreeWriteOperations, globalVariables: GlobalVariables, txEffects: TxEffect[]): Promise<L2Block>;
28
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYmxvY2tfY3JlYXRpb24uZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy91dGlscy9ibG9ja19jcmVhdGlvbi50cyJdL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C,OAAO,CAAC,IAAI,CAAC,CAkBf;AAED,wBAAsB,kBAAkB,CACtC,UAAU,EAAE,yBAAyB,EACrC,eAAe,EAAE,eAAe,GAC/B,OAAO,CAAC,WAAW,CAAC,CAYtB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,YAAY,CAChC,UAAU,EAAE,yBAAyB,EACrC,eAAe,EAAE,eAAe,EAChC,SAAS,EAAE,QAAQ,EAAE,GACpB,OAAO,CAAC,OAAO,CAAC,CAiBlB"}
@@ -1,9 +1,10 @@
1
1
  import { MAX_NOTE_HASHES_PER_TX, MAX_NULLIFIERS_PER_TX, NULLIFIER_SUBTREE_HEIGHT, NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP } from '@aztec/constants';
2
+ import { CheckpointNumber, IndexWithinCheckpoint } from '@aztec/foundation/branded-types';
2
3
  import { padArrayEnd } from '@aztec/foundation/collection';
3
4
  import { Fr } from '@aztec/foundation/curves/bn254';
4
- import { Body, L2Block, L2BlockHeader } from '@aztec/stdlib/block';
5
- import { makeContentCommitment } from '@aztec/stdlib/testing';
5
+ import { Body, L2Block } from '@aztec/stdlib/block';
6
6
  import { AppendOnlyTreeSnapshot, MerkleTreeId } from '@aztec/stdlib/trees';
7
+ import { BlockHeader } from '@aztec/stdlib/tx';
7
8
  /**
8
9
  * Returns a transaction request hash that is valid for transactions that are the only ones in a block.
9
10
  * @param blockNumber The number for the block in which there is a single transaction.
@@ -20,7 +21,14 @@ export async function insertTxEffectIntoWorldTrees(txEffect, worldTrees) {
20
21
  export async function makeTXEBlockHeader(worldTrees, globalVariables) {
21
22
  const stateReference = await worldTrees.getStateReference();
22
23
  const archiveInfo = await worldTrees.getTreeInfo(MerkleTreeId.ARCHIVE);
23
- return new L2BlockHeader(new AppendOnlyTreeSnapshot(new Fr(archiveInfo.root), Number(archiveInfo.size)), makeContentCommitment(), stateReference, globalVariables, Fr.ZERO, Fr.ZERO, Fr.ZERO, Fr.ZERO);
24
+ return BlockHeader.from({
25
+ lastArchive: new AppendOnlyTreeSnapshot(new Fr(archiveInfo.root), Number(archiveInfo.size)),
26
+ spongeBlobHash: Fr.ZERO,
27
+ state: stateReference,
28
+ globalVariables,
29
+ totalFees: Fr.ZERO,
30
+ totalManaUsed: Fr.ZERO
31
+ });
24
32
  }
25
33
  /**
26
34
  * Creates an L2Block with proper archive chaining.
@@ -37,9 +45,14 @@ export async function makeTXEBlockHeader(worldTrees, globalVariables) {
37
45
  */ export async function makeTXEBlock(worldTrees, globalVariables, txEffects) {
38
46
  const header = await makeTXEBlockHeader(worldTrees, globalVariables);
39
47
  // Update the archive tree with this block's header hash
40
- await worldTrees.updateArchive(header.toBlockHeader());
48
+ await worldTrees.updateArchive(header);
41
49
  // Get the new archive state after updating
42
50
  const newArchiveInfo = await worldTrees.getTreeInfo(MerkleTreeId.ARCHIVE);
43
51
  const newArchive = new AppendOnlyTreeSnapshot(new Fr(newArchiveInfo.root), Number(newArchiveInfo.size));
44
- return new L2Block(newArchive, header, new Body(txEffects));
52
+ // L2Block requires checkpointNumber and indexWithinCheckpoint.
53
+ // TXE uses 1-block-per-checkpoint for testing simplicity, so we can use block number as checkpoint number.
54
+ // This uses the deprecated fromBlockNumber method intentionally for the TXE testing environment.
55
+ const checkpointNumber = CheckpointNumber.fromBlockNumber(globalVariables.blockNumber);
56
+ const indexWithinCheckpoint = IndexWithinCheckpoint(0);
57
+ return new L2Block(newArchive, header, new Body(txEffects), checkpointNumber, indexWithinCheckpoint);
45
58
  }