@aztec/p2p 0.0.1-commit.fce3e4f → 0.0.1-commit.ff7989d6c
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 +7 -6
- package/dest/client/factory.d.ts.map +1 -1
- package/dest/client/factory.js +53 -15
- package/dest/client/interface.d.ts +58 -25
- package/dest/client/interface.d.ts.map +1 -1
- package/dest/client/p2p_client.d.ts +51 -56
- package/dest/client/p2p_client.d.ts.map +1 -1
- package/dest/client/p2p_client.js +608 -264
- 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 +38 -13
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +31 -20
- 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 +111 -76
- 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 +529 -289
- 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 +11 -8
- package/dest/mem_pools/attestation_pool/mocks.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/mocks.js +17 -13
- 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 +7 -1
- package/dest/mem_pools/instrumentation.d.ts.map +1 -1
- package/dest/mem_pools/instrumentation.js +31 -13
- package/dest/mem_pools/interface.d.ts +6 -7
- package/dest/mem_pools/interface.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.d.ts +37 -27
- 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 +314 -335
- package/dest/mem_pools/tx_pool/eviction/eviction_manager.d.ts +32 -0
- package/dest/mem_pools/tx_pool/eviction/eviction_manager.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool/eviction/eviction_manager.js +112 -0
- package/dest/mem_pools/tx_pool/eviction/eviction_strategy.d.ts +157 -0
- package/dest/mem_pools/tx_pool/eviction/eviction_strategy.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool/eviction/eviction_strategy.js +52 -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 +17 -0
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.js +84 -0
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.d.ts +19 -0
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.js +78 -0
- package/dest/mem_pools/tx_pool/eviction/low_priority_eviction_rule.d.ts +26 -0
- package/dest/mem_pools/tx_pool/eviction/low_priority_eviction_rule.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool/eviction/low_priority_eviction_rule.js +84 -0
- 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/index.d.ts +1 -2
- package/dest/mem_pools/tx_pool/index.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool/index.js +0 -1
- package/dest/mem_pools/tx_pool/priority.d.ts +5 -1
- package/dest/mem_pools/tx_pool/priority.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool/priority.js +6 -1
- package/dest/mem_pools/tx_pool/tx_pool.d.ts +11 -6
- package/dest/mem_pools/tx_pool/tx_pool.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool/tx_pool_test_suite.d.ts +1 -1
- package/dest/mem_pools/tx_pool/tx_pool_test_suite.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool/tx_pool_test_suite.js +30 -24
- 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 +95 -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 +97 -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 +152 -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 +355 -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 +896 -0
- package/dest/msg_validators/attestation_validator/attestation_validator.d.ts +4 -4
- package/dest/msg_validators/attestation_validator/attestation_validator.d.ts.map +1 -1
- package/dest/msg_validators/attestation_validator/attestation_validator.js +52 -19
- package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.d.ts +7 -7
- package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.d.ts.map +1 -1
- package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.js +22 -13
- 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/index.d.ts +2 -2
- package/dest/msg_validators/index.d.ts.map +1 -1
- package/dest/msg_validators/index.js +1 -1
- package/dest/msg_validators/proposal_validator/block_proposal_validator.d.ts +9 -0
- package/dest/msg_validators/proposal_validator/block_proposal_validator.d.ts.map +1 -0
- package/dest/msg_validators/proposal_validator/block_proposal_validator.js +6 -0
- package/dest/msg_validators/proposal_validator/checkpoint_proposal_validator.d.ts +9 -0
- package/dest/msg_validators/proposal_validator/checkpoint_proposal_validator.d.ts.map +1 -0
- package/dest/msg_validators/proposal_validator/checkpoint_proposal_validator.js +6 -0
- package/dest/msg_validators/proposal_validator/index.d.ts +4 -0
- package/dest/msg_validators/proposal_validator/index.d.ts.map +1 -0
- package/dest/msg_validators/proposal_validator/index.js +3 -0
- package/dest/msg_validators/proposal_validator/proposal_validator.d.ts +13 -0
- package/dest/msg_validators/proposal_validator/proposal_validator.d.ts.map +1 -0
- package/dest/msg_validators/proposal_validator/proposal_validator.js +104 -0
- package/dest/msg_validators/proposal_validator/proposal_validator_test_suite.d.ts +23 -0
- package/dest/msg_validators/proposal_validator/proposal_validator_test_suite.d.ts.map +1 -0
- package/dest/msg_validators/proposal_validator/proposal_validator_test_suite.js +212 -0
- package/dest/msg_validators/tx_validator/aggregate_tx_validator.d.ts +3 -3
- package/dest/msg_validators/tx_validator/aggregate_tx_validator.d.ts.map +1 -1
- 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 +4 -3
- 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 +10 -4
- package/dest/msg_validators/tx_validator/factory.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/factory.js +22 -12
- 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 +4 -3
- 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/test_utils.d.ts +2 -2
- package/dest/msg_validators/tx_validator/test_utils.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/timestamp_validator.d.ts +23 -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 +28 -3
- package/dest/services/dummy_service.d.ts.map +1 -1
- package/dest/services/dummy_service.js +51 -0
- package/dest/services/encoding.d.ts +2 -2
- package/dest/services/encoding.d.ts.map +1 -1
- package/dest/services/encoding.js +10 -8
- 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 +30 -72
- package/dest/services/libp2p/libp2p_service.d.ts +109 -36
- package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
- package/dest/services/libp2p/libp2p_service.js +988 -326
- package/dest/services/peer-manager/metrics.d.ts +7 -2
- package/dest/services/peer-manager/metrics.d.ts.map +1 -1
- package/dest/services/peer-manager/metrics.js +33 -21
- package/dest/services/peer-manager/peer_manager.d.ts +2 -2
- package/dest/services/peer-manager/peer_manager.d.ts.map +1 -1
- package/dest/services/peer-manager/peer_manager.js +4 -12
- 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 +32 -6
- 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 +562 -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 +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 +13 -2
- package/dest/services/reqresp/interface.d.ts.map +1 -1
- package/dest/services/reqresp/interface.js +16 -2
- 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 -21
- package/dest/services/reqresp/protocols/auth.d.ts +2 -2
- package/dest/services/reqresp/protocols/auth.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/auth.js +2 -2
- package/dest/services/reqresp/protocols/block.d.ts +1 -1
- package/dest/services/reqresp/protocols/block.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/block.js +3 -2
- 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 +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 +30 -7
- package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.js +60 -14
- package/dest/services/reqresp/protocols/status.d.ts +5 -4
- package/dest/services/reqresp/protocols/status.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/status.js +7 -3
- package/dest/services/reqresp/protocols/tx.d.ts +8 -3
- 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 +471 -50
- package/dest/services/service.d.ts +55 -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 +56 -2
- package/dest/services/tx_collection/fast_tx_collection.d.ts +10 -6
- 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 +11 -13
- 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 +9 -4
- 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 +31 -17
- 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 +6 -4
- package/dest/services/tx_provider.d.ts.map +1 -1
- package/dest/services/tx_provider.js +16 -6
- package/dest/services/tx_provider_instrumentation.d.ts +5 -2
- package/dest/services/tx_provider_instrumentation.d.ts.map +1 -1
- package/dest/services/tx_provider_instrumentation.js +14 -14
- 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 +3 -3
- package/dest/test-helpers/make-test-p2p-clients.d.ts.map +1 -1
- package/dest/test-helpers/mock-pubsub.d.ts +29 -2
- package/dest/test-helpers/mock-pubsub.d.ts.map +1 -1
- package/dest/test-helpers/mock-pubsub.js +103 -2
- package/dest/test-helpers/mock-tx-helpers.js +1 -1
- package/dest/test-helpers/reqresp-nodes.d.ts +2 -2
- package/dest/test-helpers/reqresp-nodes.d.ts.map +1 -1
- package/dest/test-helpers/reqresp-nodes.js +2 -1
- 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 +221 -126
- 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 -39
- package/dest/util.d.ts +2 -2
- package/dest/util.d.ts.map +1 -1
- package/package.json +18 -18
- package/src/bootstrap/bootstrap.ts +7 -4
- package/src/client/factory.ts +98 -31
- package/src/client/interface.ts +76 -25
- package/src/client/p2p_client.ts +283 -307
- package/src/client/test/tx_proposal_collector/README.md +227 -0
- package/src/client/test/tx_proposal_collector/proposal_tx_collector_worker.ts +346 -0
- package/src/client/test/tx_proposal_collector/proposal_tx_collector_worker_protocol.ts +43 -0
- package/src/config.ts +59 -29
- package/src/errors/tx-pool.error.ts +12 -0
- package/src/index.ts +1 -0
- package/src/mem_pools/attestation_pool/attestation_pool.ts +510 -78
- package/src/mem_pools/attestation_pool/attestation_pool_test_suite.ts +614 -322
- package/src/mem_pools/attestation_pool/index.ts +9 -2
- package/src/mem_pools/attestation_pool/mocks.ts +22 -15
- package/src/mem_pools/index.ts +4 -1
- package/src/mem_pools/instrumentation.ts +39 -14
- package/src/mem_pools/interface.ts +5 -7
- package/src/mem_pools/tx_pool/README.md +270 -0
- package/src/mem_pools/tx_pool/aztec_kv_tx_pool.ts +367 -371
- package/src/mem_pools/tx_pool/eviction/eviction_manager.ts +132 -0
- package/src/mem_pools/tx_pool/eviction/eviction_strategy.ts +208 -0
- 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_mining_rule.ts +104 -0
- package/src/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.ts +93 -0
- package/src/mem_pools/tx_pool/eviction/low_priority_eviction_rule.ts +106 -0
- package/src/mem_pools/tx_pool/eviction/nullifier_conflict_pre_add_rule.ts +75 -0
- package/src/mem_pools/tx_pool/index.ts +0 -1
- package/src/mem_pools/tx_pool/priority.ts +8 -1
- package/src/mem_pools/tx_pool/tx_pool.ts +11 -5
- package/src/mem_pools/tx_pool/tx_pool_test_suite.ts +23 -17
- 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 +122 -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 +242 -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 +1069 -0
- package/src/msg_validators/attestation_validator/attestation_validator.ts +37 -22
- package/src/msg_validators/attestation_validator/fisherman_attestation_validator.ts +21 -18
- package/src/msg_validators/clock_tolerance.ts +51 -0
- package/src/msg_validators/index.ts +1 -1
- package/src/msg_validators/proposal_validator/block_proposal_validator.ts +10 -0
- package/src/msg_validators/proposal_validator/checkpoint_proposal_validator.ts +13 -0
- package/src/msg_validators/proposal_validator/index.ts +3 -0
- package/src/msg_validators/proposal_validator/proposal_validator.ts +92 -0
- package/src/msg_validators/proposal_validator/proposal_validator_test_suite.ts +230 -0
- package/src/msg_validators/tx_validator/aggregate_tx_validator.ts +2 -2
- package/src/msg_validators/tx_validator/archive_cache.ts +3 -3
- package/src/msg_validators/tx_validator/block_header_validator.ts +21 -8
- package/src/msg_validators/tx_validator/data_validator.ts +18 -6
- package/src/msg_validators/tx_validator/double_spend_validator.ts +15 -9
- package/src/msg_validators/tx_validator/factory.ts +67 -25
- 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 +19 -8
- 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/test_utils.ts +1 -1
- package/src/msg_validators/tx_validator/timestamp_validator.ts +30 -19
- 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 +68 -1
- package/src/services/encoding.ts +9 -7
- 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 +32 -73
- package/src/services/libp2p/libp2p_service.ts +661 -316
- package/src/services/peer-manager/metrics.ts +39 -21
- package/src/services/peer-manager/peer_manager.ts +5 -4
- package/src/services/peer-manager/peer_scoring.ts +28 -4
- 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 +53 -0
- package/src/services/reqresp/batch-tx-requester/missing_txs.ts +161 -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 +19 -1
- package/src/services/reqresp/constants.ts +14 -0
- package/src/services/reqresp/interface.ts +30 -2
- package/src/services/reqresp/metrics.ts +36 -27
- package/src/services/reqresp/protocols/auth.ts +2 -2
- package/src/services/reqresp/protocols/block.ts +3 -2
- package/src/services/reqresp/protocols/block_txs/bitvector.ts +16 -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 +75 -10
- package/src/services/reqresp/protocols/status.ts +16 -12
- package/src/services/reqresp/protocols/tx.ts +23 -2
- package/src/services/reqresp/reqresp.ts +79 -22
- package/src/services/service.ts +72 -4
- package/src/services/tx_collection/config.ts +84 -2
- package/src/services/tx_collection/fast_tx_collection.ts +96 -49
- 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 +11 -13
- 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 +69 -36
- package/src/services/tx_collection/tx_collection.ts +122 -24
- 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 +27 -10
- package/src/services/tx_provider_instrumentation.ts +24 -14
- package/src/test-helpers/index.ts +2 -0
- package/src/test-helpers/make-test-p2p-clients.ts +3 -3
- package/src/test-helpers/mock-pubsub.ts +144 -4
- package/src/test-helpers/mock-tx-helpers.ts +1 -1
- package/src/test-helpers/reqresp-nodes.ts +3 -2
- 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 +349 -123
- package/src/testbench/worker_client_manager.ts +304 -42
- package/src/util.ts +7 -1
- package/dest/mem_pools/attestation_pool/kv_attestation_pool.d.ts +0 -37
- 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 -213
- package/dest/mem_pools/attestation_pool/memory_attestation_pool.d.ts +0 -30
- 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 -219
- package/dest/mem_pools/tx_pool/memory_tx_pool.d.ts +0 -80
- package/dest/mem_pools/tx_pool/memory_tx_pool.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/memory_tx_pool.js +0 -238
- package/dest/msg_validators/block_proposal_validator/block_proposal_validator.d.ts +0 -12
- package/dest/msg_validators/block_proposal_validator/block_proposal_validator.d.ts.map +0 -1
- package/dest/msg_validators/block_proposal_validator/block_proposal_validator.js +0 -82
- package/dest/msg_validators/block_proposal_validator/index.d.ts +0 -2
- package/dest/msg_validators/block_proposal_validator/index.d.ts.map +0 -1
- package/dest/msg_validators/block_proposal_validator/index.js +0 -1
- package/src/mem_pools/attestation_pool/kv_attestation_pool.ts +0 -298
- package/src/mem_pools/attestation_pool/memory_attestation_pool.ts +0 -287
- package/src/mem_pools/tx_pool/memory_tx_pool.ts +0 -283
- package/src/msg_validators/block_proposal_validator/block_proposal_validator.ts +0 -97
- package/src/msg_validators/block_proposal_validator/index.ts +0 -1
|
@@ -1,13 +1,20 @@
|
|
|
1
|
-
import { Fr } from '@aztec/foundation/
|
|
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,
|
|
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,43 +20,50 @@ export class ReqRespMetrics {
|
|
|
18
20
|
this.tracer = telemetryClient.getTracer(name);
|
|
19
21
|
|
|
20
22
|
const meter = telemetryClient.getMeter(name);
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
this.
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
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
|
+
);
|
|
40
|
+
|
|
41
|
+
this.failedOutboundRequests = createUpDownCounterWithDefault(
|
|
42
|
+
meter,
|
|
43
|
+
Metrics.P2P_REQ_RESP_FAILED_OUTBOUND_REQUESTS,
|
|
44
|
+
protocolAttrs,
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
this.failedInboundRequests = createUpDownCounterWithDefault(
|
|
48
|
+
meter,
|
|
49
|
+
Metrics.P2P_REQ_RESP_FAILED_INBOUND_REQUESTS,
|
|
50
|
+
protocolAttrs,
|
|
51
|
+
);
|
|
43
52
|
}
|
|
44
53
|
|
|
45
|
-
public recordRequestSent(protocol:
|
|
54
|
+
public recordRequestSent(protocol: ReqRespSubProtocol) {
|
|
46
55
|
this.sentRequests.add(1, { [Attributes.P2P_REQ_RESP_PROTOCOL]: protocol });
|
|
47
56
|
}
|
|
48
57
|
|
|
49
|
-
public recordRequestReceived(protocol:
|
|
58
|
+
public recordRequestReceived(protocol: ReqRespSubProtocol) {
|
|
50
59
|
this.receivedRequests.add(1, { [Attributes.P2P_REQ_RESP_PROTOCOL]: protocol });
|
|
51
60
|
}
|
|
52
61
|
|
|
53
|
-
public recordRequestError(protocol:
|
|
62
|
+
public recordRequestError(protocol: ReqRespSubProtocol) {
|
|
54
63
|
this.failedOutboundRequests.add(1, { [Attributes.P2P_REQ_RESP_PROTOCOL]: protocol });
|
|
55
64
|
}
|
|
56
65
|
|
|
57
|
-
public recordResponseError(protocol:
|
|
66
|
+
public recordResponseError(protocol: ReqRespSubProtocol) {
|
|
58
67
|
this.failedInboundRequests.add(1, { [Attributes.P2P_REQ_RESP_PROTOCOL]: protocol });
|
|
59
68
|
}
|
|
60
69
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Buffer32 } from '@aztec/foundation/buffer';
|
|
2
|
-
import { keccak256 } from '@aztec/foundation/crypto';
|
|
2
|
+
import { keccak256 } from '@aztec/foundation/crypto/keccak';
|
|
3
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
4
|
import { Signature } from '@aztec/foundation/eth-signature';
|
|
4
|
-
import { Fr } from '@aztec/foundation/fields';
|
|
5
5
|
import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
|
|
6
6
|
|
|
7
7
|
import { StatusMessage } from './status.js';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
2
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
3
|
import type { L2BlockSource } from '@aztec/stdlib/block';
|
|
3
4
|
|
|
4
5
|
import type { PeerId } from '@libp2p/interface';
|
|
@@ -27,7 +28,7 @@ export function reqRespBlockHandler(l2BlockSource: L2BlockSource): ReqRespSubPro
|
|
|
27
28
|
}
|
|
28
29
|
|
|
29
30
|
try {
|
|
30
|
-
const foundBlock = await l2BlockSource.getBlock(Number(blockNumber));
|
|
31
|
+
const foundBlock = await l2BlockSource.getBlock(BlockNumber(Number(blockNumber)));
|
|
31
32
|
return foundBlock ? foundBlock.toBuffer() : Buffer.alloc(0);
|
|
32
33
|
} catch (err: any) {
|
|
33
34
|
throw new ReqRespStatusError(ReqRespStatus.INTERNAL_ERROR, { cause: err });
|
|
@@ -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,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
|
-
import { Fr } from '@aztec/foundation/
|
|
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,3 +1,4 @@
|
|
|
1
|
+
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
1
2
|
import { Buffer32 } from '@aztec/foundation/buffer';
|
|
2
3
|
import type { Logger } from '@aztec/foundation/log';
|
|
3
4
|
import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
|
|
@@ -6,6 +7,8 @@ import type { WorldStateSyncStatus, WorldStateSynchronizer } from '@aztec/stdlib
|
|
|
6
7
|
|
|
7
8
|
import type { PeerId } from '@libp2p/interface';
|
|
8
9
|
|
|
10
|
+
import { MAX_BLOCK_HASH_STRING_LENGTH, MAX_VERSION_STRING_LENGTH } from '../constants.js';
|
|
11
|
+
|
|
9
12
|
/*
|
|
10
13
|
* P2P Status Message
|
|
11
14
|
* It is used to establish Status handshake between to peers
|
|
@@ -15,12 +18,13 @@ import type { PeerId } from '@libp2p/interface';
|
|
|
15
18
|
export class StatusMessage {
|
|
16
19
|
constructor(
|
|
17
20
|
readonly compressedComponentsVersion: string,
|
|
18
|
-
readonly latestBlockNumber:
|
|
21
|
+
readonly latestBlockNumber: BlockNumber,
|
|
19
22
|
readonly latestBlockHash: string,
|
|
20
|
-
readonly finalizedBlockNumber:
|
|
23
|
+
readonly finalizedBlockNumber: BlockNumber,
|
|
24
|
+
) {
|
|
21
25
|
//TODO: add finalizedBlockHash
|
|
22
26
|
//readonly finalizedBlockHash: string,
|
|
23
|
-
|
|
27
|
+
}
|
|
24
28
|
|
|
25
29
|
/**
|
|
26
30
|
* Deserializes the StatusMessage object from a Buffer.
|
|
@@ -30,12 +34,12 @@ export class StatusMessage {
|
|
|
30
34
|
static fromBuffer(buffer: Buffer | BufferReader): StatusMessage {
|
|
31
35
|
const reader = BufferReader.asReader(buffer);
|
|
32
36
|
return new StatusMessage(
|
|
33
|
-
reader.readString(), // compressedComponentsVersion
|
|
34
|
-
reader.readNumber(), // latestBlockNumber
|
|
35
|
-
reader.readString(), // latestBlockHash
|
|
36
|
-
reader.readNumber(), // finalizedBlockNumber
|
|
37
|
+
reader.readString(MAX_VERSION_STRING_LENGTH), // compressedComponentsVersion
|
|
38
|
+
BlockNumber(reader.readNumber()), // latestBlockNumber
|
|
39
|
+
reader.readString(MAX_BLOCK_HASH_STRING_LENGTH), // latestBlockHash
|
|
40
|
+
BlockNumber(reader.readNumber()), // finalizedBlockNumber
|
|
37
41
|
//TODO: add finalizedBlockHash
|
|
38
|
-
//reader.readString(), // finalizedBlockHash
|
|
42
|
+
//reader.readString(MAX_BLOCK_HASH_STRING_LENGTH), // finalizedBlockHash
|
|
39
43
|
);
|
|
40
44
|
}
|
|
41
45
|
|
|
@@ -63,9 +67,9 @@ export class StatusMessage {
|
|
|
63
67
|
static fromWorldStateSyncStatus(version: string, syncStatus: WorldStateSyncStatus): StatusMessage {
|
|
64
68
|
return new StatusMessage(
|
|
65
69
|
version,
|
|
66
|
-
syncStatus.latestBlockNumber,
|
|
70
|
+
BlockNumber(syncStatus.latestBlockNumber),
|
|
67
71
|
syncStatus.latestBlockHash,
|
|
68
|
-
syncStatus.finalizedBlockNumber,
|
|
72
|
+
BlockNumber(syncStatus.finalizedBlockNumber),
|
|
69
73
|
//TODO: add finalizedBlockHash
|
|
70
74
|
);
|
|
71
75
|
}
|
|
@@ -73,9 +77,9 @@ export class StatusMessage {
|
|
|
73
77
|
static random(): StatusMessage {
|
|
74
78
|
return new StatusMessage(
|
|
75
79
|
'1.0.0',
|
|
76
|
-
Math.floor(Math.random() * 100),
|
|
80
|
+
BlockNumber(Math.floor(Math.random() * 100)),
|
|
77
81
|
Buffer32.random().toString(),
|
|
78
|
-
Math.floor(Math.random() * 100),
|
|
82
|
+
BlockNumber(Math.floor(Math.random() * 100)),
|
|
79
83
|
//TODO: add finalizedBlockHash
|
|
80
84
|
);
|
|
81
85
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { chunk } from '@aztec/foundation/collection';
|
|
2
|
-
import
|
|
2
|
+
import { MAX_TX_SIZE_KB } from '@aztec/stdlib/p2p';
|
|
3
3
|
import { TxArray, TxHash, TxHashArray } from '@aztec/stdlib/tx';
|
|
4
4
|
|
|
5
5
|
import type { PeerId } from '@libp2p/interface';
|
|
@@ -16,7 +16,7 @@ import { ReqRespStatus, ReqRespStatusError } from '../status.js';
|
|
|
16
16
|
* @param mempools - the mempools
|
|
17
17
|
* @returns the Tx request handler
|
|
18
18
|
*/
|
|
19
|
-
export function reqRespTxHandler
|
|
19
|
+
export function reqRespTxHandler(mempools: MemPools): ReqRespSubProtocolHandler {
|
|
20
20
|
/**
|
|
21
21
|
* Handler for tx requests
|
|
22
22
|
* @param msg - the tx request message
|
|
@@ -56,3 +56,24 @@ export function reqRespTxHandler<T extends P2PClientType>(mempools: MemPools<T>)
|
|
|
56
56
|
export function chunkTxHashesRequest(hashes: TxHash[], chunkSize = 1): Array<TxHashArray> {
|
|
57
57
|
return chunk(hashes, chunkSize).map(chunk => new TxHashArray(...chunk));
|
|
58
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
|
+
}
|