@aztec/p2p 0.0.1-commit.b2a5d0dd1 → 0.0.1-commit.b3d3157a
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/bootstrap/bootstrap.d.ts +1 -1
- package/dest/bootstrap/bootstrap.d.ts.map +1 -1
- package/dest/bootstrap/bootstrap.js +9 -1
- package/dest/client/factory.d.ts +3 -3
- package/dest/client/factory.d.ts.map +1 -1
- package/dest/client/factory.js +12 -9
- package/dest/client/interface.d.ts +6 -4
- package/dest/client/interface.d.ts.map +1 -1
- package/dest/client/p2p_client.d.ts +11 -8
- package/dest/client/p2p_client.d.ts.map +1 -1
- package/dest/client/p2p_client.js +53 -17
- package/dest/config.d.ts +43 -17
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +48 -8
- package/dest/errors/reqresp.error.d.ts +1 -20
- package/dest/errors/reqresp.error.d.ts.map +1 -1
- package/dest/errors/reqresp.error.js +0 -21
- package/dest/mem_pools/attestation_pool/attestation_pool.d.ts +93 -55
- package/dest/mem_pools/attestation_pool/attestation_pool.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/attestation_pool.js +258 -195
- package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.d.ts +1 -1
- package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.js +175 -59
- package/dest/mem_pools/attestation_pool/mocks.d.ts +1 -1
- package/dest/mem_pools/attestation_pool/mocks.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/mocks.js +6 -4
- package/dest/mem_pools/instrumentation.d.ts +1 -1
- package/dest/mem_pools/instrumentation.d.ts.map +1 -1
- package/dest/mem_pools/instrumentation.js +17 -1
- package/dest/mem_pools/tx_pool_v2/archive/tx_archive.d.ts +1 -5
- package/dest/mem_pools/tx_pool_v2/archive/tx_archive.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/archive/tx_archive.js +1 -7
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts +1 -1
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.js +73 -83
- package/dest/msg_validators/attestation_validator/attestation_validator.d.ts +5 -2
- package/dest/msg_validators/attestation_validator/attestation_validator.d.ts.map +1 -1
- package/dest/msg_validators/attestation_validator/attestation_validator.js +18 -2
- package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.d.ts +5 -3
- package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.d.ts.map +1 -1
- package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.js +3 -4
- package/dest/msg_validators/clock_tolerance.d.ts +1 -1
- package/dest/msg_validators/clock_tolerance.d.ts.map +1 -1
- package/dest/msg_validators/clock_tolerance.js +13 -11
- package/dest/msg_validators/proposal_validator/block_proposal_validator.d.ts +5 -2
- package/dest/msg_validators/proposal_validator/block_proposal_validator.d.ts.map +1 -1
- package/dest/msg_validators/proposal_validator/checkpoint_proposal_validator.d.ts +5 -2
- package/dest/msg_validators/proposal_validator/checkpoint_proposal_validator.d.ts.map +1 -1
- package/dest/msg_validators/proposal_validator/proposal_validator.d.ts +8 -2
- package/dest/msg_validators/proposal_validator/proposal_validator.d.ts.map +1 -1
- package/dest/msg_validators/proposal_validator/proposal_validator.js +28 -2
- package/dest/msg_validators/tx_validator/aggregate_tx_validator.d.ts +1 -1
- package/dest/msg_validators/tx_validator/aggregate_tx_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/aggregate_tx_validator.js +8 -15
- package/dest/msg_validators/tx_validator/allowed_public_setup.js +3 -3
- package/dest/msg_validators/tx_validator/cached_tx_validator.d.ts +15 -0
- package/dest/msg_validators/tx_validator/cached_tx_validator.d.ts.map +1 -0
- package/dest/msg_validators/tx_validator/cached_tx_validator.js +19 -0
- package/dest/msg_validators/tx_validator/data_validator.d.ts +2 -1
- package/dest/msg_validators/tx_validator/data_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/data_validator.js +1 -0
- package/dest/msg_validators/tx_validator/factory.d.ts +5 -4
- package/dest/msg_validators/tx_validator/factory.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/factory.js +11 -7
- package/dest/msg_validators/tx_validator/index.d.ts +3 -1
- package/dest/msg_validators/tx_validator/index.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/index.js +2 -0
- package/dest/msg_validators/tx_validator/tx_proof_validator.d.ts +2 -1
- package/dest/msg_validators/tx_validator/tx_proof_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/tx_proof_validator.js +2 -0
- package/dest/msg_validators/tx_validator/tx_validation_cache.d.ts +48 -0
- package/dest/msg_validators/tx_validator/tx_validation_cache.d.ts.map +1 -0
- package/dest/msg_validators/tx_validator/tx_validation_cache.js +68 -0
- package/dest/services/discv5/discV5_service.d.ts +2 -1
- package/dest/services/discv5/discV5_service.d.ts.map +1 -1
- package/dest/services/discv5/discV5_service.js +35 -8
- package/dest/services/dummy_service.d.ts +10 -17
- package/dest/services/dummy_service.d.ts.map +1 -1
- package/dest/services/dummy_service.js +9 -18
- package/dest/services/libp2p/libp2p_service.d.ts +19 -21
- package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
- package/dest/services/libp2p/libp2p_service.js +147 -148
- package/dest/services/peer-manager/peer_manager.d.ts +1 -1
- package/dest/services/peer-manager/peer_manager.d.ts.map +1 -1
- package/dest/services/peer-manager/peer_manager.js +1 -0
- package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts +1 -8
- package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts.map +1 -1
- package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.js +35 -44
- package/dest/services/reqresp/batch-tx-requester/interface.d.ts +8 -5
- package/dest/services/reqresp/batch-tx-requester/interface.d.ts.map +1 -1
- package/dest/services/reqresp/batch-tx-requester/tx_validator.d.ts +5 -14
- package/dest/services/reqresp/batch-tx-requester/tx_validator.d.ts.map +1 -1
- package/dest/services/reqresp/batch-tx-requester/tx_validator.js +6 -20
- package/dest/services/reqresp/interface.d.ts +3 -10
- package/dest/services/reqresp/interface.d.ts.map +1 -1
- package/dest/services/reqresp/interface.js +0 -9
- package/dest/services/reqresp/protocols/block_txs/bitvector.d.ts +4 -3
- package/dest/services/reqresp/protocols/block_txs/bitvector.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/block_txs/bitvector.js +3 -2
- package/dest/services/reqresp/protocols/block_txs/block_txs_handler.d.ts +1 -1
- package/dest/services/reqresp/protocols/block_txs/block_txs_handler.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/block_txs/block_txs_handler.js +31 -28
- package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.d.ts +12 -7
- package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.js +42 -24
- package/dest/services/reqresp/reqresp.d.ts +5 -29
- package/dest/services/reqresp/reqresp.d.ts.map +1 -1
- package/dest/services/reqresp/reqresp.js +16 -206
- package/dest/services/service.d.ts +7 -13
- package/dest/services/service.d.ts.map +1 -1
- package/dest/services/tx_collection/config.d.ts +2 -23
- package/dest/services/tx_collection/config.d.ts.map +1 -1
- package/dest/services/tx_collection/config.js +2 -55
- package/dest/services/tx_collection/file_store_tx_collection.d.ts +12 -28
- package/dest/services/tx_collection/file_store_tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/file_store_tx_collection.js +43 -83
- package/dest/services/tx_collection/index.d.ts +2 -3
- package/dest/services/tx_collection/index.d.ts.map +1 -1
- package/dest/services/tx_collection/index.js +0 -1
- package/dest/services/tx_collection/instrumentation.d.ts +1 -1
- package/dest/services/tx_collection/instrumentation.d.ts.map +1 -1
- package/dest/services/tx_collection/instrumentation.js +0 -2
- package/dest/services/tx_collection/tx_collection.d.ts +35 -51
- package/dest/services/tx_collection/tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/tx_collection.js +275 -119
- package/dest/services/tx_collection/tx_collection_sink.d.ts +1 -1
- package/dest/services/tx_collection/tx_collection_sink.js +2 -2
- package/dest/services/tx_file_store/tx_file_store.d.ts +1 -3
- package/dest/services/tx_file_store/tx_file_store.d.ts.map +1 -1
- package/dest/services/tx_file_store/tx_file_store.js +4 -14
- package/dest/services/tx_provider.d.ts +3 -1
- package/dest/services/tx_provider.d.ts.map +1 -1
- package/dest/services/tx_provider.js +3 -0
- package/dest/test-helpers/make-test-p2p-clients.d.ts +1 -1
- package/dest/test-helpers/make-test-p2p-clients.d.ts.map +1 -1
- package/dest/test-helpers/make-test-p2p-clients.js +1 -1
- package/dest/test-helpers/mock-pubsub.d.ts +13 -7
- package/dest/test-helpers/mock-pubsub.d.ts.map +1 -1
- package/dest/test-helpers/mock-pubsub.js +12 -37
- package/dest/test-helpers/reqresp-nodes.d.ts +4 -5
- package/dest/test-helpers/reqresp-nodes.d.ts.map +1 -1
- package/dest/test-helpers/reqresp-nodes.js +11 -15
- package/dest/test-helpers/test_tx_provider.d.ts +3 -1
- package/dest/test-helpers/test_tx_provider.d.ts.map +1 -1
- package/dest/test-helpers/test_tx_provider.js +3 -0
- package/dest/test-helpers/testbench-utils.d.ts +12 -14
- package/dest/test-helpers/testbench-utils.d.ts.map +1 -1
- package/dest/test-helpers/testbench-utils.js +19 -14
- package/dest/testbench/p2p_client_testbench_worker.d.ts +3 -5
- package/dest/testbench/p2p_client_testbench_worker.d.ts.map +1 -1
- package/dest/testbench/p2p_client_testbench_worker.js +13 -24
- package/dest/testbench/worker_client_manager.d.ts +3 -6
- package/dest/testbench/worker_client_manager.d.ts.map +1 -1
- package/dest/testbench/worker_client_manager.js +2 -8
- package/dest/util.d.ts +11 -6
- package/dest/util.d.ts.map +1 -1
- package/dest/util.js +35 -14
- package/dest/versioning.d.ts +3 -6
- package/dest/versioning.d.ts.map +1 -1
- package/dest/versioning.js +3 -24
- package/package.json +15 -14
- package/src/bootstrap/bootstrap.ts +9 -1
- package/src/client/factory.ts +20 -5
- package/src/client/interface.ts +6 -10
- package/src/client/p2p_client.ts +61 -36
- package/src/client/test/{tx_proposal_collector/README.md → p2p_client.batch_tx_requester.bench.README.md} +23 -53
- package/src/config.ts +94 -6
- package/src/errors/reqresp.error.ts +0 -25
- package/src/mem_pools/attestation_pool/attestation_pool.ts +309 -238
- package/src/mem_pools/attestation_pool/attestation_pool_test_suite.ts +198 -62
- package/src/mem_pools/attestation_pool/mocks.ts +13 -8
- package/src/mem_pools/instrumentation.ts +5 -1
- package/src/mem_pools/tx_pool_v2/archive/tx_archive.ts +1 -9
- package/src/mem_pools/tx_pool_v2/tx_pool_v2_impl.ts +73 -90
- package/src/msg_validators/attestation_validator/attestation_validator.ts +21 -1
- package/src/msg_validators/attestation_validator/fisherman_attestation_validator.ts +11 -7
- package/src/msg_validators/clock_tolerance.ts +13 -12
- package/src/msg_validators/proposal_validator/block_proposal_validator.ts +9 -2
- package/src/msg_validators/proposal_validator/checkpoint_proposal_validator.ts +14 -2
- package/src/msg_validators/proposal_validator/proposal_validator.ts +39 -2
- package/src/msg_validators/tx_validator/aggregate_tx_validator.ts +3 -12
- package/src/msg_validators/tx_validator/allowed_public_setup.ts +3 -3
- package/src/msg_validators/tx_validator/cached_tx_validator.ts +31 -0
- package/src/msg_validators/tx_validator/data_validator.ts +2 -0
- package/src/msg_validators/tx_validator/factory.ts +15 -6
- package/src/msg_validators/tx_validator/index.ts +2 -0
- package/src/msg_validators/tx_validator/tx_proof_validator.ts +2 -0
- package/src/msg_validators/tx_validator/tx_validation_cache.ts +101 -0
- package/src/services/discv5/discV5_service.ts +38 -5
- package/src/services/dummy_service.ts +12 -43
- package/src/services/libp2p/libp2p_service.ts +169 -167
- package/src/services/peer-manager/peer_manager.ts +1 -0
- package/src/services/reqresp/README.md +0 -14
- package/src/services/reqresp/batch-tx-requester/batch_tx_requester.ts +39 -52
- package/src/services/reqresp/batch-tx-requester/interface.ts +11 -4
- package/src/services/reqresp/batch-tx-requester/tx_validator.ts +12 -25
- package/src/services/reqresp/interface.ts +2 -38
- package/src/services/reqresp/protocols/block_txs/bitvector.ts +3 -2
- package/src/services/reqresp/protocols/block_txs/block_txs_handler.ts +34 -30
- package/src/services/reqresp/protocols/block_txs/block_txs_reqresp.ts +47 -20
- package/src/services/reqresp/reqresp.ts +11 -251
- package/src/services/service.ts +9 -30
- package/src/services/tx_collection/config.ts +3 -80
- package/src/services/tx_collection/file_store_tx_collection.ts +54 -103
- package/src/services/tx_collection/index.ts +1 -6
- package/src/services/tx_collection/instrumentation.ts +1 -7
- package/src/services/tx_collection/tx_collection.ts +330 -173
- package/src/services/tx_collection/tx_collection_sink.ts +2 -2
- package/src/services/tx_file_store/tx_file_store.ts +5 -17
- package/src/services/tx_provider.ts +5 -0
- package/src/test-helpers/make-test-p2p-clients.ts +1 -0
- package/src/test-helpers/mock-pubsub.ts +17 -60
- package/src/test-helpers/reqresp-nodes.ts +8 -20
- package/src/test-helpers/test_tx_provider.ts +5 -0
- package/src/test-helpers/testbench-utils.ts +23 -27
- package/src/testbench/p2p_client_testbench_worker.ts +16 -42
- package/src/testbench/worker_client_manager.ts +4 -19
- package/src/util.ts +32 -17
- package/src/versioning.ts +3 -33
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.d.ts +0 -2
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.d.ts.map +0 -1
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.js +0 -318
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker_protocol.d.ts +0 -73
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker_protocol.d.ts.map +0 -1
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker_protocol.js +0 -8
- package/dest/services/reqresp/connection-sampler/batch_connection_sampler.d.ts +0 -64
- package/dest/services/reqresp/connection-sampler/batch_connection_sampler.d.ts.map +0 -1
- package/dest/services/reqresp/connection-sampler/batch_connection_sampler.js +0 -151
- package/dest/services/tx_collection/fast_tx_collection.d.ts +0 -51
- package/dest/services/tx_collection/fast_tx_collection.d.ts.map +0 -1
- package/dest/services/tx_collection/fast_tx_collection.js +0 -311
- package/dest/services/tx_collection/proposal_tx_collector.d.ts +0 -48
- package/dest/services/tx_collection/proposal_tx_collector.d.ts.map +0 -1
- package/dest/services/tx_collection/proposal_tx_collector.js +0 -50
- package/dest/services/tx_collection/slow_tx_collection.d.ts +0 -57
- package/dest/services/tx_collection/slow_tx_collection.d.ts.map +0 -1
- package/dest/services/tx_collection/slow_tx_collection.js +0 -211
- package/src/client/test/tx_proposal_collector/proposal_tx_collector_worker.ts +0 -357
- package/src/client/test/tx_proposal_collector/proposal_tx_collector_worker_protocol.ts +0 -43
- package/src/services/reqresp/connection-sampler/batch_connection_sampler.ts +0 -161
- package/src/services/tx_collection/fast_tx_collection.ts +0 -361
- package/src/services/tx_collection/proposal_tx_collector.ts +0 -108
- package/src/services/tx_collection/slow_tx_collection.ts +0 -266
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { FifoSet } from '@aztec/foundation/fifo-set';
|
|
1
2
|
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
2
3
|
import { RunningPromise } from '@aztec/foundation/promise';
|
|
3
4
|
import { makeBackoff, retry } from '@aztec/foundation/retry';
|
|
@@ -10,6 +11,8 @@ import type { TxPoolV2 } from '../../mem_pools/index.js';
|
|
|
10
11
|
import type { TxFileStoreConfig } from './config.js';
|
|
11
12
|
import { TxFileStoreInstrumentation } from './instrumentation.js';
|
|
12
13
|
|
|
14
|
+
const MAX_RECENT_UPLOADS = 1000;
|
|
15
|
+
|
|
13
16
|
/**
|
|
14
17
|
* Uploads validated transactions to a file store as a fallback retrieval mechanism.
|
|
15
18
|
* Listens to TxPool txs-added events and uploads txs asynchronously with bounded concurrency.
|
|
@@ -21,9 +24,7 @@ export class TxFileStore {
|
|
|
21
24
|
private readonly handleTxsAdded: (args: { txs: Tx[]; source?: string }) => void;
|
|
22
25
|
|
|
23
26
|
/** Recently uploaded tx hashes for deduplication. */
|
|
24
|
-
private recentUploads
|
|
25
|
-
private recentUploadsOrder: string[] = [];
|
|
26
|
-
private readonly maxRecentUploads = 1000;
|
|
27
|
+
private recentUploads = FifoSet.withLimit<string>(MAX_RECENT_UPLOADS);
|
|
27
28
|
|
|
28
29
|
private constructor(
|
|
29
30
|
private readonly fileStore: FileStore,
|
|
@@ -127,24 +128,11 @@ export class TxFileStore {
|
|
|
127
128
|
const path = `${this.basePath}/txs/${txHash}.bin`;
|
|
128
129
|
const timer = new Timer();
|
|
129
130
|
|
|
130
|
-
if (this.recentUploads.
|
|
131
|
+
if (!this.recentUploads.addIfAbsent(txHash)) {
|
|
131
132
|
return;
|
|
132
133
|
}
|
|
133
134
|
|
|
134
135
|
try {
|
|
135
|
-
this.recentUploads.add(txHash);
|
|
136
|
-
this.recentUploadsOrder.push(txHash);
|
|
137
|
-
|
|
138
|
-
if (this.recentUploadsOrder.length > this.maxRecentUploads) {
|
|
139
|
-
// delete old entries in recentUploads
|
|
140
|
-
for (const txHashToRemove of this.recentUploadsOrder.splice(
|
|
141
|
-
0,
|
|
142
|
-
this.recentUploadsOrder.length - this.maxRecentUploads,
|
|
143
|
-
)) {
|
|
144
|
-
this.recentUploads.delete(txHashToRemove);
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
|
|
148
136
|
await retry(
|
|
149
137
|
() => this.fileStore.save(path, tx.toBuffer(), { compress: true }),
|
|
150
138
|
`Uploading tx ${txHash}`,
|
|
@@ -32,6 +32,11 @@ export class TxProvider implements ITxProvider {
|
|
|
32
32
|
this.instrumentation = new TxProviderInstrumentation(client, 'TxProvider');
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
+
/** Returns whether each tx hash is currently in the local tx pool. */
|
|
36
|
+
public hasTxs(txHashes: TxHash[]): Promise<boolean[]> {
|
|
37
|
+
return this.txPool.hasTxs(txHashes);
|
|
38
|
+
}
|
|
39
|
+
|
|
35
40
|
/** Returns txs from the tx pool given their hashes.*/
|
|
36
41
|
public async getAvailableTxs(txHashes: TxHash[]): Promise<{ txs: Tx[]; missingTxs: TxHash[] }> {
|
|
37
42
|
const response = await this.txPool.getTxsByHash(txHashes);
|
|
@@ -23,15 +23,12 @@ import type { MemPools } from '../mem_pools/interface.js';
|
|
|
23
23
|
import { DummyPeerDiscoveryService, DummyPeerManager, LibP2PService } from '../services/index.js';
|
|
24
24
|
import type { P2PReqRespConfig } from '../services/reqresp/config.js';
|
|
25
25
|
import type { ConnectionSampler } from '../services/reqresp/connection-sampler/connection_sampler.js';
|
|
26
|
-
import {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
type ReqRespSubProtocolValidators,
|
|
33
|
-
type SubProtocolMap,
|
|
34
|
-
responseFromBuffer,
|
|
26
|
+
import type {
|
|
27
|
+
ReqRespInterface,
|
|
28
|
+
ReqRespResponse,
|
|
29
|
+
ReqRespSubProtocol,
|
|
30
|
+
ReqRespSubProtocolHandler,
|
|
31
|
+
ReqRespSubProtocolHandlers,
|
|
35
32
|
} from '../services/reqresp/interface.js';
|
|
36
33
|
import { ReqRespStatus } from '../services/reqresp/status.js';
|
|
37
34
|
import { GossipSubEvent } from '../types/index.js';
|
|
@@ -89,8 +86,8 @@ export function getMockPubSubP2PServiceFactory(
|
|
|
89
86
|
|
|
90
87
|
/**
|
|
91
88
|
* Mock implementation of ReqRespInterface that routes requests to other peers' handlers through the mock network.
|
|
92
|
-
* When a peer calls
|
|
93
|
-
*
|
|
89
|
+
* When a peer calls sendRequestToPeer, the mock looks up the target peer's registered handler for the
|
|
90
|
+
* sub-protocol and invokes it, simulating the request-response protocol without actual libp2p streams.
|
|
94
91
|
*/
|
|
95
92
|
class MockReqResp implements ReqRespInterface {
|
|
96
93
|
private handlers: Partial<ReqRespSubProtocolHandlers> = {};
|
|
@@ -106,19 +103,12 @@ class MockReqResp implements ReqRespInterface {
|
|
|
106
103
|
updateConfig(_config: Partial<P2PReqRespConfig>): void {}
|
|
107
104
|
setShouldRejectPeer(): void {}
|
|
108
105
|
|
|
109
|
-
start(
|
|
110
|
-
subProtocolHandlers: Partial<ReqRespSubProtocolHandlers>,
|
|
111
|
-
_subProtocolValidators: ReqRespSubProtocolValidators,
|
|
112
|
-
): Promise<void> {
|
|
106
|
+
start(subProtocolHandlers: Partial<ReqRespSubProtocolHandlers>): Promise<void> {
|
|
113
107
|
Object.assign(this.handlers, subProtocolHandlers);
|
|
114
108
|
return Promise.resolve();
|
|
115
109
|
}
|
|
116
110
|
|
|
117
|
-
addSubProtocol(
|
|
118
|
-
subProtocol: ReqRespSubProtocol,
|
|
119
|
-
handler: ReqRespSubProtocolHandler,
|
|
120
|
-
_validator?: ReqRespSubProtocolValidators[ReqRespSubProtocol],
|
|
121
|
-
): Promise<void> {
|
|
111
|
+
addSubProtocol(subProtocol: ReqRespSubProtocol, handler: ReqRespSubProtocolHandler): Promise<void> {
|
|
122
112
|
this.handlers[subProtocol] = handler;
|
|
123
113
|
return Promise.resolve();
|
|
124
114
|
}
|
|
@@ -132,46 +122,6 @@ class MockReqResp implements ReqRespInterface {
|
|
|
132
122
|
return this.handlers[subProtocol];
|
|
133
123
|
}
|
|
134
124
|
|
|
135
|
-
async sendBatchRequest<SubProtocol extends ReqRespSubProtocol>(
|
|
136
|
-
subProtocol: SubProtocol,
|
|
137
|
-
requests: InstanceType<SubProtocolMap[SubProtocol]['request']>[],
|
|
138
|
-
pinnedPeer: PeerId | undefined,
|
|
139
|
-
_timeoutMs?: number,
|
|
140
|
-
_maxPeers?: number,
|
|
141
|
-
_maxRetryAttempts?: number,
|
|
142
|
-
): Promise<InstanceType<SubProtocolMap[SubProtocol]['response']>[]> {
|
|
143
|
-
const responses: InstanceType<SubProtocolMap[SubProtocol]['response']>[] = [];
|
|
144
|
-
const peers = this.network.getReqRespPeers().filter(p => !p.peerId.equals(this.peerId));
|
|
145
|
-
const targetPeers = pinnedPeer ? peers.filter(p => p.peerId.equals(pinnedPeer)) : peers;
|
|
146
|
-
const delayMs = this.network.getPropagationDelayMs();
|
|
147
|
-
|
|
148
|
-
if (delayMs > 0) {
|
|
149
|
-
await sleep(delayMs);
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
for (const request of requests) {
|
|
153
|
-
const requestBuffer = request.toBuffer();
|
|
154
|
-
for (const peer of targetPeers) {
|
|
155
|
-
const handler = peer.getHandler(subProtocol);
|
|
156
|
-
if (!handler) {
|
|
157
|
-
continue;
|
|
158
|
-
}
|
|
159
|
-
try {
|
|
160
|
-
const responseBuffer = await handler(this.peerId, requestBuffer);
|
|
161
|
-
if (responseBuffer.length > 0) {
|
|
162
|
-
const response = responseFromBuffer(subProtocol, responseBuffer);
|
|
163
|
-
responses.push(response as InstanceType<SubProtocolMap[SubProtocol]['response']>);
|
|
164
|
-
break;
|
|
165
|
-
}
|
|
166
|
-
} catch (err) {
|
|
167
|
-
this.logger.debug(`Mock reqresp handler error from peer ${peer.peerId}`, { err });
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
return responses;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
125
|
async sendRequestToPeer(
|
|
176
126
|
peerId: PeerId,
|
|
177
127
|
subProtocol: ReqRespSubProtocol,
|
|
@@ -227,6 +177,13 @@ export class MockPubSub implements PubSubLibp2p {
|
|
|
227
177
|
get services() {
|
|
228
178
|
return {
|
|
229
179
|
pubsub: this.gossipSub,
|
|
180
|
+
components: {
|
|
181
|
+
addressManager: {
|
|
182
|
+
addObservedAddr: () => {},
|
|
183
|
+
confirmObservedAddr: () => {},
|
|
184
|
+
removeObservedAddr: () => {},
|
|
185
|
+
},
|
|
186
|
+
},
|
|
230
187
|
};
|
|
231
188
|
}
|
|
232
189
|
|
|
@@ -31,7 +31,7 @@ import getPort from 'get-port';
|
|
|
31
31
|
import { type Libp2p, type Libp2pOptions, createLibp2p } from 'libp2p';
|
|
32
32
|
|
|
33
33
|
import { BootstrapNode } from '../bootstrap/bootstrap.js';
|
|
34
|
-
import type
|
|
34
|
+
import { type BootnodeConfig, DEFAULT_PUBLIC_IP_SERVICES, type P2PConfig } from '../config.js';
|
|
35
35
|
import type { MemPools } from '../mem_pools/interface.js';
|
|
36
36
|
import { DiscV5Service } from '../services/discv5/discV5_service.js';
|
|
37
37
|
import { APP_SPECIFIC_WEIGHT } from '../services/gossipsub/scoring.js';
|
|
@@ -43,8 +43,6 @@ import {
|
|
|
43
43
|
ReqRespSubProtocol,
|
|
44
44
|
type ReqRespSubProtocolHandlers,
|
|
45
45
|
type ReqRespSubProtocolRateLimits,
|
|
46
|
-
type ReqRespSubProtocolValidators,
|
|
47
|
-
noopValidator,
|
|
48
46
|
} from '../services/reqresp/interface.js';
|
|
49
47
|
import { pingHandler } from '../services/reqresp/protocols/index.js';
|
|
50
48
|
import { ReqResp } from '../services/reqresp/reqresp.js';
|
|
@@ -77,6 +75,10 @@ export async function createLibp2pNode(
|
|
|
77
75
|
identify: identify({
|
|
78
76
|
protocolPrefix: 'aztec',
|
|
79
77
|
}),
|
|
78
|
+
components: (components: { connectionManager: any; addressManager: any }) => ({
|
|
79
|
+
connectionManager: components.connectionManager,
|
|
80
|
+
addressManager: components.addressManager,
|
|
81
|
+
}),
|
|
80
82
|
},
|
|
81
83
|
};
|
|
82
84
|
|
|
@@ -195,17 +197,6 @@ export const MOCK_SUB_PROTOCOL_HANDLERS: ReqRespSubProtocolHandlers = {
|
|
|
195
197
|
[ReqRespSubProtocol.BLOCK_TXS]: (_msg: any) => Promise.resolve(Buffer.from('block_txs')),
|
|
196
198
|
};
|
|
197
199
|
|
|
198
|
-
// By default, all requests are valid
|
|
199
|
-
// If you want to test an invalid response, you can override the validator
|
|
200
|
-
export const MOCK_SUB_PROTOCOL_VALIDATORS: ReqRespSubProtocolValidators = {
|
|
201
|
-
[ReqRespSubProtocol.PING]: noopValidator,
|
|
202
|
-
[ReqRespSubProtocol.STATUS]: noopValidator,
|
|
203
|
-
[ReqRespSubProtocol.TX]: noopValidator,
|
|
204
|
-
[ReqRespSubProtocol.GOODBYE]: noopValidator,
|
|
205
|
-
[ReqRespSubProtocol.AUTH]: noopValidator,
|
|
206
|
-
[ReqRespSubProtocol.BLOCK_TXS]: noopValidator,
|
|
207
|
-
};
|
|
208
|
-
|
|
209
200
|
/**
|
|
210
201
|
* @param numberOfNodes - the number of nodes to create
|
|
211
202
|
* @returns An array of the created nodes
|
|
@@ -218,13 +209,9 @@ export const createNodes = (
|
|
|
218
209
|
return timesParallel(numberOfNodes, () => createReqResp(peerScoring, rateLimits));
|
|
219
210
|
};
|
|
220
211
|
|
|
221
|
-
export const startNodes = async (
|
|
222
|
-
nodes: ReqRespNode[],
|
|
223
|
-
subProtocolHandlers = MOCK_SUB_PROTOCOL_HANDLERS,
|
|
224
|
-
subProtocolValidators = MOCK_SUB_PROTOCOL_VALIDATORS,
|
|
225
|
-
) => {
|
|
212
|
+
export const startNodes = async (nodes: ReqRespNode[], subProtocolHandlers = MOCK_SUB_PROTOCOL_HANDLERS) => {
|
|
226
213
|
for (const node of nodes) {
|
|
227
|
-
await node.req.start(subProtocolHandlers
|
|
214
|
+
await node.req.start(subProtocolHandlers);
|
|
228
215
|
}
|
|
229
216
|
};
|
|
230
217
|
|
|
@@ -292,6 +279,7 @@ export function createBootstrapNodeConfig(privateKey: string, port: number, chai
|
|
|
292
279
|
bootstrapNodes: [],
|
|
293
280
|
listenAddress: '127.0.0.1',
|
|
294
281
|
queryForIp: false,
|
|
282
|
+
publicIpServices: DEFAULT_PUBLIC_IP_SERVICES,
|
|
295
283
|
};
|
|
296
284
|
}
|
|
297
285
|
|
|
@@ -31,6 +31,11 @@ export class TestTxProvider implements ITxProvider {
|
|
|
31
31
|
return this.getTxsByHashes(txHashes);
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
+
/** Returns whether each tx hash is in the seeded collection. */
|
|
35
|
+
hasTxs(txHashes: TxHash[]): Promise<boolean[]> {
|
|
36
|
+
return Promise.resolve(txHashes.map(h => this.txs.has(h.toString())));
|
|
37
|
+
}
|
|
38
|
+
|
|
34
39
|
/** Get txs for a block proposal, returning any seeded txs that match the requested hashes. */
|
|
35
40
|
getTxsForBlockProposal(
|
|
36
41
|
blockProposal: BlockProposal,
|
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
import type { EpochCacheInterface } from '@aztec/epoch-cache';
|
|
2
|
+
import type { CheckpointProposalHash } from '@aztec/foundation/branded-types';
|
|
2
3
|
import { EpochNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
3
4
|
import type { Logger } from '@aztec/foundation/log';
|
|
4
5
|
import type { L2Block, L2BlockId } from '@aztec/stdlib/block';
|
|
5
6
|
import type { WorldStateSynchronizer } from '@aztec/stdlib/interfaces/server';
|
|
6
|
-
import type {
|
|
7
|
-
BlockProposal,
|
|
8
|
-
CheckpointAttestation,
|
|
9
|
-
CheckpointProposal,
|
|
10
|
-
CheckpointProposalCore,
|
|
11
|
-
} from '@aztec/stdlib/p2p';
|
|
7
|
+
import type { BlockProposal, CheckpointAttestation, CheckpointProposalCore } from '@aztec/stdlib/p2p';
|
|
12
8
|
import { type BlockHeader, Tx, TxHash } from '@aztec/stdlib/tx';
|
|
13
9
|
|
|
14
10
|
import EventEmitter from 'events';
|
|
@@ -214,6 +210,7 @@ export class InMemoryTxPool extends EventEmitter implements TxPoolV2 {
|
|
|
214
210
|
*/
|
|
215
211
|
export class InMemoryAttestationPool {
|
|
216
212
|
private proposals = new Map<string, BlockProposal>();
|
|
213
|
+
private checkpoints = new Map<SlotNumber, CheckpointProposalCore[]>();
|
|
217
214
|
|
|
218
215
|
tryAddBlockProposal(blockProposal: BlockProposal): Promise<TryAddResult> {
|
|
219
216
|
const id = blockProposal.archive.toString();
|
|
@@ -225,16 +222,29 @@ export class InMemoryAttestationPool {
|
|
|
225
222
|
return Promise.resolve({ added: true, alreadyExists: false, count: 1 });
|
|
226
223
|
}
|
|
227
224
|
|
|
228
|
-
|
|
225
|
+
getBlockProposalByArchive(id: string): Promise<BlockProposal | undefined> {
|
|
229
226
|
return Promise.resolve(this.proposals.get(id));
|
|
230
227
|
}
|
|
231
228
|
|
|
232
|
-
tryAddCheckpointProposal(
|
|
229
|
+
tryAddCheckpointProposal(proposal: CheckpointProposalCore): Promise<TryAddResult> {
|
|
230
|
+
const proposals = this.checkpoints.get(proposal.slotNumber) ?? [];
|
|
231
|
+
proposals.push(proposal);
|
|
232
|
+
this.checkpoints.set(proposal.slotNumber, proposals);
|
|
233
233
|
return Promise.resolve({ added: true, alreadyExists: false, count: 1 });
|
|
234
234
|
}
|
|
235
235
|
|
|
236
|
-
getCheckpointProposal(
|
|
237
|
-
return Promise.resolve(
|
|
236
|
+
getCheckpointProposal(slot: SlotNumber): Promise<CheckpointProposalCore | undefined> {
|
|
237
|
+
return Promise.resolve(this.checkpoints.get(slot)?.[0]);
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
getProposalsForSlot(slot: SlotNumber): Promise<{
|
|
241
|
+
blockProposals: BlockProposal[];
|
|
242
|
+
checkpointProposals: CheckpointProposalCore[];
|
|
243
|
+
}> {
|
|
244
|
+
return Promise.resolve({
|
|
245
|
+
blockProposals: [...this.proposals.values()].filter(proposal => proposal.slotNumber === slot),
|
|
246
|
+
checkpointProposals: this.checkpoints.get(slot) ?? [],
|
|
247
|
+
});
|
|
238
248
|
}
|
|
239
249
|
|
|
240
250
|
async addOwnCheckpointAttestations(_attestations: CheckpointAttestation[]): Promise<void> {}
|
|
@@ -247,7 +257,7 @@ export class InMemoryAttestationPool {
|
|
|
247
257
|
|
|
248
258
|
getCheckpointAttestationsForSlotAndProposal(
|
|
249
259
|
_slot: SlotNumber,
|
|
250
|
-
|
|
260
|
+
_proposalPayloadHash: CheckpointProposalHash,
|
|
251
261
|
): Promise<CheckpointAttestation[]> {
|
|
252
262
|
return Promise.resolve([]);
|
|
253
263
|
}
|
|
@@ -261,11 +271,12 @@ export class InMemoryAttestationPool {
|
|
|
261
271
|
}
|
|
262
272
|
|
|
263
273
|
isEmpty(): Promise<boolean> {
|
|
264
|
-
return Promise.resolve(this.proposals.size === 0);
|
|
274
|
+
return Promise.resolve(this.proposals.size === 0 && this.checkpoints.size === 0);
|
|
265
275
|
}
|
|
266
276
|
|
|
267
277
|
resetState(): void {
|
|
268
278
|
this.proposals.clear();
|
|
279
|
+
this.checkpoints.clear();
|
|
269
280
|
}
|
|
270
281
|
}
|
|
271
282
|
|
|
@@ -286,8 +297,6 @@ export function createMockEpochCache(): EpochCacheInterface {
|
|
|
286
297
|
ts: 0n,
|
|
287
298
|
nowMs: 0n,
|
|
288
299
|
}),
|
|
289
|
-
isProposerPipeliningEnabled: () => false,
|
|
290
|
-
pipeliningOffset: () => 0,
|
|
291
300
|
computeProposerIndex: () => 0n,
|
|
292
301
|
getCurrentAndNextSlot: () => ({ currentSlot: SlotNumber.ZERO, nextSlot: SlotNumber.ZERO }),
|
|
293
302
|
getTargetAndNextSlot: () => ({ targetSlot: SlotNumber.ZERO, nextSlot: SlotNumber.ZERO }),
|
|
@@ -367,19 +376,6 @@ export function installUnlimitedRateLimitsOnReqResp(reqResp: any): void {
|
|
|
367
376
|
*/
|
|
368
377
|
export type DistributionPattern = 'uniform' | 'sparse' | 'pinned-only';
|
|
369
378
|
|
|
370
|
-
/**
|
|
371
|
-
* Collector implementation types for benchmarking.
|
|
372
|
-
*/
|
|
373
|
-
export type CollectorType = 'batch-requester' | 'send-batch-request';
|
|
374
|
-
|
|
375
|
-
/**
|
|
376
|
-
* Display names for collector types (for output/logging only).
|
|
377
|
-
*/
|
|
378
|
-
export const COLLECTOR_DISPLAY_NAMES: Record<CollectorType, string> = {
|
|
379
|
-
'batch-requester': 'batch-requester (new)',
|
|
380
|
-
'send-batch-request': 'send-batch-request (old)',
|
|
381
|
-
};
|
|
382
|
-
|
|
383
379
|
/**
|
|
384
380
|
* Benchmark timing constants.
|
|
385
381
|
*/
|
|
@@ -23,7 +23,7 @@ import type { DataStoreConfig } from '@aztec/stdlib/kv-store';
|
|
|
23
23
|
import { type BlockProposal, P2PMessage } from '@aztec/stdlib/p2p';
|
|
24
24
|
import { ChonkProof } from '@aztec/stdlib/proofs';
|
|
25
25
|
import { makeAztecAddress, makeBlockHeader, makeBlockProposal, mockTx } from '@aztec/stdlib/testing';
|
|
26
|
-
import { Tx, TxHash, type TxValidationResult } from '@aztec/stdlib/tx';
|
|
26
|
+
import { Tx, TxHash, type TxValidationResult, type TxValidator } from '@aztec/stdlib/tx';
|
|
27
27
|
import { type TelemetryClient, getTelemetryClient } from '@aztec/telemetry-client';
|
|
28
28
|
|
|
29
29
|
import type { Message, PeerId } from '@libp2p/interface';
|
|
@@ -34,10 +34,10 @@ import type { P2PClient } from '../client/index.js';
|
|
|
34
34
|
import type { P2PConfig } from '../config.js';
|
|
35
35
|
import { createP2PClient } from '../index.js';
|
|
36
36
|
import type { MemPools } from '../mem_pools/index.js';
|
|
37
|
-
import {
|
|
37
|
+
import { LibP2PService } from '../services/index.js';
|
|
38
38
|
import type { PeerManager } from '../services/peer-manager/peer_manager.js';
|
|
39
|
+
import { BatchTxRequester } from '../services/reqresp/batch-tx-requester/batch_tx_requester.js';
|
|
39
40
|
import type { BatchTxRequesterLibP2PService } from '../services/reqresp/batch-tx-requester/interface.js';
|
|
40
|
-
import type { IBatchRequestTxValidator } from '../services/reqresp/batch-tx-requester/tx_validator.js';
|
|
41
41
|
import { RateLimitStatus } from '../services/reqresp/rate-limiter/rate_limiter.js';
|
|
42
42
|
import type { ReqResp } from '../services/reqresp/reqresp.js';
|
|
43
43
|
import type { PeerDiscoveryService } from '../services/service.js';
|
|
@@ -45,7 +45,6 @@ import { RequestTracker } from '../services/tx_collection/request_tracker.js';
|
|
|
45
45
|
import { AlwaysTrueCircuitVerifier } from '../test-helpers/index.js';
|
|
46
46
|
import {
|
|
47
47
|
BENCHMARK_CONSTANTS,
|
|
48
|
-
type CollectorType,
|
|
49
48
|
type DistributionPattern,
|
|
50
49
|
InMemoryAttestationPool,
|
|
51
50
|
InMemoryTxPool,
|
|
@@ -56,15 +55,13 @@ import {
|
|
|
56
55
|
} from '../test-helpers/index.js';
|
|
57
56
|
import type { PubSubLibp2p } from '../util.js';
|
|
58
57
|
|
|
59
|
-
export type { DistributionPattern
|
|
60
|
-
export { COLLECTOR_DISPLAY_NAMES } from '../test-helpers/testbench-utils.js';
|
|
58
|
+
export type { DistributionPattern } from '../test-helpers/testbench-utils.js';
|
|
61
59
|
|
|
62
60
|
export interface BenchReqRespCommand {
|
|
63
61
|
type: 'BENCH_REQRESP';
|
|
64
62
|
txCount: number;
|
|
65
63
|
peerCount: number;
|
|
66
64
|
distribution: DistributionPattern;
|
|
67
|
-
collectorType: CollectorType;
|
|
68
65
|
timeoutMs: number;
|
|
69
66
|
isAggregator: boolean;
|
|
70
67
|
peerIndex: number;
|
|
@@ -228,7 +225,6 @@ function getConnectedPeerCount(client: P2PClient): number {
|
|
|
228
225
|
async function runAggregatorBenchmark(
|
|
229
226
|
client: P2PClient,
|
|
230
227
|
blockProposal: BlockProposal,
|
|
231
|
-
collectorType: CollectorType,
|
|
232
228
|
timeoutMs: number,
|
|
233
229
|
pinnedPeerId: string | undefined,
|
|
234
230
|
pinnedPeerIndex: number | undefined,
|
|
@@ -279,44 +275,22 @@ async function runAggregatorBenchmark(
|
|
|
279
275
|
}
|
|
280
276
|
}
|
|
281
277
|
|
|
282
|
-
const noopTxValidator:
|
|
283
|
-
|
|
284
|
-
validateRequestedTxs: (txs: Tx[]): Promise<TxValidationResult[]> =>
|
|
285
|
-
Promise.resolve(txs.map(() => ({ result: 'valid' }))),
|
|
278
|
+
const noopTxValidator: TxValidator = {
|
|
279
|
+
validateTx: (_tx: Tx): Promise<TxValidationResult> => Promise.resolve({ result: 'valid' }),
|
|
286
280
|
};
|
|
287
281
|
|
|
288
282
|
timer = new Timer();
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
logger,
|
|
293
|
-
new DateProvider(),
|
|
294
|
-
noopTxValidator,
|
|
295
|
-
);
|
|
296
|
-
const fetchedTxs = await collector.collectTxs(
|
|
297
|
-
RequestTracker.create(txHashes, new Date(Date.now() + timeoutMs)),
|
|
298
|
-
blockProposal,
|
|
299
|
-
pinnedPeer,
|
|
300
|
-
);
|
|
301
|
-
const durationMs = timer.ms();
|
|
302
|
-
return {
|
|
303
|
-
type: 'BENCH_RESULT',
|
|
304
|
-
durationMs,
|
|
305
|
-
fetchedCount: fetchedTxs.length,
|
|
306
|
-
success: fetchedTxs.length === txHashes.length,
|
|
307
|
-
};
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
const collector = new SendBatchRequestCollector(
|
|
311
|
-
batchTxRequesterService,
|
|
312
|
-
BENCHMARK_CONSTANTS.FIXED_MAX_PEERS,
|
|
313
|
-
BENCHMARK_CONSTANTS.FIXED_MAX_RETRY_ATTEMPTS,
|
|
314
|
-
);
|
|
315
|
-
const fetchedTxs = await collector.collectTxs(
|
|
316
|
-
RequestTracker.create(txHashes, new Date(Date.now() + timeoutMs)),
|
|
283
|
+
const tracker = RequestTracker.create(txHashes, new Date(Date.now() + timeoutMs));
|
|
284
|
+
const batchRequester = new BatchTxRequester(
|
|
285
|
+
tracker,
|
|
317
286
|
blockProposal,
|
|
318
287
|
pinnedPeer,
|
|
288
|
+
batchTxRequesterService,
|
|
289
|
+
logger,
|
|
290
|
+
new DateProvider(),
|
|
291
|
+
{ txValidator: noopTxValidator },
|
|
319
292
|
);
|
|
293
|
+
const fetchedTxs = await BatchTxRequester.collectAllTxs(batchRequester.run());
|
|
320
294
|
const durationMs = timer.ms();
|
|
321
295
|
return {
|
|
322
296
|
type: 'BENCH_RESULT',
|
|
@@ -424,6 +398,7 @@ process.on('message', async msg => {
|
|
|
424
398
|
undefined,
|
|
425
399
|
telemetry as TelemetryClient,
|
|
426
400
|
deps,
|
|
401
|
+
await l2BlockSource.getInitialHeader().hash(),
|
|
427
402
|
);
|
|
428
403
|
|
|
429
404
|
const testService = new TestLibP2PService(
|
|
@@ -514,13 +489,12 @@ process.on('message', async msg => {
|
|
|
514
489
|
workerTxPool.clearTxs();
|
|
515
490
|
|
|
516
491
|
workerLogger.info(
|
|
517
|
-
`[BENCH] Aggregator starting benchmark: txCount=${benchCmd.txCount},
|
|
492
|
+
`[BENCH] Aggregator starting benchmark: txCount=${benchCmd.txCount}, distribution=${benchCmd.distribution}`,
|
|
518
493
|
);
|
|
519
494
|
|
|
520
495
|
const result = await runAggregatorBenchmark(
|
|
521
496
|
workerClient,
|
|
522
497
|
blockProposal,
|
|
523
|
-
benchCmd.collectorType,
|
|
524
498
|
benchCmd.timeoutMs,
|
|
525
499
|
benchCmd.pinnedPeerId,
|
|
526
500
|
benchCmd.pinnedPeerIndex,
|
|
@@ -13,12 +13,7 @@ import { generatePeerIdPrivateKeys } from '../test-helpers/generate-peer-id-priv
|
|
|
13
13
|
import { getPorts } from '../test-helpers/get-ports.js';
|
|
14
14
|
import { makeEnr, makeEnrs } from '../test-helpers/make-enrs.js';
|
|
15
15
|
import { BENCHMARK_CONSTANTS } from '../test-helpers/testbench-utils.js';
|
|
16
|
-
import type {
|
|
17
|
-
BenchReqRespCommand,
|
|
18
|
-
BenchResultMessage,
|
|
19
|
-
CollectorType,
|
|
20
|
-
DistributionPattern,
|
|
21
|
-
} from './p2p_client_testbench_worker.js';
|
|
16
|
+
import type { BenchReqRespCommand, BenchResultMessage, DistributionPattern } from './p2p_client_testbench_worker.js';
|
|
22
17
|
|
|
23
18
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
24
19
|
const p2pRoot = path.resolve(__dirname, '../..');
|
|
@@ -29,15 +24,12 @@ const tsconfigPath = path.join(p2pRoot, 'tsconfig.json');
|
|
|
29
24
|
const testChainConfig: ChainConfig = {
|
|
30
25
|
l1ChainId: 31337,
|
|
31
26
|
rollupVersion: 1,
|
|
32
|
-
|
|
33
|
-
rollupAddress: EthAddress.random(),
|
|
34
|
-
},
|
|
27
|
+
rollupAddress: EthAddress.random(),
|
|
35
28
|
};
|
|
36
29
|
|
|
37
30
|
export interface ReqRespBenchmarkConfig {
|
|
38
31
|
txCount: number;
|
|
39
32
|
distribution: DistributionPattern;
|
|
40
|
-
collectorType: CollectorType;
|
|
41
33
|
timeoutMs: number;
|
|
42
34
|
pinnedPeerIndex?: number;
|
|
43
35
|
blockNumber?: number;
|
|
@@ -47,7 +39,6 @@ export interface ReqRespBenchmarkConfig {
|
|
|
47
39
|
export interface ReqRespBenchmarkResult {
|
|
48
40
|
txCount: number;
|
|
49
41
|
distribution: DistributionPattern;
|
|
50
|
-
collector: CollectorType;
|
|
51
42
|
durationMs: number;
|
|
52
43
|
fetchedCount: number;
|
|
53
44
|
success: boolean;
|
|
@@ -499,9 +490,7 @@ class WorkerClientManager {
|
|
|
499
490
|
const blockNumber = config.blockNumber ?? 1;
|
|
500
491
|
const pinnedPeerId = config.pinnedPeerIndex !== undefined ? this.peerIds[config.pinnedPeerIndex] : undefined;
|
|
501
492
|
|
|
502
|
-
this.logger.info(
|
|
503
|
-
`Starting req/resp benchmark: txCount=${config.txCount}, distribution=${config.distribution}, collector=${config.collectorType}`,
|
|
504
|
-
);
|
|
493
|
+
this.logger.info(`Starting req/resp benchmark: txCount=${config.txCount}, distribution=${config.distribution}`);
|
|
505
494
|
|
|
506
495
|
const readyPromises: Promise<void>[] = [];
|
|
507
496
|
|
|
@@ -511,7 +500,6 @@ class WorkerClientManager {
|
|
|
511
500
|
txCount: config.txCount,
|
|
512
501
|
peerCount,
|
|
513
502
|
distribution: config.distribution,
|
|
514
|
-
collectorType: config.collectorType,
|
|
515
503
|
timeoutMs: config.timeoutMs,
|
|
516
504
|
isAggregator: false,
|
|
517
505
|
peerIndex: i,
|
|
@@ -533,7 +521,6 @@ class WorkerClientManager {
|
|
|
533
521
|
txCount: config.txCount,
|
|
534
522
|
peerCount,
|
|
535
523
|
distribution: config.distribution,
|
|
536
|
-
collectorType: config.collectorType,
|
|
537
524
|
timeoutMs: config.timeoutMs,
|
|
538
525
|
isAggregator: true,
|
|
539
526
|
peerIndex: 0,
|
|
@@ -554,7 +541,6 @@ class WorkerClientManager {
|
|
|
554
541
|
return {
|
|
555
542
|
txCount: config.txCount,
|
|
556
543
|
distribution: config.distribution,
|
|
557
|
-
collector: config.collectorType,
|
|
558
544
|
durationMs: result.durationMs,
|
|
559
545
|
fetchedCount: result.fetchedCount,
|
|
560
546
|
success: result.success,
|
|
@@ -632,5 +618,4 @@ class WorkerClientManager {
|
|
|
632
618
|
}
|
|
633
619
|
|
|
634
620
|
export { WorkerClientManager, testChainConfig };
|
|
635
|
-
export type { DistributionPattern
|
|
636
|
-
export { COLLECTOR_DISPLAY_NAMES } from './p2p_client_testbench_worker.js';
|
|
621
|
+
export type { DistributionPattern } from './p2p_client_testbench_worker.js';
|