@aztec/txe 0.0.1-commit.f5d02921e → 0.0.1-commit.f7ea82942

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.
@@ -1,20 +1,29 @@
1
+ import type { SimulationOverridesPlan } from '@aztec/ethereum/contracts';
1
2
  import { BlockNumber, type SlotNumber } from '@aztec/foundation/branded-types';
3
+ import { times } from '@aztec/foundation/collection';
2
4
  import type { EthAddress } from '@aztec/foundation/eth-address';
3
5
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
4
- import { GasFees } from '@aztec/stdlib/gas';
6
+ import { FEE_ORACLE_LAG, GasFees } from '@aztec/stdlib/gas';
5
7
  import { makeGlobalVariables } from '@aztec/stdlib/testing';
6
8
  import {
7
- type BuildCheckpointGlobalVariablesOpts,
8
9
  type CheckpointGlobalVariables,
10
+ type FeeProvider,
9
11
  type GlobalVariableBuilder,
10
12
  GlobalVariables,
11
13
  } from '@aztec/stdlib/tx';
12
14
 
13
- export class TXEGlobalVariablesBuilder implements GlobalVariableBuilder {
15
+ /** Simple FeeProvider for TXE that returns zero fees. */
16
+ export class TXEFeeProvider implements FeeProvider {
14
17
  public getCurrentMinFees(): Promise<GasFees> {
15
18
  return Promise.resolve(new GasFees(0, 0));
16
19
  }
17
20
 
21
+ public getPredictedMinFees(): Promise<GasFees[]> {
22
+ return Promise.resolve(times(FEE_ORACLE_LAG, () => new GasFees(0, 0)));
23
+ }
24
+ }
25
+
26
+ export class TXEGlobalVariablesBuilder implements GlobalVariableBuilder {
18
27
  public buildGlobalVariables(
19
28
  _blockNumber: BlockNumber,
20
29
  _coinbase: EthAddress,
@@ -28,7 +37,7 @@ export class TXEGlobalVariablesBuilder implements GlobalVariableBuilder {
28
37
  _coinbase: EthAddress,
29
38
  _feeRecipient: AztecAddress,
30
39
  _slotNumber: SlotNumber,
31
- _opts?: BuildCheckpointGlobalVariablesOpts,
40
+ _simulationOverridesPlan?: SimulationOverridesPlan,
32
41
  ): Promise<CheckpointGlobalVariables> {
33
42
  const vars = makeGlobalVariables();
34
43
  return Promise.resolve({
@@ -3,7 +3,6 @@ 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 { KeyStore } from '@aztec/key-store';
7
6
  import { type AnchorBlockStore, type ContractStore, ContractSyncService, type NoteStore } from '@aztec/pxe/server';
8
7
  import { MessageContextService } from '@aztec/pxe/simulator';
9
8
  import { L2Block } from '@aztec/stdlib/block';
@@ -14,7 +13,7 @@ import { getPackageVersion } from '@aztec/stdlib/update-checker';
14
13
 
15
14
  import { TXEArchiver } from './archiver.js';
16
15
  import { DummyP2P } from './dummy_p2p_client.js';
17
- import { TXEGlobalVariablesBuilder } from './global_variable_builder.js';
16
+ import { TXEFeeProvider, TXEGlobalVariablesBuilder } from './global_variable_builder.js';
18
17
  import { MockEpochCache } from './mock_epoch_cache.js';
19
18
  import { TXESynchronizer } from './synchronizer.js';
20
19
 
@@ -36,7 +35,6 @@ export class TXEStateMachine {
36
35
  anchorBlockStore: AnchorBlockStore,
37
36
  contractStore: ContractStore,
38
37
  noteStore: NoteStore,
39
- keyStore: KeyStore,
40
38
  ) {
41
39
  const synchronizer = await TXESynchronizer.create();
42
40
  const aztecNodeConfig = {} as AztecNodeConfig;
@@ -58,6 +56,7 @@ export class TXEStateMachine {
58
56
  VERSION,
59
57
  CHAIN_ID,
60
58
  new TXEGlobalVariablesBuilder(),
59
+ new TXEFeeProvider(),
61
60
  new MockEpochCache(),
62
61
  getPackageVersion() ?? '',
63
62
  new TestCircuitVerifier(),
@@ -70,7 +69,6 @@ export class TXEStateMachine {
70
69
  node,
71
70
  contractStore,
72
71
  noteStore,
73
- () => keyStore.getAccounts(),
74
72
  createLogger('txe:contract_sync'),
75
73
  );
76
74
 
@@ -59,6 +59,10 @@ export class MockEpochCache implements EpochCacheInterface {
59
59
  return false;
60
60
  }
61
61
 
62
+ pipeliningOffset(): number {
63
+ return 0;
64
+ }
65
+
62
66
  getProposerIndexEncoding(_epoch: EpochNumber, _slot: SlotNumber, _seed: bigint): `0x${string}` {
63
67
  return '0x00';
64
68
  }
@@ -3,7 +3,6 @@ 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,
@@ -180,7 +179,7 @@ export class TXESession implements TXESessionStateHandler {
180
179
 
181
180
  const archiver = new TXEArchiver(store);
182
181
  const anchorBlockStore = new AnchorBlockStore(store);
183
- const stateMachine = await TXEStateMachine.create(archiver, anchorBlockStore, contractStore, noteStore, keyStore);
182
+ const stateMachine = await TXEStateMachine.create(archiver, anchorBlockStore, contractStore, noteStore);
184
183
 
185
184
  const nextBlockTimestamp = BigInt(Math.floor(new Date().getTime() / 1000));
186
185
  const version = new Fr(await stateMachine.node.getVersion());
@@ -189,13 +188,7 @@ export class TXESession implements TXESessionStateHandler {
189
188
  const initialJobId = jobCoordinator.beginJob();
190
189
 
191
190
  const logger = createLogger('txe:session');
192
- const contractSyncService = new ContractSyncService(
193
- stateMachine.node,
194
- contractStore,
195
- noteStore,
196
- () => keyStore.getAccounts(),
197
- logger,
198
- );
191
+ const contractSyncService = new ContractSyncService(stateMachine.node, contractStore, noteStore, logger);
199
192
 
200
193
  const topLevelOracleHandler = new TXEOracleTopLevelContext(
201
194
  stateMachine,
@@ -343,7 +336,7 @@ export class TXESession implements TXESessionStateHandler {
343
336
 
344
337
  await new NoteService(this.noteStore, this.stateMachine.node, anchorBlock!, this.currentJobId).syncNoteNullifiers(
345
338
  contractAddress,
346
- 'ALL_SCOPES',
339
+ await this.keyStore.getAccounts(),
347
340
  );
348
341
  const latestBlock = await this.stateMachine.node.getBlockHeader('latest');
349
342
 
@@ -379,11 +372,12 @@ export class TXESession implements TXESessionStateHandler {
379
372
  senderTaggingStore: this.senderTaggingStore,
380
373
  recipientTaggingStore: this.recipientTaggingStore,
381
374
  senderAddressBookStore: this.senderAddressBookStore,
382
- capsuleService: new CapsuleService(this.capsuleStore, 'ALL_SCOPES'),
375
+ capsuleService: new CapsuleService(this.capsuleStore, await this.keyStore.getAccounts()),
383
376
  privateEventStore: this.privateEventStore,
384
377
  contractSyncService: this.stateMachine.contractSyncService,
378
+ l2TipsStore: this.stateMachine.node,
385
379
  jobId: this.currentJobId,
386
- scopes: 'ALL_SCOPES',
380
+ scopes: await this.keyStore.getAccounts(),
387
381
  messageContextService: this.stateMachine.messageContextService,
388
382
  });
389
383
 
@@ -437,7 +431,7 @@ export class TXESession implements TXESessionStateHandler {
437
431
  this.stateMachine.node,
438
432
  anchorBlockHeader,
439
433
  this.currentJobId,
440
- ).syncNoteNullifiers(contractAddress, 'ALL_SCOPES');
434
+ ).syncNoteNullifiers(contractAddress, await this.keyStore.getAccounts());
441
435
 
442
436
  this.oracleHandler = new UtilityExecutionOracle({
443
437
  contractAddress,
@@ -451,12 +445,13 @@ export class TXESession implements TXESessionStateHandler {
451
445
  aztecNode: this.stateMachine.node,
452
446
  recipientTaggingStore: this.recipientTaggingStore,
453
447
  senderAddressBookStore: this.senderAddressBookStore,
454
- capsuleService: new CapsuleService(this.capsuleStore, 'ALL_SCOPES'),
448
+ capsuleService: new CapsuleService(this.capsuleStore, await this.keyStore.getAccounts()),
455
449
  privateEventStore: this.privateEventStore,
456
450
  messageContextService: this.stateMachine.messageContextService,
457
451
  contractSyncService: this.contractSyncService,
452
+ l2TipsStore: this.stateMachine.node,
458
453
  jobId: this.currentJobId,
459
- scopes: 'ALL_SCOPES',
454
+ scopes: await this.keyStore.getAccounts(),
460
455
  });
461
456
 
462
457
  this.state = { name: 'UTILITY' };
@@ -525,7 +520,7 @@ export class TXESession implements TXESessionStateHandler {
525
520
  }
526
521
 
527
522
  private utilityExecutorForContractSync(anchorBlock: any) {
528
- return async (call: FunctionCall, scopes: AccessScopes) => {
523
+ return async (call: FunctionCall, scopes: AztecAddress[]) => {
529
524
  const entryPointArtifact = await this.contractStore.getFunctionArtifactWithDebugMetadata(call.to, call.selector);
530
525
  if (entryPointArtifact.functionType !== FunctionType.UTILITY) {
531
526
  throw new Error(`Cannot run ${entryPointArtifact.functionType} function as utility`);
@@ -548,6 +543,7 @@ export class TXESession implements TXESessionStateHandler {
548
543
  privateEventStore: this.privateEventStore,
549
544
  messageContextService: this.stateMachine.messageContextService,
550
545
  contractSyncService: this.contractSyncService,
546
+ l2TipsStore: this.stateMachine.node,
551
547
  jobId: this.currentJobId,
552
548
  scopes,
553
549
  });
@@ -3,6 +3,7 @@ import type { EthAddress } from '@aztec/foundation/eth-address';
3
3
  import { hexToBuffer } from '@aztec/foundation/string';
4
4
  import { type ContractArtifact, ContractArtifactSchema } from '@aztec/stdlib/abi';
5
5
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
6
+ import { BlockHash } from '@aztec/stdlib/block';
6
7
  import { type ContractInstanceWithAddress, ContractInstanceWithAddressSchema } from '@aztec/stdlib/contract';
7
8
 
8
9
  import { z } from 'zod';
@@ -25,6 +26,10 @@ export function addressFromSingle(obj: ForeignCallSingle) {
25
26
  return new AztecAddress(fromSingle(obj));
26
27
  }
27
28
 
29
+ export function blockHashFromSingle(obj: ForeignCallSingle) {
30
+ return new BlockHash(fromSingle(obj));
31
+ }
32
+
28
33
  export function fromArray(obj: ForeignCallArray) {
29
34
  return obj.map(str => Fr.fromBuffer(hexToBuffer(str)));
30
35
  }