@aztec/txe 0.0.1-commit.c7c42ec → 0.0.1-commit.c80b6263

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 (56) 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 +4 -2
  10. package/dest/oracle/txe_oracle_top_level_context.d.ts.map +1 -1
  11. package/dest/oracle/txe_oracle_top_level_context.js +44 -28
  12. package/dest/rpc_translator.d.ts +16 -10
  13. package/dest/rpc_translator.d.ts.map +1 -1
  14. package/dest/rpc_translator.js +52 -39
  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 +57 -178
  18. package/dest/state_machine/dummy_p2p_client.d.ts +8 -7
  19. package/dest/state_machine/dummy_p2p_client.d.ts.map +1 -1
  20. package/dest/state_machine/dummy_p2p_client.js +13 -10
  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 +1 -1
  25. package/dest/state_machine/index.d.ts.map +1 -1
  26. package/dest/state_machine/index.js +22 -4
  27. package/dest/state_machine/mock_epoch_cache.d.ts +7 -6
  28. package/dest/state_machine/mock_epoch_cache.d.ts.map +1 -1
  29. package/dest/state_machine/mock_epoch_cache.js +10 -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 +6 -4
  33. package/dest/txe_session.d.ts.map +1 -1
  34. package/dest/txe_session.js +55 -20
  35. package/dest/util/encoding.d.ts +17 -17
  36. package/dest/utils/block_creation.d.ts +4 -4
  37. package/dest/utils/block_creation.d.ts.map +1 -1
  38. package/dest/utils/block_creation.js +16 -5
  39. package/dest/utils/tx_effect_creation.d.ts +2 -3
  40. package/dest/utils/tx_effect_creation.d.ts.map +1 -1
  41. package/dest/utils/tx_effect_creation.js +3 -6
  42. package/package.json +16 -16
  43. package/src/constants.ts +3 -0
  44. package/src/oracle/interfaces.ts +2 -2
  45. package/src/oracle/txe_oracle_public_context.ts +6 -8
  46. package/src/oracle/txe_oracle_top_level_context.ts +77 -27
  47. package/src/rpc_translator.ts +56 -49
  48. package/src/state_machine/archiver.ts +52 -220
  49. package/src/state_machine/dummy_p2p_client.ts +18 -13
  50. package/src/state_machine/global_variable_builder.ts +1 -1
  51. package/src/state_machine/index.ts +26 -4
  52. package/src/state_machine/mock_epoch_cache.ts +10 -11
  53. package/src/state_machine/synchronizer.ts +2 -2
  54. package/src/txe_session.ts +88 -16
  55. package/src/utils/block_creation.ts +17 -16
  56. package/src/utils/tx_effect_creation.ts +3 -11
@@ -1,11 +1,14 @@
1
1
  import { type AztecNodeConfig, AztecNodeService } from '@aztec/aztec-node';
2
2
  import { TestCircuitVerifier } from '@aztec/bb-prover/test';
3
+ import { CheckpointNumber } from '@aztec/foundation/branded-types';
4
+ import { Fr } from '@aztec/foundation/curves/bn254';
3
5
  import { createLogger } from '@aztec/foundation/log';
4
6
  import type { AztecAsyncKVStore } from '@aztec/kv-store';
5
7
  import { AnchorBlockStore } from '@aztec/pxe/server';
6
8
  import { L2Block } from '@aztec/stdlib/block';
7
- import { L1PublishedData, PublishedCheckpoint } from '@aztec/stdlib/checkpoint';
9
+ import { Checkpoint, L1PublishedData, PublishedCheckpoint } from '@aztec/stdlib/checkpoint';
8
10
  import type { AztecNode } from '@aztec/stdlib/interfaces/client';
11
+ import { CheckpointHeader } from '@aztec/stdlib/rollup';
9
12
  import { getPackageVersion } from '@aztec/stdlib/update-checker';
10
13
 
11
14
  import { TXEArchiver } from './archiver.js';
@@ -59,7 +62,26 @@ export class TXEStateMachine {
59
62
  }
60
63
 
61
64
  public async handleL2Block(block: L2Block) {
62
- const checkpoint = block.toCheckpoint();
65
+ // Create a checkpoint from the block manually
66
+ const checkpoint = new Checkpoint(
67
+ block.archive,
68
+ CheckpointHeader.from({
69
+ lastArchiveRoot: block.header.lastArchive.root,
70
+ inHash: Fr.ZERO,
71
+ blobsHash: Fr.ZERO,
72
+ blockHeadersHash: Fr.ZERO,
73
+ epochOutHash: Fr.ZERO,
74
+ slotNumber: block.header.globalVariables.slotNumber,
75
+ timestamp: block.header.globalVariables.timestamp,
76
+ coinbase: block.header.globalVariables.coinbase,
77
+ feeRecipient: block.header.globalVariables.feeRecipient,
78
+ gasFees: block.header.globalVariables.gasFees,
79
+ totalManaUsed: block.header.totalManaUsed,
80
+ }),
81
+ [block],
82
+ CheckpointNumber.fromBlockNumber(block.number),
83
+ );
84
+
63
85
  const publishedCheckpoint = new PublishedCheckpoint(
64
86
  checkpoint,
65
87
  new L1PublishedData(
@@ -70,9 +92,9 @@ export class TXEStateMachine {
70
92
  [],
71
93
  );
72
94
  await Promise.all([
73
- this.synchronizer.handleL2Block(block.toL2Block()),
95
+ this.synchronizer.handleL2Block(block),
74
96
  this.archiver.addCheckpoints([publishedCheckpoint], undefined),
75
- this.anchorBlockStore.setHeader(block.getBlockHeader()),
97
+ this.anchorBlockStore.setHeader(block.header),
76
98
  ]);
77
99
  }
78
100
  }
@@ -12,14 +12,16 @@ export class MockEpochCache implements EpochCacheInterface {
12
12
  committee: undefined,
13
13
  seed: 0n,
14
14
  epoch: EpochNumber.ZERO,
15
+ isEscapeHatchOpen: false,
15
16
  });
16
17
  }
17
18
 
18
- getEpochAndSlotNow(): EpochAndSlot {
19
+ getEpochAndSlotNow(): EpochAndSlot & { nowMs: bigint } {
19
20
  return {
20
21
  epoch: EpochNumber.ZERO,
21
22
  slot: SlotNumber(0),
22
23
  ts: 0n,
24
+ nowMs: 0n,
23
25
  };
24
26
  }
25
27
 
@@ -40,18 +42,15 @@ export class MockEpochCache implements EpochCacheInterface {
40
42
  return 0n;
41
43
  }
42
44
 
43
- getProposerAttesterAddressInCurrentOrNextSlot(): Promise<{
44
- currentProposer: EthAddress | undefined;
45
- nextProposer: EthAddress | undefined;
46
- currentSlot: SlotNumber;
47
- nextSlot: SlotNumber;
48
- }> {
49
- return Promise.resolve({
50
- currentProposer: undefined,
51
- nextProposer: undefined,
45
+ getCurrentAndNextSlot(): { currentSlot: SlotNumber; nextSlot: SlotNumber } {
46
+ return {
52
47
  currentSlot: SlotNumber(0),
53
48
  nextSlot: SlotNumber(0),
54
- });
49
+ };
50
+ }
51
+
52
+ getProposerAttesterAddressInSlot(_slot: SlotNumber): Promise<EthAddress | undefined> {
53
+ return Promise.resolve(undefined);
55
54
  }
56
55
 
57
56
  isInCommittee(_slot: SlotTag, _validator: EthAddress): Promise<boolean> {
@@ -1,7 +1,7 @@
1
1
  import { NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP } from '@aztec/constants';
2
2
  import { BlockNumber } from '@aztec/foundation/branded-types';
3
3
  import { Fr } from '@aztec/foundation/curves/bn254';
4
- import type { L2BlockNew } from '@aztec/stdlib/block';
4
+ import type { L2Block } from '@aztec/stdlib/block';
5
5
  import type {
6
6
  MerkleTreeReadOperations,
7
7
  MerkleTreeWriteOperations,
@@ -23,7 +23,7 @@ export class TXESynchronizer implements WorldStateSynchronizer {
23
23
  return new this(nativeWorldStateService);
24
24
  }
25
25
 
26
- public async handleL2Block(block: L2BlockNew) {
26
+ public async handleL2Block(block: L2Block) {
27
27
  await this.nativeWorldStateService.handleL2BlockAndMessages(
28
28
  block,
29
29
  Array(NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP).fill(0).map(Fr.zero),
@@ -7,6 +7,7 @@ import type { ProtocolContract } from '@aztec/protocol-contracts';
7
7
  import {
8
8
  AddressStore,
9
9
  CapsuleStore,
10
+ JobCoordinator,
10
11
  NoteService,
11
12
  NoteStore,
12
13
  PrivateEventStore,
@@ -20,10 +21,19 @@ import {
20
21
  HashedValuesCache,
21
22
  type IPrivateExecutionOracle,
22
23
  type IUtilityExecutionOracle,
24
+ Oracle,
23
25
  PrivateExecutionOracle,
24
26
  UtilityExecutionOracle,
25
27
  } from '@aztec/pxe/simulator';
26
- import { FunctionSelector } from '@aztec/stdlib/abi';
28
+ import {
29
+ ExecutionError,
30
+ WASMSimulator,
31
+ createSimulationError,
32
+ extractCallStack,
33
+ resolveAssertionMessageFromError,
34
+ toACVMWitness,
35
+ } from '@aztec/simulator/client';
36
+ import { FunctionCall, FunctionSelector, FunctionType } from '@aztec/stdlib/abi';
27
37
  import type { AuthWitness } from '@aztec/stdlib/auth-witness';
28
38
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
29
39
  import { GasSettings } from '@aztec/stdlib/gas';
@@ -34,6 +44,7 @@ import { CallContext, GlobalVariables, TxContext } from '@aztec/stdlib/tx';
34
44
 
35
45
  import { z } from 'zod';
36
46
 
47
+ import { DEFAULT_ADDRESS } from './constants.js';
37
48
  import type { IAvmExecutionOracle, ITxeExecutionOracle } from './oracle/interfaces.js';
38
49
  import { TXEOraclePublicContext } from './oracle/txe_oracle_public_context.js';
39
50
  import { TXEOracleTopLevelContext } from './oracle/txe_oracle_top_level_context.js';
@@ -64,7 +75,6 @@ type SessionState =
64
75
  | {
65
76
  name: 'PRIVATE';
66
77
  nextBlockGlobalVariables: GlobalVariables;
67
- protocolNullifier: Fr;
68
78
  noteCache: ExecutionNoteCache;
69
79
  taggingIndexCache: ExecutionTaggingIndexCache;
70
80
  }
@@ -103,8 +113,6 @@ export interface TXESessionStateHandler {
103
113
  enterUtilityState(contractAddress?: AztecAddress): Promise<void>;
104
114
  }
105
115
 
106
- export const DEFAULT_ADDRESS = AztecAddress.fromNumber(42);
107
-
108
116
  /**
109
117
  * A `TXESession` corresponds to a Noir `#[test]` function, and handles all of its oracle calls, stores test-specific
110
118
  * state, etc., independent of all other tests running in parallel.
@@ -131,6 +139,8 @@ export class TXESession implements TXESessionStateHandler {
131
139
  private senderAddressBookStore: SenderAddressBookStore,
132
140
  private capsuleStore: CapsuleStore,
133
141
  private privateEventStore: PrivateEventStore,
142
+ private jobCoordinator: JobCoordinator,
143
+ private currentJobId: string,
134
144
  private chainId: Fr,
135
145
  private version: Fr,
136
146
  private nextBlockTimestamp: bigint,
@@ -142,7 +152,7 @@ export class TXESession implements TXESessionStateHandler {
142
152
  const addressStore = new AddressStore(store);
143
153
  const privateEventStore = new PrivateEventStore(store);
144
154
  const contractStore = new TXEContractStore(store);
145
- const noteStore = await NoteStore.create(store);
155
+ const noteStore = new NoteStore(store);
146
156
  const senderTaggingStore = new SenderTaggingStore(store);
147
157
  const recipientTaggingStore = new RecipientTaggingStore(store);
148
158
  const senderAddressBookStore = new SenderAddressBookStore(store);
@@ -150,6 +160,16 @@ export class TXESession implements TXESessionStateHandler {
150
160
  const keyStore = new KeyStore(store);
151
161
  const accountStore = new TXEAccountStore(store);
152
162
 
163
+ // Create job coordinator and register staged stores
164
+ const jobCoordinator = new JobCoordinator(store);
165
+ jobCoordinator.registerStores([
166
+ capsuleStore,
167
+ senderTaggingStore,
168
+ recipientTaggingStore,
169
+ privateEventStore,
170
+ noteStore,
171
+ ]);
172
+
153
173
  // Register protocol contracts.
154
174
  for (const { contractClass, instance, artifact } of protocolContracts) {
155
175
  await contractStore.addContractArtifact(contractClass.id, artifact);
@@ -162,6 +182,8 @@ export class TXESession implements TXESessionStateHandler {
162
182
  const version = new Fr(await stateMachine.node.getVersion());
163
183
  const chainId = new Fr(await stateMachine.node.getChainId());
164
184
 
185
+ const initialJobId = jobCoordinator.beginJob();
186
+
165
187
  const topLevelOracleHandler = new TXEOracleTopLevelContext(
166
188
  stateMachine,
167
189
  contractStore,
@@ -174,6 +196,7 @@ export class TXESession implements TXESessionStateHandler {
174
196
  senderAddressBookStore,
175
197
  capsuleStore,
176
198
  privateEventStore,
199
+ initialJobId,
177
200
  nextBlockTimestamp,
178
201
  version,
179
202
  chainId,
@@ -195,6 +218,8 @@ export class TXESession implements TXESessionStateHandler {
195
218
  senderAddressBookStore,
196
219
  capsuleStore,
197
220
  privateEventStore,
221
+ jobCoordinator,
222
+ initialJobId,
198
223
  version,
199
224
  chainId,
200
225
  nextBlockTimestamp,
@@ -254,6 +279,10 @@ export class TXESession implements TXESessionStateHandler {
254
279
  }
255
280
  }
256
281
 
282
+ // Commit all staged stores from the job that was just completed, then begin a new job
283
+ await this.jobCoordinator.commitJob(this.currentJobId);
284
+ this.currentJobId = this.jobCoordinator.beginJob();
285
+
257
286
  this.oracleHandler = new TXEOracleTopLevelContext(
258
287
  this.stateMachine,
259
288
  this.contractStore,
@@ -266,6 +295,7 @@ export class TXESession implements TXESessionStateHandler {
266
295
  this.senderAddressBookStore,
267
296
  this.capsuleStore,
268
297
  this.privateEventStore,
298
+ this.currentJobId,
269
299
  this.nextBlockTimestamp,
270
300
  this.version,
271
301
  this.chainId,
@@ -282,15 +312,11 @@ export class TXESession implements TXESessionStateHandler {
282
312
  ): Promise<PrivateContextInputs> {
283
313
  this.exitTopLevelState();
284
314
 
285
- // There is no automatic message discovery and contract-driven syncing process in inlined private or utility
286
- // contexts, which means that known nullifiers are also not searched for, since it is during the tagging sync that
287
- // we perform this. We therefore search for known nullifiers now, as otherwise notes that were nullified would not
288
- // be removed from the database.
289
- // TODO(#12553): make the synchronizer sync here instead and remove this
290
315
  await new NoteService(
291
316
  this.noteStore,
292
317
  this.stateMachine.node,
293
318
  this.stateMachine.anchorBlockStore,
319
+ this.currentJobId,
294
320
  ).syncNoteNullifiers(contractAddress);
295
321
 
296
322
  // Private execution has two associated block numbers: the anchor block (i.e. the historical block that is used to
@@ -311,11 +337,13 @@ export class TXESession implements TXESessionStateHandler {
311
337
  const noteCache = new ExecutionNoteCache(protocolNullifier);
312
338
  const taggingIndexCache = new ExecutionTaggingIndexCache();
313
339
 
340
+ const utilityExecutor = this.utilityExecutorForContractSync(anchorBlock);
314
341
  this.oracleHandler = new PrivateExecutionOracle(
315
342
  Fr.ZERO,
316
343
  new TxContext(this.chainId, this.version, GasSettings.empty()),
317
344
  new CallContext(AztecAddress.ZERO, contractAddress, FunctionSelector.empty(), false),
318
345
  anchorBlock!,
346
+ utilityExecutor,
319
347
  [],
320
348
  [],
321
349
  new HashedValuesCache(),
@@ -332,6 +360,7 @@ export class TXESession implements TXESessionStateHandler {
332
360
  this.senderAddressBookStore,
333
361
  this.capsuleStore,
334
362
  this.privateEventStore,
363
+ this.currentJobId,
335
364
  );
336
365
 
337
366
  // We store the note and tagging index caches fed into the PrivateExecutionOracle (along with some other auxiliary
@@ -339,7 +368,7 @@ export class TXESession implements TXESessionStateHandler {
339
368
  // difference resides in that the simulator has all information needed in order to run the simulation, while ours
340
369
  // will be ongoing as the different oracles will be invoked from the Noir test, until eventually the private
341
370
  // execution finishes.
342
- this.state = { name: 'PRIVATE', nextBlockGlobalVariables, protocolNullifier, noteCache, taggingIndexCache };
371
+ this.state = { name: 'PRIVATE', nextBlockGlobalVariables, noteCache, taggingIndexCache };
343
372
  this.logger.debug(`Entered state ${this.state.name}`);
344
373
 
345
374
  return (this.oracleHandler as PrivateExecutionOracle).getPrivateContextInputs();
@@ -381,6 +410,7 @@ export class TXESession implements TXESessionStateHandler {
381
410
  this.noteStore,
382
411
  this.stateMachine.node,
383
412
  this.stateMachine.anchorBlockStore,
413
+ this.currentJobId,
384
414
  ).syncNoteNullifiers(contractAddress);
385
415
 
386
416
  const anchorBlockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
@@ -400,6 +430,7 @@ export class TXESession implements TXESessionStateHandler {
400
430
  this.senderAddressBookStore,
401
431
  this.capsuleStore,
402
432
  this.privateEventStore,
433
+ this.currentJobId,
403
434
  );
404
435
 
405
436
  this.state = { name: 'UTILITY' };
@@ -435,11 +466,7 @@ export class TXESession implements TXESessionStateHandler {
435
466
  // We rely on the note cache to determine the effects of the transaction. This is incomplete as it doesn't private
436
467
  // logs (other effects like enqueued public calls don't need to be considered since those are not allowed).
437
468
 
438
- const txEffect = await makeTxEffect(
439
- this.state.noteCache,
440
- this.state.protocolNullifier,
441
- this.state.nextBlockGlobalVariables.blockNumber,
442
- );
469
+ const txEffect = await makeTxEffect(this.state.noteCache, this.state.nextBlockGlobalVariables.blockNumber);
443
470
 
444
471
  // We build a block holding just this transaction
445
472
  const forkedWorldTrees = await this.stateMachine.synchronizer.nativeWorldStateService.fork();
@@ -470,4 +497,49 @@ export class TXESession implements TXESessionStateHandler {
470
497
  throw new Error(`Expected to be in state 'UTILITY', but got '${this.state.name}' instead`);
471
498
  }
472
499
  }
500
+
501
+ private utilityExecutorForContractSync(anchorBlock: any) {
502
+ return async (call: FunctionCall) => {
503
+ const entryPointArtifact = await this.contractStore.getFunctionArtifactWithDebugMetadata(call.to, call.selector);
504
+ if (entryPointArtifact.functionType !== FunctionType.UTILITY) {
505
+ throw new Error(`Cannot run ${entryPointArtifact.functionType} function as utility`);
506
+ }
507
+
508
+ try {
509
+ const oracle = new UtilityExecutionOracle(
510
+ call.to,
511
+ [],
512
+ [],
513
+ anchorBlock!,
514
+ this.contractStore,
515
+ this.noteStore,
516
+ this.keyStore,
517
+ this.addressStore,
518
+ this.stateMachine.node,
519
+ this.stateMachine.anchorBlockStore,
520
+ this.recipientTaggingStore,
521
+ this.senderAddressBookStore,
522
+ this.capsuleStore,
523
+ this.privateEventStore,
524
+ this.currentJobId,
525
+ );
526
+ await new WASMSimulator()
527
+ .executeUserCircuit(toACVMWitness(0, call.args), entryPointArtifact, new Oracle(oracle).toACIRCallback())
528
+ .catch((err: Error) => {
529
+ err.message = resolveAssertionMessageFromError(err, entryPointArtifact);
530
+ throw new ExecutionError(
531
+ err.message,
532
+ {
533
+ contractAddress: call.to,
534
+ functionSelector: call.selector,
535
+ },
536
+ extractCallStack(err, entryPointArtifact.debug),
537
+ { cause: err },
538
+ );
539
+ });
540
+ } catch (err) {
541
+ throw createSimulationError(err instanceof Error ? err : new Error('Unknown error contract data sync'));
542
+ }
543
+ };
544
+ }
473
545
  }
@@ -4,13 +4,12 @@ import {
4
4
  NULLIFIER_SUBTREE_HEIGHT,
5
5
  NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP,
6
6
  } from '@aztec/constants';
7
- import { BlockNumber } from '@aztec/foundation/branded-types';
7
+ import { BlockNumber, CheckpointNumber, IndexWithinCheckpoint } from '@aztec/foundation/branded-types';
8
8
  import { padArrayEnd } from '@aztec/foundation/collection';
9
9
  import { Fr } from '@aztec/foundation/curves/bn254';
10
- import { Body, L2Block, L2BlockHeader } from '@aztec/stdlib/block';
11
- import { makeContentCommitment } from '@aztec/stdlib/testing';
10
+ import { Body, L2Block } from '@aztec/stdlib/block';
12
11
  import { AppendOnlyTreeSnapshot, MerkleTreeId, type MerkleTreeWriteOperations } from '@aztec/stdlib/trees';
13
- import { GlobalVariables, TxEffect } from '@aztec/stdlib/tx';
12
+ import { BlockHeader, GlobalVariables, TxEffect } from '@aztec/stdlib/tx';
14
13
 
15
14
  /**
16
15
  * Returns a transaction request hash that is valid for transactions that are the only ones in a block.
@@ -47,20 +46,18 @@ export async function insertTxEffectIntoWorldTrees(
47
46
  export async function makeTXEBlockHeader(
48
47
  worldTrees: MerkleTreeWriteOperations,
49
48
  globalVariables: GlobalVariables,
50
- ): Promise<L2BlockHeader> {
49
+ ): Promise<BlockHeader> {
51
50
  const stateReference = await worldTrees.getStateReference();
52
51
  const archiveInfo = await worldTrees.getTreeInfo(MerkleTreeId.ARCHIVE);
53
52
 
54
- return new L2BlockHeader(
55
- new AppendOnlyTreeSnapshot(new Fr(archiveInfo.root), Number(archiveInfo.size)),
56
- makeContentCommitment(),
57
- stateReference,
53
+ return BlockHeader.from({
54
+ lastArchive: new AppendOnlyTreeSnapshot(new Fr(archiveInfo.root), Number(archiveInfo.size)),
55
+ spongeBlobHash: Fr.ZERO,
56
+ state: stateReference,
58
57
  globalVariables,
59
- Fr.ZERO,
60
- Fr.ZERO,
61
- Fr.ZERO,
62
- Fr.ZERO,
63
- );
58
+ totalFees: Fr.ZERO,
59
+ totalManaUsed: Fr.ZERO,
60
+ });
64
61
  }
65
62
 
66
63
  /**
@@ -84,11 +81,15 @@ export async function makeTXEBlock(
84
81
  const header = await makeTXEBlockHeader(worldTrees, globalVariables);
85
82
 
86
83
  // Update the archive tree with this block's header hash
87
- await worldTrees.updateArchive(header.toBlockHeader());
84
+ await worldTrees.updateArchive(header);
88
85
 
89
86
  // Get the new archive state after updating
90
87
  const newArchiveInfo = await worldTrees.getTreeInfo(MerkleTreeId.ARCHIVE);
91
88
  const newArchive = new AppendOnlyTreeSnapshot(new Fr(newArchiveInfo.root), Number(newArchiveInfo.size));
92
89
 
93
- return new L2Block(newArchive, header, new Body(txEffects));
90
+ // L2Block requires checkpointNumber and indexWithinCheckpoint
91
+ const checkpointNumber = CheckpointNumber.fromBlockNumber(globalVariables.blockNumber);
92
+ const indexWithinCheckpoint = IndexWithinCheckpoint(0);
93
+
94
+ return new L2Block(newArchive, header, new Body(txEffects), checkpointNumber, indexWithinCheckpoint);
94
95
  }
@@ -4,16 +4,12 @@ import type { ExecutionNoteCache } from '@aztec/pxe/simulator';
4
4
  import { computeNoteHashNonce, computeUniqueNoteHash, siloNoteHash } from '@aztec/stdlib/hash';
5
5
  import { TxEffect, TxHash } from '@aztec/stdlib/tx';
6
6
 
7
- export async function makeTxEffect(
8
- noteCache: ExecutionNoteCache,
9
- protocolNullifier: Fr,
10
- txBlockNumber: BlockNumber,
11
- ): Promise<TxEffect> {
7
+ export async function makeTxEffect(noteCache: ExecutionNoteCache, txBlockNumber: BlockNumber): Promise<TxEffect> {
12
8
  const txEffect = TxEffect.empty();
13
9
 
14
- const { usedProtocolNullifierForNonces } = noteCache.finish();
15
- const nonceGenerator = usedProtocolNullifierForNonces ? protocolNullifier : noteCache.getAllNullifiers()[0];
10
+ noteCache.finish();
16
11
 
12
+ const nonceGenerator = noteCache.getNonceGenerator();
17
13
  txEffect.noteHashes = await Promise.all(
18
14
  noteCache
19
15
  .getAllNotes()
@@ -28,10 +24,6 @@ export async function makeTxEffect(
28
24
  // Nullifiers are already siloed
29
25
  txEffect.nullifiers = noteCache.getAllNullifiers();
30
26
 
31
- if (usedProtocolNullifierForNonces) {
32
- txEffect.nullifiers.unshift(protocolNullifier);
33
- }
34
-
35
27
  txEffect.txHash = new TxHash(new Fr(txBlockNumber));
36
28
 
37
29
  return txEffect;