@aztec/p2p 0.0.1-commit.6d3c34e → 0.0.1-commit.6d63667d
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 +1 -1
- package/dest/client/factory.d.ts.map +1 -1
- package/dest/client/factory.js +9 -6
- package/dest/client/p2p_client.d.ts +4 -2
- package/dest/client/p2p_client.d.ts.map +1 -1
- package/dest/client/p2p_client.js +16 -5
- 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 +305 -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 +14 -2
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +7 -3
- package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.d.ts +1 -1
- package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.js +20 -9
- package/dest/mem_pools/attestation_pool/mocks.d.ts +4 -2
- package/dest/mem_pools/attestation_pool/mocks.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/mocks.js +8 -5
- 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/tx_pool/aztec_kv_tx_pool.d.ts +15 -10
- package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.js +91 -50
- package/dest/mem_pools/tx_pool/eviction/eviction_manager.d.ts +19 -5
- package/dest/mem_pools/tx_pool/eviction/eviction_manager.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool/eviction/eviction_manager.js +59 -3
- package/dest/mem_pools/tx_pool/eviction/eviction_strategy.d.ts +79 -5
- package/dest/mem_pools/tx_pool/eviction/eviction_strategy.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool/eviction/eviction_strategy.js +47 -0
- package/dest/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.d.ts +16 -0
- package/dest/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.js +122 -0
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.d.ts +2 -2
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.d.ts +4 -4
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.js +2 -0
- package/dest/mem_pools/tx_pool/eviction/low_priority_eviction_rule.d.ts +2 -2
- package/dest/mem_pools/tx_pool/eviction/low_priority_eviction_rule.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool/eviction/nullifier_conflict_pre_add_rule.d.ts +25 -0
- package/dest/mem_pools/tx_pool/eviction/nullifier_conflict_pre_add_rule.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool/eviction/nullifier_conflict_pre_add_rule.js +57 -0
- 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/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 +119 -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 +90 -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 +89 -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 +131 -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 +17 -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 +63 -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 +91 -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 +70 -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 +63 -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 +5 -0
- package/dest/mem_pools/tx_pool_v2/index.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/index.js +4 -0
- package/dest/mem_pools/tx_pool_v2/interfaces.d.ts +197 -0
- package/dest/mem_pools/tx_pool_v2/interfaces.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/interfaces.js +6 -0
- package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts +71 -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 +95 -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 +99 -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 +332 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts +55 -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 +156 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts +69 -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 +748 -0
- package/dest/msg_validators/attestation_validator/attestation_validator.d.ts +3 -3
- package/dest/msg_validators/attestation_validator/attestation_validator.d.ts.map +1 -1
- package/dest/msg_validators/attestation_validator/attestation_validator.js +41 -10
- 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 +18 -6
- package/dest/msg_validators/clock_tolerance.d.ts +21 -0
- package/dest/msg_validators/clock_tolerance.d.ts.map +1 -0
- package/dest/msg_validators/clock_tolerance.js +37 -0
- package/dest/msg_validators/proposal_validator/proposal_validator.d.ts +3 -3
- package/dest/msg_validators/proposal_validator/proposal_validator.d.ts.map +1 -1
- package/dest/msg_validators/proposal_validator/proposal_validator.js +55 -31
- package/dest/msg_validators/proposal_validator/proposal_validator_test_suite.d.ts +3 -3
- package/dest/msg_validators/proposal_validator/proposal_validator_test_suite.d.ts.map +1 -1
- package/dest/msg_validators/proposal_validator/proposal_validator_test_suite.js +93 -64
- 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 +5 -4
- package/dest/msg_validators/tx_validator/block_header_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/block_header_validator.js +3 -2
- 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 +3 -2
- package/dest/msg_validators/tx_validator/double_spend_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/double_spend_validator.js +3 -2
- package/dest/msg_validators/tx_validator/factory.d.ts +8 -3
- package/dest/msg_validators/tx_validator/factory.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/factory.js +21 -11
- package/dest/msg_validators/tx_validator/fee_payer_balance.d.ts +10 -0
- package/dest/msg_validators/tx_validator/fee_payer_balance.d.ts.map +1 -0
- package/dest/msg_validators/tx_validator/fee_payer_balance.js +20 -0
- package/dest/msg_validators/tx_validator/gas_validator.d.ts +3 -2
- package/dest/msg_validators/tx_validator/gas_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/gas_validator.js +11 -16
- 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/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 +8 -0
- package/dest/msg_validators/tx_validator/size_validator.d.ts.map +1 -0
- package/dest/msg_validators/tx_validator/size_validator.js +23 -0
- package/dest/msg_validators/tx_validator/timestamp_validator.d.ts +3 -2
- package/dest/msg_validators/tx_validator/timestamp_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/timestamp_validator.js +2 -2
- 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 +13 -1
- package/dest/services/dummy_service.d.ts.map +1 -1
- package/dest/services/dummy_service.js +39 -0
- package/dest/services/encoding.d.ts +1 -1
- package/dest/services/encoding.d.ts.map +1 -1
- package/dest/services/encoding.js +2 -3
- 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 +19 -8
- package/dest/services/libp2p/libp2p_service.d.ts +15 -9
- package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
- package/dest/services/libp2p/libp2p_service.js +63 -58
- 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 +8 -2
- package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts +47 -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 +566 -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 +50 -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 +37 -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 +151 -0
- package/dest/services/reqresp/batch-tx-requester/peer_collection.d.ts +54 -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 +139 -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/constants.d.ts +12 -0
- package/dest/services/reqresp/constants.d.ts.map +1 -0
- package/dest/services/reqresp/constants.js +7 -0
- package/dest/services/reqresp/interface.d.ts +3 -1
- package/dest/services/reqresp/interface.d.ts.map +1 -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 +12 -0
- package/dest/services/reqresp/protocols/block_txs/block_txs_handler.d.ts +6 -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 +23 -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 +44 -13
- package/dest/services/reqresp/protocols/status.d.ts +1 -1
- package/dest/services/reqresp/protocols/status.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/status.js +2 -1
- 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 +58 -22
- package/dest/services/service.d.ts +4 -1
- package/dest/services/service.d.ts.map +1 -1
- package/dest/services/tx_collection/config.d.ts +4 -1
- package/dest/services/tx_collection/config.d.ts.map +1 -1
- package/dest/services/tx_collection/config.js +9 -1
- package/dest/services/tx_collection/fast_tx_collection.d.ts +5 -4
- package/dest/services/tx_collection/fast_tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/fast_tx_collection.js +17 -10
- package/dest/services/tx_collection/index.d.ts +2 -1
- 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 +9 -2
- package/dest/services/tx_collection/proposal_tx_collector.d.ts +48 -0
- package/dest/services/tx_collection/proposal_tx_collector.d.ts.map +1 -0
- package/dest/services/tx_collection/proposal_tx_collector.js +49 -0
- package/dest/services/tx_collection/slow_tx_collection.d.ts +3 -3
- package/dest/services/tx_collection/slow_tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/tx_collection.d.ts +8 -8
- package/dest/services/tx_collection/tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/tx_collection.js +5 -5
- package/dest/services/tx_file_store/config.d.ts +18 -0
- package/dest/services/tx_file_store/config.d.ts.map +1 -0
- package/dest/services/tx_file_store/config.js +26 -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 +47 -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 +149 -0
- package/dest/services/tx_provider.d.ts +3 -3
- package/dest/services/tx_provider.d.ts.map +1 -1
- 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/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 +158 -0
- package/dest/test-helpers/testbench-utils.d.ts.map +1 -0
- package/dest/test-helpers/testbench-utils.js +297 -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 +212 -132
- 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/package.json +16 -16
- package/src/bootstrap/bootstrap.ts +7 -4
- package/src/client/factory.ts +10 -10
- package/src/client/p2p_client.ts +20 -8
- package/src/client/test/tx_proposal_collector/README.md +227 -0
- package/src/client/test/tx_proposal_collector/proposal_tx_collector_worker.ts +336 -0
- package/src/client/test/tx_proposal_collector/proposal_tx_collector_worker_protocol.ts +43 -0
- package/src/config.ts +15 -3
- package/src/mem_pools/attestation_pool/attestation_pool_test_suite.ts +17 -9
- package/src/mem_pools/attestation_pool/mocks.ts +6 -4
- package/src/mem_pools/instrumentation.ts +2 -1
- package/src/mem_pools/tx_pool/README.md +28 -13
- package/src/mem_pools/tx_pool/aztec_kv_tx_pool.ts +130 -75
- package/src/mem_pools/tx_pool/eviction/eviction_manager.ts +66 -5
- package/src/mem_pools/tx_pool/eviction/eviction_strategy.ts +119 -4
- package/src/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.ts +162 -0
- package/src/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.ts +4 -2
- package/src/mem_pools/tx_pool/eviction/nullifier_conflict_pre_add_rule.ts +75 -0
- package/src/mem_pools/tx_pool_v2/README.md +209 -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/eviction/eviction_manager.ts +147 -0
- package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.ts +118 -0
- package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.ts +111 -0
- package/src/mem_pools/tx_pool_v2/eviction/index.ts +23 -0
- package/src/mem_pools/tx_pool_v2/eviction/interfaces.ts +164 -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 +86 -0
- package/src/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.ts +72 -0
- package/src/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.ts +31 -0
- package/src/mem_pools/tx_pool_v2/index.ts +11 -0
- package/src/mem_pools/tx_pool_v2/interfaces.ts +227 -0
- package/src/mem_pools/tx_pool_v2/tx_metadata.ts +161 -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 +417 -0
- package/src/mem_pools/tx_pool_v2/tx_pool_v2.ts +212 -0
- package/src/mem_pools/tx_pool_v2/tx_pool_v2_impl.ts +882 -0
- package/src/msg_validators/attestation_validator/attestation_validator.ts +26 -14
- package/src/msg_validators/attestation_validator/fisherman_attestation_validator.ts +14 -8
- package/src/msg_validators/clock_tolerance.ts +51 -0
- package/src/msg_validators/proposal_validator/proposal_validator.ts +31 -31
- package/src/msg_validators/proposal_validator/proposal_validator_test_suite.ts +91 -67
- package/src/msg_validators/tx_validator/archive_cache.ts +3 -3
- package/src/msg_validators/tx_validator/block_header_validator.ts +6 -5
- package/src/msg_validators/tx_validator/data_validator.ts +6 -2
- package/src/msg_validators/tx_validator/double_spend_validator.ts +4 -3
- package/src/msg_validators/tx_validator/factory.ts +64 -23
- package/src/msg_validators/tx_validator/fee_payer_balance.ts +40 -0
- package/src/msg_validators/tx_validator/gas_validator.ts +17 -28
- 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/phases_validator.ts +5 -3
- package/src/msg_validators/tx_validator/size_validator.ts +22 -0
- package/src/msg_validators/tx_validator/timestamp_validator.ts +6 -3
- 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 +45 -0
- package/src/services/encoding.ts +2 -3
- package/src/services/index.ts +1 -0
- package/src/services/libp2p/instrumentation.ts +20 -7
- package/src/services/libp2p/libp2p_service.ts +108 -78
- package/src/services/peer-manager/metrics.ts +21 -4
- package/src/services/peer-manager/peer_scoring.ts +4 -1
- package/src/services/reqresp/batch-tx-requester/README.md +305 -0
- package/src/services/reqresp/batch-tx-requester/batch_tx_requester.ts +706 -0
- package/src/services/reqresp/batch-tx-requester/config.ts +40 -0
- package/src/services/reqresp/batch-tx-requester/interface.ts +57 -0
- package/src/services/reqresp/batch-tx-requester/missing_txs.ts +209 -0
- package/src/services/reqresp/batch-tx-requester/peer_collection.ts +205 -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/constants.ts +14 -0
- package/src/services/reqresp/interface.ts +3 -0
- package/src/services/reqresp/metrics.ts +34 -9
- package/src/services/reqresp/protocols/block_txs/bitvector.ts +16 -0
- package/src/services/reqresp/protocols/block_txs/block_txs_handler.ts +34 -12
- package/src/services/reqresp/protocols/block_txs/block_txs_reqresp.ts +57 -9
- package/src/services/reqresp/protocols/status.ts +5 -3
- package/src/services/reqresp/reqresp.ts +66 -19
- package/src/services/service.ts +4 -0
- package/src/services/tx_collection/config.ts +15 -1
- package/src/services/tx_collection/fast_tx_collection.ts +30 -17
- package/src/services/tx_collection/index.ts +5 -0
- package/src/services/tx_collection/instrumentation.ts +11 -2
- package/src/services/tx_collection/proposal_tx_collector.ts +112 -0
- package/src/services/tx_collection/slow_tx_collection.ts +2 -2
- package/src/services/tx_collection/tx_collection.ts +8 -8
- package/src/services/tx_file_store/config.ts +43 -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 +173 -0
- package/src/services/tx_provider.ts +2 -2
- package/src/services/tx_provider_instrumentation.ts +11 -5
- package/src/test-helpers/index.ts +2 -0
- package/src/test-helpers/test_tx_provider.ts +64 -0
- package/src/test-helpers/testbench-utils.ts +374 -0
- package/src/testbench/p2p_client_testbench_worker.ts +321 -126
- package/src/testbench/worker_client_manager.ts +304 -47
- package/dest/mem_pools/tx_pool/eviction/insufficient_fee_payer_balance_rule.d.ts +0 -15
- package/dest/mem_pools/tx_pool/eviction/insufficient_fee_payer_balance_rule.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/eviction/insufficient_fee_payer_balance_rule.js +0 -88
- package/src/mem_pools/tx_pool/eviction/insufficient_fee_payer_balance_rule.ts +0 -108
|
@@ -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
|
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
|
|
2
2
|
|
|
3
|
+
import { MAX_TXS_PER_BLOCK } from '../../constants.js';
|
|
4
|
+
|
|
3
5
|
/**
|
|
4
6
|
* BitVector helper class for representing and serializing bit vectors
|
|
5
7
|
*/
|
|
@@ -62,6 +64,13 @@ export class BitVector {
|
|
|
62
64
|
return Array.from({ length: this.length }, (_, i) => i).filter(i => this.isSet(i));
|
|
63
65
|
}
|
|
64
66
|
|
|
67
|
+
/**
|
|
68
|
+
* Returns true if no indices are set to true
|
|
69
|
+
* */
|
|
70
|
+
isEmpty(): boolean {
|
|
71
|
+
return this.getTrueIndices().length === 0;
|
|
72
|
+
}
|
|
73
|
+
|
|
65
74
|
/**
|
|
66
75
|
* Serializes the BitVector object into a Buffer
|
|
67
76
|
*
|
|
@@ -80,6 +89,13 @@ export class BitVector {
|
|
|
80
89
|
const reader = BufferReader.asReader(buffer);
|
|
81
90
|
const length = reader.readNumber();
|
|
82
91
|
|
|
92
|
+
if (length < 0) {
|
|
93
|
+
throw new Error(`BitVector length ${length} cannot be negative`);
|
|
94
|
+
}
|
|
95
|
+
if (length > MAX_TXS_PER_BLOCK) {
|
|
96
|
+
throw new Error(`BitVector length ${length} exceeds maximum ${MAX_TXS_PER_BLOCK}`);
|
|
97
|
+
}
|
|
98
|
+
|
|
83
99
|
const bitBuffer = reader.readBytes(BitVector.byteLength(length));
|
|
84
100
|
return new BitVector(bitBuffer, length);
|
|
85
101
|
}
|
|
@@ -1,9 +1,10 @@
|
|
|
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 { AttestationPool } from '../../../../mem_pools/
|
|
6
|
-
import type { TxPool } from '../../../../mem_pools/index.js';
|
|
7
|
+
import type { AttestationPool, TxPool } from '../../../../mem_pools/index.js';
|
|
7
8
|
import type { ReqRespSubProtocolHandler } from '../../interface.js';
|
|
8
9
|
import { ReqRespStatus, ReqRespStatusError } from '../../status.js';
|
|
9
10
|
import { BitVector } from './bitvector.js';
|
|
@@ -12,10 +13,15 @@ import { BlockTxsRequest, BlockTxsResponse } from './block_txs_reqresp.js';
|
|
|
12
13
|
/**
|
|
13
14
|
* Handler for block txs requests
|
|
14
15
|
* @param attestationPool - the attestation pool to check for block proposals
|
|
15
|
-
* @param
|
|
16
|
+
* @param archiver - the archiver to look up blocks by archive root
|
|
17
|
+
* @param txPool - the tx pool to fetch transactions from
|
|
16
18
|
* @returns the BlockTxs request handler
|
|
17
19
|
*/
|
|
18
|
-
export function reqRespBlockTxsHandler(
|
|
20
|
+
export function reqRespBlockTxsHandler(
|
|
21
|
+
attestationPool: AttestationPool,
|
|
22
|
+
archiver: L2BlockSource,
|
|
23
|
+
txPool: TxPool,
|
|
24
|
+
): ReqRespSubProtocolHandler {
|
|
19
25
|
/**
|
|
20
26
|
* Handler for block txs requests
|
|
21
27
|
* @param msg - the block txs request message
|
|
@@ -29,24 +35,40 @@ export function reqRespBlockTxsHandler(attestationPool: AttestationPool, txPool:
|
|
|
29
35
|
} catch (err: any) {
|
|
30
36
|
throw new ReqRespStatusError(ReqRespStatus.BADLY_FORMED_REQUEST, { cause: err });
|
|
31
37
|
}
|
|
38
|
+
// First try attestation pool, then fall back to archiver
|
|
39
|
+
let txHashes = (await attestationPool.getBlockProposal(request.archiveRoot.toString()))?.txHashes;
|
|
40
|
+
if (!txHashes) {
|
|
41
|
+
txHashes = (await archiver.getL2BlockByArchive(request.archiveRoot))?.body.txEffects.map(effect => effect.txHash);
|
|
42
|
+
}
|
|
32
43
|
|
|
33
|
-
|
|
44
|
+
let requestedTxsHashes;
|
|
45
|
+
if (request.txHashes.length > 0) {
|
|
46
|
+
requestedTxsHashes = request.txHashes;
|
|
47
|
+
}
|
|
34
48
|
|
|
35
|
-
|
|
49
|
+
// This is scenario in which we don't have this block the peer is requesting from us
|
|
50
|
+
// But peer has sent requested tx hashes, so we can send them the transactions
|
|
51
|
+
if (!txHashes && requestedTxsHashes !== undefined) {
|
|
52
|
+
const responseTxs = (await txPool.getTxsByHash(requestedTxsHashes)).filter(tx => !!tx);
|
|
53
|
+
const response = new BlockTxsResponse(Fr.zero(), new TxArray(...responseTxs), BitVector.init(0, []));
|
|
54
|
+
return response.toBuffer();
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// If we don't have this block and peer has not sent requested tx hashes
|
|
58
|
+
if (!txHashes) {
|
|
36
59
|
throw new ReqRespStatusError(ReqRespStatus.NOT_FOUND);
|
|
37
60
|
}
|
|
38
61
|
|
|
39
|
-
const txsAvailableInPool = await txPool.hasTxs(
|
|
40
|
-
//Map txs in the pool to their indices in the block
|
|
62
|
+
const txsAvailableInPool = await txPool.hasTxs(txHashes);
|
|
63
|
+
// Map txs in the pool to their indices in the block
|
|
41
64
|
const availableIndices = txsAvailableInPool.map((hasTx, idx) => (hasTx ? idx : -1)).filter(idx => idx !== -1);
|
|
42
|
-
const responseBitVector = BitVector.init(
|
|
65
|
+
const responseBitVector = BitVector.init(txHashes.length, availableIndices);
|
|
43
66
|
|
|
44
67
|
const requestedIndices = new Set(request.txIndices.getTrueIndices());
|
|
45
|
-
|
|
68
|
+
requestedTxsHashes = txHashes.filter((_, idx) => requestedIndices.has(idx));
|
|
46
69
|
|
|
47
70
|
const responseTxs = (await txPool.getTxsByHash(requestedTxsHashes)).filter(tx => !!tx);
|
|
48
|
-
|
|
49
|
-
const response = new BlockTxsResponse(request.blockHash, new TxArray(...responseTxs), responseBitVector);
|
|
71
|
+
const response = new BlockTxsResponse(request.archiveRoot, new TxArray(...responseTxs), responseBitVector);
|
|
50
72
|
|
|
51
73
|
return response.toBuffer();
|
|
52
74
|
};
|
|
@@ -1,20 +1,67 @@
|
|
|
1
1
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
2
|
import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
|
|
3
|
-
import { TxArray } from '@aztec/stdlib/tx';
|
|
3
|
+
import { TxArray, type TxHash, TxHashArray } from '@aztec/stdlib/tx';
|
|
4
4
|
|
|
5
5
|
import { BitVector } from './bitvector.js';
|
|
6
6
|
|
|
7
|
+
/** Minimal interface for a block source that provides tx hashes and an archive root. */
|
|
8
|
+
export interface BlockTxsSource {
|
|
9
|
+
txHashes: TxHash[];
|
|
10
|
+
archive: Fr;
|
|
11
|
+
}
|
|
12
|
+
|
|
7
13
|
/**
|
|
8
14
|
* Request message for requesting specific transactions from a block
|
|
9
15
|
*/
|
|
10
16
|
export class BlockTxsRequest {
|
|
11
17
|
constructor(
|
|
12
|
-
|
|
18
|
+
// Archive root after the proposed block is applied (proposal identifier)
|
|
19
|
+
readonly archiveRoot: Fr,
|
|
20
|
+
// Hashes of txs we are requesting
|
|
21
|
+
readonly txHashes: TxHashArray,
|
|
13
22
|
// BitVector indicating which txs from the proposal we are requesting
|
|
14
23
|
// 1 means we want the tx, 0 means we don't
|
|
24
|
+
// If we know peer has the Block Proposal then we can use this BitVector
|
|
25
|
+
// Otherwise we can use this optimization
|
|
15
26
|
readonly txIndices: BitVector,
|
|
16
27
|
) {}
|
|
17
28
|
|
|
29
|
+
/**
|
|
30
|
+
* Creates new BlockTxsRequest given a block txs source and missing tx hashes.
|
|
31
|
+
*
|
|
32
|
+
* @param blockTxsSource - The block or proposal for which we are making the request
|
|
33
|
+
* @param missingTxHashes - Tx hashes from the source we are missing
|
|
34
|
+
* @param includeFullTxHashes - Whether to include full list of missing tx hashes in the request or just Bitvector indices
|
|
35
|
+
*
|
|
36
|
+
* @returns undefined if there were no missingTxHashes matching the source hashes, otherwise
|
|
37
|
+
* returns new BlockTxsRequest
|
|
38
|
+
*/
|
|
39
|
+
static fromTxsSourceAndMissingTxs(
|
|
40
|
+
blockTxsSource: BlockTxsSource,
|
|
41
|
+
missingTxHashes: TxHash[],
|
|
42
|
+
includeFullTxHashes = false,
|
|
43
|
+
): BlockTxsRequest | undefined {
|
|
44
|
+
if (missingTxHashes.length === 0) {
|
|
45
|
+
return undefined; // No missing txs to request
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const missingHashesSet = new Set(missingTxHashes.map(t => t.toString()));
|
|
49
|
+
|
|
50
|
+
// We cannot request txs that are not part of the block
|
|
51
|
+
if (!missingHashesSet.isSubsetOf(new Set(blockTxsSource.txHashes.map(t => t.toString())))) {
|
|
52
|
+
return undefined;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const missingIndices = blockTxsSource.txHashes
|
|
56
|
+
.map((hash, idx) => (missingHashesSet.has(hash.toString()) ? idx : -1))
|
|
57
|
+
.filter(i => i != -1);
|
|
58
|
+
|
|
59
|
+
const requestBitVector = BitVector.init(blockTxsSource.txHashes.length, missingIndices);
|
|
60
|
+
const hashes = includeFullTxHashes ? new TxHashArray(...missingTxHashes) : new TxHashArray();
|
|
61
|
+
|
|
62
|
+
return new BlockTxsRequest(blockTxsSource.archive, hashes, requestBitVector);
|
|
63
|
+
}
|
|
64
|
+
|
|
18
65
|
/**
|
|
19
66
|
* Deserializes the BlockTxRequest object from a Buffer
|
|
20
67
|
* @param buffer - Buffer or BufferReader object to deserialize
|
|
@@ -22,10 +69,11 @@ export class BlockTxsRequest {
|
|
|
22
69
|
*/
|
|
23
70
|
static fromBuffer(buffer: Buffer | BufferReader): BlockTxsRequest {
|
|
24
71
|
const reader = BufferReader.asReader(buffer);
|
|
25
|
-
const
|
|
72
|
+
const archiveRoot = Fr.fromBuffer(reader);
|
|
73
|
+
const txHashes = TxHashArray.fromBuffer(reader);
|
|
26
74
|
const txIndices = BitVector.fromBuffer(reader);
|
|
27
75
|
|
|
28
|
-
return new BlockTxsRequest(
|
|
76
|
+
return new BlockTxsRequest(archiveRoot, txHashes, txIndices);
|
|
29
77
|
}
|
|
30
78
|
|
|
31
79
|
/**
|
|
@@ -33,7 +81,7 @@ export class BlockTxsRequest {
|
|
|
33
81
|
* @returns Buffer representation of the BlockTxRequest object
|
|
34
82
|
*/
|
|
35
83
|
toBuffer(): Buffer {
|
|
36
|
-
return serializeToBuffer([this.
|
|
84
|
+
return serializeToBuffer([this.archiveRoot, this.txHashes.toBuffer(), this.txIndices.toBuffer()]);
|
|
37
85
|
}
|
|
38
86
|
}
|
|
39
87
|
|
|
@@ -42,7 +90,7 @@ export class BlockTxsRequest {
|
|
|
42
90
|
*/
|
|
43
91
|
export class BlockTxsResponse {
|
|
44
92
|
constructor(
|
|
45
|
-
readonly
|
|
93
|
+
readonly archiveRoot: Fr,
|
|
46
94
|
readonly txs: TxArray, // List of transactions we requested and peer has
|
|
47
95
|
// BitVector indicating which txs from the proposal are available at the peer
|
|
48
96
|
// 1 means the tx is available, 0 means it is not
|
|
@@ -56,11 +104,11 @@ export class BlockTxsResponse {
|
|
|
56
104
|
*/
|
|
57
105
|
static fromBuffer(buffer: Buffer | BufferReader): BlockTxsResponse {
|
|
58
106
|
const reader = BufferReader.asReader(buffer);
|
|
59
|
-
const
|
|
107
|
+
const archiveRoot = Fr.fromBuffer(reader);
|
|
60
108
|
const txs = TxArray.fromBuffer(reader);
|
|
61
109
|
const txIndices = BitVector.fromBuffer(reader);
|
|
62
110
|
|
|
63
|
-
return new BlockTxsResponse(
|
|
111
|
+
return new BlockTxsResponse(archiveRoot, txs, txIndices);
|
|
64
112
|
}
|
|
65
113
|
|
|
66
114
|
/**
|
|
@@ -70,7 +118,7 @@ export class BlockTxsResponse {
|
|
|
70
118
|
* @returns Buffer representation of the BlockTxResponse object
|
|
71
119
|
*/
|
|
72
120
|
toBuffer(): Buffer {
|
|
73
|
-
return serializeToBuffer([this.
|
|
121
|
+
return serializeToBuffer([this.archiveRoot, this.txs.toBuffer(), this.txIndices.toBuffer()]);
|
|
74
122
|
}
|
|
75
123
|
|
|
76
124
|
static empty(): BlockTxsResponse {
|
|
@@ -7,6 +7,8 @@ import type { WorldStateSyncStatus, WorldStateSynchronizer } from '@aztec/stdlib
|
|
|
7
7
|
|
|
8
8
|
import type { PeerId } from '@libp2p/interface';
|
|
9
9
|
|
|
10
|
+
import { MAX_BLOCK_HASH_STRING_LENGTH, MAX_VERSION_STRING_LENGTH } from '../constants.js';
|
|
11
|
+
|
|
10
12
|
/*
|
|
11
13
|
* P2P Status Message
|
|
12
14
|
* It is used to establish Status handshake between to peers
|
|
@@ -32,12 +34,12 @@ export class StatusMessage {
|
|
|
32
34
|
static fromBuffer(buffer: Buffer | BufferReader): StatusMessage {
|
|
33
35
|
const reader = BufferReader.asReader(buffer);
|
|
34
36
|
return new StatusMessage(
|
|
35
|
-
reader.readString(), // compressedComponentsVersion
|
|
37
|
+
reader.readString(MAX_VERSION_STRING_LENGTH), // compressedComponentsVersion
|
|
36
38
|
BlockNumber(reader.readNumber()), // latestBlockNumber
|
|
37
|
-
reader.readString(), // latestBlockHash
|
|
39
|
+
reader.readString(MAX_BLOCK_HASH_STRING_LENGTH), // latestBlockHash
|
|
38
40
|
BlockNumber(reader.readNumber()), // finalizedBlockNumber
|
|
39
41
|
//TODO: add finalizedBlockHash
|
|
40
|
-
//reader.readString(), // finalizedBlockHash
|
|
42
|
+
//reader.readString(MAX_BLOCK_HASH_STRING_LENGTH), // finalizedBlockHash
|
|
41
43
|
);
|
|
42
44
|
}
|
|
43
45
|
|
|
@@ -111,6 +111,13 @@ export class ReqResp implements ReqRespInterface {
|
|
|
111
111
|
return this.metrics.tracer;
|
|
112
112
|
}
|
|
113
113
|
|
|
114
|
+
/**
|
|
115
|
+
* Get the connection sampler instance
|
|
116
|
+
*/
|
|
117
|
+
getConnectionSampler(): Pick<ConnectionSampler, 'getPeerListSortedByConnectionCountAsc'> {
|
|
118
|
+
return this.connectionSampler;
|
|
119
|
+
}
|
|
120
|
+
|
|
114
121
|
/**
|
|
115
122
|
* Start the reqresp service
|
|
116
123
|
*/
|
|
@@ -212,6 +219,14 @@ export class ReqResp implements ReqRespInterface {
|
|
|
212
219
|
const responseValidator = this.subProtocolValidators[subProtocol] ?? DEFAULT_SUB_PROTOCOL_VALIDATORS[subProtocol];
|
|
213
220
|
const responses: InstanceType<SubProtocolMap[SubProtocol]['response']>[] = new Array(requests.length);
|
|
214
221
|
const requestBuffers = requests.map(req => req.toBuffer());
|
|
222
|
+
const isEmptyResponse = (value: unknown): boolean => {
|
|
223
|
+
// Some responses serialize to a non-empty buffer even when they contain no items (e.g., empty TxArray).
|
|
224
|
+
if (!value || typeof value !== 'object') {
|
|
225
|
+
return false;
|
|
226
|
+
}
|
|
227
|
+
const length = (value as { length?: number }).length;
|
|
228
|
+
return typeof length === 'number' && length === 0;
|
|
229
|
+
};
|
|
215
230
|
|
|
216
231
|
const requestFunction = async (signal: AbortSignal) => {
|
|
217
232
|
// Track which requests still need to be processed
|
|
@@ -252,7 +267,9 @@ export class ReqResp implements ReqRespInterface {
|
|
|
252
267
|
for (const requestIndex of pendingRequestIndices) {
|
|
253
268
|
const peer = batchSampler.getPeerForRequest(requestIndex);
|
|
254
269
|
if (!peer) {
|
|
255
|
-
|
|
270
|
+
// No peer available for this specific index (all peers exhausted for it)
|
|
271
|
+
// Skip this index for now - it stays in pendingRequestIndices for retry
|
|
272
|
+
continue;
|
|
256
273
|
}
|
|
257
274
|
const peerAsString = peer.toString();
|
|
258
275
|
if (!requestBatches.has(peerAsString)) {
|
|
@@ -271,6 +288,12 @@ export class ReqResp implements ReqRespInterface {
|
|
|
271
288
|
});
|
|
272
289
|
}
|
|
273
290
|
|
|
291
|
+
// If no requests could be assigned (all peers exhausted for all indices), exit early
|
|
292
|
+
if (requestBatches.size === 0) {
|
|
293
|
+
this.logger.warn('No peers available for any pending request indices, stopping batch request');
|
|
294
|
+
break;
|
|
295
|
+
}
|
|
296
|
+
|
|
274
297
|
// Make parallel requests for each peer's batch
|
|
275
298
|
// A batch entry will look something like this:
|
|
276
299
|
// PeerId0: [0, 1, 2, 3]
|
|
@@ -282,38 +305,61 @@ export class ReqResp implements ReqRespInterface {
|
|
|
282
305
|
const batchResults = await Promise.all(
|
|
283
306
|
Array.from(requestBatches.entries()).map(async ([peerAsString, { peerId: peer, indices }]) => {
|
|
284
307
|
try {
|
|
308
|
+
const markIndexFailed = (index: number) => batchSampler.markPeerFailedForIndex(peer, index);
|
|
285
309
|
// Requests all going to the same peer are sent synchronously
|
|
286
310
|
const peerResults: { index: number; response: InstanceType<SubProtocolMap[SubProtocol]['response']> }[] =
|
|
287
311
|
[];
|
|
312
|
+
let shouldReplacePeer = false;
|
|
313
|
+
const handleFailure = (status: ReqRespStatus, index: number) => {
|
|
314
|
+
this.logger.warn(
|
|
315
|
+
`Request to peer ${peerAsString} failed with status ${prettyPrintReqRespStatus(status)}`,
|
|
316
|
+
);
|
|
317
|
+
markIndexFailed(index);
|
|
318
|
+
return status === ReqRespStatus.RATE_LIMIT_EXCEEDED;
|
|
319
|
+
};
|
|
320
|
+
|
|
288
321
|
for (const index of indices) {
|
|
289
|
-
this.logger.
|
|
322
|
+
this.logger.info(`Sending request ${index} to peer ${peerAsString}`);
|
|
290
323
|
const response = await this.sendRequestToPeer(peer, subProtocol, requestBuffers[index]);
|
|
291
324
|
|
|
292
325
|
// Check the status of the response buffer
|
|
293
326
|
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 };
|
|
327
|
+
shouldReplacePeer = handleFailure(response.status, index);
|
|
328
|
+
if (shouldReplacePeer) {
|
|
329
|
+
break;
|
|
330
|
+
}
|
|
331
|
+
continue;
|
|
302
332
|
}
|
|
303
333
|
|
|
304
|
-
if (response
|
|
305
|
-
|
|
306
|
-
|
|
334
|
+
if (response.data.length === 0) {
|
|
335
|
+
markIndexFailed(index);
|
|
336
|
+
continue;
|
|
337
|
+
}
|
|
307
338
|
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
339
|
+
const object = responseFromBuffer(subProtocol, response.data);
|
|
340
|
+
if (isEmptyResponse(object)) {
|
|
341
|
+
markIndexFailed(index);
|
|
342
|
+
continue;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
const isValid = await responseValidator(requests[index], object, peer);
|
|
346
|
+
if (!isValid) {
|
|
347
|
+
markIndexFailed(index);
|
|
348
|
+
continue;
|
|
311
349
|
}
|
|
350
|
+
|
|
351
|
+
peerResults.push({ index, response: object });
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
// If peer had a hard failure (rate limit), replace it for future iterations
|
|
355
|
+
if (shouldReplacePeer) {
|
|
356
|
+
this.logger.warn(`Peer ${peerAsString} hit a hard failure, removing from sampler`);
|
|
357
|
+
batchSampler.removePeerAndReplace(peer);
|
|
312
358
|
}
|
|
313
359
|
|
|
314
360
|
return { peer, results: peerResults };
|
|
315
361
|
} catch (error) {
|
|
316
|
-
this.logger.
|
|
362
|
+
this.logger.warn(`Failed batch request to peer ${peerAsString}:`, error);
|
|
317
363
|
batchSampler.removePeerAndReplace(peer);
|
|
318
364
|
return { peer, results: [] };
|
|
319
365
|
}
|
|
@@ -334,7 +380,7 @@ export class ReqResp implements ReqRespInterface {
|
|
|
334
380
|
}
|
|
335
381
|
|
|
336
382
|
if (retryAttempts >= maxRetryAttempts) {
|
|
337
|
-
this.logger.
|
|
383
|
+
this.logger.warn(`Max retry attempts ${maxRetryAttempts} reached for batch request`);
|
|
338
384
|
}
|
|
339
385
|
|
|
340
386
|
return responses;
|
|
@@ -347,7 +393,7 @@ export class ReqResp implements ReqRespInterface {
|
|
|
347
393
|
() => new CollectiveReqRespTimeoutError(),
|
|
348
394
|
);
|
|
349
395
|
} catch (e: any) {
|
|
350
|
-
this.logger.
|
|
396
|
+
this.logger.warn(`${e.message} | subProtocol: ${subProtocol}`);
|
|
351
397
|
return [];
|
|
352
398
|
}
|
|
353
399
|
}
|
|
@@ -409,6 +455,7 @@ export class ReqResp implements ReqRespInterface {
|
|
|
409
455
|
);
|
|
410
456
|
return resp;
|
|
411
457
|
} catch (e: any) {
|
|
458
|
+
this.logger.warn(`SUBPROTOCOL: ${subProtocol}\n`, e);
|
|
412
459
|
// On error we immediately abort the stream, this is preferred way,
|
|
413
460
|
// because it signals to the sender that error happened, whereas
|
|
414
461
|
// closing the stream only closes our side and is much slower
|
package/src/services/service.ts
CHANGED
|
@@ -7,6 +7,7 @@ import type { PeerId } from '@libp2p/interface';
|
|
|
7
7
|
import type { ENR } from '@nethermindeth/enr';
|
|
8
8
|
import type EventEmitter from 'events';
|
|
9
9
|
|
|
10
|
+
import type { BatchTxRequesterLibP2PService } from './reqresp/batch-tx-requester/interface.js';
|
|
10
11
|
import type { P2PReqRespConfig } from './reqresp/config.js';
|
|
11
12
|
import type { StatusMessage } from './reqresp/index.js';
|
|
12
13
|
import type {
|
|
@@ -103,6 +104,9 @@ export interface P2PService {
|
|
|
103
104
|
|
|
104
105
|
/** If node running this P2P stack is validator, passes in validator address to P2P layer */
|
|
105
106
|
registerThisValidatorAddresses(address: EthAddress[]): void;
|
|
107
|
+
|
|
108
|
+
/** Get BatchTxRequester service dependencies */
|
|
109
|
+
getBatchTxRequesterService(): BatchTxRequesterLibP2PService;
|
|
106
110
|
}
|
|
107
111
|
|
|
108
112
|
/**
|
|
@@ -1,6 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
type ConfigMappingsType,
|
|
3
|
+
booleanConfigHelper,
|
|
4
|
+
enumConfigHelper,
|
|
5
|
+
numberConfigHelper,
|
|
6
|
+
} from '@aztec/foundation/config';
|
|
2
7
|
import { MAX_RPC_TXS_LEN } from '@aztec/stdlib/interfaces/api-limit';
|
|
3
8
|
|
|
9
|
+
export type MissingTxsCollectorType = 'new' | 'old';
|
|
10
|
+
|
|
4
11
|
export type TxCollectionConfig = {
|
|
5
12
|
/** How long to wait before starting reqresp for fast collection */
|
|
6
13
|
txCollectionFastNodesTimeoutBeforeReqRespMs: number;
|
|
@@ -22,6 +29,8 @@ export type TxCollectionConfig = {
|
|
|
22
29
|
txCollectionFastMaxParallelRequestsPerNode: number;
|
|
23
30
|
/** Maximum number of transactions to request from a node in a single batch */
|
|
24
31
|
txCollectionNodeRpcMaxBatchSize: number;
|
|
32
|
+
/** Which collector implementation to use for missing txs collection */
|
|
33
|
+
txCollectionMissingTxsCollectorType: MissingTxsCollectorType;
|
|
25
34
|
};
|
|
26
35
|
|
|
27
36
|
export const txCollectionConfigMappings: ConfigMappingsType<TxCollectionConfig> = {
|
|
@@ -81,4 +90,9 @@ export const txCollectionConfigMappings: ConfigMappingsType<TxCollectionConfig>
|
|
|
81
90
|
description: 'Maximum number of transactions to request from a node in a single batch',
|
|
82
91
|
...numberConfigHelper(MAX_RPC_TXS_LEN),
|
|
83
92
|
},
|
|
93
|
+
txCollectionMissingTxsCollectorType: {
|
|
94
|
+
env: 'TX_COLLECTION_MISSING_TXS_COLLECTOR_TYPE',
|
|
95
|
+
description: 'Which collector implementation to use for missing txs collection (new or old)',
|
|
96
|
+
...enumConfigHelper(['new', 'old'] as const, 'new'),
|
|
97
|
+
},
|
|
84
98
|
};
|
|
@@ -2,7 +2,6 @@ import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
|
2
2
|
import { times } from '@aztec/foundation/collection';
|
|
3
3
|
import { AbortError, TimeoutError } from '@aztec/foundation/error';
|
|
4
4
|
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
5
|
-
import { boundInclusive } from '@aztec/foundation/number';
|
|
6
5
|
import { promiseWithResolvers } from '@aztec/foundation/promise';
|
|
7
6
|
import { sleep } from '@aztec/foundation/sleep';
|
|
8
7
|
import { DateProvider, elapsed } from '@aztec/foundation/timer';
|
|
@@ -12,9 +11,14 @@ import { type Tx, TxHash } from '@aztec/stdlib/tx';
|
|
|
12
11
|
|
|
13
12
|
import type { PeerId } from '@libp2p/interface';
|
|
14
13
|
|
|
15
|
-
import
|
|
16
|
-
import {
|
|
14
|
+
import type { BatchTxRequesterConfig } from '../reqresp/batch-tx-requester/config.js';
|
|
15
|
+
import type { BatchTxRequesterLibP2PService } from '../reqresp/batch-tx-requester/interface.js';
|
|
17
16
|
import type { TxCollectionConfig } from './config.js';
|
|
17
|
+
import {
|
|
18
|
+
BatchTxRequesterCollector,
|
|
19
|
+
type MissingTxsCollector,
|
|
20
|
+
SendBatchRequestCollector,
|
|
21
|
+
} from './proposal_tx_collector.js';
|
|
18
22
|
import type { FastCollectionRequest, FastCollectionRequestInput } from './tx_collection.js';
|
|
19
23
|
import type { TxCollectionSink } from './tx_collection_sink.js';
|
|
20
24
|
import type { TxSource } from './tx_source.js';
|
|
@@ -22,15 +26,25 @@ import type { TxSource } from './tx_source.js';
|
|
|
22
26
|
export class FastTxCollection {
|
|
23
27
|
// eslint-disable-next-line aztec-custom/no-non-primitive-in-collections
|
|
24
28
|
protected requests: Set<FastCollectionRequest> = new Set();
|
|
29
|
+
private missingTxsCollector: MissingTxsCollector;
|
|
25
30
|
|
|
26
31
|
constructor(
|
|
27
|
-
|
|
32
|
+
p2pService: BatchTxRequesterLibP2PService,
|
|
28
33
|
private nodes: TxSource[],
|
|
29
34
|
private txCollectionSink: TxCollectionSink,
|
|
30
35
|
private config: TxCollectionConfig,
|
|
31
36
|
private dateProvider: DateProvider = new DateProvider(),
|
|
32
37
|
private log: Logger = createLogger('p2p:tx_collection_service'),
|
|
33
|
-
|
|
38
|
+
missingTxsCollector?: MissingTxsCollector,
|
|
39
|
+
) {
|
|
40
|
+
const batchTxRequesterConfig = this.config as Partial<BatchTxRequesterConfig>;
|
|
41
|
+
const missingTxsCollectorType = this.config.txCollectionMissingTxsCollectorType;
|
|
42
|
+
this.missingTxsCollector =
|
|
43
|
+
missingTxsCollector ??
|
|
44
|
+
(missingTxsCollectorType === 'old'
|
|
45
|
+
? new SendBatchRequestCollector(p2pService)
|
|
46
|
+
: new BatchTxRequesterCollector(p2pService, log, dateProvider, undefined, batchTxRequesterConfig));
|
|
47
|
+
}
|
|
34
48
|
|
|
35
49
|
public async stop() {
|
|
36
50
|
this.requests.forEach(request => request.promise.reject(new AbortError(`Stopped collection service`)));
|
|
@@ -241,8 +255,6 @@ export class FastTxCollection {
|
|
|
241
255
|
private async collectFastViaReqResp(request: FastCollectionRequest, opts: { pinnedPeer?: PeerId }) {
|
|
242
256
|
const timeoutMs = +request.deadline - this.dateProvider.now();
|
|
243
257
|
const pinnedPeer = opts.pinnedPeer;
|
|
244
|
-
const maxPeers = boundInclusive(Math.ceil(request.missingTxHashes.size / 2), 8, 32);
|
|
245
|
-
const maxRetryAttempts = 5;
|
|
246
258
|
const blockInfo = request.blockInfo;
|
|
247
259
|
const slotNumber = blockInfo.slotNumber;
|
|
248
260
|
if (timeoutMs < 100) {
|
|
@@ -261,16 +273,17 @@ export class FastTxCollection {
|
|
|
261
273
|
try {
|
|
262
274
|
await this.txCollectionSink.collect(
|
|
263
275
|
async txHashes => {
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
276
|
+
if (request.type === 'proposal') {
|
|
277
|
+
return await this.missingTxsCollector.collectTxs(txHashes, request.blockProposal, pinnedPeer, timeoutMs);
|
|
278
|
+
} else if (request.type === 'block') {
|
|
279
|
+
const blockTxsSource = {
|
|
280
|
+
txHashes: request.block.body.txEffects.map(e => e.txHash),
|
|
281
|
+
archive: request.block.archive.root,
|
|
282
|
+
};
|
|
283
|
+
return await this.missingTxsCollector.collectTxs(txHashes, blockTxsSource, pinnedPeer, timeoutMs);
|
|
284
|
+
} else {
|
|
285
|
+
throw new Error(`Unknown request type: ${(request as any).type}`);
|
|
286
|
+
}
|
|
274
287
|
},
|
|
275
288
|
Array.from(request.missingTxHashes).map(txHash => TxHash.fromString(txHash)),
|
|
276
289
|
{ description: `reqresp for slot ${slotNumber}`, method: 'fast-req-resp', ...opts, ...request.blockInfo },
|
|
@@ -1,2 +1,7 @@
|
|
|
1
1
|
export { TxCollection, type FastCollectionRequestInput } from './tx_collection.js';
|
|
2
2
|
export { type TxSource, createNodeRpcTxSources, NodeRpcTxSource } from './tx_source.js';
|
|
3
|
+
export {
|
|
4
|
+
type MissingTxsCollector,
|
|
5
|
+
BatchTxRequesterCollector,
|
|
6
|
+
SendBatchRequestCollector,
|
|
7
|
+
} from './proposal_tx_collector.js';
|
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
Attributes,
|
|
3
|
+
type Histogram,
|
|
4
|
+
Metrics,
|
|
5
|
+
type TelemetryClient,
|
|
6
|
+
type UpDownCounter,
|
|
7
|
+
createUpDownCounterWithDefault,
|
|
8
|
+
} from '@aztec/telemetry-client';
|
|
2
9
|
|
|
3
10
|
import type { CollectionMethod } from './tx_collection.js';
|
|
4
11
|
|
|
@@ -10,7 +17,9 @@ export class TxCollectionInstrumentation {
|
|
|
10
17
|
constructor(client: TelemetryClient, name: string) {
|
|
11
18
|
const meter = client.getMeter(name);
|
|
12
19
|
|
|
13
|
-
this.txsCollected = meter
|
|
20
|
+
this.txsCollected = createUpDownCounterWithDefault(meter, Metrics.TX_COLLECTOR_COUNT, {
|
|
21
|
+
[Attributes.TX_COLLECTION_METHOD]: ['fast-req-resp', 'fast-node-rpc', 'slow-req-resp', 'slow-node-rpc'],
|
|
22
|
+
});
|
|
14
23
|
|
|
15
24
|
this.collectionDurationPerTx = meter.createHistogram(Metrics.TX_COLLECTOR_DURATION_PER_TX);
|
|
16
25
|
|