@aztec/aztec-node 0.67.1 → 0.68.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.
package/package.json CHANGED
@@ -1,9 +1,12 @@
1
1
  {
2
2
  "name": "@aztec/aztec-node",
3
- "version": "0.67.1",
3
+ "version": "0.68.1",
4
4
  "main": "dest/index.js",
5
5
  "type": "module",
6
- "exports": "./dest/index.js",
6
+ "exports": {
7
+ ".": "./dest/index.js",
8
+ "./config": "./dest/aztec-node/config.js"
9
+ },
7
10
  "bin": "./dest/bin/index.js",
8
11
  "typedocOptions": {
9
12
  "entryPoints": [
@@ -20,7 +23,7 @@
20
23
  "clean": "rm -rf ./dest .tsbuildinfo",
21
24
  "formatting": "run -T prettier --check ./src && run -T eslint ./src",
22
25
  "formatting:fix": "run -T eslint --fix ./src && run -T prettier -w ./src",
23
- "test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --passWithNoTests"
26
+ "test": "HARDWARE_CONCURRENCY=${HARDWARE_CONCURRENCY:-16} RAYON_NUM_THREADS=${RAYON_NUM_THREADS:-4} NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --passWithNoTests --maxWorkers=${JEST_MAX_WORKERS:-8}"
24
27
  },
25
28
  "inherits": [
26
29
  "../package.common.json"
@@ -52,9 +55,9 @@
52
55
  "rootDir": "./src",
53
56
  "reporters": [
54
57
  [
55
- "default",
58
+ "jest-silent-reporter",
56
59
  {
57
- "summaryThreshold": 9999
60
+ "useDots": true
58
61
  }
59
62
  ]
60
63
  ],
@@ -64,23 +67,24 @@
64
67
  ]
65
68
  },
66
69
  "dependencies": {
67
- "@aztec/archiver": "0.67.1",
68
- "@aztec/bb-prover": "0.67.1",
69
- "@aztec/circuit-types": "0.67.1",
70
- "@aztec/circuits.js": "0.67.1",
71
- "@aztec/ethereum": "0.67.1",
72
- "@aztec/foundation": "0.67.1",
73
- "@aztec/kv-store": "0.67.1",
74
- "@aztec/merkle-tree": "0.67.1",
75
- "@aztec/p2p": "0.67.1",
76
- "@aztec/protocol-contracts": "0.67.1",
77
- "@aztec/prover-client": "0.67.1",
78
- "@aztec/sequencer-client": "0.67.1",
79
- "@aztec/simulator": "0.67.1",
80
- "@aztec/telemetry-client": "0.67.1",
81
- "@aztec/types": "0.67.1",
82
- "@aztec/validator-client": "0.67.1",
83
- "@aztec/world-state": "0.67.1",
70
+ "@aztec/archiver": "0.68.1",
71
+ "@aztec/bb-prover": "0.68.1",
72
+ "@aztec/circuit-types": "0.68.1",
73
+ "@aztec/circuits.js": "0.68.1",
74
+ "@aztec/epoch-cache": "0.68.1",
75
+ "@aztec/ethereum": "0.68.1",
76
+ "@aztec/foundation": "0.68.1",
77
+ "@aztec/kv-store": "0.68.1",
78
+ "@aztec/merkle-tree": "0.68.1",
79
+ "@aztec/p2p": "0.68.1",
80
+ "@aztec/protocol-contracts": "0.68.1",
81
+ "@aztec/prover-client": "0.68.1",
82
+ "@aztec/sequencer-client": "0.68.1",
83
+ "@aztec/simulator": "0.68.1",
84
+ "@aztec/telemetry-client": "0.68.1",
85
+ "@aztec/types": "0.68.1",
86
+ "@aztec/validator-client": "0.68.1",
87
+ "@aztec/world-state": "0.68.1",
84
88
  "koa": "^2.14.2",
85
89
  "koa-router": "^12.0.0",
86
90
  "tslib": "^2.4.0"
@@ -1,11 +1,11 @@
1
- import { type ArchiverConfig, archiverConfigMappings } from '@aztec/archiver';
1
+ import { type ArchiverConfig, archiverConfigMappings } from '@aztec/archiver/config';
2
2
  import { type ConfigMappingsType, booleanConfigHelper, getConfigFromMappings } from '@aztec/foundation/config';
3
3
  import { type DataStoreConfig, dataConfigMappings } from '@aztec/kv-store/config';
4
- import { type P2PConfig, p2pConfigMappings } from '@aztec/p2p';
5
- import { type ProverClientConfig, proverClientConfigMappings } from '@aztec/prover-client';
6
- import { type SequencerClientConfig, sequencerClientConfigMappings } from '@aztec/sequencer-client';
7
- import { type ValidatorClientConfig, validatorClientConfigMappings } from '@aztec/validator-client';
8
- import { type WorldStateConfig, worldStateConfigMappings } from '@aztec/world-state';
4
+ import { type P2PConfig, p2pConfigMappings } from '@aztec/p2p/config';
5
+ import { type ProverClientConfig, proverClientConfigMappings } from '@aztec/prover-client/config';
6
+ import { type SequencerClientConfig, sequencerClientConfigMappings } from '@aztec/sequencer-client/config';
7
+ import { type ValidatorClientConfig, validatorClientConfigMappings } from '@aztec/validator-client/config';
8
+ import { type WorldStateConfig, worldStateConfigMappings } from '@aztec/world-state/config';
9
9
 
10
10
  import { readFileSync } from 'fs';
11
11
  import { dirname, resolve } from 'path';
@@ -15,6 +15,7 @@ import {
15
15
  MerkleTreeId,
16
16
  NullifierMembershipWitness,
17
17
  type NullifierWithBlockSource,
18
+ P2PClientType,
18
19
  type ProcessedTx,
19
20
  type ProverConfig,
20
21
  PublicDataWitness,
@@ -53,12 +54,12 @@ import {
53
54
  type PublicDataTreeLeafPreimage,
54
55
  } from '@aztec/circuits.js';
55
56
  import { computePublicDataTreeLeafSlot } from '@aztec/circuits.js/hash';
57
+ import { EpochCache } from '@aztec/epoch-cache';
56
58
  import { type L1ContractAddresses, createEthereumChain } from '@aztec/ethereum';
57
- import { type ContractArtifact } from '@aztec/foundation/abi';
58
59
  import { AztecAddress } from '@aztec/foundation/aztec-address';
59
60
  import { padArrayEnd } from '@aztec/foundation/collection';
60
61
  import { type Logger, createLogger } from '@aztec/foundation/log';
61
- import { Timer } from '@aztec/foundation/timer';
62
+ import { DateProvider, Timer } from '@aztec/foundation/timer';
62
63
  import { type AztecKVStore } from '@aztec/kv-store';
63
64
  import { openTmpStore } from '@aztec/kv-store/lmdb';
64
65
  import { SHA256Trunc, StandardTree, UnbalancedTree } from '@aztec/merkle-tree';
@@ -74,7 +75,7 @@ import {
74
75
  import { ProtocolContractAddress } from '@aztec/protocol-contracts';
75
76
  import { GlobalVariableBuilder, type L1Publisher, SequencerClient } from '@aztec/sequencer-client';
76
77
  import { PublicProcessorFactory } from '@aztec/simulator';
77
- import { type TelemetryClient } from '@aztec/telemetry-client';
78
+ import { Attributes, type TelemetryClient, type Traceable, type Tracer, trackSpan } from '@aztec/telemetry-client';
78
79
  import { NoopTelemetryClient } from '@aztec/telemetry-client/noop';
79
80
  import { createValidatorClient } from '@aztec/validator-client';
80
81
  import { createWorldStateSynchronizer } from '@aztec/world-state';
@@ -85,11 +86,12 @@ import { NodeMetrics } from './node_metrics.js';
85
86
  /**
86
87
  * The aztec node.
87
88
  */
88
- export class AztecNodeService implements AztecNode {
89
+ export class AztecNodeService implements AztecNode, Traceable {
89
90
  private packageVersion: string;
90
-
91
91
  private metrics: NodeMetrics;
92
92
 
93
+ public readonly tracer: Tracer;
94
+
93
95
  constructor(
94
96
  protected config: AztecNodeConfig,
95
97
  protected readonly p2pClient: P2P,
@@ -109,6 +111,7 @@ export class AztecNodeService implements AztecNode {
109
111
  ) {
110
112
  this.packageVersion = getPackageInfo().version;
111
113
  this.metrics = new NodeMetrics(telemetry, 'AztecNodeService');
114
+ this.tracer = telemetry.getTracer('AztecNodeService');
112
115
 
113
116
  this.log.info(`Aztec Node started on chain 0x${l1ChainId.toString(16)}`, config.l1Contracts);
114
117
  }
@@ -136,10 +139,12 @@ export class AztecNodeService implements AztecNode {
136
139
  telemetry?: TelemetryClient;
137
140
  logger?: Logger;
138
141
  publisher?: L1Publisher;
142
+ dateProvider?: DateProvider;
139
143
  } = {},
140
144
  ): Promise<AztecNodeService> {
141
145
  const telemetry = deps.telemetry ?? new NoopTelemetryClient();
142
146
  const log = deps.logger ?? createLogger('node');
147
+ const dateProvider = deps.dateProvider ?? new DateProvider();
143
148
  const ethereumChain = createEthereumChain(config.l1RpcUrl, config.l1ChainId);
144
149
  //validate that the actual chain id matches that specified in configuration
145
150
  if (config.l1ChainId !== ethereumChain.chainInfo.id) {
@@ -152,7 +157,8 @@ export class AztecNodeService implements AztecNode {
152
157
 
153
158
  // we identify the P2P transaction protocol by using the rollup contract address.
154
159
  // this may well change in future
155
- config.transactionProtocol = `/aztec/tx/${config.l1Contracts.rollupAddress.toString()}`;
160
+ const rollupAddress = config.l1Contracts.rollupAddress;
161
+ config.transactionProtocol = `/aztec/tx/${rollupAddress.toString()}`;
156
162
 
157
163
  // now create the merkle trees and the world state synchronizer
158
164
  const worldStateSynchronizer = await createWorldStateSynchronizer(config, archiver, telemetry);
@@ -161,13 +167,23 @@ export class AztecNodeService implements AztecNode {
161
167
  log.warn(`Aztec node is accepting fake proofs`);
162
168
  }
163
169
 
170
+ const epochCache = await EpochCache.create(config.l1Contracts.rollupAddress, config, { dateProvider });
171
+
164
172
  // create the tx pool and the p2p client, which will need the l2 block source
165
- const p2pClient = await createP2PClient(config, archiver, proofVerifier, worldStateSynchronizer, telemetry);
173
+ const p2pClient = await createP2PClient(
174
+ P2PClientType.Full,
175
+ config,
176
+ archiver,
177
+ proofVerifier,
178
+ worldStateSynchronizer,
179
+ epochCache,
180
+ telemetry,
181
+ );
166
182
 
167
183
  // start both and wait for them to sync from the block source
168
184
  await Promise.all([p2pClient.start(), worldStateSynchronizer.start()]);
169
185
 
170
- const validatorClient = await createValidatorClient(config, config.l1Contracts.rollupAddress, p2pClient, telemetry);
186
+ const validatorClient = createValidatorClient(config, { p2pClient, telemetry, dateProvider, epochCache });
171
187
 
172
188
  // now create the sequencer
173
189
  const sequencer = config.disableValidator
@@ -180,6 +196,7 @@ export class AztecNodeService implements AztecNode {
180
196
  l2BlockSource: archiver,
181
197
  l1ToL2MessageSource: archiver,
182
198
  telemetry,
199
+ dateProvider,
183
200
  ...deps,
184
201
  });
185
202
 
@@ -214,6 +231,10 @@ export class AztecNodeService implements AztecNode {
214
231
  return this.blockSource;
215
232
  }
216
233
 
234
+ public getContractDataSource(): ContractDataSource {
235
+ return this.contractDataSource;
236
+ }
237
+
217
238
  public getP2P(): P2P {
218
239
  return this.p2pClient;
219
240
  }
@@ -457,7 +478,10 @@ export class AztecNodeService implements AztecNode {
457
478
  leafValues: Fr[],
458
479
  ): Promise<(bigint | undefined)[]> {
459
480
  const committedDb = await this.#getWorldState(blockNumber);
460
- return await Promise.all(leafValues.map(leafValue => committedDb.findLeafIndex(treeId, leafValue.toBuffer())));
481
+ return await committedDb.findLeafIndices(
482
+ treeId,
483
+ leafValues.map(x => x.toBuffer()),
484
+ );
461
485
  }
462
486
 
463
487
  /**
@@ -664,7 +688,7 @@ export class AztecNodeService implements AztecNode {
664
688
  nullifier: Fr,
665
689
  ): Promise<NullifierMembershipWitness | undefined> {
666
690
  const db = await this.#getWorldState(blockNumber);
667
- const index = await db.findLeafIndex(MerkleTreeId.NULLIFIER_TREE, nullifier.toBuffer());
691
+ const index = (await db.findLeafIndices(MerkleTreeId.NULLIFIER_TREE, [nullifier.toBuffer()]))[0];
668
692
  if (!index) {
669
693
  return undefined;
670
694
  }
@@ -779,7 +803,10 @@ export class AztecNodeService implements AztecNode {
779
803
  * Simulates the public part of a transaction with the current state.
780
804
  * @param tx - The transaction to simulate.
781
805
  **/
782
- public async simulatePublicCalls(tx: Tx): Promise<PublicSimulationOutput> {
806
+ @trackSpan('AztecNodeService.simulatePublicCalls', (tx: Tx) => ({
807
+ [Attributes.TX_HASH]: tx.tryGetTxHash()?.toString(),
808
+ }))
809
+ public async simulatePublicCalls(tx: Tx, enforceFeePayment = true): Promise<PublicSimulationOutput> {
783
810
  const txHash = tx.getTxHash();
784
811
  const blockNumber = (await this.blockSource.getBlockNumber()) + 1;
785
812
 
@@ -793,7 +820,11 @@ export class AztecNodeService implements AztecNode {
793
820
  feeRecipient,
794
821
  );
795
822
  const prevHeader = (await this.blockSource.getBlock(-1))?.header;
796
- const publicProcessorFactory = new PublicProcessorFactory(this.contractDataSource, this.telemetry);
823
+ const publicProcessorFactory = new PublicProcessorFactory(
824
+ this.contractDataSource,
825
+ new DateProvider(),
826
+ this.telemetry,
827
+ );
797
828
  const fork = await this.worldStateSynchronizer.fork();
798
829
 
799
830
  this.log.verbose(`Simulating public calls for tx ${tx.getTxHash()}`, {
@@ -803,7 +834,7 @@ export class AztecNodeService implements AztecNode {
803
834
  });
804
835
 
805
836
  try {
806
- const processor = publicProcessorFactory.create(fork, prevHeader, newGlobalVariables);
837
+ const processor = publicProcessorFactory.create(fork, prevHeader, newGlobalVariables, enforceFeePayment);
807
838
 
808
839
  // REFACTOR: Consider merging ProcessReturnValues into ProcessedTx
809
840
  const [processedTxs, failedTxs, returns] = await processor.process([tx]);
@@ -836,9 +867,7 @@ export class AztecNodeService implements AztecNode {
836
867
  new DataTxValidator(),
837
868
  new MetadataTxValidator(new Fr(this.l1ChainId), new Fr(blockNumber)),
838
869
  new DoubleSpendTxValidator({
839
- getNullifierIndex(nullifier) {
840
- return db.findLeafIndex(MerkleTreeId.NULLIFIER_TREE, nullifier.toBuffer());
841
- },
870
+ getNullifierIndices: nullifiers => db.findLeafIndices(MerkleTreeId.NULLIFIER_TREE, nullifiers),
842
871
  }),
843
872
  ];
844
873
 
@@ -884,10 +913,8 @@ export class AztecNodeService implements AztecNode {
884
913
  return this.contractDataSource.addContractClass(contractClass);
885
914
  }
886
915
 
887
- public addContractArtifact(address: AztecAddress, artifact: ContractArtifact): Promise<void> {
888
- this.log.info(`Adding contract artifact ${artifact.name} for ${address.toString()} via API`);
889
- // TODO: Node should validate the artifact before accepting it
890
- return this.contractDataSource.addContractArtifact(address, artifact);
916
+ public registerContractFunctionNames(_address: AztecAddress, names: Record<string, string>): Promise<void> {
917
+ return this.contractDataSource.registerContractFunctionNames(_address, names);
891
918
  }
892
919
 
893
920
  public flushTxs(): Promise<void> {