@aztec/p2p 0.0.1-commit.e6bd8901 → 0.0.1-commit.ec5f612
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 +10 -10
- package/dest/client/factory.d.ts.map +1 -1
- package/dest/client/factory.js +45 -18
- package/dest/client/interface.d.ts +46 -33
- package/dest/client/interface.d.ts.map +1 -1
- package/dest/client/p2p_client.d.ts +41 -51
- package/dest/client/p2p_client.d.ts.map +1 -1
- package/dest/client/p2p_client.js +156 -200
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.d.ts +2 -0
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.d.ts.map +1 -0
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.js +304 -0
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker_protocol.d.ts +73 -0
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker_protocol.d.ts.map +1 -0
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker_protocol.js +8 -0
- package/dest/config.d.ts +35 -7
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +21 -7
- 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/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 +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 +97 -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 +78 -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 +211 -0
- package/dest/mem_pools/tx_pool_v2/interfaces.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/interfaces.js +9 -0
- package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts +119 -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 +193 -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 +354 -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 +905 -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/proposal_validator/proposal_validator.js +5 -5
- package/dest/msg_validators/tx_validator/aggregate_tx_validator.d.ts +4 -4
- package/dest/msg_validators/tx_validator/aggregate_tx_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/aggregate_tx_validator.js +3 -3
- 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 +20 -6
- 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 +15 -4
- package/dest/msg_validators/tx_validator/double_spend_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/double_spend_validator.js +7 -6
- package/dest/msg_validators/tx_validator/factory.d.ts +118 -5
- package/dest/msg_validators/tx_validator/factory.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/factory.js +228 -57
- package/dest/msg_validators/tx_validator/gas_validator.d.ts +59 -3
- package/dest/msg_validators/tx_validator/gas_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/gas_validator.js +76 -38
- package/dest/msg_validators/tx_validator/index.d.ts +2 -1
- package/dest/msg_validators/tx_validator/index.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/index.js +1 -0
- 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/nullifier_cache.d.ts +14 -0
- package/dest/msg_validators/tx_validator/nullifier_cache.d.ts.map +1 -0
- package/dest/msg_validators/tx_validator/nullifier_cache.js +24 -0
- 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 +22 -5
- package/dest/msg_validators/tx_validator/timestamp_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/timestamp_validator.js +8 -8
- 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 +24 -4
- package/dest/services/dummy_service.d.ts.map +1 -1
- package/dest/services/dummy_service.js +46 -1
- package/dest/services/encoding.d.ts +3 -3
- package/dest/services/encoding.d.ts.map +1 -1
- package/dest/services/encoding.js +11 -10
- 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/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 +100 -42
- package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
- package/dest/services/libp2p/libp2p_service.js +451 -359
- 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 +33 -4
- package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts +48 -0
- package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts.map +1 -0
- package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.js +539 -0
- package/dest/services/reqresp/batch-tx-requester/config.d.ts +17 -0
- package/dest/services/reqresp/batch-tx-requester/config.d.ts.map +1 -0
- package/dest/services/reqresp/batch-tx-requester/config.js +27 -0
- package/dest/services/reqresp/batch-tx-requester/interface.d.ts +46 -0
- package/dest/services/reqresp/batch-tx-requester/interface.d.ts.map +1 -0
- package/dest/services/reqresp/batch-tx-requester/interface.js +1 -0
- package/dest/services/reqresp/batch-tx-requester/missing_txs.d.ts +34 -0
- package/dest/services/reqresp/batch-tx-requester/missing_txs.d.ts.map +1 -0
- package/dest/services/reqresp/batch-tx-requester/missing_txs.js +130 -0
- package/dest/services/reqresp/batch-tx-requester/peer_collection.d.ts +60 -0
- package/dest/services/reqresp/batch-tx-requester/peer_collection.d.ts.map +1 -0
- package/dest/services/reqresp/batch-tx-requester/peer_collection.js +173 -0
- package/dest/services/reqresp/batch-tx-requester/tx_validator.d.ts +20 -0
- package/dest/services/reqresp/batch-tx-requester/tx_validator.d.ts.map +1 -0
- package/dest/services/reqresp/batch-tx-requester/tx_validator.js +21 -0
- package/dest/services/reqresp/connection-sampler/batch_connection_sampler.d.ts +22 -3
- package/dest/services/reqresp/connection-sampler/batch_connection_sampler.d.ts.map +1 -1
- package/dest/services/reqresp/connection-sampler/batch_connection_sampler.js +63 -4
- package/dest/services/reqresp/connection-sampler/connection_sampler.d.ts +2 -1
- package/dest/services/reqresp/connection-sampler/connection_sampler.d.ts.map +1 -1
- package/dest/services/reqresp/connection-sampler/connection_sampler.js +12 -0
- package/dest/services/reqresp/interface.d.ts +12 -1
- package/dest/services/reqresp/interface.d.ts.map +1 -1
- package/dest/services/reqresp/interface.js +15 -1
- 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/bitvector.d.ts +5 -1
- package/dest/services/reqresp/protocols/block_txs/bitvector.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/block_txs/bitvector.js +5 -0
- 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 +27 -9
- package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.d.ts +29 -6
- 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 +59 -13
- 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 +6 -1
- package/dest/services/reqresp/reqresp.d.ts.map +1 -1
- package/dest/services/reqresp/reqresp.js +71 -27
- package/dest/services/service.d.ts +42 -3
- package/dest/services/service.d.ts.map +1 -1
- package/dest/services/tx_collection/config.d.ts +22 -1
- package/dest/services/tx_collection/config.d.ts.map +1 -1
- package/dest/services/tx_collection/config.js +55 -1
- package/dest/services/tx_collection/fast_tx_collection.d.ts +7 -4
- package/dest/services/tx_collection/fast_tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/fast_tx_collection.js +71 -44
- 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 -1
- package/dest/services/tx_collection/index.d.ts.map +1 -1
- package/dest/services/tx_collection/index.js +2 -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 +10 -2
- 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 +49 -0
- package/dest/services/tx_collection/proposal_tx_collector.d.ts.map +1 -0
- package/dest/services/tx_collection/proposal_tx_collector.js +50 -0
- 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 +25 -12
- package/dest/services/tx_collection/tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/tx_collection.js +79 -7
- 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 +4 -4
- package/dest/services/tx_provider.d.ts.map +1 -1
- package/dest/services/tx_provider.js +9 -8
- 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/index.d.ts +3 -1
- package/dest/test-helpers/index.d.ts.map +1 -1
- package/dest/test-helpers/index.js +2 -0
- package/dest/test-helpers/make-test-p2p-clients.d.ts +7 -8
- package/dest/test-helpers/make-test-p2p-clients.d.ts.map +1 -1
- package/dest/test-helpers/make-test-p2p-clients.js +1 -2
- package/dest/test-helpers/mock-pubsub.d.ts +30 -4
- package/dest/test-helpers/mock-pubsub.d.ts.map +1 -1
- package/dest/test-helpers/mock-pubsub.js +105 -4
- package/dest/test-helpers/reqresp-nodes.d.ts +2 -3
- package/dest/test-helpers/reqresp-nodes.d.ts.map +1 -1
- package/dest/test-helpers/reqresp-nodes.js +4 -3
- package/dest/test-helpers/test_tx_provider.d.ts +40 -0
- package/dest/test-helpers/test_tx_provider.d.ts.map +1 -0
- package/dest/test-helpers/test_tx_provider.js +41 -0
- package/dest/test-helpers/testbench-utils.d.ts +163 -0
- package/dest/test-helpers/testbench-utils.d.ts.map +1 -0
- package/dest/test-helpers/testbench-utils.js +366 -0
- package/dest/testbench/p2p_client_testbench_worker.d.ts +28 -2
- package/dest/testbench/p2p_client_testbench_worker.d.ts.map +1 -1
- package/dest/testbench/p2p_client_testbench_worker.js +219 -138
- package/dest/testbench/worker_client_manager.d.ts +51 -6
- package/dest/testbench/worker_client_manager.d.ts.map +1 -1
- package/dest/testbench/worker_client_manager.js +226 -44
- package/dest/util.d.ts +2 -2
- package/dest/util.d.ts.map +1 -1
- package/package.json +14 -14
- package/src/bootstrap/bootstrap.ts +7 -4
- package/src/client/factory.ts +83 -36
- package/src/client/interface.ts +56 -34
- package/src/client/p2p_client.ts +192 -247
- package/src/client/test/tx_proposal_collector/README.md +227 -0
- package/src/client/test/tx_proposal_collector/proposal_tx_collector_worker.ts +345 -0
- package/src/client/test/tx_proposal_collector/proposal_tx_collector_worker_protocol.ts +43 -0
- package/src/config.ts +47 -11
- 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/instrumentation.ts +2 -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 +125 -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 +91 -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 +242 -0
- package/src/mem_pools/tx_pool_v2/tx_metadata.ts +297 -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 +1083 -0
- package/src/msg_validators/attestation_validator/fisherman_attestation_validator.ts +10 -4
- package/src/msg_validators/proposal_validator/proposal_validator.ts +5 -5
- package/src/msg_validators/tx_validator/README.md +115 -0
- package/src/msg_validators/tx_validator/aggregate_tx_validator.ts +5 -5
- package/src/msg_validators/tx_validator/archive_cache.ts +3 -3
- package/src/msg_validators/tx_validator/block_header_validator.ts +21 -8
- package/src/msg_validators/tx_validator/data_validator.ts +6 -2
- package/src/msg_validators/tx_validator/double_spend_validator.ts +15 -9
- package/src/msg_validators/tx_validator/factory.ts +372 -55
- package/src/msg_validators/tx_validator/gas_validator.ts +98 -29
- package/src/msg_validators/tx_validator/index.ts +1 -0
- package/src/msg_validators/tx_validator/metadata_validator.ts +6 -3
- package/src/msg_validators/tx_validator/nullifier_cache.ts +30 -0
- 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 +29 -21
- 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 +59 -2
- package/src/services/encoding.ts +9 -9
- 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/instrumentation.ts +15 -2
- package/src/services/libp2p/libp2p_service.ts +496 -397
- package/src/services/peer-manager/metrics.ts +21 -4
- package/src/services/peer-manager/peer_scoring.ts +29 -1
- package/src/services/reqresp/batch-tx-requester/README.md +305 -0
- package/src/services/reqresp/batch-tx-requester/batch_tx_requester.ts +678 -0
- package/src/services/reqresp/batch-tx-requester/config.ts +40 -0
- package/src/services/reqresp/batch-tx-requester/interface.ts +53 -0
- package/src/services/reqresp/batch-tx-requester/missing_txs.ts +161 -0
- package/src/services/reqresp/batch-tx-requester/peer_collection.ts +244 -0
- package/src/services/reqresp/batch-tx-requester/tx_validator.ts +37 -0
- package/src/services/reqresp/connection-sampler/batch_connection_sampler.ts +65 -4
- package/src/services/reqresp/connection-sampler/connection_sampler.ts +16 -0
- package/src/services/reqresp/interface.ts +29 -1
- package/src/services/reqresp/metrics.ts +34 -9
- package/src/services/reqresp/protocols/block_txs/bitvector.ts +7 -0
- package/src/services/reqresp/protocols/block_txs/block_txs_handler.ts +35 -12
- package/src/services/reqresp/protocols/block_txs/block_txs_reqresp.ts +74 -9
- package/src/services/reqresp/protocols/tx.ts +22 -0
- package/src/services/reqresp/reqresp.ts +82 -23
- package/src/services/service.ts +55 -2
- package/src/services/tx_collection/config.ts +83 -1
- package/src/services/tx_collection/fast_tx_collection.ts +93 -47
- 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 +6 -0
- package/src/services/tx_collection/instrumentation.ts +17 -2
- package/src/services/tx_collection/missing_txs_tracker.ts +52 -0
- package/src/services/tx_collection/proposal_tx_collector.ts +113 -0
- package/src/services/tx_collection/slow_tx_collection.ts +66 -33
- package/src/services/tx_collection/tx_collection.ts +117 -20
- 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 +10 -9
- package/src/services/tx_provider_instrumentation.ts +11 -5
- package/src/test-helpers/index.ts +2 -0
- package/src/test-helpers/make-test-p2p-clients.ts +3 -5
- package/src/test-helpers/mock-pubsub.ts +146 -9
- package/src/test-helpers/reqresp-nodes.ts +4 -6
- package/src/test-helpers/test_tx_provider.ts +64 -0
- package/src/test-helpers/testbench-utils.ts +430 -0
- package/src/testbench/p2p_client_testbench_worker.ts +333 -131
- package/src/testbench/worker_client_manager.ts +304 -47
- 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
|
@@ -1,15 +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 {
|
|
8
|
+
import { MissingTxsTracker } from './missing_txs_tracker.js';
|
|
9
|
+
import { BatchTxRequesterCollector, SendBatchRequestCollector } from './proposal_tx_collector.js';
|
|
11
10
|
export class FastTxCollection {
|
|
12
|
-
reqResp;
|
|
13
11
|
nodes;
|
|
14
12
|
txCollectionSink;
|
|
15
13
|
config;
|
|
@@ -17,14 +15,17 @@ export class FastTxCollection {
|
|
|
17
15
|
log;
|
|
18
16
|
// eslint-disable-next-line aztec-custom/no-non-primitive-in-collections
|
|
19
17
|
requests;
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
missingTxsCollector;
|
|
19
|
+
constructor(p2pService, nodes, txCollectionSink, config, dateProvider = new DateProvider(), log = createLogger('p2p:tx_collection_service'), missingTxsCollector){
|
|
22
20
|
this.nodes = nodes;
|
|
23
21
|
this.txCollectionSink = txCollectionSink;
|
|
24
22
|
this.config = config;
|
|
25
23
|
this.dateProvider = dateProvider;
|
|
26
24
|
this.log = log;
|
|
27
25
|
this.requests = new Set();
|
|
26
|
+
const batchTxRequesterConfig = this.config;
|
|
27
|
+
const missingTxsCollectorType = this.config.txCollectionMissingTxsCollectorType;
|
|
28
|
+
this.missingTxsCollector = missingTxsCollector ?? (missingTxsCollectorType === 'old' ? new SendBatchRequestCollector(p2pService) : new BatchTxRequesterCollector(p2pService, log, dateProvider, undefined, batchTxRequesterConfig));
|
|
28
29
|
}
|
|
29
30
|
async stop() {
|
|
30
31
|
this.requests.forEach((request)=>request.promise.reject(new AbortError(`Stopped collection service`)));
|
|
@@ -51,34 +52,32 @@ export class FastTxCollection {
|
|
|
51
52
|
// This promise is used to await for the collection to finish during the main collectFast method.
|
|
52
53
|
// It gets resolved in `foundTxs` when all txs have been collected, or rejected if the request is aborted or hits the deadline.
|
|
53
54
|
const promise = promiseWithResolvers();
|
|
54
|
-
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);
|
|
55
56
|
const request = {
|
|
56
57
|
...input,
|
|
57
58
|
blockInfo,
|
|
58
59
|
promise,
|
|
59
|
-
|
|
60
|
-
missingTxHashes: new Set(txHashes.map((t)=>t.toString())),
|
|
60
|
+
missingTxTracker: MissingTxsTracker.fromArray(txHashes),
|
|
61
61
|
deadline: opts.deadline
|
|
62
62
|
};
|
|
63
63
|
const [duration] = await elapsed(()=>this.collectFast(request, {
|
|
64
64
|
...opts
|
|
65
65
|
}));
|
|
66
|
-
|
|
66
|
+
clearTimeout(timeoutTimer);
|
|
67
|
+
this.log.verbose(`Collected ${request.missingTxTracker.collectedTxs.length} txs out of ${txHashes.length} for ${input.type} at slot ${blockInfo.slotNumber}`, {
|
|
67
68
|
...blockInfo,
|
|
68
69
|
duration,
|
|
69
70
|
requestType: input.type,
|
|
70
71
|
missingTxs: [
|
|
71
|
-
...request.missingTxHashes
|
|
72
|
+
...request.missingTxTracker.missingTxHashes
|
|
72
73
|
]
|
|
73
74
|
});
|
|
74
|
-
return
|
|
75
|
-
...request.foundTxs.values()
|
|
76
|
-
];
|
|
75
|
+
return request.missingTxTracker.collectedTxs;
|
|
77
76
|
}
|
|
78
77
|
async collectFast(request, opts) {
|
|
79
78
|
this.requests.add(request);
|
|
80
79
|
const { blockInfo } = request;
|
|
81
|
-
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}`, {
|
|
82
81
|
...blockInfo,
|
|
83
82
|
requestType: request.type,
|
|
84
83
|
deadline: opts.deadline
|
|
@@ -94,7 +93,7 @@ export class FastTxCollection {
|
|
|
94
93
|
waitBeforeReqResp
|
|
95
94
|
]);
|
|
96
95
|
// If we have collected all txs, we can stop here
|
|
97
|
-
if (request.
|
|
96
|
+
if (request.missingTxTracker.allFetched()) {
|
|
98
97
|
this.log.debug(`All txs collected for slot ${blockInfo.slotNumber} without reqresp`, blockInfo);
|
|
99
98
|
return;
|
|
100
99
|
}
|
|
@@ -113,9 +112,7 @@ export class FastTxCollection {
|
|
|
113
112
|
const logCtx = {
|
|
114
113
|
...blockInfo,
|
|
115
114
|
errorMessage: err instanceof Error ? err.message : undefined,
|
|
116
|
-
missingTxs:
|
|
117
|
-
...request.missingTxHashes
|
|
118
|
-
].map((txHash)=>txHash.toString())
|
|
115
|
+
missingTxs: request.missingTxTracker.missingTxHashes.values().map((txHash)=>txHash.toString())
|
|
119
116
|
};
|
|
120
117
|
if (err instanceof Error && err.name === 'TimeoutError') {
|
|
121
118
|
this.log.warn(`Timed out collecting txs for ${request.type} at slot ${blockInfo.slotNumber}`, logCtx);
|
|
@@ -141,7 +138,7 @@ export class FastTxCollection {
|
|
|
141
138
|
}
|
|
142
139
|
// Keep a shared priority queue of all txs pending to be requested, sorted by the number of attempts made to collect them.
|
|
143
140
|
const attemptsPerTx = [
|
|
144
|
-
...request.missingTxHashes
|
|
141
|
+
...request.missingTxTracker.missingTxHashes
|
|
145
142
|
].map((txHash)=>({
|
|
146
143
|
txHash,
|
|
147
144
|
attempts: 0,
|
|
@@ -151,7 +148,7 @@ export class FastTxCollection {
|
|
|
151
148
|
await Promise.allSettled(this.nodes.map((node)=>this.collectFastFromNode(request, node, attemptsPerTx, opts)));
|
|
152
149
|
}
|
|
153
150
|
async collectFastFromNode(request, node, attemptsPerTx, opts) {
|
|
154
|
-
const notFinished = ()=>this.dateProvider.now() <= +opts.deadline && request.
|
|
151
|
+
const notFinished = ()=>this.dateProvider.now() <= +opts.deadline && !request.missingTxTracker.allFetched() && this.requests.has(request);
|
|
155
152
|
const maxParallelRequests = this.config.txCollectionFastMaxParallelRequestsPerNode;
|
|
156
153
|
const maxBatchSize = this.config.txCollectionNodeRpcMaxBatchSize;
|
|
157
154
|
const activeRequestsToThisNode = new Set(); // Track the txs being actively requested to this node
|
|
@@ -165,7 +162,7 @@ export class FastTxCollection {
|
|
|
165
162
|
const txToRequest = attemptsPerTx[index++];
|
|
166
163
|
if (!txToRequest) {
|
|
167
164
|
break;
|
|
168
|
-
} else if (!request.
|
|
165
|
+
} else if (!request.missingTxTracker.isMissing(txToRequest.txHash)) {
|
|
169
166
|
// Mark as found if it was found somewhere else, we'll then remove it from the array.
|
|
170
167
|
// We don't delete it now since 'array.splice' is pretty expensive, so we do it after sorting.
|
|
171
168
|
txToRequest.found = true;
|
|
@@ -189,13 +186,20 @@ export class FastTxCollection {
|
|
|
189
186
|
if (batch.length === 0) {
|
|
190
187
|
return;
|
|
191
188
|
}
|
|
189
|
+
const txHashes = batch.map(({ txHash })=>txHash);
|
|
192
190
|
// Collect this batch from the node
|
|
193
|
-
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, {
|
|
194
198
|
description: `fast ${node.getInfo()}`,
|
|
195
199
|
node: node.getInfo(),
|
|
196
200
|
method: 'fast-node-rpc',
|
|
197
201
|
...request.blockInfo
|
|
198
|
-
});
|
|
202
|
+
}, this.getAddContext(request));
|
|
199
203
|
// Clear from the active requests the txs we just requested
|
|
200
204
|
for (const requestedTx of batch){
|
|
201
205
|
activeRequestsToThisNode.delete(requestedTx.txHash);
|
|
@@ -212,8 +216,6 @@ export class FastTxCollection {
|
|
|
212
216
|
async collectFastViaReqResp(request, opts) {
|
|
213
217
|
const timeoutMs = +request.deadline - this.dateProvider.now();
|
|
214
218
|
const pinnedPeer = opts.pinnedPeer;
|
|
215
|
-
const maxPeers = boundInclusive(Math.ceil(request.missingTxHashes.size / 2), 8, 32);
|
|
216
|
-
const maxRetryAttempts = 5;
|
|
217
219
|
const blockInfo = request.blockInfo;
|
|
218
220
|
const slotNumber = blockInfo.slotNumber;
|
|
219
221
|
if (timeoutMs < 100) {
|
|
@@ -223,30 +225,57 @@ export class FastTxCollection {
|
|
|
223
225
|
});
|
|
224
226
|
return;
|
|
225
227
|
}
|
|
226
|
-
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}`, {
|
|
227
229
|
...blockInfo,
|
|
228
230
|
timeoutMs,
|
|
229
231
|
pinnedPeer
|
|
230
232
|
});
|
|
231
233
|
try {
|
|
232
|
-
await this.txCollectionSink.collect(async (
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
234
|
+
await this.txCollectionSink.collect(async ()=>{
|
|
235
|
+
let result;
|
|
236
|
+
if (request.type === 'proposal') {
|
|
237
|
+
result = await this.missingTxsCollector.collectTxs(request.missingTxTracker, request.blockProposal, pinnedPeer, timeoutMs);
|
|
238
|
+
} else if (request.type === 'block') {
|
|
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);
|
|
244
|
+
} else {
|
|
245
|
+
throw new Error(`Unknown request type: ${request.type}`);
|
|
246
|
+
}
|
|
247
|
+
return {
|
|
248
|
+
validTxs: result,
|
|
249
|
+
invalidTxHashes: []
|
|
250
|
+
};
|
|
251
|
+
}, Array.from(request.missingTxTracker.missingTxHashes), {
|
|
236
252
|
description: `reqresp for slot ${slotNumber}`,
|
|
237
253
|
method: 'fast-req-resp',
|
|
238
254
|
...opts,
|
|
239
255
|
...request.blockInfo
|
|
240
|
-
});
|
|
256
|
+
}, this.getAddContext(request));
|
|
241
257
|
} catch (err) {
|
|
242
258
|
this.log.error(`Error sending fast reqresp request for txs`, err, {
|
|
243
259
|
txs: [
|
|
244
|
-
...request.missingTxHashes
|
|
260
|
+
...request.missingTxTracker.missingTxHashes
|
|
245
261
|
],
|
|
246
262
|
...blockInfo
|
|
247
263
|
});
|
|
248
264
|
}
|
|
249
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
|
+
}
|
|
250
279
|
/**
|
|
251
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.
|
|
252
281
|
* Called internally and from the main tx collection manager whenever the tx pool emits a tx-added event.
|
|
@@ -255,22 +284,20 @@ export class FastTxCollection {
|
|
|
255
284
|
for (const tx of txs){
|
|
256
285
|
const txHash = tx.txHash.toString();
|
|
257
286
|
// Remove the tx hash from the missing set, and add it to the found set.
|
|
258
|
-
if (request.
|
|
259
|
-
request.missingTxHashes.delete(txHash);
|
|
260
|
-
request.foundTxs.set(txHash, tx);
|
|
287
|
+
if (request.missingTxTracker.markFetched(tx)) {
|
|
261
288
|
this.log.trace(`Found tx ${txHash} for fast collection request`, {
|
|
262
289
|
...request.blockInfo,
|
|
263
290
|
txHash: tx.txHash.toString(),
|
|
264
291
|
type: request.type
|
|
265
292
|
});
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
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();
|
|
274
301
|
}
|
|
275
302
|
}
|
|
276
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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZmlsZV9zdG9yZV90eF9jb2xsZWN0aW9uLmQ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QUEwQztJQUMxQyxPQUFPLENBQUMsT0FBTyxDQUFTO0lBRXhCLHNGQUFzRjtJQUN0RixPQUFPLENBQUMsVUFBVSxDQUE2QjtJQUUvQyxZQUNtQixPQUFPLEVBQUUsaUJBQWlCLEVBQUUsRUFDNUIsZ0JBQWdCLEVBQUUsZ0JBQWdCLEVBQ2xDLE1BQU0sRUFBRSx5QkFBeUIsRUFDakMsWUFBWSxHQUFFLFlBQWlDLEVBQy9DLEdBQUcsR0FBRSxNQUFxRCxFQUc1RTtJQUVELHFDQUFxQztJQUM5QixLQUFLLElBQUksSUFBSSxDQVNuQjtJQUVELDBDQUEwQztJQUM3QixJQUFJLElBQUksT0FBTyxDQUFDLElBQUksQ0FBQyxDQU1qQztJQUVELHdEQUF3RDtJQUNqRCxlQUFlLENBQUMsUUFBUSxFQUFFLE1BQU0sRUFBRSxFQUFFLE9BQU8sRUFBRSxZQUFZLEVBQUUsUUFBUSxFQUFFLElBQUksR0FBRyxJQUFJLENBc0J0RjtJQUVELDhEQUE4RDtJQUN2RCxRQUFRLENBQUMsR0FBRyxFQUFFLEVBQUUsRUFBRSxHQUFHLElBQUksQ0FJL0I7SUFFRCxrQ0FBa0M7SUFDM0IsWUFBWSxJQUFJLElBQUksQ0FFMUI7WUFFYSxVQUFVO0lBa0N4QixxR0FBcUc7SUFDckcsT0FBTyxDQUFDLGFBQWE7SUE4QnJCLDZGQUE2RjtJQUM3RixPQUFPLENBQUMsWUFBWTtJQVFwQiw4REFBOEQ7SUFDOUQsT0FBTyxDQUFDLElBQUk7WUFNRSxXQUFXO1lBS1gsV0FBVztDQUcxQiJ9
|
|
@@ -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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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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZmlsZV9zdG9yZV90eF9zb3VyY2UuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9zZXJ2aWNlcy90eF9jb2xsZWN0aW9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AYxC;IAEM,OAAO,IAAI,MAAM,CAEvB;IAEY,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,wBAAwB,CAAC,CA+B/E;CACF;AAED;;;;;;;GAOG;AACH,wBAAsB,wBAAwB,CAC5C,IAAI,EAAE,MAAM,EAAE,EACd,QAAQ,EAAE,MAAM,EAChB,GAAG,GAAE,MAAiD,EACtD,SAAS,GAAE,eAAsC,GAChD,OAAO,CAAC,iBAAiB,EAAE,CAAC,CAG9B"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { createLogger } from '@aztec/foundation/log';
|
|
2
|
+
import { Timer } from '@aztec/foundation/timer';
|
|
3
|
+
import { createReadOnlyFileStore } from '@aztec/stdlib/file-store';
|
|
4
|
+
import { Tx } from '@aztec/stdlib/tx';
|
|
5
|
+
import { Metrics, getTelemetryClient } from '@aztec/telemetry-client';
|
|
6
|
+
/** TxSource implementation that downloads txs from a file store. */ export class FileStoreTxSource {
|
|
7
|
+
fileStore;
|
|
8
|
+
baseUrl;
|
|
9
|
+
basePath;
|
|
10
|
+
log;
|
|
11
|
+
downloadsSuccess;
|
|
12
|
+
downloadsFailed;
|
|
13
|
+
downloadDuration;
|
|
14
|
+
downloadSize;
|
|
15
|
+
constructor(fileStore, baseUrl, basePath, log, telemetry){
|
|
16
|
+
this.fileStore = fileStore;
|
|
17
|
+
this.baseUrl = baseUrl;
|
|
18
|
+
this.basePath = basePath;
|
|
19
|
+
this.log = log;
|
|
20
|
+
const meter = telemetry.getMeter('file-store-tx-source');
|
|
21
|
+
this.downloadsSuccess = meter.createUpDownCounter(Metrics.TX_FILE_STORE_DOWNLOADS_SUCCESS);
|
|
22
|
+
this.downloadsFailed = meter.createUpDownCounter(Metrics.TX_FILE_STORE_DOWNLOADS_FAILED);
|
|
23
|
+
this.downloadDuration = meter.createHistogram(Metrics.TX_FILE_STORE_DOWNLOAD_DURATION);
|
|
24
|
+
this.downloadSize = meter.createHistogram(Metrics.TX_FILE_STORE_DOWNLOAD_SIZE);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Creates a FileStoreTxSource from a URL.
|
|
28
|
+
* @param url - The file store URL (s3://, gs://, file://, http://, https://).
|
|
29
|
+
* @param basePath - Base path for tx files within the store.
|
|
30
|
+
* @param log - Optional logger.
|
|
31
|
+
* @param telemetry - Optional telemetry client.
|
|
32
|
+
* @returns The FileStoreTxSource instance, or undefined if creation fails.
|
|
33
|
+
*/ static async create(url, basePath, log = createLogger('p2p:file_store_tx_source'), telemetry = getTelemetryClient()) {
|
|
34
|
+
try {
|
|
35
|
+
const fileStore = await createReadOnlyFileStore(url, log);
|
|
36
|
+
if (!fileStore) {
|
|
37
|
+
log.warn(`Failed to create file store for URL: ${url}`);
|
|
38
|
+
return undefined;
|
|
39
|
+
}
|
|
40
|
+
return new FileStoreTxSource(fileStore, url, basePath, log, telemetry);
|
|
41
|
+
} catch (err) {
|
|
42
|
+
log.warn(`Error creating file store for URL: ${url}`, {
|
|
43
|
+
error: err
|
|
44
|
+
});
|
|
45
|
+
return undefined;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
getInfo() {
|
|
49
|
+
return `file-store:${this.baseUrl}`;
|
|
50
|
+
}
|
|
51
|
+
async getTxsByHash(txHashes) {
|
|
52
|
+
const invalidTxHashes = [];
|
|
53
|
+
return {
|
|
54
|
+
validTxs: (await Promise.all(txHashes.map(async (txHash)=>{
|
|
55
|
+
const path = `${this.basePath}/txs/${txHash.toString()}.bin`;
|
|
56
|
+
const timer = new Timer();
|
|
57
|
+
try {
|
|
58
|
+
const buffer = await this.fileStore.read(path);
|
|
59
|
+
const tx = Tx.fromBuffer(buffer);
|
|
60
|
+
if (await tx.validateTxHash() && txHash.equals(tx.txHash)) {
|
|
61
|
+
this.downloadsSuccess.add(1);
|
|
62
|
+
this.downloadDuration.record(Math.ceil(timer.ms()));
|
|
63
|
+
this.downloadSize.record(buffer.length);
|
|
64
|
+
return tx;
|
|
65
|
+
} else {
|
|
66
|
+
invalidTxHashes.push(tx.txHash.toString());
|
|
67
|
+
this.downloadsFailed.add(1);
|
|
68
|
+
return undefined;
|
|
69
|
+
}
|
|
70
|
+
} catch {
|
|
71
|
+
// Tx not found or error reading - return undefined
|
|
72
|
+
this.downloadsFailed.add(1);
|
|
73
|
+
return undefined;
|
|
74
|
+
}
|
|
75
|
+
}))).filter((tx)=>tx !== undefined),
|
|
76
|
+
invalidTxHashes: invalidTxHashes
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Creates FileStoreTxSource instances from URLs.
|
|
82
|
+
* @param urls - Array of file store URLs.
|
|
83
|
+
* @param basePath - Base path for tx files within each store.
|
|
84
|
+
* @param log - Optional logger.
|
|
85
|
+
* @param telemetry - Optional telemetry client.
|
|
86
|
+
* @returns Array of successfully created FileStoreTxSource instances.
|
|
87
|
+
*/ export async function createFileStoreTxSources(urls, basePath, log = createLogger('p2p:file_store_tx_source'), telemetry = getTelemetryClient()) {
|
|
88
|
+
const sources = await Promise.all(urls.map((url)=>FileStoreTxSource.create(url, basePath, log, telemetry)));
|
|
89
|
+
return sources.filter((s)=>s !== undefined);
|
|
90
|
+
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
export { TxCollection, type FastCollectionRequestInput } from './tx_collection.js';
|
|
2
2
|
export { type TxSource, createNodeRpcTxSources, NodeRpcTxSource } from './tx_source.js';
|
|
3
|
-
|
|
3
|
+
export { type MissingTxsCollector, BatchTxRequesterCollector, SendBatchRequestCollector, } from './proposal_tx_collector.js';
|
|
4
|
+
export { FileStoreTxSource, createFileStoreTxSources } from './file_store_tx_source.js';
|
|
5
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9zZXJ2aWNlcy90eF9jb2xsZWN0aW9uL2luZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxZQUFZLEVBQUUsS0FBSywwQkFBMEIsRUFBRSxNQUFNLG9CQUFvQixDQUFDO0FBQ25GLE9BQU8sRUFBRSxLQUFLLFFBQVEsRUFBRSxzQkFBc0IsRUFBRSxlQUFlLEVBQUUsTUFBTSxnQkFBZ0IsQ0FBQztBQUN4RixPQUFPLEVBQ0wsS0FBSyxtQkFBbUIsRUFDeEIseUJBQXlCLEVBQ3pCLHlCQUF5QixHQUMxQixNQUFNLDRCQUE0QixDQUFDO0FBQ3BDLE9BQU8sRUFBRSxpQkFBaUIsRUFBRSx3QkFBd0IsRUFBRSxNQUFNLDJCQUEyQixDQUFDIn0=
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/tx_collection/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,KAAK,0BAA0B,EAAE,MAAM,oBAAoB,CAAC;AACnF,OAAO,EAAE,KAAK,QAAQ,EAAE,sBAAsB,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/tx_collection/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,KAAK,0BAA0B,EAAE,MAAM,oBAAoB,CAAC;AACnF,OAAO,EAAE,KAAK,QAAQ,EAAE,sBAAsB,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACxF,OAAO,EACL,KAAK,mBAAmB,EACxB,yBAAyB,EACzB,yBAAyB,GAC1B,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAC"}
|
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
export { TxCollection } from './tx_collection.js';
|
|
2
2
|
export { createNodeRpcTxSources, NodeRpcTxSource } from './tx_source.js';
|
|
3
|
+
export { BatchTxRequesterCollector, SendBatchRequestCollector } from './proposal_tx_collector.js';
|
|
4
|
+
export { FileStoreTxSource, createFileStoreTxSources } from './file_store_tx_source.js';
|
|
@@ -7,4 +7,4 @@ export declare class TxCollectionInstrumentation {
|
|
|
7
7
|
constructor(client: TelemetryClient, name: string);
|
|
8
8
|
increaseTxsFor(what: CollectionMethod, count: number, duration: number): void;
|
|
9
9
|
}
|
|
10
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
10
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5zdHJ1bWVudGF0aW9uLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvc2VydmljZXMvdHhfY29sbGVjdGlvbi9pbnN0cnVtZW50YXRpb24udHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUlMLEtBQUssZUFBZSxFQUdyQixNQUFNLHlCQUF5QixDQUFDO0FBRWpDLE9BQU8sS0FBSyxFQUFFLGdCQUFnQixFQUFFLE1BQU0sb0JBQW9CLENBQUM7QUFFM0QscUJBQWEsMkJBQTJCO0lBQ3RDLE9BQU8sQ0FBQyxZQUFZLENBQWdCO0lBQ3BDLE9BQU8sQ0FBQyx1QkFBdUIsQ0FBWTtJQUMzQyxPQUFPLENBQUMsNEJBQTRCLENBQVk7SUFFaEQsWUFBWSxNQUFNLEVBQUUsZUFBZSxFQUFFLElBQUksRUFBRSxNQUFNLEVBZ0JoRDtJQUVELGNBQWMsQ0FBQyxJQUFJLEVBQUUsZ0JBQWdCLEVBQUUsS0FBSyxFQUFFLE1BQU0sRUFBRSxRQUFRLEVBQUUsTUFBTSxRQUtyRTtDQUNGIn0=
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instrumentation.d.ts","sourceRoot":"","sources":["../../../src/services/tx_collection/instrumentation.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"instrumentation.d.ts","sourceRoot":"","sources":["../../../src/services/tx_collection/instrumentation.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,eAAe,EAGrB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAE3D,qBAAa,2BAA2B;IACtC,OAAO,CAAC,YAAY,CAAgB;IACpC,OAAO,CAAC,uBAAuB,CAAY;IAC3C,OAAO,CAAC,4BAA4B,CAAY;IAEhD,YAAY,MAAM,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,EAgBhD;IAED,cAAc,CAAC,IAAI,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,QAKrE;CACF"}
|