@aztec/p2p 0.0.1-commit.f2ce05ee → 0.0.1-commit.f5a9928
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 +130 -3
- 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 +11 -10
- package/dest/client/factory.d.ts.map +1 -1
- package/dest/client/factory.js +64 -17
- package/dest/client/interface.d.ts +86 -40
- package/dest/client/interface.d.ts.map +1 -1
- package/dest/client/p2p_client.d.ts +67 -64
- package/dest/client/p2p_client.d.ts.map +1 -1
- package/dest/client/p2p_client.js +251 -251
- package/dest/config.d.ts +173 -94
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +158 -44
- 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 +9 -16
- package/dest/errors/reqresp.error.d.ts.map +1 -1
- package/dest/errors/reqresp.error.js +10 -17
- 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 -2
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +1 -1
- package/dest/mem_pools/attestation_pool/attestation_pool.d.ts +106 -55
- package/dest/mem_pools/attestation_pool/attestation_pool.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/attestation_pool.js +302 -195
- package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.d.ts +1 -1
- package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.js +274 -115
- package/dest/mem_pools/attestation_pool/index.d.ts +2 -2
- package/dest/mem_pools/attestation_pool/index.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/index.js +1 -1
- 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 +7 -5
- package/dest/mem_pools/index.d.ts +2 -2
- package/dest/mem_pools/index.d.ts.map +1 -1
- package/dest/mem_pools/instrumentation.d.ts +12 -5
- package/dest/mem_pools/instrumentation.d.ts.map +1 -1
- package/dest/mem_pools/instrumentation.js +38 -17
- package/dest/mem_pools/interface.d.ts +3 -3
- package/dest/mem_pools/interface.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/archive/tx_archive.d.ts +10 -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 +29 -20
- 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 +3 -3
- package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.js +18 -9
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.d.ts +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.js +8 -4
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.d.ts +3 -3
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.js +15 -5
- package/dest/mem_pools/tx_pool_v2/eviction/index.d.ts +3 -2
- package/dest/mem_pools/tx_pool_v2/eviction/index.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/index.js +2 -1
- 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 +64 -0
- package/dest/mem_pools/tx_pool_v2/eviction/interfaces.d.ts +54 -5
- package/dest/mem_pools/tx_pool_v2/eviction/interfaces.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/interfaces.js +8 -0
- package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.d.ts +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.js +6 -5
- package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.d.ts +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.js +9 -8
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.d.ts +2 -2
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.js +15 -6
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.d.ts +4 -4
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.js +16 -4
- package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.d.ts +3 -3
- package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.js +3 -3
- package/dest/mem_pools/tx_pool_v2/index.d.ts +3 -2
- package/dest/mem_pools/tx_pool_v2/index.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/index.js +2 -1
- package/dest/mem_pools/tx_pool_v2/instrumentation.d.ts +25 -0
- package/dest/mem_pools/tx_pool_v2/instrumentation.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/instrumentation.js +67 -0
- package/dest/mem_pools/tx_pool_v2/interfaces.d.ts +62 -16
- package/dest/mem_pools/tx_pool_v2/interfaces.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/interfaces.js +6 -1
- package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts +81 -15
- package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/tx_metadata.js +147 -19
- package/dest/mem_pools/tx_pool_v2/tx_pool_indices.d.ts +26 -3
- 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 +79 -43
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts +27 -7
- 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 +94 -32
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts +62 -9
- 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 +537 -246
- 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 -15
- 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 +12 -5
- package/dest/msg_validators/proposal_validator/block_proposal_validator.d.ts.map +1 -1
- package/dest/msg_validators/proposal_validator/block_proposal_validator.js +11 -3
- package/dest/msg_validators/proposal_validator/checkpoint_proposal_validator.d.ts +12 -5
- package/dest/msg_validators/proposal_validator/checkpoint_proposal_validator.d.ts.map +1 -1
- package/dest/msg_validators/proposal_validator/checkpoint_proposal_validator.js +23 -3
- package/dest/msg_validators/proposal_validator/proposal_validator.d.ts +36 -9
- package/dest/msg_validators/proposal_validator/proposal_validator.d.ts.map +1 -1
- package/dest/msg_validators/proposal_validator/proposal_validator.js +130 -48
- 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 +11 -18
- package/dest/msg_validators/tx_validator/allowed_public_setup.d.ts +2 -1
- package/dest/msg_validators/tx_validator/allowed_public_setup.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/allowed_public_setup.js +25 -21
- package/dest/msg_validators/tx_validator/allowed_setup_helpers.d.ts +17 -0
- package/dest/msg_validators/tx_validator/allowed_setup_helpers.d.ts.map +1 -0
- package/dest/msg_validators/tx_validator/allowed_setup_helpers.js +24 -0
- package/dest/msg_validators/tx_validator/archive_cache.js +1 -1
- package/dest/msg_validators/tx_validator/block_header_validator.d.ts +16 -3
- package/dest/msg_validators/tx_validator/block_header_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/block_header_validator.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/double_spend_validator.d.ts +13 -3
- package/dest/msg_validators/tx_validator/double_spend_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/double_spend_validator.js +4 -4
- package/dest/msg_validators/tx_validator/factory.d.ts +133 -7
- package/dest/msg_validators/tx_validator/factory.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/factory.js +261 -61
- package/dest/msg_validators/tx_validator/fee_payer_balance.d.ts +1 -1
- package/dest/msg_validators/tx_validator/fee_payer_balance.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/fee_payer_balance.js +6 -2
- package/dest/msg_validators/tx_validator/gas_validator.d.ts +104 -3
- package/dest/msg_validators/tx_validator/gas_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/gas_validator.js +137 -53
- package/dest/msg_validators/tx_validator/index.d.ts +5 -1
- package/dest/msg_validators/tx_validator/index.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/index.js +4 -0
- package/dest/msg_validators/tx_validator/metadata_validator.d.ts +1 -1
- package/dest/msg_validators/tx_validator/metadata_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/metadata_validator.js +4 -4
- 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 +22 -2
- package/dest/msg_validators/tx_validator/phases_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/phases_validator.js +72 -24
- package/dest/msg_validators/tx_validator/timestamp_validator.d.ts +20 -4
- package/dest/msg_validators/tx_validator/timestamp_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/timestamp_validator.js +6 -6
- package/dest/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 +25 -19
- package/dest/services/dummy_service.d.ts.map +1 -1
- package/dest/services/dummy_service.js +28 -20
- package/dest/services/encoding.d.ts +24 -7
- package/dest/services/encoding.d.ts.map +1 -1
- package/dest/services/encoding.js +43 -26
- package/dest/services/gossipsub/topic_score_params.d.ts +23 -17
- package/dest/services/gossipsub/topic_score_params.d.ts.map +1 -1
- package/dest/services/gossipsub/topic_score_params.js +36 -24
- package/dest/services/libp2p/instrumentation.d.ts +6 -1
- package/dest/services/libp2p/instrumentation.d.ts.map +1 -1
- package/dest/services/libp2p/instrumentation.js +21 -0
- package/dest/services/libp2p/libp2p_service.d.ts +71 -60
- package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
- package/dest/services/libp2p/libp2p_service.js +602 -407
- package/dest/services/peer-manager/metrics.d.ts +3 -1
- package/dest/services/peer-manager/metrics.d.ts.map +1 -1
- package/dest/services/peer-manager/metrics.js +6 -0
- package/dest/services/peer-manager/peer_manager.d.ts +31 -3
- package/dest/services/peer-manager/peer_manager.d.ts.map +1 -1
- package/dest/services/peer-manager/peer_manager.js +127 -26
- 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 +5 -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 +95 -127
- package/dest/services/reqresp/batch-tx-requester/interface.d.ts +11 -11
- package/dest/services/reqresp/batch-tx-requester/interface.d.ts.map +1 -1
- package/dest/services/reqresp/batch-tx-requester/missing_txs.d.ts +11 -13
- package/dest/services/reqresp/batch-tx-requester/missing_txs.d.ts.map +1 -1
- package/dest/services/reqresp/batch-tx-requester/missing_txs.js +31 -46
- package/dest/services/reqresp/batch-tx-requester/peer_collection.d.ts +19 -11
- package/dest/services/reqresp/batch-tx-requester/peer_collection.d.ts.map +1 -1
- package/dest/services/reqresp/batch-tx-requester/peer_collection.js +52 -15
- 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 +15 -3
- package/dest/services/reqresp/config.d.ts.map +1 -1
- package/dest/services/reqresp/config.js +11 -0
- package/dest/services/reqresp/interface.d.ts +25 -18
- package/dest/services/reqresp/interface.d.ts.map +1 -1
- package/dest/services/reqresp/interface.js +23 -19
- 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 +3 -3
- 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 +18 -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 +57 -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 +7 -1
- package/dest/services/reqresp/protocols/tx.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/tx.js +21 -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 +3 -13
- 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 +85 -219
- package/dest/services/service.d.ts +63 -19
- package/dest/services/service.d.ts.map +1 -1
- package/dest/services/tx_collection/config.d.ts +11 -14
- package/dest/services/tx_collection/config.d.ts.map +1 -1
- package/dest/services/tx_collection/config.js +26 -33
- package/dest/services/tx_collection/file_store_tx_collection.d.ts +37 -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 +127 -0
- package/dest/services/tx_collection/file_store_tx_source.d.ts +38 -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 +100 -0
- package/dest/services/tx_collection/index.d.ts +3 -3
- package/dest/services/tx_collection/index.d.ts.map +1 -1
- package/dest/services/tx_collection/index.js +1 -1
- package/dest/services/tx_collection/instrumentation.js +1 -2
- package/dest/services/tx_collection/request_tracker.d.ts +53 -0
- package/dest/services/tx_collection/request_tracker.d.ts.map +1 -0
- package/dest/services/tx_collection/request_tracker.js +84 -0
- package/dest/services/tx_collection/tx_collection.d.ts +45 -51
- package/dest/services/tx_collection/tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/tx_collection.js +296 -68
- package/dest/services/tx_collection/tx_collection_sink.d.ts +19 -9
- package/dest/services/tx_collection/tx_collection_sink.d.ts.map +1 -1
- package/dest/services/tx_collection/tx_collection_sink.js +28 -31
- package/dest/services/tx_collection/tx_source.d.ts +13 -7
- package/dest/services/tx_collection/tx_source.d.ts.map +1 -1
- package/dest/services/tx_collection/tx_source.js +29 -7
- package/dest/services/tx_file_store/config.d.ts +1 -3
- package/dest/services/tx_file_store/config.d.ts.map +1 -1
- package/dest/services/tx_file_store/config.js +0 -4
- package/dest/services/tx_file_store/tx_file_store.d.ts +4 -5
- package/dest/services/tx_file_store/tx_file_store.d.ts.map +1 -1
- package/dest/services/tx_file_store/tx_file_store.js +13 -20
- package/dest/services/tx_provider.d.ts +6 -4
- package/dest/services/tx_provider.d.ts.map +1 -1
- package/dest/services/tx_provider.js +12 -8
- 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 +5 -3
- package/dest/test-helpers/mock-pubsub.d.ts +56 -6
- package/dest/test-helpers/mock-pubsub.d.ts.map +1 -1
- package/dest/test-helpers/mock-pubsub.js +128 -14
- package/dest/test-helpers/reqresp-nodes.d.ts +5 -7
- package/dest/test-helpers/reqresp-nodes.d.ts.map +1 -1
- package/dest/test-helpers/reqresp-nodes.js +17 -19
- 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 +49 -37
- package/dest/test-helpers/testbench-utils.d.ts.map +1 -1
- package/dest/test-helpers/testbench-utils.js +142 -50
- 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 +112 -49
- package/dest/testbench/worker_client_manager.d.ts +12 -6
- package/dest/testbench/worker_client_manager.d.ts.map +1 -1
- package/dest/testbench/worker_client_manager.js +57 -11
- package/dest/util.d.ts +13 -8
- 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 +17 -17
- package/src/bootstrap/bootstrap.ts +17 -3
- package/src/client/factory.ts +129 -28
- package/src/client/interface.ts +88 -48
- package/src/client/p2p_client.ts +284 -317
- package/src/client/test/{tx_proposal_collector/README.md → p2p_client.batch_tx_requester.bench.README.md} +23 -53
- package/src/config.ts +280 -49
- package/src/errors/p2p-service.error.ts +11 -0
- package/src/errors/reqresp.error.ts +13 -19
- package/src/errors/tx-pool.error.ts +12 -0
- package/src/index.ts +1 -1
- package/src/mem_pools/attestation_pool/attestation_pool.ts +373 -236
- package/src/mem_pools/attestation_pool/attestation_pool_test_suite.ts +298 -119
- package/src/mem_pools/attestation_pool/index.ts +3 -3
- package/src/mem_pools/attestation_pool/mocks.ts +14 -8
- package/src/mem_pools/index.ts +1 -1
- package/src/mem_pools/instrumentation.ts +27 -17
- package/src/mem_pools/interface.ts +2 -2
- package/src/mem_pools/tx_pool_v2/README.md +85 -11
- package/src/mem_pools/tx_pool_v2/archive/tx_archive.ts +30 -20
- package/src/mem_pools/tx_pool_v2/deleted_pool.ts +321 -0
- package/src/mem_pools/tx_pool_v2/eviction/eviction_manager.ts +21 -8
- package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.ts +6 -4
- package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.ts +21 -6
- package/src/mem_pools/tx_pool_v2/eviction/index.ts +5 -0
- package/src/mem_pools/tx_pool_v2/eviction/insufficient_fee_per_gas_eviction_rule.ts +67 -0
- package/src/mem_pools/tx_pool_v2/eviction/interfaces.ts +59 -4
- package/src/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.ts +4 -6
- package/src/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.ts +8 -10
- package/src/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.ts +14 -10
- package/src/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.ts +33 -6
- package/src/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.ts +4 -3
- package/src/mem_pools/tx_pool_v2/index.ts +2 -1
- package/src/mem_pools/tx_pool_v2/instrumentation.ts +96 -0
- package/src/mem_pools/tx_pool_v2/interfaces.ts +63 -16
- package/src/mem_pools/tx_pool_v2/tx_metadata.ts +215 -27
- package/src/mem_pools/tx_pool_v2/tx_pool_indices.ts +91 -43
- package/src/mem_pools/tx_pool_v2/tx_pool_v2.ts +122 -33
- package/src/mem_pools/tx_pool_v2/tx_pool_v2_impl.ts +602 -242
- package/src/msg_validators/attestation_validator/README.md +49 -0
- package/src/msg_validators/attestation_validator/attestation_validator.ts +46 -14
- package/src/msg_validators/attestation_validator/fisherman_attestation_validator.ts +15 -7
- package/src/msg_validators/proposal_validator/README.md +123 -0
- package/src/msg_validators/proposal_validator/block_proposal_validator.ts +26 -4
- package/src/msg_validators/proposal_validator/checkpoint_proposal_validator.ts +43 -7
- package/src/msg_validators/proposal_validator/proposal_validator.ts +155 -49
- package/src/msg_validators/tx_validator/README.md +129 -0
- package/src/msg_validators/tx_validator/aggregate_tx_validator.ts +8 -17
- package/src/msg_validators/tx_validator/allowed_public_setup.ts +22 -27
- package/src/msg_validators/tx_validator/allowed_setup_helpers.ts +31 -0
- package/src/msg_validators/tx_validator/archive_cache.ts +1 -1
- package/src/msg_validators/tx_validator/block_header_validator.ts +15 -3
- 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/double_spend_validator.ts +11 -6
- package/src/msg_validators/tx_validator/factory.ts +413 -80
- package/src/msg_validators/tx_validator/fee_payer_balance.ts +6 -2
- package/src/msg_validators/tx_validator/gas_validator.ts +195 -54
- package/src/msg_validators/tx_validator/index.ts +4 -0
- package/src/msg_validators/tx_validator/metadata_validator.ts +12 -4
- package/src/msg_validators/tx_validator/nullifier_cache.ts +30 -0
- package/src/msg_validators/tx_validator/phases_validator.ts +82 -27
- package/src/msg_validators/tx_validator/timestamp_validator.ts +23 -18
- 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 +38 -46
- package/src/services/encoding.ts +42 -26
- package/src/services/gossipsub/README.md +59 -22
- package/src/services/gossipsub/topic_score_params.ts +58 -31
- package/src/services/libp2p/instrumentation.ts +22 -0
- package/src/services/libp2p/libp2p_service.ts +687 -466
- package/src/services/peer-manager/metrics.ts +7 -0
- package/src/services/peer-manager/peer_manager.ts +140 -25
- package/src/services/peer-manager/peer_scoring.ts +102 -8
- package/src/services/reqresp/README.md +194 -0
- package/src/services/reqresp/batch-tx-requester/README.md +46 -7
- package/src/services/reqresp/batch-tx-requester/batch_tx_requester.ts +92 -138
- package/src/services/reqresp/batch-tx-requester/interface.ts +14 -10
- package/src/services/reqresp/batch-tx-requester/missing_txs.ts +30 -71
- package/src/services/reqresp/batch-tx-requester/peer_collection.ts +68 -24
- package/src/services/reqresp/batch-tx-requester/tx_validator.ts +12 -25
- package/src/services/reqresp/config.ts +19 -2
- package/src/services/reqresp/interface.ts +45 -46
- 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 +36 -32
- package/src/services/reqresp/protocols/block_txs/block_txs_reqresp.ts +64 -20
- package/src/services/reqresp/protocols/index.ts +0 -1
- package/src/services/reqresp/protocols/tx.ts +23 -3
- package/src/services/reqresp/rate-limiter/rate_limiter.ts +13 -9
- package/src/services/reqresp/rate-limiter/rate_limits.ts +3 -13
- package/src/services/reqresp/reqresp.ts +100 -263
- package/src/services/service.ts +80 -35
- package/src/services/tx_collection/config.ts +40 -49
- package/src/services/tx_collection/file_store_tx_collection.ts +153 -0
- package/src/services/tx_collection/file_store_tx_source.ts +129 -0
- package/src/services/tx_collection/index.ts +2 -6
- package/src/services/tx_collection/instrumentation.ts +1 -1
- package/src/services/tx_collection/request_tracker.ts +127 -0
- package/src/services/tx_collection/tx_collection.ts +362 -110
- package/src/services/tx_collection/tx_collection_sink.ts +32 -36
- package/src/services/tx_collection/tx_source.ts +29 -8
- package/src/services/tx_file_store/config.ts +0 -6
- package/src/services/tx_file_store/tx_file_store.ts +15 -25
- package/src/services/tx_provider.ts +15 -9
- package/src/test-helpers/make-test-p2p-clients.ts +7 -6
- package/src/test-helpers/mock-pubsub.ts +152 -14
- package/src/test-helpers/reqresp-nodes.ts +15 -28
- package/src/test-helpers/test_tx_provider.ts +5 -0
- package/src/test-helpers/testbench-utils.ts +171 -68
- package/src/testbench/p2p_client_testbench_worker.ts +121 -64
- package/src/testbench/worker_client_manager.ts +72 -25
- package/src/util.ts +40 -19
- 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 -122
- 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 -400
- 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 -37
- package/dest/msg_validators/proposal_validator/proposal_validator_test_suite.d.ts +0 -23
- package/dest/msg_validators/proposal_validator/proposal_validator_test_suite.d.ts.map +0 -1
- package/dest/msg_validators/proposal_validator/proposal_validator_test_suite.js +0 -212
- 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 -52
- package/dest/services/tx_collection/fast_tx_collection.d.ts.map +0 -1
- package/dest/services/tx_collection/fast_tx_collection.js +0 -307
- 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 -49
- package/dest/services/tx_collection/slow_tx_collection.d.ts +0 -53
- package/dest/services/tx_collection/slow_tx_collection.d.ts.map +0 -1
- package/dest/services/tx_collection/slow_tx_collection.js +0 -177
- package/src/client/test/tx_proposal_collector/proposal_tx_collector_worker.ts +0 -336
- 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 -162
- 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 -319
- package/src/msg_validators/clock_tolerance.ts +0 -51
- package/src/msg_validators/proposal_validator/proposal_validator_test_suite.ts +0 -230
- 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 -354
- package/src/services/tx_collection/proposal_tx_collector.ts +0 -112
- package/src/services/tx_collection/slow_tx_collection.ts +0 -233
package/src/services/service.ts
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import type { SlotNumber } from '@aztec/foundation/branded-types';
|
|
2
2
|
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
3
|
-
import type { PeerInfo } from '@aztec/stdlib/interfaces/server';
|
|
4
|
-
import type {
|
|
3
|
+
import type { P2PConnectivity, PeerInfo } from '@aztec/stdlib/interfaces/server';
|
|
4
|
+
import type {
|
|
5
|
+
CheckpointAttestation,
|
|
6
|
+
Gossipable,
|
|
7
|
+
TopicType,
|
|
8
|
+
ValidatedBlockProposal,
|
|
9
|
+
ValidatedCheckpointProposalCore,
|
|
10
|
+
} from '@aztec/stdlib/p2p';
|
|
5
11
|
import type { Tx } from '@aztec/stdlib/tx';
|
|
6
12
|
|
|
7
13
|
import type { PeerId } from '@libp2p/interface';
|
|
@@ -11,12 +17,7 @@ import type EventEmitter from 'events';
|
|
|
11
17
|
import type { BatchTxRequesterLibP2PService } from './reqresp/batch-tx-requester/interface.js';
|
|
12
18
|
import type { P2PReqRespConfig } from './reqresp/config.js';
|
|
13
19
|
import type { StatusMessage } from './reqresp/index.js';
|
|
14
|
-
import type {
|
|
15
|
-
ReqRespSubProtocol,
|
|
16
|
-
ReqRespSubProtocolHandler,
|
|
17
|
-
ReqRespSubProtocolValidators,
|
|
18
|
-
SubProtocolMap,
|
|
19
|
-
} from './reqresp/interface.js';
|
|
20
|
+
import type { ReqRespSubProtocol, ReqRespSubProtocolHandler } from './reqresp/interface.js';
|
|
20
21
|
import type { AuthRequest, AuthResponse } from './reqresp/protocols/auth.js';
|
|
21
22
|
|
|
22
23
|
export enum PeerDiscoveryState {
|
|
@@ -27,18 +28,21 @@ export enum PeerDiscoveryState {
|
|
|
27
28
|
/**
|
|
28
29
|
* Callback for when a block proposal is received.
|
|
29
30
|
* Validators validate but DO NOT attest to individual blocks - attestations are only for checkpoints.
|
|
31
|
+
* The proposal is passed as a ValidatedBlockProposal: it has already passed p2p ingress validation, and
|
|
32
|
+
* consumers are not expected to repeat it.
|
|
30
33
|
* @returns true if the proposal is valid, false otherwise
|
|
31
34
|
*/
|
|
32
|
-
export type P2PBlockReceivedCallback = (block:
|
|
35
|
+
export type P2PBlockReceivedCallback = (block: ValidatedBlockProposal, sender: PeerId) => Promise<boolean>;
|
|
33
36
|
|
|
34
37
|
/**
|
|
35
38
|
* Callback for when a checkpoint proposal is received.
|
|
36
|
-
* The checkpoint proposal is passed as
|
|
39
|
+
* The checkpoint proposal is passed as ValidatedCheckpointProposalCore (without lastBlock) since
|
|
37
40
|
* the lastBlock is extracted and stored separately as a BlockProposal, and the block
|
|
38
|
-
* callback is invoked and awaited before this checkpoint callback.
|
|
41
|
+
* callback is invoked and awaited before this checkpoint callback. As with block proposals, it has already
|
|
42
|
+
* passed p2p ingress validation.
|
|
39
43
|
*/
|
|
40
44
|
export type P2PCheckpointReceivedCallback = (
|
|
41
|
-
checkpoint:
|
|
45
|
+
checkpoint: ValidatedCheckpointProposalCore,
|
|
42
46
|
sender: PeerId,
|
|
43
47
|
) => Promise<CheckpointAttestation[] | undefined>;
|
|
44
48
|
|
|
@@ -57,6 +61,34 @@ export type DuplicateProposalInfo = {
|
|
|
57
61
|
*/
|
|
58
62
|
export type P2PDuplicateProposalCallback = (info: DuplicateProposalInfo) => void;
|
|
59
63
|
|
|
64
|
+
/** Minimal info passed to the oversized proposal callback. */
|
|
65
|
+
export type OversizedProposalInfo = {
|
|
66
|
+
slot: SlotNumber;
|
|
67
|
+
proposer: EthAddress;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Callback for when a block proposal whose index lands at or beyond the consensus per-checkpoint block
|
|
72
|
+
* limit is stored and re-broadcast as slashing evidence. May fire multiple times per (slot, proposer)
|
|
73
|
+
* if the proposer signed several oversized proposals; consumers are expected to dedup.
|
|
74
|
+
*/
|
|
75
|
+
export type P2POversizedProposalCallback = (info: OversizedProposalInfo) => void;
|
|
76
|
+
|
|
77
|
+
/** Minimal info passed to the duplicate attestation callback. */
|
|
78
|
+
export type DuplicateAttestationInfo = {
|
|
79
|
+
slot: SlotNumber;
|
|
80
|
+
attester: EthAddress;
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Callback for when a duplicate attestation is detected (equivocation).
|
|
85
|
+
* A validator signing attestations for different proposals at the same slot.
|
|
86
|
+
* Invoked on the first duplicate (when count goes from 1 to 2).
|
|
87
|
+
*/
|
|
88
|
+
export type P2PDuplicateAttestationCallback = (info: DuplicateAttestationInfo) => void;
|
|
89
|
+
|
|
90
|
+
export type P2PCheckpointAttestationCallback = (attestation: CheckpointAttestation) => void;
|
|
91
|
+
|
|
60
92
|
/**
|
|
61
93
|
* The interface for a P2P service implementation.
|
|
62
94
|
*/
|
|
@@ -79,26 +111,12 @@ export interface P2PService {
|
|
|
79
111
|
*/
|
|
80
112
|
propagate<T extends Gossipable>(message: T): Promise<void>;
|
|
81
113
|
|
|
82
|
-
/**
|
|
83
|
-
* Send a batch of requests to peers, and return the responses
|
|
84
|
-
*
|
|
85
|
-
* @param protocol - The request response protocol to use
|
|
86
|
-
* @param requests - The requests to send to the peers
|
|
87
|
-
* @returns The responses to the requests
|
|
88
|
-
*/
|
|
89
|
-
sendBatchRequest<Protocol extends ReqRespSubProtocol>(
|
|
90
|
-
protocol: Protocol,
|
|
91
|
-
requests: InstanceType<SubProtocolMap[Protocol]['request']>[],
|
|
92
|
-
pinnedPeerId?: PeerId,
|
|
93
|
-
timeoutMs?: number,
|
|
94
|
-
maxPeers?: number,
|
|
95
|
-
maxRetryAttempts?: number,
|
|
96
|
-
): Promise<InstanceType<SubProtocolMap[Protocol]['response']>[]>;
|
|
97
|
-
|
|
98
114
|
// Leaky abstraction: fix https://github.com/AztecProtocol/aztec-packages/issues/7963
|
|
99
115
|
registerBlockReceivedCallback(callback: P2PBlockReceivedCallback): void;
|
|
100
116
|
|
|
101
|
-
|
|
117
|
+
registerValidatorCheckpointReceivedCallback(callback: P2PCheckpointReceivedCallback): void;
|
|
118
|
+
|
|
119
|
+
registerAllNodesCheckpointReceivedCallback(callback: P2PCheckpointReceivedCallback): void;
|
|
102
120
|
|
|
103
121
|
/**
|
|
104
122
|
* Registers a callback invoked when a duplicate proposal is detected (equivocation).
|
|
@@ -106,17 +124,41 @@ export interface P2PService {
|
|
|
106
124
|
*/
|
|
107
125
|
registerDuplicateProposalCallback(callback: P2PDuplicateProposalCallback): void;
|
|
108
126
|
|
|
127
|
+
/**
|
|
128
|
+
* Registers a callback invoked when an oversized block proposal (index at or beyond the consensus
|
|
129
|
+
* per-checkpoint block limit) is stored and re-broadcast as slashing evidence.
|
|
130
|
+
*/
|
|
131
|
+
registerOversizedProposalCallback(callback: P2POversizedProposalCallback): void;
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Registers a callback invoked when a duplicate attestation is detected (equivocation).
|
|
135
|
+
* A validator signing attestations for different proposals at the same slot.
|
|
136
|
+
* The callback is triggered on the first duplicate (when count goes from 1 to 2).
|
|
137
|
+
*/
|
|
138
|
+
registerDuplicateAttestationCallback(callback: P2PDuplicateAttestationCallback): void;
|
|
139
|
+
|
|
140
|
+
registerCheckpointAttestationCallback(callback: P2PCheckpointAttestationCallback): void;
|
|
141
|
+
|
|
109
142
|
getEnr(): ENR | undefined;
|
|
110
143
|
|
|
111
144
|
getPeers(includePending?: boolean): PeerInfo[];
|
|
112
145
|
|
|
113
|
-
|
|
146
|
+
/**
|
|
147
|
+
* Returns whether this p2p service is a real p2p stack, and how many peers it is currently connected to.
|
|
148
|
+
* Implementations that do not run p2p at all report `enabled: false`.
|
|
149
|
+
*/
|
|
150
|
+
getP2PConnectivity(): P2PConnectivity;
|
|
114
151
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
152
|
+
/** Returns the number of peers in the GossipSub mesh for a given topic type. */
|
|
153
|
+
getGossipMeshPeerCount(topicType: TopicType): number;
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Runs minimum integrity validation on txs carried in a block proposal.
|
|
157
|
+
* @throws InvalidBlockProposalTxsError - If any tx fails validation.
|
|
158
|
+
*/
|
|
159
|
+
validateTxsReceivedInBlockProposal(txs: Tx[]): Promise<void>;
|
|
160
|
+
|
|
161
|
+
addReqRespSubProtocol(subProtocol: ReqRespSubProtocol, handler: ReqRespSubProtocolHandler): Promise<void>;
|
|
120
162
|
|
|
121
163
|
handleAuthRequestFromPeer(authRequest: AuthRequest, peerId: PeerId): Promise<StatusMessage>;
|
|
122
164
|
|
|
@@ -167,6 +209,9 @@ export interface PeerDiscoveryService extends EventEmitter {
|
|
|
167
209
|
on(event: 'peer:discovered', listener: (enr: ENR) => void): this;
|
|
168
210
|
emit(event: 'peer:discovered', enr: ENR): boolean;
|
|
169
211
|
|
|
212
|
+
on(event: 'ip:changed', listener: (ip: string) => void): this;
|
|
213
|
+
emit(event: 'ip:changed', ip: string): boolean;
|
|
214
|
+
|
|
170
215
|
getStatus(): PeerDiscoveryState;
|
|
171
216
|
|
|
172
217
|
getEnr(): ENR | undefined;
|
|
@@ -1,26 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type ConfigMappingsType,
|
|
3
|
-
booleanConfigHelper,
|
|
4
|
-
enumConfigHelper,
|
|
5
|
-
numberConfigHelper,
|
|
6
|
-
} from '@aztec/foundation/config';
|
|
1
|
+
import { type ConfigMappingsType, numberConfigHelper } from '@aztec/foundation/config';
|
|
7
2
|
import { MAX_RPC_TXS_LEN } from '@aztec/stdlib/interfaces/api-limit';
|
|
8
3
|
|
|
9
|
-
export type MissingTxsCollectorType = 'new' | 'old';
|
|
10
|
-
|
|
11
4
|
export type TxCollectionConfig = {
|
|
12
5
|
/** How long to wait before starting reqresp for fast collection */
|
|
13
6
|
txCollectionFastNodesTimeoutBeforeReqRespMs: number;
|
|
14
|
-
/** How often to collect from configured nodes */
|
|
15
|
-
txCollectionSlowNodesIntervalMs: number;
|
|
16
|
-
/** How ofter to collect from peers */
|
|
17
|
-
txCollectionSlowReqRespIntervalMs: number;
|
|
18
|
-
/** How long to wait for a reqresp response during slow collection */
|
|
19
|
-
txCollectionSlowReqRespTimeoutMs: number;
|
|
20
|
-
/** How often to reconcile found txs with the tx pool */
|
|
21
|
-
txCollectionReconcileIntervalMs: number;
|
|
22
|
-
/** Whether to disable the slow collection loop if we are dealing with any immediate requests */
|
|
23
|
-
txCollectionDisableSlowDuringFastRequests: boolean;
|
|
24
7
|
/** How many ms to wait between retried request to a node via RPC during fast collection */
|
|
25
8
|
txCollectionFastNodeIntervalMs: number;
|
|
26
9
|
/** A comma-separated list of Aztec node RPC URLs to use for tx collection */
|
|
@@ -29,8 +12,16 @@ export type TxCollectionConfig = {
|
|
|
29
12
|
txCollectionFastMaxParallelRequestsPerNode: number;
|
|
30
13
|
/** Maximum number of transactions to request from a node in a single batch */
|
|
31
14
|
txCollectionNodeRpcMaxBatchSize: number;
|
|
32
|
-
/**
|
|
33
|
-
|
|
15
|
+
/** A comma-separated list of file store URLs (s3://, gs://, file://, http://) for tx collection */
|
|
16
|
+
txCollectionFileStoreUrls: string[];
|
|
17
|
+
/** Delay in ms from reqresp start before file store collection begins */
|
|
18
|
+
txCollectionFileStoreFastDelayMs: number;
|
|
19
|
+
/** Number of concurrent workers for fast file store collection */
|
|
20
|
+
txCollectionFileStoreFastWorkerCount: number;
|
|
21
|
+
/** Base backoff time in ms for fast file store collection retries */
|
|
22
|
+
txCollectionFileStoreFastBackoffBaseMs: number;
|
|
23
|
+
/** Max backoff time in ms for fast file store collection retries */
|
|
24
|
+
txCollectionFileStoreFastBackoffMaxMs: number;
|
|
34
25
|
};
|
|
35
26
|
|
|
36
27
|
export const txCollectionConfigMappings: ConfigMappingsType<TxCollectionConfig> = {
|
|
@@ -39,31 +30,6 @@ export const txCollectionConfigMappings: ConfigMappingsType<TxCollectionConfig>
|
|
|
39
30
|
description: 'How long to wait before starting reqresp for fast collection',
|
|
40
31
|
...numberConfigHelper(200),
|
|
41
32
|
},
|
|
42
|
-
txCollectionSlowNodesIntervalMs: {
|
|
43
|
-
env: 'TX_COLLECTION_SLOW_NODES_INTERVAL_MS',
|
|
44
|
-
description: 'How often to collect from configured nodes in the slow collection loop',
|
|
45
|
-
...numberConfigHelper(12_000),
|
|
46
|
-
},
|
|
47
|
-
txCollectionSlowReqRespIntervalMs: {
|
|
48
|
-
env: 'TX_COLLECTION_SLOW_REQ_RESP_INTERVAL_MS',
|
|
49
|
-
description: 'How often to collect from peers via reqresp in the slow collection loop',
|
|
50
|
-
...numberConfigHelper(12_000),
|
|
51
|
-
},
|
|
52
|
-
txCollectionSlowReqRespTimeoutMs: {
|
|
53
|
-
env: 'TX_COLLECTION_SLOW_REQ_RESP_TIMEOUT_MS',
|
|
54
|
-
description: 'How long to wait for a reqresp response during slow collection',
|
|
55
|
-
...numberConfigHelper(20_000),
|
|
56
|
-
},
|
|
57
|
-
txCollectionReconcileIntervalMs: {
|
|
58
|
-
env: 'TX_COLLECTION_RECONCILE_INTERVAL_MS',
|
|
59
|
-
description: 'How often to reconcile found txs from the tx pool',
|
|
60
|
-
...numberConfigHelper(60_000),
|
|
61
|
-
},
|
|
62
|
-
txCollectionDisableSlowDuringFastRequests: {
|
|
63
|
-
env: 'TX_COLLECTION_DISABLE_SLOW_DURING_FAST_REQUESTS',
|
|
64
|
-
description: 'Whether to disable the slow collection loop if we are dealing with any immediate requests',
|
|
65
|
-
...booleanConfigHelper(true),
|
|
66
|
-
},
|
|
67
33
|
txCollectionFastNodeIntervalMs: {
|
|
68
34
|
env: 'TX_COLLECTION_FAST_NODE_INTERVAL_MS',
|
|
69
35
|
description: 'How many ms to wait between retried request to a node via RPC during fast collection',
|
|
@@ -90,9 +56,34 @@ export const txCollectionConfigMappings: ConfigMappingsType<TxCollectionConfig>
|
|
|
90
56
|
description: 'Maximum number of transactions to request from a node in a single batch',
|
|
91
57
|
...numberConfigHelper(MAX_RPC_TXS_LEN),
|
|
92
58
|
},
|
|
93
|
-
|
|
94
|
-
env: '
|
|
95
|
-
description: '
|
|
96
|
-
|
|
59
|
+
txCollectionFileStoreUrls: {
|
|
60
|
+
env: 'TX_COLLECTION_FILE_STORE_URLS',
|
|
61
|
+
description: 'A comma-separated list of file store URLs (s3://, gs://, file://, http://) for tx collection',
|
|
62
|
+
parseEnv: (val: string) =>
|
|
63
|
+
val
|
|
64
|
+
.split(',')
|
|
65
|
+
.map(url => url.trim())
|
|
66
|
+
.filter(url => url.length > 0),
|
|
67
|
+
defaultValue: [],
|
|
68
|
+
},
|
|
69
|
+
txCollectionFileStoreFastDelayMs: {
|
|
70
|
+
env: 'TX_COLLECTION_FILE_STORE_FAST_DELAY_MS',
|
|
71
|
+
description: 'Delay in ms from reqresp start before file store collection begins',
|
|
72
|
+
...numberConfigHelper(2_000),
|
|
73
|
+
},
|
|
74
|
+
txCollectionFileStoreFastWorkerCount: {
|
|
75
|
+
env: 'TX_COLLECTION_FILE_STORE_FAST_WORKER_COUNT',
|
|
76
|
+
description: 'Number of concurrent workers for fast file store collection',
|
|
77
|
+
...numberConfigHelper(5),
|
|
78
|
+
},
|
|
79
|
+
txCollectionFileStoreFastBackoffBaseMs: {
|
|
80
|
+
env: 'TX_COLLECTION_FILE_STORE_FAST_BACKOFF_BASE_MS',
|
|
81
|
+
description: 'Base backoff time in ms for fast file store collection retries',
|
|
82
|
+
...numberConfigHelper(1_000),
|
|
83
|
+
},
|
|
84
|
+
txCollectionFileStoreFastBackoffMaxMs: {
|
|
85
|
+
env: 'TX_COLLECTION_FILE_STORE_FAST_BACKOFF_MAX_MS',
|
|
86
|
+
description: 'Max backoff time in ms for fast file store collection retries',
|
|
87
|
+
...numberConfigHelper(5_000),
|
|
97
88
|
},
|
|
98
89
|
};
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { times } from '@aztec/foundation/collection';
|
|
2
|
+
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
3
|
+
import { sleep } from '@aztec/foundation/sleep';
|
|
4
|
+
import { DateProvider } from '@aztec/foundation/timer';
|
|
5
|
+
import { TxHash } from '@aztec/stdlib/tx';
|
|
6
|
+
|
|
7
|
+
import type { FileStoreTxSource } from './file_store_tx_source.js';
|
|
8
|
+
import type { IRequestTracker } from './request_tracker.js';
|
|
9
|
+
import type { TxAddContext, TxCollectionSink } from './tx_collection_sink.js';
|
|
10
|
+
|
|
11
|
+
/** Configuration for a FileStoreTxCollection instance. */
|
|
12
|
+
export type FileStoreCollectionConfig = {
|
|
13
|
+
workerCount: number;
|
|
14
|
+
backoffBaseMs: number;
|
|
15
|
+
backoffMaxMs: number;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
type FileStoreTxEntry = {
|
|
19
|
+
txHash: string;
|
|
20
|
+
attempts: number;
|
|
21
|
+
lastAttemptTime: number;
|
|
22
|
+
nextSourceIndex: number;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Collects txs from file stores as a fallback after P2P methods have been tried.
|
|
27
|
+
* Each call to startCollecting spins up its own worker pool which pulls entries with priority
|
|
28
|
+
* (fewest attempts first), retries with round-robin across sources, and applies exponential
|
|
29
|
+
* backoff between full cycles through all sources. Workers self-terminate when the request
|
|
30
|
+
* tracker is cancelled (deadline / all-fetched / external) or when there is nothing left to do.
|
|
31
|
+
*/
|
|
32
|
+
export class FileStoreTxCollection {
|
|
33
|
+
constructor(
|
|
34
|
+
private readonly sources: FileStoreTxSource[],
|
|
35
|
+
private readonly txCollectionSink: TxCollectionSink,
|
|
36
|
+
private readonly config: FileStoreCollectionConfig,
|
|
37
|
+
private readonly dateProvider: DateProvider = new DateProvider(),
|
|
38
|
+
private readonly log: Logger = createLogger('p2p:file_store_tx_collection'),
|
|
39
|
+
) {}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Spins up workers to download all txs still missing from the tracker, racing across the
|
|
43
|
+
* configured file store sources. Resolves once all workers settle.
|
|
44
|
+
*/
|
|
45
|
+
public async startCollecting(requestTracker: IRequestTracker, context: TxAddContext): Promise<void> {
|
|
46
|
+
if (this.sources.length === 0 || requestTracker.checkCancelled()) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// eslint-disable-next-line aztec-custom/no-non-primitive-in-collections
|
|
51
|
+
const entries: Set<FileStoreTxEntry> = new Set();
|
|
52
|
+
for (const hashStr of requestTracker.missingTxHashes) {
|
|
53
|
+
entries.add({
|
|
54
|
+
txHash: hashStr,
|
|
55
|
+
attempts: 0,
|
|
56
|
+
lastAttemptTime: 0,
|
|
57
|
+
nextSourceIndex: Math.floor(Math.random() * this.sources.length),
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// Yield before spawning so the synchronous caller can finish any follow-up (eg. marking a tx
|
|
62
|
+
// as fetched on the tracker, or cancelling it) before workers begin scanning entries.
|
|
63
|
+
await Promise.resolve();
|
|
64
|
+
if (requestTracker.checkCancelled()) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
await Promise.allSettled(times(this.config.workerCount, () => this.workerLoop(entries, requestTracker, context)));
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
private async workerLoop(
|
|
72
|
+
// eslint-disable-next-line aztec-custom/no-non-primitive-in-collections
|
|
73
|
+
entries: Set<FileStoreTxEntry>,
|
|
74
|
+
requestTracker: IRequestTracker,
|
|
75
|
+
context: TxAddContext,
|
|
76
|
+
): Promise<void> {
|
|
77
|
+
while (!requestTracker.checkCancelled() && entries.size > 0) {
|
|
78
|
+
const action = this.getNextAction(entries, requestTracker);
|
|
79
|
+
if (action.type === 'sleep') {
|
|
80
|
+
await Promise.race([sleep(action.ms), requestTracker.cancellationToken]);
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const entry = action.entry;
|
|
85
|
+
const source = this.sources[entry.nextSourceIndex % this.sources.length];
|
|
86
|
+
entry.nextSourceIndex++;
|
|
87
|
+
entry.attempts++;
|
|
88
|
+
entry.lastAttemptTime = this.dateProvider.now();
|
|
89
|
+
|
|
90
|
+
try {
|
|
91
|
+
const result = await this.txCollectionSink.collect(
|
|
92
|
+
() => source.getTxsByHash([TxHash.fromString(entry.txHash)]),
|
|
93
|
+
[entry.txHash],
|
|
94
|
+
{
|
|
95
|
+
description: `file-store ${source.getInfo()}`,
|
|
96
|
+
method: 'file-store',
|
|
97
|
+
fileStore: source.getInfo(),
|
|
98
|
+
},
|
|
99
|
+
context,
|
|
100
|
+
);
|
|
101
|
+
if (result.txs.length > 0) {
|
|
102
|
+
entries.delete(entry);
|
|
103
|
+
}
|
|
104
|
+
} catch (err) {
|
|
105
|
+
this.log.trace(`Error downloading tx ${entry.txHash} from ${source.getInfo()}`, { err });
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/** Single-pass scan: removes stale entries, finds the best ready entry, or computes sleep time. */
|
|
111
|
+
private getNextAction(
|
|
112
|
+
// eslint-disable-next-line aztec-custom/no-non-primitive-in-collections
|
|
113
|
+
entries: Set<FileStoreTxEntry>,
|
|
114
|
+
requestTracker: IRequestTracker,
|
|
115
|
+
): { type: 'process'; entry: FileStoreTxEntry } | { type: 'sleep'; ms: number } {
|
|
116
|
+
const now = this.dateProvider.now();
|
|
117
|
+
let best: FileStoreTxEntry | undefined;
|
|
118
|
+
let earliestReadyAt = Infinity;
|
|
119
|
+
|
|
120
|
+
for (const entry of entries) {
|
|
121
|
+
// Drop entries whose tx was already found via another collection path.
|
|
122
|
+
if (!requestTracker.isMissing(entry.txHash)) {
|
|
123
|
+
entries.delete(entry);
|
|
124
|
+
continue;
|
|
125
|
+
}
|
|
126
|
+
const backoffMs = this.getBackoffMs(entry);
|
|
127
|
+
const readyAt = entry.lastAttemptTime + backoffMs;
|
|
128
|
+
if (readyAt > now) {
|
|
129
|
+
earliestReadyAt = Math.min(earliestReadyAt, readyAt);
|
|
130
|
+
continue;
|
|
131
|
+
}
|
|
132
|
+
if (!best || entry.attempts < best.attempts) {
|
|
133
|
+
best = entry;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
if (best) {
|
|
138
|
+
return { type: 'process', entry: best };
|
|
139
|
+
}
|
|
140
|
+
// earliestReadyAt is finite whenever there are surviving entries; if entries became empty,
|
|
141
|
+
// the outer worker loop will exit on its next iteration via entries.size === 0.
|
|
142
|
+
return { type: 'sleep', ms: earliestReadyAt === Infinity ? 0 : earliestReadyAt - now };
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/** Computes backoff for an entry. Backoff applies after a full cycle through all sources. */
|
|
146
|
+
private getBackoffMs(entry: FileStoreTxEntry): number {
|
|
147
|
+
const fullCycles = Math.floor(entry.attempts / this.sources.length);
|
|
148
|
+
if (fullCycles === 0) {
|
|
149
|
+
return 0;
|
|
150
|
+
}
|
|
151
|
+
return Math.min(this.config.backoffBaseMs * Math.pow(2, fullCycles - 1), this.config.backoffMaxMs);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { partitionAsync } from '@aztec/foundation/collection';
|
|
2
|
+
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
3
|
+
import { Timer } from '@aztec/foundation/timer';
|
|
4
|
+
import { type ReadOnlyFileStore, createReadOnlyFileStore } from '@aztec/stdlib/file-store';
|
|
5
|
+
import { Tx, type TxHash, type TxValidator } from '@aztec/stdlib/tx';
|
|
6
|
+
import {
|
|
7
|
+
type Histogram,
|
|
8
|
+
Metrics,
|
|
9
|
+
type TelemetryClient,
|
|
10
|
+
type UpDownCounter,
|
|
11
|
+
getTelemetryClient,
|
|
12
|
+
} from '@aztec/telemetry-client';
|
|
13
|
+
|
|
14
|
+
import type { TxSource, TxSourceCollectionResult } from './tx_source.js';
|
|
15
|
+
|
|
16
|
+
/** TxSource implementation that downloads txs from a file store. */
|
|
17
|
+
export class FileStoreTxSource implements TxSource {
|
|
18
|
+
private downloadsSuccess: UpDownCounter;
|
|
19
|
+
private downloadsFailed: UpDownCounter;
|
|
20
|
+
private downloadDuration: Histogram;
|
|
21
|
+
private downloadSize: Histogram;
|
|
22
|
+
|
|
23
|
+
private constructor(
|
|
24
|
+
private readonly fileStore: ReadOnlyFileStore,
|
|
25
|
+
private readonly baseUrl: string,
|
|
26
|
+
private readonly basePath: string,
|
|
27
|
+
private readonly txValidator: TxValidator,
|
|
28
|
+
private readonly log: Logger,
|
|
29
|
+
telemetry: TelemetryClient,
|
|
30
|
+
) {
|
|
31
|
+
const meter = telemetry.getMeter('file-store-tx-source');
|
|
32
|
+
this.downloadsSuccess = meter.createUpDownCounter(Metrics.TX_FILE_STORE_DOWNLOADS_SUCCESS);
|
|
33
|
+
this.downloadsFailed = meter.createUpDownCounter(Metrics.TX_FILE_STORE_DOWNLOADS_FAILED);
|
|
34
|
+
this.downloadDuration = meter.createHistogram(Metrics.TX_FILE_STORE_DOWNLOAD_DURATION);
|
|
35
|
+
this.downloadSize = meter.createHistogram(Metrics.TX_FILE_STORE_DOWNLOAD_SIZE);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Creates a FileStoreTxSource from a URL.
|
|
40
|
+
* @param url - The file store URL (s3://, gs://, file://, http://, https://).
|
|
41
|
+
* @param basePath - Base path for tx files within the store.
|
|
42
|
+
* @param log - Optional logger.
|
|
43
|
+
* @param telemetry - Optional telemetry client.
|
|
44
|
+
* @returns The FileStoreTxSource instance, or undefined if creation fails.
|
|
45
|
+
*/
|
|
46
|
+
public static async create(
|
|
47
|
+
url: string,
|
|
48
|
+
basePath: string,
|
|
49
|
+
txValidator: TxValidator,
|
|
50
|
+
log: Logger = createLogger('p2p:file_store_tx_source'),
|
|
51
|
+
telemetry: TelemetryClient = getTelemetryClient(),
|
|
52
|
+
): Promise<FileStoreTxSource | undefined> {
|
|
53
|
+
try {
|
|
54
|
+
const fileStore = await createReadOnlyFileStore(url, log);
|
|
55
|
+
if (!fileStore) {
|
|
56
|
+
log.warn(`Failed to create file store for URL: ${url}`);
|
|
57
|
+
return undefined;
|
|
58
|
+
}
|
|
59
|
+
return new FileStoreTxSource(fileStore, url, basePath, txValidator, log, telemetry);
|
|
60
|
+
} catch (err) {
|
|
61
|
+
log.warn(`Error creating file store for URL: ${url}`, { error: err });
|
|
62
|
+
return undefined;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
public getInfo(): string {
|
|
67
|
+
return `file-store:${this.baseUrl}`;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
public async getTxsByHash(txHashes: TxHash[]): Promise<TxSourceCollectionResult> {
|
|
71
|
+
const results = await Promise.all(
|
|
72
|
+
txHashes.map(async txHash => {
|
|
73
|
+
const path = `${this.basePath}/txs/${txHash.toString()}.bin`;
|
|
74
|
+
const timer = new Timer();
|
|
75
|
+
try {
|
|
76
|
+
const buffer = await this.fileStore.read(path);
|
|
77
|
+
const tx = Tx.fromBuffer(buffer);
|
|
78
|
+
return { tx, downloadDuration: timer.ms(), downloadSize: buffer.length };
|
|
79
|
+
} catch {
|
|
80
|
+
this.downloadsFailed.add(1);
|
|
81
|
+
return undefined;
|
|
82
|
+
}
|
|
83
|
+
}),
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
const txs = results.filter(tx => tx !== undefined);
|
|
87
|
+
const [validTxs, invalidTxs] = await partitionAsync(
|
|
88
|
+
txs,
|
|
89
|
+
async ({ tx, downloadDuration, downloadSize }): Promise<boolean> => {
|
|
90
|
+
const valid = await this.txValidator.validateTx(tx);
|
|
91
|
+
if (valid.result === 'valid') {
|
|
92
|
+
this.downloadsSuccess.add(1);
|
|
93
|
+
this.downloadDuration.record(Math.ceil(downloadDuration));
|
|
94
|
+
this.downloadSize.record(downloadSize);
|
|
95
|
+
return true;
|
|
96
|
+
} else {
|
|
97
|
+
this.downloadsFailed.add(1);
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
);
|
|
102
|
+
|
|
103
|
+
return {
|
|
104
|
+
validTxs: validTxs.map(({ tx }) => tx),
|
|
105
|
+
invalidTxHashes: invalidTxs.map(({ tx }) => tx.getTxHash().toString()),
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Creates FileStoreTxSource instances from URLs.
|
|
112
|
+
* @param urls - Array of file store URLs.
|
|
113
|
+
* @param basePath - Base path for tx files within each store.
|
|
114
|
+
* @param log - Optional logger.
|
|
115
|
+
* @param telemetry - Optional telemetry client.
|
|
116
|
+
* @returns Array of successfully created FileStoreTxSource instances.
|
|
117
|
+
*/
|
|
118
|
+
export async function createFileStoreTxSources(
|
|
119
|
+
urls: string[],
|
|
120
|
+
basePath: string,
|
|
121
|
+
txValidator: TxValidator,
|
|
122
|
+
log: Logger = createLogger('p2p:file_store_tx_source'),
|
|
123
|
+
telemetry: TelemetryClient = getTelemetryClient(),
|
|
124
|
+
): Promise<FileStoreTxSource[]> {
|
|
125
|
+
const sources = await Promise.all(
|
|
126
|
+
urls.map(url => FileStoreTxSource.create(url, basePath, txValidator, log, telemetry)),
|
|
127
|
+
);
|
|
128
|
+
return sources.filter((s): s is FileStoreTxSource => s !== undefined);
|
|
129
|
+
}
|
|
@@ -1,7 +1,3 @@
|
|
|
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 {
|
|
4
|
-
type MissingTxsCollector,
|
|
5
|
-
BatchTxRequesterCollector,
|
|
6
|
-
SendBatchRequestCollector,
|
|
7
|
-
} from './proposal_tx_collector.js';
|
|
3
|
+
export { FileStoreTxSource, createFileStoreTxSources } from './file_store_tx_source.js';
|
|
@@ -18,7 +18,7 @@ export class TxCollectionInstrumentation {
|
|
|
18
18
|
const meter = client.getMeter(name);
|
|
19
19
|
|
|
20
20
|
this.txsCollected = createUpDownCounterWithDefault(meter, Metrics.TX_COLLECTOR_COUNT, {
|
|
21
|
-
[Attributes.TX_COLLECTION_METHOD]: ['fast-req-resp', 'fast-node-rpc', '
|
|
21
|
+
[Attributes.TX_COLLECTION_METHOD]: ['fast-req-resp', 'fast-node-rpc', 'file-store'],
|
|
22
22
|
});
|
|
23
23
|
|
|
24
24
|
this.collectionDurationPerTx = meter.createHistogram(Metrics.TX_COLLECTOR_DURATION_PER_TX);
|