@aztec/p2p 5.0.0-private.20260319 → 5.0.0-rc.2
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/README.md +4 -1
- package/dest/bootstrap/bootstrap.d.ts +1 -1
- package/dest/bootstrap/bootstrap.d.ts.map +1 -1
- package/dest/bootstrap/bootstrap.js +22 -6
- package/dest/client/factory.d.ts +4 -3
- package/dest/client/factory.d.ts.map +1 -1
- package/dest/client/factory.js +33 -24
- package/dest/client/interface.d.ts +43 -11
- package/dest/client/interface.d.ts.map +1 -1
- package/dest/client/p2p_client.d.ts +33 -19
- package/dest/client/p2p_client.d.ts.map +1 -1
- package/dest/client/p2p_client.js +100 -44
- package/dest/config.d.ts +137 -107
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +64 -23
- package/dest/errors/p2p-service.error.d.ts +9 -0
- package/dest/errors/p2p-service.error.d.ts.map +1 -0
- package/dest/errors/p2p-service.error.js +10 -0
- package/dest/errors/reqresp.error.d.ts +1 -20
- package/dest/errors/reqresp.error.d.ts.map +1 -1
- package/dest/errors/reqresp.error.js +0 -21
- package/dest/index.d.ts +1 -2
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +0 -1
- package/dest/mem_pools/attestation_pool/attestation_pool.d.ts +98 -56
- package/dest/mem_pools/attestation_pool/attestation_pool.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/attestation_pool.js +265 -196
- package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.d.ts +1 -1
- package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.js +175 -59
- package/dest/mem_pools/attestation_pool/mocks.d.ts +1 -1
- package/dest/mem_pools/attestation_pool/mocks.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/mocks.js +6 -4
- package/dest/mem_pools/index.d.ts +1 -2
- package/dest/mem_pools/index.d.ts.map +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 +17 -1
- package/dest/mem_pools/tx_pool_v2/archive/tx_archive.d.ts +1 -5
- package/dest/mem_pools/tx_pool_v2/archive/tx_archive.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/archive/tx_archive.js +1 -7
- package/dest/mem_pools/tx_pool_v2/deleted_pool.d.ts +3 -3
- package/dest/mem_pools/tx_pool_v2/deleted_pool.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/deleted_pool.js +6 -6
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.js +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/index.d.ts +2 -1
- package/dest/mem_pools/tx_pool_v2/eviction/index.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/index.js +1 -0
- package/dest/mem_pools/tx_pool_v2/eviction/insufficient_fee_per_gas_eviction_rule.d.ts +16 -0
- package/dest/mem_pools/tx_pool_v2/eviction/insufficient_fee_per_gas_eviction_rule.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/eviction/insufficient_fee_per_gas_eviction_rule.js +62 -0
- package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.js +2 -2
- package/dest/mem_pools/tx_pool_v2/interfaces.d.ts +22 -5
- package/dest/mem_pools/tx_pool_v2/interfaces.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts +5 -2
- package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/tx_metadata.js +13 -6
- package/dest/mem_pools/tx_pool_v2/tx_pool_indices.d.ts +7 -1
- package/dest/mem_pools/tx_pool_v2/tx_pool_indices.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/tx_pool_indices.js +10 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts +8 -3
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2.js +7 -4
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts +8 -3
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.js +153 -111
- package/dest/msg_validators/attestation_validator/attestation_validator.d.ts +10 -3
- package/dest/msg_validators/attestation_validator/attestation_validator.d.ts.map +1 -1
- package/dest/msg_validators/attestation_validator/attestation_validator.js +38 -16
- package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.d.ts +7 -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 +4 -5
- package/dest/msg_validators/proposal_validator/block_proposal_validator.d.ts +8 -3
- package/dest/msg_validators/proposal_validator/block_proposal_validator.d.ts.map +1 -1
- package/dest/msg_validators/proposal_validator/block_proposal_validator.js +2 -2
- package/dest/msg_validators/proposal_validator/checkpoint_proposal_validator.d.ts +8 -3
- package/dest/msg_validators/proposal_validator/checkpoint_proposal_validator.d.ts.map +1 -1
- package/dest/msg_validators/proposal_validator/checkpoint_proposal_validator.js +8 -2
- package/dest/msg_validators/proposal_validator/proposal_validator.d.ts +25 -3
- package/dest/msg_validators/proposal_validator/proposal_validator.d.ts.map +1 -1
- package/dest/msg_validators/proposal_validator/proposal_validator.js +77 -14
- package/dest/msg_validators/tx_validator/aggregate_tx_validator.d.ts +1 -1
- package/dest/msg_validators/tx_validator/aggregate_tx_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/aggregate_tx_validator.js +8 -15
- package/dest/msg_validators/tx_validator/allowed_public_setup.js +3 -3
- package/dest/msg_validators/tx_validator/archive_cache.js +1 -1
- package/dest/msg_validators/tx_validator/cached_tx_validator.d.ts +15 -0
- package/dest/msg_validators/tx_validator/cached_tx_validator.d.ts.map +1 -0
- package/dest/msg_validators/tx_validator/cached_tx_validator.js +19 -0
- package/dest/msg_validators/tx_validator/contract_instance_validator.d.ts +9 -0
- package/dest/msg_validators/tx_validator/contract_instance_validator.d.ts.map +1 -0
- package/dest/msg_validators/tx_validator/contract_instance_validator.js +48 -0
- package/dest/msg_validators/tx_validator/data_validator.d.ts +2 -1
- package/dest/msg_validators/tx_validator/data_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/data_validator.js +36 -2
- package/dest/msg_validators/tx_validator/factory.d.ts +14 -15
- package/dest/msg_validators/tx_validator/factory.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/factory.js +36 -17
- package/dest/msg_validators/tx_validator/gas_validator.d.ts +47 -10
- package/dest/msg_validators/tx_validator/gas_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/gas_validator.js +65 -48
- package/dest/msg_validators/tx_validator/index.d.ts +3 -1
- package/dest/msg_validators/tx_validator/index.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/index.js +2 -0
- package/dest/msg_validators/tx_validator/phases_validator.js +3 -3
- package/dest/msg_validators/tx_validator/tx_proof_validator.d.ts +2 -1
- package/dest/msg_validators/tx_validator/tx_proof_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/tx_proof_validator.js +2 -0
- package/dest/msg_validators/tx_validator/tx_validation_cache.d.ts +48 -0
- package/dest/msg_validators/tx_validator/tx_validation_cache.d.ts.map +1 -0
- package/dest/msg_validators/tx_validator/tx_validation_cache.js +68 -0
- package/dest/services/data_store.d.ts +1 -1
- package/dest/services/data_store.d.ts.map +1 -1
- package/dest/services/data_store.js +5 -5
- package/dest/services/discv5/discV5_service.d.ts +13 -2
- package/dest/services/discv5/discV5_service.d.ts.map +1 -1
- package/dest/services/discv5/discV5_service.js +119 -23
- package/dest/services/discv5/persisted_enr_store.d.ts +38 -0
- package/dest/services/discv5/persisted_enr_store.d.ts.map +1 -0
- package/dest/services/discv5/persisted_enr_store.js +145 -0
- package/dest/services/dummy_service.d.ts +15 -15
- package/dest/services/dummy_service.d.ts.map +1 -1
- package/dest/services/dummy_service.js +15 -16
- package/dest/services/encoding.d.ts +8 -8
- package/dest/services/encoding.d.ts.map +1 -1
- package/dest/services/encoding.js +11 -15
- package/dest/services/gossipsub/topic_score_params.d.ts +6 -12
- package/dest/services/gossipsub/topic_score_params.d.ts.map +1 -1
- package/dest/services/gossipsub/topic_score_params.js +4 -14
- package/dest/services/libp2p/instrumentation.d.ts +3 -1
- package/dest/services/libp2p/instrumentation.d.ts.map +1 -1
- package/dest/services/libp2p/instrumentation.js +14 -0
- package/dest/services/libp2p/libp2p_service.d.ts +44 -39
- package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
- package/dest/services/libp2p/libp2p_service.js +383 -278
- package/dest/services/peer-manager/peer_manager.d.ts +20 -3
- package/dest/services/peer-manager/peer_manager.d.ts.map +1 -1
- package/dest/services/peer-manager/peer_manager.js +79 -23
- package/dest/services/peer-manager/peer_scoring.d.ts +34 -2
- package/dest/services/peer-manager/peer_scoring.d.ts.map +1 -1
- package/dest/services/peer-manager/peer_scoring.js +102 -13
- package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts +1 -8
- package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts.map +1 -1
- package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.js +38 -44
- package/dest/services/reqresp/batch-tx-requester/interface.d.ts +8 -5
- package/dest/services/reqresp/batch-tx-requester/interface.d.ts.map +1 -1
- package/dest/services/reqresp/batch-tx-requester/tx_validator.d.ts +5 -14
- package/dest/services/reqresp/batch-tx-requester/tx_validator.d.ts.map +1 -1
- package/dest/services/reqresp/batch-tx-requester/tx_validator.js +6 -20
- package/dest/services/reqresp/config.d.ts +3 -3
- package/dest/services/reqresp/config.d.ts.map +1 -1
- package/dest/services/reqresp/interface.d.ts +16 -18
- package/dest/services/reqresp/interface.d.ts.map +1 -1
- package/dest/services/reqresp/interface.js +10 -20
- package/dest/services/reqresp/metrics.d.ts +1 -1
- package/dest/services/reqresp/metrics.d.ts.map +1 -1
- package/dest/services/reqresp/metrics.js +0 -1
- package/dest/services/reqresp/protocols/block_txs/bitvector.d.ts +4 -3
- package/dest/services/reqresp/protocols/block_txs/bitvector.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/block_txs/bitvector.js +3 -2
- package/dest/services/reqresp/protocols/block_txs/block_txs_handler.d.ts +1 -1
- package/dest/services/reqresp/protocols/block_txs/block_txs_handler.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/block_txs/block_txs_handler.js +31 -28
- package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.d.ts +12 -7
- package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.js +42 -24
- package/dest/services/reqresp/protocols/index.d.ts +1 -2
- package/dest/services/reqresp/protocols/index.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/index.js +0 -1
- package/dest/services/reqresp/protocols/tx.d.ts +1 -1
- package/dest/services/reqresp/protocols/tx.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/tx.js +1 -3
- package/dest/services/reqresp/rate-limiter/rate_limiter.d.ts +5 -4
- package/dest/services/reqresp/rate-limiter/rate_limiter.d.ts.map +1 -1
- package/dest/services/reqresp/rate-limiter/rate_limiter.js +10 -8
- package/dest/services/reqresp/rate-limiter/rate_limits.d.ts +1 -1
- package/dest/services/reqresp/rate-limiter/rate_limits.d.ts.map +1 -1
- package/dest/services/reqresp/rate-limiter/rate_limits.js +0 -10
- package/dest/services/reqresp/reqresp.d.ts +7 -29
- package/dest/services/reqresp/reqresp.d.ts.map +1 -1
- package/dest/services/reqresp/reqresp.js +26 -207
- package/dest/services/service.d.ts +25 -12
- package/dest/services/service.d.ts.map +1 -1
- package/dest/services/tx_collection/config.d.ts +2 -23
- package/dest/services/tx_collection/config.d.ts.map +1 -1
- package/dest/services/tx_collection/config.js +2 -55
- package/dest/services/tx_collection/file_store_tx_collection.d.ts +12 -28
- package/dest/services/tx_collection/file_store_tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/file_store_tx_collection.js +43 -83
- package/dest/services/tx_collection/file_store_tx_source.d.ts +5 -4
- package/dest/services/tx_collection/file_store_tx_source.d.ts.map +1 -1
- package/dest/services/tx_collection/file_store_tx_source.js +39 -29
- package/dest/services/tx_collection/index.d.ts +2 -3
- package/dest/services/tx_collection/index.d.ts.map +1 -1
- package/dest/services/tx_collection/index.js +0 -1
- package/dest/services/tx_collection/instrumentation.d.ts +1 -1
- package/dest/services/tx_collection/instrumentation.d.ts.map +1 -1
- package/dest/services/tx_collection/instrumentation.js +0 -2
- package/dest/services/tx_collection/tx_collection.d.ts +35 -51
- package/dest/services/tx_collection/tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/tx_collection.js +275 -119
- package/dest/services/tx_collection/tx_collection_sink.d.ts +1 -1
- package/dest/services/tx_collection/tx_collection_sink.js +2 -2
- package/dest/services/tx_collection/tx_source.d.ts +6 -5
- package/dest/services/tx_collection/tx_source.d.ts.map +1 -1
- package/dest/services/tx_collection/tx_source.js +13 -8
- package/dest/services/tx_file_store/tx_file_store.d.ts +1 -3
- package/dest/services/tx_file_store/tx_file_store.d.ts.map +1 -1
- package/dest/services/tx_file_store/tx_file_store.js +4 -14
- package/dest/services/tx_provider.d.ts +3 -1
- package/dest/services/tx_provider.d.ts.map +1 -1
- package/dest/services/tx_provider.js +3 -0
- package/dest/test-helpers/make-test-p2p-clients.d.ts +1 -1
- package/dest/test-helpers/make-test-p2p-clients.d.ts.map +1 -1
- package/dest/test-helpers/make-test-p2p-clients.js +5 -2
- package/dest/test-helpers/mock-pubsub.d.ts +23 -9
- package/dest/test-helpers/mock-pubsub.d.ts.map +1 -1
- package/dest/test-helpers/mock-pubsub.js +44 -44
- package/dest/test-helpers/reqresp-nodes.d.ts +4 -5
- package/dest/test-helpers/reqresp-nodes.d.ts.map +1 -1
- package/dest/test-helpers/reqresp-nodes.js +16 -18
- package/dest/test-helpers/test_tx_provider.d.ts +3 -1
- package/dest/test-helpers/test_tx_provider.d.ts.map +1 -1
- package/dest/test-helpers/test_tx_provider.js +3 -0
- package/dest/test-helpers/testbench-utils.d.ts +14 -14
- package/dest/test-helpers/testbench-utils.d.ts.map +1 -1
- package/dest/test-helpers/testbench-utils.js +25 -13
- package/dest/testbench/p2p_client_testbench_worker.d.ts +3 -5
- package/dest/testbench/p2p_client_testbench_worker.d.ts.map +1 -1
- package/dest/testbench/p2p_client_testbench_worker.js +102 -41
- package/dest/testbench/worker_client_manager.d.ts +10 -6
- package/dest/testbench/worker_client_manager.d.ts.map +1 -1
- package/dest/testbench/worker_client_manager.js +51 -9
- package/dest/util.d.ts +11 -6
- package/dest/util.d.ts.map +1 -1
- package/dest/util.js +35 -14
- package/dest/versioning.d.ts +3 -6
- package/dest/versioning.d.ts.map +1 -1
- package/dest/versioning.js +3 -24
- package/package.json +16 -16
- package/src/bootstrap/bootstrap.ts +17 -3
- package/src/client/factory.ts +52 -24
- package/src/client/interface.ts +38 -17
- package/src/client/p2p_client.ts +118 -76
- package/src/client/test/{tx_proposal_collector/README.md → p2p_client.batch_tx_requester.bench.README.md} +23 -53
- package/src/config.ts +130 -31
- package/src/errors/p2p-service.error.ts +11 -0
- package/src/errors/reqresp.error.ts +0 -25
- package/src/index.ts +0 -1
- package/src/mem_pools/attestation_pool/attestation_pool.ts +319 -238
- package/src/mem_pools/attestation_pool/attestation_pool_test_suite.ts +198 -62
- package/src/mem_pools/attestation_pool/mocks.ts +13 -8
- package/src/mem_pools/index.ts +0 -3
- package/src/mem_pools/instrumentation.ts +5 -1
- package/src/mem_pools/tx_pool_v2/archive/tx_archive.ts +1 -9
- package/src/mem_pools/tx_pool_v2/deleted_pool.ts +7 -7
- package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.ts +1 -1
- package/src/mem_pools/tx_pool_v2/eviction/index.ts +1 -0
- package/src/mem_pools/tx_pool_v2/eviction/insufficient_fee_per_gas_eviction_rule.ts +65 -0
- package/src/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.ts +3 -3
- package/src/mem_pools/tx_pool_v2/interfaces.ts +18 -4
- package/src/mem_pools/tx_pool_v2/tx_metadata.ts +20 -8
- package/src/mem_pools/tx_pool_v2/tx_pool_indices.ts +12 -0
- package/src/mem_pools/tx_pool_v2/tx_pool_v2.ts +8 -4
- package/src/mem_pools/tx_pool_v2/tx_pool_v2_impl.ts +163 -117
- package/src/msg_validators/attestation_validator/attestation_validator.ts +46 -15
- package/src/msg_validators/attestation_validator/fisherman_attestation_validator.ts +15 -7
- package/src/msg_validators/proposal_validator/README.md +1 -1
- package/src/msg_validators/proposal_validator/block_proposal_validator.ts +15 -3
- package/src/msg_validators/proposal_validator/checkpoint_proposal_validator.ts +26 -3
- package/src/msg_validators/proposal_validator/proposal_validator.ts +89 -11
- package/src/msg_validators/tx_validator/README.md +13 -3
- package/src/msg_validators/tx_validator/aggregate_tx_validator.ts +3 -12
- package/src/msg_validators/tx_validator/allowed_public_setup.ts +3 -3
- package/src/msg_validators/tx_validator/archive_cache.ts +1 -1
- package/src/msg_validators/tx_validator/cached_tx_validator.ts +31 -0
- package/src/msg_validators/tx_validator/contract_instance_validator.ts +56 -0
- package/src/msg_validators/tx_validator/data_validator.ts +44 -1
- package/src/msg_validators/tx_validator/factory.ts +44 -20
- package/src/msg_validators/tx_validator/gas_validator.ts +99 -54
- package/src/msg_validators/tx_validator/index.ts +2 -0
- package/src/msg_validators/tx_validator/phases_validator.ts +3 -3
- package/src/msg_validators/tx_validator/tx_proof_validator.ts +2 -0
- package/src/msg_validators/tx_validator/tx_validation_cache.ts +101 -0
- package/src/services/data_store.ts +5 -13
- package/src/services/discv5/discV5_service.ts +126 -14
- package/src/services/discv5/persisted_enr_store.ts +158 -0
- package/src/services/dummy_service.ts +20 -39
- package/src/services/encoding.ts +11 -21
- package/src/services/gossipsub/README.md +33 -11
- package/src/services/gossipsub/topic_score_params.ts +9 -18
- package/src/services/libp2p/instrumentation.ts +14 -0
- package/src/services/libp2p/libp2p_service.ts +436 -311
- package/src/services/peer-manager/peer_manager.ts +86 -22
- package/src/services/peer-manager/peer_scoring.ts +102 -8
- package/src/services/reqresp/README.md +0 -14
- package/src/services/reqresp/batch-tx-requester/batch_tx_requester.ts +42 -52
- package/src/services/reqresp/batch-tx-requester/interface.ts +11 -4
- package/src/services/reqresp/batch-tx-requester/tx_validator.ts +12 -25
- package/src/services/reqresp/config.ts +2 -2
- package/src/services/reqresp/interface.ts +21 -47
- package/src/services/reqresp/metrics.ts +0 -1
- package/src/services/reqresp/protocols/block_txs/bitvector.ts +3 -2
- package/src/services/reqresp/protocols/block_txs/block_txs_handler.ts +34 -30
- package/src/services/reqresp/protocols/block_txs/block_txs_reqresp.ts +47 -20
- package/src/services/reqresp/protocols/index.ts +0 -1
- package/src/services/reqresp/protocols/tx.ts +1 -3
- package/src/services/reqresp/rate-limiter/rate_limiter.ts +13 -9
- package/src/services/reqresp/rate-limiter/rate_limits.ts +0 -10
- package/src/services/reqresp/reqresp.ts +29 -252
- package/src/services/service.ts +31 -28
- package/src/services/tx_collection/config.ts +3 -80
- package/src/services/tx_collection/file_store_tx_collection.ts +54 -103
- package/src/services/tx_collection/file_store_tx_source.ts +43 -31
- package/src/services/tx_collection/index.ts +1 -6
- package/src/services/tx_collection/instrumentation.ts +1 -7
- package/src/services/tx_collection/tx_collection.ts +330 -173
- package/src/services/tx_collection/tx_collection_sink.ts +2 -2
- package/src/services/tx_collection/tx_source.ts +10 -8
- package/src/services/tx_file_store/tx_file_store.ts +5 -17
- package/src/services/tx_provider.ts +5 -0
- package/src/test-helpers/make-test-p2p-clients.ts +3 -0
- package/src/test-helpers/mock-pubsub.ts +46 -60
- package/src/test-helpers/reqresp-nodes.ts +12 -22
- package/src/test-helpers/test_tx_provider.ts +5 -0
- package/src/test-helpers/testbench-utils.ts +31 -26
- package/src/testbench/p2p_client_testbench_worker.ts +110 -55
- package/src/testbench/worker_client_manager.ts +59 -20
- package/src/util.ts +32 -17
- package/src/versioning.ts +3 -33
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.d.ts +0 -2
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.d.ts.map +0 -1
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.js +0 -305
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker_protocol.d.ts +0 -73
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker_protocol.d.ts.map +0 -1
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker_protocol.js +0 -8
- package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.d.ts +0 -125
- package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.js +0 -596
- package/dest/mem_pools/tx_pool/eviction/eviction_manager.d.ts +0 -32
- package/dest/mem_pools/tx_pool/eviction/eviction_manager.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/eviction/eviction_manager.js +0 -112
- package/dest/mem_pools/tx_pool/eviction/eviction_strategy.d.ts +0 -157
- package/dest/mem_pools/tx_pool/eviction/eviction_strategy.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/eviction/eviction_strategy.js +0 -52
- package/dest/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.d.ts +0 -16
- package/dest/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.js +0 -123
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.d.ts +0 -17
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.js +0 -84
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.d.ts +0 -19
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.js +0 -78
- package/dest/mem_pools/tx_pool/eviction/low_priority_eviction_rule.d.ts +0 -26
- package/dest/mem_pools/tx_pool/eviction/low_priority_eviction_rule.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/eviction/low_priority_eviction_rule.js +0 -84
- package/dest/mem_pools/tx_pool/eviction/nullifier_conflict_pre_add_rule.d.ts +0 -25
- package/dest/mem_pools/tx_pool/eviction/nullifier_conflict_pre_add_rule.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/eviction/nullifier_conflict_pre_add_rule.js +0 -57
- package/dest/mem_pools/tx_pool/index.d.ts +0 -3
- package/dest/mem_pools/tx_pool/index.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/index.js +0 -2
- package/dest/mem_pools/tx_pool/priority.d.ts +0 -12
- package/dest/mem_pools/tx_pool/priority.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/priority.js +0 -15
- package/dest/mem_pools/tx_pool/tx_pool.d.ts +0 -127
- package/dest/mem_pools/tx_pool/tx_pool.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/tx_pool.js +0 -3
- package/dest/mem_pools/tx_pool/tx_pool_test_suite.d.ts +0 -7
- package/dest/mem_pools/tx_pool/tx_pool_test_suite.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/tx_pool_test_suite.js +0 -402
- package/dest/msg_validators/clock_tolerance.d.ts +0 -21
- package/dest/msg_validators/clock_tolerance.d.ts.map +0 -1
- package/dest/msg_validators/clock_tolerance.js +0 -38
- package/dest/services/reqresp/connection-sampler/batch_connection_sampler.d.ts +0 -64
- package/dest/services/reqresp/connection-sampler/batch_connection_sampler.d.ts.map +0 -1
- package/dest/services/reqresp/connection-sampler/batch_connection_sampler.js +0 -151
- package/dest/services/reqresp/protocols/block.d.ts +0 -9
- package/dest/services/reqresp/protocols/block.d.ts.map +0 -1
- package/dest/services/reqresp/protocols/block.js +0 -32
- package/dest/services/tx_collection/fast_tx_collection.d.ts +0 -51
- package/dest/services/tx_collection/fast_tx_collection.d.ts.map +0 -1
- package/dest/services/tx_collection/fast_tx_collection.js +0 -311
- package/dest/services/tx_collection/proposal_tx_collector.d.ts +0 -48
- package/dest/services/tx_collection/proposal_tx_collector.d.ts.map +0 -1
- package/dest/services/tx_collection/proposal_tx_collector.js +0 -50
- package/dest/services/tx_collection/slow_tx_collection.d.ts +0 -57
- package/dest/services/tx_collection/slow_tx_collection.d.ts.map +0 -1
- package/dest/services/tx_collection/slow_tx_collection.js +0 -211
- package/src/client/test/tx_proposal_collector/proposal_tx_collector_worker.ts +0 -344
- package/src/client/test/tx_proposal_collector/proposal_tx_collector_worker_protocol.ts +0 -43
- package/src/mem_pools/tx_pool/README.md +0 -270
- package/src/mem_pools/tx_pool/aztec_kv_tx_pool.ts +0 -746
- package/src/mem_pools/tx_pool/eviction/eviction_manager.ts +0 -132
- package/src/mem_pools/tx_pool/eviction/eviction_strategy.ts +0 -208
- package/src/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.ts +0 -163
- package/src/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.ts +0 -104
- package/src/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.ts +0 -93
- package/src/mem_pools/tx_pool/eviction/low_priority_eviction_rule.ts +0 -106
- package/src/mem_pools/tx_pool/eviction/nullifier_conflict_pre_add_rule.ts +0 -75
- package/src/mem_pools/tx_pool/index.ts +0 -2
- package/src/mem_pools/tx_pool/priority.ts +0 -20
- package/src/mem_pools/tx_pool/tx_pool.ts +0 -141
- package/src/mem_pools/tx_pool/tx_pool_test_suite.ts +0 -321
- package/src/msg_validators/clock_tolerance.ts +0 -52
- package/src/services/reqresp/connection-sampler/batch_connection_sampler.ts +0 -161
- package/src/services/reqresp/protocols/block.ts +0 -37
- package/src/services/tx_collection/fast_tx_collection.ts +0 -361
- package/src/services/tx_collection/proposal_tx_collector.ts +0 -108
- package/src/services/tx_collection/slow_tx_collection.ts +0 -266
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type Logger } from '@aztec/foundation/log';
|
|
2
2
|
import { DateProvider } from '@aztec/foundation/timer';
|
|
3
|
-
import { Tx, TxHash } from '@aztec/stdlib/tx';
|
|
4
3
|
import type { FileStoreTxSource } from './file_store_tx_source.js';
|
|
4
|
+
import type { IRequestTracker } from './request_tracker.js';
|
|
5
5
|
import type { TxAddContext, TxCollectionSink } from './tx_collection_sink.js';
|
|
6
6
|
/** Configuration for a FileStoreTxCollection instance. */
|
|
7
7
|
export type FileStoreCollectionConfig = {
|
|
@@ -11,9 +11,10 @@ export type FileStoreCollectionConfig = {
|
|
|
11
11
|
};
|
|
12
12
|
/**
|
|
13
13
|
* Collects txs from file stores as a fallback after P2P methods have been tried.
|
|
14
|
-
*
|
|
15
|
-
* retries with round-robin across sources, and applies exponential
|
|
16
|
-
* full cycles through all sources.
|
|
14
|
+
* Each call to startCollecting spins up its own worker pool which pulls entries with priority
|
|
15
|
+
* (fewest attempts first), retries with round-robin across sources, and applies exponential
|
|
16
|
+
* backoff between full cycles through all sources. Workers self-terminate when the request
|
|
17
|
+
* tracker is cancelled (deadline / all-fetched / external) or when there is nothing left to do.
|
|
17
18
|
*/
|
|
18
19
|
export declare class FileStoreTxCollection {
|
|
19
20
|
private readonly sources;
|
|
@@ -21,33 +22,16 @@ export declare class FileStoreTxCollection {
|
|
|
21
22
|
private readonly config;
|
|
22
23
|
private readonly dateProvider;
|
|
23
24
|
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
25
|
constructor(sources: FileStoreTxSource[], txCollectionSink: TxCollectionSink, config: FileStoreCollectionConfig, dateProvider?: DateProvider, log?: Logger);
|
|
33
|
-
/**
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
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;
|
|
26
|
+
/**
|
|
27
|
+
* Spins up workers to download all txs still missing from the tracker, racing across the
|
|
28
|
+
* configured file store sources. Resolves once all workers settle.
|
|
29
|
+
*/
|
|
30
|
+
startCollecting(requestTracker: IRequestTracker, context: TxAddContext): Promise<void>;
|
|
43
31
|
private workerLoop;
|
|
44
|
-
/** Single-pass scan: removes
|
|
32
|
+
/** Single-pass scan: removes stale entries, finds the best ready entry, or computes sleep time. */
|
|
45
33
|
private getNextAction;
|
|
46
34
|
/** Computes backoff for an entry. Backoff applies after a full cycle through all sources. */
|
|
47
35
|
private getBackoffMs;
|
|
48
|
-
/** Resolves the current wake signal and creates a new one. */
|
|
49
|
-
private wake;
|
|
50
|
-
private waitForWake;
|
|
51
|
-
private sleepOrWake;
|
|
52
36
|
}
|
|
53
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
37
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZmlsZV9zdG9yZV90eF9jb2xsZWN0aW9uLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvc2VydmljZXMvdHhfY29sbGVjdGlvbi9maWxlX3N0b3JlX3R4X2NvbGxlY3Rpb24udHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQ0EsT0FBTyxFQUFFLEtBQUssTUFBTSxFQUFnQixNQUFNLHVCQUF1QixDQUFDO0FBRWxFLE9BQU8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UFhO0lBa0NyQiw2RkFBNkY7SUFDN0YsT0FBTyxDQUFDLFlBQVk7Q0FPckIifQ==
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file_store_tx_collection.d.ts","sourceRoot":"","sources":["../../../src/services/tx_collection/file_store_tx_collection.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"file_store_tx_collection.d.ts","sourceRoot":"","sources":["../../../src/services/tx_collection/file_store_tx_collection.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,uBAAuB,CAAC;AAElE,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAGvD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AACnE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC5D,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;AASF;;;;;;GAMG;AACH,qBAAa,qBAAqB;IAE9B,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;IALtB,YACmB,OAAO,EAAE,iBAAiB,EAAE,EAC5B,gBAAgB,EAAE,gBAAgB,EAClC,MAAM,EAAE,yBAAyB,EACjC,YAAY,GAAE,YAAiC,EAC/C,GAAG,GAAE,MAAqD,EACzE;IAEJ;;;OAGG;IACU,eAAe,CAAC,cAAc,EAAE,eAAe,EAAE,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAwBlG;YAEa,UAAU;IAuCxB,mGAAmG;IACnG,OAAO,CAAC,aAAa;IAkCrB,6FAA6F;IAC7F,OAAO,CAAC,YAAY;CAOrB"}
|
|
@@ -1,86 +1,61 @@
|
|
|
1
|
+
import { times } from '@aztec/foundation/collection';
|
|
1
2
|
import { createLogger } from '@aztec/foundation/log';
|
|
2
|
-
import { promiseWithResolvers } from '@aztec/foundation/promise';
|
|
3
3
|
import { sleep } from '@aztec/foundation/sleep';
|
|
4
4
|
import { DateProvider } from '@aztec/foundation/timer';
|
|
5
5
|
import { TxHash } from '@aztec/stdlib/tx';
|
|
6
6
|
/**
|
|
7
7
|
* Collects txs from file stores as a fallback after P2P methods have been tried.
|
|
8
|
-
*
|
|
9
|
-
* retries with round-robin across sources, and applies exponential
|
|
10
|
-
* full cycles through all sources.
|
|
8
|
+
* Each call to startCollecting spins up its own worker pool which pulls entries with priority
|
|
9
|
+
* (fewest attempts first), retries with round-robin across sources, and applies exponential
|
|
10
|
+
* backoff between full cycles through all sources. Workers self-terminate when the request
|
|
11
|
+
* tracker is cancelled (deadline / all-fetched / external) or when there is nothing left to do.
|
|
11
12
|
*/ export class FileStoreTxCollection {
|
|
12
13
|
sources;
|
|
13
14
|
txCollectionSink;
|
|
14
15
|
config;
|
|
15
16
|
dateProvider;
|
|
16
17
|
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
18
|
constructor(sources, txCollectionSink, config, dateProvider = new DateProvider(), log = createLogger('p2p:file_store_tx_collection')){
|
|
22
19
|
this.sources = sources;
|
|
23
20
|
this.txCollectionSink = txCollectionSink;
|
|
24
21
|
this.config = config;
|
|
25
22
|
this.dateProvider = dateProvider;
|
|
26
23
|
this.log = log;
|
|
27
|
-
this.entries = new Map();
|
|
28
|
-
this.workers = [];
|
|
29
|
-
this.running = false;
|
|
30
|
-
this.wakeSignal = promiseWithResolvers();
|
|
31
24
|
}
|
|
32
|
-
/**
|
|
33
|
-
|
|
34
|
-
|
|
25
|
+
/**
|
|
26
|
+
* Spins up workers to download all txs still missing from the tracker, racing across the
|
|
27
|
+
* configured file store sources. Resolves once all workers settle.
|
|
28
|
+
*/ async startCollecting(requestTracker, context) {
|
|
29
|
+
if (this.sources.length === 0 || requestTracker.checkCancelled()) {
|
|
35
30
|
return;
|
|
36
31
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
32
|
+
// eslint-disable-next-line aztec-custom/no-non-primitive-in-collections
|
|
33
|
+
const entries = new Set();
|
|
34
|
+
for (const hashStr of requestTracker.missingTxHashes){
|
|
35
|
+
entries.add({
|
|
36
|
+
txHash: hashStr,
|
|
37
|
+
attempts: 0,
|
|
38
|
+
lastAttemptTime: 0,
|
|
39
|
+
nextSourceIndex: Math.floor(Math.random() * this.sources.length)
|
|
40
|
+
});
|
|
40
41
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
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()) {
|
|
42
|
+
// Yield before spawning so the synchronous caller can finish any follow-up (eg. marking a tx
|
|
43
|
+
// as fetched on the tracker, or cancelling it) before workers begin scanning entries.
|
|
44
|
+
await Promise.resolve();
|
|
45
|
+
if (requestTracker.checkCancelled()) {
|
|
54
46
|
return;
|
|
55
47
|
}
|
|
56
|
-
|
|
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();
|
|
48
|
+
await Promise.allSettled(times(this.config.workerCount, ()=>this.workerLoop(entries, requestTracker, context)));
|
|
78
49
|
}
|
|
79
|
-
async workerLoop(
|
|
80
|
-
|
|
81
|
-
|
|
50
|
+
async workerLoop(// eslint-disable-next-line aztec-custom/no-non-primitive-in-collections
|
|
51
|
+
entries, requestTracker, context) {
|
|
52
|
+
while(!requestTracker.checkCancelled() && entries.size > 0){
|
|
53
|
+
const action = this.getNextAction(entries, requestTracker);
|
|
82
54
|
if (action.type === 'sleep') {
|
|
83
|
-
await
|
|
55
|
+
await Promise.race([
|
|
56
|
+
sleep(action.ms),
|
|
57
|
+
requestTracker.cancellationToken
|
|
58
|
+
]);
|
|
84
59
|
continue;
|
|
85
60
|
}
|
|
86
61
|
const entry = action.entry;
|
|
@@ -97,9 +72,9 @@ import { TxHash } from '@aztec/stdlib/tx';
|
|
|
97
72
|
description: `file-store ${source.getInfo()}`,
|
|
98
73
|
method: 'file-store',
|
|
99
74
|
fileStore: source.getInfo()
|
|
100
|
-
},
|
|
75
|
+
}, context);
|
|
101
76
|
if (result.txs.length > 0) {
|
|
102
|
-
|
|
77
|
+
entries.delete(entry);
|
|
103
78
|
}
|
|
104
79
|
} catch (err) {
|
|
105
80
|
this.log.trace(`Error downloading tx ${entry.txHash} from ${source.getInfo()}`, {
|
|
@@ -108,13 +83,15 @@ import { TxHash } from '@aztec/stdlib/tx';
|
|
|
108
83
|
}
|
|
109
84
|
}
|
|
110
85
|
}
|
|
111
|
-
/** Single-pass scan: removes
|
|
86
|
+
/** Single-pass scan: removes stale entries, finds the best ready entry, or computes sleep time. */ getNextAction(// eslint-disable-next-line aztec-custom/no-non-primitive-in-collections
|
|
87
|
+
entries, requestTracker) {
|
|
112
88
|
const now = this.dateProvider.now();
|
|
113
89
|
let best;
|
|
114
90
|
let earliestReadyAt = Infinity;
|
|
115
|
-
for (const
|
|
116
|
-
|
|
117
|
-
|
|
91
|
+
for (const entry of entries){
|
|
92
|
+
// Drop entries whose tx was already found via another collection path.
|
|
93
|
+
if (!requestTracker.isMissing(entry.txHash)) {
|
|
94
|
+
entries.delete(entry);
|
|
118
95
|
continue;
|
|
119
96
|
}
|
|
120
97
|
const backoffMs = this.getBackoffMs(entry);
|
|
@@ -133,15 +110,11 @@ import { TxHash } from '@aztec/stdlib/tx';
|
|
|
133
110
|
entry: best
|
|
134
111
|
};
|
|
135
112
|
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
type: 'sleep',
|
|
139
|
-
promise: this.sleepOrWake(earliestReadyAt - now)
|
|
140
|
-
};
|
|
141
|
-
}
|
|
113
|
+
// earliestReadyAt is finite whenever there are surviving entries; if entries became empty,
|
|
114
|
+
// the outer worker loop will exit on its next iteration via entries.size === 0.
|
|
142
115
|
return {
|
|
143
116
|
type: 'sleep',
|
|
144
|
-
|
|
117
|
+
ms: earliestReadyAt === Infinity ? 0 : earliestReadyAt - now
|
|
145
118
|
};
|
|
146
119
|
}
|
|
147
120
|
/** Computes backoff for an entry. Backoff applies after a full cycle through all sources. */ getBackoffMs(entry) {
|
|
@@ -151,17 +124,4 @@ import { TxHash } from '@aztec/stdlib/tx';
|
|
|
151
124
|
}
|
|
152
125
|
return Math.min(this.config.backoffBaseMs * Math.pow(2, fullCycles - 1), this.config.backoffMaxMs);
|
|
153
126
|
}
|
|
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
127
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Logger } from '@aztec/foundation/log';
|
|
2
|
-
import { type TxHash } from '@aztec/stdlib/tx';
|
|
2
|
+
import { type TxHash, type TxValidator } from '@aztec/stdlib/tx';
|
|
3
3
|
import { type TelemetryClient } from '@aztec/telemetry-client';
|
|
4
4
|
import type { TxSource, TxSourceCollectionResult } from './tx_source.js';
|
|
5
5
|
/** TxSource implementation that downloads txs from a file store. */
|
|
@@ -7,6 +7,7 @@ export declare class FileStoreTxSource implements TxSource {
|
|
|
7
7
|
private readonly fileStore;
|
|
8
8
|
private readonly baseUrl;
|
|
9
9
|
private readonly basePath;
|
|
10
|
+
private readonly txValidator;
|
|
10
11
|
private readonly log;
|
|
11
12
|
private downloadsSuccess;
|
|
12
13
|
private downloadsFailed;
|
|
@@ -21,7 +22,7 @@ export declare class FileStoreTxSource implements TxSource {
|
|
|
21
22
|
* @param telemetry - Optional telemetry client.
|
|
22
23
|
* @returns The FileStoreTxSource instance, or undefined if creation fails.
|
|
23
24
|
*/
|
|
24
|
-
static create(url: string, basePath: string, log?: Logger, telemetry?: TelemetryClient): Promise<FileStoreTxSource | undefined>;
|
|
25
|
+
static create(url: string, basePath: string, txValidator: TxValidator, log?: Logger, telemetry?: TelemetryClient): Promise<FileStoreTxSource | undefined>;
|
|
25
26
|
getInfo(): string;
|
|
26
27
|
getTxsByHash(txHashes: TxHash[]): Promise<TxSourceCollectionResult>;
|
|
27
28
|
}
|
|
@@ -33,5 +34,5 @@ export declare class FileStoreTxSource implements TxSource {
|
|
|
33
34
|
* @param telemetry - Optional telemetry client.
|
|
34
35
|
* @returns Array of successfully created FileStoreTxSource instances.
|
|
35
36
|
*/
|
|
36
|
-
export declare function createFileStoreTxSources(urls: string[], basePath: string, log?: Logger, telemetry?: TelemetryClient): Promise<FileStoreTxSource[]>;
|
|
37
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
37
|
+
export declare function createFileStoreTxSources(urls: string[], basePath: string, txValidator: TxValidator, log?: Logger, telemetry?: TelemetryClient): Promise<FileStoreTxSource[]>;
|
|
38
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZmlsZV9zdG9yZV90eF9zb3VyY2UuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9zZXJ2aWNlcy90eF9jb2xsZWN0aW9uL2ZpbGVfc3RvcmVfdHhfc291cmNlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUNBLE9BQU8sRUFBRSxLQUFLLE1BQU0sRUFBZ0IsTUFBTSx1QkFBdUIsQ0FBQztBQUdsRSxPQUFPLEVBQU0sS0FBSyxNQUFNLEVBQUUsS0FBSyxXQUFXLEVBQUUsTUFBTSxrQkFBa0IsQ0FBQztBQUNyRSxPQUFPLEVBR0wsS0FBSyxlQUFlLEVBR3JCLE1BQU0seUJBQXlCLENBQUM7QUFFakMsT0FBTyxLQUFLLEVBQUUsUUFBUSxFQUFFLHdCQUF3QixFQUFFLE1BQU0sZ0JBQWdCLENBQUM7QUFFekUsb0VBQW9FO0FBQ3BFLHFCQUFhLGlCQUFrQixZQUFXLFFBQVE7SUFPOUMsT0FBTyxDQUFDLFFBQVEsQ0FBQyxTQUFTO0lBQz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x_collection/file_store_tx_source.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"file_store_tx_source.d.ts","sourceRoot":"","sources":["../../../src/services/tx_collection/file_store_tx_source.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,uBAAuB,CAAC;AAGlE,OAAO,EAAM,KAAK,MAAM,EAAE,KAAK,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACrE,OAAO,EAGL,KAAK,eAAe,EAGrB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,KAAK,EAAE,QAAQ,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAC;AAEzE,oEAAoE;AACpE,qBAAa,iBAAkB,YAAW,QAAQ;IAO9C,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,WAAW;IAC5B,OAAO,CAAC,QAAQ,CAAC,GAAG;IAVtB,OAAO,CAAC,gBAAgB,CAAgB;IACxC,OAAO,CAAC,eAAe,CAAgB;IACvC,OAAO,CAAC,gBAAgB,CAAY;IACpC,OAAO,CAAC,YAAY,CAAY;IAEhC,OAAO,eAaN;IAED;;;;;;;OAOG;IACH,OAAoB,MAAM,CACxB,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,WAAW,EACxB,GAAG,GAAE,MAAiD,EACtD,SAAS,GAAE,eAAsC,GAChD,OAAO,CAAC,iBAAiB,GAAG,SAAS,CAAC,CAYxC;IAEM,OAAO,IAAI,MAAM,CAEvB;IAEY,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAqC/E;CACF;AAED;;;;;;;GAOG;AACH,wBAAsB,wBAAwB,CAC5C,IAAI,EAAE,MAAM,EAAE,EACd,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,WAAW,EACxB,GAAG,GAAE,MAAiD,EACtD,SAAS,GAAE,eAAsC,GAChD,OAAO,CAAC,iBAAiB,EAAE,CAAC,CAK9B"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { partitionAsync } from '@aztec/foundation/collection';
|
|
1
2
|
import { createLogger } from '@aztec/foundation/log';
|
|
2
3
|
import { Timer } from '@aztec/foundation/timer';
|
|
3
4
|
import { createReadOnlyFileStore } from '@aztec/stdlib/file-store';
|
|
@@ -7,15 +8,17 @@ import { Metrics, getTelemetryClient } from '@aztec/telemetry-client';
|
|
|
7
8
|
fileStore;
|
|
8
9
|
baseUrl;
|
|
9
10
|
basePath;
|
|
11
|
+
txValidator;
|
|
10
12
|
log;
|
|
11
13
|
downloadsSuccess;
|
|
12
14
|
downloadsFailed;
|
|
13
15
|
downloadDuration;
|
|
14
16
|
downloadSize;
|
|
15
|
-
constructor(fileStore, baseUrl, basePath, log, telemetry){
|
|
17
|
+
constructor(fileStore, baseUrl, basePath, txValidator, log, telemetry){
|
|
16
18
|
this.fileStore = fileStore;
|
|
17
19
|
this.baseUrl = baseUrl;
|
|
18
20
|
this.basePath = basePath;
|
|
21
|
+
this.txValidator = txValidator;
|
|
19
22
|
this.log = log;
|
|
20
23
|
const meter = telemetry.getMeter('file-store-tx-source');
|
|
21
24
|
this.downloadsSuccess = meter.createUpDownCounter(Metrics.TX_FILE_STORE_DOWNLOADS_SUCCESS);
|
|
@@ -30,14 +33,14 @@ import { Metrics, getTelemetryClient } from '@aztec/telemetry-client';
|
|
|
30
33
|
* @param log - Optional logger.
|
|
31
34
|
* @param telemetry - Optional telemetry client.
|
|
32
35
|
* @returns The FileStoreTxSource instance, or undefined if creation fails.
|
|
33
|
-
*/ static async create(url, basePath, log = createLogger('p2p:file_store_tx_source'), telemetry = getTelemetryClient()) {
|
|
36
|
+
*/ static async create(url, basePath, txValidator, log = createLogger('p2p:file_store_tx_source'), telemetry = getTelemetryClient()) {
|
|
34
37
|
try {
|
|
35
38
|
const fileStore = await createReadOnlyFileStore(url, log);
|
|
36
39
|
if (!fileStore) {
|
|
37
40
|
log.warn(`Failed to create file store for URL: ${url}`);
|
|
38
41
|
return undefined;
|
|
39
42
|
}
|
|
40
|
-
return new FileStoreTxSource(fileStore, url, basePath, log, telemetry);
|
|
43
|
+
return new FileStoreTxSource(fileStore, url, basePath, txValidator, log, telemetry);
|
|
41
44
|
} catch (err) {
|
|
42
45
|
log.warn(`Error creating file store for URL: ${url}`, {
|
|
43
46
|
error: err
|
|
@@ -49,31 +52,38 @@ import { Metrics, getTelemetryClient } from '@aztec/telemetry-client';
|
|
|
49
52
|
return `file-store:${this.baseUrl}`;
|
|
50
53
|
}
|
|
51
54
|
async getTxsByHash(txHashes) {
|
|
52
|
-
const
|
|
55
|
+
const results = await Promise.all(txHashes.map(async (txHash)=>{
|
|
56
|
+
const path = `${this.basePath}/txs/${txHash.toString()}.bin`;
|
|
57
|
+
const timer = new Timer();
|
|
58
|
+
try {
|
|
59
|
+
const buffer = await this.fileStore.read(path);
|
|
60
|
+
const tx = Tx.fromBuffer(buffer);
|
|
61
|
+
return {
|
|
62
|
+
tx,
|
|
63
|
+
downloadDuration: timer.ms(),
|
|
64
|
+
downloadSize: buffer.length
|
|
65
|
+
};
|
|
66
|
+
} catch {
|
|
67
|
+
this.downloadsFailed.add(1);
|
|
68
|
+
return undefined;
|
|
69
|
+
}
|
|
70
|
+
}));
|
|
71
|
+
const txs = results.filter((tx)=>tx !== undefined);
|
|
72
|
+
const [validTxs, invalidTxs] = await partitionAsync(txs, async ({ tx, downloadDuration, downloadSize })=>{
|
|
73
|
+
const valid = await this.txValidator.validateTx(tx);
|
|
74
|
+
if (valid.result === 'valid') {
|
|
75
|
+
this.downloadsSuccess.add(1);
|
|
76
|
+
this.downloadDuration.record(Math.ceil(downloadDuration));
|
|
77
|
+
this.downloadSize.record(downloadSize);
|
|
78
|
+
return true;
|
|
79
|
+
} else {
|
|
80
|
+
this.downloadsFailed.add(1);
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
});
|
|
53
84
|
return {
|
|
54
|
-
validTxs:
|
|
55
|
-
|
|
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
|
|
85
|
+
validTxs: validTxs.map(({ tx })=>tx),
|
|
86
|
+
invalidTxHashes: invalidTxs.map(({ tx })=>tx.getTxHash().toString())
|
|
77
87
|
};
|
|
78
88
|
}
|
|
79
89
|
}
|
|
@@ -84,7 +94,7 @@ import { Metrics, getTelemetryClient } from '@aztec/telemetry-client';
|
|
|
84
94
|
* @param log - Optional logger.
|
|
85
95
|
* @param telemetry - Optional telemetry client.
|
|
86
96
|
* @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)));
|
|
97
|
+
*/ export async function createFileStoreTxSources(urls, basePath, txValidator, log = createLogger('p2p:file_store_tx_source'), telemetry = getTelemetryClient()) {
|
|
98
|
+
const sources = await Promise.all(urls.map((url)=>FileStoreTxSource.create(url, basePath, txValidator, log, telemetry)));
|
|
89
99
|
return sources.filter((s)=>s !== undefined);
|
|
90
100
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
export { TxCollection, type FastCollectionRequestInput } from './tx_collection.js';
|
|
1
|
+
export { TxCollection, type FastCollectionRequestInput, type IReqRespTxsCollector } from './tx_collection.js';
|
|
2
2
|
export { type TxSource, createNodeRpcTxSources, NodeRpcTxSource } from './tx_source.js';
|
|
3
|
-
export { type MissingTxsCollector, BatchTxRequesterCollector, SendBatchRequestCollector, } from './proposal_tx_collector.js';
|
|
4
3
|
export { FileStoreTxSource, createFileStoreTxSources } from './file_store_tx_source.js';
|
|
5
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
4
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9zZXJ2aWNlcy90eF9jb2xsZWN0aW9uL2luZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxZQUFZLEVBQUUsS0FBSywwQkFBMEIsRUFBRSxLQUFLLG9CQUFvQixFQUFFLE1BQU0sb0JBQW9CLENBQUM7QUFDOUcsT0FBTyxFQUFFLEtBQUssUUFBUSxFQUFFLHNCQUFzQixFQUFFLGVBQWUsRUFBRSxNQUFNLGdCQUFnQixDQUFDO0FBQ3hGLE9BQU8sRUFBRSxpQkFBaUIsRUFBRSx3QkFBd0IsRUFBRSxNQUFNLDJCQUEyQixDQUFDIn0=
|
|
@@ -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;
|
|
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,KAAK,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC9G,OAAO,EAAE,KAAK,QAAQ,EAAE,sBAAsB,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACxF,OAAO,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAC"}
|
|
@@ -1,4 +1,3 @@
|
|
|
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
3
|
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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5zdHJ1bWVudGF0aW9uLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvc2VydmljZXMvdHhfY29sbGVjdGlvbi9pbnN0cnVtZW50YXRpb24udHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUlMLEtBQUssZUFBZSxFQUdyQixNQUFNLHlCQUF5QixDQUFDO0FBRWpDLE9BQU8sS0FBSyxFQUFFLGdCQUFnQixFQUFFLE1BQU0sb0JBQW9CLENBQUM7QUFFM0QscUJBQWEsMkJBQTJCO0lBQ3RDLE9BQU8sQ0FBQyxZQUFZLENBQWdCO0lBQ3BDLE9BQU8sQ0FBQyx1QkFBdUIsQ0FBWTtJQUMzQyxPQUFPLENBQUMsNEJBQTRCLENBQVk7SUFFaEQsWUFBWSxNQUFNLEVBQUUsZUFBZSxFQUFFLElBQUksRUFBRSxNQUFNLEVBVWhEO0lBRUQsY0FBYyxDQUFDLElBQUksRUFBRSxnQkFBZ0IsRUFBRSxLQUFLLEVBQUUsTUFBTSxFQUFFLFFBQVEsRUFBRSxNQUFNLFFBS3JFO0NBQ0YifQ==
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
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,EAUhD;IAED,cAAc,CAAC,IAAI,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,QAKrE;CACF"}
|
|
@@ -10,20 +10,13 @@ import { type TelemetryClient } from '@aztec/telemetry-client';
|
|
|
10
10
|
import type { PeerId } from '@libp2p/interface';
|
|
11
11
|
import type { TxPoolV2, TxPoolV2Events } from '../../mem_pools/tx_pool_v2/interfaces.js';
|
|
12
12
|
import type { BatchTxRequesterLibP2PService } from '../reqresp/batch-tx-requester/interface.js';
|
|
13
|
+
import type { BlockTxsSource } from '../reqresp/index.js';
|
|
13
14
|
import type { TxCollectionConfig } from './config.js';
|
|
14
|
-
import { FastTxCollection } from './fast_tx_collection.js';
|
|
15
15
|
import { FileStoreTxCollection } from './file_store_tx_collection.js';
|
|
16
16
|
import type { FileStoreTxSource } from './file_store_tx_source.js';
|
|
17
|
-
import type
|
|
18
|
-
import { SlowTxCollection } from './slow_tx_collection.js';
|
|
17
|
+
import { type IRequestTracker } from './request_tracker.js';
|
|
19
18
|
import type { TxSource } from './tx_source.js';
|
|
20
|
-
export type CollectionMethod = 'fast-req-resp' | 'fast-node-rpc' | '
|
|
21
|
-
export type MissingTxInfo = {
|
|
22
|
-
block: L2Block;
|
|
23
|
-
blockNumber: BlockNumber;
|
|
24
|
-
deadline: Date;
|
|
25
|
-
readyForReqResp: boolean;
|
|
26
|
-
};
|
|
19
|
+
export type CollectionMethod = 'fast-req-resp' | 'fast-node-rpc' | 'file-store';
|
|
27
20
|
export type FastCollectionRequestInput = {
|
|
28
21
|
type: 'block';
|
|
29
22
|
block: L2Block;
|
|
@@ -37,15 +30,21 @@ export type FastCollectionRequest = FastCollectionRequestInput & {
|
|
|
37
30
|
blockInfo: L2BlockInfo;
|
|
38
31
|
};
|
|
39
32
|
/**
|
|
40
|
-
*
|
|
33
|
+
* Collect missing transactions for a block or proposal via reqresp.
|
|
34
|
+
* @param requestTracker - The missing transactions tracker
|
|
35
|
+
* @param blockTxsSource - The block or proposal containing the transactions
|
|
36
|
+
* @param pinnedPeer - Optional peer expected to have the transactions
|
|
37
|
+
* @returns The collected transactions
|
|
38
|
+
*/
|
|
39
|
+
export type IReqRespTxsCollector = (requestTracker: IRequestTracker, blockTxsSource: BlockTxsSource, pinnedPeer: PeerId | undefined) => Promise<Tx[]>;
|
|
40
|
+
/**
|
|
41
|
+
* Coordinates tx collection from remote RPC nodes, reqresp, and file store.
|
|
41
42
|
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
* via events and notifies the slow and fast collection loops to stop collecting that tx, so that we don't
|
|
48
|
-
* collect the same tx multiple times.
|
|
43
|
+
* Runs a sequential pipeline: node RPC → reqresp → file store. Node collection starts immediately,
|
|
44
|
+
* reqresp starts after a configured delay, and file store (if configured) starts after a further
|
|
45
|
+
* delay. All paths send txs to the collection sink, which handles metrics and adds them to the
|
|
46
|
+
* tx pool. Whenever a tx is added to the sink or the pool, this service is notified and stops
|
|
47
|
+
* collecting that tx across all in-flight requests.
|
|
49
48
|
*/
|
|
50
49
|
export declare class TxCollection {
|
|
51
50
|
private readonly p2pService;
|
|
@@ -55,42 +54,22 @@ export declare class TxCollection {
|
|
|
55
54
|
private readonly config;
|
|
56
55
|
private readonly dateProvider;
|
|
57
56
|
private readonly log;
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
/** File store collection for slow (mined block) path */
|
|
63
|
-
protected readonly fileStoreSlowCollection: FileStoreTxCollection;
|
|
64
|
-
/** File store collection for fast (proposal/proving) path */
|
|
57
|
+
protected requests: Set<FastCollectionRequest>;
|
|
58
|
+
/** The collector for txs via reqresp */
|
|
59
|
+
protected reqRespTxsCollector?: IReqRespTxsCollector;
|
|
60
|
+
/** File store collection for the fast (proposal/proving) path */
|
|
65
61
|
protected readonly fileStoreFastCollection: FileStoreTxCollection;
|
|
66
|
-
/**
|
|
67
|
-
private readonly reconcileFoundTxsLoop;
|
|
68
|
-
/** Handles txs found by the slow and fast collection loops */
|
|
62
|
+
/** Handles txs found by collection paths before adding to the pool */
|
|
69
63
|
private readonly txCollectionSink;
|
|
70
64
|
/** Handler for the txs-added event from the tx pool */
|
|
71
65
|
protected readonly handleTxsAddedToPool: TxPoolV2Events['txs-added'];
|
|
72
66
|
/** Handler for the txs-added event from the tx collection sink */
|
|
73
67
|
protected readonly handleTxsFound: TxPoolV2Events['txs-added'];
|
|
74
|
-
/** Whether the service has been started. */
|
|
75
|
-
private started;
|
|
76
|
-
/** Whether file store sources are configured. */
|
|
77
|
-
private readonly hasFileStoreSources;
|
|
78
68
|
constructor(p2pService: BatchTxRequesterLibP2PService, nodes: TxSource[], constants: L1RollupConstants, txPool: TxPoolV2, config: TxCollectionConfig, fileStoreSources?: FileStoreTxSource[], dateProvider?: DateProvider, telemetryClient?: TelemetryClient, log?: Logger);
|
|
79
|
-
/**
|
|
80
|
-
|
|
81
|
-
/** Stops all activity. */
|
|
82
|
-
stop(): Promise<void>;
|
|
83
|
-
/** Force trigger the slow collection and reconciliation loops */
|
|
84
|
-
trigger(): Promise<void>;
|
|
69
|
+
/** Stops all activity. Cancels in-flight requests; file store workers self-terminate. */
|
|
70
|
+
stop(): void;
|
|
85
71
|
/** Returns L1 rollup constants. */
|
|
86
72
|
getConstants(): L1RollupConstants;
|
|
87
|
-
/** Starts collecting the given tx hashes for the given L2Block in the slow loop */
|
|
88
|
-
startCollecting(block: L2Block, txHashes: TxHash[]): void;
|
|
89
|
-
/** Collects the set of txs for the given block proposal as fast as possible */
|
|
90
|
-
collectFastForProposal(blockProposal: BlockProposal, blockNumber: BlockNumber, txHashes: TxHash[] | string[], opts: {
|
|
91
|
-
deadline: Date;
|
|
92
|
-
pinnedPeer?: PeerId;
|
|
93
|
-
}): Promise<Tx[]>;
|
|
94
73
|
/** Collects the set of txs for the given mined block as fast as possible */
|
|
95
74
|
collectFastForBlock(block: L2Block, txHashes: TxHash[] | string[], opts: {
|
|
96
75
|
deadline: Date;
|
|
@@ -101,12 +80,18 @@ export declare class TxCollection {
|
|
|
101
80
|
deadline: Date;
|
|
102
81
|
pinnedPeer?: PeerId;
|
|
103
82
|
}): Promise<Tx[]>;
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
83
|
+
protected collectFast(request: FastCollectionRequest, opts: {
|
|
84
|
+
pinnedPeer?: PeerId;
|
|
85
|
+
}): Promise<void>;
|
|
86
|
+
private collectFastFromNodes;
|
|
87
|
+
private collectFastFromNode;
|
|
88
|
+
private collectFastViaReqResp;
|
|
89
|
+
/** Returns the TxAddContext for the given request, used by the sink to add txs to the pool correctly. */
|
|
90
|
+
private getAddContext;
|
|
91
|
+
/** Mark the given txs as found. Stops collecting them across all in-flight requests. */
|
|
107
92
|
private foundTxs;
|
|
108
93
|
/**
|
|
109
|
-
* Stop collecting all txs for blocks less than or
|
|
94
|
+
* Stop collecting all txs for blocks less than or equal to the block number specified.
|
|
110
95
|
* To be called when we no longer care about gathering txs up to a certain block, eg when they become proven or finalized.
|
|
111
96
|
*/
|
|
112
97
|
stopCollectingForBlocksUpTo(blockNumber: BlockNumber): void;
|
|
@@ -115,6 +100,5 @@ export declare class TxCollection {
|
|
|
115
100
|
* To be called when there is a chain prune and previously mined txs are no longer relevant.
|
|
116
101
|
*/
|
|
117
102
|
stopCollectingForBlocksAfter(blockNumber: BlockNumber): void;
|
|
118
|
-
private reconcileFoundTxsWithPool;
|
|
119
103
|
}
|
|
120
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
104
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHhfY29sbGVjdGlvbi5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL3NlcnZpY2VzL3R4X2NvbGxlY3Rpb24vdHhfY29sbGVjdGlvbi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsV0FBVyxFQUFFLE1BQU0saUNBQWlDLENBQUM7QUFFOUQsT0FBTyxFQUFFLEtBQUssTUFBTSxFQUFnQixNQUFNLHVCQ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