@aztec/p2p 0.0.1-commit.c80b6263 → 0.0.1-commit.cd76b27
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/client/factory.d.ts +7 -6
- package/dest/client/factory.d.ts.map +1 -1
- package/dest/client/factory.js +47 -10
- package/dest/client/interface.d.ts +43 -23
- package/dest/client/interface.d.ts.map +1 -1
- package/dest/client/p2p_client.d.ts +40 -42
- package/dest/client/p2p_client.d.ts.map +1 -1
- package/dest/client/p2p_client.js +156 -145
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.js +7 -7
- package/dest/config.d.ts +29 -4
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +19 -2
- package/dest/errors/tx-pool.error.d.ts +8 -0
- package/dest/errors/tx-pool.error.d.ts.map +1 -0
- package/dest/errors/tx-pool.error.js +9 -0
- package/dest/index.d.ts +2 -1
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +1 -0
- package/dest/mem_pools/attestation_pool/attestation_pool.d.ts +104 -88
- package/dest/mem_pools/attestation_pool/attestation_pool.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/attestation_pool.js +441 -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 +353 -87
- 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/attestation_pool/mocks.d.ts +2 -2
- package/dest/mem_pools/attestation_pool/mocks.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/mocks.js +2 -2
- package/dest/mem_pools/index.d.ts +3 -2
- package/dest/mem_pools/index.d.ts.map +1 -1
- package/dest/mem_pools/index.js +1 -1
- package/dest/mem_pools/interface.d.ts +5 -5
- package/dest/mem_pools/interface.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.js +3 -3
- 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/deleted_pool.d.ts +104 -0
- package/dest/mem_pools/tx_pool_v2/deleted_pool.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/deleted_pool.js +251 -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 +128 -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 +93 -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 +95 -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 +174 -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 +25 -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 +65 -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 +93 -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 +74 -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 +73 -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 +6 -0
- package/dest/mem_pools/tx_pool_v2/index.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/index.js +5 -0
- package/dest/mem_pools/tx_pool_v2/instrumentation.d.ts +15 -0
- package/dest/mem_pools/tx_pool_v2/instrumentation.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/instrumentation.js +43 -0
- package/dest/mem_pools/tx_pool_v2/interfaces.d.ts +209 -0
- package/dest/mem_pools/tx_pool_v2/interfaces.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/interfaces.js +8 -0
- package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts +97 -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 +152 -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 +108 -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 +355 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts +60 -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 +161 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts +77 -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 +878 -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/tx_validator/aggregate_tx_validator.d.ts +3 -3
- package/dest/msg_validators/tx_validator/aggregate_tx_validator.d.ts.map +1 -1
- 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 +18 -5
- package/dest/msg_validators/tx_validator/block_header_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/block_header_validator.js +2 -2
- package/dest/msg_validators/tx_validator/double_spend_validator.d.ts +13 -3
- package/dest/msg_validators/tx_validator/double_spend_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/double_spend_validator.js +4 -4
- package/dest/msg_validators/tx_validator/timestamp_validator.d.ts +20 -4
- package/dest/msg_validators/tx_validator/timestamp_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/timestamp_validator.js +6 -6
- 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/dummy_service.d.ts +12 -3
- package/dest/services/dummy_service.d.ts.map +1 -1
- package/dest/services/dummy_service.js +9 -0
- package/dest/services/encoding.d.ts +2 -2
- package/dest/services/encoding.d.ts.map +1 -1
- package/dest/services/encoding.js +4 -3
- package/dest/services/gossipsub/index.d.ts +3 -0
- package/dest/services/gossipsub/index.d.ts.map +1 -0
- package/dest/services/gossipsub/index.js +2 -0
- package/dest/services/gossipsub/scoring.d.ts +21 -3
- package/dest/services/gossipsub/scoring.d.ts.map +1 -1
- package/dest/services/gossipsub/scoring.js +24 -7
- package/dest/services/gossipsub/topic_score_params.d.ts +173 -0
- package/dest/services/gossipsub/topic_score_params.d.ts.map +1 -0
- package/dest/services/gossipsub/topic_score_params.js +346 -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/libp2p_service.d.ts +85 -35
- package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
- package/dest/services/libp2p/libp2p_service.js +379 -280
- 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 +25 -2
- package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts +6 -5
- 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 +13 -17
- package/dest/services/reqresp/batch-tx-requester/interface.d.ts +2 -6
- package/dest/services/reqresp/batch-tx-requester/interface.d.ts.map +1 -1
- package/dest/services/reqresp/batch-tx-requester/missing_txs.d.ts +10 -13
- package/dest/services/reqresp/batch-tx-requester/missing_txs.d.ts.map +1 -1
- package/dest/services/reqresp/batch-tx-requester/missing_txs.js +25 -46
- package/dest/services/reqresp/interface.d.ts +10 -1
- package/dest/services/reqresp/interface.d.ts.map +1 -1
- package/dest/services/reqresp/interface.js +15 -1
- package/dest/services/reqresp/protocols/block_txs/block_txs_handler.d.ts +7 -5
- 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 +25 -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 +40 -24
- package/dest/services/reqresp/protocols/tx.d.ts +7 -1
- package/dest/services/reqresp/protocols/tx.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/tx.js +20 -0
- package/dest/services/reqresp/reqresp.d.ts +1 -1
- package/dest/services/reqresp/reqresp.d.ts.map +1 -1
- package/dest/services/reqresp/reqresp.js +11 -4
- package/dest/services/service.d.ts +38 -2
- package/dest/services/service.d.ts.map +1 -1
- package/dest/services/tx_collection/config.d.ts +22 -4
- package/dest/services/tx_collection/config.d.ts.map +1 -1
- package/dest/services/tx_collection/config.js +49 -3
- package/dest/services/tx_collection/fast_tx_collection.d.ts +6 -5
- package/dest/services/tx_collection/fast_tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/fast_tx_collection.js +64 -48
- package/dest/services/tx_collection/file_store_tx_collection.d.ts +53 -0
- package/dest/services/tx_collection/file_store_tx_collection.d.ts.map +1 -0
- package/dest/services/tx_collection/file_store_tx_collection.js +167 -0
- package/dest/services/tx_collection/file_store_tx_source.d.ts +37 -0
- package/dest/services/tx_collection/file_store_tx_source.d.ts.map +1 -0
- package/dest/services/tx_collection/file_store_tx_source.js +90 -0
- package/dest/services/tx_collection/index.d.ts +3 -2
- package/dest/services/tx_collection/index.d.ts.map +1 -1
- package/dest/services/tx_collection/index.js +1 -0
- 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 +2 -1
- package/dest/services/tx_collection/missing_txs_tracker.d.ts +32 -0
- package/dest/services/tx_collection/missing_txs_tracker.d.ts.map +1 -0
- package/dest/services/tx_collection/missing_txs_tracker.js +27 -0
- package/dest/services/tx_collection/proposal_tx_collector.d.ts +15 -14
- package/dest/services/tx_collection/proposal_tx_collector.d.ts.map +1 -1
- package/dest/services/tx_collection/proposal_tx_collector.js +6 -6
- package/dest/services/tx_collection/slow_tx_collection.d.ts +7 -3
- package/dest/services/tx_collection/slow_tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/slow_tx_collection.js +60 -26
- package/dest/services/tx_collection/tx_collection.d.ts +23 -10
- package/dest/services/tx_collection/tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/tx_collection.js +75 -3
- package/dest/services/tx_collection/tx_collection_sink.d.ts +18 -8
- package/dest/services/tx_collection/tx_collection_sink.d.ts.map +1 -1
- package/dest/services/tx_collection/tx_collection_sink.js +26 -29
- package/dest/services/tx_collection/tx_source.d.ts +8 -3
- package/dest/services/tx_collection/tx_source.d.ts.map +1 -1
- package/dest/services/tx_collection/tx_source.js +19 -2
- package/dest/services/tx_file_store/config.d.ts +16 -0
- package/dest/services/tx_file_store/config.d.ts.map +1 -0
- package/dest/services/tx_file_store/config.js +22 -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 +48 -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 +152 -0
- package/dest/services/tx_provider.d.ts +3 -3
- package/dest/services/tx_provider.d.ts.map +1 -1
- package/dest/services/tx_provider.js +5 -4
- package/dest/test-helpers/make-test-p2p-clients.d.ts +3 -3
- package/dest/test-helpers/make-test-p2p-clients.d.ts.map +1 -1
- package/dest/test-helpers/mock-pubsub.d.ts +29 -2
- package/dest/test-helpers/mock-pubsub.d.ts.map +1 -1
- package/dest/test-helpers/mock-pubsub.js +103 -2
- package/dest/test-helpers/reqresp-nodes.d.ts +1 -1
- package/dest/test-helpers/reqresp-nodes.d.ts.map +1 -1
- package/dest/test-helpers/reqresp-nodes.js +2 -1
- package/dest/test-helpers/testbench-utils.d.ts +45 -38
- package/dest/test-helpers/testbench-utils.d.ts.map +1 -1
- package/dest/test-helpers/testbench-utils.js +130 -60
- package/dest/testbench/p2p_client_testbench_worker.d.ts +2 -2
- package/dest/testbench/p2p_client_testbench_worker.d.ts.map +1 -1
- package/dest/testbench/p2p_client_testbench_worker.js +11 -11
- package/dest/util.d.ts +2 -2
- package/dest/util.d.ts.map +1 -1
- package/package.json +14 -14
- package/src/client/factory.ts +89 -14
- package/src/client/interface.ts +59 -23
- package/src/client/p2p_client.ts +196 -167
- package/src/client/test/tx_proposal_collector/README.md +4 -4
- package/src/client/test/tx_proposal_collector/proposal_tx_collector_worker.ts +20 -10
- package/src/config.ts +41 -2
- package/src/errors/tx-pool.error.ts +12 -0
- package/src/index.ts +1 -0
- package/src/mem_pools/attestation_pool/attestation_pool.ts +496 -91
- package/src/mem_pools/attestation_pool/attestation_pool_test_suite.ts +442 -102
- package/src/mem_pools/attestation_pool/index.ts +9 -2
- package/src/mem_pools/attestation_pool/mocks.ts +2 -1
- package/src/mem_pools/index.ts +4 -1
- package/src/mem_pools/interface.ts +4 -4
- package/src/mem_pools/tx_pool/README.md +1 -1
- package/src/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.ts +3 -3
- package/src/mem_pools/tx_pool_v2/README.md +275 -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/deleted_pool.ts +321 -0
- package/src/mem_pools/tx_pool_v2/eviction/eviction_manager.ts +160 -0
- package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.ts +121 -0
- package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.ts +122 -0
- package/src/mem_pools/tx_pool_v2/eviction/index.ts +27 -0
- package/src/mem_pools/tx_pool_v2/eviction/interfaces.ts +209 -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 +87 -0
- package/src/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.ts +90 -0
- package/src/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.ts +31 -0
- package/src/mem_pools/tx_pool_v2/index.ts +12 -0
- package/src/mem_pools/tx_pool_v2/instrumentation.ts +69 -0
- package/src/mem_pools/tx_pool_v2/interfaces.ts +239 -0
- package/src/mem_pools/tx_pool_v2/tx_metadata.ts +242 -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 +444 -0
- package/src/mem_pools/tx_pool_v2/tx_pool_v2.ts +223 -0
- package/src/mem_pools/tx_pool_v2/tx_pool_v2_impl.ts +1052 -0
- package/src/msg_validators/attestation_validator/fisherman_attestation_validator.ts +2 -2
- package/src/msg_validators/tx_validator/aggregate_tx_validator.ts +2 -2
- package/src/msg_validators/tx_validator/archive_cache.ts +3 -3
- package/src/msg_validators/tx_validator/block_header_validator.ts +18 -8
- package/src/msg_validators/tx_validator/double_spend_validator.ts +11 -6
- package/src/msg_validators/tx_validator/timestamp_validator.ts +23 -18
- package/src/services/data_store.ts +10 -7
- package/src/services/dummy_service.ts +17 -1
- package/src/services/encoding.ts +4 -3
- package/src/services/gossipsub/README.md +641 -0
- package/src/services/gossipsub/index.ts +2 -0
- package/src/services/gossipsub/scoring.ts +29 -5
- package/src/services/gossipsub/topic_score_params.ts +487 -0
- package/src/services/index.ts +1 -0
- package/src/services/libp2p/libp2p_service.ts +382 -282
- package/src/services/peer-manager/peer_scoring.ts +25 -0
- package/src/services/reqresp/batch-tx-requester/README.md +14 -14
- package/src/services/reqresp/batch-tx-requester/batch_tx_requester.ts +18 -18
- package/src/services/reqresp/batch-tx-requester/interface.ts +1 -5
- package/src/services/reqresp/batch-tx-requester/missing_txs.ts +23 -71
- package/src/services/reqresp/interface.ts +26 -1
- package/src/services/reqresp/protocols/block_txs/block_txs_handler.ts +24 -15
- package/src/services/reqresp/protocols/block_txs/block_txs_reqresp.ts +47 -24
- package/src/services/reqresp/protocols/tx.ts +22 -0
- package/src/services/reqresp/reqresp.ts +13 -3
- package/src/services/service.ts +50 -1
- package/src/services/tx_collection/config.ts +74 -6
- package/src/services/tx_collection/fast_tx_collection.ts +74 -51
- package/src/services/tx_collection/file_store_tx_collection.ts +202 -0
- package/src/services/tx_collection/file_store_tx_source.ts +117 -0
- package/src/services/tx_collection/index.ts +2 -1
- package/src/services/tx_collection/instrumentation.ts +7 -1
- package/src/services/tx_collection/missing_txs_tracker.ts +52 -0
- package/src/services/tx_collection/proposal_tx_collector.ts +20 -21
- package/src/services/tx_collection/slow_tx_collection.ts +66 -33
- package/src/services/tx_collection/tx_collection.ts +113 -16
- package/src/services/tx_collection/tx_collection_sink.ts +30 -34
- package/src/services/tx_collection/tx_source.ts +22 -3
- package/src/services/tx_file_store/config.ts +37 -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 +175 -0
- package/src/services/tx_provider.ts +8 -7
- package/src/test-helpers/make-test-p2p-clients.ts +3 -3
- package/src/test-helpers/mock-pubsub.ts +143 -3
- package/src/test-helpers/reqresp-nodes.ts +2 -1
- package/src/test-helpers/testbench-utils.ts +129 -71
- package/src/testbench/p2p_client_testbench_worker.ts +23 -16
- package/src/util.ts +7 -1
- 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
|
@@ -55,12 +55,58 @@ export const txCollectionConfigMappings = {
|
|
|
55
55
|
description: 'Maximum number of transactions to request from a node in a single batch',
|
|
56
56
|
...numberConfigHelper(MAX_RPC_TXS_LEN)
|
|
57
57
|
},
|
|
58
|
-
|
|
59
|
-
env: '
|
|
60
|
-
description: 'Which collector implementation to use for
|
|
58
|
+
txCollectionMissingTxsCollectorType: {
|
|
59
|
+
env: 'TX_COLLECTION_MISSING_TXS_COLLECTOR_TYPE',
|
|
60
|
+
description: 'Which collector implementation to use for missing txs collection (new or old)',
|
|
61
61
|
...enumConfigHelper([
|
|
62
62
|
'new',
|
|
63
63
|
'old'
|
|
64
64
|
], 'new')
|
|
65
|
+
},
|
|
66
|
+
txCollectionFileStoreUrls: {
|
|
67
|
+
env: 'TX_COLLECTION_FILE_STORE_URLS',
|
|
68
|
+
description: 'A comma-separated list of file store URLs (s3://, gs://, file://, http://) for tx collection',
|
|
69
|
+
parseEnv: (val)=>val.split(',').map((url)=>url.trim()).filter((url)=>url.length > 0),
|
|
70
|
+
defaultValue: []
|
|
71
|
+
},
|
|
72
|
+
txCollectionFileStoreSlowDelayMs: {
|
|
73
|
+
env: 'TX_COLLECTION_FILE_STORE_SLOW_DELAY_MS',
|
|
74
|
+
description: 'Delay before file store collection starts after slow collection',
|
|
75
|
+
...numberConfigHelper(24_000)
|
|
76
|
+
},
|
|
77
|
+
txCollectionFileStoreFastDelayMs: {
|
|
78
|
+
env: 'TX_COLLECTION_FILE_STORE_FAST_DELAY_MS',
|
|
79
|
+
description: 'Delay before file store collection starts after fast collection',
|
|
80
|
+
...numberConfigHelper(2_000)
|
|
81
|
+
},
|
|
82
|
+
txCollectionFileStoreFastWorkerCount: {
|
|
83
|
+
env: 'TX_COLLECTION_FILE_STORE_FAST_WORKER_COUNT',
|
|
84
|
+
description: 'Number of concurrent workers for fast file store collection',
|
|
85
|
+
...numberConfigHelper(5)
|
|
86
|
+
},
|
|
87
|
+
txCollectionFileStoreSlowWorkerCount: {
|
|
88
|
+
env: 'TX_COLLECTION_FILE_STORE_SLOW_WORKER_COUNT',
|
|
89
|
+
description: 'Number of concurrent workers for slow file store collection',
|
|
90
|
+
...numberConfigHelper(2)
|
|
91
|
+
},
|
|
92
|
+
txCollectionFileStoreFastBackoffBaseMs: {
|
|
93
|
+
env: 'TX_COLLECTION_FILE_STORE_FAST_BACKOFF_BASE_MS',
|
|
94
|
+
description: 'Base backoff time in ms for fast file store collection retries',
|
|
95
|
+
...numberConfigHelper(1_000)
|
|
96
|
+
},
|
|
97
|
+
txCollectionFileStoreSlowBackoffBaseMs: {
|
|
98
|
+
env: 'TX_COLLECTION_FILE_STORE_SLOW_BACKOFF_BASE_MS',
|
|
99
|
+
description: 'Base backoff time in ms for slow file store collection retries',
|
|
100
|
+
...numberConfigHelper(5_000)
|
|
101
|
+
},
|
|
102
|
+
txCollectionFileStoreFastBackoffMaxMs: {
|
|
103
|
+
env: 'TX_COLLECTION_FILE_STORE_FAST_BACKOFF_MAX_MS',
|
|
104
|
+
description: 'Max backoff time in ms for fast file store collection retries',
|
|
105
|
+
...numberConfigHelper(5_000)
|
|
106
|
+
},
|
|
107
|
+
txCollectionFileStoreSlowBackoffMaxMs: {
|
|
108
|
+
env: 'TX_COLLECTION_FILE_STORE_SLOW_BACKOFF_MAX_MS',
|
|
109
|
+
description: 'Max backoff time in ms for slow file store collection retries',
|
|
110
|
+
...numberConfigHelper(30_000)
|
|
65
111
|
}
|
|
66
112
|
};
|
|
@@ -6,20 +6,19 @@ import { type Tx, TxHash } from '@aztec/stdlib/tx';
|
|
|
6
6
|
import type { PeerId } from '@libp2p/interface';
|
|
7
7
|
import type { BatchTxRequesterLibP2PService } from '../reqresp/batch-tx-requester/interface.js';
|
|
8
8
|
import type { TxCollectionConfig } from './config.js';
|
|
9
|
-
import { type
|
|
9
|
+
import { type MissingTxsCollector } from './proposal_tx_collector.js';
|
|
10
10
|
import type { FastCollectionRequest, FastCollectionRequestInput } from './tx_collection.js';
|
|
11
11
|
import type { TxCollectionSink } from './tx_collection_sink.js';
|
|
12
12
|
import type { TxSource } from './tx_source.js';
|
|
13
13
|
export declare class FastTxCollection {
|
|
14
|
-
private p2pService;
|
|
15
14
|
private nodes;
|
|
16
15
|
private txCollectionSink;
|
|
17
16
|
private config;
|
|
18
17
|
private dateProvider;
|
|
19
18
|
private log;
|
|
20
19
|
protected requests: Set<FastCollectionRequest>;
|
|
21
|
-
private
|
|
22
|
-
constructor(p2pService: BatchTxRequesterLibP2PService, nodes: TxSource[], txCollectionSink: TxCollectionSink, config: TxCollectionConfig, dateProvider?: DateProvider, log?: Logger,
|
|
20
|
+
private missingTxsCollector;
|
|
21
|
+
constructor(p2pService: BatchTxRequesterLibP2PService, nodes: TxSource[], txCollectionSink: TxCollectionSink, config: TxCollectionConfig, dateProvider?: DateProvider, log?: Logger, missingTxsCollector?: MissingTxsCollector);
|
|
23
22
|
stop(): Promise<void>;
|
|
24
23
|
getFastCollectionRequests(): Set<FastCollectionRequest>;
|
|
25
24
|
collectFastFor(input: FastCollectionRequestInput, txHashes: TxHash[] | string[], opts: {
|
|
@@ -34,6 +33,8 @@ export declare class FastTxCollection {
|
|
|
34
33
|
private collectFastFromNodes;
|
|
35
34
|
private collectFastFromNode;
|
|
36
35
|
private collectFastViaReqResp;
|
|
36
|
+
/** Returns the TxAddContext for the given request, used by the sink to add txs to the pool correctly. */
|
|
37
|
+
private getAddContext;
|
|
37
38
|
/**
|
|
38
39
|
* Handle txs by marking them as found for the requests that are waiting for them, and resolves the request if all its txs have been found.
|
|
39
40
|
* Called internally and from the main tx collection manager whenever the tx pool emits a tx-added event.
|
|
@@ -50,4 +51,4 @@ export declare class FastTxCollection {
|
|
|
50
51
|
*/
|
|
51
52
|
stopCollectingForBlocksAfter(blockNumber: BlockNumber): void;
|
|
52
53
|
}
|
|
53
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
54
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZmFzdF90eF9jb2xsZWN0aW9uLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvc2VydmljZXMvdHhfY29sbGVjdGlvbi9mYXN0X3R4X2NvbGxlY3Rpb24udHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLFdBQVcsRUFBRSxNQUFNLGlDQUFpQyxDQUFDO0FBRzlELE9BQU8sRUFBRSxLQUFLLE1BQU0sRUFBZ0IsTUFBTSx1QkFBdUIsQ0FBQztBQUdsRSxPQUFPLEVBQUUsWUFBWSxFQUFXLE1BQU0seUJBQXlCLENBQUM7QUFFaEUsT0FBTyxLQUFLLEVBQUUsYUFBYSxFQUFFLE1BQU0sbUJBQW1CLENBQUM7QUFDdkQsT0FBTyxFQUFFLEtBQUssRUFBRSxFQUFFLE1BQ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LElBQUksa0JBR2hCO0lBRU0seUJBQXlCLCtCQUUvQjtJQUVZLGNBQWMsQ0FDekIsS0FBSyxFQUFFLDBCQUEwQixFQUNqQyxRQUFRLEVBQUUsTUFBTSxFQUFFLEdBQUcsTUFBTSxFQUFFLEVBQzdCLElBQUksRUFBRTtRQUFFLFFBQVEsRUFBRSxJQUFJLENBQUM7UUFBQyxVQUFVLENBQUMsRUFBRSxNQUFNLENBQUE7S0FBRSxpQkEwQzlDO0lBRUQsVUFBZ0IsV0FBVyxDQUN6QixPQUFPLEVBQUUscUJBQXFCLEVBQzlCLElBQUksRUFBRTtRQUFFLFFBQVEsQ0FBQyxFQUFFLGFBQWEsQ0FBQztRQUFDLFFBQVEsRUFBRSxJQUFJLENBQUM7UUFBQyxVQUFVLENBQUMsRUFBRSxNQUFNLENBQUE7S0FBRSxpQkErQ3hFO1lBUWEsb0JBQW9CO1lBZ0JwQixtQkFBbUI7WUF5Rm5CLHFCQUFxQjtJQXlEbkMseUdBQXlHO0lBQ3pHLE9BQU8sQ0FBQyxhQUFhO0lBUXJCOzs7T0FHRztJQUNJLFFBQVEsQ0FBQyxHQUFHLEVBQUUsRUFBRSxFQUFFLFFBc0J4QjtJQUVEOzs7T0FHRztJQUNJLDJCQUEyQixDQUFDLFdBQVcsRUFBRSxXQUFXLEdBQUcsSUFBSSxDQU9qRTtJQUVEOzs7T0FHRztJQUNJLDRCQUE0QixDQUFDLFdBQVcsRUFBRSxXQUFXLEdBQUcsSUFBSSxDQU9sRTtDQUNGIn0=
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fast_tx_collection.d.ts","sourceRoot":"","sources":["../../../src/services/tx_collection/fast_tx_collection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAG9D,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"fast_tx_collection.d.ts","sourceRoot":"","sources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,kBAGhB;IAEM,yBAAyB,+BAE/B;IAEY,cAAc,CACzB,KAAK,EAAE,0BAA0B,EACjC,QAAQ,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,EAC7B,IAAI,EAAE;QAAE,QAAQ,EAAE,IAAI,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE,iBA0C9C;IAED,UAAgB,WAAW,CACzB,OAAO,EAAE,qBAAqB,EAC9B,IAAI,EAAE;QAAE,QAAQ,CAAC,EAAE,aAAa,CAAC;QAAC,QAAQ,EAAE,IAAI,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE,iBA+CxE;YAQa,oBAAoB;YAgBpB,mBAAmB;YAyFnB,qBAAqB;IAyDnC,yGAAyG;IACzG,OAAO,CAAC,aAAa;IAQrB;;;OAGG;IACI,QAAQ,CAAC,GAAG,EAAE,EAAE,EAAE,QAsBxB;IAED;;;OAGG;IACI,2BAA2B,CAAC,WAAW,EAAE,WAAW,GAAG,IAAI,CAOjE;IAED;;;OAGG;IACI,4BAA4B,CAAC,WAAW,EAAE,WAAW,GAAG,IAAI,CAOlE;CACF"}
|
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
import { times } from '@aztec/foundation/collection';
|
|
2
2
|
import { AbortError, TimeoutError } from '@aztec/foundation/error';
|
|
3
3
|
import { createLogger } from '@aztec/foundation/log';
|
|
4
|
-
import { boundInclusive } from '@aztec/foundation/number';
|
|
5
4
|
import { promiseWithResolvers } from '@aztec/foundation/promise';
|
|
6
5
|
import { sleep } from '@aztec/foundation/sleep';
|
|
7
6
|
import { DateProvider, elapsed } from '@aztec/foundation/timer';
|
|
8
7
|
import { TxHash } from '@aztec/stdlib/tx';
|
|
9
|
-
import {
|
|
10
|
-
import { chunkTxHashesRequest } from '../reqresp/protocols/tx.js';
|
|
8
|
+
import { MissingTxsTracker } from './missing_txs_tracker.js';
|
|
11
9
|
import { BatchTxRequesterCollector, SendBatchRequestCollector } from './proposal_tx_collector.js';
|
|
12
10
|
export class FastTxCollection {
|
|
13
|
-
p2pService;
|
|
14
11
|
nodes;
|
|
15
12
|
txCollectionSink;
|
|
16
13
|
config;
|
|
@@ -18,9 +15,8 @@ export class FastTxCollection {
|
|
|
18
15
|
log;
|
|
19
16
|
// eslint-disable-next-line aztec-custom/no-non-primitive-in-collections
|
|
20
17
|
requests;
|
|
21
|
-
|
|
22
|
-
constructor(p2pService, nodes, txCollectionSink, config, dateProvider = new DateProvider(), log = createLogger('p2p:tx_collection_service'),
|
|
23
|
-
this.p2pService = p2pService;
|
|
18
|
+
missingTxsCollector;
|
|
19
|
+
constructor(p2pService, nodes, txCollectionSink, config, dateProvider = new DateProvider(), log = createLogger('p2p:tx_collection_service'), missingTxsCollector){
|
|
24
20
|
this.nodes = nodes;
|
|
25
21
|
this.txCollectionSink = txCollectionSink;
|
|
26
22
|
this.config = config;
|
|
@@ -28,8 +24,8 @@ export class FastTxCollection {
|
|
|
28
24
|
this.log = log;
|
|
29
25
|
this.requests = new Set();
|
|
30
26
|
const batchTxRequesterConfig = this.config;
|
|
31
|
-
const
|
|
32
|
-
this.
|
|
27
|
+
const missingTxsCollectorType = this.config.txCollectionMissingTxsCollectorType;
|
|
28
|
+
this.missingTxsCollector = missingTxsCollector ?? (missingTxsCollectorType === 'old' ? new SendBatchRequestCollector(p2pService) : new BatchTxRequesterCollector(p2pService, log, dateProvider, undefined, batchTxRequesterConfig));
|
|
33
29
|
}
|
|
34
30
|
async stop() {
|
|
35
31
|
this.requests.forEach((request)=>request.promise.reject(new AbortError(`Stopped collection service`)));
|
|
@@ -56,34 +52,32 @@ export class FastTxCollection {
|
|
|
56
52
|
// This promise is used to await for the collection to finish during the main collectFast method.
|
|
57
53
|
// It gets resolved in `foundTxs` when all txs have been collected, or rejected if the request is aborted or hits the deadline.
|
|
58
54
|
const promise = promiseWithResolvers();
|
|
59
|
-
setTimeout(()=>promise.reject(new TimeoutError(`Timed out while collecting txs`)), timeout);
|
|
55
|
+
const timeoutTimer = setTimeout(()=>promise.reject(new TimeoutError(`Timed out while collecting txs`)), timeout);
|
|
60
56
|
const request = {
|
|
61
57
|
...input,
|
|
62
58
|
blockInfo,
|
|
63
59
|
promise,
|
|
64
|
-
|
|
65
|
-
missingTxHashes: new Set(txHashes.map((t)=>t.toString())),
|
|
60
|
+
missingTxTracker: MissingTxsTracker.fromArray(txHashes),
|
|
66
61
|
deadline: opts.deadline
|
|
67
62
|
};
|
|
68
63
|
const [duration] = await elapsed(()=>this.collectFast(request, {
|
|
69
64
|
...opts
|
|
70
65
|
}));
|
|
71
|
-
|
|
66
|
+
clearTimeout(timeoutTimer);
|
|
67
|
+
this.log.verbose(`Collected ${request.missingTxTracker.collectedTxs.length} txs out of ${txHashes.length} for ${input.type} at slot ${blockInfo.slotNumber}`, {
|
|
72
68
|
...blockInfo,
|
|
73
69
|
duration,
|
|
74
70
|
requestType: input.type,
|
|
75
71
|
missingTxs: [
|
|
76
|
-
...request.missingTxHashes
|
|
72
|
+
...request.missingTxTracker.missingTxHashes
|
|
77
73
|
]
|
|
78
74
|
});
|
|
79
|
-
return
|
|
80
|
-
...request.foundTxs.values()
|
|
81
|
-
];
|
|
75
|
+
return request.missingTxTracker.collectedTxs;
|
|
82
76
|
}
|
|
83
77
|
async collectFast(request, opts) {
|
|
84
78
|
this.requests.add(request);
|
|
85
79
|
const { blockInfo } = request;
|
|
86
|
-
this.log.debug(`Starting fast collection of ${request.
|
|
80
|
+
this.log.debug(`Starting fast collection of ${request.missingTxTracker.numberOfMissingTxs} txs for ${request.type} at slot ${blockInfo.slotNumber}`, {
|
|
87
81
|
...blockInfo,
|
|
88
82
|
requestType: request.type,
|
|
89
83
|
deadline: opts.deadline
|
|
@@ -99,7 +93,7 @@ export class FastTxCollection {
|
|
|
99
93
|
waitBeforeReqResp
|
|
100
94
|
]);
|
|
101
95
|
// If we have collected all txs, we can stop here
|
|
102
|
-
if (request.
|
|
96
|
+
if (request.missingTxTracker.allFetched()) {
|
|
103
97
|
this.log.debug(`All txs collected for slot ${blockInfo.slotNumber} without reqresp`, blockInfo);
|
|
104
98
|
return;
|
|
105
99
|
}
|
|
@@ -118,9 +112,7 @@ export class FastTxCollection {
|
|
|
118
112
|
const logCtx = {
|
|
119
113
|
...blockInfo,
|
|
120
114
|
errorMessage: err instanceof Error ? err.message : undefined,
|
|
121
|
-
missingTxs:
|
|
122
|
-
...request.missingTxHashes
|
|
123
|
-
].map((txHash)=>txHash.toString())
|
|
115
|
+
missingTxs: request.missingTxTracker.missingTxHashes.values().map((txHash)=>txHash.toString())
|
|
124
116
|
};
|
|
125
117
|
if (err instanceof Error && err.name === 'TimeoutError') {
|
|
126
118
|
this.log.warn(`Timed out collecting txs for ${request.type} at slot ${blockInfo.slotNumber}`, logCtx);
|
|
@@ -146,7 +138,7 @@ export class FastTxCollection {
|
|
|
146
138
|
}
|
|
147
139
|
// Keep a shared priority queue of all txs pending to be requested, sorted by the number of attempts made to collect them.
|
|
148
140
|
const attemptsPerTx = [
|
|
149
|
-
...request.missingTxHashes
|
|
141
|
+
...request.missingTxTracker.missingTxHashes
|
|
150
142
|
].map((txHash)=>({
|
|
151
143
|
txHash,
|
|
152
144
|
attempts: 0,
|
|
@@ -156,7 +148,7 @@ export class FastTxCollection {
|
|
|
156
148
|
await Promise.allSettled(this.nodes.map((node)=>this.collectFastFromNode(request, node, attemptsPerTx, opts)));
|
|
157
149
|
}
|
|
158
150
|
async collectFastFromNode(request, node, attemptsPerTx, opts) {
|
|
159
|
-
const notFinished = ()=>this.dateProvider.now() <= +opts.deadline && request.
|
|
151
|
+
const notFinished = ()=>this.dateProvider.now() <= +opts.deadline && !request.missingTxTracker.allFetched() && this.requests.has(request);
|
|
160
152
|
const maxParallelRequests = this.config.txCollectionFastMaxParallelRequestsPerNode;
|
|
161
153
|
const maxBatchSize = this.config.txCollectionNodeRpcMaxBatchSize;
|
|
162
154
|
const activeRequestsToThisNode = new Set(); // Track the txs being actively requested to this node
|
|
@@ -170,7 +162,7 @@ export class FastTxCollection {
|
|
|
170
162
|
const txToRequest = attemptsPerTx[index++];
|
|
171
163
|
if (!txToRequest) {
|
|
172
164
|
break;
|
|
173
|
-
} else if (!request.
|
|
165
|
+
} else if (!request.missingTxTracker.isMissing(txToRequest.txHash)) {
|
|
174
166
|
// Mark as found if it was found somewhere else, we'll then remove it from the array.
|
|
175
167
|
// We don't delete it now since 'array.splice' is pretty expensive, so we do it after sorting.
|
|
176
168
|
txToRequest.found = true;
|
|
@@ -194,13 +186,20 @@ export class FastTxCollection {
|
|
|
194
186
|
if (batch.length === 0) {
|
|
195
187
|
return;
|
|
196
188
|
}
|
|
189
|
+
const txHashes = batch.map(({ txHash })=>txHash);
|
|
197
190
|
// Collect this batch from the node
|
|
198
|
-
await this.txCollectionSink.collect(
|
|
191
|
+
await this.txCollectionSink.collect(async ()=>{
|
|
192
|
+
const result = await node.getTxsByHash(txHashes.map(TxHash.fromString));
|
|
193
|
+
for (const tx of result.validTxs){
|
|
194
|
+
request.missingTxTracker.markFetched(tx);
|
|
195
|
+
}
|
|
196
|
+
return result;
|
|
197
|
+
}, txHashes, {
|
|
199
198
|
description: `fast ${node.getInfo()}`,
|
|
200
199
|
node: node.getInfo(),
|
|
201
200
|
method: 'fast-node-rpc',
|
|
202
201
|
...request.blockInfo
|
|
203
|
-
});
|
|
202
|
+
}, this.getAddContext(request));
|
|
204
203
|
// Clear from the active requests the txs we just requested
|
|
205
204
|
for (const requestedTx of batch){
|
|
206
205
|
activeRequestsToThisNode.delete(requestedTx.txHash);
|
|
@@ -217,8 +216,6 @@ export class FastTxCollection {
|
|
|
217
216
|
async collectFastViaReqResp(request, opts) {
|
|
218
217
|
const timeoutMs = +request.deadline - this.dateProvider.now();
|
|
219
218
|
const pinnedPeer = opts.pinnedPeer;
|
|
220
|
-
const maxPeers = boundInclusive(Math.ceil(request.missingTxHashes.size / 2), 8, 32);
|
|
221
|
-
const maxRetryAttempts = 5;
|
|
222
219
|
const blockInfo = request.blockInfo;
|
|
223
220
|
const slotNumber = blockInfo.slotNumber;
|
|
224
221
|
if (timeoutMs < 100) {
|
|
@@ -228,36 +225,57 @@ export class FastTxCollection {
|
|
|
228
225
|
});
|
|
229
226
|
return;
|
|
230
227
|
}
|
|
231
|
-
this.log.debug(`Starting fast reqresp for ${request.
|
|
228
|
+
this.log.debug(`Starting fast reqresp for ${request.missingTxTracker.numberOfMissingTxs} txs for ${request.type} at slot ${blockInfo.slotNumber}`, {
|
|
232
229
|
...blockInfo,
|
|
233
230
|
timeoutMs,
|
|
234
231
|
pinnedPeer
|
|
235
232
|
});
|
|
236
233
|
try {
|
|
237
|
-
await this.txCollectionSink.collect(async (
|
|
234
|
+
await this.txCollectionSink.collect(async ()=>{
|
|
235
|
+
let result;
|
|
238
236
|
if (request.type === 'proposal') {
|
|
239
|
-
|
|
237
|
+
result = await this.missingTxsCollector.collectTxs(request.missingTxTracker, request.blockProposal, pinnedPeer, timeoutMs);
|
|
240
238
|
} else if (request.type === 'block') {
|
|
241
|
-
const
|
|
242
|
-
|
|
239
|
+
const blockTxsSource = {
|
|
240
|
+
txHashes: request.block.body.txEffects.map((e)=>e.txHash),
|
|
241
|
+
archive: request.block.archive.root
|
|
242
|
+
};
|
|
243
|
+
result = await this.missingTxsCollector.collectTxs(request.missingTxTracker, blockTxsSource, pinnedPeer, timeoutMs);
|
|
243
244
|
} else {
|
|
244
245
|
throw new Error(`Unknown request type: ${request.type}`);
|
|
245
246
|
}
|
|
246
|
-
|
|
247
|
+
return {
|
|
248
|
+
validTxs: result,
|
|
249
|
+
invalidTxHashes: []
|
|
250
|
+
};
|
|
251
|
+
}, Array.from(request.missingTxTracker.missingTxHashes), {
|
|
247
252
|
description: `reqresp for slot ${slotNumber}`,
|
|
248
253
|
method: 'fast-req-resp',
|
|
249
254
|
...opts,
|
|
250
255
|
...request.blockInfo
|
|
251
|
-
});
|
|
256
|
+
}, this.getAddContext(request));
|
|
252
257
|
} catch (err) {
|
|
253
258
|
this.log.error(`Error sending fast reqresp request for txs`, err, {
|
|
254
259
|
txs: [
|
|
255
|
-
...request.missingTxHashes
|
|
260
|
+
...request.missingTxTracker.missingTxHashes
|
|
256
261
|
],
|
|
257
262
|
...blockInfo
|
|
258
263
|
});
|
|
259
264
|
}
|
|
260
265
|
}
|
|
266
|
+
/** Returns the TxAddContext for the given request, used by the sink to add txs to the pool correctly. */ getAddContext(request) {
|
|
267
|
+
if (request.type === 'proposal') {
|
|
268
|
+
return {
|
|
269
|
+
type: 'proposal',
|
|
270
|
+
blockHeader: request.blockProposal.blockHeader
|
|
271
|
+
};
|
|
272
|
+
} else {
|
|
273
|
+
return {
|
|
274
|
+
type: 'mined',
|
|
275
|
+
block: request.block
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
}
|
|
261
279
|
/**
|
|
262
280
|
* Handle txs by marking them as found for the requests that are waiting for them, and resolves the request if all its txs have been found.
|
|
263
281
|
* Called internally and from the main tx collection manager whenever the tx pool emits a tx-added event.
|
|
@@ -266,22 +284,20 @@ export class FastTxCollection {
|
|
|
266
284
|
for (const tx of txs){
|
|
267
285
|
const txHash = tx.txHash.toString();
|
|
268
286
|
// Remove the tx hash from the missing set, and add it to the found set.
|
|
269
|
-
if (request.
|
|
270
|
-
request.missingTxHashes.delete(txHash);
|
|
271
|
-
request.foundTxs.set(txHash, tx);
|
|
287
|
+
if (request.missingTxTracker.markFetched(tx)) {
|
|
272
288
|
this.log.trace(`Found tx ${txHash} for fast collection request`, {
|
|
273
289
|
...request.blockInfo,
|
|
274
290
|
txHash: tx.txHash.toString(),
|
|
275
291
|
type: request.type
|
|
276
292
|
});
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
293
|
+
}
|
|
294
|
+
// If we found all txs for this request, we resolve the promise
|
|
295
|
+
if (request.missingTxTracker.allFetched()) {
|
|
296
|
+
this.log.trace(`All txs found for fast collection request`, {
|
|
297
|
+
...request.blockInfo,
|
|
298
|
+
type: request.type
|
|
299
|
+
});
|
|
300
|
+
request.promise.resolve();
|
|
285
301
|
}
|
|
286
302
|
}
|
|
287
303
|
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { type Logger } from '@aztec/foundation/log';
|
|
2
|
+
import { DateProvider } from '@aztec/foundation/timer';
|
|
3
|
+
import { Tx, TxHash } from '@aztec/stdlib/tx';
|
|
4
|
+
import type { FileStoreTxSource } from './file_store_tx_source.js';
|
|
5
|
+
import type { TxAddContext, TxCollectionSink } from './tx_collection_sink.js';
|
|
6
|
+
/** Configuration for a FileStoreTxCollection instance. */
|
|
7
|
+
export type FileStoreCollectionConfig = {
|
|
8
|
+
workerCount: number;
|
|
9
|
+
backoffBaseMs: number;
|
|
10
|
+
backoffMaxMs: number;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Collects txs from file stores as a fallback after P2P methods have been tried.
|
|
14
|
+
* Uses a shared worker pool that pulls entries with priority (fewest attempts first),
|
|
15
|
+
* retries with round-robin across sources, and applies exponential backoff between
|
|
16
|
+
* full cycles through all sources.
|
|
17
|
+
*/
|
|
18
|
+
export declare class FileStoreTxCollection {
|
|
19
|
+
private readonly sources;
|
|
20
|
+
private readonly txCollectionSink;
|
|
21
|
+
private readonly config;
|
|
22
|
+
private readonly dateProvider;
|
|
23
|
+
private readonly log;
|
|
24
|
+
/** Map from tx hash string to entry for all pending downloads. */
|
|
25
|
+
private entries;
|
|
26
|
+
/** Worker promises for the shared worker pool. */
|
|
27
|
+
private workers;
|
|
28
|
+
/** Whether the worker pool is running. */
|
|
29
|
+
private running;
|
|
30
|
+
/** Signal used to wake sleeping workers when new entries arrive or stop is called. */
|
|
31
|
+
private wakeSignal;
|
|
32
|
+
constructor(sources: FileStoreTxSource[], txCollectionSink: TxCollectionSink, config: FileStoreCollectionConfig, dateProvider?: DateProvider, log?: Logger);
|
|
33
|
+
/** Starts the shared worker pool. */
|
|
34
|
+
start(): void;
|
|
35
|
+
/** Stops all workers and clears state. */
|
|
36
|
+
stop(): Promise<void>;
|
|
37
|
+
/** Adds entries to the shared map and wakes workers. */
|
|
38
|
+
startCollecting(txHashes: TxHash[], context: TxAddContext, deadline: Date): void;
|
|
39
|
+
/** Removes entries for txs that have been found elsewhere. */
|
|
40
|
+
foundTxs(txs: Tx[]): void;
|
|
41
|
+
/** Clears all pending entries. */
|
|
42
|
+
clearPending(): void;
|
|
43
|
+
private workerLoop;
|
|
44
|
+
/** Single-pass scan: removes expired entries, finds the best ready entry, or computes sleep time. */
|
|
45
|
+
private getNextAction;
|
|
46
|
+
/** Computes backoff for an entry. Backoff applies after a full cycle through all sources. */
|
|
47
|
+
private getBackoffMs;
|
|
48
|
+
/** Resolves the current wake signal and creates a new one. */
|
|
49
|
+
private wake;
|
|
50
|
+
private waitForWake;
|
|
51
|
+
private sleepOrWake;
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZmlsZV9zdG9yZV90eF9jb2xsZWN0aW9uLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvc2VydmljZXMvdHhfY29sbGVjdGlvbi9maWxlX3N0b3JlX3R4X2NvbGxlY3Rpb24udHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLEtBQUssTUFBTSxFQUFnQixNQUFNLHVCQUF1QixDQUFDO0FBR2xFLE9BQU8sRUFBRSxZQUFZLEVBQUUsTUFBTSx5QkFBeUIsQ0FBQztBQUN2RCxPQUFPLEVBQUUsRUFBRSxFQUFFLE1BQU0sRUFBRSxNQUFNLGtCQUFrQixDQUFDO0FBRTlDLE9BQU8sS0FBSyxFQUFFLGlCQUFpQixFQUFFLE1BQU0sMkJBQTJCLENBQUM7QUFDbkUsT0FBTyxLQUFLLEVBQUUsWUFBWSxFQUFFLGdCQUFnQixFQUFFLE1BQU0seUJBQXlCLENBQUM7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USxFQUFFLElBQUksR0FBRyxJQUFJLENBc0J0RjtJQUVELDhEQUE4RDtJQUN2RCxRQUFRLENBQUMsR0FBRyxFQUFFLEVBQUUsRUFBRSxHQUFHLElBQUksQ0FJL0I7SUFFRCxrQ0FBa0M7SUFDM0IsWUFBWSxJQUFJLElBQUksQ0FFMUI7WUFFYSxVQUFVO0lBa0N4QixxR0FBcUc7SUFDckcsT0FBTyxDQUFDLGFBQWE7SUE4QnJCLDZGQUE2RjtJQUM3RixPQUFPLENBQUMsWUFBWTtJQVFwQiw4REFBOEQ7SUFDOUQsT0FBTyxDQUFDLElBQUk7WUFNRSxXQUFXO1lBS1gsV0FBVztDQUcxQiJ9
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file_store_tx_collection.d.ts","sourceRoot":"","sources":["../../../src/services/tx_collection/file_store_tx_collection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,uBAAuB,CAAC;AAGlE,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE9C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AACnE,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAE9E,0DAA0D;AAC1D,MAAM,MAAM,yBAAyB,GAAG;IACtC,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC;AAWF;;;;;GAKG;AACH,qBAAa,qBAAqB;IAc9B,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,gBAAgB;IACjC,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,YAAY;IAC7B,OAAO,CAAC,QAAQ,CAAC,GAAG;IAjBtB,kEAAkE;IAClE,OAAO,CAAC,OAAO,CAAuC;IAEtD,kDAAkD;IAClD,OAAO,CAAC,OAAO,CAAuB;IAEtC,0CAA0C;IAC1C,OAAO,CAAC,OAAO,CAAS;IAExB,sFAAsF;IACtF,OAAO,CAAC,UAAU,CAA6B;IAE/C,YACmB,OAAO,EAAE,iBAAiB,EAAE,EAC5B,gBAAgB,EAAE,gBAAgB,EAClC,MAAM,EAAE,yBAAyB,EACjC,YAAY,GAAE,YAAiC,EAC/C,GAAG,GAAE,MAAqD,EAG5E;IAED,qCAAqC;IAC9B,KAAK,IAAI,IAAI,CASnB;IAED,0CAA0C;IAC7B,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAMjC;IAED,wDAAwD;IACjD,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,IAAI,GAAG,IAAI,CAsBtF;IAED,8DAA8D;IACvD,QAAQ,CAAC,GAAG,EAAE,EAAE,EAAE,GAAG,IAAI,CAI/B;IAED,kCAAkC;IAC3B,YAAY,IAAI,IAAI,CAE1B;YAEa,UAAU;IAkCxB,qGAAqG;IACrG,OAAO,CAAC,aAAa;IA8BrB,6FAA6F;IAC7F,OAAO,CAAC,YAAY;IAQpB,8DAA8D;IAC9D,OAAO,CAAC,IAAI;YAME,WAAW;YAKX,WAAW;CAG1B"}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { createLogger } from '@aztec/foundation/log';
|
|
2
|
+
import { promiseWithResolvers } from '@aztec/foundation/promise';
|
|
3
|
+
import { sleep } from '@aztec/foundation/sleep';
|
|
4
|
+
import { DateProvider } from '@aztec/foundation/timer';
|
|
5
|
+
import { TxHash } from '@aztec/stdlib/tx';
|
|
6
|
+
/**
|
|
7
|
+
* Collects txs from file stores as a fallback after P2P methods have been tried.
|
|
8
|
+
* Uses a shared worker pool that pulls entries with priority (fewest attempts first),
|
|
9
|
+
* retries with round-robin across sources, and applies exponential backoff between
|
|
10
|
+
* full cycles through all sources.
|
|
11
|
+
*/ export class FileStoreTxCollection {
|
|
12
|
+
sources;
|
|
13
|
+
txCollectionSink;
|
|
14
|
+
config;
|
|
15
|
+
dateProvider;
|
|
16
|
+
log;
|
|
17
|
+
/** Map from tx hash string to entry for all pending downloads. */ entries;
|
|
18
|
+
/** Worker promises for the shared worker pool. */ workers;
|
|
19
|
+
/** Whether the worker pool is running. */ running;
|
|
20
|
+
/** Signal used to wake sleeping workers when new entries arrive or stop is called. */ wakeSignal;
|
|
21
|
+
constructor(sources, txCollectionSink, config, dateProvider = new DateProvider(), log = createLogger('p2p:file_store_tx_collection')){
|
|
22
|
+
this.sources = sources;
|
|
23
|
+
this.txCollectionSink = txCollectionSink;
|
|
24
|
+
this.config = config;
|
|
25
|
+
this.dateProvider = dateProvider;
|
|
26
|
+
this.log = log;
|
|
27
|
+
this.entries = new Map();
|
|
28
|
+
this.workers = [];
|
|
29
|
+
this.running = false;
|
|
30
|
+
this.wakeSignal = promiseWithResolvers();
|
|
31
|
+
}
|
|
32
|
+
/** Starts the shared worker pool. */ start() {
|
|
33
|
+
if (this.sources.length === 0) {
|
|
34
|
+
this.log.debug('No file store sources configured');
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
this.running = true;
|
|
38
|
+
for(let i = 0; i < this.config.workerCount; i++){
|
|
39
|
+
this.workers.push(this.workerLoop());
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
/** Stops all workers and clears state. */ async stop() {
|
|
43
|
+
this.running = false;
|
|
44
|
+
this.wake();
|
|
45
|
+
await Promise.all(this.workers);
|
|
46
|
+
this.workers = [];
|
|
47
|
+
this.entries.clear();
|
|
48
|
+
}
|
|
49
|
+
/** Adds entries to the shared map and wakes workers. */ startCollecting(txHashes, context, deadline) {
|
|
50
|
+
if (this.sources.length === 0 || txHashes.length === 0) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
if (+deadline <= this.dateProvider.now()) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
for (const txHash of txHashes){
|
|
57
|
+
const hashStr = txHash.toString();
|
|
58
|
+
if (!this.entries.has(hashStr)) {
|
|
59
|
+
this.entries.set(hashStr, {
|
|
60
|
+
txHash: hashStr,
|
|
61
|
+
context,
|
|
62
|
+
deadline,
|
|
63
|
+
attempts: 0,
|
|
64
|
+
lastAttemptTime: 0,
|
|
65
|
+
nextSourceIndex: Math.floor(Math.random() * this.sources.length)
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
this.wake();
|
|
70
|
+
}
|
|
71
|
+
/** Removes entries for txs that have been found elsewhere. */ foundTxs(txs) {
|
|
72
|
+
for (const tx of txs){
|
|
73
|
+
this.entries.delete(tx.getTxHash().toString());
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
/** Clears all pending entries. */ clearPending() {
|
|
77
|
+
this.entries.clear();
|
|
78
|
+
}
|
|
79
|
+
async workerLoop() {
|
|
80
|
+
while(this.running){
|
|
81
|
+
const action = this.getNextAction();
|
|
82
|
+
if (action.type === 'sleep') {
|
|
83
|
+
await action.promise;
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
const entry = action.entry;
|
|
87
|
+
const source = this.sources[entry.nextSourceIndex % this.sources.length];
|
|
88
|
+
entry.nextSourceIndex++;
|
|
89
|
+
entry.attempts++;
|
|
90
|
+
entry.lastAttemptTime = this.dateProvider.now();
|
|
91
|
+
try {
|
|
92
|
+
const result = await this.txCollectionSink.collect(()=>source.getTxsByHash([
|
|
93
|
+
TxHash.fromString(entry.txHash)
|
|
94
|
+
]), [
|
|
95
|
+
entry.txHash
|
|
96
|
+
], {
|
|
97
|
+
description: `file-store ${source.getInfo()}`,
|
|
98
|
+
method: 'file-store',
|
|
99
|
+
fileStore: source.getInfo()
|
|
100
|
+
}, entry.context);
|
|
101
|
+
if (result.txs.length > 0) {
|
|
102
|
+
this.entries.delete(entry.txHash);
|
|
103
|
+
}
|
|
104
|
+
} catch (err) {
|
|
105
|
+
this.log.trace(`Error downloading tx ${entry.txHash} from ${source.getInfo()}`, {
|
|
106
|
+
err
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
/** Single-pass scan: removes expired entries, finds the best ready entry, or computes sleep time. */ getNextAction() {
|
|
112
|
+
const now = this.dateProvider.now();
|
|
113
|
+
let best;
|
|
114
|
+
let earliestReadyAt = Infinity;
|
|
115
|
+
for (const [key, entry] of this.entries){
|
|
116
|
+
if (+entry.deadline <= now) {
|
|
117
|
+
this.entries.delete(key);
|
|
118
|
+
continue;
|
|
119
|
+
}
|
|
120
|
+
const backoffMs = this.getBackoffMs(entry);
|
|
121
|
+
const readyAt = entry.lastAttemptTime + backoffMs;
|
|
122
|
+
if (readyAt > now) {
|
|
123
|
+
earliestReadyAt = Math.min(earliestReadyAt, readyAt);
|
|
124
|
+
continue;
|
|
125
|
+
}
|
|
126
|
+
if (!best || entry.attempts < best.attempts) {
|
|
127
|
+
best = entry;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
if (best) {
|
|
131
|
+
return {
|
|
132
|
+
type: 'process',
|
|
133
|
+
entry: best
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
if (earliestReadyAt < Infinity) {
|
|
137
|
+
return {
|
|
138
|
+
type: 'sleep',
|
|
139
|
+
promise: this.sleepOrWake(earliestReadyAt - now)
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
return {
|
|
143
|
+
type: 'sleep',
|
|
144
|
+
promise: this.waitForWake()
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
/** Computes backoff for an entry. Backoff applies after a full cycle through all sources. */ getBackoffMs(entry) {
|
|
148
|
+
const fullCycles = Math.floor(entry.attempts / this.sources.length);
|
|
149
|
+
if (fullCycles === 0) {
|
|
150
|
+
return 0;
|
|
151
|
+
}
|
|
152
|
+
return Math.min(this.config.backoffBaseMs * Math.pow(2, fullCycles - 1), this.config.backoffMaxMs);
|
|
153
|
+
}
|
|
154
|
+
/** Resolves the current wake signal and creates a new one. */ wake() {
|
|
155
|
+
this.wakeSignal.resolve();
|
|
156
|
+
this.wakeSignal = promiseWithResolvers();
|
|
157
|
+
}
|
|
158
|
+
/** Waits until the wake signal is resolved. */ async waitForWake() {
|
|
159
|
+
await this.wakeSignal.promise;
|
|
160
|
+
}
|
|
161
|
+
/** Sleeps for the given duration or until the wake signal is resolved. */ async sleepOrWake(ms) {
|
|
162
|
+
await Promise.race([
|
|
163
|
+
sleep(ms),
|
|
164
|
+
this.wakeSignal.promise
|
|
165
|
+
]);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { type Logger } from '@aztec/foundation/log';
|
|
2
|
+
import { type TxHash } from '@aztec/stdlib/tx';
|
|
3
|
+
import { type TelemetryClient } from '@aztec/telemetry-client';
|
|
4
|
+
import type { TxSource, TxSourceCollectionResult } from './tx_source.js';
|
|
5
|
+
/** TxSource implementation that downloads txs from a file store. */
|
|
6
|
+
export declare class FileStoreTxSource implements TxSource {
|
|
7
|
+
private readonly fileStore;
|
|
8
|
+
private readonly baseUrl;
|
|
9
|
+
private readonly basePath;
|
|
10
|
+
private readonly log;
|
|
11
|
+
private downloadsSuccess;
|
|
12
|
+
private downloadsFailed;
|
|
13
|
+
private downloadDuration;
|
|
14
|
+
private downloadSize;
|
|
15
|
+
private constructor();
|
|
16
|
+
/**
|
|
17
|
+
* Creates a FileStoreTxSource from a URL.
|
|
18
|
+
* @param url - The file store URL (s3://, gs://, file://, http://, https://).
|
|
19
|
+
* @param basePath - Base path for tx files within the store.
|
|
20
|
+
* @param log - Optional logger.
|
|
21
|
+
* @param telemetry - Optional telemetry client.
|
|
22
|
+
* @returns The FileStoreTxSource instance, or undefined if creation fails.
|
|
23
|
+
*/
|
|
24
|
+
static create(url: string, basePath: string, log?: Logger, telemetry?: TelemetryClient): Promise<FileStoreTxSource | undefined>;
|
|
25
|
+
getInfo(): string;
|
|
26
|
+
getTxsByHash(txHashes: TxHash[]): Promise<TxSourceCollectionResult>;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Creates FileStoreTxSource instances from URLs.
|
|
30
|
+
* @param urls - Array of file store URLs.
|
|
31
|
+
* @param basePath - Base path for tx files within each store.
|
|
32
|
+
* @param log - Optional logger.
|
|
33
|
+
* @param telemetry - Optional telemetry client.
|
|
34
|
+
* @returns Array of successfully created FileStoreTxSource instances.
|
|
35
|
+
*/
|
|
36
|
+
export declare function createFileStoreTxSources(urls: string[], basePath: string, log?: Logger, telemetry?: TelemetryClient): Promise<FileStoreTxSource[]>;
|
|
37
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZmlsZV9zdG9yZV90eF9zb3VyY2UuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9zZXJ2aWNlcy90eF9jb2xsZWN0aW9uL2ZpbGVfc3RvcmVfdHhfc291cmNlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxLQUFLLE1BQU0sRUFBZ0IsTUFBTSx1QkFBdUIsQ0FBQztBQUdsRSxPQUFPLEVBQU0sS0FBSyxNQUFNLEVBQUUsTUFBTSxrQkFBa0IsQ0FBQztBQUNuRCxPQUFPLEVBR0wsS0FBSyxlQUFlLEVBR3JCLE1BQU0seUJBQXlCLENBQUM7QUFFakMsT0FBTyxLQUFLLEVBQUUsUUFBUSxFQUFFLHdCQUF3QixFQUFFLE1BQU0sZ0JBQWdCLENBQUM7QUFFekUsb0VBQW9FO0FBQ3BFLHFCQUFhLGlCQUFrQixZQUFXLFFBQVE7SUFPOUMsT0FBTyxDQUFDLFFBQVEsQ0FBQyxTQUFTO0lBQzFCLE9BQU8sQ0FBQyxRQUFRLENBQUMsT0FBTztJQUN4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