@aztec/p2p 0.0.1-commit.993d52e → 0.0.1-commit.9badcec54
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/README.md +129 -3
- package/dest/client/factory.d.ts +2 -2
- package/dest/client/factory.d.ts.map +1 -1
- package/dest/client/factory.js +24 -10
- package/dest/client/interface.d.ts +9 -2
- package/dest/client/interface.d.ts.map +1 -1
- package/dest/client/p2p_client.d.ts +3 -2
- package/dest/client/p2p_client.d.ts.map +1 -1
- package/dest/client/p2p_client.js +46 -38
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.js +17 -6
- package/dest/config.d.ts +124 -106
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +87 -38
- package/dest/errors/p2p-service.error.d.ts +9 -0
- package/dest/errors/p2p-service.error.d.ts.map +1 -0
- package/dest/errors/p2p-service.error.js +10 -0
- package/dest/index.d.ts +1 -2
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +0 -1
- package/dest/mem_pools/attestation_pool/attestation_pool.d.ts +7 -5
- package/dest/mem_pools/attestation_pool/attestation_pool.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/attestation_pool.js +16 -9
- package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.js +6 -6
- package/dest/mem_pools/index.d.ts +1 -2
- package/dest/mem_pools/index.d.ts.map +1 -1
- package/dest/mem_pools/instrumentation.d.ts +4 -2
- package/dest/mem_pools/instrumentation.d.ts.map +1 -1
- package/dest/mem_pools/instrumentation.js +16 -14
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.d.ts +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.js +2 -1
- package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.js +2 -2
- package/dest/mem_pools/tx_pool_v2/interfaces.d.ts +9 -5
- package/dest/mem_pools/tx_pool_v2/interfaces.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/interfaces.js +1 -0
- package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts +13 -7
- package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/tx_metadata.js +13 -3
- package/dest/mem_pools/tx_pool_v2/tx_pool_indices.d.ts +1 -1
- package/dest/mem_pools/tx_pool_v2/tx_pool_indices.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/tx_pool_indices.js +26 -43
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts +4 -2
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2.js +6 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts +2 -1
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.js +29 -5
- package/dest/msg_validators/attestation_validator/attestation_validator.d.ts +5 -2
- package/dest/msg_validators/attestation_validator/attestation_validator.d.ts.map +1 -1
- package/dest/msg_validators/attestation_validator/attestation_validator.js +20 -11
- package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.d.ts +4 -2
- package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.d.ts.map +1 -1
- package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.js +2 -2
- package/dest/msg_validators/clock_tolerance.d.ts +12 -1
- package/dest/msg_validators/clock_tolerance.d.ts.map +1 -1
- package/dest/msg_validators/clock_tolerance.js +54 -3
- package/dest/msg_validators/proposal_validator/block_proposal_validator.d.ts +6 -4
- package/dest/msg_validators/proposal_validator/block_proposal_validator.d.ts.map +1 -1
- package/dest/msg_validators/proposal_validator/block_proposal_validator.js +10 -2
- package/dest/msg_validators/proposal_validator/checkpoint_proposal_validator.d.ts +6 -4
- package/dest/msg_validators/proposal_validator/checkpoint_proposal_validator.d.ts.map +1 -1
- package/dest/msg_validators/proposal_validator/checkpoint_proposal_validator.js +16 -2
- package/dest/msg_validators/proposal_validator/proposal_validator.d.ts +14 -9
- package/dest/msg_validators/proposal_validator/proposal_validator.d.ts.map +1 -1
- package/dest/msg_validators/proposal_validator/proposal_validator.js +65 -55
- package/dest/msg_validators/tx_validator/allowed_public_setup.d.ts +2 -1
- package/dest/msg_validators/tx_validator/allowed_public_setup.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/allowed_public_setup.js +24 -20
- package/dest/msg_validators/tx_validator/allowed_setup_helpers.d.ts +17 -0
- package/dest/msg_validators/tx_validator/allowed_setup_helpers.d.ts.map +1 -0
- package/dest/msg_validators/tx_validator/allowed_setup_helpers.js +24 -0
- package/dest/msg_validators/tx_validator/archive_cache.js +1 -1
- package/dest/msg_validators/tx_validator/contract_instance_validator.d.ts +9 -0
- package/dest/msg_validators/tx_validator/contract_instance_validator.d.ts.map +1 -0
- package/dest/msg_validators/tx_validator/contract_instance_validator.js +48 -0
- package/dest/msg_validators/tx_validator/data_validator.d.ts +1 -1
- package/dest/msg_validators/tx_validator/data_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/data_validator.js +35 -2
- package/dest/msg_validators/tx_validator/factory.d.ts +23 -4
- package/dest/msg_validators/tx_validator/factory.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/factory.js +36 -10
- package/dest/msg_validators/tx_validator/fee_payer_balance.d.ts +1 -1
- package/dest/msg_validators/tx_validator/fee_payer_balance.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/fee_payer_balance.js +6 -2
- package/dest/msg_validators/tx_validator/gas_validator.d.ts +13 -4
- package/dest/msg_validators/tx_validator/gas_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/gas_validator.js +49 -17
- 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 +1 -1
- package/dest/msg_validators/tx_validator/metadata_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/metadata_validator.js +4 -4
- package/dest/msg_validators/tx_validator/phases_validator.d.ts +22 -2
- package/dest/msg_validators/tx_validator/phases_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/phases_validator.js +72 -24
- 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 +5 -5
- package/dest/services/dummy_service.d.ts +6 -3
- package/dest/services/dummy_service.d.ts.map +1 -1
- package/dest/services/dummy_service.js +6 -1
- package/dest/services/encoding.d.ts +5 -1
- package/dest/services/encoding.d.ts.map +1 -1
- package/dest/services/encoding.js +7 -1
- package/dest/services/gossipsub/topic_score_params.d.ts +13 -2
- package/dest/services/gossipsub/topic_score_params.d.ts.map +1 -1
- package/dest/services/gossipsub/topic_score_params.js +21 -4
- package/dest/services/libp2p/instrumentation.d.ts +3 -1
- package/dest/services/libp2p/instrumentation.d.ts.map +1 -1
- package/dest/services/libp2p/instrumentation.js +14 -0
- package/dest/services/libp2p/libp2p_service.d.ts +15 -25
- package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
- package/dest/services/libp2p/libp2p_service.js +176 -127
- package/dest/services/peer-manager/metrics.d.ts +3 -1
- package/dest/services/peer-manager/metrics.d.ts.map +1 -1
- package/dest/services/peer-manager/metrics.js +6 -0
- package/dest/services/peer-manager/peer_manager.d.ts +6 -2
- package/dest/services/peer-manager/peer_manager.d.ts.map +1 -1
- package/dest/services/peer-manager/peer_manager.js +39 -11
- package/dest/services/peer-manager/peer_scoring.d.ts +7 -2
- package/dest/services/peer-manager/peer_scoring.d.ts.map +1 -1
- package/dest/services/peer-manager/peer_scoring.js +32 -10
- package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts +11 -8
- package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts.map +1 -1
- package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.js +82 -101
- package/dest/services/reqresp/batch-tx-requester/interface.d.ts +3 -2
- package/dest/services/reqresp/batch-tx-requester/interface.d.ts.map +1 -1
- package/dest/services/reqresp/batch-tx-requester/missing_txs.d.ts +5 -4
- package/dest/services/reqresp/batch-tx-requester/missing_txs.d.ts.map +1 -1
- package/dest/services/reqresp/batch-tx-requester/missing_txs.js +13 -7
- package/dest/services/reqresp/batch-tx-requester/peer_collection.d.ts +19 -11
- package/dest/services/reqresp/batch-tx-requester/peer_collection.d.ts.map +1 -1
- package/dest/services/reqresp/batch-tx-requester/peer_collection.js +52 -15
- package/dest/services/reqresp/config.d.ts +3 -3
- package/dest/services/reqresp/config.d.ts.map +1 -1
- package/dest/services/reqresp/interface.d.ts +14 -9
- package/dest/services/reqresp/interface.d.ts.map +1 -1
- package/dest/services/reqresp/interface.js +10 -11
- package/dest/services/reqresp/metrics.d.ts +1 -1
- package/dest/services/reqresp/metrics.d.ts.map +1 -1
- package/dest/services/reqresp/metrics.js +0 -1
- package/dest/services/reqresp/protocols/index.d.ts +1 -2
- package/dest/services/reqresp/protocols/index.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/index.js +0 -1
- package/dest/services/reqresp/protocols/tx.d.ts +1 -1
- package/dest/services/reqresp/protocols/tx.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/tx.js +1 -3
- package/dest/services/reqresp/rate-limiter/rate_limiter.d.ts +5 -4
- package/dest/services/reqresp/rate-limiter/rate_limiter.d.ts.map +1 -1
- package/dest/services/reqresp/rate-limiter/rate_limiter.js +10 -8
- package/dest/services/reqresp/rate-limiter/rate_limits.d.ts +1 -1
- package/dest/services/reqresp/rate-limiter/rate_limits.d.ts.map +1 -1
- package/dest/services/reqresp/rate-limiter/rate_limits.js +0 -10
- package/dest/services/reqresp/reqresp.d.ts +4 -2
- package/dest/services/reqresp/reqresp.d.ts.map +1 -1
- package/dest/services/reqresp/reqresp.js +30 -12
- package/dest/services/service.d.ts +5 -2
- package/dest/services/service.d.ts.map +1 -1
- package/dest/services/tx_collection/fast_tx_collection.d.ts +1 -4
- package/dest/services/tx_collection/fast_tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/fast_tx_collection.js +57 -73
- package/dest/services/tx_collection/file_store_tx_source.d.ts +5 -4
- package/dest/services/tx_collection/file_store_tx_source.d.ts.map +1 -1
- package/dest/services/tx_collection/file_store_tx_source.js +39 -29
- package/dest/services/tx_collection/proposal_tx_collector.d.ts +6 -7
- package/dest/services/tx_collection/proposal_tx_collector.d.ts.map +1 -1
- package/dest/services/tx_collection/proposal_tx_collector.js +4 -4
- package/dest/services/tx_collection/request_tracker.d.ts +53 -0
- package/dest/services/tx_collection/request_tracker.d.ts.map +1 -0
- package/dest/services/tx_collection/request_tracker.js +84 -0
- package/dest/services/tx_collection/slow_tx_collection.js +1 -1
- package/dest/services/tx_collection/tx_collection.d.ts +3 -6
- package/dest/services/tx_collection/tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/tx_source.d.ts +6 -5
- package/dest/services/tx_collection/tx_source.d.ts.map +1 -1
- package/dest/services/tx_collection/tx_source.js +9 -7
- package/dest/test-helpers/make-test-p2p-clients.d.ts +1 -1
- package/dest/test-helpers/make-test-p2p-clients.d.ts.map +1 -1
- package/dest/test-helpers/mock-pubsub.d.ts +11 -3
- package/dest/test-helpers/mock-pubsub.d.ts.map +1 -1
- package/dest/test-helpers/mock-pubsub.js +35 -10
- package/dest/test-helpers/reqresp-nodes.d.ts +1 -1
- package/dest/test-helpers/reqresp-nodes.d.ts.map +1 -1
- package/dest/test-helpers/reqresp-nodes.js +1 -2
- package/dest/test-helpers/testbench-utils.d.ts +1 -1
- package/dest/test-helpers/testbench-utils.d.ts.map +1 -1
- package/dest/test-helpers/testbench-utils.js +23 -3
- package/dest/testbench/p2p_client_testbench_worker.js +68 -16
- package/dest/testbench/worker_client_manager.d.ts +10 -1
- package/dest/testbench/worker_client_manager.d.ts.map +1 -1
- package/dest/testbench/worker_client_manager.js +55 -3
- package/dest/util.d.ts +1 -1
- package/package.json +14 -14
- package/src/client/factory.ts +43 -14
- package/src/client/interface.ts +9 -1
- package/src/client/p2p_client.ts +50 -39
- package/src/client/test/tx_proposal_collector/proposal_tx_collector_worker.ts +19 -9
- package/src/config.ts +129 -45
- package/src/errors/p2p-service.error.ts +11 -0
- package/src/index.ts +0 -1
- package/src/mem_pools/attestation_pool/attestation_pool.ts +17 -12
- package/src/mem_pools/attestation_pool/attestation_pool_test_suite.ts +6 -6
- package/src/mem_pools/index.ts +0 -3
- package/src/mem_pools/instrumentation.ts +17 -13
- package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.ts +2 -1
- package/src/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.ts +3 -3
- package/src/mem_pools/tx_pool_v2/interfaces.ts +9 -4
- package/src/mem_pools/tx_pool_v2/tx_metadata.ts +23 -7
- package/src/mem_pools/tx_pool_v2/tx_pool_indices.ts +29 -43
- package/src/mem_pools/tx_pool_v2/tx_pool_v2.ts +16 -1
- package/src/mem_pools/tx_pool_v2/tx_pool_v2_impl.ts +31 -5
- package/src/msg_validators/attestation_validator/README.md +49 -0
- package/src/msg_validators/attestation_validator/attestation_validator.ts +21 -9
- package/src/msg_validators/attestation_validator/fisherman_attestation_validator.ts +4 -1
- package/src/msg_validators/clock_tolerance.ts +72 -3
- package/src/msg_validators/proposal_validator/README.md +123 -0
- package/src/msg_validators/proposal_validator/block_proposal_validator.ts +17 -4
- package/src/msg_validators/proposal_validator/checkpoint_proposal_validator.ts +23 -7
- package/src/msg_validators/proposal_validator/proposal_validator.ts +74 -58
- package/src/msg_validators/tx_validator/README.md +5 -1
- package/src/msg_validators/tx_validator/allowed_public_setup.ts +22 -27
- package/src/msg_validators/tx_validator/allowed_setup_helpers.ts +31 -0
- package/src/msg_validators/tx_validator/archive_cache.ts +1 -1
- package/src/msg_validators/tx_validator/contract_instance_validator.ts +56 -0
- package/src/msg_validators/tx_validator/data_validator.ts +42 -1
- package/src/msg_validators/tx_validator/factory.ts +43 -3
- package/src/msg_validators/tx_validator/fee_payer_balance.ts +6 -2
- package/src/msg_validators/tx_validator/gas_validator.ts +65 -16
- package/src/msg_validators/tx_validator/index.ts +1 -0
- package/src/msg_validators/tx_validator/metadata_validator.ts +12 -4
- package/src/msg_validators/tx_validator/phases_validator.ts +82 -27
- package/src/services/data_store.ts +5 -13
- package/src/services/dummy_service.ts +8 -2
- package/src/services/encoding.ts +9 -1
- package/src/services/gossipsub/topic_score_params.ts +36 -4
- package/src/services/libp2p/instrumentation.ts +14 -0
- package/src/services/libp2p/libp2p_service.ts +175 -143
- package/src/services/peer-manager/metrics.ts +7 -0
- package/src/services/peer-manager/peer_manager.ts +45 -11
- package/src/services/peer-manager/peer_scoring.ts +27 -5
- package/src/services/reqresp/README.md +229 -0
- package/src/services/reqresp/batch-tx-requester/README.md +46 -7
- package/src/services/reqresp/batch-tx-requester/batch_tx_requester.ts +78 -111
- package/src/services/reqresp/batch-tx-requester/interface.ts +2 -1
- package/src/services/reqresp/batch-tx-requester/missing_txs.ts +13 -6
- package/src/services/reqresp/batch-tx-requester/peer_collection.ts +68 -24
- package/src/services/reqresp/config.ts +2 -2
- package/src/services/reqresp/interface.ts +21 -11
- package/src/services/reqresp/metrics.ts +0 -1
- package/src/services/reqresp/protocols/index.ts +0 -1
- package/src/services/reqresp/protocols/tx.ts +1 -3
- package/src/services/reqresp/rate-limiter/rate_limiter.ts +13 -9
- package/src/services/reqresp/rate-limiter/rate_limits.ts +0 -10
- package/src/services/reqresp/reqresp.ts +40 -13
- package/src/services/service.ts +6 -1
- package/src/services/tx_collection/fast_tx_collection.ts +57 -83
- package/src/services/tx_collection/file_store_tx_source.ts +43 -31
- package/src/services/tx_collection/proposal_tx_collector.ts +8 -13
- package/src/services/tx_collection/request_tracker.ts +127 -0
- package/src/services/tx_collection/slow_tx_collection.ts +1 -1
- package/src/services/tx_collection/tx_collection.ts +3 -5
- package/src/services/tx_collection/tx_source.ts +8 -7
- package/src/test-helpers/make-test-p2p-clients.ts +1 -1
- package/src/test-helpers/mock-pubsub.ts +31 -5
- package/src/test-helpers/reqresp-nodes.ts +3 -3
- package/src/test-helpers/testbench-utils.ts +30 -3
- package/src/testbench/p2p_client_testbench_worker.ts +72 -15
- package/src/testbench/worker_client_manager.ts +68 -6
- package/src/util.ts +1 -1
- package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.d.ts +0 -125
- package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.js +0 -596
- package/dest/mem_pools/tx_pool/eviction/eviction_manager.d.ts +0 -32
- package/dest/mem_pools/tx_pool/eviction/eviction_manager.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/eviction/eviction_manager.js +0 -112
- package/dest/mem_pools/tx_pool/eviction/eviction_strategy.d.ts +0 -157
- package/dest/mem_pools/tx_pool/eviction/eviction_strategy.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/eviction/eviction_strategy.js +0 -52
- package/dest/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.d.ts +0 -16
- package/dest/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.js +0 -122
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.d.ts +0 -17
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.js +0 -84
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.d.ts +0 -19
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.js +0 -78
- package/dest/mem_pools/tx_pool/eviction/low_priority_eviction_rule.d.ts +0 -26
- package/dest/mem_pools/tx_pool/eviction/low_priority_eviction_rule.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/eviction/low_priority_eviction_rule.js +0 -84
- package/dest/mem_pools/tx_pool/eviction/nullifier_conflict_pre_add_rule.d.ts +0 -25
- package/dest/mem_pools/tx_pool/eviction/nullifier_conflict_pre_add_rule.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/eviction/nullifier_conflict_pre_add_rule.js +0 -57
- package/dest/mem_pools/tx_pool/index.d.ts +0 -3
- package/dest/mem_pools/tx_pool/index.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/index.js +0 -2
- package/dest/mem_pools/tx_pool/priority.d.ts +0 -12
- package/dest/mem_pools/tx_pool/priority.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/priority.js +0 -15
- package/dest/mem_pools/tx_pool/tx_pool.d.ts +0 -127
- package/dest/mem_pools/tx_pool/tx_pool.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/tx_pool.js +0 -3
- package/dest/mem_pools/tx_pool/tx_pool_test_suite.d.ts +0 -7
- package/dest/mem_pools/tx_pool/tx_pool_test_suite.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/tx_pool_test_suite.js +0 -400
- package/dest/msg_validators/proposal_validator/proposal_validator_test_suite.d.ts +0 -24
- package/dest/msg_validators/proposal_validator/proposal_validator_test_suite.d.ts.map +0 -1
- package/dest/msg_validators/proposal_validator/proposal_validator_test_suite.js +0 -378
- package/dest/services/reqresp/protocols/block.d.ts +0 -9
- package/dest/services/reqresp/protocols/block.d.ts.map +0 -1
- package/dest/services/reqresp/protocols/block.js +0 -32
- package/dest/services/tx_collection/missing_txs_tracker.d.ts +0 -32
- package/dest/services/tx_collection/missing_txs_tracker.d.ts.map +0 -1
- package/dest/services/tx_collection/missing_txs_tracker.js +0 -27
- package/src/mem_pools/tx_pool/README.md +0 -270
- package/src/mem_pools/tx_pool/aztec_kv_tx_pool.ts +0 -746
- package/src/mem_pools/tx_pool/eviction/eviction_manager.ts +0 -132
- package/src/mem_pools/tx_pool/eviction/eviction_strategy.ts +0 -208
- package/src/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.ts +0 -162
- package/src/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.ts +0 -104
- package/src/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.ts +0 -93
- package/src/mem_pools/tx_pool/eviction/low_priority_eviction_rule.ts +0 -106
- package/src/mem_pools/tx_pool/eviction/nullifier_conflict_pre_add_rule.ts +0 -75
- package/src/mem_pools/tx_pool/index.ts +0 -2
- package/src/mem_pools/tx_pool/priority.ts +0 -20
- package/src/mem_pools/tx_pool/tx_pool.ts +0 -141
- package/src/mem_pools/tx_pool/tx_pool_test_suite.ts +0 -319
- package/src/msg_validators/proposal_validator/proposal_validator_test_suite.ts +0 -373
- package/src/services/reqresp/protocols/block.ts +0 -37
- package/src/services/tx_collection/missing_txs_tracker.ts +0 -52
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { EpochCacheInterface } from '@aztec/epoch-cache';
|
|
2
2
|
import { BlockNumber, type SlotNumber } from '@aztec/foundation/branded-types';
|
|
3
|
-
import {
|
|
3
|
+
import { maxBy } from '@aztec/foundation/collection';
|
|
4
4
|
import { type Logger, createLibp2pComponentLogger, createLogger } from '@aztec/foundation/log';
|
|
5
5
|
import { RunningPromise } from '@aztec/foundation/running-promise';
|
|
6
6
|
import { Timer } from '@aztec/foundation/timer';
|
|
7
7
|
import type { AztecAsyncKVStore } from '@aztec/kv-store';
|
|
8
8
|
import { protocolContractsHash } from '@aztec/protocol-contracts';
|
|
9
|
-
import type { EthAddress,
|
|
9
|
+
import type { EthAddress, L2BlockSource } from '@aztec/stdlib/block';
|
|
10
10
|
import type { ContractDataSource } from '@aztec/stdlib/contract';
|
|
11
11
|
import { GasFees } from '@aztec/stdlib/gas';
|
|
12
12
|
import type { ClientProtocolCircuitVerifier, PeerInfo, WorldStateSynchronizer } from '@aztec/stdlib/interfaces/server';
|
|
@@ -17,8 +17,8 @@ import {
|
|
|
17
17
|
type CheckpointProposalCore,
|
|
18
18
|
type Gossipable,
|
|
19
19
|
P2PMessage,
|
|
20
|
-
type ValidationResult as P2PValidationResult,
|
|
21
20
|
PeerErrorSeverity,
|
|
21
|
+
PeerErrorSeverityByHarshness,
|
|
22
22
|
TopicType,
|
|
23
23
|
createTopicString,
|
|
24
24
|
getTopicsForConfig,
|
|
@@ -57,6 +57,7 @@ import { ENR } from '@nethermindeth/enr';
|
|
|
57
57
|
import { createLibp2p } from 'libp2p';
|
|
58
58
|
|
|
59
59
|
import type { P2PConfig } from '../../config.js';
|
|
60
|
+
import { CheckpointProposalReceivedCallbackNotRegisteredError } from '../../errors/p2p-service.error.js';
|
|
60
61
|
import type { MemPools } from '../../mem_pools/interface.js';
|
|
61
62
|
import {
|
|
62
63
|
BlockProposalValidator,
|
|
@@ -103,7 +104,6 @@ import {
|
|
|
103
104
|
ValidationError,
|
|
104
105
|
pingHandler,
|
|
105
106
|
reqGoodbyeHandler,
|
|
106
|
-
reqRespBlockHandler,
|
|
107
107
|
reqRespBlockTxsHandler,
|
|
108
108
|
reqRespStatusHandler,
|
|
109
109
|
reqRespTxHandler,
|
|
@@ -129,7 +129,7 @@ type ValidationOutcome = { allPassed: true } | { allPassed: false; failure: Vali
|
|
|
129
129
|
// REFACTOR: Unify with the type above
|
|
130
130
|
type ReceivedMessageValidationResult<T, M = undefined> =
|
|
131
131
|
| { obj: T; result: Exclude<TopicValidatorResult, TopicValidatorResult.Reject>; metadata?: M }
|
|
132
|
-
| { obj?: T; result: TopicValidatorResult.Reject; metadata?: M };
|
|
132
|
+
| { obj?: T; result: TopicValidatorResult.Reject; metadata?: M; severity: PeerErrorSeverity };
|
|
133
133
|
|
|
134
134
|
/**
|
|
135
135
|
* Lib P2P implementation of the P2PService interface.
|
|
@@ -170,7 +170,13 @@ export class LibP2PService extends WithTracer implements P2PService {
|
|
|
170
170
|
* @param checkpoint - The checkpoint proposal received from the peer.
|
|
171
171
|
* @returns The attestations for the checkpoint, if any.
|
|
172
172
|
*/
|
|
173
|
-
private
|
|
173
|
+
private allNodesCheckpointReceivedCallback: P2PCheckpointReceivedCallback;
|
|
174
|
+
/**
|
|
175
|
+
* Callback for when a checkpoint proposal is received - specifically for validators - from a peer.
|
|
176
|
+
* @param checkpoint - The checkpoint proposal received from the peer.
|
|
177
|
+
* @returns The attestations for the checkpoint, if any.
|
|
178
|
+
*/
|
|
179
|
+
private validatorCheckpointReceivedCallback: P2PCheckpointReceivedCallback;
|
|
174
180
|
|
|
175
181
|
private gossipSubEventHandler: (e: CustomEvent<GossipsubMessage>) => void;
|
|
176
182
|
|
|
@@ -222,34 +228,39 @@ export class LibP2PService extends WithTracer implements P2PService {
|
|
|
222
228
|
this.protocolVersion,
|
|
223
229
|
);
|
|
224
230
|
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
maxTxsPerBlock: config.maxTxsPerBlock,
|
|
228
|
-
});
|
|
229
|
-
this.checkpointProposalValidator = new CheckpointProposalValidator(epochCache, {
|
|
231
|
+
const p2pPropagationTime = config.attestationPropagationTime;
|
|
232
|
+
const proposalValidatorOpts = {
|
|
230
233
|
txsPermitted: !config.disableTransactions,
|
|
231
|
-
maxTxsPerBlock: config.
|
|
232
|
-
|
|
234
|
+
maxTxsPerBlock: config.validateMaxTxsPerBlock ?? config.validateMaxTxsPerCheckpoint,
|
|
235
|
+
p2pPropagationTime,
|
|
236
|
+
};
|
|
237
|
+
this.blockProposalValidator = new BlockProposalValidator(epochCache, proposalValidatorOpts);
|
|
238
|
+
this.checkpointProposalValidator = new CheckpointProposalValidator(epochCache, proposalValidatorOpts);
|
|
233
239
|
this.checkpointAttestationValidator = config.fishermanMode
|
|
234
|
-
? new FishermanAttestationValidator(epochCache, mempools.attestationPool, telemetry
|
|
235
|
-
|
|
240
|
+
? new FishermanAttestationValidator(epochCache, mempools.attestationPool, telemetry, {
|
|
241
|
+
l1PublishingTime: config.l1PublishingTime,
|
|
242
|
+
})
|
|
243
|
+
: new CheckpointAttestationValidator(epochCache, { l1PublishingTime: config.l1PublishingTime });
|
|
236
244
|
|
|
237
245
|
this.gossipSubEventHandler = this.handleGossipSubEvent.bind(this);
|
|
238
246
|
|
|
239
247
|
this.blockReceivedCallback = async (block: BlockProposal): Promise<boolean> => {
|
|
240
|
-
this.logger.
|
|
241
|
-
`Handler not yet registered
|
|
248
|
+
this.logger.warn(
|
|
249
|
+
`Handler for block received not yet registered on P2P service. Received block ${block.blockNumber} for slot ${block.slotNumber} from peer.`,
|
|
242
250
|
{ p2pMessageIdentifier: await block.p2pMessageLoggingIdentifier() },
|
|
243
251
|
);
|
|
244
|
-
return
|
|
252
|
+
return true;
|
|
245
253
|
};
|
|
246
254
|
|
|
247
|
-
this.
|
|
248
|
-
|
|
255
|
+
this.allNodesCheckpointReceivedCallback = (
|
|
256
|
+
_checkpoint: CheckpointProposalCore,
|
|
257
|
+
): Promise<CheckpointAttestation[] | undefined> => {
|
|
258
|
+
throw new CheckpointProposalReceivedCallbackNotRegisteredError();
|
|
259
|
+
};
|
|
260
|
+
|
|
261
|
+
this.validatorCheckpointReceivedCallback = (
|
|
262
|
+
_checkpoint: CheckpointProposalCore,
|
|
249
263
|
): Promise<CheckpointAttestation[] | undefined> => {
|
|
250
|
-
this.logger.debug(
|
|
251
|
-
`Handler not yet registered: Checkpoint received callback not set. Received checkpoint for slot ${checkpoint.slotNumber} from peer.`,
|
|
252
|
-
);
|
|
253
264
|
return Promise.resolve(undefined);
|
|
254
265
|
};
|
|
255
266
|
}
|
|
@@ -339,9 +350,12 @@ export class LibP2PService extends WithTracer implements P2PService {
|
|
|
339
350
|
const l1Constants = epochCache.getL1Constants();
|
|
340
351
|
const topicScoreParams = createAllTopicScoreParams(protocolVersion, {
|
|
341
352
|
slotDurationMs: l1Constants.slotDuration * 1000,
|
|
353
|
+
ethereumSlotDuration: l1Constants.ethereumSlotDuration,
|
|
342
354
|
heartbeatIntervalMs: config.gossipsubInterval,
|
|
343
355
|
targetCommitteeSize: l1Constants.targetCommitteeSize,
|
|
344
356
|
blockDurationMs: config.blockDurationMs,
|
|
357
|
+
l1PublishingTime: config.l1PublishingTime,
|
|
358
|
+
p2pPropagationTime: config.attestationPropagationTime,
|
|
345
359
|
expectedBlockProposalsPerSlot: config.expectedBlockProposalsPerSlot,
|
|
346
360
|
});
|
|
347
361
|
|
|
@@ -466,6 +480,9 @@ export class LibP2PService extends WithTracer implements P2PService {
|
|
|
466
480
|
epochCache,
|
|
467
481
|
);
|
|
468
482
|
|
|
483
|
+
// Gate req/resp data protocols for unauthenticated peers when p2pAllowOnlyValidators is enabled
|
|
484
|
+
reqresp.setShouldRejectPeer(peerId => peerManager.shouldDisableP2PGossip(peerId));
|
|
485
|
+
|
|
469
486
|
// Configure application-specific scoring for gossipsub.
|
|
470
487
|
// The weight scales app score to align with gossipsub thresholds:
|
|
471
488
|
// - Disconnect (-50) × 10 = -500 = gossipThreshold (stops receiving gossip)
|
|
@@ -511,14 +528,12 @@ export class LibP2PService extends WithTracer implements P2PService {
|
|
|
511
528
|
// Create request response protocol handlers
|
|
512
529
|
const txHandler = reqRespTxHandler(this.mempools);
|
|
513
530
|
const goodbyeHandler = reqGoodbyeHandler(this.peerManager);
|
|
514
|
-
const blockHandler = reqRespBlockHandler(this.archiver);
|
|
515
531
|
const statusHandler = reqRespStatusHandler(this.protocolVersion, this.worldStateSynchronizer, this.logger);
|
|
516
532
|
|
|
517
533
|
const requestResponseHandlers: Partial<ReqRespSubProtocolHandlers> = {
|
|
518
534
|
[ReqRespSubProtocol.PING]: pingHandler,
|
|
519
535
|
[ReqRespSubProtocol.STATUS]: statusHandler.bind(this),
|
|
520
536
|
[ReqRespSubProtocol.GOODBYE]: goodbyeHandler.bind(this),
|
|
521
|
-
[ReqRespSubProtocol.BLOCK]: blockHandler.bind(this),
|
|
522
537
|
};
|
|
523
538
|
|
|
524
539
|
if (!this.config.disableTransactions) {
|
|
@@ -539,7 +554,6 @@ export class LibP2PService extends WithTracer implements P2PService {
|
|
|
539
554
|
...DEFAULT_SUB_PROTOCOL_VALIDATORS,
|
|
540
555
|
[ReqRespSubProtocol.TX]: this.validateRequestedTxs.bind(this),
|
|
541
556
|
[ReqRespSubProtocol.BLOCK_TXS]: this.validateRequestedBlockTxs.bind(this),
|
|
542
|
-
[ReqRespSubProtocol.BLOCK]: this.validateRequestedBlock.bind(this),
|
|
543
557
|
};
|
|
544
558
|
|
|
545
559
|
await this.peerManager.initializePeers();
|
|
@@ -667,8 +681,16 @@ export class LibP2PService extends WithTracer implements P2PService {
|
|
|
667
681
|
this.blockReceivedCallback = callback;
|
|
668
682
|
}
|
|
669
683
|
|
|
670
|
-
public
|
|
671
|
-
this.
|
|
684
|
+
public registerValidatorCheckpointReceivedCallback(callback: P2PCheckpointReceivedCallback) {
|
|
685
|
+
this.validatorCheckpointReceivedCallback = callback;
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
public registerAllNodesCheckpointReceivedCallback(callback: P2PCheckpointReceivedCallback) {
|
|
689
|
+
this.allNodesCheckpointReceivedCallback = callback;
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
public async notifyOwnCheckpointProposal(checkpoint: CheckpointProposalCore): Promise<void> {
|
|
693
|
+
await this.allNodesCheckpointReceivedCallback(checkpoint, this.node.peerId);
|
|
672
694
|
}
|
|
673
695
|
|
|
674
696
|
/**
|
|
@@ -754,6 +776,9 @@ export class LibP2PService extends WithTracer implements P2PService {
|
|
|
754
776
|
if (!validator || !validator.addMessage(msgId)) {
|
|
755
777
|
this.instrumentation.incMessagePrevalidationStatus(false, topicType);
|
|
756
778
|
this.node.services.pubsub.reportMessageValidationResult(msgId, source.toString(), TopicValidatorResult.Ignore);
|
|
779
|
+
if (topicType === TopicType.tx) {
|
|
780
|
+
this.logger.verbose(`Ignoring already-seen tx gossip message`, { msgId, source: source.toString() });
|
|
781
|
+
}
|
|
757
782
|
return { result: false, topicType };
|
|
758
783
|
}
|
|
759
784
|
|
|
@@ -880,30 +905,67 @@ export class LibP2PService extends WithTracer implements P2PService {
|
|
|
880
905
|
source: PeerId,
|
|
881
906
|
topicType: TopicType,
|
|
882
907
|
): Promise<ReceivedMessageValidationResult<T, M>> {
|
|
883
|
-
|
|
908
|
+
// Default to reject result with a penalty if validation function throws an error
|
|
909
|
+
let resultAndObj: ReceivedMessageValidationResult<T, M> = {
|
|
910
|
+
result: TopicValidatorResult.Reject,
|
|
911
|
+
severity: PeerErrorSeverity.MidToleranceError,
|
|
912
|
+
};
|
|
884
913
|
const timer = new Timer();
|
|
885
914
|
try {
|
|
886
915
|
resultAndObj = await validationFunc();
|
|
887
916
|
} catch (err) {
|
|
888
|
-
this.
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
917
|
+
this.logger.error(`Error validating gossipsub message`, err, { msgId, source: source.toString(), topicType });
|
|
918
|
+
}
|
|
919
|
+
|
|
920
|
+
const validationTimeMs = timer.ms();
|
|
921
|
+
const mcacheWindowMs = this.config.gossipsubMcacheLength * this.config.gossipsubInterval;
|
|
922
|
+
if (validationTimeMs > mcacheWindowMs * 0.75) {
|
|
923
|
+
this.instrumentation.incSlowValidation(topicType);
|
|
924
|
+
this.logger.warn(
|
|
925
|
+
`Gossip validation for ${topicType} took ${validationTimeMs}ms, approaching mcache eviction window of ${mcacheWindowMs}ms. ` +
|
|
926
|
+
`Message forwarding may be skipped if validation exceeds the window.`,
|
|
927
|
+
{ msgId, source: source.toString(), topicType, validationTimeMs, mcacheWindowMs },
|
|
928
|
+
);
|
|
894
929
|
}
|
|
895
930
|
|
|
896
931
|
if (resultAndObj.result === TopicValidatorResult.Accept) {
|
|
932
|
+
this.logger.debug(`Message ${topicType} accepted by validator`, { msgId, source: source.toString(), topicType });
|
|
897
933
|
this.instrumentation.recordMessageValidation(topicType, timer);
|
|
934
|
+
} else if (resultAndObj.result === TopicValidatorResult.Reject) {
|
|
935
|
+
this.logger.warn(`Message ${topicType} rejected by validator with severity ${resultAndObj.severity}`, {
|
|
936
|
+
msgId,
|
|
937
|
+
source: source.toString(),
|
|
938
|
+
topicType,
|
|
939
|
+
severity: resultAndObj.severity,
|
|
940
|
+
});
|
|
941
|
+
this.peerManager.penalizePeer(source, resultAndObj.severity);
|
|
942
|
+
} else {
|
|
943
|
+
this.logger.trace(`Message ${topicType} ignored by validator`, { msgId, source: source.toString(), topicType });
|
|
898
944
|
}
|
|
899
945
|
|
|
900
946
|
this.node.services.pubsub.reportMessageValidationResult(msgId, source.toString(), resultAndObj.result);
|
|
901
947
|
return resultAndObj;
|
|
902
948
|
}
|
|
903
949
|
|
|
950
|
+
private tryDeserialize<T>(deserializeFunc: () => T, msgId: string, source: PeerId): T | undefined {
|
|
951
|
+
try {
|
|
952
|
+
return deserializeFunc();
|
|
953
|
+
} catch (err) {
|
|
954
|
+
this.logger.warn(`Failed to deserialize gossipsub message from buffer`, {
|
|
955
|
+
err,
|
|
956
|
+
msgId,
|
|
957
|
+
source: source.toString(),
|
|
958
|
+
});
|
|
959
|
+
return undefined;
|
|
960
|
+
}
|
|
961
|
+
}
|
|
962
|
+
|
|
904
963
|
protected async handleGossipedTx(payloadData: Buffer, msgId: string, source: PeerId) {
|
|
905
964
|
const validationFunc: () => Promise<ReceivedMessageValidationResult<Tx>> = async () => {
|
|
906
|
-
const tx = Tx.fromBuffer(payloadData);
|
|
965
|
+
const tx = this.tryDeserialize(() => Tx.fromBuffer(payloadData), msgId, source);
|
|
966
|
+
if (!tx) {
|
|
967
|
+
return { result: TopicValidatorResult.Reject, severity: PeerErrorSeverity.LowToleranceError };
|
|
968
|
+
}
|
|
907
969
|
|
|
908
970
|
const currentBlockNumber = await this.archiver.getBlockNumber();
|
|
909
971
|
const { ts: nextSlotTimestamp } = this.epochCache.getEpochAndSlotInNextL1Slot();
|
|
@@ -923,13 +985,20 @@ export class LibP2PService extends WithTracer implements P2PService {
|
|
|
923
985
|
severity = await this.handleDoubleSpendFailure(tx, txBlockNumber);
|
|
924
986
|
}
|
|
925
987
|
|
|
926
|
-
this.
|
|
927
|
-
|
|
988
|
+
this.logger.verbose(`Rejecting gossiped tx ${tx.getTxHash().toString()}: stage 1 validation failed`, {
|
|
989
|
+
validator: name,
|
|
990
|
+
severity,
|
|
991
|
+
source: source.toString(),
|
|
992
|
+
});
|
|
993
|
+
return { result: TopicValidatorResult.Reject, severity };
|
|
928
994
|
}
|
|
929
995
|
|
|
930
996
|
// Pool pre-check: see if the pool would accept this tx before doing expensive proof verification
|
|
931
997
|
const canAdd = await this.mempools.txPool.canAddPendingTx(tx);
|
|
932
998
|
if (canAdd === 'ignored') {
|
|
999
|
+
this.logger.verbose(`Ignoring gossiped tx ${tx.getTxHash().toString()}: pool pre-check returned ignored`, {
|
|
1000
|
+
source: source.toString(),
|
|
1001
|
+
});
|
|
933
1002
|
return { result: TopicValidatorResult.Ignore, obj: tx };
|
|
934
1003
|
}
|
|
935
1004
|
|
|
@@ -937,9 +1006,13 @@ export class LibP2PService extends WithTracer implements P2PService {
|
|
|
937
1006
|
const secondStageValidators = this.createSecondStageMessageValidators();
|
|
938
1007
|
const secondStageOutcome = await this.runValidations(tx, secondStageValidators);
|
|
939
1008
|
if (!secondStageOutcome.allPassed) {
|
|
940
|
-
const { severity } = secondStageOutcome.failure;
|
|
941
|
-
this.
|
|
942
|
-
|
|
1009
|
+
const { severity, name } = secondStageOutcome.failure;
|
|
1010
|
+
this.logger.verbose(`Rejecting gossiped tx ${tx.getTxHash().toString()}: stage 2 validation failed`, {
|
|
1011
|
+
validator: name,
|
|
1012
|
+
severity,
|
|
1013
|
+
source: source.toString(),
|
|
1014
|
+
});
|
|
1015
|
+
return { result: TopicValidatorResult.Reject, severity };
|
|
943
1016
|
}
|
|
944
1017
|
|
|
945
1018
|
// Pool add: persist the tx
|
|
@@ -949,7 +1022,7 @@ export class LibP2PService extends WithTracer implements P2PService {
|
|
|
949
1022
|
const wasAccepted = addResult.accepted.some(h => h.equals(txHash));
|
|
950
1023
|
const wasIgnored = addResult.ignored.some(h => h.equals(txHash));
|
|
951
1024
|
|
|
952
|
-
this.logger.
|
|
1025
|
+
this.logger.verbose(`Validate propagated tx ${txHash.toString()}`, {
|
|
953
1026
|
wasAccepted,
|
|
954
1027
|
wasIgnored,
|
|
955
1028
|
[Attributes.P2P_ID]: source.toString(),
|
|
@@ -960,7 +1033,11 @@ export class LibP2PService extends WithTracer implements P2PService {
|
|
|
960
1033
|
} else if (wasIgnored) {
|
|
961
1034
|
return { result: TopicValidatorResult.Ignore, obj: tx };
|
|
962
1035
|
} else {
|
|
963
|
-
|
|
1036
|
+
this.logger.warn(`Gossiped tx ${txHash.toString()} unexpectedly rejected by pool`, {
|
|
1037
|
+
source: source.toString(),
|
|
1038
|
+
txHash: txHash.toString(),
|
|
1039
|
+
});
|
|
1040
|
+
return { result: TopicValidatorResult.Reject, severity: PeerErrorSeverity.HighToleranceError };
|
|
964
1041
|
}
|
|
965
1042
|
};
|
|
966
1043
|
|
|
@@ -990,7 +1067,16 @@ export class LibP2PService extends WithTracer implements P2PService {
|
|
|
990
1067
|
source: PeerId,
|
|
991
1068
|
): Promise<void> {
|
|
992
1069
|
const { result, obj: attestation } = await this.validateReceivedMessage<CheckpointAttestation>(
|
|
993
|
-
() =>
|
|
1070
|
+
() => {
|
|
1071
|
+
const attestation = this.tryDeserialize(() => CheckpointAttestation.fromBuffer(payloadData), msgId, source);
|
|
1072
|
+
if (!attestation) {
|
|
1073
|
+
return Promise.resolve({
|
|
1074
|
+
result: TopicValidatorResult.Reject,
|
|
1075
|
+
severity: PeerErrorSeverity.LowToleranceError,
|
|
1076
|
+
});
|
|
1077
|
+
}
|
|
1078
|
+
return this.validateAndStoreCheckpointAttestation(source, attestation);
|
|
1079
|
+
},
|
|
994
1080
|
msgId,
|
|
995
1081
|
source,
|
|
996
1082
|
TopicType.checkpoint_attestation,
|
|
@@ -1023,8 +1109,7 @@ export class LibP2PService extends WithTracer implements P2PService {
|
|
|
1023
1109
|
|
|
1024
1110
|
if (validationResult.result === 'reject') {
|
|
1025
1111
|
this.logger.warn(`Penalizing peer ${peerId} for checkpoint attestation validation failure`);
|
|
1026
|
-
|
|
1027
|
-
return { result: TopicValidatorResult.Reject };
|
|
1112
|
+
return { result: TopicValidatorResult.Reject, severity: validationResult.severity };
|
|
1028
1113
|
}
|
|
1029
1114
|
|
|
1030
1115
|
if (validationResult.result === 'ignore') {
|
|
@@ -1050,16 +1135,16 @@ export class LibP2PService extends WithTracer implements P2PService {
|
|
|
1050
1135
|
return { result: TopicValidatorResult.Ignore, obj: attestation };
|
|
1051
1136
|
}
|
|
1052
1137
|
|
|
1053
|
-
// Could not add (cap reached for signer),
|
|
1138
|
+
// Could not add (cap reached for signer), penalize and do not re-broadcast
|
|
1054
1139
|
if (!added) {
|
|
1055
|
-
this.logger.warn(`
|
|
1140
|
+
this.logger.warn(`Rejecting checkpoint attestation due to cap`, {
|
|
1056
1141
|
slot: slot.toString(),
|
|
1057
1142
|
archive: attestation.archive.toString(),
|
|
1058
1143
|
source: peerId.toString(),
|
|
1059
1144
|
attester: attestation.getSender()?.toString(),
|
|
1060
1145
|
count,
|
|
1061
1146
|
});
|
|
1062
|
-
return { result: TopicValidatorResult.
|
|
1147
|
+
return { result: TopicValidatorResult.Reject, severity: PeerErrorSeverity.HighToleranceError };
|
|
1063
1148
|
}
|
|
1064
1149
|
|
|
1065
1150
|
// Check if this is a duplicate attestation (signer attested to a different proposal at the same slot)
|
|
@@ -1114,8 +1199,7 @@ export class LibP2PService extends WithTracer implements P2PService {
|
|
|
1114
1199
|
|
|
1115
1200
|
if (validationResult.result === 'reject') {
|
|
1116
1201
|
this.logger.warn(`Penalizing peer ${peerId} for block proposal validation failure`);
|
|
1117
|
-
|
|
1118
|
-
return { result: TopicValidatorResult.Reject };
|
|
1202
|
+
return { result: TopicValidatorResult.Reject, severity: validationResult.severity };
|
|
1119
1203
|
}
|
|
1120
1204
|
|
|
1121
1205
|
if (validationResult.result === 'ignore') {
|
|
@@ -1139,7 +1223,6 @@ export class LibP2PService extends WithTracer implements P2PService {
|
|
|
1139
1223
|
|
|
1140
1224
|
// Too many blocks received for this slot and index, penalize peer and do not re-broadcast
|
|
1141
1225
|
if (!added) {
|
|
1142
|
-
this.peerManager.penalizePeer(peerId, PeerErrorSeverity.HighToleranceError);
|
|
1143
1226
|
this.logger.warn(`Penalizing peer for block proposal exceeding per-position cap`, {
|
|
1144
1227
|
...block.toBlockInfo(),
|
|
1145
1228
|
indexWithinCheckpoint: block.indexWithinCheckpoint,
|
|
@@ -1147,7 +1230,11 @@ export class LibP2PService extends WithTracer implements P2PService {
|
|
|
1147
1230
|
proposer: block.getSender()?.toString(),
|
|
1148
1231
|
source: peerId.toString(),
|
|
1149
1232
|
});
|
|
1150
|
-
return {
|
|
1233
|
+
return {
|
|
1234
|
+
result: TopicValidatorResult.Reject,
|
|
1235
|
+
metadata: { isEquivocated },
|
|
1236
|
+
severity: PeerErrorSeverity.HighToleranceError,
|
|
1237
|
+
};
|
|
1151
1238
|
}
|
|
1152
1239
|
|
|
1153
1240
|
// If this was a duplicate proposal, do not process it, but do invoke the duplicate callback,
|
|
@@ -1192,7 +1279,7 @@ export class LibP2PService extends WithTracer implements P2PService {
|
|
|
1192
1279
|
// Note: Validators do NOT attest to individual blocks, only to checkpoint proposals.
|
|
1193
1280
|
const isValid = await this.blockReceivedCallback(block, sender);
|
|
1194
1281
|
if (!isValid) {
|
|
1195
|
-
this.logger.
|
|
1282
|
+
this.logger.info(`Block proposal validation failed for block ${block.blockNumber}`, block.toBlockInfo());
|
|
1196
1283
|
}
|
|
1197
1284
|
}
|
|
1198
1285
|
|
|
@@ -1240,8 +1327,7 @@ export class LibP2PService extends WithTracer implements P2PService {
|
|
|
1240
1327
|
|
|
1241
1328
|
if (validationResult.result === 'reject') {
|
|
1242
1329
|
this.logger.warn(`Penalizing peer ${peerId} for checkpoint proposal validation failure`);
|
|
1243
|
-
|
|
1244
|
-
return { result: TopicValidatorResult.Reject };
|
|
1330
|
+
return { result: TopicValidatorResult.Reject, severity: validationResult.severity };
|
|
1245
1331
|
}
|
|
1246
1332
|
|
|
1247
1333
|
if (validationResult.result === 'ignore') {
|
|
@@ -1256,20 +1342,21 @@ export class LibP2PService extends WithTracer implements P2PService {
|
|
|
1256
1342
|
[Attributes.SLOT_NUMBER]: checkpoint.slotNumber.toString(),
|
|
1257
1343
|
[Attributes.P2P_ID]: peerId.toString(),
|
|
1258
1344
|
});
|
|
1259
|
-
const
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
metadata: { isEquivocated } = {},
|
|
1263
|
-
} = await this.validateAndStoreBlockProposal(peerId, blockProposal);
|
|
1264
|
-
if (result === TopicValidatorResult.Reject || !obj || isEquivocated) {
|
|
1345
|
+
const blockProposalResult = await this.validateAndStoreBlockProposal(peerId, blockProposal);
|
|
1346
|
+
const { obj, metadata: { isEquivocated } = {} } = blockProposalResult;
|
|
1347
|
+
if (blockProposalResult.result === TopicValidatorResult.Reject || !obj || isEquivocated) {
|
|
1265
1348
|
this.logger.debug(`Rejecting checkpoint due to invalid last block proposal`, {
|
|
1266
1349
|
[Attributes.SLOT_NUMBER]: checkpoint.slotNumber.toString(),
|
|
1267
1350
|
[Attributes.P2P_ID]: peerId.toString(),
|
|
1268
1351
|
isEquivocated,
|
|
1269
|
-
result,
|
|
1352
|
+
result: blockProposalResult.result,
|
|
1270
1353
|
});
|
|
1271
|
-
return {
|
|
1272
|
-
|
|
1354
|
+
return {
|
|
1355
|
+
result: TopicValidatorResult.Reject,
|
|
1356
|
+
severity:
|
|
1357
|
+
'severity' in blockProposalResult ? blockProposalResult.severity : PeerErrorSeverity.MidToleranceError,
|
|
1358
|
+
};
|
|
1359
|
+
} else if (blockProposalResult.result === TopicValidatorResult.Accept && obj && !isEquivocated) {
|
|
1273
1360
|
processBlock = true;
|
|
1274
1361
|
}
|
|
1275
1362
|
}
|
|
@@ -1296,13 +1383,17 @@ export class LibP2PService extends WithTracer implements P2PService {
|
|
|
1296
1383
|
// Too many checkpoint proposals received for this slot, penalize peer and do not re-broadcast
|
|
1297
1384
|
// Note: We still return the checkpoint obj so the lastBlock can be processed if valid
|
|
1298
1385
|
if (!added) {
|
|
1299
|
-
this.peerManager.penalizePeer(peerId, PeerErrorSeverity.HighToleranceError);
|
|
1300
1386
|
this.logger.warn(`Penalizing peer for checkpoint proposal exceeding per-slot cap`, {
|
|
1301
1387
|
...checkpoint.toCheckpointInfo(),
|
|
1302
1388
|
count,
|
|
1303
1389
|
source: peerId.toString(),
|
|
1304
1390
|
});
|
|
1305
|
-
return {
|
|
1391
|
+
return {
|
|
1392
|
+
result: TopicValidatorResult.Reject,
|
|
1393
|
+
obj: checkpoint,
|
|
1394
|
+
metadata: { isEquivocated, processBlock },
|
|
1395
|
+
severity: PeerErrorSeverity.HighToleranceError,
|
|
1396
|
+
};
|
|
1306
1397
|
}
|
|
1307
1398
|
|
|
1308
1399
|
// If this was a duplicate proposal, do not process it, but do invoke the duplicate callback,
|
|
@@ -1347,9 +1438,11 @@ export class LibP2PService extends WithTracer implements P2PService {
|
|
|
1347
1438
|
source: sender.toString(),
|
|
1348
1439
|
});
|
|
1349
1440
|
|
|
1441
|
+
await this.allNodesCheckpointReceivedCallback(checkpoint, sender);
|
|
1442
|
+
|
|
1350
1443
|
// Call the checkpoint received callback with the core version (without lastBlock)
|
|
1351
1444
|
// to validate and potentially generate attestations
|
|
1352
|
-
const attestations = await this.
|
|
1445
|
+
const attestations = await this.validatorCheckpointReceivedCallback(checkpoint, sender);
|
|
1353
1446
|
if (attestations && attestations.length > 0) {
|
|
1354
1447
|
// If the callback returned attestations, add them to the pool and propagate them
|
|
1355
1448
|
await this.mempools.attestationPool.addOwnCheckpointAttestations(attestations);
|
|
@@ -1497,53 +1590,6 @@ export class LibP2PService extends WithTracer implements P2PService {
|
|
|
1497
1590
|
}
|
|
1498
1591
|
}
|
|
1499
1592
|
|
|
1500
|
-
/**
|
|
1501
|
-
* Validates a BLOCK response.
|
|
1502
|
-
*
|
|
1503
|
-
* If a local copy exists, enforces hash equality. If missing, rejects (no penalty) since the hash cannot be verified.
|
|
1504
|
-
* Penalizes on block number mismatch or hash mismatch.
|
|
1505
|
-
*
|
|
1506
|
-
* @param requestedBlockNumber - The requested block number.
|
|
1507
|
-
* @param responseBlock - The block returned by the peer.
|
|
1508
|
-
* @param peerId - The peer that returned the block.
|
|
1509
|
-
* @returns True if the response is valid, false otherwise.
|
|
1510
|
-
*/
|
|
1511
|
-
@trackSpan('Libp2pService.validateRequestedBlock', (requestedBlockNumber, _responseBlock) => ({
|
|
1512
|
-
[Attributes.BLOCK_NUMBER]: requestedBlockNumber.toString(),
|
|
1513
|
-
}))
|
|
1514
|
-
protected async validateRequestedBlock(
|
|
1515
|
-
requestedBlockNumber: Fr,
|
|
1516
|
-
responseBlock: L2Block,
|
|
1517
|
-
peerId: PeerId,
|
|
1518
|
-
): Promise<boolean> {
|
|
1519
|
-
try {
|
|
1520
|
-
const reqNum = Number(requestedBlockNumber.toString());
|
|
1521
|
-
if (responseBlock.number !== reqNum) {
|
|
1522
|
-
this.peerManager.penalizePeer(peerId, PeerErrorSeverity.LowToleranceError);
|
|
1523
|
-
return false;
|
|
1524
|
-
}
|
|
1525
|
-
|
|
1526
|
-
const local = await this.archiver.getBlock(BlockNumber(reqNum));
|
|
1527
|
-
if (!local) {
|
|
1528
|
-
// We are missing the local block; we cannot verify the hash yet. Reject without penalizing.
|
|
1529
|
-
// TODO: Consider extending this validator to accept an expected hash or
|
|
1530
|
-
// performing quorum-based checks when using P2P syncing prior to L1 sync.
|
|
1531
|
-
this.logger.warn(`Local block ${reqNum} not found; rejecting BLOCK response without hash verification`);
|
|
1532
|
-
return false;
|
|
1533
|
-
}
|
|
1534
|
-
const [localHash, respHash] = await Promise.all([local.hash(), responseBlock.hash()]);
|
|
1535
|
-
if (!localHash.equals(respHash)) {
|
|
1536
|
-
this.peerManager.penalizePeer(peerId, PeerErrorSeverity.MidToleranceError);
|
|
1537
|
-
return false;
|
|
1538
|
-
}
|
|
1539
|
-
|
|
1540
|
-
return true;
|
|
1541
|
-
} catch (e) {
|
|
1542
|
-
this.logger.warn(`Error validating requested block`, e);
|
|
1543
|
-
return false;
|
|
1544
|
-
}
|
|
1545
|
-
}
|
|
1546
|
-
|
|
1547
1593
|
protected async validateRequestedTx(
|
|
1548
1594
|
tx: Tx,
|
|
1549
1595
|
peerId: PeerId,
|
|
@@ -1621,8 +1667,12 @@ export class LibP2PService extends WithTracer implements P2PService {
|
|
|
1621
1667
|
nextSlotTimestamp: UInt64,
|
|
1622
1668
|
): Promise<Record<string, TransactionValidator>> {
|
|
1623
1669
|
const gasFees = await this.getGasFees(currentBlockNumber);
|
|
1624
|
-
const allowedInSetup =
|
|
1670
|
+
const allowedInSetup = [
|
|
1671
|
+
...(await getDefaultAllowedSetupFunctions()),
|
|
1672
|
+
...(this.config.txPublicSetupAllowListExtend ?? []),
|
|
1673
|
+
];
|
|
1625
1674
|
const blockNumber = BlockNumber(currentBlockNumber + 1);
|
|
1675
|
+
const l1Constants = await this.archiver.getL1Constants();
|
|
1626
1676
|
|
|
1627
1677
|
return createFirstStageTxValidationsForGossipedTransactions(
|
|
1628
1678
|
nextSlotTimestamp,
|
|
@@ -1636,6 +1686,11 @@ export class LibP2PService extends WithTracer implements P2PService {
|
|
|
1636
1686
|
!this.config.disableTransactions,
|
|
1637
1687
|
allowedInSetup,
|
|
1638
1688
|
this.logger.getBindings(),
|
|
1689
|
+
{
|
|
1690
|
+
rollupManaLimit: l1Constants.rollupManaLimit,
|
|
1691
|
+
maxBlockL2Gas: this.config.validateMaxL2BlockGas,
|
|
1692
|
+
maxBlockDAGas: this.config.validateMaxDABlockGas,
|
|
1693
|
+
},
|
|
1639
1694
|
);
|
|
1640
1695
|
}
|
|
1641
1696
|
|
|
@@ -1661,8 +1716,10 @@ export class LibP2PService extends WithTracer implements P2PService {
|
|
|
1661
1716
|
|
|
1662
1717
|
// A promise that resolves when all validations have been run
|
|
1663
1718
|
const allValidations = await Promise.all(validationPromises);
|
|
1664
|
-
const
|
|
1665
|
-
if (
|
|
1719
|
+
const failures = allValidations.filter(x => !x.isValid);
|
|
1720
|
+
if (failures.length > 0) {
|
|
1721
|
+
// Pick the most severe failure (lowest tolerance = harshest penalty)
|
|
1722
|
+
const failed = maxBy(failures, f => PeerErrorSeverityByHarshness.indexOf(f.severity))!;
|
|
1666
1723
|
return {
|
|
1667
1724
|
allPassed: false,
|
|
1668
1725
|
failure: {
|
|
@@ -1715,31 +1772,6 @@ export class LibP2PService extends WithTracer implements P2PService {
|
|
|
1715
1772
|
return PeerErrorSeverity.HighToleranceError;
|
|
1716
1773
|
}
|
|
1717
1774
|
|
|
1718
|
-
/**
|
|
1719
|
-
* Validate a checkpoint attestation.
|
|
1720
|
-
*
|
|
1721
|
-
* @param attestation - The checkpoint attestation to validate.
|
|
1722
|
-
* @returns True if the checkpoint attestation is valid, false otherwise.
|
|
1723
|
-
*/
|
|
1724
|
-
@trackSpan('Libp2pService.validateCheckpointAttestation', async (_, attestation) => ({
|
|
1725
|
-
[Attributes.SLOT_NUMBER]: attestation.payload.header.slotNumber,
|
|
1726
|
-
[Attributes.BLOCK_ARCHIVE]: attestation.archive.toString(),
|
|
1727
|
-
[Attributes.P2P_ID]: await attestation.p2pMessageLoggingIdentifier().then(i => i.toString()),
|
|
1728
|
-
}))
|
|
1729
|
-
public async validateCheckpointAttestation(
|
|
1730
|
-
peerId: PeerId,
|
|
1731
|
-
attestation: CheckpointAttestation,
|
|
1732
|
-
): Promise<P2PValidationResult> {
|
|
1733
|
-
const result = await this.checkpointAttestationValidator.validate(attestation);
|
|
1734
|
-
|
|
1735
|
-
if (result.result === 'reject') {
|
|
1736
|
-
this.logger.warn(`Penalizing peer ${peerId} for checkpoint attestation validation failure`);
|
|
1737
|
-
this.peerManager.penalizePeer(peerId, result.severity);
|
|
1738
|
-
}
|
|
1739
|
-
|
|
1740
|
-
return result;
|
|
1741
|
-
}
|
|
1742
|
-
|
|
1743
1775
|
public getPeerScore(peerId: PeerId): number {
|
|
1744
1776
|
return this.node.services.pubsub.score.score(peerId.toString());
|
|
1745
1777
|
}
|
|
@@ -18,6 +18,7 @@ export class PeerManagerMetrics {
|
|
|
18
18
|
private sentGoodbyes: UpDownCounter;
|
|
19
19
|
private receivedGoodbyes: UpDownCounter;
|
|
20
20
|
private peerCount: Gauge;
|
|
21
|
+
private healthyPeerCount: Gauge;
|
|
21
22
|
private lowScoreDisconnects: UpDownCounter;
|
|
22
23
|
private peerConnectionDuration: Histogram;
|
|
23
24
|
|
|
@@ -49,6 +50,7 @@ export class PeerManagerMetrics {
|
|
|
49
50
|
goodbyeReasonAttrs,
|
|
50
51
|
);
|
|
51
52
|
this.peerCount = meter.createGauge(Metrics.PEER_MANAGER_PEER_COUNT);
|
|
53
|
+
this.healthyPeerCount = meter.createGauge(Metrics.PEER_MANAGER_HEALTHY_PEER_COUNT);
|
|
52
54
|
this.lowScoreDisconnects = createUpDownCounterWithDefault(meter, Metrics.PEER_MANAGER_LOW_SCORE_DISCONNECTS, {
|
|
53
55
|
[Attributes.P2P_PEER_SCORE_STATE]: ['Banned', 'Disconnect'],
|
|
54
56
|
});
|
|
@@ -67,6 +69,10 @@ export class PeerManagerMetrics {
|
|
|
67
69
|
this.peerCount.record(count);
|
|
68
70
|
}
|
|
69
71
|
|
|
72
|
+
public recordHealthyPeerCount(count: number) {
|
|
73
|
+
this.healthyPeerCount.record(count);
|
|
74
|
+
}
|
|
75
|
+
|
|
70
76
|
public recordLowScoreDisconnect(scoreState: 'Banned' | 'Disconnect') {
|
|
71
77
|
this.lowScoreDisconnects.add(1, { [Attributes.P2P_PEER_SCORE_STATE]: scoreState });
|
|
72
78
|
}
|
|
@@ -79,6 +85,7 @@ export class PeerManagerMetrics {
|
|
|
79
85
|
const connectedAt = this.peerConnectedAt.get(id.toString());
|
|
80
86
|
if (connectedAt) {
|
|
81
87
|
this.peerConnectionDuration.record(Date.now() - connectedAt);
|
|
88
|
+
this.peerConnectedAt.delete(id.toString());
|
|
82
89
|
}
|
|
83
90
|
}
|
|
84
91
|
}
|