@aztec/aztec-node 0.67.1 → 0.68.0
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/dest/aztec-node/config.d.ts +6 -6
- package/dest/aztec-node/config.d.ts.map +1 -1
- package/dest/aztec-node/config.js +7 -7
- package/dest/aztec-node/server.d.ts +7 -5
- package/dest/aztec-node/server.d.ts.map +1 -1
- package/dest/aztec-node/server.js +674 -656
- package/package.json +26 -22
- package/src/aztec-node/config.ts +6 -6
- package/src/aztec-node/server.ts +37 -19
package/package.json
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/aztec-node",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.68.0",
|
|
4
4
|
"main": "dest/index.js",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"exports":
|
|
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=16 RAYON_NUM_THREADS=4 NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --passWithNoTests --maxWorkers=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
|
-
"
|
|
58
|
+
"jest-silent-reporter",
|
|
56
59
|
{
|
|
57
|
-
"
|
|
60
|
+
"useDots": true
|
|
58
61
|
}
|
|
59
62
|
]
|
|
60
63
|
],
|
|
@@ -64,23 +67,24 @@
|
|
|
64
67
|
]
|
|
65
68
|
},
|
|
66
69
|
"dependencies": {
|
|
67
|
-
"@aztec/archiver": "0.
|
|
68
|
-
"@aztec/bb-prover": "0.
|
|
69
|
-
"@aztec/circuit-types": "0.
|
|
70
|
-
"@aztec/circuits.js": "0.
|
|
71
|
-
"@aztec/
|
|
72
|
-
"@aztec/
|
|
73
|
-
"@aztec/
|
|
74
|
-
"@aztec/
|
|
75
|
-
"@aztec/
|
|
76
|
-
"@aztec/
|
|
77
|
-
"@aztec/
|
|
78
|
-
"@aztec/
|
|
79
|
-
"@aztec/
|
|
80
|
-
"@aztec/
|
|
81
|
-
"@aztec/
|
|
82
|
-
"@aztec/
|
|
83
|
-
"@aztec/
|
|
70
|
+
"@aztec/archiver": "0.68.0",
|
|
71
|
+
"@aztec/bb-prover": "0.68.0",
|
|
72
|
+
"@aztec/circuit-types": "0.68.0",
|
|
73
|
+
"@aztec/circuits.js": "0.68.0",
|
|
74
|
+
"@aztec/epoch-cache": "0.68.0",
|
|
75
|
+
"@aztec/ethereum": "0.68.0",
|
|
76
|
+
"@aztec/foundation": "0.68.0",
|
|
77
|
+
"@aztec/kv-store": "0.68.0",
|
|
78
|
+
"@aztec/merkle-tree": "0.68.0",
|
|
79
|
+
"@aztec/p2p": "0.68.0",
|
|
80
|
+
"@aztec/protocol-contracts": "0.68.0",
|
|
81
|
+
"@aztec/prover-client": "0.68.0",
|
|
82
|
+
"@aztec/sequencer-client": "0.68.0",
|
|
83
|
+
"@aztec/simulator": "0.68.0",
|
|
84
|
+
"@aztec/telemetry-client": "0.68.0",
|
|
85
|
+
"@aztec/types": "0.68.0",
|
|
86
|
+
"@aztec/validator-client": "0.68.0",
|
|
87
|
+
"@aztec/world-state": "0.68.0",
|
|
84
88
|
"koa": "^2.14.2",
|
|
85
89
|
"koa-router": "^12.0.0",
|
|
86
90
|
"tslib": "^2.4.0"
|
package/src/aztec-node/config.ts
CHANGED
|
@@ -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';
|
package/src/aztec-node/server.ts
CHANGED
|
@@ -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
|
-
|
|
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(
|
|
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 =
|
|
186
|
+
const validatorClient = createValidatorClient(config, { p2pClient, telemetry, dateProvider, epochCache });
|
|
171
187
|
|
|
172
188
|
// now create the sequencer
|
|
173
189
|
const sequencer = config.disableValidator
|
|
@@ -457,7 +473,10 @@ export class AztecNodeService implements AztecNode {
|
|
|
457
473
|
leafValues: Fr[],
|
|
458
474
|
): Promise<(bigint | undefined)[]> {
|
|
459
475
|
const committedDb = await this.#getWorldState(blockNumber);
|
|
460
|
-
return await
|
|
476
|
+
return await committedDb.findLeafIndices(
|
|
477
|
+
treeId,
|
|
478
|
+
leafValues.map(x => x.toBuffer()),
|
|
479
|
+
);
|
|
461
480
|
}
|
|
462
481
|
|
|
463
482
|
/**
|
|
@@ -664,7 +683,7 @@ export class AztecNodeService implements AztecNode {
|
|
|
664
683
|
nullifier: Fr,
|
|
665
684
|
): Promise<NullifierMembershipWitness | undefined> {
|
|
666
685
|
const db = await this.#getWorldState(blockNumber);
|
|
667
|
-
const index = await db.
|
|
686
|
+
const index = (await db.findLeafIndices(MerkleTreeId.NULLIFIER_TREE, [nullifier.toBuffer()]))[0];
|
|
668
687
|
if (!index) {
|
|
669
688
|
return undefined;
|
|
670
689
|
}
|
|
@@ -779,7 +798,10 @@ export class AztecNodeService implements AztecNode {
|
|
|
779
798
|
* Simulates the public part of a transaction with the current state.
|
|
780
799
|
* @param tx - The transaction to simulate.
|
|
781
800
|
**/
|
|
782
|
-
|
|
801
|
+
@trackSpan('AztecNodeService.simulatePublicCalls', (tx: Tx) => ({
|
|
802
|
+
[Attributes.TX_HASH]: tx.tryGetTxHash()?.toString(),
|
|
803
|
+
}))
|
|
804
|
+
public async simulatePublicCalls(tx: Tx, enforceFeePayment = true): Promise<PublicSimulationOutput> {
|
|
783
805
|
const txHash = tx.getTxHash();
|
|
784
806
|
const blockNumber = (await this.blockSource.getBlockNumber()) + 1;
|
|
785
807
|
|
|
@@ -803,7 +825,7 @@ export class AztecNodeService implements AztecNode {
|
|
|
803
825
|
});
|
|
804
826
|
|
|
805
827
|
try {
|
|
806
|
-
const processor = publicProcessorFactory.create(fork, prevHeader, newGlobalVariables);
|
|
828
|
+
const processor = publicProcessorFactory.create(fork, prevHeader, newGlobalVariables, enforceFeePayment);
|
|
807
829
|
|
|
808
830
|
// REFACTOR: Consider merging ProcessReturnValues into ProcessedTx
|
|
809
831
|
const [processedTxs, failedTxs, returns] = await processor.process([tx]);
|
|
@@ -836,9 +858,7 @@ export class AztecNodeService implements AztecNode {
|
|
|
836
858
|
new DataTxValidator(),
|
|
837
859
|
new MetadataTxValidator(new Fr(this.l1ChainId), new Fr(blockNumber)),
|
|
838
860
|
new DoubleSpendTxValidator({
|
|
839
|
-
|
|
840
|
-
return db.findLeafIndex(MerkleTreeId.NULLIFIER_TREE, nullifier.toBuffer());
|
|
841
|
-
},
|
|
861
|
+
getNullifierIndices: nullifiers => db.findLeafIndices(MerkleTreeId.NULLIFIER_TREE, nullifiers),
|
|
842
862
|
}),
|
|
843
863
|
];
|
|
844
864
|
|
|
@@ -884,10 +904,8 @@ export class AztecNodeService implements AztecNode {
|
|
|
884
904
|
return this.contractDataSource.addContractClass(contractClass);
|
|
885
905
|
}
|
|
886
906
|
|
|
887
|
-
public
|
|
888
|
-
this.
|
|
889
|
-
// TODO: Node should validate the artifact before accepting it
|
|
890
|
-
return this.contractDataSource.addContractArtifact(address, artifact);
|
|
907
|
+
public registerContractFunctionNames(_address: AztecAddress, names: Record<string, string>): Promise<void> {
|
|
908
|
+
return this.contractDataSource.registerContractFunctionNames(_address, names);
|
|
891
909
|
}
|
|
892
910
|
|
|
893
911
|
public flushTxs(): Promise<void> {
|