@aztec/p2p 0.0.1-commit.29c6b1a3 → 0.0.1-commit.2eb6648a
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 +4 -3
- package/dest/bootstrap/bootstrap.d.ts.map +1 -1
- package/dest/bootstrap/bootstrap.js +4 -4
- package/dest/client/factory.d.ts +3 -3
- package/dest/client/factory.d.ts.map +1 -1
- package/dest/client/factory.js +10 -7
- package/dest/client/interface.d.ts +9 -2
- package/dest/client/interface.d.ts.map +1 -1
- package/dest/client/p2p_client.d.ts +7 -4
- package/dest/client/p2p_client.d.ts.map +1 -1
- package/dest/client/p2p_client.js +24 -7
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.js +2 -2
- package/dest/config.d.ts +9 -3
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +3 -1
- package/dest/mem_pools/attestation_pool/attestation_pool.d.ts +94 -87
- package/dest/mem_pools/attestation_pool/attestation_pool.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/attestation_pool.js +411 -3
- package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.d.ts +2 -2
- 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 +351 -85
- package/dest/mem_pools/attestation_pool/index.d.ts +2 -3
- package/dest/mem_pools/attestation_pool/index.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/index.js +1 -2
- package/dest/mem_pools/index.d.ts +2 -2
- package/dest/mem_pools/index.d.ts.map +1 -1
- package/dest/mem_pools/index.js +1 -1
- 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 +2 -2
- package/dest/mem_pools/interface.d.ts +3 -3
- package/dest/mem_pools/interface.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/archive/index.d.ts +2 -0
- package/dest/mem_pools/tx_pool_v2/archive/index.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/archive/index.js +1 -0
- package/dest/mem_pools/tx_pool_v2/archive/tx_archive.d.ts +43 -0
- package/dest/mem_pools/tx_pool_v2/archive/tx_archive.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/archive/tx_archive.js +103 -0
- package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.d.ts +47 -0
- package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.js +119 -0
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.d.ts +17 -0
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.js +90 -0
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.d.ts +19 -0
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.js +89 -0
- package/dest/mem_pools/tx_pool_v2/eviction/index.d.ts +10 -0
- package/dest/mem_pools/tx_pool_v2/eviction/index.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/eviction/index.js +11 -0
- package/dest/mem_pools/tx_pool_v2/eviction/interfaces.d.ts +131 -0
- package/dest/mem_pools/tx_pool_v2/eviction/interfaces.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/eviction/interfaces.js +17 -0
- package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.d.ts +15 -0
- package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.js +63 -0
- package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.d.ts +17 -0
- package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.js +91 -0
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.d.ts +16 -0
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.js +70 -0
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.d.ts +20 -0
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.js +63 -0
- package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.d.ts +15 -0
- package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.js +19 -0
- package/dest/mem_pools/tx_pool_v2/index.d.ts +5 -0
- package/dest/mem_pools/tx_pool_v2/index.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/index.js +4 -0
- package/dest/mem_pools/tx_pool_v2/interfaces.d.ts +197 -0
- package/dest/mem_pools/tx_pool_v2/interfaces.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/interfaces.js +6 -0
- package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts +71 -0
- package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/tx_metadata.js +95 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_bench_metrics.d.ts +26 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_bench_metrics.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_bench_metrics.js +70 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_indices.d.ts +99 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_indices.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_indices.js +332 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts +55 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2.js +156 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts +69 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.js +748 -0
- package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.d.ts +3 -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 +7 -2
- package/dest/msg_validators/tx_validator/archive_cache.d.ts +3 -3
- package/dest/msg_validators/tx_validator/archive_cache.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/archive_cache.js +1 -1
- package/dest/msg_validators/tx_validator/block_header_validator.d.ts +5 -4
- package/dest/msg_validators/tx_validator/block_header_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/block_header_validator.js +4 -3
- package/dest/msg_validators/tx_validator/data_validator.d.ts +3 -1
- package/dest/msg_validators/tx_validator/data_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/data_validator.js +4 -1
- package/dest/msg_validators/tx_validator/double_spend_validator.d.ts +3 -2
- package/dest/msg_validators/tx_validator/double_spend_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/double_spend_validator.js +3 -2
- package/dest/msg_validators/tx_validator/factory.d.ts +4 -3
- package/dest/msg_validators/tx_validator/factory.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/factory.js +12 -12
- package/dest/msg_validators/tx_validator/gas_validator.d.ts +3 -2
- package/dest/msg_validators/tx_validator/gas_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/gas_validator.js +3 -2
- package/dest/msg_validators/tx_validator/metadata_validator.d.ts +3 -2
- package/dest/msg_validators/tx_validator/metadata_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/metadata_validator.js +2 -2
- package/dest/msg_validators/tx_validator/phases_validator.d.ts +3 -2
- package/dest/msg_validators/tx_validator/phases_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/phases_validator.js +3 -3
- package/dest/msg_validators/tx_validator/size_validator.d.ts +3 -1
- package/dest/msg_validators/tx_validator/size_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/size_validator.js +4 -1
- package/dest/msg_validators/tx_validator/timestamp_validator.d.ts +3 -2
- package/dest/msg_validators/tx_validator/timestamp_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/timestamp_validator.js +2 -2
- package/dest/msg_validators/tx_validator/tx_permitted_validator.d.ts +3 -2
- package/dest/msg_validators/tx_validator/tx_permitted_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/tx_permitted_validator.js +2 -2
- package/dest/msg_validators/tx_validator/tx_proof_validator.d.ts +3 -2
- 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 -2
- package/dest/services/data_store.d.ts +1 -1
- package/dest/services/data_store.d.ts.map +1 -1
- package/dest/services/data_store.js +10 -6
- package/dest/services/discv5/discV5_service.js +1 -1
- package/dest/services/dummy_service.d.ts +6 -2
- package/dest/services/dummy_service.d.ts.map +1 -1
- package/dest/services/dummy_service.js +3 -0
- package/dest/services/index.d.ts +2 -1
- package/dest/services/index.d.ts.map +1 -1
- package/dest/services/index.js +1 -0
- package/dest/services/libp2p/instrumentation.d.ts +1 -1
- package/dest/services/libp2p/instrumentation.d.ts.map +1 -1
- package/dest/services/libp2p/instrumentation.js +14 -3
- package/dest/services/libp2p/libp2p_service.d.ts +74 -33
- package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
- package/dest/services/libp2p/libp2p_service.js +309 -238
- package/dest/services/peer-manager/metrics.d.ts +2 -2
- package/dest/services/peer-manager/metrics.d.ts.map +1 -1
- package/dest/services/peer-manager/metrics.js +20 -5
- package/dest/services/peer-manager/peer_scoring.d.ts +1 -1
- package/dest/services/peer-manager/peer_scoring.d.ts.map +1 -1
- package/dest/services/peer-manager/peer_scoring.js +8 -2
- package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts +4 -4
- 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 +9 -9
- package/dest/services/reqresp/metrics.d.ts +6 -5
- package/dest/services/reqresp/metrics.d.ts.map +1 -1
- package/dest/services/reqresp/metrics.js +17 -5
- package/dest/services/reqresp/protocols/block_txs/block_txs_handler.d.ts +6 -4
- 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 +17 -12
- package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.d.ts +19 -14
- 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 +25 -24
- package/dest/services/service.d.ts +18 -1
- package/dest/services/service.d.ts.map +1 -1
- package/dest/services/tx_collection/config.d.ts +3 -3
- package/dest/services/tx_collection/config.js +3 -3
- package/dest/services/tx_collection/fast_tx_collection.d.ts +4 -5
- package/dest/services/tx_collection/fast_tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/fast_tx_collection.js +10 -14
- package/dest/services/tx_collection/index.d.ts +1 -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 +9 -2
- package/dest/services/tx_collection/proposal_tx_collector.d.ts +12 -12
- package/dest/services/tx_collection/proposal_tx_collector.d.ts.map +1 -1
- package/dest/services/tx_collection/proposal_tx_collector.js +4 -5
- package/dest/services/tx_file_store/config.d.ts +18 -0
- package/dest/services/tx_file_store/config.d.ts.map +1 -0
- package/dest/services/tx_file_store/config.js +26 -0
- package/dest/services/tx_file_store/index.d.ts +4 -0
- package/dest/services/tx_file_store/index.d.ts.map +1 -0
- package/dest/services/tx_file_store/index.js +3 -0
- package/dest/services/tx_file_store/instrumentation.d.ts +15 -0
- package/dest/services/tx_file_store/instrumentation.d.ts.map +1 -0
- package/dest/services/tx_file_store/instrumentation.js +29 -0
- package/dest/services/tx_file_store/tx_file_store.d.ts +47 -0
- package/dest/services/tx_file_store/tx_file_store.d.ts.map +1 -0
- package/dest/services/tx_file_store/tx_file_store.js +149 -0
- package/dest/services/tx_provider_instrumentation.d.ts +1 -1
- package/dest/services/tx_provider_instrumentation.d.ts.map +1 -1
- package/dest/services/tx_provider_instrumentation.js +5 -5
- package/dest/test-helpers/testbench-utils.d.ts +12 -16
- package/dest/test-helpers/testbench-utils.d.ts.map +1 -1
- package/dest/test-helpers/testbench-utils.js +34 -31
- package/dest/testbench/p2p_client_testbench_worker.js +2 -2
- package/package.json +14 -14
- package/src/bootstrap/bootstrap.ts +7 -4
- package/src/client/factory.ts +12 -13
- package/src/client/interface.ts +13 -1
- package/src/client/p2p_client.ts +32 -8
- package/src/client/test/tx_proposal_collector/README.md +4 -4
- package/src/client/test/tx_proposal_collector/proposal_tx_collector_worker.ts +2 -2
- package/src/config.ts +8 -1
- package/src/mem_pools/attestation_pool/attestation_pool.ts +444 -90
- package/src/mem_pools/attestation_pool/attestation_pool_test_suite.ts +436 -100
- package/src/mem_pools/attestation_pool/index.ts +9 -2
- package/src/mem_pools/index.ts +1 -1
- package/src/mem_pools/instrumentation.ts +2 -1
- package/src/mem_pools/interface.ts +2 -2
- package/src/mem_pools/tx_pool_v2/README.md +209 -0
- package/src/mem_pools/tx_pool_v2/archive/index.ts +1 -0
- package/src/mem_pools/tx_pool_v2/archive/tx_archive.ts +120 -0
- package/src/mem_pools/tx_pool_v2/eviction/eviction_manager.ts +147 -0
- package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.ts +118 -0
- package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.ts +111 -0
- package/src/mem_pools/tx_pool_v2/eviction/index.ts +23 -0
- package/src/mem_pools/tx_pool_v2/eviction/interfaces.ts +164 -0
- package/src/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.ts +74 -0
- package/src/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.ts +101 -0
- package/src/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.ts +86 -0
- package/src/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.ts +72 -0
- package/src/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.ts +31 -0
- package/src/mem_pools/tx_pool_v2/index.ts +11 -0
- package/src/mem_pools/tx_pool_v2/interfaces.ts +227 -0
- package/src/mem_pools/tx_pool_v2/tx_metadata.ts +161 -0
- package/src/mem_pools/tx_pool_v2/tx_pool_bench_metrics.ts +77 -0
- package/src/mem_pools/tx_pool_v2/tx_pool_indices.ts +417 -0
- package/src/mem_pools/tx_pool_v2/tx_pool_v2.ts +212 -0
- package/src/mem_pools/tx_pool_v2/tx_pool_v2_impl.ts +882 -0
- package/src/msg_validators/attestation_validator/fisherman_attestation_validator.ts +10 -4
- package/src/msg_validators/tx_validator/archive_cache.ts +3 -3
- package/src/msg_validators/tx_validator/block_header_validator.ts +7 -8
- package/src/msg_validators/tx_validator/data_validator.ts +6 -2
- package/src/msg_validators/tx_validator/double_spend_validator.ts +4 -3
- package/src/msg_validators/tx_validator/factory.ts +46 -30
- package/src/msg_validators/tx_validator/gas_validator.ts +9 -3
- package/src/msg_validators/tx_validator/metadata_validator.ts +6 -3
- package/src/msg_validators/tx_validator/phases_validator.ts +5 -3
- package/src/msg_validators/tx_validator/size_validator.ts +6 -2
- package/src/msg_validators/tx_validator/timestamp_validator.ts +6 -3
- package/src/msg_validators/tx_validator/tx_permitted_validator.ts +8 -3
- package/src/msg_validators/tx_validator/tx_proof_validator.ts +8 -3
- package/src/services/data_store.ts +10 -7
- package/src/services/discv5/discV5_service.ts +1 -1
- package/src/services/dummy_service.ts +6 -0
- package/src/services/index.ts +1 -0
- package/src/services/libp2p/instrumentation.ts +15 -2
- package/src/services/libp2p/libp2p_service.ts +324 -246
- package/src/services/peer-manager/metrics.ts +21 -4
- package/src/services/peer-manager/peer_scoring.ts +4 -1
- package/src/services/reqresp/batch-tx-requester/README.md +14 -14
- package/src/services/reqresp/batch-tx-requester/batch_tx_requester.ts +12 -12
- package/src/services/reqresp/metrics.ts +34 -9
- package/src/services/reqresp/protocols/block_txs/block_txs_handler.ts +23 -14
- package/src/services/reqresp/protocols/block_txs/block_txs_reqresp.ts +30 -24
- package/src/services/service.ts +20 -0
- package/src/services/tx_collection/config.ts +6 -6
- package/src/services/tx_collection/fast_tx_collection.ts +14 -24
- package/src/services/tx_collection/index.ts +1 -1
- package/src/services/tx_collection/instrumentation.ts +11 -2
- package/src/services/tx_collection/proposal_tx_collector.ts +12 -14
- package/src/services/tx_file_store/config.ts +43 -0
- package/src/services/tx_file_store/index.ts +3 -0
- package/src/services/tx_file_store/instrumentation.ts +36 -0
- package/src/services/tx_file_store/tx_file_store.ts +173 -0
- package/src/services/tx_provider_instrumentation.ts +11 -5
- package/src/test-helpers/testbench-utils.ts +20 -39
- package/src/testbench/p2p_client_testbench_worker.ts +2 -2
- package/dest/mem_pools/attestation_pool/kv_attestation_pool.d.ts +0 -40
- package/dest/mem_pools/attestation_pool/kv_attestation_pool.d.ts.map +0 -1
- package/dest/mem_pools/attestation_pool/kv_attestation_pool.js +0 -218
- package/dest/mem_pools/attestation_pool/memory_attestation_pool.d.ts +0 -31
- package/dest/mem_pools/attestation_pool/memory_attestation_pool.d.ts.map +0 -1
- package/dest/mem_pools/attestation_pool/memory_attestation_pool.js +0 -180
- package/src/mem_pools/attestation_pool/kv_attestation_pool.ts +0 -320
- package/src/mem_pools/attestation_pool/memory_attestation_pool.ts +0 -264
|
@@ -2,7 +2,6 @@ import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
|
2
2
|
import { times } from '@aztec/foundation/collection';
|
|
3
3
|
import { AbortError, TimeoutError } from '@aztec/foundation/error';
|
|
4
4
|
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
5
|
-
import { boundInclusive } from '@aztec/foundation/number';
|
|
6
5
|
import { promiseWithResolvers } from '@aztec/foundation/promise';
|
|
7
6
|
import { sleep } from '@aztec/foundation/sleep';
|
|
8
7
|
import { DateProvider, elapsed } from '@aztec/foundation/timer';
|
|
@@ -14,12 +13,10 @@ import type { PeerId } from '@libp2p/interface';
|
|
|
14
13
|
|
|
15
14
|
import type { BatchTxRequesterConfig } from '../reqresp/batch-tx-requester/config.js';
|
|
16
15
|
import type { BatchTxRequesterLibP2PService } from '../reqresp/batch-tx-requester/interface.js';
|
|
17
|
-
import { ReqRespSubProtocol } from '../reqresp/interface.js';
|
|
18
|
-
import { chunkTxHashesRequest } from '../reqresp/protocols/tx.js';
|
|
19
16
|
import type { TxCollectionConfig } from './config.js';
|
|
20
17
|
import {
|
|
21
18
|
BatchTxRequesterCollector,
|
|
22
|
-
type
|
|
19
|
+
type MissingTxsCollector,
|
|
23
20
|
SendBatchRequestCollector,
|
|
24
21
|
} from './proposal_tx_collector.js';
|
|
25
22
|
import type { FastCollectionRequest, FastCollectionRequestInput } from './tx_collection.js';
|
|
@@ -29,22 +26,22 @@ import type { TxSource } from './tx_source.js';
|
|
|
29
26
|
export class FastTxCollection {
|
|
30
27
|
// eslint-disable-next-line aztec-custom/no-non-primitive-in-collections
|
|
31
28
|
protected requests: Set<FastCollectionRequest> = new Set();
|
|
32
|
-
private
|
|
29
|
+
private missingTxsCollector: MissingTxsCollector;
|
|
33
30
|
|
|
34
31
|
constructor(
|
|
35
|
-
|
|
32
|
+
p2pService: BatchTxRequesterLibP2PService,
|
|
36
33
|
private nodes: TxSource[],
|
|
37
34
|
private txCollectionSink: TxCollectionSink,
|
|
38
35
|
private config: TxCollectionConfig,
|
|
39
36
|
private dateProvider: DateProvider = new DateProvider(),
|
|
40
37
|
private log: Logger = createLogger('p2p:tx_collection_service'),
|
|
41
|
-
|
|
38
|
+
missingTxsCollector?: MissingTxsCollector,
|
|
42
39
|
) {
|
|
43
40
|
const batchTxRequesterConfig = this.config as Partial<BatchTxRequesterConfig>;
|
|
44
|
-
const
|
|
45
|
-
this.
|
|
46
|
-
|
|
47
|
-
(
|
|
41
|
+
const missingTxsCollectorType = this.config.txCollectionMissingTxsCollectorType;
|
|
42
|
+
this.missingTxsCollector =
|
|
43
|
+
missingTxsCollector ??
|
|
44
|
+
(missingTxsCollectorType === 'old'
|
|
48
45
|
? new SendBatchRequestCollector(p2pService)
|
|
49
46
|
: new BatchTxRequesterCollector(p2pService, log, dateProvider, undefined, batchTxRequesterConfig));
|
|
50
47
|
}
|
|
@@ -258,8 +255,6 @@ export class FastTxCollection {
|
|
|
258
255
|
private async collectFastViaReqResp(request: FastCollectionRequest, opts: { pinnedPeer?: PeerId }) {
|
|
259
256
|
const timeoutMs = +request.deadline - this.dateProvider.now();
|
|
260
257
|
const pinnedPeer = opts.pinnedPeer;
|
|
261
|
-
const maxPeers = boundInclusive(Math.ceil(request.missingTxHashes.size / 2), 8, 32);
|
|
262
|
-
const maxRetryAttempts = 5;
|
|
263
258
|
const blockInfo = request.blockInfo;
|
|
264
259
|
const slotNumber = blockInfo.slotNumber;
|
|
265
260
|
if (timeoutMs < 100) {
|
|
@@ -279,18 +274,13 @@ export class FastTxCollection {
|
|
|
279
274
|
await this.txCollectionSink.collect(
|
|
280
275
|
async txHashes => {
|
|
281
276
|
if (request.type === 'proposal') {
|
|
282
|
-
return await this.
|
|
277
|
+
return await this.missingTxsCollector.collectTxs(txHashes, request.blockProposal, pinnedPeer, timeoutMs);
|
|
283
278
|
} else if (request.type === 'block') {
|
|
284
|
-
const
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
maxPeers,
|
|
290
|
-
maxRetryAttempts,
|
|
291
|
-
);
|
|
292
|
-
|
|
293
|
-
return txs.flat();
|
|
279
|
+
const blockTxsSource = {
|
|
280
|
+
txHashes: request.block.body.txEffects.map(e => e.txHash),
|
|
281
|
+
archive: request.block.archive.root,
|
|
282
|
+
};
|
|
283
|
+
return await this.missingTxsCollector.collectTxs(txHashes, blockTxsSource, pinnedPeer, timeoutMs);
|
|
294
284
|
} else {
|
|
295
285
|
throw new Error(`Unknown request type: ${(request as any).type}`);
|
|
296
286
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { TxCollection, type FastCollectionRequestInput } from './tx_collection.js';
|
|
2
2
|
export { type TxSource, createNodeRpcTxSources, NodeRpcTxSource } from './tx_source.js';
|
|
3
3
|
export {
|
|
4
|
-
type
|
|
4
|
+
type MissingTxsCollector,
|
|
5
5
|
BatchTxRequesterCollector,
|
|
6
6
|
SendBatchRequestCollector,
|
|
7
7
|
} from './proposal_tx_collector.js';
|
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
Attributes,
|
|
3
|
+
type Histogram,
|
|
4
|
+
Metrics,
|
|
5
|
+
type TelemetryClient,
|
|
6
|
+
type UpDownCounter,
|
|
7
|
+
createUpDownCounterWithDefault,
|
|
8
|
+
} from '@aztec/telemetry-client';
|
|
2
9
|
|
|
3
10
|
import type { CollectionMethod } from './tx_collection.js';
|
|
4
11
|
|
|
@@ -10,7 +17,9 @@ export class TxCollectionInstrumentation {
|
|
|
10
17
|
constructor(client: TelemetryClient, name: string) {
|
|
11
18
|
const meter = client.getMeter(name);
|
|
12
19
|
|
|
13
|
-
this.txsCollected = meter
|
|
20
|
+
this.txsCollected = createUpDownCounterWithDefault(meter, Metrics.TX_COLLECTOR_COUNT, {
|
|
21
|
+
[Attributes.TX_COLLECTION_METHOD]: ['fast-req-resp', 'fast-node-rpc', 'slow-req-resp', 'slow-node-rpc'],
|
|
22
|
+
});
|
|
14
23
|
|
|
15
24
|
this.collectionDurationPerTx = meter.createHistogram(Metrics.TX_COLLECTOR_DURATION_PER_TX);
|
|
16
25
|
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { Logger } from '@aztec/foundation/log';
|
|
2
2
|
import type { DateProvider } from '@aztec/foundation/timer';
|
|
3
|
-
import type { BlockProposal } from '@aztec/stdlib/p2p';
|
|
4
3
|
import type { Tx, TxHash } from '@aztec/stdlib/tx';
|
|
5
4
|
|
|
6
5
|
import type { PeerId } from '@libp2p/interface';
|
|
@@ -9,25 +8,24 @@ import { BatchTxRequester } from '../reqresp/batch-tx-requester/batch_tx_request
|
|
|
9
8
|
import type { BatchTxRequesterConfig } from '../reqresp/batch-tx-requester/config.js';
|
|
10
9
|
import type { BatchTxRequesterLibP2PService } from '../reqresp/batch-tx-requester/interface.js';
|
|
11
10
|
import type { IBatchRequestTxValidator } from '../reqresp/batch-tx-requester/tx_validator.js';
|
|
12
|
-
import { ReqRespSubProtocol } from '../reqresp/
|
|
13
|
-
import { chunkTxHashesRequest } from '../reqresp/protocols/tx.js';
|
|
11
|
+
import { type BlockTxsSource, ReqRespSubProtocol, chunkTxHashesRequest } from '../reqresp/index.js';
|
|
14
12
|
|
|
15
13
|
/**
|
|
16
|
-
* Strategy interface for collecting transactions for block
|
|
14
|
+
* Strategy interface for collecting missing transactions for a block or proposal.
|
|
17
15
|
* Allows swapping between different tx collection implementations for benchmarking.
|
|
18
16
|
*/
|
|
19
|
-
export interface
|
|
17
|
+
export interface MissingTxsCollector {
|
|
20
18
|
/**
|
|
21
|
-
* Collect transactions for a block proposal.
|
|
19
|
+
* Collect missing transactions for a block or proposal.
|
|
22
20
|
* @param txHashes - The transaction hashes to collect
|
|
23
|
-
* @param
|
|
24
|
-
* @param pinnedPeer - Optional peer
|
|
21
|
+
* @param blockTxsSource - The block or proposal containing the transactions
|
|
22
|
+
* @param pinnedPeer - Optional peer expected to have the transactions
|
|
25
23
|
* @param timeoutMs - Timeout in milliseconds
|
|
26
24
|
* @returns The collected transactions
|
|
27
25
|
*/
|
|
28
26
|
collectTxs(
|
|
29
27
|
txHashes: TxHash[],
|
|
30
|
-
|
|
28
|
+
blockTxsSource: BlockTxsSource,
|
|
31
29
|
pinnedPeer: PeerId | undefined,
|
|
32
30
|
timeoutMs: number,
|
|
33
31
|
): Promise<Tx[]>;
|
|
@@ -37,7 +35,7 @@ export interface ProposalTxCollector {
|
|
|
37
35
|
* Collects transactions using the BatchTxRequester implementation.
|
|
38
36
|
* This uses a smart/dumb peer strategy with parallel workers.
|
|
39
37
|
*/
|
|
40
|
-
export class BatchTxRequesterCollector implements
|
|
38
|
+
export class BatchTxRequesterCollector implements MissingTxsCollector {
|
|
41
39
|
constructor(
|
|
42
40
|
private p2pService: BatchTxRequesterLibP2PService,
|
|
43
41
|
private log: Logger,
|
|
@@ -48,7 +46,7 @@ export class BatchTxRequesterCollector implements ProposalTxCollector {
|
|
|
48
46
|
|
|
49
47
|
async collectTxs(
|
|
50
48
|
txHashes: TxHash[],
|
|
51
|
-
|
|
49
|
+
blockTxsSource: BlockTxsSource,
|
|
52
50
|
pinnedPeer: PeerId | undefined,
|
|
53
51
|
timeoutMs: number,
|
|
54
52
|
): Promise<Tx[]> {
|
|
@@ -61,7 +59,7 @@ export class BatchTxRequesterCollector implements ProposalTxCollector {
|
|
|
61
59
|
|
|
62
60
|
const batchRequester = new BatchTxRequester(
|
|
63
61
|
txHashes,
|
|
64
|
-
|
|
62
|
+
blockTxsSource,
|
|
65
63
|
pinnedPeer,
|
|
66
64
|
timeoutMs,
|
|
67
65
|
this.p2pService,
|
|
@@ -87,7 +85,7 @@ const DEFAULT_MAX_RETRY_ATTEMPTS = 3;
|
|
|
87
85
|
* Collects transactions using the sendBatchRequest implementation from ReqResp.
|
|
88
86
|
* This is the original implementation that balances requests across peers.
|
|
89
87
|
*/
|
|
90
|
-
export class SendBatchRequestCollector implements
|
|
88
|
+
export class SendBatchRequestCollector implements MissingTxsCollector {
|
|
91
89
|
constructor(
|
|
92
90
|
private p2pService: BatchTxRequesterLibP2PService,
|
|
93
91
|
private maxPeers: number = DEFAULT_MAX_PEERS,
|
|
@@ -96,7 +94,7 @@ export class SendBatchRequestCollector implements ProposalTxCollector {
|
|
|
96
94
|
|
|
97
95
|
async collectTxs(
|
|
98
96
|
txHashes: TxHash[],
|
|
99
|
-
|
|
97
|
+
_blockTxsSource: BlockTxsSource,
|
|
100
98
|
pinnedPeer: PeerId | undefined,
|
|
101
99
|
timeoutMs: number,
|
|
102
100
|
): Promise<Tx[]> {
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { type ConfigMappingsType, booleanConfigHelper, numberConfigHelper } from '@aztec/foundation/config';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Configuration for the TxFileStore service.
|
|
5
|
+
*/
|
|
6
|
+
export type TxFileStoreConfig = {
|
|
7
|
+
/** URL for uploading txs to file storage (s3://, gs://, file://) */
|
|
8
|
+
txFileStoreUrl?: string;
|
|
9
|
+
/** URL for downloading txs from file storage */
|
|
10
|
+
txFileStoreDownloadUrl?: string;
|
|
11
|
+
/** Max concurrent uploads */
|
|
12
|
+
txFileStoreUploadConcurrency: number;
|
|
13
|
+
/** Max queue size to prevent unbounded memory growth */
|
|
14
|
+
txFileStoreMaxQueueSize: number;
|
|
15
|
+
/** Enable tx file store upload */
|
|
16
|
+
txFileStoreEnabled: boolean;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export const txFileStoreConfigMappings: ConfigMappingsType<TxFileStoreConfig> = {
|
|
20
|
+
txFileStoreUrl: {
|
|
21
|
+
env: 'TX_FILE_STORE_URL',
|
|
22
|
+
description: 'URL for uploading txs to file storage (s3://, gs://, file://)',
|
|
23
|
+
},
|
|
24
|
+
txFileStoreDownloadUrl: {
|
|
25
|
+
env: 'TX_FILE_STORE_DOWNLOAD_URL',
|
|
26
|
+
description: 'URL for downloading txs from file storage',
|
|
27
|
+
},
|
|
28
|
+
txFileStoreUploadConcurrency: {
|
|
29
|
+
env: 'TX_FILE_STORE_UPLOAD_CONCURRENCY',
|
|
30
|
+
description: 'Maximum number of concurrent tx uploads',
|
|
31
|
+
...numberConfigHelper(10),
|
|
32
|
+
},
|
|
33
|
+
txFileStoreMaxQueueSize: {
|
|
34
|
+
env: 'TX_FILE_STORE_MAX_QUEUE_SIZE',
|
|
35
|
+
description: 'Maximum queue size for pending uploads (oldest dropped when exceeded)',
|
|
36
|
+
...numberConfigHelper(1000),
|
|
37
|
+
},
|
|
38
|
+
txFileStoreEnabled: {
|
|
39
|
+
env: 'TX_FILE_STORE_ENABLED',
|
|
40
|
+
description: 'Enable uploading transactions to file storage',
|
|
41
|
+
...booleanConfigHelper(false),
|
|
42
|
+
},
|
|
43
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { type Gauge, type Histogram, Metrics, type TelemetryClient, type UpDownCounter } from '@aztec/telemetry-client';
|
|
2
|
+
|
|
3
|
+
/** Instrumentation for the TxFileStore service. */
|
|
4
|
+
export class TxFileStoreInstrumentation {
|
|
5
|
+
private uploadsSuccess: UpDownCounter;
|
|
6
|
+
private uploadsFailed: UpDownCounter;
|
|
7
|
+
private uploadsSkipped: UpDownCounter;
|
|
8
|
+
private uploadDuration: Histogram;
|
|
9
|
+
private queueSize: Gauge;
|
|
10
|
+
|
|
11
|
+
constructor(client: TelemetryClient, name: string) {
|
|
12
|
+
const meter = client.getMeter(name);
|
|
13
|
+
this.uploadsSuccess = meter.createUpDownCounter(Metrics.TX_FILE_STORE_UPLOADS_SUCCESS);
|
|
14
|
+
this.uploadsFailed = meter.createUpDownCounter(Metrics.TX_FILE_STORE_UPLOADS_FAILED);
|
|
15
|
+
this.uploadsSkipped = meter.createUpDownCounter(Metrics.TX_FILE_STORE_UPLOADS_SKIPPED);
|
|
16
|
+
this.uploadDuration = meter.createHistogram(Metrics.TX_FILE_STORE_UPLOAD_DURATION);
|
|
17
|
+
this.queueSize = meter.createGauge(Metrics.TX_FILE_STORE_QUEUE_SIZE);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
recordUploadSuccess(durationMs: number) {
|
|
21
|
+
this.uploadsSuccess.add(1);
|
|
22
|
+
this.uploadDuration.record(durationMs);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
recordUploadFailed() {
|
|
26
|
+
this.uploadsFailed.add(1);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
recordUploadSkipped() {
|
|
30
|
+
this.uploadsSkipped.add(1);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
recordQueueSize(size: number) {
|
|
34
|
+
this.queueSize.record(size);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
2
|
+
import { RunningPromise } from '@aztec/foundation/promise';
|
|
3
|
+
import { makeBackoff, retry } from '@aztec/foundation/retry';
|
|
4
|
+
import { Timer } from '@aztec/foundation/timer';
|
|
5
|
+
import { type FileStore, createFileStore } from '@aztec/stdlib/file-store';
|
|
6
|
+
import type { Tx } from '@aztec/stdlib/tx';
|
|
7
|
+
import { type TelemetryClient, getTelemetryClient } from '@aztec/telemetry-client';
|
|
8
|
+
|
|
9
|
+
import type { TxPool, TxPoolEvents } from '../../mem_pools/tx_pool/index.js';
|
|
10
|
+
import type { TxFileStoreConfig } from './config.js';
|
|
11
|
+
import { TxFileStoreInstrumentation } from './instrumentation.js';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Uploads validated transactions to a file store as a fallback retrieval mechanism.
|
|
15
|
+
* Listens to TxPool txs-added events and uploads txs asynchronously with bounded concurrency.
|
|
16
|
+
*/
|
|
17
|
+
export class TxFileStore {
|
|
18
|
+
private uploadQueue: Tx[] = [];
|
|
19
|
+
private activeUploads = 0;
|
|
20
|
+
private readonly queueProcessor: RunningPromise;
|
|
21
|
+
private readonly handleTxsAdded: TxPoolEvents['txs-added'];
|
|
22
|
+
|
|
23
|
+
/** Recently uploaded tx hashes for deduplication. */
|
|
24
|
+
private recentUploads: Set<string> = new Set();
|
|
25
|
+
private recentUploadsOrder: string[] = [];
|
|
26
|
+
private readonly maxRecentUploads = 1000;
|
|
27
|
+
|
|
28
|
+
private constructor(
|
|
29
|
+
private readonly fileStore: FileStore,
|
|
30
|
+
private readonly txPool: TxPool,
|
|
31
|
+
private readonly config: TxFileStoreConfig,
|
|
32
|
+
private readonly instrumentation: TxFileStoreInstrumentation,
|
|
33
|
+
private readonly log: Logger,
|
|
34
|
+
) {
|
|
35
|
+
this.handleTxsAdded = (args: { txs: Tx[]; source?: string }) => {
|
|
36
|
+
this.enqueueTxs(args.txs);
|
|
37
|
+
};
|
|
38
|
+
this.queueProcessor = new RunningPromise(() => this.processQueueBatch(), this.log, 100);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Creates and initializes the file store.
|
|
43
|
+
* @param txPool - The transaction pool to listen to.
|
|
44
|
+
* @param config - The file store configuration.
|
|
45
|
+
* @param log - Optional logger.
|
|
46
|
+
* @param telemetry - Optional telemetry client.
|
|
47
|
+
* @param fileStoreOverride - Optional FileStore for testing (bypasses createFileStore).
|
|
48
|
+
* @returns The file store instance, or undefined if not configured/enabled.
|
|
49
|
+
*/
|
|
50
|
+
static async create(
|
|
51
|
+
txPool: TxPool,
|
|
52
|
+
config: TxFileStoreConfig,
|
|
53
|
+
log: Logger = createLogger('p2p:tx_file_store'),
|
|
54
|
+
telemetry: TelemetryClient = getTelemetryClient(),
|
|
55
|
+
fileStoreOverride?: FileStore,
|
|
56
|
+
): Promise<TxFileStore | undefined> {
|
|
57
|
+
if (!config.txFileStoreEnabled) {
|
|
58
|
+
log.debug('Tx file store is disabled');
|
|
59
|
+
return undefined;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if (!config.txFileStoreUrl) {
|
|
63
|
+
log.warn('Tx file store is enabled but URL is not configured');
|
|
64
|
+
return undefined;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const fileStore = fileStoreOverride ?? (await createFileStore(config.txFileStoreUrl, log));
|
|
68
|
+
if (!fileStore) {
|
|
69
|
+
log.warn('Failed to create file store for tx file store');
|
|
70
|
+
return undefined;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const instrumentation = new TxFileStoreInstrumentation(telemetry, 'TxFileStore');
|
|
74
|
+
log.info('Created tx file store', { url: config.txFileStoreUrl });
|
|
75
|
+
return new TxFileStore(fileStore, txPool, config, instrumentation, log);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** Starts listening to TxPool events and uploading txs. */
|
|
79
|
+
public start(): void {
|
|
80
|
+
this.queueProcessor.start();
|
|
81
|
+
this.txPool.on('txs-added', this.handleTxsAdded);
|
|
82
|
+
this.log.info('Started tx file store', {
|
|
83
|
+
concurrency: this.config.txFileStoreUploadConcurrency,
|
|
84
|
+
maxQueueSize: this.config.txFileStoreMaxQueueSize,
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** Stops listening and waits for pending uploads to complete. */
|
|
89
|
+
public async stop(): Promise<void> {
|
|
90
|
+
this.txPool.removeListener('txs-added', this.handleTxsAdded);
|
|
91
|
+
await this.queueProcessor.stop();
|
|
92
|
+
this.log.info('Stopped tx file store');
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
private enqueueTxs(txs: Tx[]): void {
|
|
96
|
+
this.uploadQueue.push(...txs);
|
|
97
|
+
|
|
98
|
+
// Enforce max queue size by dropping oldest entries
|
|
99
|
+
const overflow = this.uploadQueue.length - this.config.txFileStoreMaxQueueSize;
|
|
100
|
+
if (overflow > 0) {
|
|
101
|
+
this.log.warn(`Upload queue overflow, dropping ${overflow} oldest txs`);
|
|
102
|
+
this.uploadQueue.splice(0, overflow);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
this.instrumentation.recordQueueSize(this.uploadQueue.length);
|
|
106
|
+
|
|
107
|
+
// Immediately start uploading txs
|
|
108
|
+
void this.queueProcessor.trigger();
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
private async processQueueBatch(): Promise<void> {
|
|
112
|
+
const batch = this.uploadQueue.splice(0, this.config.txFileStoreUploadConcurrency);
|
|
113
|
+
this.instrumentation.recordQueueSize(this.uploadQueue.length);
|
|
114
|
+
|
|
115
|
+
this.activeUploads += batch.length;
|
|
116
|
+
try {
|
|
117
|
+
await Promise.all(batch.map(tx => this.uploadTx(tx)));
|
|
118
|
+
} finally {
|
|
119
|
+
this.activeUploads -= batch.length;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
private async uploadTx(tx: Tx): Promise<void> {
|
|
124
|
+
const txHash = tx.getTxHash().toString();
|
|
125
|
+
const path = `txs/${txHash}.bin`;
|
|
126
|
+
const timer = new Timer();
|
|
127
|
+
|
|
128
|
+
if (this.recentUploads.has(txHash)) {
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
try {
|
|
133
|
+
this.recentUploads.add(txHash);
|
|
134
|
+
this.recentUploadsOrder.push(txHash);
|
|
135
|
+
|
|
136
|
+
if (this.recentUploadsOrder.length > this.maxRecentUploads) {
|
|
137
|
+
// delete old entries in recentUploads
|
|
138
|
+
for (const txHashToRemove of this.recentUploadsOrder.splice(
|
|
139
|
+
0,
|
|
140
|
+
this.recentUploadsOrder.length - this.maxRecentUploads,
|
|
141
|
+
)) {
|
|
142
|
+
this.recentUploads.delete(txHashToRemove);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
await retry(
|
|
147
|
+
() => this.fileStore.save(path, tx.toBuffer(), { compress: false }),
|
|
148
|
+
`Uploading tx ${txHash}`,
|
|
149
|
+
makeBackoff([0.1, 0.5, 2]),
|
|
150
|
+
this.log,
|
|
151
|
+
true, // failSilently - don't log errors during retries
|
|
152
|
+
);
|
|
153
|
+
const durationMs = Math.trunc(timer.ms());
|
|
154
|
+
this.log.debug(`Uploaded tx to file store`, { txHash, path, durationMs });
|
|
155
|
+
this.instrumentation.recordUploadSuccess(durationMs);
|
|
156
|
+
} catch (err) {
|
|
157
|
+
this.log.warn(`Failed to upload tx to file store after retries`, { txHash, error: err });
|
|
158
|
+
this.instrumentation.recordUploadFailed();
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/** Waits for all queued and in-flight uploads to complete. For testing. */
|
|
163
|
+
public async flush(): Promise<void> {
|
|
164
|
+
while (this.uploadQueue.length > 0 || this.activeUploads > 0) {
|
|
165
|
+
await this.queueProcessor.trigger();
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/** Returns the number of pending uploads (queued + in-flight). */
|
|
170
|
+
public getPendingUploadCount(): number {
|
|
171
|
+
return this.uploadQueue.length + this.activeUploads;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
type Histogram,
|
|
3
|
+
Metrics,
|
|
4
|
+
type TelemetryClient,
|
|
5
|
+
type UpDownCounter,
|
|
6
|
+
createUpDownCounterWithDefault,
|
|
7
|
+
} from '@aztec/telemetry-client';
|
|
2
8
|
|
|
3
9
|
export class TxProviderInstrumentation {
|
|
4
10
|
private txFromProposalCount: UpDownCounter;
|
|
@@ -12,13 +18,13 @@ export class TxProviderInstrumentation {
|
|
|
12
18
|
constructor(client: TelemetryClient, name: string) {
|
|
13
19
|
const meter = client.getMeter(name);
|
|
14
20
|
|
|
15
|
-
this.txFromProposalCount = meter
|
|
21
|
+
this.txFromProposalCount = createUpDownCounterWithDefault(meter, Metrics.TX_PROVIDER_TXS_FROM_PROPOSALS_COUNT);
|
|
16
22
|
|
|
17
|
-
this.txFromMempoolCount = meter
|
|
23
|
+
this.txFromMempoolCount = createUpDownCounterWithDefault(meter, Metrics.TX_PROVIDER_TXS_FROM_MEMPOOL_COUNT);
|
|
18
24
|
|
|
19
|
-
this.txFromP2PCount = meter
|
|
25
|
+
this.txFromP2PCount = createUpDownCounterWithDefault(meter, Metrics.TX_PROVIDER_TXS_FROM_P2P_COUNT);
|
|
20
26
|
|
|
21
|
-
this.missingTxsCount = meter
|
|
27
|
+
this.missingTxsCount = createUpDownCounterWithDefault(meter, Metrics.TX_PROVIDER_MISSING_TXS_COUNT);
|
|
22
28
|
|
|
23
29
|
this.fractionOfTxsRequestedFromP2P = meter.createHistogram(Metrics.TX_PROVIDER_P2P_TXS_REQUESTED_FRACTION);
|
|
24
30
|
|
|
@@ -12,7 +12,7 @@ import { type BlockHeader, Tx, TxHash } from '@aztec/stdlib/tx';
|
|
|
12
12
|
|
|
13
13
|
import EventEmitter from 'events';
|
|
14
14
|
|
|
15
|
-
import type {
|
|
15
|
+
import type { TryAddResult } from '../mem_pools/attestation_pool/attestation_pool.js';
|
|
16
16
|
import type { TxPool } from '../mem_pools/tx_pool/index.js';
|
|
17
17
|
import { RateLimitStatus } from '../services/reqresp/rate-limiter/rate_limiter.js';
|
|
18
18
|
|
|
@@ -145,42 +145,37 @@ export class InMemoryTxPool extends EventEmitter implements TxPool {
|
|
|
145
145
|
}
|
|
146
146
|
|
|
147
147
|
/**
|
|
148
|
-
* In-memory AttestationPool
|
|
148
|
+
* In-memory AttestationPool mock for testing/benchmarking.
|
|
149
|
+
* Provides minimal implementation without persistence.
|
|
149
150
|
*/
|
|
150
|
-
export class InMemoryAttestationPool
|
|
151
|
+
export class InMemoryAttestationPool {
|
|
151
152
|
private proposals = new Map<string, BlockProposal>();
|
|
152
153
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
154
|
+
tryAddBlockProposal(blockProposal: BlockProposal): Promise<TryAddResult> {
|
|
155
|
+
const id = blockProposal.archive.toString();
|
|
156
|
+
const alreadyExists = this.proposals.has(id);
|
|
157
|
+
if (alreadyExists) {
|
|
158
|
+
return Promise.resolve({ added: false, alreadyExists: true, totalForPosition: 1 });
|
|
159
|
+
}
|
|
160
|
+
this.proposals.set(id, blockProposal);
|
|
161
|
+
return Promise.resolve({ added: true, alreadyExists: false, totalForPosition: 1 });
|
|
156
162
|
}
|
|
157
163
|
|
|
158
164
|
getBlockProposal(id: string): Promise<BlockProposal | undefined> {
|
|
159
165
|
return Promise.resolve(this.proposals.get(id));
|
|
160
166
|
}
|
|
161
167
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
return Promise.resolve(this.proposals.has(id));
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
canAddProposal(_block: BlockProposal): Promise<boolean> {
|
|
168
|
-
return Promise.resolve(true);
|
|
168
|
+
tryAddCheckpointProposal(_proposal: CheckpointProposal): Promise<TryAddResult> {
|
|
169
|
+
return Promise.resolve({ added: true, alreadyExists: false, totalForPosition: 1 });
|
|
169
170
|
}
|
|
170
171
|
|
|
171
|
-
async addCheckpointProposal(_proposal: CheckpointProposal): Promise<void> {}
|
|
172
|
-
|
|
173
172
|
getCheckpointProposal(_id: string): Promise<CheckpointProposalCore | undefined> {
|
|
174
173
|
return Promise.resolve(undefined);
|
|
175
174
|
}
|
|
176
175
|
|
|
177
|
-
|
|
178
|
-
return Promise.resolve(false);
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
async addCheckpointAttestations(_attestations: CheckpointAttestation[]): Promise<void> {}
|
|
176
|
+
async addOwnCheckpointAttestations(_attestations: CheckpointAttestation[]): Promise<void> {}
|
|
182
177
|
|
|
183
|
-
async
|
|
178
|
+
async deleteOlderThan(_slot: SlotNumber): Promise<void> {}
|
|
184
179
|
|
|
185
180
|
getCheckpointAttestationsForSlot(_slot: SlotNumber): Promise<CheckpointAttestation[]> {
|
|
186
181
|
return Promise.resolve([]);
|
|
@@ -193,24 +188,8 @@ export class InMemoryAttestationPool implements AttestationPool {
|
|
|
193
188
|
return Promise.resolve([]);
|
|
194
189
|
}
|
|
195
190
|
|
|
196
|
-
|
|
197
|
-
return Promise.resolve(false);
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
canAddCheckpointProposal(_proposal: CheckpointProposal): Promise<boolean> {
|
|
201
|
-
return Promise.resolve(true);
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
canAddCheckpointAttestation(_attestation: CheckpointAttestation, _committeeSize: number): Promise<boolean> {
|
|
205
|
-
return Promise.resolve(true);
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
hasReachedCheckpointProposalCap(_slot: SlotNumber): Promise<boolean> {
|
|
209
|
-
return Promise.resolve(false);
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
hasReachedCheckpointAttestationCap(_slot: SlotNumber, _proposalId: string, _committeeSize: number): Promise<boolean> {
|
|
213
|
-
return Promise.resolve(false);
|
|
191
|
+
tryAddCheckpointAttestation(_attestation: CheckpointAttestation, _committeeSize: number): Promise<TryAddResult> {
|
|
192
|
+
return Promise.resolve({ added: true, alreadyExists: false, totalForPosition: 1 });
|
|
214
193
|
}
|
|
215
194
|
|
|
216
195
|
isEmpty(): Promise<boolean> {
|
|
@@ -321,6 +300,8 @@ export const BENCHMARK_CONSTANTS = {
|
|
|
321
300
|
FIXED_MAX_PEERS: 10,
|
|
322
301
|
/** Fixed max retry attempts for fair benchmarking */
|
|
323
302
|
FIXED_MAX_RETRY_ATTEMPTS: 3,
|
|
303
|
+
/** LMDB map size for temp stores used in benchmarks (in KB). */
|
|
304
|
+
KV_STORE_MAP_SIZE_KB: 256 * 1024,
|
|
324
305
|
} as const;
|
|
325
306
|
|
|
326
307
|
/**
|
|
@@ -345,7 +345,7 @@ process.on('message', async msg => {
|
|
|
345
345
|
const l2BlockSource = new MockL2BlockSource();
|
|
346
346
|
|
|
347
347
|
const proofVerifier = new AlwaysTrueCircuitVerifier();
|
|
348
|
-
kvStore = await openTmpStore(`test-${clientIndex}
|
|
348
|
+
kvStore = await openTmpStore(`test-${clientIndex}`, true, BENCHMARK_CONSTANTS.KV_STORE_MAP_SIZE_KB);
|
|
349
349
|
workerLogger = createLogger(`p2p:${clientIndex}`);
|
|
350
350
|
workerTxPool.setLogger(workerLogger);
|
|
351
351
|
const telemetry = getTelemetryClient();
|
|
@@ -447,7 +447,7 @@ process.on('message', async msg => {
|
|
|
447
447
|
const txHashes = allTxs.map(tx => tx.getTxHash());
|
|
448
448
|
const blockProposal = await createBlockProposal(benchCmd.blockNumber, txHashes, benchCmd.seed);
|
|
449
449
|
|
|
450
|
-
await workerAttestationPool.
|
|
450
|
+
await workerAttestationPool.tryAddBlockProposal(blockProposal);
|
|
451
451
|
workerLogger.debug(
|
|
452
452
|
`[BENCH] Added block proposal with archive ${blockProposal.archive.toString().slice(0, 10)}...`,
|
|
453
453
|
);
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { SlotNumber } from '@aztec/foundation/branded-types';
|
|
2
|
-
import type { AztecAsyncKVStore } from '@aztec/kv-store';
|
|
3
|
-
import { BlockProposal, CheckpointAttestation, CheckpointProposal, type CheckpointProposalCore } from '@aztec/stdlib/p2p';
|
|
4
|
-
import { type TelemetryClient } from '@aztec/telemetry-client';
|
|
5
|
-
import type { AttestationPool } from './attestation_pool.js';
|
|
6
|
-
export declare const MAX_PROPOSALS_PER_SLOT = 5;
|
|
7
|
-
export declare const ATTESTATION_CAP_BUFFER = 10;
|
|
8
|
-
export declare class KvAttestationPool implements AttestationPool {
|
|
9
|
-
private store;
|
|
10
|
-
private log;
|
|
11
|
-
private metrics;
|
|
12
|
-
private proposals;
|
|
13
|
-
private checkpointAttestations;
|
|
14
|
-
private checkpointProposals;
|
|
15
|
-
private checkpointProposalsForSlot;
|
|
16
|
-
private checkpointAttestationsForProposal;
|
|
17
|
-
constructor(store: AztecAsyncKVStore, telemetry?: TelemetryClient, log?: import("@aztec/foundation/log").Logger);
|
|
18
|
-
private poolStats;
|
|
19
|
-
isEmpty(): Promise<boolean>;
|
|
20
|
-
private getProposalKey;
|
|
21
|
-
private getAttestationKey;
|
|
22
|
-
addBlockProposal(blockProposal: BlockProposal): Promise<void>;
|
|
23
|
-
getBlockProposal(id: string): Promise<BlockProposal | undefined>;
|
|
24
|
-
hasBlockProposal(idOrProposal: string | BlockProposal): Promise<boolean>;
|
|
25
|
-
addCheckpointProposal(proposal: CheckpointProposal): Promise<void>;
|
|
26
|
-
getCheckpointProposal(id: string): Promise<CheckpointProposalCore | undefined>;
|
|
27
|
-
hasCheckpointProposal(idOrProposal: string | CheckpointProposal): Promise<boolean>;
|
|
28
|
-
addCheckpointAttestations(attestations: CheckpointAttestation[]): Promise<void>;
|
|
29
|
-
getCheckpointAttestationsForSlot(slot: SlotNumber): Promise<CheckpointAttestation[]>;
|
|
30
|
-
getCheckpointAttestationsForSlotAndProposal(slot: SlotNumber, proposalId: string): Promise<CheckpointAttestation[]>;
|
|
31
|
-
deleteCheckpointAttestationsOlderThan(oldestSlot: SlotNumber): Promise<void>;
|
|
32
|
-
private deleteCheckpointAttestationsForSlot;
|
|
33
|
-
hasCheckpointAttestation(attestation: CheckpointAttestation): Promise<boolean>;
|
|
34
|
-
canAddProposal(_block: BlockProposal): Promise<boolean>;
|
|
35
|
-
canAddCheckpointProposal(proposal: CheckpointProposal): Promise<boolean>;
|
|
36
|
-
canAddCheckpointAttestation(attestation: CheckpointAttestation, committeeSize: number): Promise<boolean>;
|
|
37
|
-
hasReachedCheckpointProposalCap(slot: SlotNumber): Promise<boolean>;
|
|
38
|
-
hasReachedCheckpointAttestationCap(slot: SlotNumber, proposalId: string, committeeSize: number): Promise<boolean>;
|
|
39
|
-
}
|
|
40
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoia3ZfYXR0ZXN0YXRpb25fcG9vbC5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL21lbV9wb29scy9hdHRlc3RhdGlvbl9wb29sL2t2X2F0dGVzdGF0aW9uX3Bvb2wudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLFVBQVUsRUFBRSxNQUFNLGlDQUFpQyxDQUFDO0FBSTdELE9BQU8sS0FBSyxFQUFFLGlCQUFpQixFQUFxQyxNQUFNLGlCQUFpQixDQUFDO0FBQzVGLE9BQU8sRUFDTCxhQUFhLEVBQ2IscUJBQXFCLEVBQ3JCLGtCQUFrQixFQUNsQixLQUFLLHNCQUFzQixFQUM1QixNQUFNLG1CQUFtQixDQUFDO0FBQzNCLE9BQU8sRUFBRSxLQUFLLGVBQWUsRUFBc0IsTUFBTSx5QkFBeUIsQ0FBQztBQUluRixPQUFPLEtBQUssRUFBRSxlQUFlLEVBQUUsTUFBTSx1QkFBdUIsQ0FBQztBQUU3RCxlQUFPLE1BQU0sc0JBQXNCLElBQUksQ0FBQztBQUN4QyxlQUFPLE1BQU0sc0JBQXNCLEtBQUssQ0FBQztBQUV6QyxxQkFBYSxpQkFBa0IsWUFBVyxlQUFlO0lBZXJELE9BQU8sQ0FBQyxLQUFLO0lBRWIsT0FBTyxDQUFDLEdBQUc7SUFoQmIsT0FBTyxDQUFDLE9BQU8sQ0FBNkM7SUFFNUQsT0FBTyxDQUFDLFNBQVMsQ0FHZjtJQUdGLE9BQU8sQ0FBQyxzQkFBc0IsQ0FBZ0M7SUFDOUQsT0FBTyxDQUFDLG1CQUFtQixDQUFnQztJQUMzRCxPQUFPLENBQUMsMEJBQTBCLENBQXFDO0lBQ3ZFLE9BQU8sQ0FBQyxpQ0FBaUMsQ0FBcUM7SUFFOUUsWUFDVSxLQUFLLEVBQUUsaUJBQWlCLEVBQ2hDLFNBQVMsR0FBRSxlQUFzQyxFQUN6QyxHQUFHLHlDQUF5QyxFQVdyRDtJQUVELE9BQU8sQ0FBQyxTQUFTLENBSWY7SUFFVyxPQUFPLElBQUksT0FBTyxDQUFDLE9BQU8sQ0FBQyxDQVF2QztJQUVELE9BQU8sQ0FBQyxjQUFjO0lBWXRCLE9BQU8sQ0FBQyxpQkFBaUI7SUFJWixnQkFBZ0IsQ0FBQyxhQUFhLEVBQUUsYUFBYSxHQUFHLE9BQU8sQ0FBQyxJQUFJLENBQUMsQ0FNekU7SUFFWSxnQkFBZ0IsQ0FBQyxFQUFFLEVBQUUsTUFBTSxHQUFHLE9BQU8sQ0FBQyxhQUFhLEdBQUcsU0FBUyxDQUFDLENBVzVFO0lBRVksZ0JBQWdCLENBQUMsWUFBWSxFQUFFLE1BQU0sR0FBRyxhQUFhLEdBQUcsT0FBTyxDQUFDLE9BQU8sQ0FBQyxDQUdwRjtJQUVZLHFCQUFxQixDQUFDLFFBQVEsRUFBRSxrQkFBa0IsR0FBRyxPQUFPLENBQUMsSUFBSSxDQUFDLENBNEI5RTtJQUVZLHFCQUFxQixDQUFDLEVBQUUsRUFBRSxNQUFNLEdBQUcsT0FBTyxDQUFDLHNCQUFzQixHQUFHLFNBQVMsQ0FBQyxDQVcxRjtJQUVZLHFCQUFxQixDQUFDLFlBQVksRUFBRSxNQUFNLEdBQUcsa0JBQWtCLEdBQUcsT0FBTyxDQUFDLE9BQU8sQ0FBQyxDQUc5RjtJQUVZLHlCQUF5QixDQUFDLFlBQVksRUFBRSxxQkFBcUIsRUFBRSxHQUFHLE9BQU8sQ0FBQyxJQUFJLENBQUMsQ0FzQzNGO0lBRVksZ0NBQWdDLENBQUMsSUFBSSxFQUFFLFVBQVUsR0FBRyxPQUFPLENBQUMscUJBQXFCLEVBQUUsQ0FBQyxDQVNoRztJQUVZLDJDQUEyQyxDQUN0RCxJQUFJLEVBQUUsVUFBVSxFQUNoQixVQUFVLEVBQUUsTUFBTSxHQUNqQixPQUFPLENBQUMscUJBQXFCLEVBQUUsQ0FBQyxDQWtCbEM7SUFFWSxxQ0FBcUMsQ0FBQyxVQUFVLEVBQUUsVUFBVSxHQUFHLE9BQU8sQ0FBQyxJQUFJLENBQUMsQ0FLeEY7WUFFYSxtQ0FBbUM7SUF3QnBDLHdCQUF3QixDQUFDLFdBQVcsRUFBRSxxQkFBcUIsR0FBRyxPQUFPLENBQUMsT0FBTyxDQUFDLENBYzFGO0lBRU0sY0FBYyxDQUFDLE1BQU0sRUFBRSxhQUFhLEdBQUcsT0FBTyxDQUFDLE9BQU8sQ0FBQyxDQUc3RDtJQUVZLHdCQUF3QixDQUFDLFFBQVEsRUFBRSxrQkFBa0IsR0FBRyxPQUFPLENBQUMsT0FBTyxDQUFDLENBTXBGO0lBRVksMkJBQTJCLENBQ3RDLFdBQVcsRUFBRSxxQkFBcUIsRUFDbEMsYUFBYSxFQUFFLE1BQU0sR0FDcEIsT0FBTyxDQUFDLE9BQU8sQ0FBQyxDQVNsQjtJQUVZLCtCQUErQixDQUFDLElBQUksRUFBRSxVQUFVLEdBQUcsT0FBTyxDQUFDLE9BQU8sQ0FBQyxDQUcvRTtJQUVZLGtDQUFrQyxDQUM3QyxJQUFJLEVBQUUsVUFBVSxFQUNoQixVQUFVLEVBQUUsTUFBTSxFQUNsQixhQUFhLEVBQUUsTUFBTSxHQUNwQixPQUFPLENBQUMsT0FBTyxDQUFDLENBS2xCO0NBQ0YifQ==
|