@aztec/p2p 0.0.1-commit.6c91f13 → 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/interface.d.ts +18 -5
- package/dest/client/interface.d.ts.map +1 -1
- package/dest/client/p2p_client.d.ts +13 -14
- package/dest/client/p2p_client.d.ts.map +1 -1
- package/dest/client/p2p_client.js +462 -120
- 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.d.ts +61 -42
- package/dest/mem_pools/attestation_pool/attestation_pool.d.ts.map +1 -1
- 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 +237 -263
- package/dest/mem_pools/attestation_pool/kv_attestation_pool.d.ts +21 -18
- package/dest/mem_pools/attestation_pool/kv_attestation_pool.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/kv_attestation_pool.js +113 -108
- package/dest/mem_pools/attestation_pool/memory_attestation_pool.d.ts +17 -16
- package/dest/mem_pools/attestation_pool/memory_attestation_pool.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/memory_attestation_pool.js +89 -128
- package/dest/mem_pools/attestation_pool/mocks.d.ts +9 -6
- package/dest/mem_pools/attestation_pool/mocks.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/mocks.js +16 -12
- 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 +5 -14
- 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 +4 -4
- package/dest/msg_validators/attestation_validator/attestation_validator.d.ts.map +1 -1
- package/dest/msg_validators/attestation_validator/attestation_validator.js +51 -18
- package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.d.ts +5 -5
- 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/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 +18 -2
- package/dest/services/dummy_service.d.ts.map +1 -1
- package/dest/services/dummy_service.js +42 -0
- package/dest/services/encoding.d.ts +1 -1
- package/dest/services/encoding.d.ts.map +1 -1
- package/dest/services/encoding.js +6 -5
- 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 +38 -15
- package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
- package/dest/services/libp2p/libp2p_service.js +747 -183
- 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 +21 -26
- 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 +0 -10
- 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 +7 -4
- 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 -21
- 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 +4 -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 +460 -46
- package/dest/services/service.d.ts +19 -3
- 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 +10 -13
- 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 +7 -20
- 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 +218 -124
- 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/package.json +16 -16
- package/src/bootstrap/bootstrap.ts +7 -4
- package/src/client/factory.ts +10 -10
- package/src/client/interface.ts +19 -4
- package/src/client/p2p_client.ts +95 -133
- 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.ts +68 -41
- package/src/mem_pools/attestation_pool/attestation_pool_test_suite.ts +239 -287
- package/src/mem_pools/attestation_pool/kv_attestation_pool.ts +162 -140
- package/src/mem_pools/attestation_pool/memory_attestation_pool.ts +141 -164
- package/src/mem_pools/attestation_pool/mocks.ts +19 -13
- package/src/mem_pools/instrumentation.ts +10 -18
- 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 +36 -21
- package/src/msg_validators/attestation_validator/fisherman_attestation_validator.ts +19 -16
- 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/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 +18 -6
- 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 +18 -7
- 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 +9 -4
- 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 +51 -0
- package/src/services/encoding.ts +5 -4
- package/src/services/index.ts +1 -0
- package/src/services/libp2p/instrumentation.ts +32 -73
- package/src/services/libp2p/libp2p_service.ts +420 -166
- package/src/services/peer-manager/metrics.ts +22 -26
- package/src/services/peer-manager/peer_manager.ts +1 -2
- package/src/services/peer-manager/peer_scoring.ts +3 -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 +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 +19 -1
- package/src/services/reqresp/constants.ts +14 -0
- package/src/services/reqresp/interface.ts +3 -0
- package/src/services/reqresp/metrics.ts +36 -27
- 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 +7 -4
- package/src/services/reqresp/reqresp.ts +66 -19
- package/src/services/service.ts +23 -4
- 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 +5 -13
- 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 +13 -20
- 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 +337 -119
- package/src/testbench/worker_client_manager.ts +304 -42
- 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/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/tx_pool/eviction/insufficient_fee_payer_balance_rule.ts +0 -108
- 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,23 +1,25 @@
|
|
|
1
1
|
import type { EpochCacheInterface } from '@aztec/epoch-cache';
|
|
2
|
-
import { BlockNumber
|
|
2
|
+
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
3
3
|
import { randomInt } from '@aztec/foundation/crypto/random';
|
|
4
4
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
5
5
|
import { type Logger, createLibp2pComponentLogger, createLogger } from '@aztec/foundation/log';
|
|
6
6
|
import { RunningPromise } from '@aztec/foundation/running-promise';
|
|
7
7
|
import { Timer } from '@aztec/foundation/timer';
|
|
8
8
|
import type { AztecAsyncKVStore } from '@aztec/kv-store';
|
|
9
|
-
import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
|
|
10
9
|
import { protocolContractsHash } from '@aztec/protocol-contracts';
|
|
11
10
|
import type { EthAddress, L2Block, L2BlockSource } from '@aztec/stdlib/block';
|
|
12
11
|
import type { ContractDataSource } from '@aztec/stdlib/contract';
|
|
13
12
|
import { GasFees } from '@aztec/stdlib/gas';
|
|
14
13
|
import type { ClientProtocolCircuitVerifier, PeerInfo, WorldStateSynchronizer } from '@aztec/stdlib/interfaces/server';
|
|
15
14
|
import {
|
|
16
|
-
BlockAttestation,
|
|
17
15
|
BlockProposal,
|
|
16
|
+
CheckpointAttestation,
|
|
17
|
+
CheckpointProposal,
|
|
18
|
+
type CheckpointProposalCore,
|
|
18
19
|
type Gossipable,
|
|
19
20
|
P2PClientType,
|
|
20
21
|
P2PMessage,
|
|
22
|
+
type ValidationResult as P2PValidationResult,
|
|
21
23
|
PeerErrorSeverity,
|
|
22
24
|
TopicType,
|
|
23
25
|
createTopicString,
|
|
@@ -28,7 +30,14 @@ import { MerkleTreeId } from '@aztec/stdlib/trees';
|
|
|
28
30
|
import { Tx, type TxHash, type TxValidationResult, type TxValidator } from '@aztec/stdlib/tx';
|
|
29
31
|
import type { UInt64 } from '@aztec/stdlib/types';
|
|
30
32
|
import { compressComponentVersions } from '@aztec/stdlib/versioning';
|
|
31
|
-
import {
|
|
33
|
+
import {
|
|
34
|
+
Attributes,
|
|
35
|
+
OtelMetricsAdapter,
|
|
36
|
+
SpanStatusCode,
|
|
37
|
+
type TelemetryClient,
|
|
38
|
+
WithTracer,
|
|
39
|
+
trackSpan,
|
|
40
|
+
} from '@aztec/telemetry-client';
|
|
32
41
|
|
|
33
42
|
import {
|
|
34
43
|
type GossipSub,
|
|
@@ -51,22 +60,21 @@ import { createLibp2p } from 'libp2p';
|
|
|
51
60
|
|
|
52
61
|
import type { P2PConfig } from '../../config.js';
|
|
53
62
|
import { ProposalSlotCapExceededError } from '../../errors/attestation-pool.error.js';
|
|
54
|
-
import type { MemPools } from '../../mem_pools/
|
|
63
|
+
import type { MemPools } from '../../mem_pools/index.js';
|
|
55
64
|
import {
|
|
56
|
-
AttestationValidator,
|
|
57
65
|
BlockProposalValidator,
|
|
66
|
+
CheckpointAttestationValidator,
|
|
67
|
+
CheckpointProposalValidator,
|
|
68
|
+
DoubleSpendTxValidator,
|
|
58
69
|
FishermanAttestationValidator,
|
|
70
|
+
getDefaultAllowedSetupFunctions,
|
|
59
71
|
} from '../../msg_validators/index.js';
|
|
60
72
|
import { MessageSeenValidator } from '../../msg_validators/msg_seen_validator/msg_seen_validator.js';
|
|
61
|
-
import { getDefaultAllowedSetupFunctions } from '../../msg_validators/tx_validator/allowed_public_setup.js';
|
|
62
|
-
import { type MessageValidator, createTxMessageValidators } from '../../msg_validators/tx_validator/factory.js';
|
|
63
73
|
import {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
TxProofValidator,
|
|
69
|
-
} from '../../msg_validators/tx_validator/index.js';
|
|
74
|
+
type MessageValidator,
|
|
75
|
+
createTxMessageValidators,
|
|
76
|
+
createTxReqRespValidator,
|
|
77
|
+
} from '../../msg_validators/tx_validator/factory.js';
|
|
70
78
|
import { GossipSubEvent } from '../../types/index.js';
|
|
71
79
|
import { type PubSubLibp2p, convertToMultiaddr } from '../../util.js';
|
|
72
80
|
import { getVersions } from '../../versioning.js';
|
|
@@ -77,31 +85,38 @@ import { gossipScoreThresholds } from '../gossipsub/scoring.js';
|
|
|
77
85
|
import type { PeerManagerInterface } from '../peer-manager/interface.js';
|
|
78
86
|
import { PeerManager } from '../peer-manager/peer_manager.js';
|
|
79
87
|
import { PeerScoring } from '../peer-manager/peer_scoring.js';
|
|
88
|
+
import type { BatchTxRequesterLibP2PService } from '../reqresp/batch-tx-requester/interface.js';
|
|
80
89
|
import type { P2PReqRespConfig } from '../reqresp/config.js';
|
|
81
90
|
import {
|
|
82
91
|
DEFAULT_SUB_PROTOCOL_VALIDATORS,
|
|
83
92
|
type ReqRespInterface,
|
|
93
|
+
type ReqRespResponse,
|
|
84
94
|
ReqRespSubProtocol,
|
|
85
95
|
type ReqRespSubProtocolHandler,
|
|
86
96
|
type ReqRespSubProtocolHandlers,
|
|
87
97
|
type ReqRespSubProtocolValidators,
|
|
88
98
|
type SubProtocolMap,
|
|
89
99
|
ValidationError,
|
|
90
|
-
} from '../reqresp/
|
|
91
|
-
import { reqRespBlockTxsHandler } from '../reqresp/protocols/block_txs/block_txs_handler.js';
|
|
92
|
-
import { reqGoodbyeHandler } from '../reqresp/protocols/goodbye.js';
|
|
100
|
+
} from '../reqresp/index.js';
|
|
93
101
|
import {
|
|
94
102
|
AuthRequest,
|
|
95
103
|
BlockTxsRequest,
|
|
96
104
|
BlockTxsResponse,
|
|
97
105
|
StatusMessage,
|
|
98
106
|
pingHandler,
|
|
107
|
+
reqGoodbyeHandler,
|
|
99
108
|
reqRespBlockHandler,
|
|
109
|
+
reqRespBlockTxsHandler,
|
|
100
110
|
reqRespStatusHandler,
|
|
101
111
|
reqRespTxHandler,
|
|
102
|
-
} from '../reqresp/
|
|
112
|
+
} from '../reqresp/index.js';
|
|
103
113
|
import { ReqResp } from '../reqresp/reqresp.js';
|
|
104
|
-
import type {
|
|
114
|
+
import type {
|
|
115
|
+
P2PBlockReceivedCallback,
|
|
116
|
+
P2PCheckpointReceivedCallback,
|
|
117
|
+
P2PService,
|
|
118
|
+
PeerDiscoveryService,
|
|
119
|
+
} from '../service.js';
|
|
105
120
|
import { P2PInstrumentation } from './instrumentation.js';
|
|
106
121
|
|
|
107
122
|
interface ValidationResult {
|
|
@@ -125,8 +140,9 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
125
140
|
private msgIdSeenValidators: Record<TopicType, MessageSeenValidator> = {} as Record<TopicType, MessageSeenValidator>;
|
|
126
141
|
|
|
127
142
|
// Message validators
|
|
128
|
-
private attestationValidator: AttestationValidator;
|
|
129
143
|
private blockProposalValidator: BlockProposalValidator;
|
|
144
|
+
private checkpointProposalValidator: CheckpointProposalValidator;
|
|
145
|
+
private checkpointAttestationValidator: CheckpointAttestationValidator;
|
|
130
146
|
|
|
131
147
|
private protocolVersion = '';
|
|
132
148
|
private topicStrings: Record<TopicType, string> = {} as Record<TopicType, string>;
|
|
@@ -140,10 +156,19 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
140
156
|
*/
|
|
141
157
|
private blockReceivedCallback: P2PBlockReceivedCallback;
|
|
142
158
|
|
|
159
|
+
/**
|
|
160
|
+
* Callback for when a checkpoint proposal is received from a peer.
|
|
161
|
+
* @param checkpoint - The checkpoint proposal received from the peer.
|
|
162
|
+
* @returns The attestations for the checkpoint, if any.
|
|
163
|
+
*/
|
|
164
|
+
private checkpointReceivedCallback: P2PCheckpointReceivedCallback;
|
|
165
|
+
|
|
143
166
|
private gossipSubEventHandler: (e: CustomEvent<GossipsubMessage>) => void;
|
|
144
167
|
|
|
145
168
|
private instrumentation: P2PInstrumentation;
|
|
146
169
|
|
|
170
|
+
private telemetry: TelemetryClient;
|
|
171
|
+
|
|
147
172
|
protected logger: Logger;
|
|
148
173
|
|
|
149
174
|
constructor(
|
|
@@ -162,6 +187,7 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
162
187
|
logger: Logger = createLogger('p2p:libp2p_service'),
|
|
163
188
|
) {
|
|
164
189
|
super(telemetry, 'LibP2PService');
|
|
190
|
+
this.telemetry = telemetry;
|
|
165
191
|
|
|
166
192
|
// Create child logger with fisherman prefix if in fisherman mode
|
|
167
193
|
this.logger = config.fishermanMode ? logger.createChild('[FISHERMAN]') : logger;
|
|
@@ -170,7 +196,8 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
170
196
|
|
|
171
197
|
this.msgIdSeenValidators[TopicType.tx] = new MessageSeenValidator(config.seenMessageCacheSize);
|
|
172
198
|
this.msgIdSeenValidators[TopicType.block_proposal] = new MessageSeenValidator(config.seenMessageCacheSize);
|
|
173
|
-
this.msgIdSeenValidators[TopicType.
|
|
199
|
+
this.msgIdSeenValidators[TopicType.checkpoint_proposal] = new MessageSeenValidator(config.seenMessageCacheSize);
|
|
200
|
+
this.msgIdSeenValidators[TopicType.checkpoint_attestation] = new MessageSeenValidator(config.seenMessageCacheSize);
|
|
174
201
|
|
|
175
202
|
const versions = getVersions(config);
|
|
176
203
|
this.protocolVersion = compressComponentVersions(versions);
|
|
@@ -178,25 +205,40 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
178
205
|
|
|
179
206
|
this.topicStrings[TopicType.tx] = createTopicString(TopicType.tx, this.protocolVersion);
|
|
180
207
|
this.topicStrings[TopicType.block_proposal] = createTopicString(TopicType.block_proposal, this.protocolVersion);
|
|
181
|
-
this.topicStrings[TopicType.
|
|
182
|
-
TopicType.
|
|
208
|
+
this.topicStrings[TopicType.checkpoint_proposal] = createTopicString(
|
|
209
|
+
TopicType.checkpoint_proposal,
|
|
210
|
+
this.protocolVersion,
|
|
211
|
+
);
|
|
212
|
+
this.topicStrings[TopicType.checkpoint_attestation] = createTopicString(
|
|
213
|
+
TopicType.checkpoint_attestation,
|
|
183
214
|
this.protocolVersion,
|
|
184
215
|
);
|
|
185
216
|
|
|
186
|
-
// Use FishermanAttestationValidator in fisherman mode to validate attestation payloads against proposals
|
|
187
|
-
this.attestationValidator = config.fishermanMode
|
|
188
|
-
? new FishermanAttestationValidator(epochCache, mempools.attestationPool, telemetry)
|
|
189
|
-
: new AttestationValidator(epochCache);
|
|
190
217
|
this.blockProposalValidator = new BlockProposalValidator(epochCache, { txsPermitted: !config.disableTransactions });
|
|
218
|
+
this.checkpointProposalValidator = new CheckpointProposalValidator(epochCache, {
|
|
219
|
+
txsPermitted: !config.disableTransactions,
|
|
220
|
+
});
|
|
221
|
+
this.checkpointAttestationValidator = config.fishermanMode
|
|
222
|
+
? new FishermanAttestationValidator(epochCache, mempools.attestationPool, telemetry)
|
|
223
|
+
: new CheckpointAttestationValidator(epochCache);
|
|
191
224
|
|
|
192
225
|
this.gossipSubEventHandler = this.handleGossipSubEvent.bind(this);
|
|
193
226
|
|
|
194
|
-
this.blockReceivedCallback = async (block: BlockProposal): Promise<
|
|
227
|
+
this.blockReceivedCallback = async (block: BlockProposal): Promise<boolean> => {
|
|
195
228
|
this.logger.debug(
|
|
196
229
|
`Handler not yet registered: Block received callback not set. Received block for slot ${block.slotNumber} from peer.`,
|
|
197
230
|
{ p2pMessageIdentifier: await block.p2pMessageLoggingIdentifier() },
|
|
198
231
|
);
|
|
199
|
-
return
|
|
232
|
+
return false;
|
|
233
|
+
};
|
|
234
|
+
|
|
235
|
+
this.checkpointReceivedCallback = (
|
|
236
|
+
checkpoint: CheckpointProposalCore,
|
|
237
|
+
): Promise<CheckpointAttestation[] | undefined> => {
|
|
238
|
+
this.logger.debug(
|
|
239
|
+
`Handler not yet registered: Checkpoint received callback not set. Received checkpoint for slot ${checkpoint.slotNumber} from peer.`,
|
|
240
|
+
);
|
|
241
|
+
return Promise.resolve(undefined);
|
|
200
242
|
};
|
|
201
243
|
}
|
|
202
244
|
|
|
@@ -242,14 +284,14 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
242
284
|
|
|
243
285
|
const datastore = new AztecDatastore(peerStore);
|
|
244
286
|
|
|
245
|
-
const otelMetricsAdapter = new OtelMetricsAdapter(telemetry);
|
|
287
|
+
const otelMetricsAdapter = new OtelMetricsAdapter(telemetry, logger.getBindings());
|
|
246
288
|
|
|
247
289
|
const peerDiscoveryService = new DiscV5Service(
|
|
248
290
|
peerId,
|
|
249
291
|
config,
|
|
250
292
|
packageVersion,
|
|
251
293
|
telemetry,
|
|
252
|
-
createLogger(`${logger.module}:discv5_service
|
|
294
|
+
createLogger(`${logger.module}:discv5_service`, logger.getBindings()),
|
|
253
295
|
);
|
|
254
296
|
|
|
255
297
|
// Seed libp2p's bootstrap discovery with private and trusted peers
|
|
@@ -265,7 +307,8 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
265
307
|
|
|
266
308
|
const txTopic = createTopicString(TopicType.tx, protocolVersion);
|
|
267
309
|
const blockProposalTopic = createTopicString(TopicType.block_proposal, protocolVersion);
|
|
268
|
-
const
|
|
310
|
+
const checkpointProposalTopic = createTopicString(TopicType.checkpoint_proposal, protocolVersion);
|
|
311
|
+
const checkpointAttestationTopic = createTopicString(TopicType.checkpoint_attestation, protocolVersion);
|
|
269
312
|
|
|
270
313
|
const preferredPeersEnrs: ENR[] = config.preferredPeers.map(enr => ENR.decodeTxt(enr));
|
|
271
314
|
const directPeers = (
|
|
@@ -387,12 +430,17 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
387
430
|
invalidMessageDeliveriesWeight: -20,
|
|
388
431
|
invalidMessageDeliveriesDecay: 0.5,
|
|
389
432
|
}),
|
|
390
|
-
[
|
|
433
|
+
[blockProposalTopic]: createTopicScoreParams({
|
|
391
434
|
topicWeight: 1,
|
|
392
435
|
invalidMessageDeliveriesWeight: -20,
|
|
393
436
|
invalidMessageDeliveriesDecay: 0.5,
|
|
394
437
|
}),
|
|
395
|
-
[
|
|
438
|
+
[checkpointProposalTopic]: createTopicScoreParams({
|
|
439
|
+
topicWeight: 1,
|
|
440
|
+
invalidMessageDeliveriesWeight: -20,
|
|
441
|
+
invalidMessageDeliveriesDecay: 0.5,
|
|
442
|
+
}),
|
|
443
|
+
[checkpointAttestationTopic]: createTopicScoreParams({
|
|
396
444
|
topicWeight: 1,
|
|
397
445
|
invalidMessageDeliveriesWeight: -20,
|
|
398
446
|
invalidMessageDeliveriesDecay: 0.5,
|
|
@@ -404,7 +452,7 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
404
452
|
connectionManager: components.connectionManager,
|
|
405
453
|
}),
|
|
406
454
|
},
|
|
407
|
-
logger: createLibp2pComponentLogger(logger.module),
|
|
455
|
+
logger: createLibp2pComponentLogger(logger.module, logger.getBindings()),
|
|
408
456
|
});
|
|
409
457
|
|
|
410
458
|
const peerScoring = new PeerScoring(config, telemetry);
|
|
@@ -462,17 +510,6 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
462
510
|
}
|
|
463
511
|
const announceTcpMultiaddr = convertToMultiaddr(p2pIp, p2pPort, 'tcp');
|
|
464
512
|
|
|
465
|
-
await this.peerManager.initializePeers();
|
|
466
|
-
if (!this.config.p2pDiscoveryDisabled) {
|
|
467
|
-
await this.peerDiscoveryService.start();
|
|
468
|
-
}
|
|
469
|
-
await this.node.start();
|
|
470
|
-
|
|
471
|
-
// Subscribe to standard GossipSub topics by default
|
|
472
|
-
for (const topic of getTopicsForClientAndConfig(this.clientType, this.config.disableTransactions)) {
|
|
473
|
-
this.subscribeToTopic(this.topicStrings[topic]);
|
|
474
|
-
}
|
|
475
|
-
|
|
476
513
|
// Create request response protocol handlers
|
|
477
514
|
const txHandler = reqRespTxHandler(this.mempools);
|
|
478
515
|
const goodbyeHandler = reqGoodbyeHandler(this.peerManager);
|
|
@@ -487,7 +524,11 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
487
524
|
};
|
|
488
525
|
|
|
489
526
|
if (!this.config.disableTransactions) {
|
|
490
|
-
const blockTxsHandler = reqRespBlockTxsHandler(
|
|
527
|
+
const blockTxsHandler = reqRespBlockTxsHandler(
|
|
528
|
+
this.mempools.attestationPool,
|
|
529
|
+
this.archiver,
|
|
530
|
+
this.mempools.txPool,
|
|
531
|
+
);
|
|
491
532
|
requestResponseHandlers[ReqRespSubProtocol.BLOCK_TXS] = blockTxsHandler.bind(this);
|
|
492
533
|
}
|
|
493
534
|
|
|
@@ -495,10 +536,32 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
495
536
|
requestResponseHandlers[ReqRespSubProtocol.TX] = txHandler.bind(this);
|
|
496
537
|
}
|
|
497
538
|
|
|
539
|
+
// Define the sub protocol validators - This is done within this start() method to gain a callback to the existing validateTx function
|
|
540
|
+
const reqrespSubProtocolValidators = {
|
|
541
|
+
...DEFAULT_SUB_PROTOCOL_VALIDATORS,
|
|
542
|
+
[ReqRespSubProtocol.TX]: this.validateRequestedTxs.bind(this),
|
|
543
|
+
[ReqRespSubProtocol.BLOCK_TXS]: this.validateRequestedBlockTxs.bind(this),
|
|
544
|
+
[ReqRespSubProtocol.BLOCK]: this.validateRequestedBlock.bind(this),
|
|
545
|
+
};
|
|
546
|
+
|
|
547
|
+
await this.peerManager.initializePeers();
|
|
548
|
+
|
|
549
|
+
await this.reqresp.start(requestResponseHandlers, reqrespSubProtocolValidators);
|
|
550
|
+
|
|
551
|
+
await this.node.start();
|
|
552
|
+
|
|
553
|
+
// Subscribe to standard GossipSub topics by default
|
|
554
|
+
for (const topic of getTopicsForClientAndConfig(this.clientType, this.config.disableTransactions)) {
|
|
555
|
+
this.subscribeToTopic(this.topicStrings[topic]);
|
|
556
|
+
}
|
|
557
|
+
|
|
498
558
|
// add GossipSub listener
|
|
499
559
|
this.node.services.pubsub.addEventListener(GossipSubEvent.MESSAGE, this.gossipSubEventHandler);
|
|
500
560
|
|
|
501
561
|
// Start running promise for peer discovery and metrics collection
|
|
562
|
+
if (!this.config.p2pDiscoveryDisabled) {
|
|
563
|
+
await this.peerDiscoveryService.start();
|
|
564
|
+
}
|
|
502
565
|
this.discoveryRunningPromise = new RunningPromise(
|
|
503
566
|
async () => {
|
|
504
567
|
await this.peerManager.heartbeat();
|
|
@@ -508,14 +571,6 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
508
571
|
);
|
|
509
572
|
this.discoveryRunningPromise.start();
|
|
510
573
|
|
|
511
|
-
// Define the sub protocol validators - This is done within this start() method to gain a callback to the existing validateTx function
|
|
512
|
-
const reqrespSubProtocolValidators = {
|
|
513
|
-
...DEFAULT_SUB_PROTOCOL_VALIDATORS,
|
|
514
|
-
[ReqRespSubProtocol.TX]: this.validateRequestedTxs.bind(this),
|
|
515
|
-
[ReqRespSubProtocol.BLOCK_TXS]: this.validateRequestedBlockTxs.bind(this),
|
|
516
|
-
[ReqRespSubProtocol.BLOCK]: this.validateRequestedBlock.bind(this),
|
|
517
|
-
};
|
|
518
|
-
await this.reqresp.start(requestResponseHandlers, reqrespSubProtocolValidators);
|
|
519
574
|
this.logger.info(`Started P2P service`, {
|
|
520
575
|
listen: this.config.listenAddress,
|
|
521
576
|
port: this.config.p2pPort,
|
|
@@ -589,6 +644,15 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
589
644
|
return this.reqresp.sendBatchRequest(protocol, requests, pinnedPeerId);
|
|
590
645
|
}
|
|
591
646
|
|
|
647
|
+
public sendRequestToPeer(
|
|
648
|
+
peerId: PeerId,
|
|
649
|
+
subProtocol: ReqRespSubProtocol,
|
|
650
|
+
payload: Buffer,
|
|
651
|
+
dialTimeout?: number,
|
|
652
|
+
): Promise<ReqRespResponse> {
|
|
653
|
+
return this.reqresp.sendRequestToPeer(peerId, subProtocol, payload, dialTimeout);
|
|
654
|
+
}
|
|
655
|
+
|
|
592
656
|
/**
|
|
593
657
|
* Get the ENR of the node
|
|
594
658
|
* @returns The ENR of the node
|
|
@@ -601,6 +665,10 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
601
665
|
this.blockReceivedCallback = callback;
|
|
602
666
|
}
|
|
603
667
|
|
|
668
|
+
public registerCheckpointReceivedCallback(callback: P2PCheckpointReceivedCallback) {
|
|
669
|
+
this.checkpointReceivedCallback = callback;
|
|
670
|
+
}
|
|
671
|
+
|
|
604
672
|
/**
|
|
605
673
|
* Subscribes to a topic.
|
|
606
674
|
* @param topic - The topic to subscribe to.
|
|
@@ -622,7 +690,10 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
622
690
|
if (!this.node.services.pubsub) {
|
|
623
691
|
throw new Error('Pubsub service not available.');
|
|
624
692
|
}
|
|
625
|
-
const
|
|
693
|
+
const isBlockProposal = topic === this.topicStrings[TopicType.block_proposal];
|
|
694
|
+
const traceContext =
|
|
695
|
+
this.config.debugP2PInstrumentMessages && isBlockProposal ? this.telemetry.getTraceContext() : undefined;
|
|
696
|
+
const p2pMessage = P2PMessage.fromGossipable(message, this.config.debugP2PInstrumentMessages, traceContext);
|
|
626
697
|
const result = await this.node.services.pubsub.publish(topic, p2pMessage.toMessageData());
|
|
627
698
|
return result.recipients.length;
|
|
628
699
|
}
|
|
@@ -643,12 +714,15 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
643
714
|
case this.topicStrings[TopicType.tx]:
|
|
644
715
|
topicType = TopicType.tx;
|
|
645
716
|
break;
|
|
646
|
-
case this.topicStrings[TopicType.block_attestation]:
|
|
647
|
-
topicType = TopicType.block_attestation;
|
|
648
|
-
break;
|
|
649
717
|
case this.topicStrings[TopicType.block_proposal]:
|
|
650
718
|
topicType = TopicType.block_proposal;
|
|
651
719
|
break;
|
|
720
|
+
case this.topicStrings[TopicType.checkpoint_proposal]:
|
|
721
|
+
topicType = TopicType.checkpoint_proposal;
|
|
722
|
+
break;
|
|
723
|
+
case this.topicStrings[TopicType.checkpoint_attestation]:
|
|
724
|
+
topicType = TopicType.checkpoint_attestation;
|
|
725
|
+
break;
|
|
652
726
|
default:
|
|
653
727
|
this.logger.error(`Received message on unknown topic: ${msg.topic}`);
|
|
654
728
|
break;
|
|
@@ -707,23 +781,74 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
707
781
|
return;
|
|
708
782
|
}
|
|
709
783
|
|
|
784
|
+
// Determine topic type for attributes
|
|
710
785
|
if (msg.topic === this.topicStrings[TopicType.tx]) {
|
|
711
786
|
topicType = TopicType.tx;
|
|
712
|
-
|
|
787
|
+
} else if (msg.topic === this.topicStrings[TopicType.checkpoint_attestation]) {
|
|
788
|
+
topicType = TopicType.checkpoint_attestation;
|
|
789
|
+
} else if (msg.topic === this.topicStrings[TopicType.block_proposal]) {
|
|
790
|
+
topicType = TopicType.block_proposal;
|
|
791
|
+
} else if (msg.topic === this.topicStrings[TopicType.checkpoint_proposal]) {
|
|
792
|
+
topicType = TopicType.checkpoint_proposal;
|
|
713
793
|
}
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
794
|
+
|
|
795
|
+
// Process the message, optionally within a linked span for trace propagation
|
|
796
|
+
const processMessage = async () => {
|
|
797
|
+
if (msg.topic === this.topicStrings[TopicType.tx]) {
|
|
798
|
+
await this.handleGossipedTx(p2pMessage.payload, msgId, source);
|
|
799
|
+
} else if (msg.topic === this.topicStrings[TopicType.checkpoint_attestation]) {
|
|
800
|
+
if (this.clientType === P2PClientType.Full) {
|
|
801
|
+
await this.processCheckpointAttestationFromPeer(p2pMessage.payload, msgId, source);
|
|
802
|
+
}
|
|
803
|
+
} else if (msg.topic === this.topicStrings[TopicType.block_proposal]) {
|
|
804
|
+
await this.processBlockFromPeer(p2pMessage.payload, msgId, source);
|
|
805
|
+
} else if (msg.topic === this.topicStrings[TopicType.checkpoint_proposal]) {
|
|
806
|
+
await this.handleGossipedCheckpointProposal(p2pMessage.payload, msgId, source);
|
|
807
|
+
} else {
|
|
808
|
+
this.logger.error(`Received message on unknown topic: ${msg.topic}`);
|
|
718
809
|
}
|
|
719
|
-
}
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
810
|
+
};
|
|
811
|
+
|
|
812
|
+
const latency = p2pMessage.timestamp !== undefined ? msgReceivedTime - p2pMessage.timestamp.getTime() : undefined;
|
|
813
|
+
const propagatedContext = p2pMessage.traceContext
|
|
814
|
+
? this.telemetry.extractPropagatedContext(p2pMessage.traceContext)
|
|
815
|
+
: undefined;
|
|
816
|
+
|
|
817
|
+
if (propagatedContext) {
|
|
818
|
+
await this.tracer.startActiveSpan(
|
|
819
|
+
'LibP2PService.processMessage',
|
|
820
|
+
{
|
|
821
|
+
attributes: {
|
|
822
|
+
[Attributes.TOPIC_NAME]: topicType!,
|
|
823
|
+
[Attributes.PEER_ID]: source.toString(),
|
|
824
|
+
},
|
|
825
|
+
},
|
|
826
|
+
propagatedContext,
|
|
827
|
+
async span => {
|
|
828
|
+
try {
|
|
829
|
+
await processMessage();
|
|
830
|
+
span.setStatus({
|
|
831
|
+
code: SpanStatusCode.OK,
|
|
832
|
+
});
|
|
833
|
+
} catch (err) {
|
|
834
|
+
span.setStatus({
|
|
835
|
+
code: SpanStatusCode.ERROR,
|
|
836
|
+
message: String(err),
|
|
837
|
+
});
|
|
838
|
+
if (typeof err === 'string' || (err && err instanceof Error)) {
|
|
839
|
+
span.recordException(err);
|
|
840
|
+
}
|
|
841
|
+
throw err;
|
|
842
|
+
} finally {
|
|
843
|
+
span.end();
|
|
844
|
+
}
|
|
845
|
+
},
|
|
846
|
+
);
|
|
847
|
+
} else {
|
|
848
|
+
await processMessage();
|
|
723
849
|
}
|
|
724
850
|
|
|
725
|
-
if (
|
|
726
|
-
const latency = msgReceivedTime - p2pMessage.timestamp.getTime();
|
|
851
|
+
if (latency !== undefined && topicType !== undefined) {
|
|
727
852
|
this.instrumentation.recordMessageLatency(topicType, latency);
|
|
728
853
|
}
|
|
729
854
|
|
|
@@ -800,27 +925,30 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
800
925
|
}
|
|
801
926
|
|
|
802
927
|
/**
|
|
803
|
-
* Process
|
|
804
|
-
*
|
|
805
|
-
*
|
|
806
|
-
* @param attestation - The attestation to process.
|
|
928
|
+
* Process a checkpoint attestation from a peer.
|
|
929
|
+
* Validates the attestation and adds it to the pool.
|
|
807
930
|
*/
|
|
808
|
-
private async
|
|
809
|
-
|
|
810
|
-
|
|
931
|
+
private async processCheckpointAttestationFromPeer(
|
|
932
|
+
payloadData: Buffer,
|
|
933
|
+
msgId: string,
|
|
934
|
+
source: PeerId,
|
|
935
|
+
): Promise<void> {
|
|
936
|
+
const validationFunc: () => Promise<ReceivedMessageValidationResult<CheckpointAttestation>> = async () => {
|
|
937
|
+
const attestation = CheckpointAttestation.fromBuffer(payloadData);
|
|
811
938
|
const pool = this.mempools.attestationPool;
|
|
812
|
-
const
|
|
813
|
-
const
|
|
939
|
+
const validationResult = await this.validateCheckpointAttestation(source, attestation);
|
|
940
|
+
const isValid = validationResult.result === 'accept';
|
|
941
|
+
const exists = isValid && (await pool.hasCheckpointAttestation(attestation));
|
|
814
942
|
|
|
815
943
|
let canAdd = true;
|
|
816
944
|
if (isValid && !exists) {
|
|
817
945
|
const slot = attestation.payload.header.slotNumber;
|
|
818
946
|
const { committee } = await this.epochCache.getCommittee(slot);
|
|
819
947
|
const committeeSize = committee?.length ?? 0;
|
|
820
|
-
canAdd = await pool.
|
|
948
|
+
canAdd = await pool.canAddCheckpointAttestation(attestation, committeeSize);
|
|
821
949
|
}
|
|
822
950
|
|
|
823
|
-
this.logger.trace(`Validate propagated
|
|
951
|
+
this.logger.trace(`Validate propagated checkpoint attestation`, {
|
|
824
952
|
isValid,
|
|
825
953
|
exists,
|
|
826
954
|
canAdd,
|
|
@@ -828,12 +956,12 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
828
956
|
[Attributes.P2P_ID]: source.toString(),
|
|
829
957
|
});
|
|
830
958
|
|
|
831
|
-
if (
|
|
959
|
+
if (validationResult.result === 'reject') {
|
|
832
960
|
return { result: TopicValidatorResult.Reject };
|
|
833
|
-
} else if (exists) {
|
|
961
|
+
} else if (validationResult.result === 'ignore' || exists) {
|
|
834
962
|
return { result: TopicValidatorResult.Ignore, obj: attestation };
|
|
835
963
|
} else if (!canAdd) {
|
|
836
|
-
this.logger.warn(`Dropping
|
|
964
|
+
this.logger.warn(`Dropping checkpoint attestation due to per-(slot, proposalId) attestation cap`, {
|
|
837
965
|
slot: attestation.payload.header.slotNumber.toString(),
|
|
838
966
|
archive: attestation.archive.toString(),
|
|
839
967
|
source: source.toString(),
|
|
@@ -844,11 +972,11 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
844
972
|
}
|
|
845
973
|
};
|
|
846
974
|
|
|
847
|
-
const { result, obj: attestation } = await this.validateReceivedMessage<
|
|
975
|
+
const { result, obj: attestation } = await this.validateReceivedMessage<CheckpointAttestation>(
|
|
848
976
|
validationFunc,
|
|
849
977
|
msgId,
|
|
850
978
|
source,
|
|
851
|
-
TopicType.
|
|
979
|
+
TopicType.checkpoint_attestation,
|
|
852
980
|
);
|
|
853
981
|
|
|
854
982
|
if (result !== TopicValidatorResult.Accept || !attestation) {
|
|
@@ -856,7 +984,7 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
856
984
|
}
|
|
857
985
|
|
|
858
986
|
this.logger.debug(
|
|
859
|
-
`Received attestation for slot ${attestation.slotNumber} from external peer ${source.toString()}`,
|
|
987
|
+
`Received checkpoint attestation for slot ${attestation.slotNumber} from external peer ${source.toString()}`,
|
|
860
988
|
{
|
|
861
989
|
p2pMessageIdentifier: await attestation.p2pMessageLoggingIdentifier(),
|
|
862
990
|
slot: attestation.slotNumber,
|
|
@@ -865,13 +993,14 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
865
993
|
},
|
|
866
994
|
);
|
|
867
995
|
|
|
868
|
-
await this.mempools.attestationPool.
|
|
996
|
+
await this.mempools.attestationPool.addCheckpointAttestations([attestation]);
|
|
869
997
|
}
|
|
870
998
|
|
|
871
999
|
private async processBlockFromPeer(payloadData: Buffer, msgId: string, source: PeerId): Promise<void> {
|
|
872
1000
|
const validationFunc: () => Promise<ReceivedMessageValidationResult<BlockProposal>> = async () => {
|
|
873
1001
|
const block = BlockProposal.fromBuffer(payloadData);
|
|
874
|
-
const
|
|
1002
|
+
const validationResult = await this.validateBlockProposal(source, block);
|
|
1003
|
+
const isValid = validationResult.result === 'accept';
|
|
875
1004
|
const pool = this.mempools.attestationPool;
|
|
876
1005
|
|
|
877
1006
|
const exists = isValid && (await pool.hasBlockProposal(block));
|
|
@@ -881,13 +1010,13 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
881
1010
|
isValid,
|
|
882
1011
|
exists,
|
|
883
1012
|
canAdd,
|
|
884
|
-
[Attributes.SLOT_NUMBER]: block.
|
|
1013
|
+
[Attributes.SLOT_NUMBER]: block.slotNumber.toString(),
|
|
885
1014
|
[Attributes.P2P_ID]: source.toString(),
|
|
886
1015
|
});
|
|
887
1016
|
|
|
888
|
-
if (
|
|
1017
|
+
if (validationResult.result === 'reject') {
|
|
889
1018
|
return { result: TopicValidatorResult.Reject };
|
|
890
|
-
} else if (exists) {
|
|
1019
|
+
} else if (validationResult.result === 'ignore' || exists) {
|
|
891
1020
|
return { result: TopicValidatorResult.Ignore, obj: block };
|
|
892
1021
|
} else if (!canAdd) {
|
|
893
1022
|
this.peerManager.penalizePeer(source, PeerErrorSeverity.MidToleranceError);
|
|
@@ -917,6 +1046,8 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
917
1046
|
}
|
|
918
1047
|
|
|
919
1048
|
// REVIEW: callback pattern https://github.com/AztecProtocol/aztec-packages/issues/7963
|
|
1049
|
+
// REFACTOR(palla): This method should be moved to the p2p_client or to a separate component,
|
|
1050
|
+
// should not be here as it does not deal with p2p networking.
|
|
920
1051
|
@trackSpan('Libp2pService.processValidBlockProposal', async block => ({
|
|
921
1052
|
[Attributes.SLOT_NUMBER]: block.slotNumber,
|
|
922
1053
|
[Attributes.BLOCK_ARCHIVE]: block.archive.toString(),
|
|
@@ -924,17 +1055,13 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
924
1055
|
}))
|
|
925
1056
|
private async processValidBlockProposal(block: BlockProposal, sender: PeerId) {
|
|
926
1057
|
const slot = block.slotNumber;
|
|
927
|
-
const previousSlot = SlotNumber(slot - 1);
|
|
928
1058
|
this.logger.verbose(`Received block proposal for slot ${slot} from external peer ${sender.toString()}.`, {
|
|
929
1059
|
p2pMessageIdentifier: await block.p2pMessageLoggingIdentifier(),
|
|
930
|
-
slot: block.slotNumber,
|
|
931
|
-
archive: block.archive.toString(),
|
|
932
1060
|
source: sender.toString(),
|
|
1061
|
+
...block.toBlockInfo(),
|
|
933
1062
|
});
|
|
934
|
-
const attestationsForPreviousSlot = await this.mempools.attestationPool.getAttestationsForSlot(previousSlot);
|
|
935
|
-
this.logger.verbose(`Received ${attestationsForPreviousSlot.length} attestations for slot ${previousSlot}`);
|
|
936
1063
|
|
|
937
|
-
// Attempt to add proposal
|
|
1064
|
+
// Attempt to add proposal
|
|
938
1065
|
try {
|
|
939
1066
|
await this.mempools.attestationPool.addBlockProposal(block);
|
|
940
1067
|
} catch (err: unknown) {
|
|
@@ -949,34 +1076,126 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
949
1076
|
}
|
|
950
1077
|
throw err;
|
|
951
1078
|
}
|
|
1079
|
+
|
|
1080
|
+
// Mark the txs in this proposal as non-evictable
|
|
952
1081
|
await this.mempools.txPool.markTxsAsNonEvictable(block.txHashes);
|
|
953
|
-
const attestations = await this.blockReceivedCallback(block, sender);
|
|
954
1082
|
|
|
955
|
-
//
|
|
956
|
-
//
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
1083
|
+
// Call the block received callback to validate the proposal.
|
|
1084
|
+
// Note: Validators do NOT attest to individual blocks, only to checkpoint proposals.
|
|
1085
|
+
const isValid = await this.blockReceivedCallback(block, sender);
|
|
1086
|
+
if (!isValid) {
|
|
1087
|
+
this.logger.warn(`Block proposal validation failed for block ${block.blockNumber}`, block.toBlockInfo());
|
|
1088
|
+
}
|
|
1089
|
+
}
|
|
1090
|
+
|
|
1091
|
+
/**
|
|
1092
|
+
* Handle a gossiped checkpoint proposal.
|
|
1093
|
+
* Validates and processes the checkpoint proposal, then triggers the callback for attestation.
|
|
1094
|
+
*/
|
|
1095
|
+
private async handleGossipedCheckpointProposal(payloadData: Buffer, msgId: string, source: PeerId): Promise<void> {
|
|
1096
|
+
// TODO(palla/mbps): This pattern is repeated across multiple message handlers, consider abstracting it.
|
|
1097
|
+
const validationFunc: () => Promise<ReceivedMessageValidationResult<CheckpointProposal>> = async () => {
|
|
1098
|
+
const checkpoint = CheckpointProposal.fromBuffer(payloadData);
|
|
1099
|
+
const validationResult = await this.validateCheckpointProposal(source, checkpoint);
|
|
1100
|
+
const isValid = validationResult.result === 'accept';
|
|
1101
|
+
const pool = this.mempools.attestationPool;
|
|
1102
|
+
|
|
1103
|
+
const exists = isValid && (await pool.hasCheckpointProposal(checkpoint));
|
|
1104
|
+
const canAdd = isValid && (await pool.canAddCheckpointProposal(checkpoint));
|
|
1105
|
+
|
|
1106
|
+
this.logger.trace(`Validate propagated checkpoint proposal`, {
|
|
1107
|
+
isValid,
|
|
1108
|
+
exists,
|
|
1109
|
+
canAdd,
|
|
1110
|
+
[Attributes.SLOT_NUMBER]: checkpoint.slotNumber.toString(),
|
|
1111
|
+
[Attributes.P2P_ID]: source.toString(),
|
|
1112
|
+
});
|
|
1113
|
+
|
|
1114
|
+
if (validationResult.result === 'reject') {
|
|
1115
|
+
return { result: TopicValidatorResult.Reject };
|
|
1116
|
+
} else if (validationResult.result === 'ignore' || exists) {
|
|
1117
|
+
return { result: TopicValidatorResult.Ignore, obj: checkpoint };
|
|
1118
|
+
} else if (!canAdd) {
|
|
1119
|
+
this.peerManager.penalizePeer(source, PeerErrorSeverity.MidToleranceError);
|
|
1120
|
+
this.logger.warn(`Penalizing peer for checkpoint proposal exceeding per-slot cap`, {
|
|
1121
|
+
slot: checkpoint.slotNumber.toString(),
|
|
1122
|
+
archive: checkpoint.archive.toString(),
|
|
1123
|
+
source: source.toString(),
|
|
963
1124
|
});
|
|
964
|
-
|
|
1125
|
+
return { result: TopicValidatorResult.Reject };
|
|
1126
|
+
} else {
|
|
1127
|
+
return { result: TopicValidatorResult.Accept, obj: checkpoint };
|
|
965
1128
|
}
|
|
1129
|
+
};
|
|
1130
|
+
|
|
1131
|
+
const { result, obj: checkpoint } = await this.validateReceivedMessage<CheckpointProposal>(
|
|
1132
|
+
validationFunc,
|
|
1133
|
+
msgId,
|
|
1134
|
+
source,
|
|
1135
|
+
TopicType.checkpoint_proposal,
|
|
1136
|
+
);
|
|
1137
|
+
|
|
1138
|
+
if (result !== TopicValidatorResult.Accept || !checkpoint) {
|
|
1139
|
+
return;
|
|
966
1140
|
}
|
|
1141
|
+
|
|
1142
|
+
await this.processValidCheckpointProposal(checkpoint, source);
|
|
967
1143
|
}
|
|
968
1144
|
|
|
969
1145
|
/**
|
|
970
|
-
*
|
|
971
|
-
*
|
|
1146
|
+
* Process a validated checkpoint proposal.
|
|
1147
|
+
* Extracts and processes the last block proposal (if present) first, then processes the checkpoint.
|
|
1148
|
+
* The block callback is invoked before the checkpoint callback.
|
|
972
1149
|
*/
|
|
973
|
-
@trackSpan('Libp2pService.
|
|
974
|
-
[Attributes.SLOT_NUMBER]:
|
|
975
|
-
[Attributes.BLOCK_ARCHIVE]:
|
|
976
|
-
[Attributes.P2P_ID]: await
|
|
1150
|
+
@trackSpan('Libp2pService.processValidCheckpointProposal', async checkpoint => ({
|
|
1151
|
+
[Attributes.SLOT_NUMBER]: checkpoint.slotNumber,
|
|
1152
|
+
[Attributes.BLOCK_ARCHIVE]: checkpoint.archive.toString(),
|
|
1153
|
+
[Attributes.P2P_ID]: await checkpoint.p2pMessageLoggingIdentifier().then(i => i.toString()),
|
|
977
1154
|
}))
|
|
978
|
-
private async
|
|
979
|
-
|
|
1155
|
+
private async processValidCheckpointProposal(checkpoint: CheckpointProposal, sender: PeerId) {
|
|
1156
|
+
const slot = checkpoint.slotNumber;
|
|
1157
|
+
this.logger.verbose(`Received checkpoint proposal for slot ${slot} from external peer ${sender.toString()}.`, {
|
|
1158
|
+
p2pMessageIdentifier: await checkpoint.p2pMessageLoggingIdentifier(),
|
|
1159
|
+
slot: checkpoint.slotNumber,
|
|
1160
|
+
archive: checkpoint.archive.toString(),
|
|
1161
|
+
source: sender.toString(),
|
|
1162
|
+
});
|
|
1163
|
+
|
|
1164
|
+
// Extract block proposal before adding to pool (pool stores them separately)
|
|
1165
|
+
const blockProposal = checkpoint.getBlockProposal();
|
|
1166
|
+
|
|
1167
|
+
// Add proposal to the pool (this extracts and stores block proposal separately)
|
|
1168
|
+
await this.mempools.attestationPool.addCheckpointProposal(checkpoint);
|
|
1169
|
+
|
|
1170
|
+
// Mark txs as non-evictable if present (from the last block)
|
|
1171
|
+
if (checkpoint.txHashes.length > 0) {
|
|
1172
|
+
await this.mempools.txPool.markTxsAsNonEvictable(checkpoint.txHashes);
|
|
1173
|
+
}
|
|
1174
|
+
|
|
1175
|
+
// If there was a last block proposal, invoke the block callback first for validation.
|
|
1176
|
+
// Note: The block proposal is already stored in the pool by addCheckpointProposal.
|
|
1177
|
+
if (blockProposal) {
|
|
1178
|
+
const isValid = await this.blockReceivedCallback(blockProposal, sender);
|
|
1179
|
+
if (!isValid) {
|
|
1180
|
+
this.logger.warn(`Block proposal from checkpoint failed validation`, {
|
|
1181
|
+
slot: slot.toString(),
|
|
1182
|
+
archive: checkpoint.archive.toString(),
|
|
1183
|
+
blockNumber: blockProposal.blockNumber.toString(),
|
|
1184
|
+
});
|
|
1185
|
+
return;
|
|
1186
|
+
}
|
|
1187
|
+
}
|
|
1188
|
+
|
|
1189
|
+
// Call the checkpoint received callback with the core version (without lastBlock)
|
|
1190
|
+
// to validate and potentially generate attestations
|
|
1191
|
+
const attestations = await this.checkpointReceivedCallback(checkpoint.toCore(), sender);
|
|
1192
|
+
if (attestations && attestations.length > 0) {
|
|
1193
|
+
// If the callback returned attestations, add them to the pool and propagate them
|
|
1194
|
+
await this.mempools.attestationPool.addCheckpointAttestations(attestations);
|
|
1195
|
+
for (const attestation of attestations) {
|
|
1196
|
+
await this.propagate(attestation);
|
|
1197
|
+
}
|
|
1198
|
+
}
|
|
980
1199
|
}
|
|
981
1200
|
|
|
982
1201
|
/**
|
|
@@ -999,7 +1218,7 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
999
1218
|
* @returns True if the requested block transactions are valid, false otherwise.
|
|
1000
1219
|
*/
|
|
1001
1220
|
@trackSpan('Libp2pService.validateRequestedBlockTxs', request => ({
|
|
1002
|
-
[Attributes.
|
|
1221
|
+
[Attributes.BLOCK_ARCHIVE]: request.archiveRoot.toString(),
|
|
1003
1222
|
}))
|
|
1004
1223
|
private async validateRequestedBlockTxs(
|
|
1005
1224
|
request: BlockTxsRequest,
|
|
@@ -1009,10 +1228,10 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
1009
1228
|
const requestedTxValidator = this.createRequestedTxValidator();
|
|
1010
1229
|
|
|
1011
1230
|
try {
|
|
1012
|
-
if (!response.
|
|
1231
|
+
if (!response.archiveRoot.equals(request.archiveRoot)) {
|
|
1013
1232
|
this.peerManager.penalizePeer(peerId, PeerErrorSeverity.MidToleranceError);
|
|
1014
1233
|
throw new ValidationError(
|
|
1015
|
-
`Received block txs for unexpected
|
|
1234
|
+
`Received block txs for unexpected archive root: expected ${request.archiveRoot.toString()}, got ${response.archiveRoot.toString()}`,
|
|
1016
1235
|
);
|
|
1017
1236
|
}
|
|
1018
1237
|
|
|
@@ -1042,7 +1261,7 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
1042
1261
|
}
|
|
1043
1262
|
|
|
1044
1263
|
// Given proposal (should have locally), ensure returned txs are valid subset and match request indices
|
|
1045
|
-
const proposal = await this.mempools.attestationPool.getBlockProposal(request.
|
|
1264
|
+
const proposal = await this.mempools.attestationPool.getBlockProposal(request.archiveRoot.toString());
|
|
1046
1265
|
if (proposal) {
|
|
1047
1266
|
// Build intersected indices
|
|
1048
1267
|
const intersectIdx = request.txIndices.getTrueIndices().filter(i => response.txIndices.isSet(i));
|
|
@@ -1062,7 +1281,7 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
1062
1281
|
} else {
|
|
1063
1282
|
// No local proposal, cannot check the membership/order of the returned txs
|
|
1064
1283
|
this.logger.warn(
|
|
1065
|
-
`Block proposal not found for
|
|
1284
|
+
`Block proposal not found for archive root ${request.archiveRoot.toString()}; cannot validate membership/order of returned txs`,
|
|
1066
1285
|
);
|
|
1067
1286
|
return false;
|
|
1068
1287
|
}
|
|
@@ -1101,7 +1320,7 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
1101
1320
|
const requested = new Set(requestedTxHash.map(h => h.toString()));
|
|
1102
1321
|
const requestedTxValidator = this.createRequestedTxValidator();
|
|
1103
1322
|
|
|
1104
|
-
//TODO: (mralj) - this is somewhat naive implementation, if single tx is
|
|
1323
|
+
//TODO: (mralj) - this is somewhat naive implementation, if single tx is invalid we consider the whole response invalid.
|
|
1105
1324
|
// I think we should still extract the valid txs and return them, so that we can still use the response.
|
|
1106
1325
|
try {
|
|
1107
1326
|
await Promise.all(responseTx.map(tx => this.validateRequestedTx(tx, peerId, requestedTxValidator, requested)));
|
|
@@ -1164,27 +1383,8 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
1164
1383
|
}
|
|
1165
1384
|
}
|
|
1166
1385
|
|
|
1167
|
-
private createRequestedTxValidator(): TxValidator {
|
|
1168
|
-
return new AggregateTxValidator(
|
|
1169
|
-
new DataTxValidator(),
|
|
1170
|
-
new MetadataTxValidator({
|
|
1171
|
-
l1ChainId: new Fr(this.config.l1ChainId),
|
|
1172
|
-
rollupVersion: new Fr(this.config.rollupVersion),
|
|
1173
|
-
protocolContractsHash,
|
|
1174
|
-
vkTreeRoot: getVKTreeRoot(),
|
|
1175
|
-
}),
|
|
1176
|
-
new TxProofValidator(this.proofVerifier),
|
|
1177
|
-
);
|
|
1178
|
-
}
|
|
1179
|
-
|
|
1180
1386
|
private async validateRequestedTx(tx: Tx, peerId: PeerId, txValidator: TxValidator, requested?: Set<`0x${string}`>) {
|
|
1181
1387
|
const penalize = (severity: PeerErrorSeverity) => this.peerManager.penalizePeer(peerId, severity);
|
|
1182
|
-
|
|
1183
|
-
if (!(await tx.validateTxHash())) {
|
|
1184
|
-
penalize(PeerErrorSeverity.MidToleranceError);
|
|
1185
|
-
throw new ValidationError(`Received tx with invalid hash ${tx.getTxHash().toString()}.`);
|
|
1186
|
-
}
|
|
1187
|
-
|
|
1188
1388
|
if (requested && !requested.has(tx.getTxHash().toString())) {
|
|
1189
1389
|
penalize(PeerErrorSeverity.MidToleranceError);
|
|
1190
1390
|
throw new ValidationError(`Received tx with hash ${tx.getTxHash().toString()} that was not requested.`);
|
|
@@ -1197,6 +1397,13 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
1197
1397
|
}
|
|
1198
1398
|
}
|
|
1199
1399
|
|
|
1400
|
+
private createRequestedTxValidator(): TxValidator {
|
|
1401
|
+
return createTxReqRespValidator(this.proofVerifier, {
|
|
1402
|
+
l1ChainId: this.config.l1ChainId,
|
|
1403
|
+
rollupVersion: this.config.rollupVersion,
|
|
1404
|
+
});
|
|
1405
|
+
}
|
|
1406
|
+
|
|
1200
1407
|
@trackSpan('Libp2pService.validatePropagatedTx', tx => ({
|
|
1201
1408
|
[Attributes.TX_HASH]: tx.getTxHash().toString(),
|
|
1202
1409
|
}))
|
|
@@ -1239,6 +1446,22 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
1239
1446
|
return gasFees;
|
|
1240
1447
|
}
|
|
1241
1448
|
|
|
1449
|
+
/**
|
|
1450
|
+
* Get the BatchTxRequesterLibP2PService dependencies for creating BatchTxRequester instances
|
|
1451
|
+
*/
|
|
1452
|
+
public getBatchTxRequesterService(): BatchTxRequesterLibP2PService {
|
|
1453
|
+
return {
|
|
1454
|
+
reqResp: this.reqresp,
|
|
1455
|
+
connectionSampler: this.reqresp.getConnectionSampler(),
|
|
1456
|
+
txValidatorConfig: {
|
|
1457
|
+
l1ChainId: this.config.l1ChainId,
|
|
1458
|
+
rollupVersion: this.config.rollupVersion,
|
|
1459
|
+
proofVerifier: this.proofVerifier,
|
|
1460
|
+
},
|
|
1461
|
+
peerScoring: this.peerManager,
|
|
1462
|
+
};
|
|
1463
|
+
}
|
|
1464
|
+
|
|
1242
1465
|
public async validate(txs: Tx[]): Promise<void> {
|
|
1243
1466
|
const currentBlockNumber = await this.archiver.getBlockNumber();
|
|
1244
1467
|
|
|
@@ -1289,6 +1512,7 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
1289
1512
|
this.proofVerifier,
|
|
1290
1513
|
!this.config.disableTransactions,
|
|
1291
1514
|
allowedInSetup,
|
|
1515
|
+
this.logger.getBindings(),
|
|
1292
1516
|
);
|
|
1293
1517
|
}
|
|
1294
1518
|
|
|
@@ -1342,15 +1566,18 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
1342
1566
|
return PeerErrorSeverity.HighToleranceError;
|
|
1343
1567
|
}
|
|
1344
1568
|
|
|
1345
|
-
const snapshotValidator = new DoubleSpendTxValidator(
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1569
|
+
const snapshotValidator = new DoubleSpendTxValidator(
|
|
1570
|
+
{
|
|
1571
|
+
nullifiersExist: async (nullifiers: Buffer[]) => {
|
|
1572
|
+
const merkleTree = this.worldStateSynchronizer.getSnapshot(
|
|
1573
|
+
BlockNumber(blockNumber - this.config.doubleSpendSeverePeerPenaltyWindow),
|
|
1574
|
+
);
|
|
1575
|
+
const indices = await merkleTree.findLeafIndices(MerkleTreeId.NULLIFIER_TREE, nullifiers);
|
|
1576
|
+
return indices.map(index => index !== undefined);
|
|
1577
|
+
},
|
|
1352
1578
|
},
|
|
1353
|
-
|
|
1579
|
+
this.logger.getBindings(),
|
|
1580
|
+
);
|
|
1354
1581
|
|
|
1355
1582
|
const validSnapshot = await snapshotValidator.validateTx(tx);
|
|
1356
1583
|
if (validSnapshot.result !== 'valid') {
|
|
@@ -1361,24 +1588,28 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
1361
1588
|
}
|
|
1362
1589
|
|
|
1363
1590
|
/**
|
|
1364
|
-
* Validate
|
|
1591
|
+
* Validate a checkpoint attestation.
|
|
1365
1592
|
*
|
|
1366
|
-
* @param attestation - The attestation to validate.
|
|
1367
|
-
* @returns True if the attestation is valid, false otherwise.
|
|
1593
|
+
* @param attestation - The checkpoint attestation to validate.
|
|
1594
|
+
* @returns True if the checkpoint attestation is valid, false otherwise.
|
|
1368
1595
|
*/
|
|
1369
|
-
@trackSpan('Libp2pService.
|
|
1596
|
+
@trackSpan('Libp2pService.validateCheckpointAttestation', async (_, attestation) => ({
|
|
1370
1597
|
[Attributes.SLOT_NUMBER]: attestation.payload.header.slotNumber,
|
|
1371
1598
|
[Attributes.BLOCK_ARCHIVE]: attestation.archive.toString(),
|
|
1372
1599
|
[Attributes.P2P_ID]: await attestation.p2pMessageLoggingIdentifier().then(i => i.toString()),
|
|
1373
1600
|
}))
|
|
1374
|
-
public async
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1601
|
+
public async validateCheckpointAttestation(
|
|
1602
|
+
peerId: PeerId,
|
|
1603
|
+
attestation: CheckpointAttestation,
|
|
1604
|
+
): Promise<P2PValidationResult> {
|
|
1605
|
+
const result = await this.checkpointAttestationValidator.validate(attestation);
|
|
1606
|
+
|
|
1607
|
+
if (result.result === 'reject') {
|
|
1608
|
+
this.logger.debug(`Penalizing peer ${peerId} for checkpoint attestation validation failure`);
|
|
1609
|
+
this.peerManager.penalizePeer(peerId, result.severity);
|
|
1379
1610
|
}
|
|
1380
1611
|
|
|
1381
|
-
return
|
|
1612
|
+
return result;
|
|
1382
1613
|
}
|
|
1383
1614
|
|
|
1384
1615
|
/**
|
|
@@ -1388,17 +1619,40 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
1388
1619
|
* @returns True if the block proposal is valid, false otherwise.
|
|
1389
1620
|
*/
|
|
1390
1621
|
@trackSpan('Libp2pService.validateBlockProposal', (_peerId, block) => ({
|
|
1391
|
-
[Attributes.SLOT_NUMBER]: block.
|
|
1622
|
+
[Attributes.SLOT_NUMBER]: block.slotNumber.toString(),
|
|
1392
1623
|
}))
|
|
1393
|
-
public async validateBlockProposal(peerId: PeerId, block: BlockProposal): Promise<
|
|
1394
|
-
const
|
|
1395
|
-
|
|
1624
|
+
public async validateBlockProposal(peerId: PeerId, block: BlockProposal): Promise<P2PValidationResult> {
|
|
1625
|
+
const result = await this.blockProposalValidator.validate(block);
|
|
1626
|
+
|
|
1627
|
+
if (result.result === 'reject') {
|
|
1396
1628
|
this.logger.debug(`Penalizing peer ${peerId} for block proposal validation failure`);
|
|
1397
|
-
this.peerManager.penalizePeer(peerId, severity);
|
|
1398
|
-
return false;
|
|
1629
|
+
this.peerManager.penalizePeer(peerId, result.severity);
|
|
1399
1630
|
}
|
|
1400
1631
|
|
|
1401
|
-
return
|
|
1632
|
+
return result;
|
|
1633
|
+
}
|
|
1634
|
+
|
|
1635
|
+
/**
|
|
1636
|
+
* Validate a checkpoint proposal.
|
|
1637
|
+
*
|
|
1638
|
+
* @param checkpoint - The checkpoint proposal to validate.
|
|
1639
|
+
* @returns True if the checkpoint proposal is valid, false otherwise.
|
|
1640
|
+
*/
|
|
1641
|
+
@trackSpan('Libp2pService.validateCheckpointProposal', (_peerId, checkpoint) => ({
|
|
1642
|
+
[Attributes.SLOT_NUMBER]: checkpoint.slotNumber.toString(),
|
|
1643
|
+
}))
|
|
1644
|
+
public async validateCheckpointProposal(
|
|
1645
|
+
peerId: PeerId,
|
|
1646
|
+
checkpoint: CheckpointProposal,
|
|
1647
|
+
): Promise<P2PValidationResult> {
|
|
1648
|
+
const result = await this.checkpointProposalValidator.validate(checkpoint);
|
|
1649
|
+
|
|
1650
|
+
if (result.result === 'reject') {
|
|
1651
|
+
this.logger.debug(`Penalizing peer ${peerId} for checkpoint proposal validation failure`);
|
|
1652
|
+
this.peerManager.penalizePeer(peerId, result.severity);
|
|
1653
|
+
}
|
|
1654
|
+
|
|
1655
|
+
return result;
|
|
1402
1656
|
}
|
|
1403
1657
|
|
|
1404
1658
|
public getPeerScore(peerId: PeerId): number {
|