@aztec/p2p 0.0.1-commit.ec5f612 → 0.0.1-commit.ec7ac5448
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 +25 -11
- 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 +37 -36
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.js +17 -6
- package/dest/config.d.ts +34 -11
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +91 -32
- 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/interfaces.d.ts +7 -1
- package/dest/mem_pools/tx_pool_v2/eviction/interfaces.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.d.ts +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.js +8 -6
- package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.d.ts +2 -2
- package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_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 +2 -1
- package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts +25 -10
- package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/tx_metadata.js +38 -11
- 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 +24 -6
- 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 +7 -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 +7 -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 +15 -8
- package/dest/msg_validators/proposal_validator/proposal_validator.d.ts.map +1 -1
- package/dest/msg_validators/proposal_validator/proposal_validator.js +67 -47
- 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/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/libp2p_service.d.ts +15 -25
- package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
- package/dest/services/libp2p/libp2p_service.js +165 -126
- 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 +24 -9
- 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 +69 -65
- 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 +3 -1
- package/dest/services/reqresp/batch-tx-requester/peer_collection.d.ts.map +1 -1
- package/dest/services/reqresp/batch-tx-requester/peer_collection.js +3 -0
- 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 +28 -11
- 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 +39 -36
- package/src/client/test/tx_proposal_collector/proposal_tx_collector_worker.ts +19 -9
- package/src/config.ts +136 -34
- 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/README.md +9 -1
- package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.ts +2 -1
- package/src/mem_pools/tx_pool_v2/eviction/interfaces.ts +11 -1
- package/src/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.ts +15 -6
- package/src/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.ts +2 -1
- package/src/mem_pools/tx_pool_v2/interfaces.ts +9 -4
- package/src/mem_pools/tx_pool_v2/tx_metadata.ts +59 -13
- 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 +28 -6
- 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 +79 -49
- 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/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/libp2p_service.ts +164 -139
- package/src/services/peer-manager/metrics.ts +7 -0
- package/src/services/peer-manager/peer_manager.ts +28 -9
- 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 +64 -69
- 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 +5 -0
- 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 +37 -12
- 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 -23
- 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 -212
- 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 -230
- 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,30 +228,39 @@ export class LibP2PService extends WithTracer implements P2PService {
|
|
|
222
228
|
this.protocolVersion,
|
|
223
229
|
);
|
|
224
230
|
|
|
225
|
-
|
|
226
|
-
|
|
231
|
+
const p2pPropagationTime = config.attestationPropagationTime;
|
|
232
|
+
const proposalValidatorOpts = {
|
|
227
233
|
txsPermitted: !config.disableTransactions,
|
|
228
|
-
|
|
234
|
+
maxTxsPerBlock: config.validateMaxTxsPerBlock ?? config.validateMaxTxsPerCheckpoint,
|
|
235
|
+
p2pPropagationTime,
|
|
236
|
+
};
|
|
237
|
+
this.blockProposalValidator = new BlockProposalValidator(epochCache, proposalValidatorOpts);
|
|
238
|
+
this.checkpointProposalValidator = new CheckpointProposalValidator(epochCache, proposalValidatorOpts);
|
|
229
239
|
this.checkpointAttestationValidator = config.fishermanMode
|
|
230
|
-
? new FishermanAttestationValidator(epochCache, mempools.attestationPool, telemetry
|
|
231
|
-
|
|
240
|
+
? new FishermanAttestationValidator(epochCache, mempools.attestationPool, telemetry, {
|
|
241
|
+
l1PublishingTime: config.l1PublishingTime,
|
|
242
|
+
})
|
|
243
|
+
: new CheckpointAttestationValidator(epochCache, { l1PublishingTime: config.l1PublishingTime });
|
|
232
244
|
|
|
233
245
|
this.gossipSubEventHandler = this.handleGossipSubEvent.bind(this);
|
|
234
246
|
|
|
235
247
|
this.blockReceivedCallback = async (block: BlockProposal): Promise<boolean> => {
|
|
236
|
-
this.logger.
|
|
237
|
-
`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.`,
|
|
238
250
|
{ p2pMessageIdentifier: await block.p2pMessageLoggingIdentifier() },
|
|
239
251
|
);
|
|
240
|
-
return
|
|
252
|
+
return true;
|
|
241
253
|
};
|
|
242
254
|
|
|
243
|
-
this.
|
|
244
|
-
|
|
255
|
+
this.allNodesCheckpointReceivedCallback = (
|
|
256
|
+
_checkpoint: CheckpointProposalCore,
|
|
257
|
+
): Promise<CheckpointAttestation[] | undefined> => {
|
|
258
|
+
throw new CheckpointProposalReceivedCallbackNotRegisteredError();
|
|
259
|
+
};
|
|
260
|
+
|
|
261
|
+
this.validatorCheckpointReceivedCallback = (
|
|
262
|
+
_checkpoint: CheckpointProposalCore,
|
|
245
263
|
): Promise<CheckpointAttestation[] | undefined> => {
|
|
246
|
-
this.logger.debug(
|
|
247
|
-
`Handler not yet registered: Checkpoint received callback not set. Received checkpoint for slot ${checkpoint.slotNumber} from peer.`,
|
|
248
|
-
);
|
|
249
264
|
return Promise.resolve(undefined);
|
|
250
265
|
};
|
|
251
266
|
}
|
|
@@ -335,9 +350,12 @@ export class LibP2PService extends WithTracer implements P2PService {
|
|
|
335
350
|
const l1Constants = epochCache.getL1Constants();
|
|
336
351
|
const topicScoreParams = createAllTopicScoreParams(protocolVersion, {
|
|
337
352
|
slotDurationMs: l1Constants.slotDuration * 1000,
|
|
353
|
+
ethereumSlotDuration: l1Constants.ethereumSlotDuration,
|
|
338
354
|
heartbeatIntervalMs: config.gossipsubInterval,
|
|
339
355
|
targetCommitteeSize: l1Constants.targetCommitteeSize,
|
|
340
356
|
blockDurationMs: config.blockDurationMs,
|
|
357
|
+
l1PublishingTime: config.l1PublishingTime,
|
|
358
|
+
p2pPropagationTime: config.attestationPropagationTime,
|
|
341
359
|
expectedBlockProposalsPerSlot: config.expectedBlockProposalsPerSlot,
|
|
342
360
|
});
|
|
343
361
|
|
|
@@ -462,6 +480,9 @@ export class LibP2PService extends WithTracer implements P2PService {
|
|
|
462
480
|
epochCache,
|
|
463
481
|
);
|
|
464
482
|
|
|
483
|
+
// Gate req/resp data protocols for unauthenticated peers when p2pAllowOnlyValidators is enabled
|
|
484
|
+
reqresp.setShouldRejectPeer(peerId => peerManager.shouldDisableP2PGossip(peerId));
|
|
485
|
+
|
|
465
486
|
// Configure application-specific scoring for gossipsub.
|
|
466
487
|
// The weight scales app score to align with gossipsub thresholds:
|
|
467
488
|
// - Disconnect (-50) × 10 = -500 = gossipThreshold (stops receiving gossip)
|
|
@@ -507,14 +528,12 @@ export class LibP2PService extends WithTracer implements P2PService {
|
|
|
507
528
|
// Create request response protocol handlers
|
|
508
529
|
const txHandler = reqRespTxHandler(this.mempools);
|
|
509
530
|
const goodbyeHandler = reqGoodbyeHandler(this.peerManager);
|
|
510
|
-
const blockHandler = reqRespBlockHandler(this.archiver);
|
|
511
531
|
const statusHandler = reqRespStatusHandler(this.protocolVersion, this.worldStateSynchronizer, this.logger);
|
|
512
532
|
|
|
513
533
|
const requestResponseHandlers: Partial<ReqRespSubProtocolHandlers> = {
|
|
514
534
|
[ReqRespSubProtocol.PING]: pingHandler,
|
|
515
535
|
[ReqRespSubProtocol.STATUS]: statusHandler.bind(this),
|
|
516
536
|
[ReqRespSubProtocol.GOODBYE]: goodbyeHandler.bind(this),
|
|
517
|
-
[ReqRespSubProtocol.BLOCK]: blockHandler.bind(this),
|
|
518
537
|
};
|
|
519
538
|
|
|
520
539
|
if (!this.config.disableTransactions) {
|
|
@@ -535,7 +554,6 @@ export class LibP2PService extends WithTracer implements P2PService {
|
|
|
535
554
|
...DEFAULT_SUB_PROTOCOL_VALIDATORS,
|
|
536
555
|
[ReqRespSubProtocol.TX]: this.validateRequestedTxs.bind(this),
|
|
537
556
|
[ReqRespSubProtocol.BLOCK_TXS]: this.validateRequestedBlockTxs.bind(this),
|
|
538
|
-
[ReqRespSubProtocol.BLOCK]: this.validateRequestedBlock.bind(this),
|
|
539
557
|
};
|
|
540
558
|
|
|
541
559
|
await this.peerManager.initializePeers();
|
|
@@ -663,8 +681,16 @@ export class LibP2PService extends WithTracer implements P2PService {
|
|
|
663
681
|
this.blockReceivedCallback = callback;
|
|
664
682
|
}
|
|
665
683
|
|
|
666
|
-
public
|
|
667
|
-
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);
|
|
668
694
|
}
|
|
669
695
|
|
|
670
696
|
/**
|
|
@@ -750,6 +776,9 @@ export class LibP2PService extends WithTracer implements P2PService {
|
|
|
750
776
|
if (!validator || !validator.addMessage(msgId)) {
|
|
751
777
|
this.instrumentation.incMessagePrevalidationStatus(false, topicType);
|
|
752
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
|
+
}
|
|
753
782
|
return { result: false, topicType };
|
|
754
783
|
}
|
|
755
784
|
|
|
@@ -876,30 +905,56 @@ export class LibP2PService extends WithTracer implements P2PService {
|
|
|
876
905
|
source: PeerId,
|
|
877
906
|
topicType: TopicType,
|
|
878
907
|
): Promise<ReceivedMessageValidationResult<T, M>> {
|
|
879
|
-
|
|
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
|
+
};
|
|
880
913
|
const timer = new Timer();
|
|
881
914
|
try {
|
|
882
915
|
resultAndObj = await validationFunc();
|
|
883
916
|
} catch (err) {
|
|
884
|
-
this.
|
|
885
|
-
this.logger.error(`Error deserializing and validating gossipsub message`, err, {
|
|
886
|
-
msgId,
|
|
887
|
-
source: source.toString(),
|
|
888
|
-
topicType,
|
|
889
|
-
});
|
|
917
|
+
this.logger.error(`Error validating gossipsub message`, err, { msgId, source: source.toString(), topicType });
|
|
890
918
|
}
|
|
891
919
|
|
|
892
920
|
if (resultAndObj.result === TopicValidatorResult.Accept) {
|
|
921
|
+
this.logger.debug(`Message ${topicType} accepted by validator`, { msgId, source: source.toString(), topicType });
|
|
893
922
|
this.instrumentation.recordMessageValidation(topicType, timer);
|
|
923
|
+
} else if (resultAndObj.result === TopicValidatorResult.Reject) {
|
|
924
|
+
this.logger.warn(`Message ${topicType} rejected by validator with severity ${resultAndObj.severity}`, {
|
|
925
|
+
msgId,
|
|
926
|
+
source: source.toString(),
|
|
927
|
+
topicType,
|
|
928
|
+
severity: resultAndObj.severity,
|
|
929
|
+
});
|
|
930
|
+
this.peerManager.penalizePeer(source, resultAndObj.severity);
|
|
931
|
+
} else {
|
|
932
|
+
this.logger.trace(`Message ${topicType} ignored by validator`, { msgId, source: source.toString(), topicType });
|
|
894
933
|
}
|
|
895
934
|
|
|
896
935
|
this.node.services.pubsub.reportMessageValidationResult(msgId, source.toString(), resultAndObj.result);
|
|
897
936
|
return resultAndObj;
|
|
898
937
|
}
|
|
899
938
|
|
|
939
|
+
private tryDeserialize<T>(deserializeFunc: () => T, msgId: string, source: PeerId): T | undefined {
|
|
940
|
+
try {
|
|
941
|
+
return deserializeFunc();
|
|
942
|
+
} catch (err) {
|
|
943
|
+
this.logger.warn(`Failed to deserialize gossipsub message from buffer`, {
|
|
944
|
+
err,
|
|
945
|
+
msgId,
|
|
946
|
+
source: source.toString(),
|
|
947
|
+
});
|
|
948
|
+
return undefined;
|
|
949
|
+
}
|
|
950
|
+
}
|
|
951
|
+
|
|
900
952
|
protected async handleGossipedTx(payloadData: Buffer, msgId: string, source: PeerId) {
|
|
901
953
|
const validationFunc: () => Promise<ReceivedMessageValidationResult<Tx>> = async () => {
|
|
902
|
-
const tx = Tx.fromBuffer(payloadData);
|
|
954
|
+
const tx = this.tryDeserialize(() => Tx.fromBuffer(payloadData), msgId, source);
|
|
955
|
+
if (!tx) {
|
|
956
|
+
return { result: TopicValidatorResult.Reject, severity: PeerErrorSeverity.LowToleranceError };
|
|
957
|
+
}
|
|
903
958
|
|
|
904
959
|
const currentBlockNumber = await this.archiver.getBlockNumber();
|
|
905
960
|
const { ts: nextSlotTimestamp } = this.epochCache.getEpochAndSlotInNextL1Slot();
|
|
@@ -919,13 +974,20 @@ export class LibP2PService extends WithTracer implements P2PService {
|
|
|
919
974
|
severity = await this.handleDoubleSpendFailure(tx, txBlockNumber);
|
|
920
975
|
}
|
|
921
976
|
|
|
922
|
-
this.
|
|
923
|
-
|
|
977
|
+
this.logger.verbose(`Rejecting gossiped tx ${tx.getTxHash().toString()}: stage 1 validation failed`, {
|
|
978
|
+
validator: name,
|
|
979
|
+
severity,
|
|
980
|
+
source: source.toString(),
|
|
981
|
+
});
|
|
982
|
+
return { result: TopicValidatorResult.Reject, severity };
|
|
924
983
|
}
|
|
925
984
|
|
|
926
985
|
// Pool pre-check: see if the pool would accept this tx before doing expensive proof verification
|
|
927
986
|
const canAdd = await this.mempools.txPool.canAddPendingTx(tx);
|
|
928
987
|
if (canAdd === 'ignored') {
|
|
988
|
+
this.logger.verbose(`Ignoring gossiped tx ${tx.getTxHash().toString()}: pool pre-check returned ignored`, {
|
|
989
|
+
source: source.toString(),
|
|
990
|
+
});
|
|
929
991
|
return { result: TopicValidatorResult.Ignore, obj: tx };
|
|
930
992
|
}
|
|
931
993
|
|
|
@@ -933,9 +995,13 @@ export class LibP2PService extends WithTracer implements P2PService {
|
|
|
933
995
|
const secondStageValidators = this.createSecondStageMessageValidators();
|
|
934
996
|
const secondStageOutcome = await this.runValidations(tx, secondStageValidators);
|
|
935
997
|
if (!secondStageOutcome.allPassed) {
|
|
936
|
-
const { severity } = secondStageOutcome.failure;
|
|
937
|
-
this.
|
|
938
|
-
|
|
998
|
+
const { severity, name } = secondStageOutcome.failure;
|
|
999
|
+
this.logger.verbose(`Rejecting gossiped tx ${tx.getTxHash().toString()}: stage 2 validation failed`, {
|
|
1000
|
+
validator: name,
|
|
1001
|
+
severity,
|
|
1002
|
+
source: source.toString(),
|
|
1003
|
+
});
|
|
1004
|
+
return { result: TopicValidatorResult.Reject, severity };
|
|
939
1005
|
}
|
|
940
1006
|
|
|
941
1007
|
// Pool add: persist the tx
|
|
@@ -945,7 +1011,7 @@ export class LibP2PService extends WithTracer implements P2PService {
|
|
|
945
1011
|
const wasAccepted = addResult.accepted.some(h => h.equals(txHash));
|
|
946
1012
|
const wasIgnored = addResult.ignored.some(h => h.equals(txHash));
|
|
947
1013
|
|
|
948
|
-
this.logger.
|
|
1014
|
+
this.logger.verbose(`Validate propagated tx ${txHash.toString()}`, {
|
|
949
1015
|
wasAccepted,
|
|
950
1016
|
wasIgnored,
|
|
951
1017
|
[Attributes.P2P_ID]: source.toString(),
|
|
@@ -956,7 +1022,11 @@ export class LibP2PService extends WithTracer implements P2PService {
|
|
|
956
1022
|
} else if (wasIgnored) {
|
|
957
1023
|
return { result: TopicValidatorResult.Ignore, obj: tx };
|
|
958
1024
|
} else {
|
|
959
|
-
|
|
1025
|
+
this.logger.warn(`Gossiped tx ${txHash.toString()} unexpectedly rejected by pool`, {
|
|
1026
|
+
source: source.toString(),
|
|
1027
|
+
txHash: txHash.toString(),
|
|
1028
|
+
});
|
|
1029
|
+
return { result: TopicValidatorResult.Reject, severity: PeerErrorSeverity.HighToleranceError };
|
|
960
1030
|
}
|
|
961
1031
|
};
|
|
962
1032
|
|
|
@@ -986,7 +1056,16 @@ export class LibP2PService extends WithTracer implements P2PService {
|
|
|
986
1056
|
source: PeerId,
|
|
987
1057
|
): Promise<void> {
|
|
988
1058
|
const { result, obj: attestation } = await this.validateReceivedMessage<CheckpointAttestation>(
|
|
989
|
-
() =>
|
|
1059
|
+
() => {
|
|
1060
|
+
const attestation = this.tryDeserialize(() => CheckpointAttestation.fromBuffer(payloadData), msgId, source);
|
|
1061
|
+
if (!attestation) {
|
|
1062
|
+
return Promise.resolve({
|
|
1063
|
+
result: TopicValidatorResult.Reject,
|
|
1064
|
+
severity: PeerErrorSeverity.LowToleranceError,
|
|
1065
|
+
});
|
|
1066
|
+
}
|
|
1067
|
+
return this.validateAndStoreCheckpointAttestation(source, attestation);
|
|
1068
|
+
},
|
|
990
1069
|
msgId,
|
|
991
1070
|
source,
|
|
992
1071
|
TopicType.checkpoint_attestation,
|
|
@@ -1019,8 +1098,7 @@ export class LibP2PService extends WithTracer implements P2PService {
|
|
|
1019
1098
|
|
|
1020
1099
|
if (validationResult.result === 'reject') {
|
|
1021
1100
|
this.logger.warn(`Penalizing peer ${peerId} for checkpoint attestation validation failure`);
|
|
1022
|
-
|
|
1023
|
-
return { result: TopicValidatorResult.Reject };
|
|
1101
|
+
return { result: TopicValidatorResult.Reject, severity: validationResult.severity };
|
|
1024
1102
|
}
|
|
1025
1103
|
|
|
1026
1104
|
if (validationResult.result === 'ignore') {
|
|
@@ -1046,16 +1124,16 @@ export class LibP2PService extends WithTracer implements P2PService {
|
|
|
1046
1124
|
return { result: TopicValidatorResult.Ignore, obj: attestation };
|
|
1047
1125
|
}
|
|
1048
1126
|
|
|
1049
|
-
// Could not add (cap reached for signer),
|
|
1127
|
+
// Could not add (cap reached for signer), penalize and do not re-broadcast
|
|
1050
1128
|
if (!added) {
|
|
1051
|
-
this.logger.warn(`
|
|
1129
|
+
this.logger.warn(`Rejecting checkpoint attestation due to cap`, {
|
|
1052
1130
|
slot: slot.toString(),
|
|
1053
1131
|
archive: attestation.archive.toString(),
|
|
1054
1132
|
source: peerId.toString(),
|
|
1055
1133
|
attester: attestation.getSender()?.toString(),
|
|
1056
1134
|
count,
|
|
1057
1135
|
});
|
|
1058
|
-
return { result: TopicValidatorResult.
|
|
1136
|
+
return { result: TopicValidatorResult.Reject, severity: PeerErrorSeverity.HighToleranceError };
|
|
1059
1137
|
}
|
|
1060
1138
|
|
|
1061
1139
|
// Check if this is a duplicate attestation (signer attested to a different proposal at the same slot)
|
|
@@ -1110,8 +1188,7 @@ export class LibP2PService extends WithTracer implements P2PService {
|
|
|
1110
1188
|
|
|
1111
1189
|
if (validationResult.result === 'reject') {
|
|
1112
1190
|
this.logger.warn(`Penalizing peer ${peerId} for block proposal validation failure`);
|
|
1113
|
-
|
|
1114
|
-
return { result: TopicValidatorResult.Reject };
|
|
1191
|
+
return { result: TopicValidatorResult.Reject, severity: validationResult.severity };
|
|
1115
1192
|
}
|
|
1116
1193
|
|
|
1117
1194
|
if (validationResult.result === 'ignore') {
|
|
@@ -1135,7 +1212,6 @@ export class LibP2PService extends WithTracer implements P2PService {
|
|
|
1135
1212
|
|
|
1136
1213
|
// Too many blocks received for this slot and index, penalize peer and do not re-broadcast
|
|
1137
1214
|
if (!added) {
|
|
1138
|
-
this.peerManager.penalizePeer(peerId, PeerErrorSeverity.HighToleranceError);
|
|
1139
1215
|
this.logger.warn(`Penalizing peer for block proposal exceeding per-position cap`, {
|
|
1140
1216
|
...block.toBlockInfo(),
|
|
1141
1217
|
indexWithinCheckpoint: block.indexWithinCheckpoint,
|
|
@@ -1143,7 +1219,11 @@ export class LibP2PService extends WithTracer implements P2PService {
|
|
|
1143
1219
|
proposer: block.getSender()?.toString(),
|
|
1144
1220
|
source: peerId.toString(),
|
|
1145
1221
|
});
|
|
1146
|
-
return {
|
|
1222
|
+
return {
|
|
1223
|
+
result: TopicValidatorResult.Reject,
|
|
1224
|
+
metadata: { isEquivocated },
|
|
1225
|
+
severity: PeerErrorSeverity.HighToleranceError,
|
|
1226
|
+
};
|
|
1147
1227
|
}
|
|
1148
1228
|
|
|
1149
1229
|
// If this was a duplicate proposal, do not process it, but do invoke the duplicate callback,
|
|
@@ -1188,7 +1268,7 @@ export class LibP2PService extends WithTracer implements P2PService {
|
|
|
1188
1268
|
// Note: Validators do NOT attest to individual blocks, only to checkpoint proposals.
|
|
1189
1269
|
const isValid = await this.blockReceivedCallback(block, sender);
|
|
1190
1270
|
if (!isValid) {
|
|
1191
|
-
this.logger.
|
|
1271
|
+
this.logger.info(`Block proposal validation failed for block ${block.blockNumber}`, block.toBlockInfo());
|
|
1192
1272
|
}
|
|
1193
1273
|
}
|
|
1194
1274
|
|
|
@@ -1236,8 +1316,7 @@ export class LibP2PService extends WithTracer implements P2PService {
|
|
|
1236
1316
|
|
|
1237
1317
|
if (validationResult.result === 'reject') {
|
|
1238
1318
|
this.logger.warn(`Penalizing peer ${peerId} for checkpoint proposal validation failure`);
|
|
1239
|
-
|
|
1240
|
-
return { result: TopicValidatorResult.Reject };
|
|
1319
|
+
return { result: TopicValidatorResult.Reject, severity: validationResult.severity };
|
|
1241
1320
|
}
|
|
1242
1321
|
|
|
1243
1322
|
if (validationResult.result === 'ignore') {
|
|
@@ -1252,20 +1331,21 @@ export class LibP2PService extends WithTracer implements P2PService {
|
|
|
1252
1331
|
[Attributes.SLOT_NUMBER]: checkpoint.slotNumber.toString(),
|
|
1253
1332
|
[Attributes.P2P_ID]: peerId.toString(),
|
|
1254
1333
|
});
|
|
1255
|
-
const
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
metadata: { isEquivocated } = {},
|
|
1259
|
-
} = await this.validateAndStoreBlockProposal(peerId, blockProposal);
|
|
1260
|
-
if (result === TopicValidatorResult.Reject || !obj || isEquivocated) {
|
|
1334
|
+
const blockProposalResult = await this.validateAndStoreBlockProposal(peerId, blockProposal);
|
|
1335
|
+
const { obj, metadata: { isEquivocated } = {} } = blockProposalResult;
|
|
1336
|
+
if (blockProposalResult.result === TopicValidatorResult.Reject || !obj || isEquivocated) {
|
|
1261
1337
|
this.logger.debug(`Rejecting checkpoint due to invalid last block proposal`, {
|
|
1262
1338
|
[Attributes.SLOT_NUMBER]: checkpoint.slotNumber.toString(),
|
|
1263
1339
|
[Attributes.P2P_ID]: peerId.toString(),
|
|
1264
1340
|
isEquivocated,
|
|
1265
|
-
result,
|
|
1341
|
+
result: blockProposalResult.result,
|
|
1266
1342
|
});
|
|
1267
|
-
return {
|
|
1268
|
-
|
|
1343
|
+
return {
|
|
1344
|
+
result: TopicValidatorResult.Reject,
|
|
1345
|
+
severity:
|
|
1346
|
+
'severity' in blockProposalResult ? blockProposalResult.severity : PeerErrorSeverity.MidToleranceError,
|
|
1347
|
+
};
|
|
1348
|
+
} else if (blockProposalResult.result === TopicValidatorResult.Accept && obj && !isEquivocated) {
|
|
1269
1349
|
processBlock = true;
|
|
1270
1350
|
}
|
|
1271
1351
|
}
|
|
@@ -1292,13 +1372,17 @@ export class LibP2PService extends WithTracer implements P2PService {
|
|
|
1292
1372
|
// Too many checkpoint proposals received for this slot, penalize peer and do not re-broadcast
|
|
1293
1373
|
// Note: We still return the checkpoint obj so the lastBlock can be processed if valid
|
|
1294
1374
|
if (!added) {
|
|
1295
|
-
this.peerManager.penalizePeer(peerId, PeerErrorSeverity.HighToleranceError);
|
|
1296
1375
|
this.logger.warn(`Penalizing peer for checkpoint proposal exceeding per-slot cap`, {
|
|
1297
1376
|
...checkpoint.toCheckpointInfo(),
|
|
1298
1377
|
count,
|
|
1299
1378
|
source: peerId.toString(),
|
|
1300
1379
|
});
|
|
1301
|
-
return {
|
|
1380
|
+
return {
|
|
1381
|
+
result: TopicValidatorResult.Reject,
|
|
1382
|
+
obj: checkpoint,
|
|
1383
|
+
metadata: { isEquivocated, processBlock },
|
|
1384
|
+
severity: PeerErrorSeverity.HighToleranceError,
|
|
1385
|
+
};
|
|
1302
1386
|
}
|
|
1303
1387
|
|
|
1304
1388
|
// If this was a duplicate proposal, do not process it, but do invoke the duplicate callback,
|
|
@@ -1343,9 +1427,11 @@ export class LibP2PService extends WithTracer implements P2PService {
|
|
|
1343
1427
|
source: sender.toString(),
|
|
1344
1428
|
});
|
|
1345
1429
|
|
|
1430
|
+
await this.allNodesCheckpointReceivedCallback(checkpoint, sender);
|
|
1431
|
+
|
|
1346
1432
|
// Call the checkpoint received callback with the core version (without lastBlock)
|
|
1347
1433
|
// to validate and potentially generate attestations
|
|
1348
|
-
const attestations = await this.
|
|
1434
|
+
const attestations = await this.validatorCheckpointReceivedCallback(checkpoint, sender);
|
|
1349
1435
|
if (attestations && attestations.length > 0) {
|
|
1350
1436
|
// If the callback returned attestations, add them to the pool and propagate them
|
|
1351
1437
|
await this.mempools.attestationPool.addOwnCheckpointAttestations(attestations);
|
|
@@ -1493,53 +1579,6 @@ export class LibP2PService extends WithTracer implements P2PService {
|
|
|
1493
1579
|
}
|
|
1494
1580
|
}
|
|
1495
1581
|
|
|
1496
|
-
/**
|
|
1497
|
-
* Validates a BLOCK response.
|
|
1498
|
-
*
|
|
1499
|
-
* If a local copy exists, enforces hash equality. If missing, rejects (no penalty) since the hash cannot be verified.
|
|
1500
|
-
* Penalizes on block number mismatch or hash mismatch.
|
|
1501
|
-
*
|
|
1502
|
-
* @param requestedBlockNumber - The requested block number.
|
|
1503
|
-
* @param responseBlock - The block returned by the peer.
|
|
1504
|
-
* @param peerId - The peer that returned the block.
|
|
1505
|
-
* @returns True if the response is valid, false otherwise.
|
|
1506
|
-
*/
|
|
1507
|
-
@trackSpan('Libp2pService.validateRequestedBlock', (requestedBlockNumber, _responseBlock) => ({
|
|
1508
|
-
[Attributes.BLOCK_NUMBER]: requestedBlockNumber.toString(),
|
|
1509
|
-
}))
|
|
1510
|
-
protected async validateRequestedBlock(
|
|
1511
|
-
requestedBlockNumber: Fr,
|
|
1512
|
-
responseBlock: L2Block,
|
|
1513
|
-
peerId: PeerId,
|
|
1514
|
-
): Promise<boolean> {
|
|
1515
|
-
try {
|
|
1516
|
-
const reqNum = Number(requestedBlockNumber.toString());
|
|
1517
|
-
if (responseBlock.number !== reqNum) {
|
|
1518
|
-
this.peerManager.penalizePeer(peerId, PeerErrorSeverity.LowToleranceError);
|
|
1519
|
-
return false;
|
|
1520
|
-
}
|
|
1521
|
-
|
|
1522
|
-
const local = await this.archiver.getBlock(BlockNumber(reqNum));
|
|
1523
|
-
if (!local) {
|
|
1524
|
-
// We are missing the local block; we cannot verify the hash yet. Reject without penalizing.
|
|
1525
|
-
// TODO: Consider extending this validator to accept an expected hash or
|
|
1526
|
-
// performing quorum-based checks when using P2P syncing prior to L1 sync.
|
|
1527
|
-
this.logger.warn(`Local block ${reqNum} not found; rejecting BLOCK response without hash verification`);
|
|
1528
|
-
return false;
|
|
1529
|
-
}
|
|
1530
|
-
const [localHash, respHash] = await Promise.all([local.hash(), responseBlock.hash()]);
|
|
1531
|
-
if (!localHash.equals(respHash)) {
|
|
1532
|
-
this.peerManager.penalizePeer(peerId, PeerErrorSeverity.MidToleranceError);
|
|
1533
|
-
return false;
|
|
1534
|
-
}
|
|
1535
|
-
|
|
1536
|
-
return true;
|
|
1537
|
-
} catch (e) {
|
|
1538
|
-
this.logger.warn(`Error validating requested block`, e);
|
|
1539
|
-
return false;
|
|
1540
|
-
}
|
|
1541
|
-
}
|
|
1542
|
-
|
|
1543
1582
|
protected async validateRequestedTx(
|
|
1544
1583
|
tx: Tx,
|
|
1545
1584
|
peerId: PeerId,
|
|
@@ -1617,8 +1656,12 @@ export class LibP2PService extends WithTracer implements P2PService {
|
|
|
1617
1656
|
nextSlotTimestamp: UInt64,
|
|
1618
1657
|
): Promise<Record<string, TransactionValidator>> {
|
|
1619
1658
|
const gasFees = await this.getGasFees(currentBlockNumber);
|
|
1620
|
-
const allowedInSetup =
|
|
1659
|
+
const allowedInSetup = [
|
|
1660
|
+
...(await getDefaultAllowedSetupFunctions()),
|
|
1661
|
+
...(this.config.txPublicSetupAllowListExtend ?? []),
|
|
1662
|
+
];
|
|
1621
1663
|
const blockNumber = BlockNumber(currentBlockNumber + 1);
|
|
1664
|
+
const l1Constants = await this.archiver.getL1Constants();
|
|
1622
1665
|
|
|
1623
1666
|
return createFirstStageTxValidationsForGossipedTransactions(
|
|
1624
1667
|
nextSlotTimestamp,
|
|
@@ -1632,6 +1675,11 @@ export class LibP2PService extends WithTracer implements P2PService {
|
|
|
1632
1675
|
!this.config.disableTransactions,
|
|
1633
1676
|
allowedInSetup,
|
|
1634
1677
|
this.logger.getBindings(),
|
|
1678
|
+
{
|
|
1679
|
+
rollupManaLimit: l1Constants.rollupManaLimit,
|
|
1680
|
+
maxBlockL2Gas: this.config.validateMaxL2BlockGas,
|
|
1681
|
+
maxBlockDAGas: this.config.validateMaxDABlockGas,
|
|
1682
|
+
},
|
|
1635
1683
|
);
|
|
1636
1684
|
}
|
|
1637
1685
|
|
|
@@ -1657,8 +1705,10 @@ export class LibP2PService extends WithTracer implements P2PService {
|
|
|
1657
1705
|
|
|
1658
1706
|
// A promise that resolves when all validations have been run
|
|
1659
1707
|
const allValidations = await Promise.all(validationPromises);
|
|
1660
|
-
const
|
|
1661
|
-
if (
|
|
1708
|
+
const failures = allValidations.filter(x => !x.isValid);
|
|
1709
|
+
if (failures.length > 0) {
|
|
1710
|
+
// Pick the most severe failure (lowest tolerance = harshest penalty)
|
|
1711
|
+
const failed = maxBy(failures, f => PeerErrorSeverityByHarshness.indexOf(f.severity))!;
|
|
1662
1712
|
return {
|
|
1663
1713
|
allPassed: false,
|
|
1664
1714
|
failure: {
|
|
@@ -1711,31 +1761,6 @@ export class LibP2PService extends WithTracer implements P2PService {
|
|
|
1711
1761
|
return PeerErrorSeverity.HighToleranceError;
|
|
1712
1762
|
}
|
|
1713
1763
|
|
|
1714
|
-
/**
|
|
1715
|
-
* Validate a checkpoint attestation.
|
|
1716
|
-
*
|
|
1717
|
-
* @param attestation - The checkpoint attestation to validate.
|
|
1718
|
-
* @returns True if the checkpoint attestation is valid, false otherwise.
|
|
1719
|
-
*/
|
|
1720
|
-
@trackSpan('Libp2pService.validateCheckpointAttestation', async (_, attestation) => ({
|
|
1721
|
-
[Attributes.SLOT_NUMBER]: attestation.payload.header.slotNumber,
|
|
1722
|
-
[Attributes.BLOCK_ARCHIVE]: attestation.archive.toString(),
|
|
1723
|
-
[Attributes.P2P_ID]: await attestation.p2pMessageLoggingIdentifier().then(i => i.toString()),
|
|
1724
|
-
}))
|
|
1725
|
-
public async validateCheckpointAttestation(
|
|
1726
|
-
peerId: PeerId,
|
|
1727
|
-
attestation: CheckpointAttestation,
|
|
1728
|
-
): Promise<P2PValidationResult> {
|
|
1729
|
-
const result = await this.checkpointAttestationValidator.validate(attestation);
|
|
1730
|
-
|
|
1731
|
-
if (result.result === 'reject') {
|
|
1732
|
-
this.logger.warn(`Penalizing peer ${peerId} for checkpoint attestation validation failure`);
|
|
1733
|
-
this.peerManager.penalizePeer(peerId, result.severity);
|
|
1734
|
-
}
|
|
1735
|
-
|
|
1736
|
-
return result;
|
|
1737
|
-
}
|
|
1738
|
-
|
|
1739
1764
|
public getPeerScore(peerId: PeerId): number {
|
|
1740
1765
|
return this.node.services.pubsub.score.score(peerId.toString());
|
|
1741
1766
|
}
|
|
@@ -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
|
}
|