@aztec/p2p 0.0.1-commit.e61ad554 → 0.0.1-commit.ec5f612
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dest/bootstrap/bootstrap.d.ts +4 -3
- package/dest/bootstrap/bootstrap.d.ts.map +1 -1
- package/dest/bootstrap/bootstrap.js +4 -4
- package/dest/client/factory.d.ts +10 -10
- package/dest/client/factory.d.ts.map +1 -1
- package/dest/client/factory.js +45 -18
- package/dest/client/interface.d.ts +46 -33
- package/dest/client/interface.d.ts.map +1 -1
- package/dest/client/p2p_client.d.ts +41 -51
- package/dest/client/p2p_client.d.ts.map +1 -1
- package/dest/client/p2p_client.js +156 -200
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.d.ts +2 -0
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.d.ts.map +1 -0
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.js +304 -0
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker_protocol.d.ts +73 -0
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker_protocol.d.ts.map +1 -0
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker_protocol.js +8 -0
- package/dest/config.d.ts +35 -7
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +21 -7
- package/dest/errors/tx-pool.error.d.ts +8 -0
- package/dest/errors/tx-pool.error.d.ts.map +1 -0
- package/dest/errors/tx-pool.error.js +9 -0
- package/dest/index.d.ts +2 -1
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +1 -0
- package/dest/mem_pools/attestation_pool/attestation_pool.d.ts +104 -88
- package/dest/mem_pools/attestation_pool/attestation_pool.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/attestation_pool.js +441 -3
- package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.d.ts +2 -2
- package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.js +353 -87
- package/dest/mem_pools/attestation_pool/index.d.ts +2 -3
- package/dest/mem_pools/attestation_pool/index.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/index.js +1 -2
- package/dest/mem_pools/attestation_pool/mocks.d.ts +2 -2
- package/dest/mem_pools/attestation_pool/mocks.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/mocks.js +2 -2
- package/dest/mem_pools/index.d.ts +3 -2
- package/dest/mem_pools/index.d.ts.map +1 -1
- package/dest/mem_pools/index.js +1 -1
- package/dest/mem_pools/instrumentation.d.ts +1 -1
- package/dest/mem_pools/instrumentation.d.ts.map +1 -1
- package/dest/mem_pools/instrumentation.js +2 -2
- package/dest/mem_pools/interface.d.ts +5 -5
- package/dest/mem_pools/interface.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.js +3 -3
- package/dest/mem_pools/tx_pool_v2/archive/index.d.ts +2 -0
- package/dest/mem_pools/tx_pool_v2/archive/index.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/archive/index.js +1 -0
- package/dest/mem_pools/tx_pool_v2/archive/tx_archive.d.ts +43 -0
- package/dest/mem_pools/tx_pool_v2/archive/tx_archive.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/archive/tx_archive.js +103 -0
- package/dest/mem_pools/tx_pool_v2/deleted_pool.d.ts +104 -0
- package/dest/mem_pools/tx_pool_v2/deleted_pool.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/deleted_pool.js +251 -0
- package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.d.ts +47 -0
- package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.js +128 -0
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.d.ts +17 -0
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.js +93 -0
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.d.ts +19 -0
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.js +97 -0
- package/dest/mem_pools/tx_pool_v2/eviction/index.d.ts +10 -0
- package/dest/mem_pools/tx_pool_v2/eviction/index.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/eviction/index.js +11 -0
- package/dest/mem_pools/tx_pool_v2/eviction/interfaces.d.ts +174 -0
- package/dest/mem_pools/tx_pool_v2/eviction/interfaces.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/eviction/interfaces.js +25 -0
- package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.d.ts +15 -0
- package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.js +65 -0
- package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.d.ts +17 -0
- package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.js +93 -0
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.d.ts +16 -0
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.js +78 -0
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.d.ts +20 -0
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.js +73 -0
- package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.d.ts +15 -0
- package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.js +19 -0
- package/dest/mem_pools/tx_pool_v2/index.d.ts +6 -0
- package/dest/mem_pools/tx_pool_v2/index.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/index.js +5 -0
- package/dest/mem_pools/tx_pool_v2/instrumentation.d.ts +15 -0
- package/dest/mem_pools/tx_pool_v2/instrumentation.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/instrumentation.js +43 -0
- package/dest/mem_pools/tx_pool_v2/interfaces.d.ts +211 -0
- package/dest/mem_pools/tx_pool_v2/interfaces.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/interfaces.js +9 -0
- package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts +119 -0
- package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/tx_metadata.js +193 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_bench_metrics.d.ts +26 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_bench_metrics.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_bench_metrics.js +70 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_indices.d.ts +108 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_indices.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_indices.js +354 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts +60 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2.js +161 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts +77 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.js +905 -0
- package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.d.ts +3 -3
- package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.d.ts.map +1 -1
- package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.js +7 -2
- package/dest/msg_validators/proposal_validator/proposal_validator.js +5 -5
- package/dest/msg_validators/tx_validator/aggregate_tx_validator.d.ts +4 -4
- package/dest/msg_validators/tx_validator/aggregate_tx_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/aggregate_tx_validator.js +3 -3
- package/dest/msg_validators/tx_validator/archive_cache.d.ts +3 -3
- package/dest/msg_validators/tx_validator/archive_cache.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/archive_cache.js +1 -1
- package/dest/msg_validators/tx_validator/block_header_validator.d.ts +20 -6
- package/dest/msg_validators/tx_validator/block_header_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/block_header_validator.js +5 -4
- package/dest/msg_validators/tx_validator/data_validator.d.ts +3 -1
- package/dest/msg_validators/tx_validator/data_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/data_validator.js +4 -1
- package/dest/msg_validators/tx_validator/double_spend_validator.d.ts +15 -4
- package/dest/msg_validators/tx_validator/double_spend_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/double_spend_validator.js +7 -6
- package/dest/msg_validators/tx_validator/factory.d.ts +118 -5
- package/dest/msg_validators/tx_validator/factory.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/factory.js +228 -57
- package/dest/msg_validators/tx_validator/gas_validator.d.ts +59 -3
- package/dest/msg_validators/tx_validator/gas_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/gas_validator.js +76 -38
- package/dest/msg_validators/tx_validator/index.d.ts +2 -1
- package/dest/msg_validators/tx_validator/index.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/index.js +1 -0
- package/dest/msg_validators/tx_validator/metadata_validator.d.ts +3 -2
- package/dest/msg_validators/tx_validator/metadata_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/metadata_validator.js +2 -2
- package/dest/msg_validators/tx_validator/nullifier_cache.d.ts +14 -0
- package/dest/msg_validators/tx_validator/nullifier_cache.d.ts.map +1 -0
- package/dest/msg_validators/tx_validator/nullifier_cache.js +24 -0
- package/dest/msg_validators/tx_validator/phases_validator.d.ts +3 -2
- package/dest/msg_validators/tx_validator/phases_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/phases_validator.js +3 -3
- package/dest/msg_validators/tx_validator/size_validator.d.ts +3 -1
- package/dest/msg_validators/tx_validator/size_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/size_validator.js +4 -1
- package/dest/msg_validators/tx_validator/timestamp_validator.d.ts +22 -5
- package/dest/msg_validators/tx_validator/timestamp_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/timestamp_validator.js +8 -8
- package/dest/msg_validators/tx_validator/tx_permitted_validator.d.ts +3 -2
- package/dest/msg_validators/tx_validator/tx_permitted_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/tx_permitted_validator.js +2 -2
- package/dest/msg_validators/tx_validator/tx_proof_validator.d.ts +3 -2
- package/dest/msg_validators/tx_validator/tx_proof_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/tx_proof_validator.js +2 -2
- package/dest/services/data_store.d.ts +1 -1
- package/dest/services/data_store.d.ts.map +1 -1
- package/dest/services/data_store.js +10 -6
- package/dest/services/discv5/discV5_service.js +1 -1
- package/dest/services/dummy_service.d.ts +24 -4
- package/dest/services/dummy_service.d.ts.map +1 -1
- package/dest/services/dummy_service.js +46 -1
- package/dest/services/encoding.d.ts +3 -3
- package/dest/services/encoding.d.ts.map +1 -1
- package/dest/services/encoding.js +11 -10
- package/dest/services/gossipsub/index.d.ts +3 -0
- package/dest/services/gossipsub/index.d.ts.map +1 -0
- package/dest/services/gossipsub/index.js +2 -0
- package/dest/services/gossipsub/scoring.d.ts +21 -3
- package/dest/services/gossipsub/scoring.d.ts.map +1 -1
- package/dest/services/gossipsub/scoring.js +24 -7
- package/dest/services/gossipsub/topic_score_params.d.ts +173 -0
- package/dest/services/gossipsub/topic_score_params.d.ts.map +1 -0
- package/dest/services/gossipsub/topic_score_params.js +346 -0
- package/dest/services/index.d.ts +2 -1
- package/dest/services/index.d.ts.map +1 -1
- package/dest/services/index.js +1 -0
- package/dest/services/libp2p/instrumentation.d.ts +1 -1
- package/dest/services/libp2p/instrumentation.d.ts.map +1 -1
- package/dest/services/libp2p/instrumentation.js +14 -3
- package/dest/services/libp2p/libp2p_service.d.ts +100 -42
- package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
- package/dest/services/libp2p/libp2p_service.js +451 -359
- package/dest/services/peer-manager/metrics.d.ts +2 -2
- package/dest/services/peer-manager/metrics.d.ts.map +1 -1
- package/dest/services/peer-manager/metrics.js +20 -5
- package/dest/services/peer-manager/peer_scoring.d.ts +1 -1
- package/dest/services/peer-manager/peer_scoring.d.ts.map +1 -1
- package/dest/services/peer-manager/peer_scoring.js +33 -4
- package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts +48 -0
- package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts.map +1 -0
- package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.js +539 -0
- package/dest/services/reqresp/batch-tx-requester/config.d.ts +17 -0
- package/dest/services/reqresp/batch-tx-requester/config.d.ts.map +1 -0
- package/dest/services/reqresp/batch-tx-requester/config.js +27 -0
- package/dest/services/reqresp/batch-tx-requester/interface.d.ts +46 -0
- package/dest/services/reqresp/batch-tx-requester/interface.d.ts.map +1 -0
- package/dest/services/reqresp/batch-tx-requester/interface.js +1 -0
- package/dest/services/reqresp/batch-tx-requester/missing_txs.d.ts +34 -0
- package/dest/services/reqresp/batch-tx-requester/missing_txs.d.ts.map +1 -0
- package/dest/services/reqresp/batch-tx-requester/missing_txs.js +130 -0
- package/dest/services/reqresp/batch-tx-requester/peer_collection.d.ts +60 -0
- package/dest/services/reqresp/batch-tx-requester/peer_collection.d.ts.map +1 -0
- package/dest/services/reqresp/batch-tx-requester/peer_collection.js +173 -0
- package/dest/services/reqresp/batch-tx-requester/tx_validator.d.ts +20 -0
- package/dest/services/reqresp/batch-tx-requester/tx_validator.d.ts.map +1 -0
- package/dest/services/reqresp/batch-tx-requester/tx_validator.js +21 -0
- package/dest/services/reqresp/connection-sampler/batch_connection_sampler.d.ts +22 -3
- package/dest/services/reqresp/connection-sampler/batch_connection_sampler.d.ts.map +1 -1
- package/dest/services/reqresp/connection-sampler/batch_connection_sampler.js +63 -4
- package/dest/services/reqresp/connection-sampler/connection_sampler.d.ts +2 -1
- package/dest/services/reqresp/connection-sampler/connection_sampler.d.ts.map +1 -1
- package/dest/services/reqresp/connection-sampler/connection_sampler.js +12 -0
- package/dest/services/reqresp/interface.d.ts +12 -1
- package/dest/services/reqresp/interface.d.ts.map +1 -1
- package/dest/services/reqresp/interface.js +15 -1
- package/dest/services/reqresp/metrics.d.ts +6 -5
- package/dest/services/reqresp/metrics.d.ts.map +1 -1
- package/dest/services/reqresp/metrics.js +17 -5
- package/dest/services/reqresp/protocols/block_txs/bitvector.d.ts +5 -1
- package/dest/services/reqresp/protocols/block_txs/bitvector.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/block_txs/bitvector.js +5 -0
- package/dest/services/reqresp/protocols/block_txs/block_txs_handler.d.ts +7 -5
- package/dest/services/reqresp/protocols/block_txs/block_txs_handler.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/block_txs/block_txs_handler.js +27 -9
- package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.d.ts +29 -6
- package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.js +59 -13
- package/dest/services/reqresp/protocols/tx.d.ts +7 -1
- package/dest/services/reqresp/protocols/tx.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/tx.js +20 -0
- package/dest/services/reqresp/reqresp.d.ts +6 -1
- package/dest/services/reqresp/reqresp.d.ts.map +1 -1
- package/dest/services/reqresp/reqresp.js +71 -27
- package/dest/services/service.d.ts +42 -3
- package/dest/services/service.d.ts.map +1 -1
- package/dest/services/tx_collection/config.d.ts +22 -1
- package/dest/services/tx_collection/config.d.ts.map +1 -1
- package/dest/services/tx_collection/config.js +55 -1
- package/dest/services/tx_collection/fast_tx_collection.d.ts +7 -4
- package/dest/services/tx_collection/fast_tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/fast_tx_collection.js +71 -44
- package/dest/services/tx_collection/file_store_tx_collection.d.ts +53 -0
- package/dest/services/tx_collection/file_store_tx_collection.d.ts.map +1 -0
- package/dest/services/tx_collection/file_store_tx_collection.js +167 -0
- package/dest/services/tx_collection/file_store_tx_source.d.ts +37 -0
- package/dest/services/tx_collection/file_store_tx_source.d.ts.map +1 -0
- package/dest/services/tx_collection/file_store_tx_source.js +90 -0
- package/dest/services/tx_collection/index.d.ts +3 -1
- package/dest/services/tx_collection/index.d.ts.map +1 -1
- package/dest/services/tx_collection/index.js +2 -0
- package/dest/services/tx_collection/instrumentation.d.ts +1 -1
- package/dest/services/tx_collection/instrumentation.d.ts.map +1 -1
- package/dest/services/tx_collection/instrumentation.js +10 -2
- package/dest/services/tx_collection/missing_txs_tracker.d.ts +32 -0
- package/dest/services/tx_collection/missing_txs_tracker.d.ts.map +1 -0
- package/dest/services/tx_collection/missing_txs_tracker.js +27 -0
- package/dest/services/tx_collection/proposal_tx_collector.d.ts +49 -0
- package/dest/services/tx_collection/proposal_tx_collector.d.ts.map +1 -0
- package/dest/services/tx_collection/proposal_tx_collector.js +50 -0
- package/dest/services/tx_collection/slow_tx_collection.d.ts +7 -3
- package/dest/services/tx_collection/slow_tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/slow_tx_collection.js +60 -26
- package/dest/services/tx_collection/tx_collection.d.ts +25 -12
- package/dest/services/tx_collection/tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/tx_collection.js +79 -7
- package/dest/services/tx_collection/tx_collection_sink.d.ts +18 -8
- package/dest/services/tx_collection/tx_collection_sink.d.ts.map +1 -1
- package/dest/services/tx_collection/tx_collection_sink.js +26 -29
- package/dest/services/tx_collection/tx_source.d.ts +8 -3
- package/dest/services/tx_collection/tx_source.d.ts.map +1 -1
- package/dest/services/tx_collection/tx_source.js +19 -2
- package/dest/services/tx_file_store/config.d.ts +16 -0
- package/dest/services/tx_file_store/config.d.ts.map +1 -0
- package/dest/services/tx_file_store/config.js +22 -0
- package/dest/services/tx_file_store/index.d.ts +4 -0
- package/dest/services/tx_file_store/index.d.ts.map +1 -0
- package/dest/services/tx_file_store/index.js +3 -0
- package/dest/services/tx_file_store/instrumentation.d.ts +15 -0
- package/dest/services/tx_file_store/instrumentation.d.ts.map +1 -0
- package/dest/services/tx_file_store/instrumentation.js +29 -0
- package/dest/services/tx_file_store/tx_file_store.d.ts +48 -0
- package/dest/services/tx_file_store/tx_file_store.d.ts.map +1 -0
- package/dest/services/tx_file_store/tx_file_store.js +152 -0
- package/dest/services/tx_provider.d.ts +4 -4
- package/dest/services/tx_provider.d.ts.map +1 -1
- package/dest/services/tx_provider.js +9 -8
- package/dest/services/tx_provider_instrumentation.d.ts +1 -1
- package/dest/services/tx_provider_instrumentation.d.ts.map +1 -1
- package/dest/services/tx_provider_instrumentation.js +5 -5
- package/dest/test-helpers/index.d.ts +3 -1
- package/dest/test-helpers/index.d.ts.map +1 -1
- package/dest/test-helpers/index.js +2 -0
- package/dest/test-helpers/make-test-p2p-clients.d.ts +7 -8
- package/dest/test-helpers/make-test-p2p-clients.d.ts.map +1 -1
- package/dest/test-helpers/make-test-p2p-clients.js +1 -2
- package/dest/test-helpers/mock-pubsub.d.ts +30 -4
- package/dest/test-helpers/mock-pubsub.d.ts.map +1 -1
- package/dest/test-helpers/mock-pubsub.js +105 -4
- package/dest/test-helpers/reqresp-nodes.d.ts +2 -3
- package/dest/test-helpers/reqresp-nodes.d.ts.map +1 -1
- package/dest/test-helpers/reqresp-nodes.js +4 -3
- package/dest/test-helpers/test_tx_provider.d.ts +40 -0
- package/dest/test-helpers/test_tx_provider.d.ts.map +1 -0
- package/dest/test-helpers/test_tx_provider.js +41 -0
- package/dest/test-helpers/testbench-utils.d.ts +163 -0
- package/dest/test-helpers/testbench-utils.d.ts.map +1 -0
- package/dest/test-helpers/testbench-utils.js +366 -0
- package/dest/testbench/p2p_client_testbench_worker.d.ts +28 -2
- package/dest/testbench/p2p_client_testbench_worker.d.ts.map +1 -1
- package/dest/testbench/p2p_client_testbench_worker.js +219 -138
- package/dest/testbench/worker_client_manager.d.ts +51 -6
- package/dest/testbench/worker_client_manager.d.ts.map +1 -1
- package/dest/testbench/worker_client_manager.js +226 -44
- package/dest/util.d.ts +2 -2
- package/dest/util.d.ts.map +1 -1
- package/package.json +14 -14
- package/src/bootstrap/bootstrap.ts +7 -4
- package/src/client/factory.ts +83 -36
- package/src/client/interface.ts +56 -34
- package/src/client/p2p_client.ts +192 -247
- package/src/client/test/tx_proposal_collector/README.md +227 -0
- package/src/client/test/tx_proposal_collector/proposal_tx_collector_worker.ts +345 -0
- package/src/client/test/tx_proposal_collector/proposal_tx_collector_worker_protocol.ts +43 -0
- package/src/config.ts +47 -11
- package/src/errors/tx-pool.error.ts +12 -0
- package/src/index.ts +1 -0
- package/src/mem_pools/attestation_pool/attestation_pool.ts +496 -91
- package/src/mem_pools/attestation_pool/attestation_pool_test_suite.ts +442 -102
- package/src/mem_pools/attestation_pool/index.ts +9 -2
- package/src/mem_pools/attestation_pool/mocks.ts +2 -1
- package/src/mem_pools/index.ts +4 -1
- package/src/mem_pools/instrumentation.ts +2 -1
- package/src/mem_pools/interface.ts +4 -4
- package/src/mem_pools/tx_pool/README.md +1 -1
- package/src/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.ts +3 -3
- package/src/mem_pools/tx_pool_v2/README.md +275 -0
- package/src/mem_pools/tx_pool_v2/archive/index.ts +1 -0
- package/src/mem_pools/tx_pool_v2/archive/tx_archive.ts +120 -0
- package/src/mem_pools/tx_pool_v2/deleted_pool.ts +321 -0
- package/src/mem_pools/tx_pool_v2/eviction/eviction_manager.ts +160 -0
- package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.ts +121 -0
- package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.ts +125 -0
- package/src/mem_pools/tx_pool_v2/eviction/index.ts +27 -0
- package/src/mem_pools/tx_pool_v2/eviction/interfaces.ts +209 -0
- package/src/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.ts +74 -0
- package/src/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.ts +101 -0
- package/src/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.ts +91 -0
- package/src/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.ts +90 -0
- package/src/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.ts +31 -0
- package/src/mem_pools/tx_pool_v2/index.ts +12 -0
- package/src/mem_pools/tx_pool_v2/instrumentation.ts +69 -0
- package/src/mem_pools/tx_pool_v2/interfaces.ts +242 -0
- package/src/mem_pools/tx_pool_v2/tx_metadata.ts +297 -0
- package/src/mem_pools/tx_pool_v2/tx_pool_bench_metrics.ts +77 -0
- package/src/mem_pools/tx_pool_v2/tx_pool_indices.ts +444 -0
- package/src/mem_pools/tx_pool_v2/tx_pool_v2.ts +223 -0
- package/src/mem_pools/tx_pool_v2/tx_pool_v2_impl.ts +1083 -0
- package/src/msg_validators/attestation_validator/fisherman_attestation_validator.ts +10 -4
- package/src/msg_validators/proposal_validator/proposal_validator.ts +5 -5
- package/src/msg_validators/tx_validator/README.md +115 -0
- package/src/msg_validators/tx_validator/aggregate_tx_validator.ts +5 -5
- package/src/msg_validators/tx_validator/archive_cache.ts +3 -3
- package/src/msg_validators/tx_validator/block_header_validator.ts +22 -11
- package/src/msg_validators/tx_validator/data_validator.ts +6 -2
- package/src/msg_validators/tx_validator/double_spend_validator.ts +15 -9
- package/src/msg_validators/tx_validator/factory.ts +372 -55
- package/src/msg_validators/tx_validator/gas_validator.ts +98 -29
- package/src/msg_validators/tx_validator/index.ts +1 -0
- package/src/msg_validators/tx_validator/metadata_validator.ts +6 -3
- package/src/msg_validators/tx_validator/nullifier_cache.ts +30 -0
- package/src/msg_validators/tx_validator/phases_validator.ts +5 -3
- package/src/msg_validators/tx_validator/size_validator.ts +6 -2
- package/src/msg_validators/tx_validator/timestamp_validator.ts +29 -21
- package/src/msg_validators/tx_validator/tx_permitted_validator.ts +8 -3
- package/src/msg_validators/tx_validator/tx_proof_validator.ts +8 -3
- package/src/services/data_store.ts +10 -7
- package/src/services/discv5/discV5_service.ts +1 -1
- package/src/services/dummy_service.ts +59 -2
- package/src/services/encoding.ts +9 -9
- package/src/services/gossipsub/README.md +641 -0
- package/src/services/gossipsub/index.ts +2 -0
- package/src/services/gossipsub/scoring.ts +29 -5
- package/src/services/gossipsub/topic_score_params.ts +487 -0
- package/src/services/index.ts +1 -0
- package/src/services/libp2p/instrumentation.ts +15 -2
- package/src/services/libp2p/libp2p_service.ts +496 -397
- package/src/services/peer-manager/metrics.ts +21 -4
- package/src/services/peer-manager/peer_scoring.ts +29 -1
- package/src/services/reqresp/batch-tx-requester/README.md +305 -0
- package/src/services/reqresp/batch-tx-requester/batch_tx_requester.ts +678 -0
- package/src/services/reqresp/batch-tx-requester/config.ts +40 -0
- package/src/services/reqresp/batch-tx-requester/interface.ts +53 -0
- package/src/services/reqresp/batch-tx-requester/missing_txs.ts +161 -0
- package/src/services/reqresp/batch-tx-requester/peer_collection.ts +244 -0
- package/src/services/reqresp/batch-tx-requester/tx_validator.ts +37 -0
- package/src/services/reqresp/connection-sampler/batch_connection_sampler.ts +65 -4
- package/src/services/reqresp/connection-sampler/connection_sampler.ts +16 -0
- package/src/services/reqresp/interface.ts +29 -1
- package/src/services/reqresp/metrics.ts +34 -9
- package/src/services/reqresp/protocols/block_txs/bitvector.ts +7 -0
- package/src/services/reqresp/protocols/block_txs/block_txs_handler.ts +35 -12
- package/src/services/reqresp/protocols/block_txs/block_txs_reqresp.ts +74 -9
- package/src/services/reqresp/protocols/tx.ts +22 -0
- package/src/services/reqresp/reqresp.ts +82 -23
- package/src/services/service.ts +55 -2
- package/src/services/tx_collection/config.ts +83 -1
- package/src/services/tx_collection/fast_tx_collection.ts +93 -47
- package/src/services/tx_collection/file_store_tx_collection.ts +202 -0
- package/src/services/tx_collection/file_store_tx_source.ts +117 -0
- package/src/services/tx_collection/index.ts +6 -0
- package/src/services/tx_collection/instrumentation.ts +17 -2
- package/src/services/tx_collection/missing_txs_tracker.ts +52 -0
- package/src/services/tx_collection/proposal_tx_collector.ts +113 -0
- package/src/services/tx_collection/slow_tx_collection.ts +66 -33
- package/src/services/tx_collection/tx_collection.ts +117 -20
- package/src/services/tx_collection/tx_collection_sink.ts +30 -34
- package/src/services/tx_collection/tx_source.ts +22 -3
- package/src/services/tx_file_store/config.ts +37 -0
- package/src/services/tx_file_store/index.ts +3 -0
- package/src/services/tx_file_store/instrumentation.ts +36 -0
- package/src/services/tx_file_store/tx_file_store.ts +175 -0
- package/src/services/tx_provider.ts +10 -9
- package/src/services/tx_provider_instrumentation.ts +11 -5
- package/src/test-helpers/index.ts +2 -0
- package/src/test-helpers/make-test-p2p-clients.ts +3 -5
- package/src/test-helpers/mock-pubsub.ts +146 -9
- package/src/test-helpers/reqresp-nodes.ts +4 -6
- package/src/test-helpers/test_tx_provider.ts +64 -0
- package/src/test-helpers/testbench-utils.ts +430 -0
- package/src/testbench/p2p_client_testbench_worker.ts +333 -131
- package/src/testbench/worker_client_manager.ts +304 -47
- package/src/util.ts +7 -1
- package/dest/mem_pools/attestation_pool/kv_attestation_pool.d.ts +0 -40
- package/dest/mem_pools/attestation_pool/kv_attestation_pool.d.ts.map +0 -1
- package/dest/mem_pools/attestation_pool/kv_attestation_pool.js +0 -218
- package/dest/mem_pools/attestation_pool/memory_attestation_pool.d.ts +0 -31
- package/dest/mem_pools/attestation_pool/memory_attestation_pool.d.ts.map +0 -1
- package/dest/mem_pools/attestation_pool/memory_attestation_pool.js +0 -180
- package/src/mem_pools/attestation_pool/kv_attestation_pool.ts +0 -320
- package/src/mem_pools/attestation_pool/memory_attestation_pool.ts +0 -264
|
@@ -1,13 +1,20 @@
|
|
|
1
1
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
2
|
import { L2Block } from '@aztec/stdlib/block';
|
|
3
|
+
import { MAX_L2_BLOCK_SIZE_KB } from '@aztec/stdlib/p2p';
|
|
3
4
|
import { TxArray, TxHashArray } from '@aztec/stdlib/tx';
|
|
4
5
|
|
|
5
6
|
import type { PeerId } from '@libp2p/interface';
|
|
6
7
|
|
|
7
8
|
import type { P2PReqRespConfig } from './config.js';
|
|
9
|
+
import type { ConnectionSampler } from './connection-sampler/connection_sampler.js';
|
|
8
10
|
import { AuthRequest, AuthResponse } from './protocols/auth.js';
|
|
9
|
-
import {
|
|
11
|
+
import {
|
|
12
|
+
BlockTxsRequest,
|
|
13
|
+
BlockTxsResponse,
|
|
14
|
+
calculateBlockTxsResponseSize,
|
|
15
|
+
} from './protocols/block_txs/block_txs_reqresp.js';
|
|
10
16
|
import { StatusMessage } from './protocols/status.js';
|
|
17
|
+
import { calculateTxResponseSize } from './protocols/tx.js';
|
|
11
18
|
import type { ReqRespStatus } from './status.js';
|
|
12
19
|
|
|
13
20
|
/*
|
|
@@ -210,6 +217,25 @@ export const subProtocolMap = {
|
|
|
210
217
|
},
|
|
211
218
|
};
|
|
212
219
|
|
|
220
|
+
/**
|
|
221
|
+
* Type for a function that calculates the expected response size in KB for a given request.
|
|
222
|
+
*/
|
|
223
|
+
export type ExpectedResponseSizeCalculator = (requestBuffer: Buffer) => number;
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* Map of sub-protocols to their expected response size calculators.
|
|
227
|
+
* These are used to validate that responses don't exceed expected sizes based on request parameters.
|
|
228
|
+
*/
|
|
229
|
+
export const subProtocolSizeCalculators: Record<ReqRespSubProtocol, ExpectedResponseSizeCalculator> = {
|
|
230
|
+
[ReqRespSubProtocol.TX]: calculateTxResponseSize,
|
|
231
|
+
[ReqRespSubProtocol.BLOCK_TXS]: calculateBlockTxsResponseSize,
|
|
232
|
+
[ReqRespSubProtocol.BLOCK]: () => MAX_L2_BLOCK_SIZE_KB,
|
|
233
|
+
[ReqRespSubProtocol.STATUS]: () => 1,
|
|
234
|
+
[ReqRespSubProtocol.PING]: () => 1,
|
|
235
|
+
[ReqRespSubProtocol.AUTH]: () => 1,
|
|
236
|
+
[ReqRespSubProtocol.GOODBYE]: () => 1, // No response expected, but provide minimal limit
|
|
237
|
+
};
|
|
238
|
+
|
|
213
239
|
export interface ReqRespInterface {
|
|
214
240
|
start(
|
|
215
241
|
subProtocolHandlers: Partial<ReqRespSubProtocolHandlers>,
|
|
@@ -237,4 +263,6 @@ export interface ReqRespInterface {
|
|
|
237
263
|
): Promise<ReqRespResponse>;
|
|
238
264
|
|
|
239
265
|
updateConfig(config: Partial<P2PReqRespConfig>): void;
|
|
266
|
+
|
|
267
|
+
getConnectionSampler(): Pick<ConnectionSampler, 'getPeerListSortedByConnectionCountAsc'>;
|
|
240
268
|
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
// Request response metrics
|
|
2
|
-
import { Attributes, Metrics } from '@aztec/telemetry-client';
|
|
2
|
+
import { Attributes, Metrics, createUpDownCounterWithDefault } from '@aztec/telemetry-client';
|
|
3
3
|
import type { TelemetryClient, Tracer, UpDownCounter } from '@aztec/telemetry-client';
|
|
4
4
|
|
|
5
|
+
import { ReqRespSubProtocol } from './interface.js';
|
|
6
|
+
|
|
5
7
|
export class ReqRespMetrics {
|
|
6
8
|
public readonly tracer: Tracer;
|
|
7
9
|
|
|
@@ -18,27 +20,50 @@ export class ReqRespMetrics {
|
|
|
18
20
|
this.tracer = telemetryClient.getTracer(name);
|
|
19
21
|
|
|
20
22
|
const meter = telemetryClient.getMeter(name);
|
|
21
|
-
|
|
22
|
-
|
|
23
|
+
const protocolAttrs = {
|
|
24
|
+
[Attributes.P2P_REQ_RESP_PROTOCOL]: [
|
|
25
|
+
ReqRespSubProtocol.PING,
|
|
26
|
+
ReqRespSubProtocol.STATUS,
|
|
27
|
+
ReqRespSubProtocol.GOODBYE,
|
|
28
|
+
ReqRespSubProtocol.TX,
|
|
29
|
+
ReqRespSubProtocol.BLOCK,
|
|
30
|
+
ReqRespSubProtocol.AUTH,
|
|
31
|
+
ReqRespSubProtocol.BLOCK_TXS,
|
|
32
|
+
],
|
|
33
|
+
};
|
|
34
|
+
this.sentRequests = createUpDownCounterWithDefault(meter, Metrics.P2P_REQ_RESP_SENT_REQUESTS, protocolAttrs);
|
|
35
|
+
this.receivedRequests = createUpDownCounterWithDefault(
|
|
36
|
+
meter,
|
|
37
|
+
Metrics.P2P_REQ_RESP_RECEIVED_REQUESTS,
|
|
38
|
+
protocolAttrs,
|
|
39
|
+
);
|
|
23
40
|
|
|
24
|
-
this.failedOutboundRequests =
|
|
41
|
+
this.failedOutboundRequests = createUpDownCounterWithDefault(
|
|
42
|
+
meter,
|
|
43
|
+
Metrics.P2P_REQ_RESP_FAILED_OUTBOUND_REQUESTS,
|
|
44
|
+
protocolAttrs,
|
|
45
|
+
);
|
|
25
46
|
|
|
26
|
-
this.failedInboundRequests =
|
|
47
|
+
this.failedInboundRequests = createUpDownCounterWithDefault(
|
|
48
|
+
meter,
|
|
49
|
+
Metrics.P2P_REQ_RESP_FAILED_INBOUND_REQUESTS,
|
|
50
|
+
protocolAttrs,
|
|
51
|
+
);
|
|
27
52
|
}
|
|
28
53
|
|
|
29
|
-
public recordRequestSent(protocol:
|
|
54
|
+
public recordRequestSent(protocol: ReqRespSubProtocol) {
|
|
30
55
|
this.sentRequests.add(1, { [Attributes.P2P_REQ_RESP_PROTOCOL]: protocol });
|
|
31
56
|
}
|
|
32
57
|
|
|
33
|
-
public recordRequestReceived(protocol:
|
|
58
|
+
public recordRequestReceived(protocol: ReqRespSubProtocol) {
|
|
34
59
|
this.receivedRequests.add(1, { [Attributes.P2P_REQ_RESP_PROTOCOL]: protocol });
|
|
35
60
|
}
|
|
36
61
|
|
|
37
|
-
public recordRequestError(protocol:
|
|
62
|
+
public recordRequestError(protocol: ReqRespSubProtocol) {
|
|
38
63
|
this.failedOutboundRequests.add(1, { [Attributes.P2P_REQ_RESP_PROTOCOL]: protocol });
|
|
39
64
|
}
|
|
40
65
|
|
|
41
|
-
public recordResponseError(protocol:
|
|
66
|
+
public recordResponseError(protocol: ReqRespSubProtocol) {
|
|
42
67
|
this.failedInboundRequests.add(1, { [Attributes.P2P_REQ_RESP_PROTOCOL]: protocol });
|
|
43
68
|
}
|
|
44
69
|
}
|
|
@@ -64,6 +64,13 @@ export class BitVector {
|
|
|
64
64
|
return Array.from({ length: this.length }, (_, i) => i).filter(i => this.isSet(i));
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
+
/**
|
|
68
|
+
* Returns true if no indices are set to true
|
|
69
|
+
* */
|
|
70
|
+
isEmpty(): boolean {
|
|
71
|
+
return this.getTrueIndices().length === 0;
|
|
72
|
+
}
|
|
73
|
+
|
|
67
74
|
/**
|
|
68
75
|
* Serializes the BitVector object into a Buffer
|
|
69
76
|
*
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
|
+
import type { L2BlockSource } from '@aztec/stdlib/block';
|
|
1
3
|
import { TxArray } from '@aztec/stdlib/tx';
|
|
2
4
|
|
|
3
5
|
import type { PeerId } from '@libp2p/interface';
|
|
4
6
|
|
|
5
|
-
import type {
|
|
6
|
-
import type {
|
|
7
|
+
import type { AttestationPoolApi } from '../../../../mem_pools/attestation_pool/attestation_pool.js';
|
|
8
|
+
import type { TxPoolV2 } from '../../../../mem_pools/tx_pool_v2/interfaces.js';
|
|
7
9
|
import type { ReqRespSubProtocolHandler } from '../../interface.js';
|
|
8
10
|
import { ReqRespStatus, ReqRespStatusError } from '../../status.js';
|
|
9
11
|
import { BitVector } from './bitvector.js';
|
|
@@ -12,10 +14,15 @@ import { BlockTxsRequest, BlockTxsResponse } from './block_txs_reqresp.js';
|
|
|
12
14
|
/**
|
|
13
15
|
* Handler for block txs requests
|
|
14
16
|
* @param attestationPool - the attestation pool to check for block proposals
|
|
15
|
-
* @param
|
|
17
|
+
* @param archiver - the archiver to look up blocks by archive root
|
|
18
|
+
* @param txPool - the tx pool to fetch transactions from
|
|
16
19
|
* @returns the BlockTxs request handler
|
|
17
20
|
*/
|
|
18
|
-
export function reqRespBlockTxsHandler(
|
|
21
|
+
export function reqRespBlockTxsHandler(
|
|
22
|
+
attestationPool: AttestationPoolApi,
|
|
23
|
+
archiver: L2BlockSource,
|
|
24
|
+
txPool: TxPoolV2,
|
|
25
|
+
): ReqRespSubProtocolHandler {
|
|
19
26
|
/**
|
|
20
27
|
* Handler for block txs requests
|
|
21
28
|
* @param msg - the block txs request message
|
|
@@ -29,24 +36,40 @@ export function reqRespBlockTxsHandler(attestationPool: AttestationPool, txPool:
|
|
|
29
36
|
} catch (err: any) {
|
|
30
37
|
throw new ReqRespStatusError(ReqRespStatus.BADLY_FORMED_REQUEST, { cause: err });
|
|
31
38
|
}
|
|
39
|
+
// First try attestation pool, then fall back to archiver
|
|
40
|
+
let txHashes = (await attestationPool.getBlockProposal(request.archiveRoot.toString()))?.txHashes;
|
|
41
|
+
if (!txHashes) {
|
|
42
|
+
txHashes = (await archiver.getL2BlockByArchive(request.archiveRoot))?.body.txEffects.map(effect => effect.txHash);
|
|
43
|
+
}
|
|
32
44
|
|
|
33
|
-
|
|
45
|
+
let requestedTxsHashes;
|
|
46
|
+
if (request.txHashes.length > 0) {
|
|
47
|
+
requestedTxsHashes = request.txHashes;
|
|
48
|
+
}
|
|
34
49
|
|
|
35
|
-
|
|
50
|
+
// This is scenario in which we don't have this block the peer is requesting from us
|
|
51
|
+
// But peer has sent requested tx hashes, so we can send them the transactions
|
|
52
|
+
if (!txHashes && requestedTxsHashes !== undefined) {
|
|
53
|
+
const responseTxs = (await txPool.getTxsByHash(requestedTxsHashes)).filter(tx => !!tx);
|
|
54
|
+
const response = new BlockTxsResponse(Fr.zero(), new TxArray(...responseTxs), BitVector.init(0, []));
|
|
55
|
+
return response.toBuffer();
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// If we don't have this block and peer has not sent requested tx hashes
|
|
59
|
+
if (!txHashes) {
|
|
36
60
|
throw new ReqRespStatusError(ReqRespStatus.NOT_FOUND);
|
|
37
61
|
}
|
|
38
62
|
|
|
39
|
-
const txsAvailableInPool = await txPool.hasTxs(
|
|
40
|
-
//Map txs in the pool to their indices in the block
|
|
63
|
+
const txsAvailableInPool = await txPool.hasTxs(txHashes);
|
|
64
|
+
// Map txs in the pool to their indices in the block
|
|
41
65
|
const availableIndices = txsAvailableInPool.map((hasTx, idx) => (hasTx ? idx : -1)).filter(idx => idx !== -1);
|
|
42
|
-
const responseBitVector = BitVector.init(
|
|
66
|
+
const responseBitVector = BitVector.init(txHashes.length, availableIndices);
|
|
43
67
|
|
|
44
68
|
const requestedIndices = new Set(request.txIndices.getTrueIndices());
|
|
45
|
-
|
|
69
|
+
requestedTxsHashes = txHashes.filter((_, idx) => requestedIndices.has(idx));
|
|
46
70
|
|
|
47
71
|
const responseTxs = (await txPool.getTxsByHash(requestedTxsHashes)).filter(tx => !!tx);
|
|
48
|
-
|
|
49
|
-
const response = new BlockTxsResponse(request.blockHash, new TxArray(...responseTxs), responseBitVector);
|
|
72
|
+
const response = new BlockTxsResponse(request.archiveRoot, new TxArray(...responseTxs), responseBitVector);
|
|
50
73
|
|
|
51
74
|
return response.toBuffer();
|
|
52
75
|
};
|
|
@@ -1,20 +1,68 @@
|
|
|
1
1
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
2
|
import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
|
|
3
|
-
import {
|
|
3
|
+
import { MAX_TX_SIZE_KB } from '@aztec/stdlib/p2p';
|
|
4
|
+
import { TxArray, type TxHash, TxHashArray } from '@aztec/stdlib/tx';
|
|
4
5
|
|
|
5
6
|
import { BitVector } from './bitvector.js';
|
|
6
7
|
|
|
8
|
+
/** Minimal interface for a block source that provides tx hashes and an archive root. */
|
|
9
|
+
export interface BlockTxsSource {
|
|
10
|
+
txHashes: TxHash[];
|
|
11
|
+
archive: Fr;
|
|
12
|
+
}
|
|
13
|
+
|
|
7
14
|
/**
|
|
8
15
|
* Request message for requesting specific transactions from a block
|
|
9
16
|
*/
|
|
10
17
|
export class BlockTxsRequest {
|
|
11
18
|
constructor(
|
|
12
|
-
|
|
19
|
+
// Archive root after the proposed block is applied (proposal identifier)
|
|
20
|
+
readonly archiveRoot: Fr,
|
|
21
|
+
// Hashes of txs we are requesting
|
|
22
|
+
readonly txHashes: TxHashArray,
|
|
13
23
|
// BitVector indicating which txs from the proposal we are requesting
|
|
14
24
|
// 1 means we want the tx, 0 means we don't
|
|
25
|
+
// If we know peer has the Block Proposal then we can use this BitVector
|
|
26
|
+
// Otherwise we can use this optimization
|
|
15
27
|
readonly txIndices: BitVector,
|
|
16
28
|
) {}
|
|
17
29
|
|
|
30
|
+
/**
|
|
31
|
+
* Creates new BlockTxsRequest given a block txs source and missing tx hashes.
|
|
32
|
+
*
|
|
33
|
+
* @param blockTxsSource - The block or proposal for which we are making the request
|
|
34
|
+
* @param missingTxHashes - Tx hashes from the source we are missing
|
|
35
|
+
* @param includeFullTxHashes - Whether to include full list of missing tx hashes in the request or just Bitvector indices
|
|
36
|
+
*
|
|
37
|
+
* @returns undefined if there were no missingTxHashes matching the source hashes, otherwise
|
|
38
|
+
* returns new BlockTxsRequest
|
|
39
|
+
*/
|
|
40
|
+
static fromTxsSourceAndMissingTxs(
|
|
41
|
+
blockTxsSource: BlockTxsSource,
|
|
42
|
+
missingTxHashes: TxHash[],
|
|
43
|
+
includeFullTxHashes = false,
|
|
44
|
+
): BlockTxsRequest | undefined {
|
|
45
|
+
if (missingTxHashes.length === 0) {
|
|
46
|
+
return undefined; // No missing txs to request
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const missingHashesSet = new Set(missingTxHashes.map(t => t.toString()));
|
|
50
|
+
|
|
51
|
+
// We cannot request txs that are not part of the block
|
|
52
|
+
if (!missingHashesSet.isSubsetOf(new Set(blockTxsSource.txHashes.map(t => t.toString())))) {
|
|
53
|
+
return undefined;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const missingIndices = blockTxsSource.txHashes
|
|
57
|
+
.map((hash, idx) => (missingHashesSet.has(hash.toString()) ? idx : -1))
|
|
58
|
+
.filter(i => i != -1);
|
|
59
|
+
|
|
60
|
+
const requestBitVector = BitVector.init(blockTxsSource.txHashes.length, missingIndices);
|
|
61
|
+
const hashes = includeFullTxHashes ? new TxHashArray(...missingTxHashes) : new TxHashArray();
|
|
62
|
+
|
|
63
|
+
return new BlockTxsRequest(blockTxsSource.archive, hashes, requestBitVector);
|
|
64
|
+
}
|
|
65
|
+
|
|
18
66
|
/**
|
|
19
67
|
* Deserializes the BlockTxRequest object from a Buffer
|
|
20
68
|
* @param buffer - Buffer or BufferReader object to deserialize
|
|
@@ -22,10 +70,11 @@ export class BlockTxsRequest {
|
|
|
22
70
|
*/
|
|
23
71
|
static fromBuffer(buffer: Buffer | BufferReader): BlockTxsRequest {
|
|
24
72
|
const reader = BufferReader.asReader(buffer);
|
|
25
|
-
const
|
|
73
|
+
const archiveRoot = Fr.fromBuffer(reader);
|
|
74
|
+
const txHashes = TxHashArray.fromBuffer(reader);
|
|
26
75
|
const txIndices = BitVector.fromBuffer(reader);
|
|
27
76
|
|
|
28
|
-
return new BlockTxsRequest(
|
|
77
|
+
return new BlockTxsRequest(archiveRoot, txHashes, txIndices);
|
|
29
78
|
}
|
|
30
79
|
|
|
31
80
|
/**
|
|
@@ -33,7 +82,7 @@ export class BlockTxsRequest {
|
|
|
33
82
|
* @returns Buffer representation of the BlockTxRequest object
|
|
34
83
|
*/
|
|
35
84
|
toBuffer(): Buffer {
|
|
36
|
-
return serializeToBuffer([this.
|
|
85
|
+
return serializeToBuffer([this.archiveRoot, this.txHashes.toBuffer(), this.txIndices.toBuffer()]);
|
|
37
86
|
}
|
|
38
87
|
}
|
|
39
88
|
|
|
@@ -42,7 +91,7 @@ export class BlockTxsRequest {
|
|
|
42
91
|
*/
|
|
43
92
|
export class BlockTxsResponse {
|
|
44
93
|
constructor(
|
|
45
|
-
readonly
|
|
94
|
+
readonly archiveRoot: Fr,
|
|
46
95
|
readonly txs: TxArray, // List of transactions we requested and peer has
|
|
47
96
|
// BitVector indicating which txs from the proposal are available at the peer
|
|
48
97
|
// 1 means the tx is available, 0 means it is not
|
|
@@ -56,11 +105,11 @@ export class BlockTxsResponse {
|
|
|
56
105
|
*/
|
|
57
106
|
static fromBuffer(buffer: Buffer | BufferReader): BlockTxsResponse {
|
|
58
107
|
const reader = BufferReader.asReader(buffer);
|
|
59
|
-
const
|
|
108
|
+
const archiveRoot = Fr.fromBuffer(reader);
|
|
60
109
|
const txs = TxArray.fromBuffer(reader);
|
|
61
110
|
const txIndices = BitVector.fromBuffer(reader);
|
|
62
111
|
|
|
63
|
-
return new BlockTxsResponse(
|
|
112
|
+
return new BlockTxsResponse(archiveRoot, txs, txIndices);
|
|
64
113
|
}
|
|
65
114
|
|
|
66
115
|
/**
|
|
@@ -70,10 +119,26 @@ export class BlockTxsResponse {
|
|
|
70
119
|
* @returns Buffer representation of the BlockTxResponse object
|
|
71
120
|
*/
|
|
72
121
|
toBuffer(): Buffer {
|
|
73
|
-
return serializeToBuffer([this.
|
|
122
|
+
return serializeToBuffer([this.archiveRoot, this.txs.toBuffer(), this.txIndices.toBuffer()]);
|
|
74
123
|
}
|
|
75
124
|
|
|
76
125
|
static empty(): BlockTxsResponse {
|
|
77
126
|
return new BlockTxsResponse(Fr.ZERO, new TxArray(), BitVector.init(0, []));
|
|
78
127
|
}
|
|
79
128
|
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Calculate the expected response size for a BLOCK_TXS request.
|
|
132
|
+
* @param requestBuffer - The serialized request buffer containing BlockTxsRequest
|
|
133
|
+
* @returns Expected response size in KB
|
|
134
|
+
*/
|
|
135
|
+
export function calculateBlockTxsResponseSize(requestBuffer: Buffer): number {
|
|
136
|
+
try {
|
|
137
|
+
const request = BlockTxsRequest.fromBuffer(requestBuffer);
|
|
138
|
+
const requestedTxCount = request.txIndices.getTrueIndices().length;
|
|
139
|
+
return requestedTxCount * MAX_TX_SIZE_KB + 1; // +1 KB overhead for serialization
|
|
140
|
+
} catch {
|
|
141
|
+
// If we can't parse the request, fall back to allowing a single transaction response
|
|
142
|
+
return MAX_TX_SIZE_KB + 1;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { chunk } from '@aztec/foundation/collection';
|
|
2
|
+
import { MAX_TX_SIZE_KB } from '@aztec/stdlib/p2p';
|
|
2
3
|
import { TxArray, TxHash, TxHashArray } from '@aztec/stdlib/tx';
|
|
3
4
|
|
|
4
5
|
import type { PeerId } from '@libp2p/interface';
|
|
@@ -55,3 +56,24 @@ export function reqRespTxHandler(mempools: MemPools): ReqRespSubProtocolHandler
|
|
|
55
56
|
export function chunkTxHashesRequest(hashes: TxHash[], chunkSize = 1): Array<TxHashArray> {
|
|
56
57
|
return chunk(hashes, chunkSize).map(chunk => new TxHashArray(...chunk));
|
|
57
58
|
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Calculate the expected response size for a TX request.
|
|
62
|
+
* @param requestBuffer - The serialized request buffer containing TxHashArray
|
|
63
|
+
* @returns Expected response size in KB
|
|
64
|
+
*/
|
|
65
|
+
export function calculateTxResponseSize(requestBuffer: Buffer): number {
|
|
66
|
+
try {
|
|
67
|
+
const txHashes = TxHashArray.fromBuffer(requestBuffer);
|
|
68
|
+
// TxHashArray.fromBuffer returns empty array on parse failure, so check for that
|
|
69
|
+
if (txHashes.length === 0 && requestBuffer.length > 0) {
|
|
70
|
+
// If we got an empty array but had a non-empty buffer, parsing likely failed
|
|
71
|
+
// Fall back to allowing a single transaction response
|
|
72
|
+
return MAX_TX_SIZE_KB + 1;
|
|
73
|
+
}
|
|
74
|
+
return Math.max(txHashes.length, 1) * MAX_TX_SIZE_KB + 1; // +1 KB overhead, at least 1 tx
|
|
75
|
+
} catch {
|
|
76
|
+
// If we can't parse the request, fall back to allowing a single transaction response
|
|
77
|
+
return MAX_TX_SIZE_KB + 1;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
@@ -36,6 +36,7 @@ import {
|
|
|
36
36
|
type ReqRespSubProtocolValidators,
|
|
37
37
|
type SubProtocolMap,
|
|
38
38
|
responseFromBuffer,
|
|
39
|
+
subProtocolSizeCalculators,
|
|
39
40
|
} from './interface.js';
|
|
40
41
|
import { ReqRespMetrics } from './metrics.js';
|
|
41
42
|
import {
|
|
@@ -111,6 +112,13 @@ export class ReqResp implements ReqRespInterface {
|
|
|
111
112
|
return this.metrics.tracer;
|
|
112
113
|
}
|
|
113
114
|
|
|
115
|
+
/**
|
|
116
|
+
* Get the connection sampler instance
|
|
117
|
+
*/
|
|
118
|
+
getConnectionSampler(): Pick<ConnectionSampler, 'getPeerListSortedByConnectionCountAsc'> {
|
|
119
|
+
return this.connectionSampler;
|
|
120
|
+
}
|
|
121
|
+
|
|
114
122
|
/**
|
|
115
123
|
* Start the reqresp service
|
|
116
124
|
*/
|
|
@@ -212,6 +220,14 @@ export class ReqResp implements ReqRespInterface {
|
|
|
212
220
|
const responseValidator = this.subProtocolValidators[subProtocol] ?? DEFAULT_SUB_PROTOCOL_VALIDATORS[subProtocol];
|
|
213
221
|
const responses: InstanceType<SubProtocolMap[SubProtocol]['response']>[] = new Array(requests.length);
|
|
214
222
|
const requestBuffers = requests.map(req => req.toBuffer());
|
|
223
|
+
const isEmptyResponse = (value: unknown): boolean => {
|
|
224
|
+
// Some responses serialize to a non-empty buffer even when they contain no items (e.g., empty TxArray).
|
|
225
|
+
if (!value || typeof value !== 'object') {
|
|
226
|
+
return false;
|
|
227
|
+
}
|
|
228
|
+
const length = (value as { length?: number }).length;
|
|
229
|
+
return typeof length === 'number' && length === 0;
|
|
230
|
+
};
|
|
215
231
|
|
|
216
232
|
const requestFunction = async (signal: AbortSignal) => {
|
|
217
233
|
// Track which requests still need to be processed
|
|
@@ -252,7 +268,9 @@ export class ReqResp implements ReqRespInterface {
|
|
|
252
268
|
for (const requestIndex of pendingRequestIndices) {
|
|
253
269
|
const peer = batchSampler.getPeerForRequest(requestIndex);
|
|
254
270
|
if (!peer) {
|
|
255
|
-
|
|
271
|
+
// No peer available for this specific index (all peers exhausted for it)
|
|
272
|
+
// Skip this index for now - it stays in pendingRequestIndices for retry
|
|
273
|
+
continue;
|
|
256
274
|
}
|
|
257
275
|
const peerAsString = peer.toString();
|
|
258
276
|
if (!requestBatches.has(peerAsString)) {
|
|
@@ -271,6 +289,12 @@ export class ReqResp implements ReqRespInterface {
|
|
|
271
289
|
});
|
|
272
290
|
}
|
|
273
291
|
|
|
292
|
+
// If no requests could be assigned (all peers exhausted for all indices), exit early
|
|
293
|
+
if (requestBatches.size === 0) {
|
|
294
|
+
this.logger.warn('No peers available for any pending request indices, stopping batch request');
|
|
295
|
+
break;
|
|
296
|
+
}
|
|
297
|
+
|
|
274
298
|
// Make parallel requests for each peer's batch
|
|
275
299
|
// A batch entry will look something like this:
|
|
276
300
|
// PeerId0: [0, 1, 2, 3]
|
|
@@ -282,38 +306,61 @@ export class ReqResp implements ReqRespInterface {
|
|
|
282
306
|
const batchResults = await Promise.all(
|
|
283
307
|
Array.from(requestBatches.entries()).map(async ([peerAsString, { peerId: peer, indices }]) => {
|
|
284
308
|
try {
|
|
309
|
+
const markIndexFailed = (index: number) => batchSampler.markPeerFailedForIndex(peer, index);
|
|
285
310
|
// Requests all going to the same peer are sent synchronously
|
|
286
311
|
const peerResults: { index: number; response: InstanceType<SubProtocolMap[SubProtocol]['response']> }[] =
|
|
287
312
|
[];
|
|
313
|
+
let shouldReplacePeer = false;
|
|
314
|
+
const handleFailure = (status: ReqRespStatus, index: number) => {
|
|
315
|
+
this.logger.warn(
|
|
316
|
+
`Request to peer ${peerAsString} failed with status ${prettyPrintReqRespStatus(status)}`,
|
|
317
|
+
);
|
|
318
|
+
markIndexFailed(index);
|
|
319
|
+
return status === ReqRespStatus.RATE_LIMIT_EXCEEDED;
|
|
320
|
+
};
|
|
321
|
+
|
|
288
322
|
for (const index of indices) {
|
|
289
|
-
this.logger.
|
|
323
|
+
this.logger.info(`Sending request ${index} to peer ${peerAsString}`);
|
|
290
324
|
const response = await this.sendRequestToPeer(peer, subProtocol, requestBuffers[index]);
|
|
291
325
|
|
|
292
326
|
// Check the status of the response buffer
|
|
293
327
|
if (response.status !== ReqRespStatus.SUCCESS) {
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
// they will be split among remaining peers and the new sampled peer
|
|
300
|
-
batchSampler.removePeerAndReplace(peer);
|
|
301
|
-
return { peer, results: peerResults };
|
|
328
|
+
shouldReplacePeer = handleFailure(response.status, index);
|
|
329
|
+
if (shouldReplacePeer) {
|
|
330
|
+
break;
|
|
331
|
+
}
|
|
332
|
+
continue;
|
|
302
333
|
}
|
|
303
334
|
|
|
304
|
-
if (response
|
|
305
|
-
|
|
306
|
-
|
|
335
|
+
if (response.data.length === 0) {
|
|
336
|
+
markIndexFailed(index);
|
|
337
|
+
continue;
|
|
338
|
+
}
|
|
307
339
|
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
340
|
+
const object = responseFromBuffer(subProtocol, response.data);
|
|
341
|
+
if (isEmptyResponse(object)) {
|
|
342
|
+
markIndexFailed(index);
|
|
343
|
+
continue;
|
|
311
344
|
}
|
|
345
|
+
|
|
346
|
+
const isValid = await responseValidator(requests[index], object, peer);
|
|
347
|
+
if (!isValid) {
|
|
348
|
+
markIndexFailed(index);
|
|
349
|
+
continue;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
peerResults.push({ index, response: object });
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
// If peer had a hard failure (rate limit), replace it for future iterations
|
|
356
|
+
if (shouldReplacePeer) {
|
|
357
|
+
this.logger.warn(`Peer ${peerAsString} hit a hard failure, removing from sampler`);
|
|
358
|
+
batchSampler.removePeerAndReplace(peer);
|
|
312
359
|
}
|
|
313
360
|
|
|
314
361
|
return { peer, results: peerResults };
|
|
315
362
|
} catch (error) {
|
|
316
|
-
this.logger.
|
|
363
|
+
this.logger.warn(`Failed batch request to peer ${peerAsString}:`, error);
|
|
317
364
|
batchSampler.removePeerAndReplace(peer);
|
|
318
365
|
return { peer, results: [] };
|
|
319
366
|
}
|
|
@@ -334,7 +381,7 @@ export class ReqResp implements ReqRespInterface {
|
|
|
334
381
|
}
|
|
335
382
|
|
|
336
383
|
if (retryAttempts >= maxRetryAttempts) {
|
|
337
|
-
this.logger.
|
|
384
|
+
this.logger.warn(`Max retry attempts ${maxRetryAttempts} reached for batch request`);
|
|
338
385
|
}
|
|
339
386
|
|
|
340
387
|
return responses;
|
|
@@ -347,7 +394,7 @@ export class ReqResp implements ReqRespInterface {
|
|
|
347
394
|
() => new CollectiveReqRespTimeoutError(),
|
|
348
395
|
);
|
|
349
396
|
} catch (e: any) {
|
|
350
|
-
this.logger.
|
|
397
|
+
this.logger.warn(`${e.message} | subProtocol: ${subProtocol}`);
|
|
351
398
|
return [];
|
|
352
399
|
}
|
|
353
400
|
}
|
|
@@ -391,6 +438,9 @@ export class ReqResp implements ReqRespInterface {
|
|
|
391
438
|
try {
|
|
392
439
|
this.metrics.recordRequestSent(subProtocol);
|
|
393
440
|
|
|
441
|
+
// Calculate expected response size based on the request payload
|
|
442
|
+
const expectedSizeKb = subProtocolSizeCalculators[subProtocol](payload);
|
|
443
|
+
|
|
394
444
|
this.logger.trace(`Sending request to peer ${peerId.toString()} on sub protocol ${subProtocol}`);
|
|
395
445
|
stream = await this.connectionSampler.dialProtocol(peerId, subProtocol, dialTimeout);
|
|
396
446
|
this.logger.trace(
|
|
@@ -398,17 +448,21 @@ export class ReqResp implements ReqRespInterface {
|
|
|
398
448
|
);
|
|
399
449
|
|
|
400
450
|
const timeoutErr = new IndividualReqRespTimeoutError();
|
|
451
|
+
// Create a wrapper to pass the expected size to readMessage
|
|
452
|
+
const readMessageWithSizeLimit = (source: AsyncIterable<Uint8ArrayList>) =>
|
|
453
|
+
this.readMessage(source, expectedSizeKb);
|
|
401
454
|
const [_, resp] = await executeTimeout(
|
|
402
455
|
signal =>
|
|
403
456
|
Promise.all([
|
|
404
457
|
pipeline([payload], stream!.sink, { signal }),
|
|
405
|
-
pipeline(stream!.source,
|
|
458
|
+
pipeline(stream!.source, readMessageWithSizeLimit, { signal }),
|
|
406
459
|
]),
|
|
407
460
|
this.individualRequestTimeoutMs,
|
|
408
461
|
() => timeoutErr,
|
|
409
462
|
);
|
|
410
463
|
return resp;
|
|
411
464
|
} catch (e: any) {
|
|
465
|
+
this.logger.warn(`SUBPROTOCOL: ${subProtocol}\n`, e);
|
|
412
466
|
// On error we immediately abort the stream, this is preferred way,
|
|
413
467
|
// because it signals to the sender that error happened, whereas
|
|
414
468
|
// closing the stream only closes our side and is much slower
|
|
@@ -463,8 +517,11 @@ export class ReqResp implements ReqRespInterface {
|
|
|
463
517
|
* The message is split into two components
|
|
464
518
|
* - The first chunk should contain a control byte, indicating the status of the response see `ReqRespStatus`
|
|
465
519
|
* - The second chunk should contain the response data
|
|
520
|
+
*
|
|
521
|
+
* @param source - The async iterable source of data chunks
|
|
522
|
+
* @param maxSizeKb - Optional maximum expected size in KB for the decompressed response
|
|
466
523
|
*/
|
|
467
|
-
private async readMessage(source: AsyncIterable<Uint8ArrayList
|
|
524
|
+
private async readMessage(source: AsyncIterable<Uint8ArrayList>, maxSizeKb?: number): Promise<ReqRespResponse> {
|
|
468
525
|
let status: ReqRespStatus | undefined;
|
|
469
526
|
const chunks: Uint8Array[] = [];
|
|
470
527
|
|
|
@@ -489,7 +546,7 @@ export class ReqResp implements ReqRespInterface {
|
|
|
489
546
|
}
|
|
490
547
|
|
|
491
548
|
const messageData = Buffer.concat(chunks);
|
|
492
|
-
const message: Buffer = this.snappyTransform.inboundTransformData(messageData);
|
|
549
|
+
const message: Buffer = this.snappyTransform.inboundTransformData(messageData, undefined, maxSizeKb);
|
|
493
550
|
|
|
494
551
|
return {
|
|
495
552
|
status: status ?? ReqRespStatus.UNKNOWN,
|
|
@@ -570,7 +627,9 @@ export class ReqResp implements ReqRespInterface {
|
|
|
570
627
|
// and that this stream should be dropped
|
|
571
628
|
const isMessageToNotWarn =
|
|
572
629
|
err instanceof Error &&
|
|
573
|
-
['stream reset', 'Cannot push value onto an ended pushable'].some(msg =>
|
|
630
|
+
['stream reset', 'Cannot push value onto an ended pushable', 'read ECONNRESET'].some(msg =>
|
|
631
|
+
err.message.includes(msg),
|
|
632
|
+
);
|
|
574
633
|
const level = isMessageToNotWarn ? 'debug' : 'warn';
|
|
575
634
|
this.logger[level]('Unknown stream error while handling the stream, aborting', {
|
|
576
635
|
protocol,
|