@aztec/txe 0.0.1-commit.1bea0213 → 0.0.1-commit.21ecf947b

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 (40) hide show
  1. package/dest/oracle/interfaces.d.ts +2 -2
  2. package/dest/oracle/interfaces.d.ts.map +1 -1
  3. package/dest/oracle/txe_oracle_public_context.d.ts +2 -2
  4. package/dest/oracle/txe_oracle_public_context.d.ts.map +1 -1
  5. package/dest/oracle/txe_oracle_public_context.js +3 -4
  6. package/dest/oracle/txe_oracle_top_level_context.d.ts +2 -2
  7. package/dest/oracle/txe_oracle_top_level_context.d.ts.map +1 -1
  8. package/dest/oracle/txe_oracle_top_level_context.js +87 -26
  9. package/dest/rpc_translator.d.ts +8 -8
  10. package/dest/rpc_translator.d.ts.map +1 -1
  11. package/dest/rpc_translator.js +40 -29
  12. package/dest/state_machine/archiver.d.ts +1 -1
  13. package/dest/state_machine/archiver.d.ts.map +1 -1
  14. package/dest/state_machine/archiver.js +2 -0
  15. package/dest/state_machine/dummy_p2p_client.d.ts +11 -8
  16. package/dest/state_machine/dummy_p2p_client.d.ts.map +1 -1
  17. package/dest/state_machine/dummy_p2p_client.js +21 -12
  18. package/dest/state_machine/index.d.ts +5 -5
  19. package/dest/state_machine/index.d.ts.map +1 -1
  20. package/dest/state_machine/index.js +14 -9
  21. package/dest/state_machine/mock_epoch_cache.d.ts +3 -1
  22. package/dest/state_machine/mock_epoch_cache.d.ts.map +1 -1
  23. package/dest/state_machine/mock_epoch_cache.js +4 -0
  24. package/dest/txe_session.d.ts +1 -1
  25. package/dest/txe_session.d.ts.map +1 -1
  26. package/dest/txe_session.js +68 -9
  27. package/dest/utils/block_creation.d.ts +1 -1
  28. package/dest/utils/block_creation.d.ts.map +1 -1
  29. package/dest/utils/block_creation.js +3 -1
  30. package/package.json +15 -15
  31. package/src/oracle/interfaces.ts +1 -1
  32. package/src/oracle/txe_oracle_public_context.ts +3 -5
  33. package/src/oracle/txe_oracle_top_level_context.ts +106 -74
  34. package/src/rpc_translator.ts +42 -24
  35. package/src/state_machine/archiver.ts +2 -0
  36. package/src/state_machine/dummy_p2p_client.ts +29 -15
  37. package/src/state_machine/index.ts +24 -9
  38. package/src/state_machine/mock_epoch_cache.ts +5 -0
  39. package/src/txe_session.ts +70 -66
  40. package/src/utils/block_creation.ts +3 -1
@@ -328,7 +328,7 @@ export class RPCTranslator {
328
328
 
329
329
  // When the argument is a slice, noir automatically adds a length field to oracle call.
330
330
  // When the argument is an array, we add the field length manually to the signature.
331
- utilityDebugLog(
331
+ async utilityLog(
332
332
  foreignLevel: ForeignCallSingle,
333
333
  foreignMessage: ForeignCallArray,
334
334
  _foreignLength: ForeignCallSingle,
@@ -340,7 +340,7 @@ export class RPCTranslator {
340
340
  .join('');
341
341
  const fields = fromArray(foreignFields);
342
342
 
343
- this.handlerAsMisc().utilityDebugLog(level, message, fields);
343
+ await this.handlerAsMisc().utilityLog(level, message, fields);
344
344
 
345
345
  return toForeignCallResult([]);
346
346
  }
@@ -351,7 +351,7 @@ export class RPCTranslator {
351
351
  foreignStartStorageSlot: ForeignCallSingle,
352
352
  foreignNumberOfElements: ForeignCallSingle,
353
353
  ) {
354
- const blockHash = BlockHash.fromString(foreignBlockHash);
354
+ const blockHash = new BlockHash(fromSingle(foreignBlockHash));
355
355
  const contractAddress = addressFromSingle(foreignContractAddress);
356
356
  const startStorageSlot = fromSingle(foreignStartStorageSlot);
357
357
  const numberOfElements = fromSingle(foreignNumberOfElements).toNumber();
@@ -367,7 +367,7 @@ export class RPCTranslator {
367
367
  }
368
368
 
369
369
  async utilityGetPublicDataWitness(foreignBlockHash: ForeignCallSingle, foreignLeafSlot: ForeignCallSingle) {
370
- const blockHash = BlockHash.fromString(foreignBlockHash);
370
+ const blockHash = new BlockHash(fromSingle(foreignBlockHash));
371
371
  const leafSlot = fromSingle(foreignLeafSlot);
372
372
 
373
373
  const witness = await this.handlerAsUtility().utilityGetPublicDataWitness(blockHash, leafSlot);
@@ -545,12 +545,23 @@ export class RPCTranslator {
545
545
  );
546
546
  }
547
547
 
548
- async utilityGetPublicKeysAndPartialAddress(foreignAddress: ForeignCallSingle) {
548
+ async utilityTryGetPublicKeysAndPartialAddress(foreignAddress: ForeignCallSingle) {
549
549
  const address = addressFromSingle(foreignAddress);
550
550
 
551
- const { publicKeys, partialAddress } = await this.handlerAsUtility().utilityGetPublicKeysAndPartialAddress(address);
551
+ const result = await this.handlerAsUtility().utilityTryGetPublicKeysAndPartialAddress(address);
552
552
 
553
- return toForeignCallResult([toArray([...publicKeys.toFields(), partialAddress])]);
553
+ // We are going to return a Noir Option struct to represent the possibility of null values. Options are a struct
554
+ // with two fields: `some` (a boolean) and `value` (a field array in this case).
555
+ if (result === undefined) {
556
+ // No data was found so we set `some` to 0 and pad `value` with zeros get the correct return size.
557
+ return toForeignCallResult([toSingle(new Fr(0)), toArray(Array(13).fill(new Fr(0)))]);
558
+ } else {
559
+ // Data was found so we set `some` to 1 and return it along with `value`.
560
+ return toForeignCallResult([
561
+ toSingle(new Fr(1)),
562
+ toArray([...result.publicKeys.toFields(), result.partialAddress]),
563
+ ]);
564
+ }
554
565
  }
555
566
 
556
567
  async utilityGetKeyValidationRequest(foreignPkMHash: ForeignCallSingle) {
@@ -574,7 +585,7 @@ export class RPCTranslator {
574
585
  }
575
586
 
576
587
  async utilityGetNullifierMembershipWitness(foreignBlockHash: ForeignCallSingle, foreignNullifier: ForeignCallSingle) {
577
- const blockHash = BlockHash.fromString(foreignBlockHash);
588
+ const blockHash = new BlockHash(fromSingle(foreignBlockHash));
578
589
  const nullifier = fromSingle(foreignNullifier);
579
590
 
580
591
  const witness = await this.handlerAsUtility().utilityGetNullifierMembershipWitness(blockHash, nullifier);
@@ -641,26 +652,34 @@ export class RPCTranslator {
641
652
  return toForeignCallResult(header.toFields().map(toSingle));
642
653
  }
643
654
 
644
- async utilityGetNoteHashMembershipWitness(foreignBlockHash: ForeignCallSingle, foreignLeafValue: ForeignCallSingle) {
645
- const blockHash = BlockHash.fromString(foreignBlockHash);
646
- const leafValue = fromSingle(foreignLeafValue);
655
+ async utilityGetNoteHashMembershipWitness(
656
+ foreignAnchorBlockHash: ForeignCallSingle,
657
+ foreignNoteHash: ForeignCallSingle,
658
+ ) {
659
+ const blockHash = new BlockHash(fromSingle(foreignAnchorBlockHash));
660
+ const noteHash = fromSingle(foreignNoteHash);
647
661
 
648
- const witness = await this.handlerAsUtility().utilityGetNoteHashMembershipWitness(blockHash, leafValue);
662
+ const witness = await this.handlerAsUtility().utilityGetNoteHashMembershipWitness(blockHash, noteHash);
649
663
 
650
664
  if (!witness) {
651
- throw new Error(`Note hash ${leafValue} not found in the note hash tree at block ${blockHash.toString()}.`);
665
+ throw new Error(`Note hash ${noteHash} not found in the note hash tree at block ${blockHash.toString()}.`);
652
666
  }
653
667
  return toForeignCallResult(witness.toNoirRepresentation());
654
668
  }
655
669
 
656
- async utilityGetArchiveMembershipWitness(foreignBlockHash: ForeignCallSingle, foreignLeafValue: ForeignCallSingle) {
657
- const blockHash = BlockHash.fromString(foreignBlockHash);
658
- const leafValue = fromSingle(foreignLeafValue);
670
+ async utilityGetBlockHashMembershipWitness(
671
+ foreignAnchorBlockHash: ForeignCallSingle,
672
+ foreignBlockHash: ForeignCallSingle,
673
+ ) {
674
+ const anchorBlockHash = new BlockHash(fromSingle(foreignAnchorBlockHash));
675
+ const blockHash = new BlockHash(fromSingle(foreignBlockHash));
659
676
 
660
- const witness = await this.handlerAsUtility().utilityGetArchiveMembershipWitness(blockHash, leafValue);
677
+ const witness = await this.handlerAsUtility().utilityGetBlockHashMembershipWitness(anchorBlockHash, blockHash);
661
678
 
662
679
  if (!witness) {
663
- throw new Error(`Block hash ${leafValue} not found in the archive tree at block ${blockHash.toString()}.`);
680
+ throw new Error(
681
+ `Block hash ${blockHash.toString()} not found in the archive tree at anchor block ${anchorBlockHash.toString()}.`,
682
+ );
664
683
  }
665
684
  return toForeignCallResult(witness.toNoirRepresentation());
666
685
  }
@@ -669,7 +688,7 @@ export class RPCTranslator {
669
688
  foreignBlockHash: ForeignCallSingle,
670
689
  foreignNullifier: ForeignCallSingle,
671
690
  ) {
672
- const blockHash = BlockHash.fromString(foreignBlockHash);
691
+ const blockHash = new BlockHash(fromSingle(foreignBlockHash));
673
692
  const nullifier = fromSingle(foreignNullifier);
674
693
 
675
694
  const witness = await this.handlerAsUtility().utilityGetLowNullifierMembershipWitness(blockHash, nullifier);
@@ -830,7 +849,7 @@ export class RPCTranslator {
830
849
 
831
850
  // AVM opcodes
832
851
 
833
- avmOpcodeEmitUnencryptedLog(_foreignMessage: ForeignCallArray) {
852
+ avmOpcodeEmitPublicLog(_foreignMessage: ForeignCallArray) {
834
853
  // TODO(#8811): Implement
835
854
  return toForeignCallResult([]);
836
855
  }
@@ -911,11 +930,10 @@ export class RPCTranslator {
911
930
  return toForeignCallResult([]);
912
931
  }
913
932
 
914
- async avmOpcodeNullifierExists(foreignInnerNullifier: ForeignCallSingle, foreignTargetAddress: ForeignCallSingle) {
915
- const innerNullifier = fromSingle(foreignInnerNullifier);
916
- const targetAddress = AztecAddress.fromField(fromSingle(foreignTargetAddress));
933
+ async avmOpcodeNullifierExists(foreignSiloedNullifier: ForeignCallSingle) {
934
+ const siloedNullifier = fromSingle(foreignSiloedNullifier);
917
935
 
918
- const exists = await this.handlerAsAvm().avmOpcodeNullifierExists(innerNullifier, targetAddress);
936
+ const exists = await this.handlerAsAvm().avmOpcodeNullifierExists(siloedNullifier);
919
937
 
920
938
  return toForeignCallResult([toSingle(new Fr(exists))]);
921
939
  }
@@ -59,6 +59,8 @@ export class TXEArchiver extends ArchiverDataSourceBase {
59
59
  if (!checkpointedBlock) {
60
60
  throw new Error(`L2Tips requested from TXE Archiver but no checkpointed block found for block number ${number}`);
61
61
  }
62
+ // TXE uses 1-block-per-checkpoint for testing simplicity, so we can use block number as checkpoint number.
63
+ // This uses the deprecated fromBlockNumber method intentionally for the TXE testing environment.
62
64
  const checkpoint = await this.store.getRangeOfCheckpoints(CheckpointNumber.fromBlockNumber(number), 1);
63
65
  if (checkpoint.length === 0) {
64
66
  throw new Error(`L2Tips requested from TXE Archiver but no checkpoint found for block number ${number}`);
@@ -6,6 +6,8 @@ import type {
6
6
  P2PBlockReceivedCallback,
7
7
  P2PCheckpointReceivedCallback,
8
8
  P2PConfig,
9
+ P2PDuplicateAttestationCallback,
10
+ P2PDuplicateProposalCallback,
9
11
  P2PSyncState,
10
12
  PeerId,
11
13
  ReqRespSubProtocol,
@@ -16,7 +18,7 @@ import type {
16
18
  import type { EthAddress, L2BlockStreamEvent, L2Tips } from '@aztec/stdlib/block';
17
19
  import type { PeerInfo } from '@aztec/stdlib/interfaces/server';
18
20
  import type { BlockProposal, CheckpointAttestation, CheckpointProposal } from '@aztec/stdlib/p2p';
19
- import type { Tx, TxHash } from '@aztec/stdlib/tx';
21
+ import type { BlockHeader, Tx, TxHash } from '@aztec/stdlib/tx';
20
22
 
21
23
  export class DummyP2P implements P2P {
22
24
  public validate(_txs: Tx[]): Promise<void> {
@@ -71,8 +73,8 @@ export class DummyP2P implements P2P {
71
73
  throw new Error('DummyP2P does not implement "sendTx"');
72
74
  }
73
75
 
74
- public deleteTxs(_txHashes: TxHash[]): Promise<void> {
75
- throw new Error('DummyP2P does not implement "deleteTxs"');
76
+ public handleFailedExecution(_txHashes: TxHash[]): Promise<void> {
77
+ throw new Error('DummyP2P does not implement "handleFailedExecution"');
76
78
  }
77
79
 
78
80
  public getTxByHashFromPool(_txHash: TxHash): Promise<Tx | undefined> {
@@ -97,6 +99,10 @@ export class DummyP2P implements P2P {
97
99
  throw new Error('DummyP2P does not implement "iteratePendingTxs"');
98
100
  }
99
101
 
102
+ public iterateEligiblePendingTxs(): AsyncIterableIterator<Tx> {
103
+ throw new Error('DummyP2P does not implement "iterateEligiblePendingTxs"');
104
+ }
105
+
100
106
  public getPendingTxCount(): Promise<number> {
101
107
  throw new Error('DummyP2P does not implement "getPendingTxCount"');
102
108
  }
@@ -133,8 +139,8 @@ export class DummyP2P implements P2P {
133
139
  throw new Error('DummyP2P does not implement "getCheckpointAttestationsForSlot"');
134
140
  }
135
141
 
136
- public addCheckpointAttestations(_attestations: CheckpointAttestation[]): Promise<void> {
137
- throw new Error('DummyP2P does not implement "addCheckpointAttestations"');
142
+ public addOwnCheckpointAttestations(_attestations: CheckpointAttestation[]): Promise<void> {
143
+ throw new Error('DummyP2P does not implement "addOwnCheckpointAttestations"');
138
144
  }
139
145
 
140
146
  public getL2BlockHash(_number: number): Promise<string | undefined> {
@@ -157,14 +163,6 @@ export class DummyP2P implements P2P {
157
163
  throw new Error('DummyP2P does not implement "sync"');
158
164
  }
159
165
 
160
- public requestTxsByHash(_txHashes: TxHash[]): Promise<Tx[]> {
161
- throw new Error('DummyP2P does not implement "requestTxsByHash"');
162
- }
163
-
164
- public getTxs(_filter: 'all' | 'pending' | 'mined'): Promise<Tx[]> {
165
- throw new Error('DummyP2P does not implement "getTxs"');
166
- }
167
-
168
166
  public getTxsByHashFromPool(_txHashes: TxHash[]): Promise<(Tx | undefined)[]> {
169
167
  throw new Error('DummyP2P does not implement "getTxsByHashFromPool"');
170
168
  }
@@ -189,8 +187,12 @@ export class DummyP2P implements P2P {
189
187
  throw new Error('DummyP2P does not implement "getSyncedLatestSlot"');
190
188
  }
191
189
 
192
- markTxsAsNonEvictable(_: TxHash[]): Promise<void> {
193
- throw new Error('DummyP2P does not implement "markTxsAsNonEvictable".');
190
+ protectTxs(_txHashes: TxHash[], _blockHeader: BlockHeader): Promise<TxHash[]> {
191
+ throw new Error('DummyP2P does not implement "protectTxs".');
192
+ }
193
+
194
+ prepareForSlot(_slotNumber: SlotNumber): Promise<void> {
195
+ return Promise.resolve();
194
196
  }
195
197
 
196
198
  addReqRespSubProtocol(
@@ -206,4 +208,16 @@ export class DummyP2P implements P2P {
206
208
 
207
209
  //This is no-op
208
210
  public registerThisValidatorAddresses(_address: EthAddress[]): void {}
211
+
212
+ public registerDuplicateProposalCallback(_callback: P2PDuplicateProposalCallback): void {
213
+ throw new Error('DummyP2P does not implement "registerDuplicateProposalCallback"');
214
+ }
215
+
216
+ public registerDuplicateAttestationCallback(_callback: P2PDuplicateAttestationCallback): void {
217
+ throw new Error('DummyP2P does not implement "registerDuplicateAttestationCallback"');
218
+ }
219
+
220
+ public hasBlockProposalsForSlot(_slot: SlotNumber): Promise<boolean> {
221
+ throw new Error('DummyP2P does not implement "hasBlockProposalsForSlot"');
222
+ }
209
223
  }
@@ -3,8 +3,7 @@ import { TestCircuitVerifier } from '@aztec/bb-prover/test';
3
3
  import { CheckpointNumber } from '@aztec/foundation/branded-types';
4
4
  import { Fr } from '@aztec/foundation/curves/bn254';
5
5
  import { createLogger } from '@aztec/foundation/log';
6
- import type { AztecAsyncKVStore } from '@aztec/kv-store';
7
- import { AnchorBlockStore } from '@aztec/pxe/server';
6
+ import { type AnchorBlockStore, type ContractStore, ContractSyncService, type NoteStore } from '@aztec/pxe/server';
8
7
  import { L2Block } from '@aztec/stdlib/block';
9
8
  import { Checkpoint, L1PublishedData, PublishedCheckpoint } from '@aztec/stdlib/checkpoint';
10
9
  import type { AztecNode } from '@aztec/stdlib/interfaces/client';
@@ -26,13 +25,16 @@ export class TXEStateMachine {
26
25
  public synchronizer: TXESynchronizer,
27
26
  public archiver: TXEArchiver,
28
27
  public anchorBlockStore: AnchorBlockStore,
28
+ public contractSyncService: ContractSyncService,
29
29
  ) {}
30
30
 
31
- public static async create(db: AztecAsyncKVStore) {
32
- const archiver = new TXEArchiver(db);
31
+ public static async create(
32
+ archiver: TXEArchiver,
33
+ anchorBlockStore: AnchorBlockStore,
34
+ contractStore: ContractStore,
35
+ noteStore: NoteStore,
36
+ ) {
33
37
  const synchronizer = await TXESynchronizer.create();
34
- const anchorBlockStore = new AnchorBlockStore(db);
35
-
36
38
  const aztecNodeConfig = {} as AztecNodeConfig;
37
39
 
38
40
  const log = createLogger('txe_node');
@@ -58,11 +60,21 @@ export class TXEStateMachine {
58
60
  log,
59
61
  );
60
62
 
61
- return new this(node, synchronizer, archiver, anchorBlockStore);
63
+ const contractSyncService = new ContractSyncService(
64
+ node,
65
+ contractStore,
66
+ noteStore,
67
+ createLogger('txe:contract_sync'),
68
+ );
69
+
70
+ return new this(node, synchronizer, archiver, anchorBlockStore, contractSyncService);
62
71
  }
63
72
 
64
73
  public async handleL2Block(block: L2Block) {
65
- // Create a checkpoint from the block manually
74
+ // Create a checkpoint from the block manually.
75
+ // TXE uses 1-block-per-checkpoint for testing simplicity, so we can use block number as checkpoint number.
76
+ // This uses the deprecated fromBlockNumber method intentionally for the TXE testing environment.
77
+ const checkpointNumber = CheckpointNumber.fromBlockNumber(block.number);
66
78
  const checkpoint = new Checkpoint(
67
79
  block.archive,
68
80
  CheckpointHeader.from({
@@ -79,7 +91,7 @@ export class TXEStateMachine {
79
91
  totalManaUsed: block.header.totalManaUsed,
80
92
  }),
81
93
  [block],
82
- CheckpointNumber.fromBlockNumber(block.number),
94
+ checkpointNumber,
83
95
  );
84
96
 
85
97
  const publishedCheckpoint = new PublishedCheckpoint(
@@ -91,6 +103,9 @@ export class TXEStateMachine {
91
103
  ),
92
104
  [],
93
105
  );
106
+ // Wipe contract sync cache when anchor block changes (mirrors BlockSynchronizer behavior)
107
+ this.contractSyncService.wipe();
108
+
94
109
  await Promise.all([
95
110
  this.synchronizer.handleL2Block(block),
96
111
  this.archiver.addCheckpoints([publishedCheckpoint], undefined),
@@ -1,6 +1,7 @@
1
1
  import type { EpochAndSlot, EpochCacheInterface, EpochCommitteeInfo, SlotTag } from '@aztec/epoch-cache';
2
2
  import { EpochNumber, SlotNumber } from '@aztec/foundation/branded-types';
3
3
  import { EthAddress } from '@aztec/foundation/eth-address';
4
+ import { EmptyL1RollupConstants, type L1RollupConstants } from '@aztec/stdlib/epoch-helpers';
4
5
 
5
6
  /**
6
7
  * Mock implementation of the EpochCacheInterface used to satisfy dependencies of AztecNodeService.
@@ -64,4 +65,8 @@ export class MockEpochCache implements EpochCacheInterface {
64
65
  filterInCommittee(_slot: SlotTag, _validators: EthAddress[]): Promise<EthAddress[]> {
65
66
  return Promise.resolve([]);
66
67
  }
68
+
69
+ getL1Constants(): L1RollupConstants {
70
+ return EmptyL1RollupConstants;
71
+ }
67
72
  }
@@ -4,8 +4,10 @@ import { type Logger, createLogger } from '@aztec/foundation/log';
4
4
  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
+ import type { AccessScopes } from '@aztec/pxe/client/lazy';
7
8
  import {
8
9
  AddressStore,
10
+ AnchorBlockStore,
9
11
  CapsuleStore,
10
12
  JobCoordinator,
11
13
  NoteService,
@@ -49,6 +51,7 @@ import type { IAvmExecutionOracle, ITxeExecutionOracle } from './oracle/interfac
49
51
  import { TXEOraclePublicContext } from './oracle/txe_oracle_public_context.js';
50
52
  import { TXEOracleTopLevelContext } from './oracle/txe_oracle_top_level_context.js';
51
53
  import { RPCTranslator } from './rpc_translator.js';
54
+ import { TXEArchiver } from './state_machine/archiver.js';
52
55
  import { TXEStateMachine } from './state_machine/index.js';
53
56
  import type { ForeignCallArgs, ForeignCallResult } from './util/encoding.js';
54
57
  import { TXEAccountStore } from './util/txe_account_store.js';
@@ -176,7 +179,9 @@ export class TXESession implements TXESessionStateHandler {
176
179
  await contractStore.addContractInstance(instance);
177
180
  }
178
181
 
179
- const stateMachine = await TXEStateMachine.create(store);
182
+ const archiver = new TXEArchiver(store);
183
+ const anchorBlockStore = new AnchorBlockStore(store);
184
+ const stateMachine = await TXEStateMachine.create(archiver, anchorBlockStore, contractStore, noteStore);
180
185
 
181
186
  const nextBlockTimestamp = BigInt(Math.floor(new Date().getTime() / 1000));
182
187
  const version = new Fr(await stateMachine.node.getVersion());
@@ -312,17 +317,15 @@ export class TXESession implements TXESessionStateHandler {
312
317
  ): Promise<PrivateContextInputs> {
313
318
  this.exitTopLevelState();
314
319
 
315
- await new NoteService(
316
- this.noteStore,
317
- this.stateMachine.node,
318
- this.stateMachine.anchorBlockStore,
319
- this.currentJobId,
320
- ).syncNoteNullifiers(contractAddress);
321
-
322
320
  // Private execution has two associated block numbers: the anchor block (i.e. the historical block that is used to
323
321
  // build the proof), and the *next* block, i.e. the one we'll create once the execution ends, and which will contain
324
322
  // a single transaction with the effects of what was done in the test.
325
323
  const anchorBlock = await this.stateMachine.node.getBlockHeader(anchorBlockNumber ?? 'latest');
324
+
325
+ await new NoteService(this.noteStore, this.stateMachine.node, anchorBlock!, this.currentJobId).syncNoteNullifiers(
326
+ contractAddress,
327
+ 'ALL_SCOPES',
328
+ );
326
329
  const latestBlock = await this.stateMachine.node.getBlockHeader('latest');
327
330
 
328
331
  const nextBlockGlobalVariables = makeGlobalVariables(undefined, {
@@ -338,30 +341,31 @@ export class TXESession implements TXESessionStateHandler {
338
341
  const taggingIndexCache = new ExecutionTaggingIndexCache();
339
342
 
340
343
  const utilityExecutor = this.utilityExecutorForContractSync(anchorBlock);
341
- this.oracleHandler = new PrivateExecutionOracle(
342
- Fr.ZERO,
343
- new TxContext(this.chainId, this.version, GasSettings.empty()),
344
- new CallContext(AztecAddress.ZERO, contractAddress, FunctionSelector.empty(), false),
345
- anchorBlock!,
344
+ this.oracleHandler = new PrivateExecutionOracle({
345
+ argsHash: Fr.ZERO,
346
+ txContext: new TxContext(this.chainId, this.version, GasSettings.empty()),
347
+ callContext: new CallContext(AztecAddress.ZERO, contractAddress, FunctionSelector.empty(), false),
348
+ anchorBlockHeader: anchorBlock!,
346
349
  utilityExecutor,
347
- [],
348
- [],
349
- new HashedValuesCache(),
350
+ authWitnesses: [],
351
+ capsules: [],
352
+ executionCache: new HashedValuesCache(),
350
353
  noteCache,
351
354
  taggingIndexCache,
352
- this.contractStore,
353
- this.noteStore,
354
- this.keyStore,
355
- this.addressStore,
356
- this.stateMachine.node,
357
- this.stateMachine.anchorBlockStore,
358
- this.senderTaggingStore,
359
- this.recipientTaggingStore,
360
- this.senderAddressBookStore,
361
- this.capsuleStore,
362
- this.privateEventStore,
363
- this.currentJobId,
364
- );
355
+ contractStore: this.contractStore,
356
+ noteStore: this.noteStore,
357
+ keyStore: this.keyStore,
358
+ addressStore: this.addressStore,
359
+ aztecNode: this.stateMachine.node,
360
+ senderTaggingStore: this.senderTaggingStore,
361
+ recipientTaggingStore: this.recipientTaggingStore,
362
+ senderAddressBookStore: this.senderAddressBookStore,
363
+ capsuleStore: this.capsuleStore,
364
+ privateEventStore: this.privateEventStore,
365
+ contractSyncService: this.stateMachine.contractSyncService,
366
+ jobId: this.currentJobId,
367
+ scopes: 'ALL_SCOPES',
368
+ });
365
369
 
366
370
  // We store the note and tagging index caches fed into the PrivateExecutionOracle (along with some other auxiliary
367
371
  // data) in order to refer to it later, mimicking the way this object is used by the ContractFunctionSimulator. The
@@ -401,6 +405,8 @@ export class TXESession implements TXESessionStateHandler {
401
405
  async enterUtilityState(contractAddress: AztecAddress = DEFAULT_ADDRESS) {
402
406
  this.exitTopLevelState();
403
407
 
408
+ const anchorBlockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
409
+
404
410
  // There is no automatic message discovery and contract-driven syncing process in inlined private or utility
405
411
  // contexts, which means that known nullifiers are also not searched for, since it is during the tagging sync that
406
412
  // we perform this. We therefore search for known nullifiers now, as otherwise notes that were nullified would not
@@ -409,29 +415,27 @@ export class TXESession implements TXESessionStateHandler {
409
415
  await new NoteService(
410
416
  this.noteStore,
411
417
  this.stateMachine.node,
412
- this.stateMachine.anchorBlockStore,
418
+ anchorBlockHeader,
413
419
  this.currentJobId,
414
- ).syncNoteNullifiers(contractAddress);
415
-
416
- const anchorBlockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
420
+ ).syncNoteNullifiers(contractAddress, 'ALL_SCOPES');
417
421
 
418
- this.oracleHandler = new UtilityExecutionOracle(
422
+ this.oracleHandler = new UtilityExecutionOracle({
419
423
  contractAddress,
420
- [],
421
- [],
424
+ authWitnesses: [],
425
+ capsules: [],
422
426
  anchorBlockHeader,
423
- this.contractStore,
424
- this.noteStore,
425
- this.keyStore,
426
- this.addressStore,
427
- this.stateMachine.node,
428
- this.stateMachine.anchorBlockStore,
429
- this.recipientTaggingStore,
430
- this.senderAddressBookStore,
431
- this.capsuleStore,
432
- this.privateEventStore,
433
- this.currentJobId,
434
- );
427
+ contractStore: this.contractStore,
428
+ noteStore: this.noteStore,
429
+ keyStore: this.keyStore,
430
+ addressStore: this.addressStore,
431
+ aztecNode: this.stateMachine.node,
432
+ recipientTaggingStore: this.recipientTaggingStore,
433
+ senderAddressBookStore: this.senderAddressBookStore,
434
+ capsuleStore: this.capsuleStore,
435
+ privateEventStore: this.privateEventStore,
436
+ jobId: this.currentJobId,
437
+ scopes: 'ALL_SCOPES',
438
+ });
435
439
 
436
440
  this.state = { name: 'UTILITY' };
437
441
  this.logger.debug(`Entered state ${this.state.name}`);
@@ -499,30 +503,30 @@ export class TXESession implements TXESessionStateHandler {
499
503
  }
500
504
 
501
505
  private utilityExecutorForContractSync(anchorBlock: any) {
502
- return async (call: FunctionCall) => {
506
+ return async (call: FunctionCall, scopes: AccessScopes) => {
503
507
  const entryPointArtifact = await this.contractStore.getFunctionArtifactWithDebugMetadata(call.to, call.selector);
504
508
  if (entryPointArtifact.functionType !== FunctionType.UTILITY) {
505
509
  throw new Error(`Cannot run ${entryPointArtifact.functionType} function as utility`);
506
510
  }
507
511
 
508
512
  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
- );
513
+ const oracle = new UtilityExecutionOracle({
514
+ contractAddress: call.to,
515
+ authWitnesses: [],
516
+ capsules: [],
517
+ anchorBlockHeader: anchorBlock!,
518
+ contractStore: this.contractStore,
519
+ noteStore: this.noteStore,
520
+ keyStore: this.keyStore,
521
+ addressStore: this.addressStore,
522
+ aztecNode: this.stateMachine.node,
523
+ recipientTaggingStore: this.recipientTaggingStore,
524
+ senderAddressBookStore: this.senderAddressBookStore,
525
+ capsuleStore: this.capsuleStore,
526
+ privateEventStore: this.privateEventStore,
527
+ jobId: this.currentJobId,
528
+ scopes,
529
+ });
526
530
  await new WASMSimulator()
527
531
  .executeUserCircuit(toACVMWitness(0, call.args), entryPointArtifact, new Oracle(oracle).toACIRCallback())
528
532
  .catch((err: Error) => {
@@ -87,7 +87,9 @@ export async function makeTXEBlock(
87
87
  const newArchiveInfo = await worldTrees.getTreeInfo(MerkleTreeId.ARCHIVE);
88
88
  const newArchive = new AppendOnlyTreeSnapshot(new Fr(newArchiveInfo.root), Number(newArchiveInfo.size));
89
89
 
90
- // L2Block requires checkpointNumber and indexWithinCheckpoint
90
+ // L2Block requires checkpointNumber and indexWithinCheckpoint.
91
+ // TXE uses 1-block-per-checkpoint for testing simplicity, so we can use block number as checkpoint number.
92
+ // This uses the deprecated fromBlockNumber method intentionally for the TXE testing environment.
91
93
  const checkpointNumber = CheckpointNumber.fromBlockNumber(globalVariables.blockNumber);
92
94
  const indexWithinCheckpoint = IndexWithinCheckpoint(0);
93
95