@aztec/p2p 0.0.1-commit.8afd444 → 0.0.1-commit.9117c5f5a
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dest/client/factory.d.ts +10 -10
- package/dest/client/factory.d.ts.map +1 -1
- package/dest/client/factory.js +39 -15
- package/dest/client/interface.d.ts +46 -33
- package/dest/client/interface.d.ts.map +1 -1
- package/dest/client/p2p_client.d.ts +39 -51
- package/dest/client/p2p_client.d.ts.map +1 -1
- package/dest/client/p2p_client.js +145 -200
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.js +7 -8
- package/dest/config.d.ts +25 -9
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +16 -6
- package/dest/errors/tx-pool.error.d.ts +8 -0
- package/dest/errors/tx-pool.error.d.ts.map +1 -0
- package/dest/errors/tx-pool.error.js +9 -0
- package/dest/index.d.ts +2 -1
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +1 -0
- package/dest/mem_pools/attestation_pool/attestation_pool.d.ts +104 -88
- package/dest/mem_pools/attestation_pool/attestation_pool.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/attestation_pool.js +441 -3
- package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.d.ts +2 -2
- package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.js +353 -87
- package/dest/mem_pools/attestation_pool/index.d.ts +2 -3
- package/dest/mem_pools/attestation_pool/index.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/index.js +1 -2
- package/dest/mem_pools/attestation_pool/mocks.d.ts +2 -2
- package/dest/mem_pools/attestation_pool/mocks.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/mocks.js +2 -2
- package/dest/mem_pools/index.d.ts +3 -2
- package/dest/mem_pools/index.d.ts.map +1 -1
- package/dest/mem_pools/index.js +1 -1
- package/dest/mem_pools/interface.d.ts +5 -5
- package/dest/mem_pools/interface.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.js +3 -3
- package/dest/mem_pools/tx_pool_v2/archive/index.d.ts +2 -0
- package/dest/mem_pools/tx_pool_v2/archive/index.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/archive/index.js +1 -0
- package/dest/mem_pools/tx_pool_v2/archive/tx_archive.d.ts +43 -0
- package/dest/mem_pools/tx_pool_v2/archive/tx_archive.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/archive/tx_archive.js +103 -0
- package/dest/mem_pools/tx_pool_v2/deleted_pool.d.ts +104 -0
- package/dest/mem_pools/tx_pool_v2/deleted_pool.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/deleted_pool.js +251 -0
- package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.d.ts +47 -0
- package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.js +128 -0
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.d.ts +17 -0
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.js +93 -0
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.d.ts +19 -0
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.js +97 -0
- package/dest/mem_pools/tx_pool_v2/eviction/index.d.ts +10 -0
- package/dest/mem_pools/tx_pool_v2/eviction/index.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/eviction/index.js +11 -0
- package/dest/mem_pools/tx_pool_v2/eviction/interfaces.d.ts +174 -0
- package/dest/mem_pools/tx_pool_v2/eviction/interfaces.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/eviction/interfaces.js +25 -0
- package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.d.ts +15 -0
- package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.js +65 -0
- package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.d.ts +17 -0
- package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.js +93 -0
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.d.ts +16 -0
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.js +78 -0
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.d.ts +20 -0
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.js +73 -0
- package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.d.ts +15 -0
- package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.js +19 -0
- package/dest/mem_pools/tx_pool_v2/index.d.ts +6 -0
- package/dest/mem_pools/tx_pool_v2/index.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/index.js +5 -0
- package/dest/mem_pools/tx_pool_v2/instrumentation.d.ts +15 -0
- package/dest/mem_pools/tx_pool_v2/instrumentation.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/instrumentation.js +43 -0
- package/dest/mem_pools/tx_pool_v2/interfaces.d.ts +211 -0
- package/dest/mem_pools/tx_pool_v2/interfaces.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/interfaces.js +9 -0
- package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts +119 -0
- package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/tx_metadata.js +193 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_bench_metrics.d.ts +26 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_bench_metrics.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_bench_metrics.js +70 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_indices.d.ts +108 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_indices.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_indices.js +354 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts +60 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2.js +161 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts +77 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.js +905 -0
- package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.d.ts +3 -3
- package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/aggregate_tx_validator.d.ts +4 -4
- package/dest/msg_validators/tx_validator/aggregate_tx_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/aggregate_tx_validator.js +3 -3
- package/dest/msg_validators/tx_validator/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/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 +114 -6
- package/dest/msg_validators/tx_validator/factory.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/factory.js +219 -58
- package/dest/msg_validators/tx_validator/gas_validator.d.ts +58 -3
- package/dest/msg_validators/tx_validator/gas_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/gas_validator.js +73 -36
- package/dest/msg_validators/tx_validator/index.d.ts +2 -1
- package/dest/msg_validators/tx_validator/index.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/index.js +1 -0
- package/dest/msg_validators/tx_validator/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/timestamp_validator.d.ts +20 -4
- package/dest/msg_validators/tx_validator/timestamp_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/timestamp_validator.js +6 -6
- package/dest/services/dummy_service.d.ts +13 -5
- package/dest/services/dummy_service.d.ts.map +1 -1
- package/dest/services/dummy_service.js +10 -4
- package/dest/services/encoding.d.ts +3 -3
- package/dest/services/encoding.d.ts.map +1 -1
- package/dest/services/encoding.js +11 -10
- package/dest/services/gossipsub/index.d.ts +3 -0
- package/dest/services/gossipsub/index.d.ts.map +1 -0
- package/dest/services/gossipsub/index.js +2 -0
- package/dest/services/gossipsub/scoring.d.ts +21 -3
- package/dest/services/gossipsub/scoring.d.ts.map +1 -1
- package/dest/services/gossipsub/scoring.js +24 -7
- package/dest/services/gossipsub/topic_score_params.d.ts +173 -0
- package/dest/services/gossipsub/topic_score_params.d.ts.map +1 -0
- package/dest/services/gossipsub/topic_score_params.js +346 -0
- package/dest/services/libp2p/libp2p_service.d.ts +94 -42
- package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
- package/dest/services/libp2p/libp2p_service.js +420 -337
- package/dest/services/peer-manager/peer_scoring.d.ts +1 -1
- package/dest/services/peer-manager/peer_scoring.d.ts.map +1 -1
- package/dest/services/peer-manager/peer_scoring.js +25 -2
- package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts +6 -5
- package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts.map +1 -1
- package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.js +26 -53
- package/dest/services/reqresp/batch-tx-requester/interface.d.ts +2 -6
- package/dest/services/reqresp/batch-tx-requester/interface.d.ts.map +1 -1
- package/dest/services/reqresp/batch-tx-requester/missing_txs.d.ts +10 -13
- package/dest/services/reqresp/batch-tx-requester/missing_txs.d.ts.map +1 -1
- package/dest/services/reqresp/batch-tx-requester/missing_txs.js +25 -46
- package/dest/services/reqresp/batch-tx-requester/peer_collection.d.ts +17 -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 +49 -15
- package/dest/services/reqresp/batch-tx-requester/tx_validator.js +2 -2
- package/dest/services/reqresp/interface.d.ts +10 -1
- package/dest/services/reqresp/interface.d.ts.map +1 -1
- package/dest/services/reqresp/interface.js +15 -1
- package/dest/services/reqresp/protocols/block_txs/block_txs_handler.d.ts +7 -5
- package/dest/services/reqresp/protocols/block_txs/block_txs_handler.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/block_txs/block_txs_handler.js +16 -11
- package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.d.ts +21 -10
- 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 +27 -11
- package/dest/services/reqresp/protocols/tx.d.ts +7 -1
- package/dest/services/reqresp/protocols/tx.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/tx.js +20 -0
- package/dest/services/reqresp/reqresp.d.ts +1 -1
- package/dest/services/reqresp/reqresp.d.ts.map +1 -1
- package/dest/services/reqresp/reqresp.js +13 -5
- package/dest/services/service.d.ts +39 -3
- package/dest/services/service.d.ts.map +1 -1
- package/dest/services/tx_collection/config.d.ts +22 -4
- package/dest/services/tx_collection/config.d.ts.map +1 -1
- package/dest/services/tx_collection/config.js +49 -3
- package/dest/services/tx_collection/fast_tx_collection.d.ts +6 -5
- package/dest/services/tx_collection/fast_tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/fast_tx_collection.js +64 -48
- package/dest/services/tx_collection/file_store_tx_collection.d.ts +53 -0
- package/dest/services/tx_collection/file_store_tx_collection.d.ts.map +1 -0
- package/dest/services/tx_collection/file_store_tx_collection.js +167 -0
- package/dest/services/tx_collection/file_store_tx_source.d.ts +37 -0
- package/dest/services/tx_collection/file_store_tx_source.d.ts.map +1 -0
- package/dest/services/tx_collection/file_store_tx_source.js +90 -0
- package/dest/services/tx_collection/index.d.ts +3 -2
- package/dest/services/tx_collection/index.d.ts.map +1 -1
- package/dest/services/tx_collection/index.js +1 -0
- package/dest/services/tx_collection/instrumentation.d.ts +1 -1
- package/dest/services/tx_collection/instrumentation.d.ts.map +1 -1
- package/dest/services/tx_collection/instrumentation.js +2 -1
- package/dest/services/tx_collection/missing_txs_tracker.d.ts +32 -0
- package/dest/services/tx_collection/missing_txs_tracker.d.ts.map +1 -0
- package/dest/services/tx_collection/missing_txs_tracker.js +27 -0
- package/dest/services/tx_collection/proposal_tx_collector.d.ts +15 -14
- package/dest/services/tx_collection/proposal_tx_collector.d.ts.map +1 -1
- package/dest/services/tx_collection/proposal_tx_collector.js +6 -6
- package/dest/services/tx_collection/slow_tx_collection.d.ts +7 -3
- package/dest/services/tx_collection/slow_tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/slow_tx_collection.js +60 -26
- package/dest/services/tx_collection/tx_collection.d.ts +23 -10
- package/dest/services/tx_collection/tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/tx_collection.js +75 -3
- package/dest/services/tx_collection/tx_collection_sink.d.ts +18 -8
- package/dest/services/tx_collection/tx_collection_sink.d.ts.map +1 -1
- package/dest/services/tx_collection/tx_collection_sink.js +26 -29
- package/dest/services/tx_collection/tx_source.d.ts +8 -3
- package/dest/services/tx_collection/tx_source.d.ts.map +1 -1
- package/dest/services/tx_collection/tx_source.js +19 -2
- package/dest/services/tx_file_store/config.d.ts +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 -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 +9 -6
- package/dest/services/tx_provider.d.ts +4 -4
- package/dest/services/tx_provider.d.ts.map +1 -1
- package/dest/services/tx_provider.js +9 -8
- package/dest/test-helpers/make-test-p2p-clients.d.ts +7 -8
- package/dest/test-helpers/make-test-p2p-clients.d.ts.map +1 -1
- package/dest/test-helpers/make-test-p2p-clients.js +1 -2
- package/dest/test-helpers/mock-pubsub.d.ts +30 -4
- package/dest/test-helpers/mock-pubsub.d.ts.map +1 -1
- package/dest/test-helpers/mock-pubsub.js +105 -4
- package/dest/test-helpers/reqresp-nodes.d.ts +2 -3
- package/dest/test-helpers/reqresp-nodes.d.ts.map +1 -1
- package/dest/test-helpers/reqresp-nodes.js +4 -3
- package/dest/test-helpers/testbench-utils.d.ts +43 -38
- package/dest/test-helpers/testbench-utils.d.ts.map +1 -1
- package/dest/test-helpers/testbench-utils.js +128 -59
- package/dest/testbench/p2p_client_testbench_worker.d.ts +2 -2
- package/dest/testbench/p2p_client_testbench_worker.d.ts.map +1 -1
- package/dest/testbench/p2p_client_testbench_worker.js +15 -15
- package/dest/util.d.ts +2 -2
- package/dest/util.d.ts.map +1 -1
- package/package.json +14 -14
- package/src/client/factory.ts +74 -27
- package/src/client/interface.ts +56 -34
- package/src/client/p2p_client.ts +180 -247
- package/src/client/test/tx_proposal_collector/proposal_tx_collector_worker.ts +20 -11
- package/src/config.ts +35 -11
- package/src/errors/tx-pool.error.ts +12 -0
- package/src/index.ts +1 -0
- package/src/mem_pools/attestation_pool/attestation_pool.ts +496 -91
- package/src/mem_pools/attestation_pool/attestation_pool_test_suite.ts +442 -102
- package/src/mem_pools/attestation_pool/index.ts +9 -2
- package/src/mem_pools/attestation_pool/mocks.ts +2 -1
- package/src/mem_pools/index.ts +4 -1
- package/src/mem_pools/interface.ts +4 -4
- package/src/mem_pools/tx_pool/README.md +1 -1
- package/src/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.ts +3 -3
- package/src/mem_pools/tx_pool_v2/README.md +275 -0
- package/src/mem_pools/tx_pool_v2/archive/index.ts +1 -0
- package/src/mem_pools/tx_pool_v2/archive/tx_archive.ts +120 -0
- package/src/mem_pools/tx_pool_v2/deleted_pool.ts +321 -0
- package/src/mem_pools/tx_pool_v2/eviction/eviction_manager.ts +160 -0
- package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.ts +121 -0
- package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.ts +125 -0
- package/src/mem_pools/tx_pool_v2/eviction/index.ts +27 -0
- package/src/mem_pools/tx_pool_v2/eviction/interfaces.ts +209 -0
- package/src/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.ts +74 -0
- package/src/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.ts +101 -0
- package/src/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.ts +91 -0
- package/src/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.ts +90 -0
- package/src/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.ts +31 -0
- package/src/mem_pools/tx_pool_v2/index.ts +12 -0
- package/src/mem_pools/tx_pool_v2/instrumentation.ts +69 -0
- package/src/mem_pools/tx_pool_v2/interfaces.ts +242 -0
- package/src/mem_pools/tx_pool_v2/tx_metadata.ts +297 -0
- package/src/mem_pools/tx_pool_v2/tx_pool_bench_metrics.ts +77 -0
- package/src/mem_pools/tx_pool_v2/tx_pool_indices.ts +444 -0
- package/src/mem_pools/tx_pool_v2/tx_pool_v2.ts +223 -0
- package/src/mem_pools/tx_pool_v2/tx_pool_v2_impl.ts +1083 -0
- package/src/msg_validators/attestation_validator/fisherman_attestation_validator.ts +2 -2
- package/src/msg_validators/tx_validator/README.md +115 -0
- package/src/msg_validators/tx_validator/aggregate_tx_validator.ts +5 -5
- package/src/msg_validators/tx_validator/block_header_validator.ts +15 -3
- package/src/msg_validators/tx_validator/double_spend_validator.ts +11 -6
- package/src/msg_validators/tx_validator/factory.ts +353 -77
- package/src/msg_validators/tx_validator/gas_validator.ts +90 -27
- package/src/msg_validators/tx_validator/index.ts +1 -0
- package/src/msg_validators/tx_validator/nullifier_cache.ts +30 -0
- package/src/msg_validators/tx_validator/timestamp_validator.ts +23 -18
- package/src/services/dummy_service.ts +18 -6
- package/src/services/encoding.ts +9 -9
- package/src/services/gossipsub/README.md +641 -0
- package/src/services/gossipsub/index.ts +2 -0
- package/src/services/gossipsub/scoring.ts +29 -5
- package/src/services/gossipsub/topic_score_params.ts +487 -0
- package/src/services/libp2p/libp2p_service.ts +445 -360
- package/src/services/peer-manager/peer_scoring.ts +25 -0
- package/src/services/reqresp/batch-tx-requester/README.md +7 -7
- package/src/services/reqresp/batch-tx-requester/batch_tx_requester.ts +31 -59
- package/src/services/reqresp/batch-tx-requester/interface.ts +1 -5
- package/src/services/reqresp/batch-tx-requester/missing_txs.ts +23 -71
- package/src/services/reqresp/batch-tx-requester/peer_collection.ts +63 -24
- package/src/services/reqresp/batch-tx-requester/tx_validator.ts +2 -2
- package/src/services/reqresp/interface.ts +26 -1
- package/src/services/reqresp/protocols/block_txs/block_txs_handler.ts +23 -14
- package/src/services/reqresp/protocols/block_txs/block_txs_reqresp.ts +38 -15
- package/src/services/reqresp/protocols/tx.ts +22 -0
- package/src/services/reqresp/reqresp.ts +16 -4
- package/src/services/service.ts +51 -2
- package/src/services/tx_collection/config.ts +74 -6
- package/src/services/tx_collection/fast_tx_collection.ts +74 -51
- package/src/services/tx_collection/file_store_tx_collection.ts +202 -0
- package/src/services/tx_collection/file_store_tx_source.ts +117 -0
- package/src/services/tx_collection/index.ts +2 -1
- package/src/services/tx_collection/instrumentation.ts +7 -1
- package/src/services/tx_collection/missing_txs_tracker.ts +52 -0
- package/src/services/tx_collection/proposal_tx_collector.ts +20 -21
- package/src/services/tx_collection/slow_tx_collection.ts +66 -33
- package/src/services/tx_collection/tx_collection.ts +113 -16
- package/src/services/tx_collection/tx_collection_sink.ts +30 -34
- package/src/services/tx_collection/tx_source.ts +22 -3
- package/src/services/tx_file_store/config.ts +0 -6
- package/src/services/tx_file_store/tx_file_store.ts +10 -8
- package/src/services/tx_provider.ts +10 -9
- package/src/test-helpers/make-test-p2p-clients.ts +3 -5
- package/src/test-helpers/mock-pubsub.ts +146 -9
- package/src/test-helpers/reqresp-nodes.ts +4 -6
- package/src/test-helpers/testbench-utils.ts +127 -71
- package/src/testbench/p2p_client_testbench_worker.ts +24 -21
- package/src/util.ts +7 -1
- package/dest/mem_pools/attestation_pool/kv_attestation_pool.d.ts +0 -40
- package/dest/mem_pools/attestation_pool/kv_attestation_pool.d.ts.map +0 -1
- package/dest/mem_pools/attestation_pool/kv_attestation_pool.js +0 -218
- package/dest/mem_pools/attestation_pool/memory_attestation_pool.d.ts +0 -31
- package/dest/mem_pools/attestation_pool/memory_attestation_pool.d.ts.map +0 -1
- package/dest/mem_pools/attestation_pool/memory_attestation_pool.js +0 -180
- package/src/mem_pools/attestation_pool/kv_attestation_pool.ts +0 -320
- package/src/mem_pools/attestation_pool/memory_attestation_pool.ts +0 -264
|
@@ -6,9 +6,11 @@ import type { Tx, TxHash } from '@aztec/stdlib/tx';
|
|
|
6
6
|
import { type ComponentsVersions, getComponentsVersionsFromConfig } from '@aztec/stdlib/versioning';
|
|
7
7
|
import { makeTracedFetch } from '@aztec/telemetry-client';
|
|
8
8
|
|
|
9
|
+
export type TxSourceCollectionResult = { validTxs: Tx[]; invalidTxHashes: string[] };
|
|
10
|
+
|
|
9
11
|
export interface TxSource {
|
|
10
12
|
getInfo(): string;
|
|
11
|
-
getTxsByHash(txHashes: TxHash[]): Promise<
|
|
13
|
+
getTxsByHash(txHashes: TxHash[]): Promise<TxSourceCollectionResult>;
|
|
12
14
|
}
|
|
13
15
|
|
|
14
16
|
export class NodeRpcTxSource implements TxSource {
|
|
@@ -26,8 +28,25 @@ export class NodeRpcTxSource implements TxSource {
|
|
|
26
28
|
return this.info;
|
|
27
29
|
}
|
|
28
30
|
|
|
29
|
-
public getTxsByHash(txHashes: TxHash[]): Promise<
|
|
30
|
-
return this.client.getTxsByHash(txHashes);
|
|
31
|
+
public async getTxsByHash(txHashes: TxHash[]): Promise<TxSourceCollectionResult> {
|
|
32
|
+
return this.verifyTxs(await this.client.getTxsByHash(txHashes));
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
private async verifyTxs(txs: Tx[]): Promise<TxSourceCollectionResult> {
|
|
36
|
+
// Validate tx hashes for all collected txs from external sources
|
|
37
|
+
const validTxs: Tx[] = [];
|
|
38
|
+
const invalidTxHashes: string[] = [];
|
|
39
|
+
await Promise.all(
|
|
40
|
+
txs.map(async tx => {
|
|
41
|
+
const isValid = await tx.validateTxHash();
|
|
42
|
+
if (isValid) {
|
|
43
|
+
validTxs.push(tx);
|
|
44
|
+
} else {
|
|
45
|
+
invalidTxHashes.push(tx.getTxHash().toString());
|
|
46
|
+
}
|
|
47
|
+
}),
|
|
48
|
+
);
|
|
49
|
+
return { validTxs: validTxs, invalidTxHashes: invalidTxHashes };
|
|
31
50
|
}
|
|
32
51
|
}
|
|
33
52
|
|
|
@@ -6,8 +6,6 @@ import { type ConfigMappingsType, booleanConfigHelper, numberConfigHelper } from
|
|
|
6
6
|
export type TxFileStoreConfig = {
|
|
7
7
|
/** URL for uploading txs to file storage (s3://, gs://, file://) */
|
|
8
8
|
txFileStoreUrl?: string;
|
|
9
|
-
/** URL for downloading txs from file storage */
|
|
10
|
-
txFileStoreDownloadUrl?: string;
|
|
11
9
|
/** Max concurrent uploads */
|
|
12
10
|
txFileStoreUploadConcurrency: number;
|
|
13
11
|
/** Max queue size to prevent unbounded memory growth */
|
|
@@ -21,10 +19,6 @@ export const txFileStoreConfigMappings: ConfigMappingsType<TxFileStoreConfig> =
|
|
|
21
19
|
env: 'TX_FILE_STORE_URL',
|
|
22
20
|
description: 'URL for uploading txs to file storage (s3://, gs://, file://)',
|
|
23
21
|
},
|
|
24
|
-
txFileStoreDownloadUrl: {
|
|
25
|
-
env: 'TX_FILE_STORE_DOWNLOAD_URL',
|
|
26
|
-
description: 'URL for downloading txs from file storage',
|
|
27
|
-
},
|
|
28
22
|
txFileStoreUploadConcurrency: {
|
|
29
23
|
env: 'TX_FILE_STORE_UPLOAD_CONCURRENCY',
|
|
30
24
|
description: 'Maximum number of concurrent tx uploads',
|
|
@@ -6,7 +6,7 @@ import { type FileStore, createFileStore } from '@aztec/stdlib/file-store';
|
|
|
6
6
|
import type { Tx } from '@aztec/stdlib/tx';
|
|
7
7
|
import { type TelemetryClient, getTelemetryClient } from '@aztec/telemetry-client';
|
|
8
8
|
|
|
9
|
-
import type {
|
|
9
|
+
import type { TxPoolV2 } from '../../mem_pools/index.js';
|
|
10
10
|
import type { TxFileStoreConfig } from './config.js';
|
|
11
11
|
import { TxFileStoreInstrumentation } from './instrumentation.js';
|
|
12
12
|
|
|
@@ -18,7 +18,7 @@ export class TxFileStore {
|
|
|
18
18
|
private uploadQueue: Tx[] = [];
|
|
19
19
|
private activeUploads = 0;
|
|
20
20
|
private readonly queueProcessor: RunningPromise;
|
|
21
|
-
private readonly handleTxsAdded:
|
|
21
|
+
private readonly handleTxsAdded: (args: { txs: Tx[]; source?: string }) => void;
|
|
22
22
|
|
|
23
23
|
/** Recently uploaded tx hashes for deduplication. */
|
|
24
24
|
private recentUploads: Set<string> = new Set();
|
|
@@ -27,10 +27,11 @@ export class TxFileStore {
|
|
|
27
27
|
|
|
28
28
|
private constructor(
|
|
29
29
|
private readonly fileStore: FileStore,
|
|
30
|
-
private readonly txPool:
|
|
30
|
+
private readonly txPool: TxPoolV2,
|
|
31
31
|
private readonly config: TxFileStoreConfig,
|
|
32
32
|
private readonly instrumentation: TxFileStoreInstrumentation,
|
|
33
33
|
private readonly log: Logger,
|
|
34
|
+
private readonly basePath: string,
|
|
34
35
|
) {
|
|
35
36
|
this.handleTxsAdded = (args: { txs: Tx[]; source?: string }) => {
|
|
36
37
|
this.enqueueTxs(args.txs);
|
|
@@ -48,8 +49,9 @@ export class TxFileStore {
|
|
|
48
49
|
* @returns The file store instance, or undefined if not configured/enabled.
|
|
49
50
|
*/
|
|
50
51
|
static async create(
|
|
51
|
-
txPool:
|
|
52
|
+
txPool: TxPoolV2,
|
|
52
53
|
config: TxFileStoreConfig,
|
|
54
|
+
basePath: string,
|
|
53
55
|
log: Logger = createLogger('p2p:tx_file_store'),
|
|
54
56
|
telemetry: TelemetryClient = getTelemetryClient(),
|
|
55
57
|
fileStoreOverride?: FileStore,
|
|
@@ -71,8 +73,8 @@ export class TxFileStore {
|
|
|
71
73
|
}
|
|
72
74
|
|
|
73
75
|
const instrumentation = new TxFileStoreInstrumentation(telemetry, 'TxFileStore');
|
|
74
|
-
log.info('Created tx file store', { url: config.txFileStoreUrl });
|
|
75
|
-
return new TxFileStore(fileStore, txPool, config, instrumentation, log);
|
|
76
|
+
log.info('Created tx file store', { url: config.txFileStoreUrl, basePath });
|
|
77
|
+
return new TxFileStore(fileStore, txPool, config, instrumentation, log, basePath);
|
|
76
78
|
}
|
|
77
79
|
|
|
78
80
|
/** Starts listening to TxPool events and uploading txs. */
|
|
@@ -122,7 +124,7 @@ export class TxFileStore {
|
|
|
122
124
|
|
|
123
125
|
private async uploadTx(tx: Tx): Promise<void> {
|
|
124
126
|
const txHash = tx.getTxHash().toString();
|
|
125
|
-
const path =
|
|
127
|
+
const path = `${this.basePath}/txs/${txHash}.bin`;
|
|
126
128
|
const timer = new Timer();
|
|
127
129
|
|
|
128
130
|
if (this.recentUploads.has(txHash)) {
|
|
@@ -144,7 +146,7 @@ export class TxFileStore {
|
|
|
144
146
|
}
|
|
145
147
|
|
|
146
148
|
await retry(
|
|
147
|
-
() => this.fileStore.save(path, tx.toBuffer(), { compress:
|
|
149
|
+
() => this.fileStore.save(path, tx.toBuffer(), { compress: true }),
|
|
148
150
|
`Uploading tx ${txHash}`,
|
|
149
151
|
makeBackoff([0.1, 0.5, 2]),
|
|
150
152
|
this.log,
|
|
@@ -5,13 +5,13 @@ import { elapsed } from '@aztec/foundation/timer';
|
|
|
5
5
|
import type { L2Block, L2BlockInfo } from '@aztec/stdlib/block';
|
|
6
6
|
import type { ITxProvider } from '@aztec/stdlib/interfaces/server';
|
|
7
7
|
import type { BlockProposal } from '@aztec/stdlib/p2p';
|
|
8
|
-
import { Tx, TxHash } from '@aztec/stdlib/tx';
|
|
8
|
+
import { type BlockHeader, Tx, TxHash } from '@aztec/stdlib/tx';
|
|
9
9
|
import { type TelemetryClient, getTelemetryClient } from '@aztec/telemetry-client';
|
|
10
10
|
|
|
11
11
|
import type { PeerId } from '@libp2p/interface';
|
|
12
12
|
|
|
13
13
|
import type { P2PClient } from '../client/p2p_client.js';
|
|
14
|
-
import type {
|
|
14
|
+
import type { TxPoolV2 } from '../mem_pools/tx_pool_v2/interfaces.js';
|
|
15
15
|
import type { FastCollectionRequestInput, TxCollection } from './tx_collection/tx_collection.js';
|
|
16
16
|
import { TxProviderInstrumentation } from './tx_provider_instrumentation.js';
|
|
17
17
|
|
|
@@ -24,8 +24,8 @@ export class TxProvider implements ITxProvider {
|
|
|
24
24
|
|
|
25
25
|
constructor(
|
|
26
26
|
private txCollection: TxCollection,
|
|
27
|
-
private txPool:
|
|
28
|
-
private
|
|
27
|
+
private txPool: TxPoolV2,
|
|
28
|
+
private blockProposalTransactionValidator: Pick<P2PClient, 'validateTxsReceivedInBlockProposal'>,
|
|
29
29
|
private log: Logger = createLogger('p2p:tx-collector'),
|
|
30
30
|
client: TelemetryClient = getTelemetryClient(),
|
|
31
31
|
) {
|
|
@@ -144,6 +144,7 @@ export class TxProvider implements ITxProvider {
|
|
|
144
144
|
// Take txs from the proposal body if there are any
|
|
145
145
|
// Note that we still have to validate these txs, but we do it in parallel with tx collection
|
|
146
146
|
const proposal = request.type === 'proposal' ? request.blockProposal : undefined;
|
|
147
|
+
const proposalBlockHeader = proposal?.blockHeader;
|
|
147
148
|
const txsFromProposal = this.extractFromProposal(proposal, [...missingTxHashes]);
|
|
148
149
|
if (txsFromProposal.length > 0) {
|
|
149
150
|
this.instrumentation.incTxsFromProposals(txsFromProposal.length);
|
|
@@ -155,7 +156,7 @@ export class TxProvider implements ITxProvider {
|
|
|
155
156
|
}
|
|
156
157
|
|
|
157
158
|
if (missingTxHashes.size === 0) {
|
|
158
|
-
await this.processProposalTxs(txsFromProposal);
|
|
159
|
+
await this.processProposalTxs(txsFromProposal, proposalBlockHeader!);
|
|
159
160
|
this.instrumentation.incTxsFromP2P(0, txHashes.length);
|
|
160
161
|
return { txsFromMempool, txsFromProposal };
|
|
161
162
|
}
|
|
@@ -163,7 +164,7 @@ export class TxProvider implements ITxProvider {
|
|
|
163
164
|
// Start tx collection from the network if needed, while we validate the txs taken from the proposal in parallel
|
|
164
165
|
const [txsFromNetwork] = await Promise.all([
|
|
165
166
|
this.collectFromP2P(request, [...missingTxHashes], opts),
|
|
166
|
-
this.processProposalTxs(txsFromProposal),
|
|
167
|
+
this.processProposalTxs(txsFromProposal, proposalBlockHeader!),
|
|
167
168
|
] as const);
|
|
168
169
|
|
|
169
170
|
if (txsFromNetwork.length > 0) {
|
|
@@ -222,11 +223,11 @@ export class TxProvider implements ITxProvider {
|
|
|
222
223
|
return compactArray(proposal.txs ?? []).filter(tx => missingTxHashes.includes(tx.getTxHash().toString()));
|
|
223
224
|
}
|
|
224
225
|
|
|
225
|
-
private async processProposalTxs(txs: Tx[]): Promise<void> {
|
|
226
|
+
private async processProposalTxs(txs: Tx[], blockHeader: BlockHeader): Promise<void> {
|
|
226
227
|
if (txs.length === 0) {
|
|
227
228
|
return;
|
|
228
229
|
}
|
|
229
|
-
await this.
|
|
230
|
-
await this.txPool.
|
|
230
|
+
await this.blockProposalTransactionValidator.validateTxsReceivedInBlockProposal(txs);
|
|
231
|
+
await this.txPool.addProtectedTxs(txs, blockHeader);
|
|
231
232
|
}
|
|
232
233
|
}
|
|
@@ -7,13 +7,12 @@ import { sleep } from '@aztec/foundation/sleep';
|
|
|
7
7
|
import type { DataStoreConfig } from '@aztec/kv-store/config';
|
|
8
8
|
import { openTmpStore } from '@aztec/kv-store/lmdb-v2';
|
|
9
9
|
import type { WorldStateSynchronizer } from '@aztec/stdlib/interfaces/server';
|
|
10
|
-
import { P2PClientType } from '@aztec/stdlib/p2p';
|
|
11
10
|
|
|
12
11
|
import { createP2PClient } from '../client/index.js';
|
|
13
12
|
import type { P2PClient } from '../client/p2p_client.js';
|
|
14
13
|
import type { P2PConfig } from '../config.js';
|
|
15
14
|
import type { AttestationPool } from '../mem_pools/attestation_pool/attestation_pool.js';
|
|
16
|
-
import type {
|
|
15
|
+
import type { TxPoolV2 } from '../mem_pools/tx_pool_v2/interfaces.js';
|
|
17
16
|
import { generatePeerIdPrivateKeys } from '../test-helpers/generate-peer-id-private-keys.js';
|
|
18
17
|
import { getPorts } from './get-ports.js';
|
|
19
18
|
import { makeEnrs } from './make-enrs.js';
|
|
@@ -22,7 +21,7 @@ import { AlwaysFalseCircuitVerifier, AlwaysTrueCircuitVerifier } from './reqresp
|
|
|
22
21
|
|
|
23
22
|
export interface MakeTestP2PClientOptions {
|
|
24
23
|
mockAttestationPool: AttestationPool;
|
|
25
|
-
mockTxPool:
|
|
24
|
+
mockTxPool: TxPoolV2;
|
|
26
25
|
mockEpochCache: EpochCache;
|
|
27
26
|
mockWorldState: WorldStateSynchronizer;
|
|
28
27
|
alwaysTrueVerifier?: boolean;
|
|
@@ -98,7 +97,6 @@ export async function makeTestP2PClient(
|
|
|
98
97
|
const kvStore = await openTmpStore('test');
|
|
99
98
|
|
|
100
99
|
const client = await createP2PClient(
|
|
101
|
-
P2PClientType.Full,
|
|
102
100
|
config,
|
|
103
101
|
l2BlockSource,
|
|
104
102
|
proofVerifier,
|
|
@@ -108,7 +106,7 @@ export async function makeTestP2PClient(
|
|
|
108
106
|
undefined,
|
|
109
107
|
undefined,
|
|
110
108
|
{
|
|
111
|
-
txPool: mockTxPool as unknown as
|
|
109
|
+
txPool: mockTxPool as unknown as TxPoolV2,
|
|
112
110
|
attestationPool: mockAttestationPool as unknown as AttestationPool,
|
|
113
111
|
store: kvStore,
|
|
114
112
|
logger,
|
|
@@ -4,7 +4,6 @@ import type { AztecAsyncKVStore } from '@aztec/kv-store';
|
|
|
4
4
|
import type { L2BlockSource } from '@aztec/stdlib/block';
|
|
5
5
|
import type { ContractDataSource } from '@aztec/stdlib/contract';
|
|
6
6
|
import type { ClientProtocolCircuitVerifier, WorldStateSynchronizer } from '@aztec/stdlib/interfaces/server';
|
|
7
|
-
import { P2PClientType } from '@aztec/stdlib/p2p';
|
|
8
7
|
import type { TelemetryClient } from '@aztec/telemetry-client';
|
|
9
8
|
|
|
10
9
|
import type { GossipsubEvents, GossipsubMessage } from '@chainsafe/libp2p-gossipsub';
|
|
@@ -19,8 +18,20 @@ import {
|
|
|
19
18
|
|
|
20
19
|
import type { P2PConfig } from '../config.js';
|
|
21
20
|
import type { MemPools } from '../mem_pools/interface.js';
|
|
22
|
-
import { DummyPeerDiscoveryService, DummyPeerManager,
|
|
23
|
-
import type {
|
|
21
|
+
import { DummyPeerDiscoveryService, DummyPeerManager, LibP2PService } from '../services/index.js';
|
|
22
|
+
import type { P2PReqRespConfig } from '../services/reqresp/config.js';
|
|
23
|
+
import type { ConnectionSampler } from '../services/reqresp/connection-sampler/connection_sampler.js';
|
|
24
|
+
import {
|
|
25
|
+
type ReqRespInterface,
|
|
26
|
+
type ReqRespResponse,
|
|
27
|
+
type ReqRespSubProtocol,
|
|
28
|
+
type ReqRespSubProtocolHandler,
|
|
29
|
+
type ReqRespSubProtocolHandlers,
|
|
30
|
+
type ReqRespSubProtocolValidators,
|
|
31
|
+
type SubProtocolMap,
|
|
32
|
+
responseFromBuffer,
|
|
33
|
+
} from '../services/reqresp/interface.js';
|
|
34
|
+
import { ReqRespStatus } from '../services/reqresp/status.js';
|
|
24
35
|
import { GossipSubEvent } from '../types/index.js';
|
|
25
36
|
import type { PubSubLibp2p } from '../util.js';
|
|
26
37
|
|
|
@@ -30,11 +41,10 @@ type GossipSubService = PubSubLibp2p['services']['pubsub'];
|
|
|
30
41
|
* Given a mock gossip sub network, returns a factory function that creates an instance LibP2PService connected to it.
|
|
31
42
|
* Designed to be used in tests in P2PClientDeps.p2pServiceFactory.
|
|
32
43
|
*/
|
|
33
|
-
export function getMockPubSubP2PServiceFactory
|
|
44
|
+
export function getMockPubSubP2PServiceFactory(
|
|
34
45
|
network: MockGossipSubNetwork,
|
|
35
|
-
): (...args: Parameters<(typeof LibP2PService
|
|
46
|
+
): (...args: Parameters<(typeof LibP2PService)['new']>) => Promise<LibP2PService> {
|
|
36
47
|
return (
|
|
37
|
-
clientType: P2PClientType,
|
|
38
48
|
config: P2PConfig,
|
|
39
49
|
peerId: PeerId,
|
|
40
50
|
deps: {
|
|
@@ -52,10 +62,9 @@ export function getMockPubSubP2PServiceFactory<T extends P2PClientType>(
|
|
|
52
62
|
deps.logger.verbose('Creating mock PubSub service');
|
|
53
63
|
const libp2p = new MockPubSub(peerId, network);
|
|
54
64
|
const peerManager = new DummyPeerManager(peerId, network);
|
|
55
|
-
const reqresp: ReqRespInterface = new
|
|
65
|
+
const reqresp: ReqRespInterface = new MockReqResp(peerId, network);
|
|
56
66
|
const peerDiscoveryService = new DummyPeerDiscoveryService();
|
|
57
|
-
const service = new LibP2PService
|
|
58
|
-
clientType as T,
|
|
67
|
+
const service = new LibP2PService(
|
|
59
68
|
config,
|
|
60
69
|
libp2p,
|
|
61
70
|
peerDiscoveryService,
|
|
@@ -74,6 +83,115 @@ export function getMockPubSubP2PServiceFactory<T extends P2PClientType>(
|
|
|
74
83
|
};
|
|
75
84
|
}
|
|
76
85
|
|
|
86
|
+
/**
|
|
87
|
+
* Mock implementation of ReqRespInterface that routes requests to other peers' handlers through the mock network.
|
|
88
|
+
* When a peer calls sendBatchRequest, the mock iterates over network peers and invokes their registered handler
|
|
89
|
+
* for the sub-protocol, simulating the request-response protocol without actual libp2p streams.
|
|
90
|
+
*/
|
|
91
|
+
class MockReqResp implements ReqRespInterface {
|
|
92
|
+
private handlers: Partial<ReqRespSubProtocolHandlers> = {};
|
|
93
|
+
private logger = createLogger('p2p:test:mock-reqresp');
|
|
94
|
+
|
|
95
|
+
constructor(
|
|
96
|
+
private peerId: PeerId,
|
|
97
|
+
private network: MockGossipSubNetwork,
|
|
98
|
+
) {
|
|
99
|
+
network.registerReqRespPeer(this);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
updateConfig(_config: Partial<P2PReqRespConfig>): void {}
|
|
103
|
+
|
|
104
|
+
start(
|
|
105
|
+
subProtocolHandlers: Partial<ReqRespSubProtocolHandlers>,
|
|
106
|
+
_subProtocolValidators: ReqRespSubProtocolValidators,
|
|
107
|
+
): Promise<void> {
|
|
108
|
+
Object.assign(this.handlers, subProtocolHandlers);
|
|
109
|
+
return Promise.resolve();
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
addSubProtocol(
|
|
113
|
+
subProtocol: ReqRespSubProtocol,
|
|
114
|
+
handler: ReqRespSubProtocolHandler,
|
|
115
|
+
_validator?: ReqRespSubProtocolValidators[ReqRespSubProtocol],
|
|
116
|
+
): Promise<void> {
|
|
117
|
+
this.handlers[subProtocol] = handler;
|
|
118
|
+
return Promise.resolve();
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
stop(): Promise<void> {
|
|
122
|
+
this.handlers = {};
|
|
123
|
+
return Promise.resolve();
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
getHandler(subProtocol: ReqRespSubProtocol): ReqRespSubProtocolHandler | undefined {
|
|
127
|
+
return this.handlers[subProtocol];
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
async sendBatchRequest<SubProtocol extends ReqRespSubProtocol>(
|
|
131
|
+
subProtocol: SubProtocol,
|
|
132
|
+
requests: InstanceType<SubProtocolMap[SubProtocol]['request']>[],
|
|
133
|
+
pinnedPeer: PeerId | undefined,
|
|
134
|
+
_timeoutMs?: number,
|
|
135
|
+
_maxPeers?: number,
|
|
136
|
+
_maxRetryAttempts?: number,
|
|
137
|
+
): Promise<InstanceType<SubProtocolMap[SubProtocol]['response']>[]> {
|
|
138
|
+
const responses: InstanceType<SubProtocolMap[SubProtocol]['response']>[] = [];
|
|
139
|
+
const peers = this.network.getReqRespPeers().filter(p => !p.peerId.equals(this.peerId));
|
|
140
|
+
const targetPeers = pinnedPeer ? peers.filter(p => p.peerId.equals(pinnedPeer)) : peers;
|
|
141
|
+
|
|
142
|
+
for (const request of requests) {
|
|
143
|
+
const requestBuffer = request.toBuffer();
|
|
144
|
+
for (const peer of targetPeers) {
|
|
145
|
+
const handler = peer.getHandler(subProtocol);
|
|
146
|
+
if (!handler) {
|
|
147
|
+
continue;
|
|
148
|
+
}
|
|
149
|
+
try {
|
|
150
|
+
const responseBuffer = await handler(this.peerId, requestBuffer);
|
|
151
|
+
if (responseBuffer.length > 0) {
|
|
152
|
+
const response = responseFromBuffer(subProtocol, responseBuffer);
|
|
153
|
+
responses.push(response as InstanceType<SubProtocolMap[SubProtocol]['response']>);
|
|
154
|
+
break;
|
|
155
|
+
}
|
|
156
|
+
} catch (err) {
|
|
157
|
+
this.logger.debug(`Mock reqresp handler error from peer ${peer.peerId}`, { err });
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
return responses;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
async sendRequestToPeer(
|
|
166
|
+
peerId: PeerId,
|
|
167
|
+
subProtocol: ReqRespSubProtocol,
|
|
168
|
+
payload: Buffer,
|
|
169
|
+
_dialTimeout?: number,
|
|
170
|
+
): Promise<ReqRespResponse> {
|
|
171
|
+
const peer = this.network.getReqRespPeers().find(p => p.peerId.equals(peerId));
|
|
172
|
+
const handler = peer?.getHandler(subProtocol);
|
|
173
|
+
if (!handler) {
|
|
174
|
+
return { status: ReqRespStatus.SUCCESS, data: Buffer.from([]) };
|
|
175
|
+
}
|
|
176
|
+
try {
|
|
177
|
+
const data = await handler(this.peerId, payload);
|
|
178
|
+
return { status: ReqRespStatus.SUCCESS, data };
|
|
179
|
+
} catch {
|
|
180
|
+
return { status: ReqRespStatus.FAILURE };
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
getConnectionSampler(): Pick<ConnectionSampler, 'getPeerListSortedByConnectionCountAsc'> {
|
|
185
|
+
return {
|
|
186
|
+
getPeerListSortedByConnectionCountAsc: () =>
|
|
187
|
+
this.network
|
|
188
|
+
.getReqRespPeers()
|
|
189
|
+
.filter(p => !p.peerId.equals(this.peerId))
|
|
190
|
+
.map(p => p.peerId),
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
77
195
|
/**
|
|
78
196
|
* Implementation of PubSub services that relies on a mock gossip sub network.
|
|
79
197
|
* This is used in tests to simulate a gossip sub network without needing a real P2P network.
|
|
@@ -149,6 +267,16 @@ class MockGossipSubService extends TypedEventEmitter<GossipsubEvents> implements
|
|
|
149
267
|
{ msgId, propagationSource, acceptance },
|
|
150
268
|
);
|
|
151
269
|
}
|
|
270
|
+
|
|
271
|
+
getMeshPeers(topic?: TopicStr): PeerIdStr[] {
|
|
272
|
+
if (topic && !this.subscribedTopics.has(topic)) {
|
|
273
|
+
return [];
|
|
274
|
+
}
|
|
275
|
+
return this.network
|
|
276
|
+
.getPeers()
|
|
277
|
+
.filter(peer => !this.peerId.equals(peer))
|
|
278
|
+
.map(peer => peer.toString());
|
|
279
|
+
}
|
|
152
280
|
}
|
|
153
281
|
|
|
154
282
|
/**
|
|
@@ -157,6 +285,7 @@ class MockGossipSubService extends TypedEventEmitter<GossipsubEvents> implements
|
|
|
157
285
|
*/
|
|
158
286
|
export class MockGossipSubNetwork {
|
|
159
287
|
private peers: MockGossipSubService[] = [];
|
|
288
|
+
private reqRespPeers: MockReqResp[] = [];
|
|
160
289
|
private nextMsgId = 0;
|
|
161
290
|
|
|
162
291
|
private logger = createLogger('p2p:test:mock-gossipsub-network');
|
|
@@ -169,6 +298,14 @@ export class MockGossipSubNetwork {
|
|
|
169
298
|
this.peers.push(peer);
|
|
170
299
|
}
|
|
171
300
|
|
|
301
|
+
public registerReqRespPeer(peer: MockReqResp): void {
|
|
302
|
+
this.reqRespPeers.push(peer);
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
public getReqRespPeers(): MockReqResp[] {
|
|
306
|
+
return this.reqRespPeers;
|
|
307
|
+
}
|
|
308
|
+
|
|
172
309
|
public publishToPeers(topic: TopicStr, data: Uint8Array, sender: PeerId): void {
|
|
173
310
|
const msgId = (this.nextMsgId++).toString();
|
|
174
311
|
this.logger.debug(`Network is distributing message on topic ${topic}`, {
|
|
@@ -12,7 +12,6 @@ import type {
|
|
|
12
12
|
IVCProofVerificationResult,
|
|
13
13
|
WorldStateSynchronizer,
|
|
14
14
|
} from '@aztec/stdlib/interfaces/server';
|
|
15
|
-
import type { P2PClientType } from '@aztec/stdlib/p2p';
|
|
16
15
|
import type { Tx } from '@aztec/stdlib/tx';
|
|
17
16
|
import { compressComponentVersions } from '@aztec/stdlib/versioning';
|
|
18
17
|
import { type TelemetryClient, getTelemetryClient } from '@aztec/telemetry-client';
|
|
@@ -34,6 +33,7 @@ import { BootstrapNode } from '../bootstrap/bootstrap.js';
|
|
|
34
33
|
import type { BootnodeConfig, P2PConfig } from '../config.js';
|
|
35
34
|
import type { MemPools } from '../mem_pools/interface.js';
|
|
36
35
|
import { DiscV5Service } from '../services/discv5/discV5_service.js';
|
|
36
|
+
import { APP_SPECIFIC_WEIGHT } from '../services/gossipsub/scoring.js';
|
|
37
37
|
import { LibP2PService } from '../services/libp2p/libp2p_service.js';
|
|
38
38
|
import { PeerManager } from '../services/peer-manager/peer_manager.js';
|
|
39
39
|
import { PeerScoring } from '../services/peer-manager/peer_scoring.js';
|
|
@@ -106,8 +106,7 @@ export async function createLibp2pNode(
|
|
|
106
106
|
*
|
|
107
107
|
*
|
|
108
108
|
*/
|
|
109
|
-
export async function createTestLibP2PService
|
|
110
|
-
clientType: T,
|
|
109
|
+
export async function createTestLibP2PService(
|
|
111
110
|
boostrapAddrs: string[] = [],
|
|
112
111
|
archiver: L2BlockSource & ContractDataSource,
|
|
113
112
|
worldStateSynchronizer: WorldStateSynchronizer,
|
|
@@ -154,12 +153,11 @@ export async function createTestLibP2PService<T extends P2PClientType>(
|
|
|
154
153
|
epochCache,
|
|
155
154
|
);
|
|
156
155
|
|
|
157
|
-
p2pNode.services.pubsub.score.params.appSpecificWeight =
|
|
156
|
+
p2pNode.services.pubsub.score.params.appSpecificWeight = APP_SPECIFIC_WEIGHT;
|
|
158
157
|
p2pNode.services.pubsub.score.params.appSpecificScore = (peerId: string) =>
|
|
159
158
|
peerManager.shouldDisableP2PGossip(peerId) ? -Infinity : peerManager.getPeerScore(peerId);
|
|
160
159
|
|
|
161
|
-
return new LibP2PService
|
|
162
|
-
clientType,
|
|
160
|
+
return new LibP2PService(
|
|
163
161
|
config,
|
|
164
162
|
p2pNode as PubSubLibp2p,
|
|
165
163
|
discoveryService,
|