@aztec/p2p 0.0.1-commit.934299a21 → 0.0.1-commit.949a33fd8
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 +6 -6
- package/dest/client/factory.d.ts.map +1 -1
- package/dest/client/factory.js +29 -14
- package/dest/client/interface.d.ts +12 -5
- package/dest/client/interface.d.ts.map +1 -1
- package/dest/client/p2p_client.d.ts +6 -5
- package/dest/client/p2p_client.d.ts.map +1 -1
- package/dest/client/p2p_client.js +47 -39
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.js +21 -8
- package/dest/config.d.ts +128 -100
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +97 -34
- 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/attestation_pool/mocks.d.ts +1 -1
- package/dest/mem_pools/attestation_pool/mocks.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/mocks.js +6 -4
- 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 +33 -15
- 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/fee_payer_balance_pre_add_rule.d.ts +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.js +2 -0
- package/dest/mem_pools/tx_pool_v2/eviction/index.d.ts +2 -1
- package/dest/mem_pools/tx_pool_v2/eviction/index.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/index.js +1 -0
- package/dest/mem_pools/tx_pool_v2/eviction/insufficient_fee_per_gas_eviction_rule.d.ts +16 -0
- package/dest/mem_pools/tx_pool_v2/eviction/insufficient_fee_per_gas_eviction_rule.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/eviction/insufficient_fee_per_gas_eviction_rule.js +62 -0
- 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/invalid_txs_after_reorg_rule.js +2 -2
- 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/index.d.ts +2 -2
- package/dest/mem_pools/tx_pool_v2/index.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/index.js +1 -1
- package/dest/mem_pools/tx_pool_v2/interfaces.d.ts +12 -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 +44 -12
- package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/tx_metadata.js +81 -22
- 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 -44
- 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 +62 -29
- package/dest/msg_validators/attestation_validator/attestation_validator.d.ts +9 -3
- package/dest/msg_validators/attestation_validator/attestation_validator.d.ts.map +1 -1
- package/dest/msg_validators/attestation_validator/attestation_validator.js +37 -12
- package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.d.ts +7 -3
- package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.d.ts.map +1 -1
- package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.js +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 +61 -3
- package/dest/msg_validators/proposal_validator/block_proposal_validator.d.ts +8 -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 +8 -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 +17 -8
- package/dest/msg_validators/proposal_validator/proposal_validator.d.ts.map +1 -1
- package/dest/msg_validators/proposal_validator/proposal_validator.js +83 -48
- 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 +37 -11
- 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 +48 -7
- package/dest/msg_validators/tx_validator/gas_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/gas_validator.js +88 -41
- 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 +6 -2
- package/dest/services/encoding.d.ts.map +1 -1
- package/dest/services/encoding.js +14 -8
- 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 +23 -32
- package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
- package/dest/services/libp2p/libp2p_service.js +202 -151
- 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 +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/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 +5 -6
- package/dest/test-helpers/make-test-p2p-clients.d.ts.map +1 -1
- package/dest/test-helpers/make-test-p2p-clients.js +4 -2
- package/dest/test-helpers/mock-pubsub.d.ts +12 -5
- package/dest/test-helpers/mock-pubsub.d.ts.map +1 -1
- package/dest/test-helpers/mock-pubsub.js +37 -12
- package/dest/test-helpers/reqresp-nodes.d.ts +2 -3
- package/dest/test-helpers/reqresp-nodes.d.ts.map +1 -1
- package/dest/test-helpers/reqresp-nodes.js +6 -4
- 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.d.ts +1 -1
- package/dest/testbench/p2p_client_testbench_worker.d.ts.map +1 -1
- package/dest/testbench/p2p_client_testbench_worker.js +78 -21
- 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 +48 -19
- package/src/client/interface.ts +12 -10
- package/src/client/p2p_client.ts +52 -51
- package/src/client/test/tx_proposal_collector/proposal_tx_collector_worker.ts +22 -11
- package/src/config.ts +146 -36
- 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/attestation_pool/mocks.ts +13 -8
- package/src/mem_pools/index.ts +0 -3
- package/src/mem_pools/instrumentation.ts +22 -14
- 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/fee_payer_balance_pre_add_rule.ts +3 -0
- package/src/mem_pools/tx_pool_v2/eviction/index.ts +1 -0
- package/src/mem_pools/tx_pool_v2/eviction/insufficient_fee_per_gas_eviction_rule.ts +65 -0
- package/src/mem_pools/tx_pool_v2/eviction/interfaces.ts +11 -1
- package/src/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.ts +3 -3
- 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/index.ts +1 -1
- package/src/mem_pools/tx_pool_v2/interfaces.ts +12 -4
- package/src/mem_pools/tx_pool_v2/tx_metadata.ts +121 -27
- 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 +70 -26
- package/src/msg_validators/attestation_validator/README.md +49 -0
- package/src/msg_validators/attestation_validator/attestation_validator.ts +41 -9
- package/src/msg_validators/attestation_validator/fisherman_attestation_validator.ts +12 -2
- package/src/msg_validators/clock_tolerance.ts +79 -3
- package/src/msg_validators/proposal_validator/README.md +123 -0
- package/src/msg_validators/proposal_validator/block_proposal_validator.ts +22 -4
- package/src/msg_validators/proposal_validator/checkpoint_proposal_validator.ts +33 -7
- package/src/msg_validators/proposal_validator/proposal_validator.ts +99 -49
- package/src/msg_validators/tx_validator/README.md +15 -3
- 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 +46 -4
- package/src/msg_validators/tx_validator/fee_payer_balance.ts +6 -2
- package/src/msg_validators/tx_validator/gas_validator.ts +121 -39
- 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 +14 -7
- 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 +206 -164
- 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 +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/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 +3 -3
- package/src/test-helpers/mock-pubsub.ts +37 -11
- package/src/test-helpers/reqresp-nodes.ts +7 -8
- package/src/test-helpers/testbench-utils.ts +30 -3
- package/src/testbench/p2p_client_testbench_worker.ts +77 -21
- 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,14 +1,14 @@
|
|
|
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, merge } 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
|
-
import { GasFees } from '@aztec/stdlib/gas';
|
|
11
|
+
import { type BlockMinFeesProvider, GasFees } from '@aztec/stdlib/gas';
|
|
12
12
|
import type { ClientProtocolCircuitVerifier, PeerInfo, WorldStateSynchronizer } from '@aztec/stdlib/interfaces/server';
|
|
13
13
|
import {
|
|
14
14
|
BlockProposal,
|
|
@@ -16,13 +16,12 @@ import {
|
|
|
16
16
|
CheckpointProposal,
|
|
17
17
|
type CheckpointProposalCore,
|
|
18
18
|
type Gossipable,
|
|
19
|
-
P2PClientType,
|
|
20
19
|
P2PMessage,
|
|
21
|
-
type ValidationResult as P2PValidationResult,
|
|
22
20
|
PeerErrorSeverity,
|
|
21
|
+
PeerErrorSeverityByHarshness,
|
|
23
22
|
TopicType,
|
|
24
23
|
createTopicString,
|
|
25
|
-
|
|
24
|
+
getTopicsForConfig,
|
|
26
25
|
metricsTopicStrToLabels,
|
|
27
26
|
} from '@aztec/stdlib/p2p';
|
|
28
27
|
import { MerkleTreeId } from '@aztec/stdlib/trees';
|
|
@@ -58,6 +57,7 @@ import { ENR } from '@nethermindeth/enr';
|
|
|
58
57
|
import { createLibp2p } from 'libp2p';
|
|
59
58
|
|
|
60
59
|
import type { P2PConfig } from '../../config.js';
|
|
60
|
+
import { CheckpointProposalReceivedCallbackNotRegisteredError } from '../../errors/p2p-service.error.js';
|
|
61
61
|
import type { MemPools } from '../../mem_pools/interface.js';
|
|
62
62
|
import {
|
|
63
63
|
BlockProposalValidator,
|
|
@@ -104,7 +104,6 @@ import {
|
|
|
104
104
|
ValidationError,
|
|
105
105
|
pingHandler,
|
|
106
106
|
reqGoodbyeHandler,
|
|
107
|
-
reqRespBlockHandler,
|
|
108
107
|
reqRespBlockTxsHandler,
|
|
109
108
|
reqRespStatusHandler,
|
|
110
109
|
reqRespTxHandler,
|
|
@@ -130,12 +129,12 @@ type ValidationOutcome = { allPassed: true } | { allPassed: false; failure: Vali
|
|
|
130
129
|
// REFACTOR: Unify with the type above
|
|
131
130
|
type ReceivedMessageValidationResult<T, M = undefined> =
|
|
132
131
|
| { obj: T; result: Exclude<TopicValidatorResult, TopicValidatorResult.Reject>; metadata?: M }
|
|
133
|
-
| { obj?: T; result: TopicValidatorResult.Reject; metadata?: M };
|
|
132
|
+
| { obj?: T; result: TopicValidatorResult.Reject; metadata?: M; severity: PeerErrorSeverity };
|
|
134
133
|
|
|
135
134
|
/**
|
|
136
135
|
* Lib P2P implementation of the P2PService interface.
|
|
137
136
|
*/
|
|
138
|
-
export class LibP2PService
|
|
137
|
+
export class LibP2PService extends WithTracer implements P2PService {
|
|
139
138
|
private discoveryRunningPromise?: RunningPromise;
|
|
140
139
|
private msgIdSeenValidators: Record<TopicType, MessageSeenValidator> = {} as Record<TopicType, MessageSeenValidator>;
|
|
141
140
|
|
|
@@ -147,8 +146,6 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
147
146
|
private protocolVersion = '';
|
|
148
147
|
private topicStrings: Record<TopicType, string> = {} as Record<TopicType, string>;
|
|
149
148
|
|
|
150
|
-
private feesCache: { blockNumber: BlockNumber; gasFees: GasFees } | undefined;
|
|
151
|
-
|
|
152
149
|
/** Callback invoked when a duplicate proposal is detected (triggers slashing). */
|
|
153
150
|
private duplicateProposalCallback?: (info: {
|
|
154
151
|
slot: SlotNumber;
|
|
@@ -171,7 +168,13 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
171
168
|
* @param checkpoint - The checkpoint proposal received from the peer.
|
|
172
169
|
* @returns The attestations for the checkpoint, if any.
|
|
173
170
|
*/
|
|
174
|
-
private
|
|
171
|
+
private allNodesCheckpointReceivedCallback: P2PCheckpointReceivedCallback;
|
|
172
|
+
/**
|
|
173
|
+
* Callback for when a checkpoint proposal is received - specifically for validators - from a peer.
|
|
174
|
+
* @param checkpoint - The checkpoint proposal received from the peer.
|
|
175
|
+
* @returns The attestations for the checkpoint, if any.
|
|
176
|
+
*/
|
|
177
|
+
private validatorCheckpointReceivedCallback: P2PCheckpointReceivedCallback;
|
|
175
178
|
|
|
176
179
|
private gossipSubEventHandler: (e: CustomEvent<GossipsubMessage>) => void;
|
|
177
180
|
|
|
@@ -182,7 +185,6 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
182
185
|
protected logger: Logger;
|
|
183
186
|
|
|
184
187
|
constructor(
|
|
185
|
-
private clientType: T,
|
|
186
188
|
private config: P2PConfig,
|
|
187
189
|
protected node: PubSubLibp2p,
|
|
188
190
|
private peerDiscoveryService: PeerDiscoveryService,
|
|
@@ -193,6 +195,7 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
193
195
|
private epochCache: EpochCacheInterface,
|
|
194
196
|
private proofVerifier: ClientProtocolCircuitVerifier,
|
|
195
197
|
private worldStateSynchronizer: WorldStateSynchronizer,
|
|
198
|
+
private blockMinFeesProvider: BlockMinFeesProvider,
|
|
196
199
|
telemetry: TelemetryClient,
|
|
197
200
|
logger: Logger = createLogger('p2p:libp2p_service'),
|
|
198
201
|
) {
|
|
@@ -224,36 +227,53 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
224
227
|
this.protocolVersion,
|
|
225
228
|
);
|
|
226
229
|
|
|
227
|
-
|
|
228
|
-
|
|
230
|
+
const p2pPropagationTime = config.attestationPropagationTime;
|
|
231
|
+
const proposalValidatorOpts = {
|
|
229
232
|
txsPermitted: !config.disableTransactions,
|
|
230
|
-
|
|
233
|
+
maxTxsPerBlock: config.validateMaxTxsPerBlock ?? config.validateMaxTxsPerCheckpoint,
|
|
234
|
+
p2pPropagationTime,
|
|
235
|
+
signatureContext: {
|
|
236
|
+
chainId: config.l1ChainId,
|
|
237
|
+
rollupAddress: config.l1Contracts.rollupAddress,
|
|
238
|
+
},
|
|
239
|
+
};
|
|
240
|
+
this.blockProposalValidator = new BlockProposalValidator(epochCache, proposalValidatorOpts);
|
|
241
|
+
this.checkpointProposalValidator = new CheckpointProposalValidator(epochCache, proposalValidatorOpts);
|
|
242
|
+
const attestationValidatorOpts = {
|
|
243
|
+
l1PublishingTime: config.l1PublishingTime,
|
|
244
|
+
p2pPropagationTime,
|
|
245
|
+
signatureContext: proposalValidatorOpts.signatureContext,
|
|
246
|
+
};
|
|
231
247
|
this.checkpointAttestationValidator = config.fishermanMode
|
|
232
|
-
? new FishermanAttestationValidator(epochCache, mempools.attestationPool, telemetry)
|
|
233
|
-
: new CheckpointAttestationValidator(epochCache);
|
|
248
|
+
? new FishermanAttestationValidator(epochCache, mempools.attestationPool, telemetry, attestationValidatorOpts)
|
|
249
|
+
: new CheckpointAttestationValidator(epochCache, attestationValidatorOpts);
|
|
234
250
|
|
|
235
251
|
this.gossipSubEventHandler = this.handleGossipSubEvent.bind(this);
|
|
236
252
|
|
|
237
253
|
this.blockReceivedCallback = async (block: BlockProposal): Promise<boolean> => {
|
|
238
|
-
this.logger.
|
|
239
|
-
`Handler not yet registered
|
|
254
|
+
this.logger.warn(
|
|
255
|
+
`Handler for block received not yet registered on P2P service. Received block ${block.blockNumber} for slot ${block.slotNumber} from peer.`,
|
|
240
256
|
{ p2pMessageIdentifier: await block.p2pMessageLoggingIdentifier() },
|
|
241
257
|
);
|
|
242
|
-
return
|
|
258
|
+
return true;
|
|
243
259
|
};
|
|
244
260
|
|
|
245
|
-
this.
|
|
246
|
-
|
|
261
|
+
this.allNodesCheckpointReceivedCallback = (
|
|
262
|
+
_checkpoint: CheckpointProposalCore,
|
|
263
|
+
): Promise<CheckpointAttestation[] | undefined> => {
|
|
264
|
+
throw new CheckpointProposalReceivedCallbackNotRegisteredError();
|
|
265
|
+
};
|
|
266
|
+
|
|
267
|
+
this.validatorCheckpointReceivedCallback = (
|
|
268
|
+
_checkpoint: CheckpointProposalCore,
|
|
247
269
|
): Promise<CheckpointAttestation[] | undefined> => {
|
|
248
|
-
this.logger.debug(
|
|
249
|
-
`Handler not yet registered: Checkpoint received callback not set. Received checkpoint for slot ${checkpoint.slotNumber} from peer.`,
|
|
250
|
-
);
|
|
251
270
|
return Promise.resolve(undefined);
|
|
252
271
|
};
|
|
253
272
|
}
|
|
254
273
|
|
|
255
|
-
public updateConfig(config: Partial<P2PReqRespConfig
|
|
274
|
+
public updateConfig(config: Partial<P2PReqRespConfig & Pick<P2PConfig, 'skipIncomingProposals'>>) {
|
|
256
275
|
this.reqresp.updateConfig(config);
|
|
276
|
+
this.config = merge(this.config, config);
|
|
257
277
|
}
|
|
258
278
|
|
|
259
279
|
/**
|
|
@@ -262,8 +282,7 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
262
282
|
* @param txPool - The transaction pool to be accessed by the service.
|
|
263
283
|
* @returns The new service.
|
|
264
284
|
*/
|
|
265
|
-
public static async new
|
|
266
|
-
clientType: T,
|
|
285
|
+
public static async new(
|
|
267
286
|
config: P2PConfig,
|
|
268
287
|
peerId: PeerId,
|
|
269
288
|
deps: {
|
|
@@ -273,6 +292,7 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
273
292
|
proofVerifier: ClientProtocolCircuitVerifier;
|
|
274
293
|
worldStateSynchronizer: WorldStateSynchronizer;
|
|
275
294
|
peerStore: AztecAsyncKVStore;
|
|
295
|
+
blockMinFeesProvider: BlockMinFeesProvider;
|
|
276
296
|
telemetry: TelemetryClient;
|
|
277
297
|
logger: Logger;
|
|
278
298
|
packageVersion: string;
|
|
@@ -285,6 +305,7 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
285
305
|
mempools,
|
|
286
306
|
proofVerifier,
|
|
287
307
|
peerStore,
|
|
308
|
+
blockMinFeesProvider,
|
|
288
309
|
telemetry,
|
|
289
310
|
logger,
|
|
290
311
|
packageVersion,
|
|
@@ -338,9 +359,12 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
338
359
|
const l1Constants = epochCache.getL1Constants();
|
|
339
360
|
const topicScoreParams = createAllTopicScoreParams(protocolVersion, {
|
|
340
361
|
slotDurationMs: l1Constants.slotDuration * 1000,
|
|
362
|
+
ethereumSlotDuration: l1Constants.ethereumSlotDuration,
|
|
341
363
|
heartbeatIntervalMs: config.gossipsubInterval,
|
|
342
364
|
targetCommitteeSize: l1Constants.targetCommitteeSize,
|
|
343
365
|
blockDurationMs: config.blockDurationMs,
|
|
366
|
+
l1PublishingTime: config.l1PublishingTime,
|
|
367
|
+
p2pPropagationTime: config.attestationPropagationTime,
|
|
344
368
|
expectedBlockProposalsPerSlot: config.expectedBlockProposalsPerSlot,
|
|
345
369
|
});
|
|
346
370
|
|
|
@@ -465,6 +489,9 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
465
489
|
epochCache,
|
|
466
490
|
);
|
|
467
491
|
|
|
492
|
+
// Gate req/resp data protocols for unauthenticated peers when p2pAllowOnlyValidators is enabled
|
|
493
|
+
reqresp.setShouldRejectPeer(peerId => peerManager.shouldDisableP2PGossip(peerId));
|
|
494
|
+
|
|
468
495
|
// Configure application-specific scoring for gossipsub.
|
|
469
496
|
// The weight scales app score to align with gossipsub thresholds:
|
|
470
497
|
// - Disconnect (-50) × 10 = -500 = gossipThreshold (stops receiving gossip)
|
|
@@ -475,7 +502,6 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
475
502
|
peerManager.shouldDisableP2PGossip(peerId) ? -Infinity : peerManager.getPeerScore(peerId);
|
|
476
503
|
|
|
477
504
|
return new LibP2PService(
|
|
478
|
-
clientType,
|
|
479
505
|
config,
|
|
480
506
|
node,
|
|
481
507
|
peerDiscoveryService,
|
|
@@ -486,6 +512,7 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
486
512
|
epochCache,
|
|
487
513
|
proofVerifier,
|
|
488
514
|
worldStateSynchronizer,
|
|
515
|
+
blockMinFeesProvider,
|
|
489
516
|
telemetry,
|
|
490
517
|
logger,
|
|
491
518
|
);
|
|
@@ -511,14 +538,12 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
511
538
|
// Create request response protocol handlers
|
|
512
539
|
const txHandler = reqRespTxHandler(this.mempools);
|
|
513
540
|
const goodbyeHandler = reqGoodbyeHandler(this.peerManager);
|
|
514
|
-
const blockHandler = reqRespBlockHandler(this.archiver);
|
|
515
541
|
const statusHandler = reqRespStatusHandler(this.protocolVersion, this.worldStateSynchronizer, this.logger);
|
|
516
542
|
|
|
517
543
|
const requestResponseHandlers: Partial<ReqRespSubProtocolHandlers> = {
|
|
518
544
|
[ReqRespSubProtocol.PING]: pingHandler,
|
|
519
545
|
[ReqRespSubProtocol.STATUS]: statusHandler.bind(this),
|
|
520
546
|
[ReqRespSubProtocol.GOODBYE]: goodbyeHandler.bind(this),
|
|
521
|
-
[ReqRespSubProtocol.BLOCK]: blockHandler.bind(this),
|
|
522
547
|
};
|
|
523
548
|
|
|
524
549
|
if (!this.config.disableTransactions) {
|
|
@@ -539,7 +564,6 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
539
564
|
...DEFAULT_SUB_PROTOCOL_VALIDATORS,
|
|
540
565
|
[ReqRespSubProtocol.TX]: this.validateRequestedTxs.bind(this),
|
|
541
566
|
[ReqRespSubProtocol.BLOCK_TXS]: this.validateRequestedBlockTxs.bind(this),
|
|
542
|
-
[ReqRespSubProtocol.BLOCK]: this.validateRequestedBlock.bind(this),
|
|
543
567
|
};
|
|
544
568
|
|
|
545
569
|
await this.peerManager.initializePeers();
|
|
@@ -549,7 +573,7 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
549
573
|
await this.node.start();
|
|
550
574
|
|
|
551
575
|
// Subscribe to standard GossipSub topics by default
|
|
552
|
-
for (const topic of
|
|
576
|
+
for (const topic of getTopicsForConfig(this.config.disableTransactions)) {
|
|
553
577
|
this.subscribeToTopic(this.topicStrings[topic]);
|
|
554
578
|
}
|
|
555
579
|
|
|
@@ -667,8 +691,16 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
667
691
|
this.blockReceivedCallback = callback;
|
|
668
692
|
}
|
|
669
693
|
|
|
670
|
-
public
|
|
671
|
-
this.
|
|
694
|
+
public registerValidatorCheckpointReceivedCallback(callback: P2PCheckpointReceivedCallback) {
|
|
695
|
+
this.validatorCheckpointReceivedCallback = callback;
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
public registerAllNodesCheckpointReceivedCallback(callback: P2PCheckpointReceivedCallback) {
|
|
699
|
+
this.allNodesCheckpointReceivedCallback = callback;
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
public async notifyOwnCheckpointProposal(checkpoint: CheckpointProposalCore): Promise<void> {
|
|
703
|
+
await this.allNodesCheckpointReceivedCallback(checkpoint, this.node.peerId);
|
|
672
704
|
}
|
|
673
705
|
|
|
674
706
|
/**
|
|
@@ -754,6 +786,9 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
754
786
|
if (!validator || !validator.addMessage(msgId)) {
|
|
755
787
|
this.instrumentation.incMessagePrevalidationStatus(false, topicType);
|
|
756
788
|
this.node.services.pubsub.reportMessageValidationResult(msgId, source.toString(), TopicValidatorResult.Ignore);
|
|
789
|
+
if (topicType === TopicType.tx) {
|
|
790
|
+
this.logger.verbose(`Ignoring already-seen tx gossip message`, { msgId, source: source.toString() });
|
|
791
|
+
}
|
|
757
792
|
return { result: false, topicType };
|
|
758
793
|
}
|
|
759
794
|
|
|
@@ -815,12 +850,19 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
815
850
|
|
|
816
851
|
// Process the message, optionally within a linked span for trace propagation
|
|
817
852
|
const processMessage = async () => {
|
|
853
|
+
if (
|
|
854
|
+
this.config.skipIncomingProposals &&
|
|
855
|
+
(msg.topic === this.topicStrings[TopicType.block_proposal] ||
|
|
856
|
+
msg.topic === this.topicStrings[TopicType.checkpoint_proposal])
|
|
857
|
+
) {
|
|
858
|
+
this.logger.warn(`Ignoring incoming proposal (skipIncomingProposals is set)`, { topic: msg.topic });
|
|
859
|
+
this.node.services.pubsub.reportMessageValidationResult(msgId, source.toString(), TopicValidatorResult.Ignore);
|
|
860
|
+
return;
|
|
861
|
+
}
|
|
818
862
|
if (msg.topic === this.topicStrings[TopicType.tx]) {
|
|
819
863
|
await this.handleGossipedTx(p2pMessage.payload, msgId, source);
|
|
820
864
|
} else if (msg.topic === this.topicStrings[TopicType.checkpoint_attestation]) {
|
|
821
|
-
|
|
822
|
-
await this.processCheckpointAttestationFromPeer(p2pMessage.payload, msgId, source);
|
|
823
|
-
}
|
|
865
|
+
await this.processCheckpointAttestationFromPeer(p2pMessage.payload, msgId, source);
|
|
824
866
|
} else if (msg.topic === this.topicStrings[TopicType.block_proposal]) {
|
|
825
867
|
await this.processBlockFromPeer(p2pMessage.payload, msgId, source);
|
|
826
868
|
} else if (msg.topic === this.topicStrings[TopicType.checkpoint_proposal]) {
|
|
@@ -882,30 +924,67 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
882
924
|
source: PeerId,
|
|
883
925
|
topicType: TopicType,
|
|
884
926
|
): Promise<ReceivedMessageValidationResult<T, M>> {
|
|
885
|
-
|
|
927
|
+
// Default to reject result with a penalty if validation function throws an error
|
|
928
|
+
let resultAndObj: ReceivedMessageValidationResult<T, M> = {
|
|
929
|
+
result: TopicValidatorResult.Reject,
|
|
930
|
+
severity: PeerErrorSeverity.MidToleranceError,
|
|
931
|
+
};
|
|
886
932
|
const timer = new Timer();
|
|
887
933
|
try {
|
|
888
934
|
resultAndObj = await validationFunc();
|
|
889
935
|
} catch (err) {
|
|
890
|
-
this.
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
936
|
+
this.logger.error(`Error validating gossipsub message`, err, { msgId, source: source.toString(), topicType });
|
|
937
|
+
}
|
|
938
|
+
|
|
939
|
+
const validationTimeMs = timer.ms();
|
|
940
|
+
const mcacheWindowMs = this.config.gossipsubMcacheLength * this.config.gossipsubInterval;
|
|
941
|
+
if (validationTimeMs > mcacheWindowMs * 0.75) {
|
|
942
|
+
this.instrumentation.incSlowValidation(topicType);
|
|
943
|
+
this.logger.warn(
|
|
944
|
+
`Gossip validation for ${topicType} took ${validationTimeMs}ms, approaching mcache eviction window of ${mcacheWindowMs}ms. ` +
|
|
945
|
+
`Message forwarding may be skipped if validation exceeds the window.`,
|
|
946
|
+
{ msgId, source: source.toString(), topicType, validationTimeMs, mcacheWindowMs },
|
|
947
|
+
);
|
|
896
948
|
}
|
|
897
949
|
|
|
898
950
|
if (resultAndObj.result === TopicValidatorResult.Accept) {
|
|
951
|
+
this.logger.debug(`Message ${topicType} accepted by validator`, { msgId, source: source.toString(), topicType });
|
|
899
952
|
this.instrumentation.recordMessageValidation(topicType, timer);
|
|
953
|
+
} else if (resultAndObj.result === TopicValidatorResult.Reject) {
|
|
954
|
+
this.logger.warn(`Message ${topicType} rejected by validator with severity ${resultAndObj.severity}`, {
|
|
955
|
+
msgId,
|
|
956
|
+
source: source.toString(),
|
|
957
|
+
topicType,
|
|
958
|
+
severity: resultAndObj.severity,
|
|
959
|
+
});
|
|
960
|
+
this.peerManager.penalizePeer(source, resultAndObj.severity);
|
|
961
|
+
} else {
|
|
962
|
+
this.logger.trace(`Message ${topicType} ignored by validator`, { msgId, source: source.toString(), topicType });
|
|
900
963
|
}
|
|
901
964
|
|
|
902
965
|
this.node.services.pubsub.reportMessageValidationResult(msgId, source.toString(), resultAndObj.result);
|
|
903
966
|
return resultAndObj;
|
|
904
967
|
}
|
|
905
968
|
|
|
969
|
+
private tryDeserialize<T>(deserializeFunc: () => T, msgId: string, source: PeerId): T | undefined {
|
|
970
|
+
try {
|
|
971
|
+
return deserializeFunc();
|
|
972
|
+
} catch (err) {
|
|
973
|
+
this.logger.warn(`Failed to deserialize gossipsub message from buffer`, {
|
|
974
|
+
err,
|
|
975
|
+
msgId,
|
|
976
|
+
source: source.toString(),
|
|
977
|
+
});
|
|
978
|
+
return undefined;
|
|
979
|
+
}
|
|
980
|
+
}
|
|
981
|
+
|
|
906
982
|
protected async handleGossipedTx(payloadData: Buffer, msgId: string, source: PeerId) {
|
|
907
983
|
const validationFunc: () => Promise<ReceivedMessageValidationResult<Tx>> = async () => {
|
|
908
|
-
const tx = Tx.fromBuffer(payloadData);
|
|
984
|
+
const tx = this.tryDeserialize(() => Tx.fromBuffer(payloadData), msgId, source);
|
|
985
|
+
if (!tx) {
|
|
986
|
+
return { result: TopicValidatorResult.Reject, severity: PeerErrorSeverity.LowToleranceError };
|
|
987
|
+
}
|
|
909
988
|
|
|
910
989
|
const currentBlockNumber = await this.archiver.getBlockNumber();
|
|
911
990
|
const { ts: nextSlotTimestamp } = this.epochCache.getEpochAndSlotInNextL1Slot();
|
|
@@ -925,13 +1004,20 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
925
1004
|
severity = await this.handleDoubleSpendFailure(tx, txBlockNumber);
|
|
926
1005
|
}
|
|
927
1006
|
|
|
928
|
-
this.
|
|
929
|
-
|
|
1007
|
+
this.logger.verbose(`Rejecting gossiped tx ${tx.getTxHash().toString()}: stage 1 validation failed`, {
|
|
1008
|
+
validator: name,
|
|
1009
|
+
severity,
|
|
1010
|
+
source: source.toString(),
|
|
1011
|
+
});
|
|
1012
|
+
return { result: TopicValidatorResult.Reject, severity };
|
|
930
1013
|
}
|
|
931
1014
|
|
|
932
1015
|
// Pool pre-check: see if the pool would accept this tx before doing expensive proof verification
|
|
933
1016
|
const canAdd = await this.mempools.txPool.canAddPendingTx(tx);
|
|
934
1017
|
if (canAdd === 'ignored') {
|
|
1018
|
+
this.logger.verbose(`Ignoring gossiped tx ${tx.getTxHash().toString()}: pool pre-check returned ignored`, {
|
|
1019
|
+
source: source.toString(),
|
|
1020
|
+
});
|
|
935
1021
|
return { result: TopicValidatorResult.Ignore, obj: tx };
|
|
936
1022
|
}
|
|
937
1023
|
|
|
@@ -939,9 +1025,13 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
939
1025
|
const secondStageValidators = this.createSecondStageMessageValidators();
|
|
940
1026
|
const secondStageOutcome = await this.runValidations(tx, secondStageValidators);
|
|
941
1027
|
if (!secondStageOutcome.allPassed) {
|
|
942
|
-
const { severity } = secondStageOutcome.failure;
|
|
943
|
-
this.
|
|
944
|
-
|
|
1028
|
+
const { severity, name } = secondStageOutcome.failure;
|
|
1029
|
+
this.logger.verbose(`Rejecting gossiped tx ${tx.getTxHash().toString()}: stage 2 validation failed`, {
|
|
1030
|
+
validator: name,
|
|
1031
|
+
severity,
|
|
1032
|
+
source: source.toString(),
|
|
1033
|
+
});
|
|
1034
|
+
return { result: TopicValidatorResult.Reject, severity };
|
|
945
1035
|
}
|
|
946
1036
|
|
|
947
1037
|
// Pool add: persist the tx
|
|
@@ -951,7 +1041,7 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
951
1041
|
const wasAccepted = addResult.accepted.some(h => h.equals(txHash));
|
|
952
1042
|
const wasIgnored = addResult.ignored.some(h => h.equals(txHash));
|
|
953
1043
|
|
|
954
|
-
this.logger.
|
|
1044
|
+
this.logger.verbose(`Validate propagated tx ${txHash.toString()}`, {
|
|
955
1045
|
wasAccepted,
|
|
956
1046
|
wasIgnored,
|
|
957
1047
|
[Attributes.P2P_ID]: source.toString(),
|
|
@@ -962,7 +1052,11 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
962
1052
|
} else if (wasIgnored) {
|
|
963
1053
|
return { result: TopicValidatorResult.Ignore, obj: tx };
|
|
964
1054
|
} else {
|
|
965
|
-
|
|
1055
|
+
this.logger.warn(`Gossiped tx ${txHash.toString()} unexpectedly rejected by pool`, {
|
|
1056
|
+
source: source.toString(),
|
|
1057
|
+
txHash: txHash.toString(),
|
|
1058
|
+
});
|
|
1059
|
+
return { result: TopicValidatorResult.Reject, severity: PeerErrorSeverity.HighToleranceError };
|
|
966
1060
|
}
|
|
967
1061
|
};
|
|
968
1062
|
|
|
@@ -992,7 +1086,16 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
992
1086
|
source: PeerId,
|
|
993
1087
|
): Promise<void> {
|
|
994
1088
|
const { result, obj: attestation } = await this.validateReceivedMessage<CheckpointAttestation>(
|
|
995
|
-
() =>
|
|
1089
|
+
() => {
|
|
1090
|
+
const attestation = this.tryDeserialize(() => CheckpointAttestation.fromBuffer(payloadData), msgId, source);
|
|
1091
|
+
if (!attestation) {
|
|
1092
|
+
return Promise.resolve({
|
|
1093
|
+
result: TopicValidatorResult.Reject,
|
|
1094
|
+
severity: PeerErrorSeverity.LowToleranceError,
|
|
1095
|
+
});
|
|
1096
|
+
}
|
|
1097
|
+
return this.validateAndStoreCheckpointAttestation(source, attestation);
|
|
1098
|
+
},
|
|
996
1099
|
msgId,
|
|
997
1100
|
source,
|
|
998
1101
|
TopicType.checkpoint_attestation,
|
|
@@ -1025,8 +1128,7 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
1025
1128
|
|
|
1026
1129
|
if (validationResult.result === 'reject') {
|
|
1027
1130
|
this.logger.warn(`Penalizing peer ${peerId} for checkpoint attestation validation failure`);
|
|
1028
|
-
|
|
1029
|
-
return { result: TopicValidatorResult.Reject };
|
|
1131
|
+
return { result: TopicValidatorResult.Reject, severity: validationResult.severity };
|
|
1030
1132
|
}
|
|
1031
1133
|
|
|
1032
1134
|
if (validationResult.result === 'ignore') {
|
|
@@ -1052,16 +1154,16 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
1052
1154
|
return { result: TopicValidatorResult.Ignore, obj: attestation };
|
|
1053
1155
|
}
|
|
1054
1156
|
|
|
1055
|
-
// Could not add (cap reached for signer),
|
|
1157
|
+
// Could not add (cap reached for signer), penalize and do not re-broadcast
|
|
1056
1158
|
if (!added) {
|
|
1057
|
-
this.logger.warn(`
|
|
1159
|
+
this.logger.warn(`Rejecting checkpoint attestation due to cap`, {
|
|
1058
1160
|
slot: slot.toString(),
|
|
1059
1161
|
archive: attestation.archive.toString(),
|
|
1060
1162
|
source: peerId.toString(),
|
|
1061
1163
|
attester: attestation.getSender()?.toString(),
|
|
1062
1164
|
count,
|
|
1063
1165
|
});
|
|
1064
|
-
return { result: TopicValidatorResult.
|
|
1166
|
+
return { result: TopicValidatorResult.Reject, severity: PeerErrorSeverity.HighToleranceError };
|
|
1065
1167
|
}
|
|
1066
1168
|
|
|
1067
1169
|
// Check if this is a duplicate attestation (signer attested to a different proposal at the same slot)
|
|
@@ -1116,8 +1218,7 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
1116
1218
|
|
|
1117
1219
|
if (validationResult.result === 'reject') {
|
|
1118
1220
|
this.logger.warn(`Penalizing peer ${peerId} for block proposal validation failure`);
|
|
1119
|
-
|
|
1120
|
-
return { result: TopicValidatorResult.Reject };
|
|
1221
|
+
return { result: TopicValidatorResult.Reject, severity: validationResult.severity };
|
|
1121
1222
|
}
|
|
1122
1223
|
|
|
1123
1224
|
if (validationResult.result === 'ignore') {
|
|
@@ -1141,7 +1242,6 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
1141
1242
|
|
|
1142
1243
|
// Too many blocks received for this slot and index, penalize peer and do not re-broadcast
|
|
1143
1244
|
if (!added) {
|
|
1144
|
-
this.peerManager.penalizePeer(peerId, PeerErrorSeverity.HighToleranceError);
|
|
1145
1245
|
this.logger.warn(`Penalizing peer for block proposal exceeding per-position cap`, {
|
|
1146
1246
|
...block.toBlockInfo(),
|
|
1147
1247
|
indexWithinCheckpoint: block.indexWithinCheckpoint,
|
|
@@ -1149,7 +1249,11 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
1149
1249
|
proposer: block.getSender()?.toString(),
|
|
1150
1250
|
source: peerId.toString(),
|
|
1151
1251
|
});
|
|
1152
|
-
return {
|
|
1252
|
+
return {
|
|
1253
|
+
result: TopicValidatorResult.Reject,
|
|
1254
|
+
metadata: { isEquivocated },
|
|
1255
|
+
severity: PeerErrorSeverity.HighToleranceError,
|
|
1256
|
+
};
|
|
1153
1257
|
}
|
|
1154
1258
|
|
|
1155
1259
|
// If this was a duplicate proposal, do not process it, but do invoke the duplicate callback,
|
|
@@ -1194,7 +1298,7 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
1194
1298
|
// Note: Validators do NOT attest to individual blocks, only to checkpoint proposals.
|
|
1195
1299
|
const isValid = await this.blockReceivedCallback(block, sender);
|
|
1196
1300
|
if (!isValid) {
|
|
1197
|
-
this.logger.
|
|
1301
|
+
this.logger.info(`Block proposal validation failed for block ${block.blockNumber}`, block.toBlockInfo());
|
|
1198
1302
|
}
|
|
1199
1303
|
}
|
|
1200
1304
|
|
|
@@ -1242,8 +1346,7 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
1242
1346
|
|
|
1243
1347
|
if (validationResult.result === 'reject') {
|
|
1244
1348
|
this.logger.warn(`Penalizing peer ${peerId} for checkpoint proposal validation failure`);
|
|
1245
|
-
|
|
1246
|
-
return { result: TopicValidatorResult.Reject };
|
|
1349
|
+
return { result: TopicValidatorResult.Reject, severity: validationResult.severity };
|
|
1247
1350
|
}
|
|
1248
1351
|
|
|
1249
1352
|
if (validationResult.result === 'ignore') {
|
|
@@ -1258,20 +1361,21 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
1258
1361
|
[Attributes.SLOT_NUMBER]: checkpoint.slotNumber.toString(),
|
|
1259
1362
|
[Attributes.P2P_ID]: peerId.toString(),
|
|
1260
1363
|
});
|
|
1261
|
-
const
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
metadata: { isEquivocated } = {},
|
|
1265
|
-
} = await this.validateAndStoreBlockProposal(peerId, blockProposal);
|
|
1266
|
-
if (result === TopicValidatorResult.Reject || !obj || isEquivocated) {
|
|
1364
|
+
const blockProposalResult = await this.validateAndStoreBlockProposal(peerId, blockProposal);
|
|
1365
|
+
const { obj, metadata: { isEquivocated } = {} } = blockProposalResult;
|
|
1366
|
+
if (blockProposalResult.result === TopicValidatorResult.Reject || !obj || isEquivocated) {
|
|
1267
1367
|
this.logger.debug(`Rejecting checkpoint due to invalid last block proposal`, {
|
|
1268
1368
|
[Attributes.SLOT_NUMBER]: checkpoint.slotNumber.toString(),
|
|
1269
1369
|
[Attributes.P2P_ID]: peerId.toString(),
|
|
1270
1370
|
isEquivocated,
|
|
1271
|
-
result,
|
|
1371
|
+
result: blockProposalResult.result,
|
|
1272
1372
|
});
|
|
1273
|
-
return {
|
|
1274
|
-
|
|
1373
|
+
return {
|
|
1374
|
+
result: TopicValidatorResult.Reject,
|
|
1375
|
+
severity:
|
|
1376
|
+
'severity' in blockProposalResult ? blockProposalResult.severity : PeerErrorSeverity.MidToleranceError,
|
|
1377
|
+
};
|
|
1378
|
+
} else if (blockProposalResult.result === TopicValidatorResult.Accept && obj && !isEquivocated) {
|
|
1275
1379
|
processBlock = true;
|
|
1276
1380
|
}
|
|
1277
1381
|
}
|
|
@@ -1298,13 +1402,17 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
1298
1402
|
// Too many checkpoint proposals received for this slot, penalize peer and do not re-broadcast
|
|
1299
1403
|
// Note: We still return the checkpoint obj so the lastBlock can be processed if valid
|
|
1300
1404
|
if (!added) {
|
|
1301
|
-
this.peerManager.penalizePeer(peerId, PeerErrorSeverity.HighToleranceError);
|
|
1302
1405
|
this.logger.warn(`Penalizing peer for checkpoint proposal exceeding per-slot cap`, {
|
|
1303
1406
|
...checkpoint.toCheckpointInfo(),
|
|
1304
1407
|
count,
|
|
1305
1408
|
source: peerId.toString(),
|
|
1306
1409
|
});
|
|
1307
|
-
return {
|
|
1410
|
+
return {
|
|
1411
|
+
result: TopicValidatorResult.Reject,
|
|
1412
|
+
obj: checkpoint,
|
|
1413
|
+
metadata: { isEquivocated, processBlock },
|
|
1414
|
+
severity: PeerErrorSeverity.HighToleranceError,
|
|
1415
|
+
};
|
|
1308
1416
|
}
|
|
1309
1417
|
|
|
1310
1418
|
// If this was a duplicate proposal, do not process it, but do invoke the duplicate callback,
|
|
@@ -1349,9 +1457,11 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
1349
1457
|
source: sender.toString(),
|
|
1350
1458
|
});
|
|
1351
1459
|
|
|
1460
|
+
await this.allNodesCheckpointReceivedCallback(checkpoint, sender);
|
|
1461
|
+
|
|
1352
1462
|
// Call the checkpoint received callback with the core version (without lastBlock)
|
|
1353
1463
|
// to validate and potentially generate attestations
|
|
1354
|
-
const attestations = await this.
|
|
1464
|
+
const attestations = await this.validatorCheckpointReceivedCallback(checkpoint, sender);
|
|
1355
1465
|
if (attestations && attestations.length > 0) {
|
|
1356
1466
|
// If the callback returned attestations, add them to the pool and propagate them
|
|
1357
1467
|
await this.mempools.attestationPool.addOwnCheckpointAttestations(attestations);
|
|
@@ -1499,53 +1609,6 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
1499
1609
|
}
|
|
1500
1610
|
}
|
|
1501
1611
|
|
|
1502
|
-
/**
|
|
1503
|
-
* Validates a BLOCK response.
|
|
1504
|
-
*
|
|
1505
|
-
* If a local copy exists, enforces hash equality. If missing, rejects (no penalty) since the hash cannot be verified.
|
|
1506
|
-
* Penalizes on block number mismatch or hash mismatch.
|
|
1507
|
-
*
|
|
1508
|
-
* @param requestedBlockNumber - The requested block number.
|
|
1509
|
-
* @param responseBlock - The block returned by the peer.
|
|
1510
|
-
* @param peerId - The peer that returned the block.
|
|
1511
|
-
* @returns True if the response is valid, false otherwise.
|
|
1512
|
-
*/
|
|
1513
|
-
@trackSpan('Libp2pService.validateRequestedBlock', (requestedBlockNumber, _responseBlock) => ({
|
|
1514
|
-
[Attributes.BLOCK_NUMBER]: requestedBlockNumber.toString(),
|
|
1515
|
-
}))
|
|
1516
|
-
protected async validateRequestedBlock(
|
|
1517
|
-
requestedBlockNumber: Fr,
|
|
1518
|
-
responseBlock: L2Block,
|
|
1519
|
-
peerId: PeerId,
|
|
1520
|
-
): Promise<boolean> {
|
|
1521
|
-
try {
|
|
1522
|
-
const reqNum = Number(requestedBlockNumber.toString());
|
|
1523
|
-
if (responseBlock.number !== reqNum) {
|
|
1524
|
-
this.peerManager.penalizePeer(peerId, PeerErrorSeverity.LowToleranceError);
|
|
1525
|
-
return false;
|
|
1526
|
-
}
|
|
1527
|
-
|
|
1528
|
-
const local = await this.archiver.getBlock(BlockNumber(reqNum));
|
|
1529
|
-
if (!local) {
|
|
1530
|
-
// We are missing the local block; we cannot verify the hash yet. Reject without penalizing.
|
|
1531
|
-
// TODO: Consider extending this validator to accept an expected hash or
|
|
1532
|
-
// performing quorum-based checks when using P2P syncing prior to L1 sync.
|
|
1533
|
-
this.logger.warn(`Local block ${reqNum} not found; rejecting BLOCK response without hash verification`);
|
|
1534
|
-
return false;
|
|
1535
|
-
}
|
|
1536
|
-
const [localHash, respHash] = await Promise.all([local.hash(), responseBlock.hash()]);
|
|
1537
|
-
if (!localHash.equals(respHash)) {
|
|
1538
|
-
this.peerManager.penalizePeer(peerId, PeerErrorSeverity.MidToleranceError);
|
|
1539
|
-
return false;
|
|
1540
|
-
}
|
|
1541
|
-
|
|
1542
|
-
return true;
|
|
1543
|
-
} catch (e) {
|
|
1544
|
-
this.logger.warn(`Error validating requested block`, e);
|
|
1545
|
-
return false;
|
|
1546
|
-
}
|
|
1547
|
-
}
|
|
1548
|
-
|
|
1549
1612
|
protected async validateRequestedTx(
|
|
1550
1613
|
tx: Tx,
|
|
1551
1614
|
peerId: PeerId,
|
|
@@ -1572,15 +1635,8 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
1572
1635
|
});
|
|
1573
1636
|
}
|
|
1574
1637
|
|
|
1575
|
-
private
|
|
1576
|
-
|
|
1577
|
-
return this.feesCache.gasFees;
|
|
1578
|
-
}
|
|
1579
|
-
|
|
1580
|
-
const header = await this.archiver.getBlockHeader(blockNumber);
|
|
1581
|
-
const gasFees = header?.globalVariables.gasFees ?? GasFees.empty();
|
|
1582
|
-
this.feesCache = { blockNumber, gasFees };
|
|
1583
|
-
return gasFees;
|
|
1638
|
+
private getGasFees(): Promise<GasFees> {
|
|
1639
|
+
return this.blockMinFeesProvider.getCurrentMinFees();
|
|
1584
1640
|
}
|
|
1585
1641
|
|
|
1586
1642
|
/**
|
|
@@ -1622,9 +1678,13 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
1622
1678
|
currentBlockNumber: BlockNumber,
|
|
1623
1679
|
nextSlotTimestamp: UInt64,
|
|
1624
1680
|
): Promise<Record<string, TransactionValidator>> {
|
|
1625
|
-
const gasFees = await this.getGasFees(
|
|
1626
|
-
const allowedInSetup =
|
|
1681
|
+
const gasFees = await this.getGasFees();
|
|
1682
|
+
const allowedInSetup = [
|
|
1683
|
+
...(await getDefaultAllowedSetupFunctions()),
|
|
1684
|
+
...(this.config.txPublicSetupAllowListExtend ?? []),
|
|
1685
|
+
];
|
|
1627
1686
|
const blockNumber = BlockNumber(currentBlockNumber + 1);
|
|
1687
|
+
const l1Constants = await this.archiver.getL1Constants();
|
|
1628
1688
|
|
|
1629
1689
|
return createFirstStageTxValidationsForGossipedTransactions(
|
|
1630
1690
|
nextSlotTimestamp,
|
|
@@ -1638,6 +1698,11 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
1638
1698
|
!this.config.disableTransactions,
|
|
1639
1699
|
allowedInSetup,
|
|
1640
1700
|
this.logger.getBindings(),
|
|
1701
|
+
{
|
|
1702
|
+
rollupManaLimit: l1Constants.rollupManaLimit,
|
|
1703
|
+
maxBlockL2Gas: this.config.validateMaxL2BlockGas,
|
|
1704
|
+
maxBlockDAGas: this.config.validateMaxDABlockGas,
|
|
1705
|
+
},
|
|
1641
1706
|
);
|
|
1642
1707
|
}
|
|
1643
1708
|
|
|
@@ -1663,8 +1728,10 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
1663
1728
|
|
|
1664
1729
|
// A promise that resolves when all validations have been run
|
|
1665
1730
|
const allValidations = await Promise.all(validationPromises);
|
|
1666
|
-
const
|
|
1667
|
-
if (
|
|
1731
|
+
const failures = allValidations.filter(x => !x.isValid);
|
|
1732
|
+
if (failures.length > 0) {
|
|
1733
|
+
// Pick the most severe failure (lowest tolerance = harshest penalty)
|
|
1734
|
+
const failed = maxBy(failures, f => PeerErrorSeverityByHarshness.indexOf(f.severity))!;
|
|
1668
1735
|
return {
|
|
1669
1736
|
allPassed: false,
|
|
1670
1737
|
failure: {
|
|
@@ -1717,31 +1784,6 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
1717
1784
|
return PeerErrorSeverity.HighToleranceError;
|
|
1718
1785
|
}
|
|
1719
1786
|
|
|
1720
|
-
/**
|
|
1721
|
-
* Validate a checkpoint attestation.
|
|
1722
|
-
*
|
|
1723
|
-
* @param attestation - The checkpoint attestation to validate.
|
|
1724
|
-
* @returns True if the checkpoint attestation is valid, false otherwise.
|
|
1725
|
-
*/
|
|
1726
|
-
@trackSpan('Libp2pService.validateCheckpointAttestation', async (_, attestation) => ({
|
|
1727
|
-
[Attributes.SLOT_NUMBER]: attestation.payload.header.slotNumber,
|
|
1728
|
-
[Attributes.BLOCK_ARCHIVE]: attestation.archive.toString(),
|
|
1729
|
-
[Attributes.P2P_ID]: await attestation.p2pMessageLoggingIdentifier().then(i => i.toString()),
|
|
1730
|
-
}))
|
|
1731
|
-
public async validateCheckpointAttestation(
|
|
1732
|
-
peerId: PeerId,
|
|
1733
|
-
attestation: CheckpointAttestation,
|
|
1734
|
-
): Promise<P2PValidationResult> {
|
|
1735
|
-
const result = await this.checkpointAttestationValidator.validate(attestation);
|
|
1736
|
-
|
|
1737
|
-
if (result.result === 'reject') {
|
|
1738
|
-
this.logger.warn(`Penalizing peer ${peerId} for checkpoint attestation validation failure`);
|
|
1739
|
-
this.peerManager.penalizePeer(peerId, result.severity);
|
|
1740
|
-
}
|
|
1741
|
-
|
|
1742
|
-
return result;
|
|
1743
|
-
}
|
|
1744
|
-
|
|
1745
1787
|
public getPeerScore(peerId: PeerId): number {
|
|
1746
1788
|
return this.node.services.pubsub.score.score(peerId.toString());
|
|
1747
1789
|
}
|