@aztec/txe 4.0.0-devnet.2-patch.4 → 4.0.0-devnet.3-patch.1

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/index.d.ts +1 -1
  2. package/dest/index.d.ts.map +1 -1
  3. package/dest/index.js +8 -6
  4. package/dest/oracle/interfaces.d.ts +29 -28
  5. package/dest/oracle/interfaces.d.ts.map +1 -1
  6. package/dest/oracle/txe_oracle_public_context.d.ts +13 -13
  7. package/dest/oracle/txe_oracle_public_context.d.ts.map +1 -1
  8. package/dest/oracle/txe_oracle_public_context.js +12 -12
  9. package/dest/oracle/txe_oracle_top_level_context.d.ts +23 -22
  10. package/dest/oracle/txe_oracle_top_level_context.d.ts.map +1 -1
  11. package/dest/oracle/txe_oracle_top_level_context.js +57 -41
  12. package/dest/rpc_translator.d.ts +87 -82
  13. package/dest/rpc_translator.d.ts.map +1 -1
  14. package/dest/rpc_translator.js +285 -152
  15. package/dest/state_machine/archiver.d.ts +3 -3
  16. package/dest/state_machine/archiver.d.ts.map +1 -1
  17. package/dest/state_machine/archiver.js +5 -7
  18. package/dest/state_machine/dummy_p2p_client.d.ts +4 -3
  19. package/dest/state_machine/dummy_p2p_client.d.ts.map +1 -1
  20. package/dest/state_machine/dummy_p2p_client.js +4 -1
  21. package/dest/state_machine/index.d.ts +4 -2
  22. package/dest/state_machine/index.d.ts.map +1 -1
  23. package/dest/state_machine/index.js +6 -2
  24. package/dest/state_machine/synchronizer.d.ts +5 -5
  25. package/dest/state_machine/synchronizer.d.ts.map +1 -1
  26. package/dest/state_machine/synchronizer.js +3 -3
  27. package/dest/txe_session.d.ts +9 -3
  28. package/dest/txe_session.d.ts.map +1 -1
  29. package/dest/txe_session.js +33 -17
  30. package/package.json +15 -15
  31. package/src/index.ts +8 -5
  32. package/src/oracle/interfaces.ts +32 -31
  33. package/src/oracle/txe_oracle_public_context.ts +12 -12
  34. package/src/oracle/txe_oracle_top_level_context.ts +69 -40
  35. package/src/rpc_translator.ts +332 -174
  36. package/src/state_machine/archiver.ts +5 -5
  37. package/src/state_machine/dummy_p2p_client.ts +6 -2
  38. package/src/state_machine/index.ts +5 -1
  39. package/src/state_machine/synchronizer.ts +4 -4
  40. package/src/txe_session.ts +42 -17
@@ -17,7 +17,7 @@ export class TXEArchiver extends ArchiverDataSourceBase {
17
17
  private readonly updater = new ArchiverDataStoreUpdater(this.store);
18
18
 
19
19
  constructor(db: AztecAsyncKVStore) {
20
- const store = new KVArchiverDataStore(db, 9999, { epochDuration: 32 });
20
+ const store = new KVArchiverDataStore(db, 9999);
21
21
  super(store);
22
22
  }
23
23
 
@@ -79,12 +79,12 @@ export class TXEArchiver extends ArchiverDataSourceBase {
79
79
  };
80
80
  }
81
81
 
82
- public getL2SlotNumber(): Promise<SlotNumber | undefined> {
83
- throw new Error('TXE Archiver does not implement "getL2SlotNumber"');
82
+ public getSyncedL2SlotNumber(): Promise<SlotNumber | undefined> {
83
+ throw new Error('TXE Archiver does not implement "getSyncedL2SlotNumber"');
84
84
  }
85
85
 
86
- public getL2EpochNumber(): Promise<EpochNumber | undefined> {
87
- throw new Error('TXE Archiver does not implement "getL2EpochNumber"');
86
+ public getSyncedL2EpochNumber(): Promise<EpochNumber | undefined> {
87
+ throw new Error('TXE Archiver does not implement "getSyncedL2EpochNumber"');
88
88
  }
89
89
 
90
90
  public isEpochComplete(_epochNumber: EpochNumber): Promise<boolean> {
@@ -17,11 +17,11 @@ import type {
17
17
  } from '@aztec/p2p';
18
18
  import type { EthAddress, L2BlockStreamEvent, L2Tips } from '@aztec/stdlib/block';
19
19
  import type { ITxProvider, PeerInfo } from '@aztec/stdlib/interfaces/server';
20
- import type { BlockProposal, CheckpointAttestation, CheckpointProposal } from '@aztec/stdlib/p2p';
20
+ import type { BlockProposal, CheckpointAttestation, CheckpointProposal, TopicType } from '@aztec/stdlib/p2p';
21
21
  import type { BlockHeader, Tx, TxHash } from '@aztec/stdlib/tx';
22
22
 
23
23
  export class DummyP2P implements P2P {
24
- public validate(_txs: Tx[]): Promise<void> {
24
+ public validateTxsReceivedInBlockProposal(_txs: Tx[]): Promise<void> {
25
25
  return Promise.resolve();
26
26
  }
27
27
 
@@ -41,6 +41,10 @@ export class DummyP2P implements P2P {
41
41
  throw new Error('DummyP2P does not implement "getPeers"');
42
42
  }
43
43
 
44
+ public getGossipMeshPeerCount(_topicType: TopicType): Promise<number> {
45
+ return Promise.resolve(0);
46
+ }
47
+
44
48
  public broadcastProposal(_proposal: BlockProposal): Promise<void> {
45
49
  throw new Error('DummyP2P does not implement "broadcastProposal"');
46
50
  }
@@ -4,6 +4,7 @@ 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
6
  import { type AnchorBlockStore, type ContractStore, ContractSyncService, type NoteStore } from '@aztec/pxe/server';
7
+ import { MessageContextService } from '@aztec/pxe/simulator';
7
8
  import { L2Block } from '@aztec/stdlib/block';
8
9
  import { Checkpoint, L1PublishedData, PublishedCheckpoint } from '@aztec/stdlib/checkpoint';
9
10
  import type { AztecNode } from '@aztec/stdlib/interfaces/client';
@@ -26,6 +27,7 @@ export class TXEStateMachine {
26
27
  public archiver: TXEArchiver,
27
28
  public anchorBlockStore: AnchorBlockStore,
28
29
  public contractSyncService: ContractSyncService,
30
+ public messageContextService: MessageContextService,
29
31
  ) {}
30
32
 
31
33
  public static async create(
@@ -68,7 +70,9 @@ export class TXEStateMachine {
68
70
  createLogger('txe:contract_sync'),
69
71
  );
70
72
 
71
- return new this(node, synchronizer, archiver, anchorBlockStore, contractSyncService);
73
+ const messageContextService = new MessageContextService(node);
74
+
75
+ return new this(node, synchronizer, archiver, anchorBlockStore, contractSyncService, messageContextService);
72
76
  }
73
77
 
74
78
  public async handleL2Block(block: L2Block) {
@@ -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 { L2Block } from '@aztec/stdlib/block';
4
+ import type { BlockHash, L2Block } from '@aztec/stdlib/block';
5
5
  import type {
6
6
  MerkleTreeReadOperations,
7
7
  MerkleTreeWriteOperations,
@@ -33,12 +33,12 @@ export class TXESynchronizer implements WorldStateSynchronizer {
33
33
  }
34
34
 
35
35
  /**
36
- * Forces an immediate sync to an optionally provided minimum block number
36
+ * Forces an immediate sync to an optionally provided minimum block number.
37
37
  * @param targetBlockNumber - The target block number that we must sync to. Will download unproven blocks if needed to reach it.
38
- * @param skipThrowIfTargetNotReached - Whether to skip throwing if the target block number is not reached.
38
+ * @param blockHash - If provided, verifies the block at targetBlockNumber matches this hash.
39
39
  * @returns A promise that resolves with the block number the world state was synced to
40
40
  */
41
- public syncImmediate(_minBlockNumber?: BlockNumber, _skipThrowIfTargetNotReached?: boolean): Promise<BlockNumber> {
41
+ public syncImmediate(_minBlockNumber?: BlockNumber, _blockHash?: BlockHash): Promise<BlockNumber> {
42
42
  return Promise.resolve(this.blockNumber);
43
43
  }
44
44
 
@@ -3,12 +3,13 @@ import { Fr } from '@aztec/foundation/curves/bn254';
3
3
  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
- import type { AccessScopes } from '@aztec/pxe/client/lazy';
7
6
  import {
8
7
  AddressStore,
9
8
  AnchorBlockStore,
9
+ CapsuleService,
10
10
  CapsuleStore,
11
11
  ContractStore,
12
+ ContractSyncService,
12
13
  JobCoordinator,
13
14
  NoteService,
14
15
  NoteStore,
@@ -113,6 +114,10 @@ export interface TXESessionStateHandler {
113
114
  enterPublicState(contractAddress?: AztecAddress): Promise<void>;
114
115
  enterPrivateState(contractAddress?: AztecAddress, anchorBlockNumber?: BlockNumber): Promise<PrivateContextInputs>;
115
116
  enterUtilityState(contractAddress?: AztecAddress): Promise<void>;
117
+
118
+ // TODO(F-335): Exposing the job info is abstraction breakage - drop the following 2 functions.
119
+ cycleJob(): Promise<string>;
120
+ getCurrentJob(): string;
116
121
  }
117
122
 
118
123
  /**
@@ -146,6 +151,7 @@ export class TXESession implements TXESessionStateHandler {
146
151
  private chainId: Fr,
147
152
  private version: Fr,
148
153
  private nextBlockTimestamp: bigint,
154
+ private contractSyncService: ContractSyncService,
149
155
  ) {}
150
156
 
151
157
  static async init(contractStore: ContractStore) {
@@ -181,6 +187,9 @@ export class TXESession implements TXESessionStateHandler {
181
187
 
182
188
  const initialJobId = jobCoordinator.beginJob();
183
189
 
190
+ const logger = createLogger('txe:session');
191
+ const contractSyncService = new ContractSyncService(stateMachine.node, contractStore, noteStore, logger);
192
+
184
193
  const topLevelOracleHandler = new TXEOracleTopLevelContext(
185
194
  stateMachine,
186
195
  contractStore,
@@ -193,16 +202,16 @@ export class TXESession implements TXESessionStateHandler {
193
202
  senderAddressBookStore,
194
203
  capsuleStore,
195
204
  privateEventStore,
196
- initialJobId,
197
205
  nextBlockTimestamp,
198
206
  version,
199
207
  chainId,
200
208
  new Map(),
209
+ contractSyncService,
201
210
  );
202
- await topLevelOracleHandler.txeAdvanceBlocksBy(1);
211
+ await topLevelOracleHandler.advanceBlocksBy(1);
203
212
 
204
213
  return new TXESession(
205
- createLogger('txe:session'),
214
+ logger,
206
215
  stateMachine,
207
216
  topLevelOracleHandler,
208
217
  contractStore,
@@ -220,6 +229,7 @@ export class TXESession implements TXESessionStateHandler {
220
229
  version,
221
230
  chainId,
222
231
  nextBlockTimestamp,
232
+ contractSyncService,
223
233
  );
224
234
  }
225
235
 
@@ -254,6 +264,17 @@ export class TXESession implements TXESessionStateHandler {
254
264
  }
255
265
  }
256
266
 
267
+ getCurrentJob(): string {
268
+ return this.currentJobId;
269
+ }
270
+
271
+ /** Commits the current job and begins a new one. Returns the new job ID. */
272
+ async cycleJob(): Promise<string> {
273
+ await this.jobCoordinator.commitJob(this.currentJobId);
274
+ this.currentJobId = this.jobCoordinator.beginJob();
275
+ return this.currentJobId;
276
+ }
277
+
257
278
  async enterTopLevelState() {
258
279
  switch (this.state.name) {
259
280
  case 'PRIVATE': {
@@ -277,8 +298,7 @@ export class TXESession implements TXESessionStateHandler {
277
298
  }
278
299
 
279
300
  // Commit all staged stores from the job that was just completed, then begin a new job
280
- await this.jobCoordinator.commitJob(this.currentJobId);
281
- this.currentJobId = this.jobCoordinator.beginJob();
301
+ await this.cycleJob();
282
302
 
283
303
  this.oracleHandler = new TXEOracleTopLevelContext(
284
304
  this.stateMachine,
@@ -292,11 +312,11 @@ export class TXESession implements TXESessionStateHandler {
292
312
  this.senderAddressBookStore,
293
313
  this.capsuleStore,
294
314
  this.privateEventStore,
295
- this.currentJobId,
296
315
  this.nextBlockTimestamp,
297
316
  this.version,
298
317
  this.chainId,
299
318
  this.authwits,
319
+ this.contractSyncService,
300
320
  );
301
321
 
302
322
  this.state = { name: 'TOP_LEVEL' };
@@ -316,7 +336,7 @@ export class TXESession implements TXESessionStateHandler {
316
336
 
317
337
  await new NoteService(this.noteStore, this.stateMachine.node, anchorBlock!, this.currentJobId).syncNoteNullifiers(
318
338
  contractAddress,
319
- 'ALL_SCOPES',
339
+ await this.keyStore.getAccounts(),
320
340
  );
321
341
  const latestBlock = await this.stateMachine.node.getBlockHeader('latest');
322
342
 
@@ -352,11 +372,12 @@ export class TXESession implements TXESessionStateHandler {
352
372
  senderTaggingStore: this.senderTaggingStore,
353
373
  recipientTaggingStore: this.recipientTaggingStore,
354
374
  senderAddressBookStore: this.senderAddressBookStore,
355
- capsuleStore: this.capsuleStore,
375
+ capsuleService: new CapsuleService(this.capsuleStore, await this.keyStore.getAccounts()),
356
376
  privateEventStore: this.privateEventStore,
357
377
  contractSyncService: this.stateMachine.contractSyncService,
358
378
  jobId: this.currentJobId,
359
- scopes: 'ALL_SCOPES',
379
+ scopes: await this.keyStore.getAccounts(),
380
+ messageContextService: this.stateMachine.messageContextService,
360
381
  });
361
382
 
362
383
  // We store the note and tagging index caches fed into the PrivateExecutionOracle (along with some other auxiliary
@@ -409,7 +430,7 @@ export class TXESession implements TXESessionStateHandler {
409
430
  this.stateMachine.node,
410
431
  anchorBlockHeader,
411
432
  this.currentJobId,
412
- ).syncNoteNullifiers(contractAddress, 'ALL_SCOPES');
433
+ ).syncNoteNullifiers(contractAddress, await this.keyStore.getAccounts());
413
434
 
414
435
  this.oracleHandler = new UtilityExecutionOracle({
415
436
  contractAddress,
@@ -423,10 +444,12 @@ export class TXESession implements TXESessionStateHandler {
423
444
  aztecNode: this.stateMachine.node,
424
445
  recipientTaggingStore: this.recipientTaggingStore,
425
446
  senderAddressBookStore: this.senderAddressBookStore,
426
- capsuleStore: this.capsuleStore,
447
+ capsuleService: new CapsuleService(this.capsuleStore, await this.keyStore.getAccounts()),
427
448
  privateEventStore: this.privateEventStore,
449
+ messageContextService: this.stateMachine.messageContextService,
450
+ contractSyncService: this.contractSyncService,
428
451
  jobId: this.currentJobId,
429
- scopes: 'ALL_SCOPES',
452
+ scopes: await this.keyStore.getAccounts(),
430
453
  });
431
454
 
432
455
  this.state = { name: 'UTILITY' };
@@ -440,8 +463,8 @@ export class TXESession implements TXESessionStateHandler {
440
463
 
441
464
  // Note that while all public and private contexts do is build a single block that we then process when exiting
442
465
  // those, the top level context performs a large number of actions not captured in the following 'close' call. Among
443
- // others, it will create empty blocks (via `txeAdvanceBlocksBy` and `deploy`), create blocks with transactions via
444
- // `txePrivateCallNewFlow` and `txePublicCallNewFlow`, add accounts to PXE via `txeAddAccount`, etc. This is a
466
+ // others, it will create empty blocks (via `advanceBlocksBy` and `deploy`), create blocks with transactions via
467
+ // `privateCallNewFlow` and `publicCallNewFlow`, add accounts to PXE via `addAccount`, etc. This is a
445
468
  // slight inconsistency in the working model of this class, but is not too bad.
446
469
  // TODO: it's quite unfortunate that we need to capture the authwits created to later pass them again when the top
447
470
  // level context is re-created. This is because authwits create a temporary utility context that'd otherwise reset
@@ -495,7 +518,7 @@ export class TXESession implements TXESessionStateHandler {
495
518
  }
496
519
 
497
520
  private utilityExecutorForContractSync(anchorBlock: any) {
498
- return async (call: FunctionCall, scopes: AccessScopes) => {
521
+ return async (call: FunctionCall, scopes: AztecAddress[]) => {
499
522
  const entryPointArtifact = await this.contractStore.getFunctionArtifactWithDebugMetadata(call.to, call.selector);
500
523
  if (entryPointArtifact.functionType !== FunctionType.UTILITY) {
501
524
  throw new Error(`Cannot run ${entryPointArtifact.functionType} function as utility`);
@@ -514,8 +537,10 @@ export class TXESession implements TXESessionStateHandler {
514
537
  aztecNode: this.stateMachine.node,
515
538
  recipientTaggingStore: this.recipientTaggingStore,
516
539
  senderAddressBookStore: this.senderAddressBookStore,
517
- capsuleStore: this.capsuleStore,
540
+ capsuleService: new CapsuleService(this.capsuleStore, scopes),
518
541
  privateEventStore: this.privateEventStore,
542
+ messageContextService: this.stateMachine.messageContextService,
543
+ contractSyncService: this.contractSyncService,
519
544
  jobId: this.currentJobId,
520
545
  scopes,
521
546
  });