@aztec/aztec-node 0.81.0 → 0.82.1-alpha-testnet.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/dest/aztec-node/config.d.ts +3 -0
- package/dest/aztec-node/config.d.ts.map +1 -1
- package/dest/aztec-node/config.js +6 -1
- package/dest/aztec-node/server.d.ts +13 -22
- package/dest/aztec-node/server.d.ts.map +1 -1
- package/dest/aztec-node/server.js +72 -51
- package/package.json +19 -19
- package/src/aztec-node/config.ts +8 -1
- package/src/aztec-node/server.ts +84 -70
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type ArchiverConfig } from '@aztec/archiver/config';
|
|
2
|
+
import { type L1ContractAddresses } from '@aztec/ethereum';
|
|
2
3
|
import { type ConfigMappingsType } from '@aztec/foundation/config';
|
|
3
4
|
import { type DataStoreConfig } from '@aztec/kv-store/config';
|
|
4
5
|
import { type P2PConfig } from '@aztec/p2p/config';
|
|
@@ -15,6 +16,8 @@ export type AztecNodeConfig = ArchiverConfig & SequencerClientConfig & Validator
|
|
|
15
16
|
disableValidator: boolean;
|
|
16
17
|
/** Whether to populate the genesis state with initial fee juice for the test accounts */
|
|
17
18
|
testAccounts: boolean;
|
|
19
|
+
} & {
|
|
20
|
+
l1Contracts: L1ContractAddresses;
|
|
18
21
|
};
|
|
19
22
|
export declare const aztecNodeConfigMappings: ConfigMappingsType<AztecNodeConfig>;
|
|
20
23
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/aztec-node/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAA0B,MAAM,wBAAwB,CAAC;AACrF,OAAO,EAAE,KAAK,kBAAkB,EAA8C,MAAM,0BAA0B,CAAC;AAC/G,OAAO,EAAE,KAAK,eAAe,EAAsB,MAAM,wBAAwB,CAAC;AAClF,OAAO,EAAE,KAAK,SAAS,EAAqB,MAAM,mBA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AAqB,EAAiC,MAAM,gCAAgC,CAAC;AAC3G,OAAO,EAAE,KAAK,gBAAgB,EAA4B,MAAM,2BAA2B,CAAC;AAM5F,OAAO,EAAE,6BAA6B,EAAE,KAAK,qBAAqB,EAAE,CAAC;AAErE;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,cAAc,GAC1C,qBAAqB,GACrB,qBAAqB,GACrB,kBAAkB,GAClB,gBAAgB,GAChB,IAAI,CAAC,kBAAkB,EAAE,cAAc,GAAG,oBAAoB,GAAG,YAAY,CAAC,GAC9E,SAAS,GACT,eAAe,GAAG;IAChB,sDAAsD;IACtD,gBAAgB,EAAE,OAAO,CAAC;IAC1B,yFAAyF;IACzF,YAAY,EAAE,OAAO,CAAC;CACvB,GAAG;IACF,WAAW,EAAE,mBAAmB,CAAC;CAClC,CAAC;AAEJ,eAAO,MAAM,uBAAuB,EAAE,kBAAkB,CAAC,eAAe,CAsBvE,CAAC;AAEF;;;GAGG;AACH,wBAAgB,gBAAgB,IAAI,eAAe,CAElD;AAED;;GAEG;AACH,wBAAgB,iBAAiB,QAOhC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { archiverConfigMappings } from '@aztec/archiver/config';
|
|
2
|
+
import { l1ContractAddressesMapping } from '@aztec/ethereum';
|
|
2
3
|
import { booleanConfigHelper, getConfigFromMappings } from '@aztec/foundation/config';
|
|
3
4
|
import { dataConfigMappings } from '@aztec/kv-store/config';
|
|
4
5
|
import { p2pConfigMappings } from '@aztec/p2p/config';
|
|
@@ -11,13 +12,17 @@ import { dirname, resolve } from 'path';
|
|
|
11
12
|
import { fileURLToPath } from 'url';
|
|
12
13
|
export { sequencerClientConfigMappings };
|
|
13
14
|
export const aztecNodeConfigMappings = {
|
|
15
|
+
...dataConfigMappings,
|
|
14
16
|
...archiverConfigMappings,
|
|
15
17
|
...sequencerClientConfigMappings,
|
|
16
18
|
...validatorClientConfigMappings,
|
|
17
19
|
...proverClientConfigMappings,
|
|
18
20
|
...worldStateConfigMappings,
|
|
19
21
|
...p2pConfigMappings,
|
|
20
|
-
|
|
22
|
+
l1Contracts: {
|
|
23
|
+
description: 'The deployed L1 contract addresses',
|
|
24
|
+
nested: l1ContractAddressesMapping
|
|
25
|
+
},
|
|
21
26
|
disableValidator: {
|
|
22
27
|
env: 'VALIDATOR_DISABLED',
|
|
23
28
|
description: 'Whether the validator is disabled for this node.',
|
|
@@ -8,22 +8,22 @@ import { SiblingPath } from '@aztec/foundation/trees';
|
|
|
8
8
|
import { type P2P } from '@aztec/p2p';
|
|
9
9
|
import { GlobalVariableBuilder, SequencerClient, type SequencerPublisher } from '@aztec/sequencer-client';
|
|
10
10
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
11
|
-
import type { InBlock, L2Block, L2BlockNumber, L2BlockSource,
|
|
11
|
+
import type { InBlock, L2Block, L2BlockNumber, L2BlockSource, PublishedL2Block } from '@aztec/stdlib/block';
|
|
12
12
|
import type { ContractClassPublic, ContractDataSource, ContractInstanceWithAddress, NodeInfo, ProtocolContractAddresses } from '@aztec/stdlib/contract';
|
|
13
13
|
import type { GasFees } from '@aztec/stdlib/gas';
|
|
14
|
-
import type { AztecNode, GetContractClassLogsResponse, GetPublicLogsResponse } from '@aztec/stdlib/interfaces/client';
|
|
14
|
+
import type { AztecNode, AztecNodeAdmin, GetContractClassLogsResponse, GetPublicLogsResponse } from '@aztec/stdlib/interfaces/client';
|
|
15
15
|
import { type ClientProtocolCircuitVerifier, type L2LogsSource, type ProverConfig, type SequencerConfig, type Service, type WorldStateSyncStatus, type WorldStateSynchronizer } from '@aztec/stdlib/interfaces/server';
|
|
16
16
|
import type { LogFilter, PrivateLog, TxScopedL2Log } from '@aztec/stdlib/logs';
|
|
17
17
|
import type { L1ToL2MessageSource } from '@aztec/stdlib/messaging';
|
|
18
|
-
import { MerkleTreeId, NullifierMembershipWitness, PublicDataWitness } from '@aztec/stdlib/trees';
|
|
19
18
|
import type { PublicDataTreeLeaf } from '@aztec/stdlib/trees';
|
|
19
|
+
import { MerkleTreeId, NullifierMembershipWitness, PublicDataWitness } from '@aztec/stdlib/trees';
|
|
20
20
|
import { type BlockHeader, PublicSimulationOutput, Tx, TxEffect, type TxHash, TxReceipt, type TxValidationResult } from '@aztec/stdlib/tx';
|
|
21
21
|
import { type TelemetryClient, type Traceable, type Tracer } from '@aztec/telemetry-client';
|
|
22
22
|
import { type AztecNodeConfig } from './config.js';
|
|
23
23
|
/**
|
|
24
24
|
* The aztec node.
|
|
25
25
|
*/
|
|
26
|
-
export declare class AztecNodeService implements AztecNode, Traceable {
|
|
26
|
+
export declare class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
27
27
|
#private;
|
|
28
28
|
protected config: AztecNodeConfig;
|
|
29
29
|
protected readonly p2pClient: P2P;
|
|
@@ -31,7 +31,6 @@ export declare class AztecNodeService implements AztecNode, Traceable {
|
|
|
31
31
|
protected readonly logsSource: L2LogsSource;
|
|
32
32
|
protected readonly contractDataSource: ContractDataSource;
|
|
33
33
|
protected readonly l1ToL2MessageSource: L1ToL2MessageSource;
|
|
34
|
-
protected readonly nullifierSource: NullifierWithBlockSource;
|
|
35
34
|
protected readonly worldStateSynchronizer: WorldStateSynchronizer;
|
|
36
35
|
protected readonly sequencer: SequencerClient | undefined;
|
|
37
36
|
protected readonly l1ChainId: number;
|
|
@@ -42,8 +41,9 @@ export declare class AztecNodeService implements AztecNode, Traceable {
|
|
|
42
41
|
private log;
|
|
43
42
|
private packageVersion;
|
|
44
43
|
private metrics;
|
|
44
|
+
private txQueue;
|
|
45
45
|
readonly tracer: Tracer;
|
|
46
|
-
constructor(config: AztecNodeConfig, p2pClient: P2P, blockSource: L2BlockSource & Partial<Service>, logsSource: L2LogsSource, contractDataSource: ContractDataSource, l1ToL2MessageSource: L1ToL2MessageSource,
|
|
46
|
+
constructor(config: AztecNodeConfig, p2pClient: P2P, blockSource: L2BlockSource & Partial<Service>, logsSource: L2LogsSource, contractDataSource: ContractDataSource, l1ToL2MessageSource: L1ToL2MessageSource, worldStateSynchronizer: WorldStateSynchronizer, sequencer: SequencerClient | undefined, l1ChainId: number, version: number, globalVariableBuilder: GlobalVariableBuilder, proofVerifier: ClientProtocolCircuitVerifier, telemetry?: TelemetryClient, log?: Logger);
|
|
47
47
|
getWorldStateSyncStatus(): Promise<WorldStateSyncStatus>;
|
|
48
48
|
getL2Tips(): Promise<import("@aztec/stdlib/block").L2Tips>;
|
|
49
49
|
/**
|
|
@@ -178,22 +178,14 @@ export declare class AztecNodeService implements AztecNode, Traceable {
|
|
|
178
178
|
*/
|
|
179
179
|
getTxsByHash(txHashes: TxHash[]): Promise<Tx[]>;
|
|
180
180
|
/**
|
|
181
|
-
* Find the indexes of the given leaves in the given tree
|
|
182
|
-
*
|
|
183
|
-
* @param
|
|
184
|
-
* @param leafValue - The values to search for
|
|
185
|
-
* @returns The indexes of the given leaves in the given tree or undefined if not found.
|
|
186
|
-
*/
|
|
187
|
-
findLeavesIndexes(blockNumber: L2BlockNumber, treeId: MerkleTreeId, leafValues: Fr[]): Promise<(bigint | undefined)[]>;
|
|
188
|
-
/**
|
|
189
|
-
* Find the block numbers of the given leaf indices in the given tree.
|
|
190
|
-
* @param blockNumber - The block number at which to get the data or 'latest' for latest data
|
|
181
|
+
* Find the indexes of the given leaves in the given tree along with a block metadata pointing to the block in which
|
|
182
|
+
* the leaves were inserted.
|
|
183
|
+
* @param blockNumber - The block number at which to get the data or 'latest' for latest data.
|
|
191
184
|
* @param treeId - The tree to search in.
|
|
192
|
-
* @param
|
|
193
|
-
* @returns The
|
|
185
|
+
* @param leafValues - The values to search for.
|
|
186
|
+
* @returns The indices of leaves and the block metadata of a block in which the leaves were inserted.
|
|
194
187
|
*/
|
|
195
|
-
|
|
196
|
-
findNullifiersIndexesWithBlock(blockNumber: L2BlockNumber, nullifiers: Fr[]): Promise<(InBlock<bigint> | undefined)[]>;
|
|
188
|
+
findLeavesIndexes(blockNumber: L2BlockNumber, treeId: MerkleTreeId, leafValues: Fr[]): Promise<(InBlock<bigint> | undefined)[]>;
|
|
197
189
|
/**
|
|
198
190
|
* Returns a sibling path for the given index in the nullifier tree.
|
|
199
191
|
* @param blockNumber - The block number at which to get the data.
|
|
@@ -268,7 +260,7 @@ export declare class AztecNodeService implements AztecNode, Traceable {
|
|
|
268
260
|
* TODO: This is a confusing behavior and we should eventually address that.
|
|
269
261
|
*/
|
|
270
262
|
getLowNullifierMembershipWitness(blockNumber: L2BlockNumber, nullifier: Fr): Promise<NullifierMembershipWitness | undefined>;
|
|
271
|
-
|
|
263
|
+
getPublicDataWitness(blockNumber: L2BlockNumber, leafSlot: Fr): Promise<PublicDataWitness | undefined>;
|
|
272
264
|
/**
|
|
273
265
|
* Gets the storage value at the given contract storage slot.
|
|
274
266
|
*
|
|
@@ -297,7 +289,6 @@ export declare class AztecNodeService implements AztecNode, Traceable {
|
|
|
297
289
|
}): Promise<TxValidationResult>;
|
|
298
290
|
setConfig(config: Partial<SequencerConfig & ProverConfig>): Promise<void>;
|
|
299
291
|
getProtocolContractAddresses(): Promise<ProtocolContractAddresses>;
|
|
300
|
-
addContractClass(contractClass: ContractClassPublic): Promise<void>;
|
|
301
292
|
registerContractFunctionSignatures(_address: AztecAddress, signatures: string[]): Promise<void>;
|
|
302
293
|
flushTxs(): Promise<void>;
|
|
303
294
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/aztec-node/server.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,uBAAuB,EAAwB,MAAM,yBAAyB,CAAC;AAC7F,OAAO,EACL,KAAK,cAAc,EAEnB,KAAK,wBAAwB,EAC7B,KAAK,qBAAqB,EAC1B,KAAK,qBAAqB,EAC1B,KAAK,uBAAuB,
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/aztec-node/server.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,uBAAuB,EAAwB,MAAM,yBAAyB,C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AAC,kBAAkB,CAAC;IAejB,SAAS,CAAC,MAAM,EAAE,OAAO,CAAC,eAAe,GAAG,YAAY,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAW/E,4BAA4B,IAAI,OAAO,CAAC,yBAAyB,CAAC;IASlE,kCAAkC,CAAC,QAAQ,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAI/F,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;CA8CjC"}
|
|
@@ -7,13 +7,14 @@ function _ts_decorate(decorators, target, key, desc) {
|
|
|
7
7
|
import { createArchiver } from '@aztec/archiver';
|
|
8
8
|
import { BBCircuitVerifier, TestCircuitVerifier } from '@aztec/bb-prover';
|
|
9
9
|
import { createBlobSinkClient } from '@aztec/blob-sink/client';
|
|
10
|
-
import { INITIAL_L2_BLOCK_NUM
|
|
10
|
+
import { INITIAL_L2_BLOCK_NUM } from '@aztec/constants';
|
|
11
11
|
import { EpochCache } from '@aztec/epoch-cache';
|
|
12
12
|
import { createEthereumChain } from '@aztec/ethereum';
|
|
13
13
|
import { compactArray } from '@aztec/foundation/collection';
|
|
14
14
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
15
15
|
import { Fr } from '@aztec/foundation/fields';
|
|
16
16
|
import { createLogger } from '@aztec/foundation/log';
|
|
17
|
+
import { SerialQueue } from '@aztec/foundation/queue';
|
|
17
18
|
import { DateProvider, Timer } from '@aztec/foundation/timer';
|
|
18
19
|
import { SiblingPath } from '@aztec/foundation/trees';
|
|
19
20
|
import { openTmpStore } from '@aztec/kv-store/lmdb';
|
|
@@ -23,7 +24,7 @@ import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
|
23
24
|
import { GlobalVariableBuilder, SequencerClient, createSlasherClient, createValidatorForAcceptingTxs, getDefaultAllowedSetupFunctions } from '@aztec/sequencer-client';
|
|
24
25
|
import { PublicProcessorFactory } from '@aztec/simulator/server';
|
|
25
26
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
26
|
-
import { computePublicDataTreeLeafSlot
|
|
27
|
+
import { computePublicDataTreeLeafSlot } from '@aztec/stdlib/hash';
|
|
27
28
|
import { tryStop } from '@aztec/stdlib/interfaces/server';
|
|
28
29
|
import { P2PClientType } from '@aztec/stdlib/p2p';
|
|
29
30
|
import { MerkleTreeId, NullifierMembershipWitness, PublicDataWitness } from '@aztec/stdlib/trees';
|
|
@@ -42,7 +43,6 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
42
43
|
logsSource;
|
|
43
44
|
contractDataSource;
|
|
44
45
|
l1ToL2MessageSource;
|
|
45
|
-
nullifierSource;
|
|
46
46
|
worldStateSynchronizer;
|
|
47
47
|
sequencer;
|
|
48
48
|
l1ChainId;
|
|
@@ -53,15 +53,16 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
53
53
|
log;
|
|
54
54
|
packageVersion;
|
|
55
55
|
metrics;
|
|
56
|
+
// Serial queue to ensure that we only send one tx at a time
|
|
57
|
+
txQueue;
|
|
56
58
|
tracer;
|
|
57
|
-
constructor(config, p2pClient, blockSource, logsSource, contractDataSource, l1ToL2MessageSource,
|
|
59
|
+
constructor(config, p2pClient, blockSource, logsSource, contractDataSource, l1ToL2MessageSource, worldStateSynchronizer, sequencer, l1ChainId, version, globalVariableBuilder, proofVerifier, telemetry = getTelemetryClient(), log = createLogger('node')){
|
|
58
60
|
this.config = config;
|
|
59
61
|
this.p2pClient = p2pClient;
|
|
60
62
|
this.blockSource = blockSource;
|
|
61
63
|
this.logsSource = logsSource;
|
|
62
64
|
this.contractDataSource = contractDataSource;
|
|
63
65
|
this.l1ToL2MessageSource = l1ToL2MessageSource;
|
|
64
|
-
this.nullifierSource = nullifierSource;
|
|
65
66
|
this.worldStateSynchronizer = worldStateSynchronizer;
|
|
66
67
|
this.sequencer = sequencer;
|
|
67
68
|
this.l1ChainId = l1ChainId;
|
|
@@ -70,9 +71,11 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
70
71
|
this.proofVerifier = proofVerifier;
|
|
71
72
|
this.telemetry = telemetry;
|
|
72
73
|
this.log = log;
|
|
74
|
+
this.txQueue = new SerialQueue();
|
|
73
75
|
this.packageVersion = getPackageVersion();
|
|
74
76
|
this.metrics = new NodeMetrics(telemetry, 'AztecNodeService');
|
|
75
77
|
this.tracer = telemetry.getTracer('AztecNodeService');
|
|
78
|
+
this.txQueue.start();
|
|
76
79
|
this.log.info(`Aztec Node version: ${this.packageVersion}`);
|
|
77
80
|
this.log.info(`Aztec Node started on chain 0x${l1ChainId.toString(16)}`, config.l1Contracts);
|
|
78
81
|
}
|
|
@@ -139,7 +142,7 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
139
142
|
dateProvider,
|
|
140
143
|
blobSinkClient
|
|
141
144
|
});
|
|
142
|
-
return new AztecNodeService(config, p2pClient, archiver, archiver, archiver, archiver,
|
|
145
|
+
return new AztecNodeService(config, p2pClient, archiver, archiver, archiver, archiver, worldStateSynchronizer, sequencer, ethereumChain.chainInfo.id, config.version, new GlobalVariableBuilder(config), proofVerifier, telemetry, log);
|
|
143
146
|
}
|
|
144
147
|
/**
|
|
145
148
|
* Returns the sequencer client instance.
|
|
@@ -241,25 +244,8 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
241
244
|
*/ getChainId() {
|
|
242
245
|
return Promise.resolve(this.l1ChainId);
|
|
243
246
|
}
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
// TODO(#10007): Remove this check. This is needed only because we're manually registering
|
|
247
|
-
// some contracts in the archiver so they are available to all nodes (see `registerCommonContracts`
|
|
248
|
-
// in `archiver/src/factory.ts`), but we still want clients to send the registration tx in order
|
|
249
|
-
// to emit the corresponding nullifier, which is now being checked. Note that this method
|
|
250
|
-
// is only called by the PXE to check if a contract is publicly registered.
|
|
251
|
-
if (klazz) {
|
|
252
|
-
const classNullifier = await siloNullifier(AztecAddress.fromNumber(REGISTERER_CONTRACT_ADDRESS), id);
|
|
253
|
-
const worldState = await this.#getWorldState('latest');
|
|
254
|
-
const [index] = await worldState.findLeafIndices(MerkleTreeId.NULLIFIER_TREE, [
|
|
255
|
-
classNullifier.toBuffer()
|
|
256
|
-
]);
|
|
257
|
-
this.log.debug(`Registration nullifier ${classNullifier} for contract class ${id} found at index ${index}`);
|
|
258
|
-
if (index === undefined) {
|
|
259
|
-
return undefined;
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
return klazz;
|
|
247
|
+
getContractClass(id) {
|
|
248
|
+
return this.contractDataSource.getContractClass(id);
|
|
263
249
|
}
|
|
264
250
|
getContract(address) {
|
|
265
251
|
return this.contractDataSource.getContract(address);
|
|
@@ -298,6 +284,15 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
298
284
|
* Method to submit a transaction to the p2p pool.
|
|
299
285
|
* @param tx - The transaction to be submitted.
|
|
300
286
|
*/ async sendTx(tx) {
|
|
287
|
+
await this.txQueue.put(async ()=>{
|
|
288
|
+
await this.#sendTx(tx);
|
|
289
|
+
}).catch((error)=>{
|
|
290
|
+
this.log.error(`Error sending tx`, {
|
|
291
|
+
error
|
|
292
|
+
});
|
|
293
|
+
});
|
|
294
|
+
}
|
|
295
|
+
async #sendTx(tx) {
|
|
301
296
|
const timer = new Timer();
|
|
302
297
|
const txHash = (await tx.getTxHash()).toString();
|
|
303
298
|
const valid = await this.isValidTx(tx);
|
|
@@ -338,6 +333,7 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
338
333
|
* Method to stop the aztec node.
|
|
339
334
|
*/ async stop() {
|
|
340
335
|
this.log.info(`Stopping`);
|
|
336
|
+
await this.txQueue.end();
|
|
341
337
|
await this.sequencer?.stop();
|
|
342
338
|
await this.p2pClient.stop();
|
|
343
339
|
await this.worldStateSynchronizer.stop();
|
|
@@ -370,30 +366,60 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
370
366
|
return compactArray(await Promise.all(txHashes.map((txHash)=>this.getTxByHash(txHash))));
|
|
371
367
|
}
|
|
372
368
|
/**
|
|
373
|
-
* Find the indexes of the given leaves in the given tree
|
|
374
|
-
*
|
|
369
|
+
* Find the indexes of the given leaves in the given tree along with a block metadata pointing to the block in which
|
|
370
|
+
* the leaves were inserted.
|
|
371
|
+
* @param blockNumber - The block number at which to get the data or 'latest' for latest data.
|
|
375
372
|
* @param treeId - The tree to search in.
|
|
376
|
-
* @param
|
|
377
|
-
* @returns The
|
|
373
|
+
* @param leafValues - The values to search for.
|
|
374
|
+
* @returns The indices of leaves and the block metadata of a block in which the leaves were inserted.
|
|
378
375
|
*/ async findLeavesIndexes(blockNumber, treeId, leafValues) {
|
|
379
376
|
const committedDb = await this.#getWorldState(blockNumber);
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
return await committedDb.getBlockNumbersForLeafIndices(treeId, leafIndices);
|
|
391
|
-
}
|
|
392
|
-
async findNullifiersIndexesWithBlock(blockNumber, nullifiers) {
|
|
393
|
-
if (blockNumber === 'latest') {
|
|
394
|
-
blockNumber = await this.getBlockNumber();
|
|
377
|
+
const maybeIndices = await committedDb.findLeafIndices(treeId, leafValues.map((x)=>x.toBuffer()));
|
|
378
|
+
// We filter out undefined values
|
|
379
|
+
const indices = maybeIndices.filter((x)=>x !== undefined);
|
|
380
|
+
// Now we find the block numbers for the indices
|
|
381
|
+
const blockNumbers = await committedDb.getBlockNumbersForLeafIndices(treeId, indices);
|
|
382
|
+
// If any of the block numbers are undefined, we throw an error.
|
|
383
|
+
for(let i = 0; i < indices.length; i++){
|
|
384
|
+
if (blockNumbers[i] === undefined) {
|
|
385
|
+
throw new Error(`Block number is undefined for leaf index ${indices[i]} in tree ${MerkleTreeId[treeId]}`);
|
|
386
|
+
}
|
|
395
387
|
}
|
|
396
|
-
|
|
388
|
+
// Get unique block numbers in order to optimize num calls to getLeafValue function.
|
|
389
|
+
const uniqueBlockNumbers = [
|
|
390
|
+
...new Set(blockNumbers.filter((x)=>x !== undefined))
|
|
391
|
+
];
|
|
392
|
+
// Now we obtain the block hashes from the archive tree by calling await `committedDb.getLeafValue(treeId, index)`
|
|
393
|
+
// (note that block number corresponds to the leaf index in the archive tree).
|
|
394
|
+
const blockHashes = await Promise.all(uniqueBlockNumbers.map((blockNumber)=>{
|
|
395
|
+
return committedDb.getLeafValue(MerkleTreeId.ARCHIVE, blockNumber);
|
|
396
|
+
}));
|
|
397
|
+
// If any of the block hashes are undefined, we throw an error.
|
|
398
|
+
for(let i = 0; i < uniqueBlockNumbers.length; i++){
|
|
399
|
+
if (blockHashes[i] === undefined) {
|
|
400
|
+
throw new Error(`Block hash is undefined for block number ${uniqueBlockNumbers[i]}`);
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
// Create InBlock objects by combining indices, blockNumbers and blockHashes and return them.
|
|
404
|
+
return maybeIndices.map((index, i)=>{
|
|
405
|
+
if (index === undefined) {
|
|
406
|
+
return undefined;
|
|
407
|
+
}
|
|
408
|
+
const blockNumber = blockNumbers[i];
|
|
409
|
+
if (blockNumber === undefined) {
|
|
410
|
+
return undefined;
|
|
411
|
+
}
|
|
412
|
+
const blockHashIndex = uniqueBlockNumbers.indexOf(blockNumber);
|
|
413
|
+
const blockHash = blockHashes[blockHashIndex]?.toString();
|
|
414
|
+
if (!blockHash) {
|
|
415
|
+
return undefined;
|
|
416
|
+
}
|
|
417
|
+
return {
|
|
418
|
+
l2BlockNumber: Number(blockNumber),
|
|
419
|
+
l2BlockHash: blockHash,
|
|
420
|
+
data: index
|
|
421
|
+
};
|
|
422
|
+
});
|
|
397
423
|
}
|
|
398
424
|
/**
|
|
399
425
|
* Returns a sibling path for the given index in the nullifier tree.
|
|
@@ -567,7 +593,7 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
567
593
|
const siblingPath = await committedDb.getSiblingPath(MerkleTreeId.NULLIFIER_TREE, BigInt(index));
|
|
568
594
|
return new NullifierMembershipWitness(BigInt(index), preimageData, siblingPath);
|
|
569
595
|
}
|
|
570
|
-
async
|
|
596
|
+
async getPublicDataWitness(blockNumber, leafSlot) {
|
|
571
597
|
const committedDb = await this.#getWorldState(blockNumber);
|
|
572
598
|
const lowLeafResult = await committedDb.getPreviousValueIndex(MerkleTreeId.PUBLIC_DATA_TREE, leafSlot.toBigInt());
|
|
573
599
|
if (!lowLeafResult) {
|
|
@@ -672,11 +698,6 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
672
698
|
multiCallEntrypoint: ProtocolContractAddress.MultiCallEntrypoint
|
|
673
699
|
});
|
|
674
700
|
}
|
|
675
|
-
// TODO(#10007): Remove this method
|
|
676
|
-
addContractClass(contractClass) {
|
|
677
|
-
this.log.info(`Adding contract class via API ${contractClass.id}`);
|
|
678
|
-
return this.contractDataSource.addContractClass(contractClass);
|
|
679
|
-
}
|
|
680
701
|
registerContractFunctionSignatures(_address, signatures) {
|
|
681
702
|
return this.contractDataSource.registerContractFunctionSignatures(_address, signatures);
|
|
682
703
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/aztec-node",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.82.1-alpha-testnet.1",
|
|
4
4
|
"main": "dest/index.js",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -62,24 +62,24 @@
|
|
|
62
62
|
]
|
|
63
63
|
},
|
|
64
64
|
"dependencies": {
|
|
65
|
-
"@aztec/archiver": "0.
|
|
66
|
-
"@aztec/bb-prover": "0.
|
|
67
|
-
"@aztec/blob-sink": "0.
|
|
68
|
-
"@aztec/constants": "0.
|
|
69
|
-
"@aztec/epoch-cache": "0.
|
|
70
|
-
"@aztec/ethereum": "0.
|
|
71
|
-
"@aztec/foundation": "0.
|
|
72
|
-
"@aztec/kv-store": "0.
|
|
73
|
-
"@aztec/merkle-tree": "0.
|
|
74
|
-
"@aztec/p2p": "0.
|
|
75
|
-
"@aztec/protocol-contracts": "0.
|
|
76
|
-
"@aztec/prover-client": "0.
|
|
77
|
-
"@aztec/sequencer-client": "0.
|
|
78
|
-
"@aztec/simulator": "0.
|
|
79
|
-
"@aztec/stdlib": "0.
|
|
80
|
-
"@aztec/telemetry-client": "0.
|
|
81
|
-
"@aztec/validator-client": "0.
|
|
82
|
-
"@aztec/world-state": "0.
|
|
65
|
+
"@aztec/archiver": "0.82.1-alpha-testnet.1",
|
|
66
|
+
"@aztec/bb-prover": "0.82.1-alpha-testnet.1",
|
|
67
|
+
"@aztec/blob-sink": "0.82.1-alpha-testnet.1",
|
|
68
|
+
"@aztec/constants": "0.82.1-alpha-testnet.1",
|
|
69
|
+
"@aztec/epoch-cache": "0.82.1-alpha-testnet.1",
|
|
70
|
+
"@aztec/ethereum": "0.82.1-alpha-testnet.1",
|
|
71
|
+
"@aztec/foundation": "0.82.1-alpha-testnet.1",
|
|
72
|
+
"@aztec/kv-store": "0.82.1-alpha-testnet.1",
|
|
73
|
+
"@aztec/merkle-tree": "0.82.1-alpha-testnet.1",
|
|
74
|
+
"@aztec/p2p": "0.82.1-alpha-testnet.1",
|
|
75
|
+
"@aztec/protocol-contracts": "0.82.1-alpha-testnet.1",
|
|
76
|
+
"@aztec/prover-client": "0.82.1-alpha-testnet.1",
|
|
77
|
+
"@aztec/sequencer-client": "0.82.1-alpha-testnet.1",
|
|
78
|
+
"@aztec/simulator": "0.82.1-alpha-testnet.1",
|
|
79
|
+
"@aztec/stdlib": "0.82.1-alpha-testnet.1",
|
|
80
|
+
"@aztec/telemetry-client": "0.82.1-alpha-testnet.1",
|
|
81
|
+
"@aztec/validator-client": "0.82.1-alpha-testnet.1",
|
|
82
|
+
"@aztec/world-state": "0.82.1-alpha-testnet.1",
|
|
83
83
|
"koa": "^2.14.2",
|
|
84
84
|
"koa-router": "^12.0.0",
|
|
85
85
|
"tslib": "^2.4.0"
|
package/src/aztec-node/config.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type ArchiverConfig, archiverConfigMappings } from '@aztec/archiver/config';
|
|
2
|
+
import { type L1ContractAddresses, l1ContractAddressesMapping } from '@aztec/ethereum';
|
|
2
3
|
import { type ConfigMappingsType, booleanConfigHelper, getConfigFromMappings } from '@aztec/foundation/config';
|
|
3
4
|
import { type DataStoreConfig, dataConfigMappings } from '@aztec/kv-store/config';
|
|
4
5
|
import { type P2PConfig, p2pConfigMappings } from '@aztec/p2p/config';
|
|
@@ -28,16 +29,22 @@ export type AztecNodeConfig = ArchiverConfig &
|
|
|
28
29
|
disableValidator: boolean;
|
|
29
30
|
/** Whether to populate the genesis state with initial fee juice for the test accounts */
|
|
30
31
|
testAccounts: boolean;
|
|
32
|
+
} & {
|
|
33
|
+
l1Contracts: L1ContractAddresses;
|
|
31
34
|
};
|
|
32
35
|
|
|
33
36
|
export const aztecNodeConfigMappings: ConfigMappingsType<AztecNodeConfig> = {
|
|
37
|
+
...dataConfigMappings,
|
|
34
38
|
...archiverConfigMappings,
|
|
35
39
|
...sequencerClientConfigMappings,
|
|
36
40
|
...validatorClientConfigMappings,
|
|
37
41
|
...proverClientConfigMappings,
|
|
38
42
|
...worldStateConfigMappings,
|
|
39
43
|
...p2pConfigMappings,
|
|
40
|
-
|
|
44
|
+
l1Contracts: {
|
|
45
|
+
description: 'The deployed L1 contract addresses',
|
|
46
|
+
nested: l1ContractAddressesMapping,
|
|
47
|
+
},
|
|
41
48
|
disableValidator: {
|
|
42
49
|
env: 'VALIDATOR_DISABLED',
|
|
43
50
|
description: 'Whether the validator is disabled for this node.',
|
package/src/aztec-node/server.ts
CHANGED
|
@@ -8,7 +8,6 @@ import {
|
|
|
8
8
|
type NOTE_HASH_TREE_HEIGHT,
|
|
9
9
|
type NULLIFIER_TREE_HEIGHT,
|
|
10
10
|
type PUBLIC_DATA_TREE_HEIGHT,
|
|
11
|
-
REGISTERER_CONTRACT_ADDRESS,
|
|
12
11
|
} from '@aztec/constants';
|
|
13
12
|
import { EpochCache } from '@aztec/epoch-cache';
|
|
14
13
|
import { type L1ContractAddresses, createEthereumChain } from '@aztec/ethereum';
|
|
@@ -16,6 +15,7 @@ import { compactArray } from '@aztec/foundation/collection';
|
|
|
16
15
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
17
16
|
import { Fr } from '@aztec/foundation/fields';
|
|
18
17
|
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
18
|
+
import { SerialQueue } from '@aztec/foundation/queue';
|
|
19
19
|
import { DateProvider, Timer } from '@aztec/foundation/timer';
|
|
20
20
|
import { SiblingPath } from '@aztec/foundation/trees';
|
|
21
21
|
import type { AztecKVStore } from '@aztec/kv-store';
|
|
@@ -33,14 +33,7 @@ import {
|
|
|
33
33
|
} from '@aztec/sequencer-client';
|
|
34
34
|
import { PublicProcessorFactory } from '@aztec/simulator/server';
|
|
35
35
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
36
|
-
import type {
|
|
37
|
-
InBlock,
|
|
38
|
-
L2Block,
|
|
39
|
-
L2BlockNumber,
|
|
40
|
-
L2BlockSource,
|
|
41
|
-
NullifierWithBlockSource,
|
|
42
|
-
PublishedL2Block,
|
|
43
|
-
} from '@aztec/stdlib/block';
|
|
36
|
+
import type { InBlock, L2Block, L2BlockNumber, L2BlockSource, PublishedL2Block } from '@aztec/stdlib/block';
|
|
44
37
|
import type {
|
|
45
38
|
ContractClassPublic,
|
|
46
39
|
ContractDataSource,
|
|
@@ -49,8 +42,13 @@ import type {
|
|
|
49
42
|
ProtocolContractAddresses,
|
|
50
43
|
} from '@aztec/stdlib/contract';
|
|
51
44
|
import type { GasFees } from '@aztec/stdlib/gas';
|
|
52
|
-
import { computePublicDataTreeLeafSlot
|
|
53
|
-
import type {
|
|
45
|
+
import { computePublicDataTreeLeafSlot } from '@aztec/stdlib/hash';
|
|
46
|
+
import type {
|
|
47
|
+
AztecNode,
|
|
48
|
+
AztecNodeAdmin,
|
|
49
|
+
GetContractClassLogsResponse,
|
|
50
|
+
GetPublicLogsResponse,
|
|
51
|
+
} from '@aztec/stdlib/interfaces/client';
|
|
54
52
|
import {
|
|
55
53
|
type ClientProtocolCircuitVerifier,
|
|
56
54
|
type L2LogsSource,
|
|
@@ -64,8 +62,8 @@ import {
|
|
|
64
62
|
import type { LogFilter, PrivateLog, TxScopedL2Log } from '@aztec/stdlib/logs';
|
|
65
63
|
import type { L1ToL2MessageSource } from '@aztec/stdlib/messaging';
|
|
66
64
|
import { P2PClientType } from '@aztec/stdlib/p2p';
|
|
67
|
-
import { MerkleTreeId, NullifierMembershipWitness, PublicDataWitness } from '@aztec/stdlib/trees';
|
|
68
65
|
import type { NullifierLeafPreimage, PublicDataTreeLeaf, PublicDataTreeLeafPreimage } from '@aztec/stdlib/trees';
|
|
66
|
+
import { MerkleTreeId, NullifierMembershipWitness, PublicDataWitness } from '@aztec/stdlib/trees';
|
|
69
67
|
import {
|
|
70
68
|
type BlockHeader,
|
|
71
69
|
PublicSimulationOutput,
|
|
@@ -93,10 +91,13 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
93
91
|
/**
|
|
94
92
|
* The aztec node.
|
|
95
93
|
*/
|
|
96
|
-
export class AztecNodeService implements AztecNode, Traceable {
|
|
94
|
+
export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
97
95
|
private packageVersion: string;
|
|
98
96
|
private metrics: NodeMetrics;
|
|
99
97
|
|
|
98
|
+
// Serial queue to ensure that we only send one tx at a time
|
|
99
|
+
private txQueue: SerialQueue = new SerialQueue();
|
|
100
|
+
|
|
100
101
|
public readonly tracer: Tracer;
|
|
101
102
|
|
|
102
103
|
constructor(
|
|
@@ -106,7 +107,6 @@ export class AztecNodeService implements AztecNode, Traceable {
|
|
|
106
107
|
protected readonly logsSource: L2LogsSource,
|
|
107
108
|
protected readonly contractDataSource: ContractDataSource,
|
|
108
109
|
protected readonly l1ToL2MessageSource: L1ToL2MessageSource,
|
|
109
|
-
protected readonly nullifierSource: NullifierWithBlockSource,
|
|
110
110
|
protected readonly worldStateSynchronizer: WorldStateSynchronizer,
|
|
111
111
|
protected readonly sequencer: SequencerClient | undefined,
|
|
112
112
|
protected readonly l1ChainId: number,
|
|
@@ -119,6 +119,7 @@ export class AztecNodeService implements AztecNode, Traceable {
|
|
|
119
119
|
this.packageVersion = getPackageVersion();
|
|
120
120
|
this.metrics = new NodeMetrics(telemetry, 'AztecNodeService');
|
|
121
121
|
this.tracer = telemetry.getTracer('AztecNodeService');
|
|
122
|
+
this.txQueue.start();
|
|
122
123
|
|
|
123
124
|
this.log.info(`Aztec Node version: ${this.packageVersion}`);
|
|
124
125
|
this.log.info(`Aztec Node started on chain 0x${l1ChainId.toString(16)}`, config.l1Contracts);
|
|
@@ -222,7 +223,6 @@ export class AztecNodeService implements AztecNode, Traceable {
|
|
|
222
223
|
archiver,
|
|
223
224
|
archiver,
|
|
224
225
|
archiver,
|
|
225
|
-
archiver,
|
|
226
226
|
worldStateSynchronizer,
|
|
227
227
|
sequencer,
|
|
228
228
|
ethereumChain.chainInfo.id,
|
|
@@ -364,25 +364,8 @@ export class AztecNodeService implements AztecNode, Traceable {
|
|
|
364
364
|
return Promise.resolve(this.l1ChainId);
|
|
365
365
|
}
|
|
366
366
|
|
|
367
|
-
public
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
// TODO(#10007): Remove this check. This is needed only because we're manually registering
|
|
371
|
-
// some contracts in the archiver so they are available to all nodes (see `registerCommonContracts`
|
|
372
|
-
// in `archiver/src/factory.ts`), but we still want clients to send the registration tx in order
|
|
373
|
-
// to emit the corresponding nullifier, which is now being checked. Note that this method
|
|
374
|
-
// is only called by the PXE to check if a contract is publicly registered.
|
|
375
|
-
if (klazz) {
|
|
376
|
-
const classNullifier = await siloNullifier(AztecAddress.fromNumber(REGISTERER_CONTRACT_ADDRESS), id);
|
|
377
|
-
const worldState = await this.#getWorldState('latest');
|
|
378
|
-
const [index] = await worldState.findLeafIndices(MerkleTreeId.NULLIFIER_TREE, [classNullifier.toBuffer()]);
|
|
379
|
-
this.log.debug(`Registration nullifier ${classNullifier} for contract class ${id} found at index ${index}`);
|
|
380
|
-
if (index === undefined) {
|
|
381
|
-
return undefined;
|
|
382
|
-
}
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
return klazz;
|
|
367
|
+
public getContractClass(id: Fr): Promise<ContractClassPublic | undefined> {
|
|
368
|
+
return this.contractDataSource.getContractClass(id);
|
|
386
369
|
}
|
|
387
370
|
|
|
388
371
|
public getContract(address: AztecAddress): Promise<ContractInstanceWithAddress | undefined> {
|
|
@@ -432,6 +415,16 @@ export class AztecNodeService implements AztecNode, Traceable {
|
|
|
432
415
|
* @param tx - The transaction to be submitted.
|
|
433
416
|
*/
|
|
434
417
|
public async sendTx(tx: Tx) {
|
|
418
|
+
await this.txQueue
|
|
419
|
+
.put(async () => {
|
|
420
|
+
await this.#sendTx(tx);
|
|
421
|
+
})
|
|
422
|
+
.catch(error => {
|
|
423
|
+
this.log.error(`Error sending tx`, { error });
|
|
424
|
+
});
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
async #sendTx(tx: Tx) {
|
|
435
428
|
const timer = new Timer();
|
|
436
429
|
const txHash = (await tx.getTxHash()).toString();
|
|
437
430
|
|
|
@@ -477,6 +470,7 @@ export class AztecNodeService implements AztecNode, Traceable {
|
|
|
477
470
|
*/
|
|
478
471
|
public async stop() {
|
|
479
472
|
this.log.info(`Stopping`);
|
|
473
|
+
await this.txQueue.end();
|
|
480
474
|
await this.sequencer?.stop();
|
|
481
475
|
await this.p2pClient.stop();
|
|
482
476
|
await this.worldStateSynchronizer.stop();
|
|
@@ -517,48 +511,74 @@ export class AztecNodeService implements AztecNode, Traceable {
|
|
|
517
511
|
}
|
|
518
512
|
|
|
519
513
|
/**
|
|
520
|
-
* Find the indexes of the given leaves in the given tree
|
|
521
|
-
*
|
|
514
|
+
* Find the indexes of the given leaves in the given tree along with a block metadata pointing to the block in which
|
|
515
|
+
* the leaves were inserted.
|
|
516
|
+
* @param blockNumber - The block number at which to get the data or 'latest' for latest data.
|
|
522
517
|
* @param treeId - The tree to search in.
|
|
523
|
-
* @param
|
|
524
|
-
* @returns The
|
|
518
|
+
* @param leafValues - The values to search for.
|
|
519
|
+
* @returns The indices of leaves and the block metadata of a block in which the leaves were inserted.
|
|
525
520
|
*/
|
|
526
521
|
public async findLeavesIndexes(
|
|
527
522
|
blockNumber: L2BlockNumber,
|
|
528
523
|
treeId: MerkleTreeId,
|
|
529
524
|
leafValues: Fr[],
|
|
530
|
-
): Promise<(bigint | undefined)[]> {
|
|
525
|
+
): Promise<(InBlock<bigint> | undefined)[]> {
|
|
531
526
|
const committedDb = await this.#getWorldState(blockNumber);
|
|
532
|
-
|
|
527
|
+
const maybeIndices = await committedDb.findLeafIndices(
|
|
533
528
|
treeId,
|
|
534
529
|
leafValues.map(x => x.toBuffer()),
|
|
535
530
|
);
|
|
536
|
-
|
|
531
|
+
// We filter out undefined values
|
|
532
|
+
const indices = maybeIndices.filter(x => x !== undefined) as bigint[];
|
|
537
533
|
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
* @param blockNumber - The block number at which to get the data or 'latest' for latest data
|
|
541
|
-
* @param treeId - The tree to search in.
|
|
542
|
-
* @param leafIndices - The values to search for
|
|
543
|
-
* @returns The indexes of the given leaves in the given tree or undefined if not found.
|
|
544
|
-
*/
|
|
545
|
-
public async findBlockNumbersForIndexes(
|
|
546
|
-
blockNumber: L2BlockNumber,
|
|
547
|
-
treeId: MerkleTreeId,
|
|
548
|
-
leafIndices: bigint[],
|
|
549
|
-
): Promise<(bigint | undefined)[]> {
|
|
550
|
-
const committedDb = await this.#getWorldState(blockNumber);
|
|
551
|
-
return await committedDb.getBlockNumbersForLeafIndices(treeId, leafIndices);
|
|
552
|
-
}
|
|
534
|
+
// Now we find the block numbers for the indices
|
|
535
|
+
const blockNumbers = await committedDb.getBlockNumbersForLeafIndices(treeId, indices);
|
|
553
536
|
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
537
|
+
// If any of the block numbers are undefined, we throw an error.
|
|
538
|
+
for (let i = 0; i < indices.length; i++) {
|
|
539
|
+
if (blockNumbers[i] === undefined) {
|
|
540
|
+
throw new Error(`Block number is undefined for leaf index ${indices[i]} in tree ${MerkleTreeId[treeId]}`);
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
// Get unique block numbers in order to optimize num calls to getLeafValue function.
|
|
545
|
+
const uniqueBlockNumbers = [...new Set(blockNumbers.filter(x => x !== undefined))];
|
|
546
|
+
|
|
547
|
+
// Now we obtain the block hashes from the archive tree by calling await `committedDb.getLeafValue(treeId, index)`
|
|
548
|
+
// (note that block number corresponds to the leaf index in the archive tree).
|
|
549
|
+
const blockHashes = await Promise.all(
|
|
550
|
+
uniqueBlockNumbers.map(blockNumber => {
|
|
551
|
+
return committedDb.getLeafValue(MerkleTreeId.ARCHIVE, blockNumber!);
|
|
552
|
+
}),
|
|
553
|
+
);
|
|
554
|
+
|
|
555
|
+
// If any of the block hashes are undefined, we throw an error.
|
|
556
|
+
for (let i = 0; i < uniqueBlockNumbers.length; i++) {
|
|
557
|
+
if (blockHashes[i] === undefined) {
|
|
558
|
+
throw new Error(`Block hash is undefined for block number ${uniqueBlockNumbers[i]}`);
|
|
559
|
+
}
|
|
560
560
|
}
|
|
561
|
-
|
|
561
|
+
|
|
562
|
+
// Create InBlock objects by combining indices, blockNumbers and blockHashes and return them.
|
|
563
|
+
return maybeIndices.map((index, i) => {
|
|
564
|
+
if (index === undefined) {
|
|
565
|
+
return undefined;
|
|
566
|
+
}
|
|
567
|
+
const blockNumber = blockNumbers[i];
|
|
568
|
+
if (blockNumber === undefined) {
|
|
569
|
+
return undefined;
|
|
570
|
+
}
|
|
571
|
+
const blockHashIndex = uniqueBlockNumbers.indexOf(blockNumber);
|
|
572
|
+
const blockHash = blockHashes[blockHashIndex]?.toString();
|
|
573
|
+
if (!blockHash) {
|
|
574
|
+
return undefined;
|
|
575
|
+
}
|
|
576
|
+
return {
|
|
577
|
+
l2BlockNumber: Number(blockNumber),
|
|
578
|
+
l2BlockHash: blockHash,
|
|
579
|
+
data: index,
|
|
580
|
+
};
|
|
581
|
+
});
|
|
562
582
|
}
|
|
563
583
|
|
|
564
584
|
/**
|
|
@@ -797,7 +817,7 @@ export class AztecNodeService implements AztecNode, Traceable {
|
|
|
797
817
|
return new NullifierMembershipWitness(BigInt(index), preimageData as NullifierLeafPreimage, siblingPath);
|
|
798
818
|
}
|
|
799
819
|
|
|
800
|
-
async
|
|
820
|
+
async getPublicDataWitness(blockNumber: L2BlockNumber, leafSlot: Fr): Promise<PublicDataWitness | undefined> {
|
|
801
821
|
const committedDb = await this.#getWorldState(blockNumber);
|
|
802
822
|
const lowLeafResult = await committedDb.getPreviousValueIndex(MerkleTreeId.PUBLIC_DATA_TREE, leafSlot.toBigInt());
|
|
803
823
|
if (!lowLeafResult) {
|
|
@@ -946,12 +966,6 @@ export class AztecNodeService implements AztecNode, Traceable {
|
|
|
946
966
|
});
|
|
947
967
|
}
|
|
948
968
|
|
|
949
|
-
// TODO(#10007): Remove this method
|
|
950
|
-
public addContractClass(contractClass: ContractClassPublic): Promise<void> {
|
|
951
|
-
this.log.info(`Adding contract class via API ${contractClass.id}`);
|
|
952
|
-
return this.contractDataSource.addContractClass(contractClass);
|
|
953
|
-
}
|
|
954
|
-
|
|
955
969
|
public registerContractFunctionSignatures(_address: AztecAddress, signatures: string[]): Promise<void> {
|
|
956
970
|
return this.contractDataSource.registerContractFunctionSignatures(_address, signatures);
|
|
957
971
|
}
|