@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
package/src/util.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SecretValue } from '@aztec/foundation/config';
|
|
2
|
-
import type
|
|
2
|
+
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
3
3
|
import type { AztecAsyncKVStore, AztecAsyncSingleton } from '@aztec/kv-store';
|
|
4
4
|
import type { DataStoreConfig } from '@aztec/stdlib/kv-store';
|
|
5
5
|
|
|
@@ -7,7 +7,7 @@ import type { GossipSub } from '@chainsafe/libp2p-gossipsub';
|
|
|
7
7
|
import { generateKeyPair, marshalPrivateKey, unmarshalPrivateKey } from '@libp2p/crypto/keys';
|
|
8
8
|
import type { Identify } from '@libp2p/identify';
|
|
9
9
|
import type { PeerId, PrivateKey } from '@libp2p/interface';
|
|
10
|
-
import type { ConnectionManager } from '@libp2p/interface-internal';
|
|
10
|
+
import type { AddressManager, ConnectionManager } from '@libp2p/interface-internal';
|
|
11
11
|
import { createFromPrivKey } from '@libp2p/peer-id-factory';
|
|
12
12
|
import { resolve } from 'dns/promises';
|
|
13
13
|
import { promises as fs } from 'fs';
|
|
@@ -15,7 +15,7 @@ import type { Libp2p } from 'libp2p';
|
|
|
15
15
|
import net from 'net';
|
|
16
16
|
import path from 'path';
|
|
17
17
|
|
|
18
|
-
import type
|
|
18
|
+
import { DEFAULT_PUBLIC_IP_SERVICES, type P2PConfig } from './config.js';
|
|
19
19
|
|
|
20
20
|
const PEER_ID_DATA_DIR_FILE = 'p2p-private-key';
|
|
21
21
|
|
|
@@ -31,6 +31,9 @@ export interface PubSubLibp2p extends Pick<Libp2p, 'status' | 'start' | 'stop' |
|
|
|
31
31
|
| 'direct'
|
|
32
32
|
| 'getMeshPeers'
|
|
33
33
|
> & { score: Pick<GossipSub['score'], 'score'> };
|
|
34
|
+
components: {
|
|
35
|
+
addressManager: Pick<AddressManager, 'addObservedAddr' | 'confirmObservedAddr' | 'removeObservedAddr'>;
|
|
36
|
+
};
|
|
34
37
|
};
|
|
35
38
|
}
|
|
36
39
|
|
|
@@ -39,6 +42,7 @@ export type FullLibp2p = Libp2p<{
|
|
|
39
42
|
pubsub: GossipSub;
|
|
40
43
|
components: {
|
|
41
44
|
connectionManager: ConnectionManager;
|
|
45
|
+
addressManager: AddressManager;
|
|
42
46
|
};
|
|
43
47
|
}>;
|
|
44
48
|
|
|
@@ -60,16 +64,25 @@ export function convertToMultiaddr(address: string, port: number, protocol: 'tcp
|
|
|
60
64
|
}
|
|
61
65
|
|
|
62
66
|
/**
|
|
63
|
-
* Queries the public IP address of the machine.
|
|
67
|
+
* Queries the public IP address of the machine, trying multiple services in order.
|
|
68
|
+
* @param services - HTTPS URLs to try; defaults to {@link DEFAULT_PUBLIC_IP_SERVICES}.
|
|
64
69
|
*/
|
|
65
|
-
export async function getPublicIp(): Promise<string> {
|
|
66
|
-
const
|
|
67
|
-
const
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
70
|
+
export async function getPublicIp(services: string[] = DEFAULT_PUBLIC_IP_SERVICES): Promise<string> {
|
|
71
|
+
const errors: string[] = [];
|
|
72
|
+
for (const url of services) {
|
|
73
|
+
try {
|
|
74
|
+
const resp = await fetch(url, { signal: AbortSignal.timeout(5000) });
|
|
75
|
+
const text = await resp.text();
|
|
76
|
+
const address = text.trim();
|
|
77
|
+
if (isValidIpAddress(address)) {
|
|
78
|
+
return address;
|
|
79
|
+
}
|
|
80
|
+
errors.push(`${url}: invalid IP "${address}"`);
|
|
81
|
+
} catch (err: any) {
|
|
82
|
+
errors.push(`${url}: ${err.message ?? err}`);
|
|
83
|
+
}
|
|
71
84
|
}
|
|
72
|
-
|
|
85
|
+
throw new Error(`Failed to determine public IP from all services:\n${errors.join('\n')}`);
|
|
73
86
|
}
|
|
74
87
|
|
|
75
88
|
export function isValidIpAddress(address: string): boolean {
|
|
@@ -107,18 +120,20 @@ export async function configureP2PClientAddresses(
|
|
|
107
120
|
): Promise<P2PConfig & DataStoreConfig> {
|
|
108
121
|
const config = { ..._config };
|
|
109
122
|
const { p2pIp, queryForIp, p2pBroadcastPort, p2pPort } = config;
|
|
123
|
+
const logger = createLogger('p2p:config');
|
|
110
124
|
|
|
111
125
|
// If no broadcast port is provided, use the given p2p port as the broadcast port
|
|
112
126
|
if (!p2pBroadcastPort) {
|
|
113
127
|
config.p2pBroadcastPort = p2pPort;
|
|
114
128
|
}
|
|
115
129
|
|
|
116
|
-
//
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
130
|
+
// Resolve the initial public IP so the ENR and announce address are set at startup.
|
|
131
|
+
// If queryForIp is enabled, discv5 will also track IP changes at runtime via enrUpdate.
|
|
132
|
+
if (!p2pIp && queryForIp) {
|
|
133
|
+
config.p2pIp = await getPublicIp(config.publicIpServices);
|
|
134
|
+
logger.info('Resolved initial public IP for P2P', { ip: config.p2pIp, queryForIp });
|
|
135
|
+
} else if (p2pIp) {
|
|
136
|
+
logger.info('Using configured static P2P IP', { ip: p2pIp, queryForIp });
|
|
122
137
|
}
|
|
123
138
|
// TODO(md): guard against setting a local ip address as the announce ip
|
|
124
139
|
|
package/src/versioning.ts
CHANGED
|
@@ -1,33 +1,21 @@
|
|
|
1
|
-
import { toBufferBE } from '@aztec/foundation/bigint-buffer';
|
|
2
1
|
import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
|
|
3
2
|
import { protocolContractsHash } from '@aztec/protocol-contracts';
|
|
4
3
|
import type { ChainConfig } from '@aztec/stdlib/config';
|
|
5
|
-
import {
|
|
6
|
-
type ComponentsVersions,
|
|
7
|
-
checkCompressedComponentVersion,
|
|
8
|
-
compressComponentVersions,
|
|
9
|
-
getComponentsVersionsFromConfig,
|
|
10
|
-
} from '@aztec/stdlib/versioning';
|
|
4
|
+
import { compressComponentVersions, getComponentsVersionsFromConfig } from '@aztec/stdlib/versioning';
|
|
11
5
|
|
|
12
6
|
import type { SignableENR } from '@nethermindeth/enr';
|
|
13
|
-
import xxhashFactory from 'xxhash-wasm';
|
|
14
7
|
|
|
15
8
|
import { AZTEC_ENR_CLIENT_VERSION_KEY, AZTEC_ENR_KEY } from './types/index.js';
|
|
16
9
|
|
|
17
|
-
const USE_XX_HASH = false; // Enable to reduce the size of the ENR record for production
|
|
18
|
-
const XX_HASH_LEN = 8;
|
|
19
|
-
const xxhash = await xxhashFactory();
|
|
20
|
-
|
|
21
10
|
/** Returns the component versions based on config and this build. */
|
|
22
11
|
export function getVersions(config: ChainConfig) {
|
|
23
12
|
return getComponentsVersionsFromConfig(config, protocolContractsHash, getVKTreeRoot());
|
|
24
13
|
}
|
|
25
14
|
|
|
26
15
|
/** Sets the aztec key on the ENR record with versioning info. */
|
|
27
|
-
export function setAztecEnrKey(enr: SignableENR, config: ChainConfig
|
|
16
|
+
export function setAztecEnrKey(enr: SignableENR, config: ChainConfig) {
|
|
28
17
|
const versions = getVersions(config);
|
|
29
|
-
|
|
30
|
-
enr.set(AZTEC_ENR_KEY, value);
|
|
18
|
+
enr.set(AZTEC_ENR_KEY, Buffer.from(compressComponentVersions(versions)));
|
|
31
19
|
return versions;
|
|
32
20
|
}
|
|
33
21
|
|
|
@@ -37,21 +25,3 @@ export function setAztecClientVersionEnrKey(enr: SignableENR, clientVersion: str
|
|
|
37
25
|
enr.set(AZTEC_ENR_CLIENT_VERSION_KEY, Buffer.from(clientVersion));
|
|
38
26
|
}
|
|
39
27
|
}
|
|
40
|
-
|
|
41
|
-
/** Checks the given value from an ENR record against the expected versions. */
|
|
42
|
-
export function checkAztecEnrVersion(enrValue: Buffer, expectedVersions: ComponentsVersions) {
|
|
43
|
-
if (enrValue.length === XX_HASH_LEN) {
|
|
44
|
-
const expected = versionsToEnrValue(expectedVersions, true);
|
|
45
|
-
if (!Buffer.from(enrValue).equals(expected)) {
|
|
46
|
-
throw new Error(`Expected ENR version ${expected.toString('hex')} but received ${enrValue.toString('hex')}`);
|
|
47
|
-
}
|
|
48
|
-
} else {
|
|
49
|
-
const actual = Buffer.from(enrValue).toString();
|
|
50
|
-
checkCompressedComponentVersion(actual, expectedVersions);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
function versionsToEnrValue(versions: ComponentsVersions, useXxHash: boolean) {
|
|
55
|
-
const compressed = compressComponentVersions(versions);
|
|
56
|
-
return useXxHash ? toBufferBE(xxhash.h64(compressed), XX_HASH_LEN) : Buffer.from(compressed);
|
|
57
|
-
}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
export {};
|
|
2
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHJvcG9zYWxfdHhfY29sbGVjdG9yX3dvcmtlci5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vc3JjL2NsaWVudC90ZXN0L3R4X3Byb3Bvc2FsX2NvbGxlY3Rvci9wcm9wb3NhbF90eF9jb2xsZWN0b3Jfd29ya2VyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiIifQ==
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"proposal_tx_collector_worker.d.ts","sourceRoot":"","sources":["../../../../src/client/test/tx_proposal_collector/proposal_tx_collector_worker.ts"],"names":[],"mappings":""}
|
|
@@ -1,318 +0,0 @@
|
|
|
1
|
-
import { MockL2BlockSource } from '@aztec/archiver/test';
|
|
2
|
-
import { SecretValue } from '@aztec/foundation/config';
|
|
3
|
-
import { createLogger } from '@aztec/foundation/log';
|
|
4
|
-
import { sleep } from '@aztec/foundation/sleep';
|
|
5
|
-
import { DateProvider, Timer, executeTimeout } from '@aztec/foundation/timer';
|
|
6
|
-
import { openTmpStore } from '@aztec/kv-store/lmdb-v2';
|
|
7
|
-
import { GasFees } from '@aztec/stdlib/gas';
|
|
8
|
-
import { getTelemetryClient } from '@aztec/telemetry-client';
|
|
9
|
-
import { peerIdFromString } from '@libp2p/peer-id';
|
|
10
|
-
import { BatchTxRequesterCollector, SendBatchRequestCollector } from '../../../services/index.js';
|
|
11
|
-
import { RateLimitStatus } from '../../../services/reqresp/rate-limiter/rate_limiter.js';
|
|
12
|
-
import { RequestTracker } from '../../../services/tx_collection/request_tracker.js';
|
|
13
|
-
import { AlwaysTrueCircuitVerifier, BENCHMARK_CONSTANTS, InMemoryAttestationPool, InMemoryTxPool, UNLIMITED_RATE_LIMIT_QUOTA, calculateInternalTimeout, createMockEpochCache, createMockWorldStateSynchronizer } from '../../../test-helpers/index.js';
|
|
14
|
-
import { createP2PClient } from '../../index.js';
|
|
15
|
-
import { deserializeBlockProposal, deserializeTx, deserializeTxHash } from './proposal_tx_collector_worker_protocol.js';
|
|
16
|
-
let client;
|
|
17
|
-
let txPool;
|
|
18
|
-
let attestationPool;
|
|
19
|
-
let logger = createLogger('p2p:proposal-bench');
|
|
20
|
-
let kvStore;
|
|
21
|
-
let ipcDisconnected = false;
|
|
22
|
-
function ensureClient() {
|
|
23
|
-
if (!client || !txPool) {
|
|
24
|
-
throw new Error('Worker client not started');
|
|
25
|
-
}
|
|
26
|
-
return client;
|
|
27
|
-
}
|
|
28
|
-
function isIpcDisconnectError(err) {
|
|
29
|
-
const code = err?.code;
|
|
30
|
-
return code === 'EPIPE' || code === 'ERR_IPC_CHANNEL_CLOSED';
|
|
31
|
-
}
|
|
32
|
-
function sendMessage(message) {
|
|
33
|
-
const send = process.send;
|
|
34
|
-
if (!send || !process.connected || ipcDisconnected) {
|
|
35
|
-
return Promise.resolve();
|
|
36
|
-
}
|
|
37
|
-
return new Promise((resolve)=>{
|
|
38
|
-
const fallbackTimeout = setTimeout(()=>resolve(), 2000);
|
|
39
|
-
try {
|
|
40
|
-
send.call(process, message, undefined, undefined, (err)=>{
|
|
41
|
-
clearTimeout(fallbackTimeout);
|
|
42
|
-
if (!err) {
|
|
43
|
-
resolve();
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
if (isIpcDisconnectError(err)) {
|
|
47
|
-
ipcDisconnected = true;
|
|
48
|
-
resolve();
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
logger.warn('Failed to send IPC message', {
|
|
52
|
-
error: err?.message ?? String(err)
|
|
53
|
-
});
|
|
54
|
-
resolve();
|
|
55
|
-
});
|
|
56
|
-
} catch (err) {
|
|
57
|
-
clearTimeout(fallbackTimeout);
|
|
58
|
-
if (isIpcDisconnectError(err)) {
|
|
59
|
-
ipcDisconnected = true;
|
|
60
|
-
resolve();
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
logger.warn('Failed to send IPC message', {
|
|
64
|
-
error: err?.message ?? String(err)
|
|
65
|
-
});
|
|
66
|
-
resolve();
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
async function startClient(config, clientIndex) {
|
|
71
|
-
txPool = new InMemoryTxPool();
|
|
72
|
-
attestationPool = new InMemoryAttestationPool();
|
|
73
|
-
const epochCache = createMockEpochCache();
|
|
74
|
-
const worldState = createMockWorldStateSynchronizer();
|
|
75
|
-
const l2BlockSource = new MockL2BlockSource();
|
|
76
|
-
const proofVerifier = new AlwaysTrueCircuitVerifier();
|
|
77
|
-
kvStore = await openTmpStore(`proposal-bench-${clientIndex}`, true, BENCHMARK_CONSTANTS.KV_STORE_MAP_SIZE_KB);
|
|
78
|
-
logger = createLogger(`p2p:proposal-bench:${clientIndex}`);
|
|
79
|
-
const telemetry = getTelemetryClient();
|
|
80
|
-
const deps = {
|
|
81
|
-
txPool,
|
|
82
|
-
attestationPool,
|
|
83
|
-
store: kvStore,
|
|
84
|
-
logger
|
|
85
|
-
};
|
|
86
|
-
client = await createP2PClient(config, l2BlockSource, proofVerifier, worldState, epochCache, {
|
|
87
|
-
getCurrentMinFees: ()=>Promise.resolve(GasFees.empty())
|
|
88
|
-
}, 'proposal-tx-collector-bench-worker', new DateProvider(), telemetry, deps);
|
|
89
|
-
await client.start();
|
|
90
|
-
installUnlimitedRateLimits();
|
|
91
|
-
for(let i = 0; i < 120; i++){
|
|
92
|
-
if (client.isReady()) {
|
|
93
|
-
return;
|
|
94
|
-
}
|
|
95
|
-
await sleep(500);
|
|
96
|
-
}
|
|
97
|
-
throw new Error('Timed out waiting for P2P client readiness');
|
|
98
|
-
}
|
|
99
|
-
function installSamplerOverrides(peerList) {
|
|
100
|
-
const reqResp = ensureClient().p2pService.reqresp;
|
|
101
|
-
const sampler = reqResp.connectionSampler;
|
|
102
|
-
sampler.getPeerListSortedByConnectionCountAsc = (excluding)=>{
|
|
103
|
-
if (!excluding || excluding.size === 0) {
|
|
104
|
-
return peerList;
|
|
105
|
-
}
|
|
106
|
-
return peerList.filter((peerId)=>!excluding.has(peerId.toString()));
|
|
107
|
-
};
|
|
108
|
-
sampler.samplePeersBatch = (numberToSample, excluding)=>{
|
|
109
|
-
const filtered = peerList.filter((peerId)=>!excluding?.has(peerId.toString()));
|
|
110
|
-
return filtered.slice(0, Math.min(numberToSample, filtered.length));
|
|
111
|
-
};
|
|
112
|
-
sampler.getPeer = (excluding)=>{
|
|
113
|
-
const filtered = peerList.filter((peerId)=>!excluding?.has(peerId.toString()));
|
|
114
|
-
return filtered[0];
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
|
-
function installUnlimitedRateLimits() {
|
|
118
|
-
const reqResp = ensureClient().p2pService.reqresp;
|
|
119
|
-
const rateLimiter = reqResp.rateLimiter;
|
|
120
|
-
rateLimiter.getRateLimits = ()=>UNLIMITED_RATE_LIMIT_QUOTA;
|
|
121
|
-
rateLimiter.allow = ()=>RateLimitStatus.Allowed;
|
|
122
|
-
}
|
|
123
|
-
async function runCollector(cmd) {
|
|
124
|
-
const { collectorType, txHashes, blockProposal, pinnedPeerId, peerIds, timeoutMs } = cmd;
|
|
125
|
-
const reqResp = ensureClient().p2pService.reqresp;
|
|
126
|
-
const peerList = peerIds.map((peerId)=>peerIdFromString(peerId));
|
|
127
|
-
installSamplerOverrides(peerList);
|
|
128
|
-
installUnlimitedRateLimits();
|
|
129
|
-
const p2pService = {
|
|
130
|
-
reqResp,
|
|
131
|
-
connectionSampler: {
|
|
132
|
-
getPeerListSortedByConnectionCountAsc: ()=>peerList
|
|
133
|
-
},
|
|
134
|
-
txValidatorConfig: {
|
|
135
|
-
l1ChainId: 1,
|
|
136
|
-
rollupVersion: 1,
|
|
137
|
-
proofVerifier: {
|
|
138
|
-
verifyProof: ()=>Promise.resolve({
|
|
139
|
-
valid: true,
|
|
140
|
-
durationMs: 0,
|
|
141
|
-
totalDurationMs: 0
|
|
142
|
-
}),
|
|
143
|
-
stop: ()=>Promise.resolve()
|
|
144
|
-
}
|
|
145
|
-
},
|
|
146
|
-
peerScoring: {
|
|
147
|
-
penalizePeer: (_peerId, _penalty)=>{}
|
|
148
|
-
}
|
|
149
|
-
};
|
|
150
|
-
const parsedTxHashes = txHashes.map(deserializeTxHash);
|
|
151
|
-
const parsedProposal = deserializeBlockProposal(blockProposal);
|
|
152
|
-
const pinnedPeer = pinnedPeerId ? peerIdFromString(pinnedPeerId) : undefined;
|
|
153
|
-
const timer = new Timer();
|
|
154
|
-
let fetchedCount = 0;
|
|
155
|
-
const internalTimeoutMs = calculateInternalTimeout(timeoutMs);
|
|
156
|
-
const noopTxValidator = {
|
|
157
|
-
validateRequestedTx: (_tx)=>Promise.resolve({
|
|
158
|
-
result: 'valid'
|
|
159
|
-
}),
|
|
160
|
-
validateRequestedTxs: (txs)=>Promise.resolve(txs.map(()=>({
|
|
161
|
-
result: 'valid'
|
|
162
|
-
})))
|
|
163
|
-
};
|
|
164
|
-
try {
|
|
165
|
-
if (collectorType === 'batch-requester') {
|
|
166
|
-
const collector = new BatchTxRequesterCollector(p2pService, logger, new DateProvider(), noopTxValidator);
|
|
167
|
-
const fetched = await executeTimeout((_signal)=>collector.collectTxs(RequestTracker.create(parsedTxHashes, new Date(Date.now() + internalTimeoutMs)), parsedProposal, pinnedPeer), timeoutMs, ()=>new Error(`Collector timed out after ${timeoutMs}ms`));
|
|
168
|
-
fetchedCount = fetched.length;
|
|
169
|
-
} else {
|
|
170
|
-
const collector = new SendBatchRequestCollector(p2pService, BENCHMARK_CONSTANTS.FIXED_MAX_PEERS, BENCHMARK_CONSTANTS.FIXED_MAX_RETRY_ATTEMPTS);
|
|
171
|
-
const fetched = await executeTimeout((_signal)=>collector.collectTxs(RequestTracker.create(parsedTxHashes, new Date(Date.now() + internalTimeoutMs)), parsedProposal, pinnedPeer), timeoutMs, ()=>new Error(`Collector timed out after ${timeoutMs}ms`));
|
|
172
|
-
fetchedCount = fetched.length;
|
|
173
|
-
}
|
|
174
|
-
} catch (err) {
|
|
175
|
-
logger.warn(`Collector error: ${err?.message ?? String(err)}`);
|
|
176
|
-
}
|
|
177
|
-
return {
|
|
178
|
-
durationMs: timer.ms(),
|
|
179
|
-
fetchedCount
|
|
180
|
-
};
|
|
181
|
-
}
|
|
182
|
-
async function stopClient() {
|
|
183
|
-
if (!client) {
|
|
184
|
-
return;
|
|
185
|
-
}
|
|
186
|
-
await client.stop();
|
|
187
|
-
if (kvStore?.close) {
|
|
188
|
-
await kvStore.close();
|
|
189
|
-
}
|
|
190
|
-
client = undefined;
|
|
191
|
-
txPool = undefined;
|
|
192
|
-
attestationPool = undefined;
|
|
193
|
-
}
|
|
194
|
-
function gracefulExit(code = 0) {
|
|
195
|
-
try {
|
|
196
|
-
if (process.connected) {
|
|
197
|
-
process.disconnect();
|
|
198
|
-
}
|
|
199
|
-
} catch {
|
|
200
|
-
// IPC channel already closed
|
|
201
|
-
}
|
|
202
|
-
setTimeout(()=>process.exit(code), 5000).unref();
|
|
203
|
-
}
|
|
204
|
-
process.on('disconnect', ()=>{
|
|
205
|
-
ipcDisconnected = true;
|
|
206
|
-
void stopClient();
|
|
207
|
-
});
|
|
208
|
-
process.on('error', (err)=>{
|
|
209
|
-
if (isIpcDisconnectError(err)) {
|
|
210
|
-
ipcDisconnected = true;
|
|
211
|
-
return;
|
|
212
|
-
}
|
|
213
|
-
logger.warn('Worker process error', {
|
|
214
|
-
error: err?.message ?? String(err)
|
|
215
|
-
});
|
|
216
|
-
});
|
|
217
|
-
process.on('message', (msg)=>{
|
|
218
|
-
void (async ()=>{
|
|
219
|
-
if (!msg || typeof msg !== 'object') {
|
|
220
|
-
return;
|
|
221
|
-
}
|
|
222
|
-
const requestId = msg.requestId;
|
|
223
|
-
try {
|
|
224
|
-
switch(msg.type){
|
|
225
|
-
case 'START':
|
|
226
|
-
{
|
|
227
|
-
const rawConfig = msg.config;
|
|
228
|
-
const config = {
|
|
229
|
-
...rawConfig,
|
|
230
|
-
peerIdPrivateKey: rawConfig.peerIdPrivateKey ? new SecretValue(rawConfig.peerIdPrivateKey) : undefined
|
|
231
|
-
};
|
|
232
|
-
await startClient(config, msg.clientIndex);
|
|
233
|
-
const peerId = ensureClient().p2pService.node.peerId.toString();
|
|
234
|
-
await sendMessage({
|
|
235
|
-
type: 'READY',
|
|
236
|
-
requestId,
|
|
237
|
-
peerId
|
|
238
|
-
});
|
|
239
|
-
break;
|
|
240
|
-
}
|
|
241
|
-
case 'SET_TXS':
|
|
242
|
-
{
|
|
243
|
-
if (!txPool) {
|
|
244
|
-
throw new Error('Tx pool not initialized');
|
|
245
|
-
}
|
|
246
|
-
const txs = msg.txs.map(deserializeTx);
|
|
247
|
-
const count = msg.mode === 'append' ? txPool.appendTxs(txs) : txPool.setTxs(txs);
|
|
248
|
-
await sendMessage({
|
|
249
|
-
type: 'TXS_SET',
|
|
250
|
-
requestId,
|
|
251
|
-
count
|
|
252
|
-
});
|
|
253
|
-
break;
|
|
254
|
-
}
|
|
255
|
-
case 'SET_BLOCK_PROPOSAL':
|
|
256
|
-
{
|
|
257
|
-
if (!attestationPool) {
|
|
258
|
-
throw new Error('Attestation pool not initialized');
|
|
259
|
-
}
|
|
260
|
-
const proposal = deserializeBlockProposal(msg.blockProposal);
|
|
261
|
-
await attestationPool.tryAddBlockProposal(proposal);
|
|
262
|
-
await sendMessage({
|
|
263
|
-
type: 'BLOCK_PROPOSAL_SET',
|
|
264
|
-
requestId,
|
|
265
|
-
archiveRoot: proposal.archive.toString()
|
|
266
|
-
});
|
|
267
|
-
break;
|
|
268
|
-
}
|
|
269
|
-
case 'RUN_COLLECTOR':
|
|
270
|
-
{
|
|
271
|
-
const { durationMs, fetchedCount } = await runCollector(msg);
|
|
272
|
-
await sendMessage({
|
|
273
|
-
type: 'COLLECTOR_RESULT',
|
|
274
|
-
requestId,
|
|
275
|
-
durationMs,
|
|
276
|
-
fetchedCount
|
|
277
|
-
});
|
|
278
|
-
break;
|
|
279
|
-
}
|
|
280
|
-
case 'GET_PEER_COUNT':
|
|
281
|
-
{
|
|
282
|
-
const peers = await ensureClient().getPeers();
|
|
283
|
-
await sendMessage({
|
|
284
|
-
type: 'PEER_COUNT',
|
|
285
|
-
requestId,
|
|
286
|
-
count: peers.length
|
|
287
|
-
});
|
|
288
|
-
break;
|
|
289
|
-
}
|
|
290
|
-
case 'STOP':
|
|
291
|
-
{
|
|
292
|
-
await stopClient();
|
|
293
|
-
await sendMessage({
|
|
294
|
-
type: 'STOPPED',
|
|
295
|
-
requestId
|
|
296
|
-
});
|
|
297
|
-
gracefulExit(0);
|
|
298
|
-
break;
|
|
299
|
-
}
|
|
300
|
-
default:
|
|
301
|
-
{
|
|
302
|
-
const _exhaustive = msg;
|
|
303
|
-
throw new Error(`Unknown command: ${msg.type}`);
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
} catch (err) {
|
|
307
|
-
await sendMessage({
|
|
308
|
-
type: 'ERROR',
|
|
309
|
-
requestId,
|
|
310
|
-
error: err?.message ?? String(err)
|
|
311
|
-
});
|
|
312
|
-
if (msg.type === 'START') {
|
|
313
|
-
await stopClient();
|
|
314
|
-
gracefulExit(1);
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
})();
|
|
318
|
-
});
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import { BlockProposal } from '@aztec/stdlib/p2p';
|
|
2
|
-
import { Tx, TxHash } from '@aztec/stdlib/tx';
|
|
3
|
-
import type { P2PConfig } from '../../../config.js';
|
|
4
|
-
export type SerializedP2PConfig = Omit<P2PConfig, 'peerIdPrivateKey'> & {
|
|
5
|
-
peerIdPrivateKey?: string;
|
|
6
|
-
};
|
|
7
|
-
export type CollectorType = 'batch-requester' | 'send-batch-request';
|
|
8
|
-
export type WorkerCommand = {
|
|
9
|
-
type: 'START';
|
|
10
|
-
requestId: string;
|
|
11
|
-
clientIndex: number;
|
|
12
|
-
config: SerializedP2PConfig;
|
|
13
|
-
} | {
|
|
14
|
-
type: 'SET_TXS';
|
|
15
|
-
requestId: string;
|
|
16
|
-
txs: string[];
|
|
17
|
-
mode?: 'replace' | 'append';
|
|
18
|
-
} | {
|
|
19
|
-
type: 'SET_BLOCK_PROPOSAL';
|
|
20
|
-
requestId: string;
|
|
21
|
-
blockProposal: string;
|
|
22
|
-
} | {
|
|
23
|
-
type: 'RUN_COLLECTOR';
|
|
24
|
-
requestId: string;
|
|
25
|
-
collectorType: CollectorType;
|
|
26
|
-
txHashes: string[];
|
|
27
|
-
blockProposal: string;
|
|
28
|
-
pinnedPeerId?: string;
|
|
29
|
-
peerIds: string[];
|
|
30
|
-
timeoutMs: number;
|
|
31
|
-
} | {
|
|
32
|
-
type: 'GET_PEER_COUNT';
|
|
33
|
-
requestId: string;
|
|
34
|
-
} | {
|
|
35
|
-
type: 'STOP';
|
|
36
|
-
requestId: string;
|
|
37
|
-
};
|
|
38
|
-
export type WorkerResponse = {
|
|
39
|
-
type: 'READY';
|
|
40
|
-
requestId: string;
|
|
41
|
-
peerId: string;
|
|
42
|
-
} | {
|
|
43
|
-
type: 'TXS_SET';
|
|
44
|
-
requestId: string;
|
|
45
|
-
count: number;
|
|
46
|
-
} | {
|
|
47
|
-
type: 'BLOCK_PROPOSAL_SET';
|
|
48
|
-
requestId: string;
|
|
49
|
-
archiveRoot: string;
|
|
50
|
-
} | {
|
|
51
|
-
type: 'COLLECTOR_RESULT';
|
|
52
|
-
requestId: string;
|
|
53
|
-
durationMs: number;
|
|
54
|
-
fetchedCount: number;
|
|
55
|
-
} | {
|
|
56
|
-
type: 'PEER_COUNT';
|
|
57
|
-
requestId: string;
|
|
58
|
-
count: number;
|
|
59
|
-
} | {
|
|
60
|
-
type: 'STOPPED';
|
|
61
|
-
requestId: string;
|
|
62
|
-
} | {
|
|
63
|
-
type: 'ERROR';
|
|
64
|
-
requestId: string;
|
|
65
|
-
error: string;
|
|
66
|
-
};
|
|
67
|
-
export declare const serializeTx: (tx: Tx) => string;
|
|
68
|
-
export declare const deserializeTx: (hex: string) => Tx;
|
|
69
|
-
export declare const serializeTxHash: (txHash: TxHash) => `0x${string}`;
|
|
70
|
-
export declare const deserializeTxHash: (hex: string) => TxHash;
|
|
71
|
-
export declare const serializeBlockProposal: (proposal: BlockProposal) => string;
|
|
72
|
-
export declare const deserializeBlockProposal: (hex: string) => BlockProposal;
|
|
73
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHJvcG9zYWxfdHhfY29sbGVj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lBQUMsWUFBWSxFQUFFLE1BQU0sQ0FBQTtDQUFFLEdBQ3pGO0lBQUUsSUFBSSxFQUFFLFlBQVksQ0FBQztJQUFDLFNBQVMsRUFBRSxNQUFNLENBQUM7SUFBQyxLQUFLLEVBQUUsTUFBTSxDQUFBO0NBQUUsR0FDeEQ7SUFBRSxJQUFJLEVBQUUsU0FBUyxDQUFDO0lBQUMsU0FBUyxFQUFFLE1BQU0sQ0FBQTtDQUFFLEdBQ3RDO0lBQUUsSUFBSSxFQUFFLE9BQU8sQ0FBQztJQUFDLFNBQVMsRUFBRSxNQUFNLENBQUM7SUFBQyxLQUFLLEVBQUUsTUFBTSxDQUFBO0NBQUUsQ0FBQztBQUV4RCxlQUFPLE1BQU0sV0FBVyxvQkFBNEMsQ0FBQztBQUNyRSxlQUFPLE1BQU0sYUFBYSxxQkFBMEQsQ0FBQztBQUVyRixlQUFPLE1BQU0sZUFBZSxtQ0FBd0MsQ0FBQztBQUNyRSxlQUFPLE1BQU0saUJBQWlCLHlCQUEwQyxDQUFDO0FBRXpFLGVBQU8sTUFBTSxzQkFBc0IscUNBQW1FLENBQUM7QUFDdkcsZUFBTyxNQUFNLHdCQUF3QixnQ0FBcUUsQ0FBQyJ9
|
package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker_protocol.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"proposal_tx_collector_worker_protocol.d.ts","sourceRoot":"","sources":["../../../../src/client/test/tx_proposal_collector/proposal_tx_collector_worker_protocol.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE9C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEpD,MAAM,MAAM,mBAAmB,GAAG,IAAI,CAAC,SAAS,EAAE,kBAAkB,CAAC,GAAG;IAAE,gBAAg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AM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,GACtE;IAAE,IAAI,EAAE,kBAAkB,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAE,GACzF;IAAE,IAAI,EAAE,YAAY,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GACxD;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,GACtC;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAExD,eAAO,MAAM,WAAW,oBAA4C,CAAC;AACrE,eAAO,MAAM,aAAa,qBAA0D,CAAC;AAErF,eAAO,MAAM,eAAe,mCAAwC,CAAC;AACrE,eAAO,MAAM,iBAAiB,yBAA0C,CAAC;AAEzE,eAAO,MAAM,sBAAsB,qCAAmE,CAAC;AACvG,eAAO,MAAM,wBAAwB,gCAAqE,CAAC"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { BlockProposal } from '@aztec/stdlib/p2p';
|
|
2
|
-
import { Tx, TxHash } from '@aztec/stdlib/tx';
|
|
3
|
-
export const serializeTx = (tx)=>tx.toBuffer().toString('hex');
|
|
4
|
-
export const deserializeTx = (hex)=>Tx.fromBuffer(Buffer.from(hex, 'hex'));
|
|
5
|
-
export const serializeTxHash = (txHash)=>txHash.toString();
|
|
6
|
-
export const deserializeTxHash = (hex)=>TxHash.fromString(hex);
|
|
7
|
-
export const serializeBlockProposal = (proposal)=>proposal.toBuffer().toString('hex');
|
|
8
|
-
export const deserializeBlockProposal = (hex)=>BlockProposal.fromBuffer(Buffer.from(hex, 'hex'));
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import type { PeerId } from '@libp2p/interface';
|
|
2
|
-
import type { ConnectionSampler } from './connection_sampler.js';
|
|
3
|
-
/**
|
|
4
|
-
* Manages batches of peers for parallel request processing.
|
|
5
|
-
* Tracks active peers and provides deterministic peer assignment for requests.
|
|
6
|
-
*
|
|
7
|
-
* Example with 3 peers and 10 requests:
|
|
8
|
-
*
|
|
9
|
-
* Peers: [P1] [P2] [P3]
|
|
10
|
-
* ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
|
|
11
|
-
* Requests: 0,1,2,9 | 3,4,5 | 6,7,8
|
|
12
|
-
*
|
|
13
|
-
* Each peer handles a bucket of consecutive requests.
|
|
14
|
-
* If a peer fails, it is replaced while maintaining the same bucket.
|
|
15
|
-
*/
|
|
16
|
-
export declare class BatchConnectionSampler {
|
|
17
|
-
private readonly connectionSampler;
|
|
18
|
-
private readonly logger;
|
|
19
|
-
private readonly batch;
|
|
20
|
-
private readonly requestsPerPeer;
|
|
21
|
-
/** Tracks peer-index combinations that returned empty/invalid responses */
|
|
22
|
-
private readonly failedPeerIndices;
|
|
23
|
-
constructor(connectionSampler: ConnectionSampler, batchSize: number, maxPeers: number, exclude?: PeerId[], logger?: import("@aztec/foundation/log").Logger);
|
|
24
|
-
/**
|
|
25
|
-
* Gets the peer responsible for handling a specific request index.
|
|
26
|
-
* If the primary peer has previously failed for this index, tries other peers.
|
|
27
|
-
* If all batch peers have failed, attempts to sample a new peer.
|
|
28
|
-
*
|
|
29
|
-
* @param index - The request index
|
|
30
|
-
* @returns The peer assigned to handle this request, or undefined if no peer available
|
|
31
|
-
*/
|
|
32
|
-
getPeerForRequest(index: number): PeerId | undefined;
|
|
33
|
-
/**
|
|
34
|
-
* Attempts to sample a new peer that isn't already in the batch.
|
|
35
|
-
* If successful, adds the peer to the batch.
|
|
36
|
-
*
|
|
37
|
-
* @returns The new peer if one was sampled, undefined otherwise
|
|
38
|
-
*/
|
|
39
|
-
private sampleNewPeer;
|
|
40
|
-
/**
|
|
41
|
-
* Marks that a peer returned an empty/invalid response for a specific request index.
|
|
42
|
-
* The peer will not be assigned this index again.
|
|
43
|
-
*
|
|
44
|
-
* @param peerId - The peer that failed
|
|
45
|
-
* @param index - The request index that failed
|
|
46
|
-
*/
|
|
47
|
-
markPeerFailedForIndex(peerId: PeerId, index: number): void;
|
|
48
|
-
/**
|
|
49
|
-
* Removes a peer and replaces it with a new one, maintaining the same position
|
|
50
|
-
* in the batch array to keep request distribution consistent
|
|
51
|
-
*
|
|
52
|
-
* @param peerId - The peer to remove and replace
|
|
53
|
-
*/
|
|
54
|
-
removePeerAndReplace(peerId: PeerId): void;
|
|
55
|
-
/**
|
|
56
|
-
* Gets the number of active peers
|
|
57
|
-
*/
|
|
58
|
-
get activePeerCount(): number;
|
|
59
|
-
/**
|
|
60
|
-
* Gets the number of requests each peer is assigned to handle
|
|
61
|
-
*/
|
|
62
|
-
get requestsPerBucket(): number;
|
|
63
|
-
}
|
|
64
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYmF0Y2hfY29ubmVjdGlvbl9zYW1wbGVyLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi9zcmMvc2VydmljZXMvcmVxcmVzcC9jb25uZWN0aW9uLXNhbXBsZXIvYmF0Y2hfY29ubmVjdGlvbl9zYW1wbGVyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUVBLE9BQU8sS0FBSyxFQUFFLE1BQU0sRUFBRSxNQUFNLG1CQUFtQixDQUFDO0FBRWhELE9BQU8sS0FBSyxFQUFFLGlCQUFpQixFQUFFLE1BQU0seUJBQXlCLENBQUM7QUFFakU7Ozs7Ozs7Ozs7OztHQVlHO0FBQ0gscUJBQWEsc0JBQXNCO0lBTy9CLE9BQU8sQ0FBQyxRQUFRLENBQUMsaUJBQWlCO0lBSWxDLE9BQU8sQ0FBQyxRQUFRLENBQUMsTUFBTTtJQVZ6QixPQUFPLENBQUMsUUFBUSxDQUFDLEtBQUssQ0FBZ0I7SUFDdEMsT0FBTyxDQUFDLFFBQVEsQ0FBQyxlQUFlLENBQVM7SUFDekMsMkVBQTJFO0lBQzNFLE9BQU8sQ0FBQyxRQUFRLENBQUMsaUJBQWlCLENBQXVDO0lBRXpFLFlBQ21CLGlCQUFpQixFQUFFLGlCQUFpQixFQUNyRCxTQUFTLEVBQUUsTUFBTSxFQUNqQixRQUFRLEVBQUUsTUFBTSxFQUNoQixPQUFPLENBQUMsRUFBRSxNQUFNLEVBQUUsRUFDRCxNQUFNLHlDQUF1RCxFQWUvRTtJQUVEOzs7Ozs7O09BT0c7SUFDSCxpQkFBaUIsQ0FBQyxLQUFLLEVBQUUsTUFBTSxHQUFHLE1BQU0sR0FBRyxTQUFTLENBMkJuRDtJQUVEOzs7OztPQUtHO0lBQ0gsT0FBTyxDQUFDLGFBQWE7SUFjckI7Ozs7OztPQU1HO0lBQ0gsc0JBQXNCLENBQUMsTUFBTSxFQUFFLE1BQU0sRUFBRSxLQUFLLEVBQUUsTUFBTSxHQUFHLElBQUksQ0FTMUQ7SUFFRDs7Ozs7T0FLRztJQUNILG9CQUFvQixDQUFDLE1BQU0sRUFBRSxNQUFNLEdBQUcsSUFBSSxDQWlCekM7SUFFRDs7T0FFRztJQUNILElBQUksZUFBZSxJQUFJLE1BQU0sQ0FFNUI7SUFFRDs7T0FFRztJQUNILElBQUksaUJBQWlCLElBQUksTUFBTSxDQUU5QjtDQUNGIn0=
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"batch_connection_sampler.d.ts","sourceRoot":"","sources":["../../../../src/services/reqresp/connection-sampler/batch_connection_sampler.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAEjE;;;;;;;;;;;;GAYG;AACH,qBAAa,sBAAsB;IAO/B,OAAO,CAAC,QAAQ,CAAC,iBAAiB;IAIlC,OAAO,CAAC,QAAQ,CAAC,MAAM;IAVzB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAgB;IACtC,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAS;IACzC,2EAA2E;IAC3E,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAuC;IAEzE,YACmB,iBAAiB,EAAE,iBAAiB,EACrD,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE,MAAM,EAAE,EACD,MAAM,yCAAuD,EAe/E;IAED;;;;;;;OAOG;IACH,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CA2BnD;IAED;;;;;OAKG;IACH,OAAO,CAAC,aAAa;IAcrB;;;;;;OAMG;IACH,sBAAsB,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAS1D;IAED;;;;;OAKG;IACH,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAiBzC;IAED;;OAEG;IACH,IAAI,eAAe,IAAI,MAAM,CAE5B;IAED;;OAEG;IACH,IAAI,iBAAiB,IAAI,MAAM,CAE9B;CACF"}
|