@aztec/p2p 0.0.1-commit.b6e433891 → 0.0.1-commit.b9865e97
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dest/bootstrap/bootstrap.d.ts +1 -1
- package/dest/bootstrap/bootstrap.d.ts.map +1 -1
- package/dest/bootstrap/bootstrap.js +9 -1
- package/dest/client/factory.d.ts +4 -3
- package/dest/client/factory.d.ts.map +1 -1
- package/dest/client/factory.js +28 -23
- package/dest/client/interface.d.ts +14 -5
- package/dest/client/interface.d.ts.map +1 -1
- package/dest/client/p2p_client.d.ts +13 -9
- package/dest/client/p2p_client.d.ts.map +1 -1
- package/dest/client/p2p_client.js +78 -22
- package/dest/config.d.ts +131 -101
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +53 -8
- 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/errors/reqresp.error.d.ts +1 -20
- package/dest/errors/reqresp.error.d.ts.map +1 -1
- package/dest/errors/reqresp.error.js +0 -21
- 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 +96 -56
- package/dest/mem_pools/attestation_pool/attestation_pool.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/attestation_pool.js +262 -196
- package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.d.ts +1 -1
- package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.js +175 -59
- 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 +1 -1
- package/dest/mem_pools/instrumentation.d.ts.map +1 -1
- package/dest/mem_pools/instrumentation.js +17 -1
- package/dest/mem_pools/tx_pool_v2/archive/tx_archive.d.ts +1 -5
- package/dest/mem_pools/tx_pool_v2/archive/tx_archive.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/archive/tx_archive.js +1 -7
- 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/invalid_txs_after_reorg_rule.js +2 -2
- package/dest/mem_pools/tx_pool_v2/interfaces.d.ts +4 -1
- package/dest/mem_pools/tx_pool_v2/interfaces.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts +5 -2
- package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/tx_metadata.js +13 -6
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts +1 -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 +75 -84
- 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 +34 -10
- 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 +4 -5
- 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 +52 -0
- package/dest/msg_validators/proposal_validator/block_proposal_validator.d.ts +6 -2
- package/dest/msg_validators/proposal_validator/block_proposal_validator.d.ts.map +1 -1
- package/dest/msg_validators/proposal_validator/checkpoint_proposal_validator.d.ts +6 -2
- package/dest/msg_validators/proposal_validator/checkpoint_proposal_validator.d.ts.map +1 -1
- package/dest/msg_validators/proposal_validator/proposal_validator.d.ts +10 -2
- package/dest/msg_validators/proposal_validator/proposal_validator.d.ts.map +1 -1
- package/dest/msg_validators/proposal_validator/proposal_validator.js +44 -10
- package/dest/msg_validators/tx_validator/aggregate_tx_validator.d.ts +1 -1
- package/dest/msg_validators/tx_validator/aggregate_tx_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/aggregate_tx_validator.js +8 -15
- package/dest/msg_validators/tx_validator/allowed_public_setup.js +3 -3
- package/dest/msg_validators/tx_validator/archive_cache.js +1 -1
- package/dest/msg_validators/tx_validator/cached_tx_validator.d.ts +15 -0
- package/dest/msg_validators/tx_validator/cached_tx_validator.d.ts.map +1 -0
- package/dest/msg_validators/tx_validator/cached_tx_validator.js +19 -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 +2 -1
- package/dest/msg_validators/tx_validator/data_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/data_validator.js +36 -2
- package/dest/msg_validators/tx_validator/factory.d.ts +6 -5
- package/dest/msg_validators/tx_validator/factory.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/factory.js +21 -11
- package/dest/msg_validators/tx_validator/gas_validator.d.ts +36 -4
- package/dest/msg_validators/tx_validator/gas_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/gas_validator.js +50 -33
- package/dest/msg_validators/tx_validator/index.d.ts +3 -1
- package/dest/msg_validators/tx_validator/index.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/index.js +2 -0
- package/dest/msg_validators/tx_validator/phases_validator.js +1 -1
- package/dest/msg_validators/tx_validator/tx_proof_validator.d.ts +2 -1
- package/dest/msg_validators/tx_validator/tx_proof_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/tx_proof_validator.js +2 -0
- package/dest/msg_validators/tx_validator/tx_validation_cache.d.ts +48 -0
- package/dest/msg_validators/tx_validator/tx_validation_cache.d.ts.map +1 -0
- package/dest/msg_validators/tx_validator/tx_validation_cache.js +68 -0
- 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/discv5/discV5_service.d.ts +2 -1
- package/dest/services/discv5/discV5_service.d.ts.map +1 -1
- package/dest/services/discv5/discV5_service.js +35 -8
- package/dest/services/dummy_service.d.ts +11 -15
- package/dest/services/dummy_service.d.ts.map +1 -1
- package/dest/services/dummy_service.js +12 -16
- 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 +36 -39
- package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
- package/dest/services/libp2p/libp2p_service.js +268 -241
- 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 +36 -8
- 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 +1 -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 +38 -44
- package/dest/services/reqresp/batch-tx-requester/interface.d.ts +8 -5
- package/dest/services/reqresp/batch-tx-requester/interface.d.ts.map +1 -1
- package/dest/services/reqresp/batch-tx-requester/tx_validator.d.ts +5 -14
- package/dest/services/reqresp/batch-tx-requester/tx_validator.d.ts.map +1 -1
- package/dest/services/reqresp/batch-tx-requester/tx_validator.js +6 -20
- 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 +16 -18
- package/dest/services/reqresp/interface.d.ts.map +1 -1
- package/dest/services/reqresp/interface.js +10 -20
- 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/block_txs/bitvector.d.ts +4 -3
- package/dest/services/reqresp/protocols/block_txs/bitvector.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/block_txs/bitvector.js +3 -2
- package/dest/services/reqresp/protocols/block_txs/block_txs_handler.d.ts +1 -1
- package/dest/services/reqresp/protocols/block_txs/block_txs_handler.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/block_txs/block_txs_handler.js +31 -28
- package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.d.ts +12 -7
- package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.js +42 -24
- 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 +7 -29
- package/dest/services/reqresp/reqresp.d.ts.map +1 -1
- package/dest/services/reqresp/reqresp.js +26 -207
- package/dest/services/service.d.ts +9 -12
- package/dest/services/service.d.ts.map +1 -1
- package/dest/services/tx_collection/config.d.ts +2 -23
- package/dest/services/tx_collection/config.d.ts.map +1 -1
- package/dest/services/tx_collection/config.js +2 -55
- package/dest/services/tx_collection/file_store_tx_collection.d.ts +12 -28
- package/dest/services/tx_collection/file_store_tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/file_store_tx_collection.js +43 -83
- 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/index.d.ts +2 -3
- package/dest/services/tx_collection/index.d.ts.map +1 -1
- package/dest/services/tx_collection/index.js +0 -1
- package/dest/services/tx_collection/instrumentation.d.ts +1 -1
- package/dest/services/tx_collection/instrumentation.d.ts.map +1 -1
- package/dest/services/tx_collection/instrumentation.js +0 -2
- package/dest/services/tx_collection/tx_collection.d.ts +35 -51
- package/dest/services/tx_collection/tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/tx_collection.js +275 -119
- package/dest/services/tx_collection/tx_collection_sink.d.ts +1 -1
- package/dest/services/tx_collection/tx_collection_sink.js +2 -2
- 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/services/tx_file_store/tx_file_store.d.ts +1 -3
- package/dest/services/tx_file_store/tx_file_store.d.ts.map +1 -1
- package/dest/services/tx_file_store/tx_file_store.js +4 -14
- package/dest/services/tx_provider.d.ts +3 -1
- package/dest/services/tx_provider.d.ts.map +1 -1
- package/dest/services/tx_provider.js +3 -0
- 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/make-test-p2p-clients.js +5 -2
- package/dest/test-helpers/mock-pubsub.d.ts +23 -9
- package/dest/test-helpers/mock-pubsub.d.ts.map +1 -1
- package/dest/test-helpers/mock-pubsub.js +44 -44
- package/dest/test-helpers/reqresp-nodes.d.ts +4 -5
- package/dest/test-helpers/reqresp-nodes.d.ts.map +1 -1
- package/dest/test-helpers/reqresp-nodes.js +16 -18
- package/dest/test-helpers/test_tx_provider.d.ts +3 -1
- package/dest/test-helpers/test_tx_provider.d.ts.map +1 -1
- package/dest/test-helpers/test_tx_provider.js +3 -0
- package/dest/test-helpers/testbench-utils.d.ts +12 -14
- package/dest/test-helpers/testbench-utils.d.ts.map +1 -1
- package/dest/test-helpers/testbench-utils.js +19 -13
- package/dest/testbench/p2p_client_testbench_worker.d.ts +3 -5
- package/dest/testbench/p2p_client_testbench_worker.d.ts.map +1 -1
- package/dest/testbench/p2p_client_testbench_worker.js +84 -40
- package/dest/testbench/worker_client_manager.d.ts +10 -6
- package/dest/testbench/worker_client_manager.d.ts.map +1 -1
- package/dest/testbench/worker_client_manager.js +51 -9
- package/dest/util.d.ts +11 -6
- package/dest/util.d.ts.map +1 -1
- package/dest/util.js +35 -14
- package/dest/versioning.d.ts +3 -6
- package/dest/versioning.d.ts.map +1 -1
- package/dest/versioning.js +3 -24
- package/package.json +15 -14
- package/src/bootstrap/bootstrap.ts +9 -1
- package/src/client/factory.ts +48 -23
- package/src/client/interface.ts +15 -11
- package/src/client/p2p_client.ts +91 -43
- package/src/client/test/{tx_proposal_collector/README.md → p2p_client.batch_tx_requester.bench.README.md} +23 -53
- package/src/config.ts +107 -7
- package/src/errors/p2p-service.error.ts +11 -0
- package/src/errors/reqresp.error.ts +0 -25
- package/src/index.ts +0 -1
- package/src/mem_pools/attestation_pool/attestation_pool.ts +313 -238
- package/src/mem_pools/attestation_pool/attestation_pool_test_suite.ts +198 -62
- package/src/mem_pools/attestation_pool/mocks.ts +13 -8
- package/src/mem_pools/index.ts +0 -3
- package/src/mem_pools/instrumentation.ts +5 -1
- package/src/mem_pools/tx_pool_v2/archive/tx_archive.ts +1 -9
- 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/invalid_txs_after_reorg_rule.ts +3 -3
- package/src/mem_pools/tx_pool_v2/interfaces.ts +3 -0
- package/src/mem_pools/tx_pool_v2/tx_metadata.ts +20 -8
- package/src/mem_pools/tx_pool_v2/tx_pool_v2_impl.ts +75 -90
- package/src/msg_validators/attestation_validator/attestation_validator.ts +38 -7
- package/src/msg_validators/attestation_validator/fisherman_attestation_validator.ts +14 -7
- package/src/msg_validators/clock_tolerance.ts +69 -0
- package/src/msg_validators/proposal_validator/README.md +1 -1
- package/src/msg_validators/proposal_validator/block_proposal_validator.ts +12 -2
- package/src/msg_validators/proposal_validator/checkpoint_proposal_validator.ts +17 -2
- package/src/msg_validators/proposal_validator/proposal_validator.ts +51 -8
- package/src/msg_validators/tx_validator/README.md +11 -3
- package/src/msg_validators/tx_validator/aggregate_tx_validator.ts +3 -12
- package/src/msg_validators/tx_validator/allowed_public_setup.ts +3 -3
- package/src/msg_validators/tx_validator/archive_cache.ts +1 -1
- package/src/msg_validators/tx_validator/cached_tx_validator.ts +31 -0
- package/src/msg_validators/tx_validator/contract_instance_validator.ts +56 -0
- package/src/msg_validators/tx_validator/data_validator.ts +44 -1
- package/src/msg_validators/tx_validator/factory.ts +25 -7
- package/src/msg_validators/tx_validator/gas_validator.ts +82 -33
- package/src/msg_validators/tx_validator/index.ts +2 -0
- package/src/msg_validators/tx_validator/phases_validator.ts +1 -1
- package/src/msg_validators/tx_validator/tx_proof_validator.ts +2 -0
- package/src/msg_validators/tx_validator/tx_validation_cache.ts +101 -0
- package/src/services/data_store.ts +5 -13
- package/src/services/discv5/discV5_service.ts +38 -5
- package/src/services/dummy_service.ts +14 -39
- 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 +297 -274
- package/src/services/peer-manager/peer_manager.ts +41 -8
- package/src/services/peer-manager/peer_scoring.ts +27 -5
- package/src/services/reqresp/README.md +0 -14
- package/src/services/reqresp/batch-tx-requester/batch_tx_requester.ts +42 -52
- package/src/services/reqresp/batch-tx-requester/interface.ts +11 -4
- package/src/services/reqresp/batch-tx-requester/tx_validator.ts +12 -25
- package/src/services/reqresp/config.ts +2 -2
- package/src/services/reqresp/interface.ts +21 -47
- package/src/services/reqresp/metrics.ts +0 -1
- package/src/services/reqresp/protocols/block_txs/bitvector.ts +3 -2
- package/src/services/reqresp/protocols/block_txs/block_txs_handler.ts +34 -30
- package/src/services/reqresp/protocols/block_txs/block_txs_reqresp.ts +47 -20
- 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 +29 -252
- package/src/services/service.ts +12 -28
- package/src/services/tx_collection/config.ts +3 -80
- package/src/services/tx_collection/file_store_tx_collection.ts +54 -103
- package/src/services/tx_collection/file_store_tx_source.ts +43 -31
- package/src/services/tx_collection/index.ts +1 -6
- package/src/services/tx_collection/instrumentation.ts +1 -7
- package/src/services/tx_collection/tx_collection.ts +330 -173
- package/src/services/tx_collection/tx_collection_sink.ts +2 -2
- package/src/services/tx_collection/tx_source.ts +8 -7
- package/src/services/tx_file_store/tx_file_store.ts +5 -17
- package/src/services/tx_provider.ts +5 -0
- package/src/test-helpers/make-test-p2p-clients.ts +3 -0
- package/src/test-helpers/mock-pubsub.ts +46 -60
- package/src/test-helpers/reqresp-nodes.ts +12 -22
- package/src/test-helpers/test_tx_provider.ts +5 -0
- package/src/test-helpers/testbench-utils.ts +23 -26
- package/src/testbench/p2p_client_testbench_worker.ts +89 -54
- package/src/testbench/worker_client_manager.ts +59 -20
- package/src/util.ts +32 -17
- package/src/versioning.ts +3 -33
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.d.ts +0 -2
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.d.ts.map +0 -1
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.js +0 -305
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker_protocol.d.ts +0 -73
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker_protocol.d.ts.map +0 -1
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker_protocol.js +0 -8
- 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 -123
- 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 -402
- package/dest/services/reqresp/connection-sampler/batch_connection_sampler.d.ts +0 -64
- package/dest/services/reqresp/connection-sampler/batch_connection_sampler.d.ts.map +0 -1
- package/dest/services/reqresp/connection-sampler/batch_connection_sampler.js +0 -151
- 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/fast_tx_collection.d.ts +0 -51
- package/dest/services/tx_collection/fast_tx_collection.d.ts.map +0 -1
- package/dest/services/tx_collection/fast_tx_collection.js +0 -311
- package/dest/services/tx_collection/proposal_tx_collector.d.ts +0 -48
- package/dest/services/tx_collection/proposal_tx_collector.d.ts.map +0 -1
- package/dest/services/tx_collection/proposal_tx_collector.js +0 -50
- package/dest/services/tx_collection/slow_tx_collection.d.ts +0 -57
- package/dest/services/tx_collection/slow_tx_collection.d.ts.map +0 -1
- package/dest/services/tx_collection/slow_tx_collection.js +0 -211
- package/src/client/test/tx_proposal_collector/proposal_tx_collector_worker.ts +0 -344
- package/src/client/test/tx_proposal_collector/proposal_tx_collector_worker_protocol.ts +0 -43
- 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 -163
- 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 -321
- package/src/services/reqresp/connection-sampler/batch_connection_sampler.ts +0 -161
- package/src/services/reqresp/protocols/block.ts +0 -37
- package/src/services/tx_collection/fast_tx_collection.ts +0 -361
- package/src/services/tx_collection/proposal_tx_collector.ts +0 -108
- package/src/services/tx_collection/slow_tx_collection.ts +0 -266
|
@@ -226,20 +226,30 @@ export class PeerManager implements PeerManagerInterface {
|
|
|
226
226
|
}
|
|
227
227
|
|
|
228
228
|
/**
|
|
229
|
-
* Cleans up expired timeouts.
|
|
229
|
+
* Cleans up expired timeouts and stale failed-auth-handshake entries.
|
|
230
230
|
*
|
|
231
231
|
* When peers fail to dial after a number of retries, they are temporarily timed out.
|
|
232
232
|
* This function removes any peers that have been in the timed out state for too long.
|
|
233
233
|
* To give them a chance to reconnect.
|
|
234
|
+
*
|
|
235
|
+
* Also evicts entries from the failed-auth-handshake map whose expiry window has passed.
|
|
236
|
+
* Without this, peers that probe once and never reconnect would leave their entries in the
|
|
237
|
+
* map forever, causing an unbounded memory leak.
|
|
234
238
|
*/
|
|
235
239
|
private cleanupExpiredTimeouts() {
|
|
236
|
-
// Clean up expired timeouts
|
|
237
240
|
const now = this.dateProvider.now();
|
|
241
|
+
|
|
238
242
|
for (const [peerId, timedOutPeer] of this.timedOutPeers.entries()) {
|
|
239
243
|
if (now >= timedOutPeer.timeoutUntilMs) {
|
|
240
244
|
this.timedOutPeers.delete(peerId);
|
|
241
245
|
}
|
|
242
246
|
}
|
|
247
|
+
|
|
248
|
+
for (const [id, entry] of this.failedAuthHandshakes.entries()) {
|
|
249
|
+
if (now - entry.lastFailureTimestamp > FAILED_AUTH_HANDSHAKE_EXPIRY_MS) {
|
|
250
|
+
this.failedAuthHandshakes.delete(id);
|
|
251
|
+
}
|
|
252
|
+
}
|
|
243
253
|
}
|
|
244
254
|
|
|
245
255
|
/**
|
|
@@ -303,15 +313,20 @@ export class PeerManager implements PeerManagerInterface {
|
|
|
303
313
|
*/
|
|
304
314
|
private handleDisconnectedPeerEvent(e: CustomEvent<PeerId>) {
|
|
305
315
|
const peerId = e.detail;
|
|
316
|
+
const peerIdStr = peerId.toString();
|
|
306
317
|
this.metrics.peerDisconnected(peerId);
|
|
307
|
-
this.logger.verbose(`Disconnected from peer ${
|
|
308
|
-
const validatorAddress = this.authenticatedPeerIdToValidatorAddress.get(
|
|
318
|
+
this.logger.verbose(`Disconnected from peer ${peerIdStr}`);
|
|
319
|
+
const validatorAddress = this.authenticatedPeerIdToValidatorAddress.get(peerIdStr);
|
|
309
320
|
if (validatorAddress !== undefined) {
|
|
310
321
|
this.logger.info(
|
|
311
|
-
`Removing authentication for validator ${validatorAddress} at peer id ${
|
|
322
|
+
`Removing authentication for validator ${validatorAddress} at peer id ${peerIdStr} due to disconnection`,
|
|
312
323
|
);
|
|
313
324
|
this.authenticatedValidatorAddressToPeerId.delete(validatorAddress.toString());
|
|
314
|
-
this.authenticatedPeerIdToValidatorAddress.delete(
|
|
325
|
+
this.authenticatedPeerIdToValidatorAddress.delete(peerIdStr);
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
if (this.peerScoring.getScoreState(peerIdStr) === PeerScoreState.Healthy) {
|
|
329
|
+
this.peerScoring.removePeer(peerIdStr);
|
|
315
330
|
}
|
|
316
331
|
}
|
|
317
332
|
|
|
@@ -512,6 +527,7 @@ export class PeerManager implements PeerManagerInterface {
|
|
|
512
527
|
protectedConnections: protectedPeerCount,
|
|
513
528
|
maxPeerCount: this.config.maxPeerCount,
|
|
514
529
|
cachedPeers: this.cachedPeers.size,
|
|
530
|
+
discv5KadPeers: this.peerDiscoveryService.getKadValues().length,
|
|
515
531
|
...this.peerScoring.getStats(),
|
|
516
532
|
});
|
|
517
533
|
|
|
@@ -713,6 +729,12 @@ export class PeerManager implements PeerManagerInterface {
|
|
|
713
729
|
return;
|
|
714
730
|
}
|
|
715
731
|
|
|
732
|
+
// Don't dial peers that have exceeded the auth failure threshold
|
|
733
|
+
if (!this.isNodeAllowedToConnect(peerId)) {
|
|
734
|
+
this.logger.trace(`Skipping peer ${peerId} due to failed auth handshake attempts`);
|
|
735
|
+
return;
|
|
736
|
+
}
|
|
737
|
+
|
|
716
738
|
const [multiaddrTcp] = await Promise.all([enr.getFullMultiaddr('tcp')]);
|
|
717
739
|
|
|
718
740
|
this.logger.trace(`Handling discovered peer ${peerId} at ${multiaddrTcp?.toString() ?? 'undefined address'}`);
|
|
@@ -939,6 +961,8 @@ export class PeerManager implements PeerManagerInterface {
|
|
|
939
961
|
`Received auth for validator ${sender.toString()} from peer ${peerIdString}, but this validator is already authenticated to peer ${peerForAddress.toString()}`,
|
|
940
962
|
{ ...logData, address: sender.toString() },
|
|
941
963
|
);
|
|
964
|
+
this.markAuthHandshakeFailed(peerId);
|
|
965
|
+
this.markPeerForDisconnect(peerId);
|
|
942
966
|
return;
|
|
943
967
|
}
|
|
944
968
|
|
|
@@ -968,14 +992,14 @@ export class PeerManager implements PeerManagerInterface {
|
|
|
968
992
|
const peerIdStr = peerId.toString();
|
|
969
993
|
|
|
970
994
|
const existingEntry = this.failedAuthHandshakes.get(peerIdStr);
|
|
995
|
+
const failureCount = (existingEntry?.count || 0) + 1;
|
|
971
996
|
this.failedAuthHandshakes.set(peerIdStr, {
|
|
972
|
-
count:
|
|
997
|
+
count: failureCount,
|
|
973
998
|
lastFailureTimestamp: now,
|
|
974
999
|
});
|
|
975
1000
|
|
|
976
1001
|
const connections = this.libP2PNode.getConnections(peerId);
|
|
977
1002
|
connections.forEach(conn => {
|
|
978
|
-
// We mark the IP address
|
|
979
1003
|
const address = conn.remoteAddr.nodeAddress().address;
|
|
980
1004
|
const existingAddressEntry = this.failedAuthHandshakes.get(address);
|
|
981
1005
|
this.failedAuthHandshakes.set(address, {
|
|
@@ -983,6 +1007,15 @@ export class PeerManager implements PeerManagerInterface {
|
|
|
983
1007
|
lastFailureTimestamp: now,
|
|
984
1008
|
});
|
|
985
1009
|
});
|
|
1010
|
+
|
|
1011
|
+
// Ban the peer from being re-dialed for a cooldown period (exponential backoff)
|
|
1012
|
+
const banTimeMs = this.config.peerFailedBanTimeMs ?? DEFAULT_FAILED_PEER_BAN_TIME_MS;
|
|
1013
|
+
const backoffMs = banTimeMs * Math.pow(2, Math.min(failureCount - 1, 5));
|
|
1014
|
+
this.timedOutPeers.set(peerIdStr, {
|
|
1015
|
+
peerId: peerIdStr,
|
|
1016
|
+
timeoutUntilMs: now + backoffMs,
|
|
1017
|
+
});
|
|
1018
|
+
this.cachedPeers.delete(peerIdStr);
|
|
986
1019
|
}
|
|
987
1020
|
|
|
988
1021
|
/*
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { median } from '@aztec/foundation/collection';
|
|
2
2
|
import { createLogger } from '@aztec/foundation/log';
|
|
3
|
+
import { DateProvider } from '@aztec/foundation/timer';
|
|
3
4
|
import { PeerErrorSeverity } from '@aztec/stdlib/p2p';
|
|
4
5
|
import {
|
|
5
6
|
Attributes,
|
|
@@ -54,6 +55,7 @@ export enum PeerScoreState {
|
|
|
54
55
|
// TODO: move into config / constants
|
|
55
56
|
const MIN_SCORE_BEFORE_BAN = -100;
|
|
56
57
|
const MIN_SCORE_BEFORE_DISCONNECT = -50;
|
|
58
|
+
const SCORE_CLEANUP_THRESHOLD = 0.1;
|
|
57
59
|
|
|
58
60
|
export class PeerScoring {
|
|
59
61
|
private logger = createLogger('p2p:peer-scoring');
|
|
@@ -65,7 +67,11 @@ export class PeerScoring {
|
|
|
65
67
|
|
|
66
68
|
private peerStateCounter: UpDownCounter;
|
|
67
69
|
|
|
68
|
-
constructor(
|
|
70
|
+
constructor(
|
|
71
|
+
config: P2PConfig,
|
|
72
|
+
telemetry: TelemetryClient = getTelemetryClient(),
|
|
73
|
+
private readonly dateProvider: DateProvider = new DateProvider(),
|
|
74
|
+
) {
|
|
69
75
|
const orderedValues = config.peerPenaltyValues?.sort((a, b) => a - b);
|
|
70
76
|
this.peerPenalties = {
|
|
71
77
|
[PeerErrorSeverity.HighToleranceError]:
|
|
@@ -92,7 +98,7 @@ export class PeerScoring {
|
|
|
92
98
|
}
|
|
93
99
|
|
|
94
100
|
updateScore(peerId: string, scoreDelta: number): number {
|
|
95
|
-
const currentTime =
|
|
101
|
+
const currentTime = this.dateProvider.now();
|
|
96
102
|
const lastUpdate = this.lastUpdateTime.get(peerId) || currentTime;
|
|
97
103
|
const timePassed = currentTime - lastUpdate;
|
|
98
104
|
const decayPeriods = Math.floor(timePassed / this.decayInterval);
|
|
@@ -111,19 +117,35 @@ export class PeerScoring {
|
|
|
111
117
|
}
|
|
112
118
|
|
|
113
119
|
decayAllScores(): void {
|
|
114
|
-
const currentTime =
|
|
120
|
+
const currentTime = this.dateProvider.now();
|
|
115
121
|
for (const [peerId, lastUpdate] of this.lastUpdateTime.entries()) {
|
|
116
122
|
const timePassed = currentTime - lastUpdate;
|
|
117
123
|
const decayPeriods = Math.floor(timePassed / this.decayInterval);
|
|
118
124
|
if (decayPeriods > 0) {
|
|
119
125
|
let score = this.scores.get(peerId) || 0;
|
|
120
126
|
score *= Math.pow(this.decayFactor, decayPeriods);
|
|
121
|
-
|
|
122
|
-
|
|
127
|
+
if (Math.abs(score) < SCORE_CLEANUP_THRESHOLD) {
|
|
128
|
+
this.scores.delete(peerId);
|
|
129
|
+
this.lastUpdateTime.delete(peerId);
|
|
130
|
+
} else {
|
|
131
|
+
this.scores.set(peerId, score);
|
|
132
|
+
this.lastUpdateTime.set(peerId, currentTime);
|
|
133
|
+
}
|
|
123
134
|
}
|
|
124
135
|
}
|
|
125
136
|
}
|
|
126
137
|
|
|
138
|
+
/** Resets all peer scores. Useful for benchmarks to prevent cross-case contamination. */
|
|
139
|
+
resetAllScores(): void {
|
|
140
|
+
this.scores.clear();
|
|
141
|
+
this.lastUpdateTime.clear();
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
removePeer(peerId: string): void {
|
|
145
|
+
this.scores.delete(peerId);
|
|
146
|
+
this.lastUpdateTime.delete(peerId);
|
|
147
|
+
}
|
|
148
|
+
|
|
127
149
|
getScore(peerId: string): number {
|
|
128
150
|
return this.scores.get(peerId) || 0;
|
|
129
151
|
}
|
|
@@ -46,7 +46,6 @@ Per-protocol size limits checked via preamble before decompression.
|
|
|
46
46
|
| Error Type | Severity |
|
|
47
47
|
|------------|----------|
|
|
48
48
|
| GOODBYE subprotocol errors | None |
|
|
49
|
-
| `CollectiveReqRespTimeoutError` / `InvalidResponseError` | None |
|
|
50
49
|
| `AbortError` / connection close / muxer closed | None |
|
|
51
50
|
| `ECONNRESET` / `EPIPE` / `ECONNREFUSED` / `ERR_UNEXPECTED_EOF` | HighToleranceError |
|
|
52
51
|
| `ERR_UNSUPPORTED_PROTOCOL` | HighToleranceError |
|
|
@@ -183,19 +182,6 @@ Protected peers (private/trusted/preferred) are always considered "authenticated
|
|
|
183
182
|
|
|
184
183
|
Conditional registration: BLOCK_TXS handler only registered when `config.disableTransactions` is false. Otherwise peers get `ERR_UNSUPPORTED_PROTOCOL`.
|
|
185
184
|
|
|
186
|
-
**Requester side via `sendBatchRequest`** (Snappy limit: `max(N, 1) * 512 + 1` KB):
|
|
187
|
-
|
|
188
|
-
| Rule | Consequence | File |
|
|
189
|
-
|------|-------------|------|
|
|
190
|
-
| Archive root must match request | MidToleranceError | `libp2p_service.ts` (`validateRequestedBlockTxs`) |
|
|
191
|
-
| BitVector length must match request | MidToleranceError | same |
|
|
192
|
-
| No duplicate tx hashes | MidToleranceError | same |
|
|
193
|
-
| Tx count within bounds | MidToleranceError | same |
|
|
194
|
-
| Local block proposal must exist for archive root | Rejected (no penalty) | same |
|
|
195
|
-
| All tx hashes must be in proposal's tx list at allowed indices | LowToleranceError | same |
|
|
196
|
-
| Txs in strictly increasing index order | LowToleranceError | same |
|
|
197
|
-
| Each tx passes well-formedness (Metadata [4 fields], Size, Data, Proof) | LowToleranceError | same |
|
|
198
|
-
|
|
199
185
|
**Requester side via `BatchTxRequester`** (separate validation path):
|
|
200
186
|
|
|
201
187
|
| Rule | Consequence | File |
|
|
@@ -4,9 +4,10 @@ import { FifoMemoryQueue, type ISemaphore, Semaphore } from '@aztec/foundation/q
|
|
|
4
4
|
import { sleep } from '@aztec/foundation/sleep';
|
|
5
5
|
import { DateProvider } from '@aztec/foundation/timer';
|
|
6
6
|
import { PeerErrorSeverity } from '@aztec/stdlib/p2p';
|
|
7
|
-
import { Tx, TxArray, TxHash } from '@aztec/stdlib/tx';
|
|
7
|
+
import { Tx, TxArray, TxHash, type TxValidator } from '@aztec/stdlib/tx';
|
|
8
8
|
|
|
9
9
|
import type { PeerId } from '@libp2p/interface';
|
|
10
|
+
import { strict as assert } from 'assert';
|
|
10
11
|
|
|
11
12
|
import type { IRequestTracker } from '../../tx_collection/request_tracker.js';
|
|
12
13
|
import { ReqRespSubProtocol } from '.././interface.js';
|
|
@@ -21,7 +22,7 @@ import {
|
|
|
21
22
|
import type { BatchTxRequesterLibP2PService, BatchTxRequesterOptions, ITxMetadataCollection } from './interface.js';
|
|
22
23
|
import { MissingTxMetadataCollection } from './missing_txs.js';
|
|
23
24
|
import { type IPeerCollection, PeerCollection } from './peer_collection.js';
|
|
24
|
-
import {
|
|
25
|
+
import { createBatchRequestTxValidator } from './tx_validator.js';
|
|
25
26
|
|
|
26
27
|
/*
|
|
27
28
|
* Tries to fetch all missing transaction until deadline is hit.
|
|
@@ -51,7 +52,7 @@ export class BatchTxRequester {
|
|
|
51
52
|
private readonly txsMetadata: ITxMetadataCollection;
|
|
52
53
|
private readonly smartRequesterSemaphore: ISemaphore;
|
|
53
54
|
private readonly txQueue: FifoMemoryQueue<Tx>;
|
|
54
|
-
private readonly txValidator:
|
|
55
|
+
private readonly txValidator: TxValidator;
|
|
55
56
|
private readonly smartParallelWorkerCount: number;
|
|
56
57
|
private readonly dumbParallelWorkerCount: number;
|
|
57
58
|
private readonly txBatchSize: number;
|
|
@@ -78,7 +79,7 @@ export class BatchTxRequester {
|
|
|
78
79
|
this.opts.dumbParallelWorkerCount ?? DEFAULT_BATCH_TX_REQUESTER_DUMB_PARALLEL_WORKER_COUNT;
|
|
79
80
|
this.txBatchSize = this.opts.txBatchSize ?? DEFAULT_BATCH_TX_REQUESTER_TX_BATCH_SIZE;
|
|
80
81
|
this.txQueue = new FifoMemoryQueue(this.logger);
|
|
81
|
-
this.txValidator = this.opts.txValidator ??
|
|
82
|
+
this.txValidator = this.opts.txValidator ?? createBatchRequestTxValidator(this.p2pService.txValidatorConfig);
|
|
82
83
|
|
|
83
84
|
if (this.opts.peerCollection) {
|
|
84
85
|
this.peers = this.opts.peerCollection;
|
|
@@ -97,7 +98,7 @@ export class BatchTxRequester {
|
|
|
97
98
|
}
|
|
98
99
|
|
|
99
100
|
/*
|
|
100
|
-
* Fetches all missing transactions and yields them
|
|
101
|
+
* Fetches all missing transactions and yields them one by one
|
|
101
102
|
* */
|
|
102
103
|
public async *run(): AsyncGenerator<Tx, Tx | undefined, unknown> {
|
|
103
104
|
try {
|
|
@@ -428,6 +429,15 @@ export class BatchTxRequester {
|
|
|
428
429
|
}
|
|
429
430
|
|
|
430
431
|
const blockResponse = BlockTxsResponse.fromBuffer(response.data);
|
|
432
|
+
|
|
433
|
+
// Validate response. Peers will be penalised by the validator if they send invalid response.
|
|
434
|
+
const isValid = await this.p2pService.validateRequestedBlockTxsConsistency(request, blockResponse, peerId);
|
|
435
|
+
if (!isValid) {
|
|
436
|
+
this.logger.debug(`Peer ${peerId.toString()} sent invalid response`);
|
|
437
|
+
this.handleFailResponseFromPeer(peerId, ReqRespStatus.INTERNAL_ERROR);
|
|
438
|
+
return;
|
|
439
|
+
}
|
|
440
|
+
|
|
431
441
|
await this.handleSuccessResponseFromPeer(peerId, blockResponse);
|
|
432
442
|
} catch (err: any) {
|
|
433
443
|
this.logger.error(`Failed to get valid response from peer ${peerId.toString()}: ${err.message}`, {
|
|
@@ -445,27 +455,24 @@ export class BatchTxRequester {
|
|
|
445
455
|
* Handles failed response form the peer
|
|
446
456
|
* There are 3 scenarios
|
|
447
457
|
* - RATE_LIMIT_EXCEEDED: We mark this and don't query this peer again for some_time
|
|
458
|
+
* - INTERNAL_ERROR: We use this to cover cases where the request-response consistency validation fails.
|
|
448
459
|
* - FAILURE and UNKNOWN: We penalise this, if peer has been penalised this way N times they are not queried again
|
|
449
460
|
* this implies we will query these peers couple of more times and give them a chance to "redeem" themselves before completely ignoring them
|
|
450
461
|
*/
|
|
451
462
|
private handleFailResponseFromPeer(peerId: PeerId, responseStatus: ReqRespStatus) {
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
}
|
|
466
|
-
|
|
467
|
-
if (responseStatus === ReqRespStatus.RATE_LIMIT_EXCEEDED) {
|
|
468
|
-
this.peers.markPeerRateLimitExceeded(peerId);
|
|
463
|
+
switch (responseStatus) {
|
|
464
|
+
case ReqRespStatus.RATE_LIMIT_EXCEEDED:
|
|
465
|
+
this.peers.markPeerRateLimitExceeded(peerId);
|
|
466
|
+
return;
|
|
467
|
+
case ReqRespStatus.INTERNAL_ERROR:
|
|
468
|
+
this.peers.markPeerDumb(peerId);
|
|
469
|
+
this.txsMetadata.clearPeerData(peerId);
|
|
470
|
+
return;
|
|
471
|
+
default: // includes FAILURE, UNKNOWN
|
|
472
|
+
this.peers.penalisePeer(peerId, PeerErrorSeverity.HighToleranceError);
|
|
473
|
+
this.peers.markPeerDumb(peerId);
|
|
474
|
+
this.txsMetadata.clearPeerData(peerId);
|
|
475
|
+
return;
|
|
469
476
|
}
|
|
470
477
|
}
|
|
471
478
|
|
|
@@ -485,7 +492,7 @@ export class BatchTxRequester {
|
|
|
485
492
|
* Handles received txs.
|
|
486
493
|
* Transactions are validated and then put on async queue
|
|
487
494
|
* to be yielded by main running loop
|
|
488
|
-
|
|
495
|
+
*/
|
|
489
496
|
private async handleReceivedTxs(peerId: PeerId, txs: TxArray) {
|
|
490
497
|
const newTxs = txs.filter(tx => !this.txsMetadata.alreadyFetched(tx.txHash));
|
|
491
498
|
|
|
@@ -493,12 +500,12 @@ export class BatchTxRequester {
|
|
|
493
500
|
return;
|
|
494
501
|
}
|
|
495
502
|
|
|
496
|
-
//TODO: this validation can be slow, maybe spawn worker just for validation
|
|
503
|
+
// TODO: this validation can be slow, maybe spawn worker just for validation
|
|
497
504
|
// We could use the async queue for communication.
|
|
498
505
|
const validationResults = await Promise.allSettled(
|
|
499
506
|
newTxs.map(async tx => ({
|
|
500
507
|
tx,
|
|
501
|
-
isValid: (await this.txValidator.
|
|
508
|
+
isValid: (await this.txValidator.validateTx(tx)).result === 'valid',
|
|
502
509
|
})),
|
|
503
510
|
);
|
|
504
511
|
|
|
@@ -514,6 +521,9 @@ export class BatchTxRequester {
|
|
|
514
521
|
});
|
|
515
522
|
|
|
516
523
|
if (hasInvalidTx) {
|
|
524
|
+
this.logger.warn(`Penalizing peer ${peerId.toString()} for sending invalid transactions in batch response`, {
|
|
525
|
+
peerId,
|
|
526
|
+
});
|
|
517
527
|
this.peers.penalisePeer(peerId, PeerErrorSeverity.LowToleranceError);
|
|
518
528
|
} else {
|
|
519
529
|
// If we have received successful response from the peer, they have "redeemed" themselves and not considered bad anymore
|
|
@@ -550,9 +560,10 @@ export class BatchTxRequester {
|
|
|
550
560
|
return;
|
|
551
561
|
}
|
|
552
562
|
|
|
553
|
-
|
|
554
|
-
if (
|
|
555
|
-
this.
|
|
563
|
+
// If the peer doesn't have the block, we mark them as dumb.
|
|
564
|
+
if (!response.peerHasBlock()) {
|
|
565
|
+
this.peers.markPeerDumb(peerId);
|
|
566
|
+
this.txsMetadata.clearPeerData(peerId);
|
|
556
567
|
return;
|
|
557
568
|
}
|
|
558
569
|
|
|
@@ -570,21 +581,6 @@ export class BatchTxRequester {
|
|
|
570
581
|
this.smartRequesterSemaphore.release();
|
|
571
582
|
}
|
|
572
583
|
|
|
573
|
-
/**
|
|
574
|
-
* Handles an archive root mismatch between local state and peer response.
|
|
575
|
-
*
|
|
576
|
-
* - Response archive is Fr.ZERO (peer pruned proposal, legitimate): marks peer dumb.
|
|
577
|
-
* - Non-zero archive mismatch (malicious response): penalises + marks dumb.
|
|
578
|
-
*/
|
|
579
|
-
private handleArchiveRootMismatch(peerId: PeerId, response: BlockTxsResponse): void {
|
|
580
|
-
if (!response.archiveRoot.isZero()) {
|
|
581
|
-
this.peers.penalisePeer(peerId, PeerErrorSeverity.LowToleranceError);
|
|
582
|
-
}
|
|
583
|
-
|
|
584
|
-
this.peers.markPeerDumb(peerId);
|
|
585
|
-
this.txsMetadata.clearPeerData(peerId);
|
|
586
|
-
}
|
|
587
|
-
|
|
588
584
|
private peerHasSomeTxsWeAreMissing(_peerId: PeerId, response: BlockTxsResponse): boolean {
|
|
589
585
|
if (response.txIndices.isEmpty()) {
|
|
590
586
|
return false;
|
|
@@ -600,15 +596,9 @@ export class BatchTxRequester {
|
|
|
600
596
|
}
|
|
601
597
|
|
|
602
598
|
private extractHashesPeerHasFromResponse(response: BlockTxsResponse): Array<TxHash> {
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
if (indicesOfHashesPeerHas.has(idx)) {
|
|
607
|
-
hashes.push(hash);
|
|
608
|
-
}
|
|
609
|
-
});
|
|
610
|
-
|
|
611
|
-
return hashes;
|
|
599
|
+
// Should already have been validated, but just in case.
|
|
600
|
+
assert(response.txIndices.getLength() === this.blockTxsSource.txHashes.length);
|
|
601
|
+
return response.txIndices.getTrueIndices().map(idx => this.blockTxsSource.txHashes[idx]);
|
|
612
602
|
}
|
|
613
603
|
|
|
614
604
|
/*
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import type { ISemaphore } from '@aztec/foundation/queue';
|
|
2
2
|
import type { PeerErrorSeverity } from '@aztec/stdlib/p2p';
|
|
3
|
-
import type { Tx, TxHash } from '@aztec/stdlib/tx';
|
|
3
|
+
import type { Tx, TxHash, TxValidator } from '@aztec/stdlib/tx';
|
|
4
4
|
|
|
5
5
|
import type { PeerId } from '@libp2p/interface';
|
|
6
6
|
|
|
7
7
|
import type { ConnectionSampler } from '../connection-sampler/connection_sampler.js';
|
|
8
|
+
import type { BlockTxsRequest, BlockTxsResponse } from '../index.js';
|
|
8
9
|
import type { ReqRespInterface } from '../interface.js';
|
|
9
10
|
import type { IPeerCollection } from './peer_collection.js';
|
|
10
|
-
import type { BatchRequestTxValidatorConfig
|
|
11
|
+
import type { BatchRequestTxValidatorConfig } from './tx_validator.js';
|
|
11
12
|
|
|
12
13
|
export interface IPeerPenalizer {
|
|
13
14
|
penalizePeer(peerId: PeerId, penalty: PeerErrorSeverity): void;
|
|
@@ -32,13 +33,19 @@ export interface ITxMetadataCollection {
|
|
|
32
33
|
*/
|
|
33
34
|
export interface BatchTxRequesterLibP2PService {
|
|
34
35
|
/** ReqResp interface for sending requests to peers */
|
|
35
|
-
reqResp: Pick<ReqRespInterface, '
|
|
36
|
+
reqResp: Pick<ReqRespInterface, 'sendRequestToPeer'>;
|
|
36
37
|
/** Connection sampler for getting peer lists */
|
|
37
38
|
connectionSampler: Pick<ConnectionSampler, 'getPeerListSortedByConnectionCountAsc'>;
|
|
38
39
|
/** Configuration needed for transaction validation */
|
|
39
40
|
txValidatorConfig: BatchRequestTxValidatorConfig;
|
|
40
41
|
/** Peer scoring for penalizing peers */
|
|
41
42
|
peerScoring: IPeerPenalizer;
|
|
43
|
+
/** Validate the requested block transactions request-response consistency */
|
|
44
|
+
validateRequestedBlockTxsConsistency: (
|
|
45
|
+
request: BlockTxsRequest,
|
|
46
|
+
response: BlockTxsResponse,
|
|
47
|
+
peerId: PeerId,
|
|
48
|
+
) => Promise<boolean>;
|
|
42
49
|
}
|
|
43
50
|
|
|
44
51
|
export interface BatchTxRequesterOptions {
|
|
@@ -50,5 +57,5 @@ export interface BatchTxRequesterOptions {
|
|
|
50
57
|
semaphore?: ISemaphore;
|
|
51
58
|
peerCollection?: IPeerCollection;
|
|
52
59
|
/** Optional tx validator for testing - if not provided, one is created from p2pService.txValidatorConfig */
|
|
53
|
-
txValidator?:
|
|
60
|
+
txValidator?: TxValidator;
|
|
54
61
|
}
|
|
@@ -1,37 +1,24 @@
|
|
|
1
1
|
import type { ClientProtocolCircuitVerifier } from '@aztec/stdlib/interfaces/server';
|
|
2
|
-
import
|
|
2
|
+
import type { TxValidator } from '@aztec/stdlib/tx';
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import { createTxValidatorForOnDemandReceivedTxs } from '../../../msg_validators/index.js';
|
|
5
|
+
import type { TxValidationCache } from '../../../msg_validators/tx_validator/tx_validation_cache.js';
|
|
5
6
|
|
|
6
7
|
export interface BatchRequestTxValidatorConfig {
|
|
7
8
|
l1ChainId: number;
|
|
8
9
|
rollupVersion: number;
|
|
9
10
|
proofVerifier: ClientProtocolCircuitVerifier;
|
|
11
|
+
txValidationCache?: TxValidationCache;
|
|
10
12
|
}
|
|
11
13
|
|
|
12
|
-
export
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
export class BatchRequestTxValidator implements IBatchRequestTxValidator {
|
|
18
|
-
readonly txValidator: TxValidator;
|
|
19
|
-
constructor(private readonly config: BatchRequestTxValidatorConfig) {
|
|
20
|
-
this.txValidator = BatchRequestTxValidator.createRequestedTxValidator(this.config);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
public async validateRequestedTx(tx: Tx): Promise<TxValidationResult> {
|
|
24
|
-
return await this.txValidator.validateTx(tx);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
public async validateRequestedTxs(txs: Tx[]): Promise<TxValidationResult[]> {
|
|
28
|
-
return await Promise.all(txs.map(tx => this.validateRequestedTx(tx)));
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
static createRequestedTxValidator(config: BatchRequestTxValidatorConfig): TxValidator {
|
|
32
|
-
return createTxValidatorForReqResponseReceivedTxs(config.proofVerifier, {
|
|
14
|
+
export function createBatchRequestTxValidator(config: BatchRequestTxValidatorConfig): TxValidator {
|
|
15
|
+
return createTxValidatorForOnDemandReceivedTxs(
|
|
16
|
+
config.proofVerifier,
|
|
17
|
+
{
|
|
33
18
|
l1ChainId: config.l1ChainId,
|
|
34
19
|
rollupVersion: config.rollupVersion,
|
|
35
|
-
}
|
|
36
|
-
|
|
20
|
+
},
|
|
21
|
+
/*bindings=*/ undefined,
|
|
22
|
+
config.txValidationCache,
|
|
23
|
+
);
|
|
37
24
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type ConfigMappingsType, booleanConfigHelper, numberConfigHelper } from '@aztec/foundation/config';
|
|
2
2
|
|
|
3
3
|
export const DEFAULT_INDIVIDUAL_REQUEST_TIMEOUT_MS = 10_000;
|
|
4
4
|
export const DEFAULT_OVERALL_REQUEST_TIMEOUT_MS = 10_000; // Not currently used
|
|
@@ -27,7 +27,7 @@ export interface P2PReqRespConfig {
|
|
|
27
27
|
dialTimeoutMs: number;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
export const p2pReqRespConfigMappings:
|
|
30
|
+
export const p2pReqRespConfigMappings: ConfigMappingsType<P2PReqRespConfig> = {
|
|
31
31
|
overallRequestTimeoutMs: {
|
|
32
32
|
env: 'P2P_REQRESP_OVERALL_REQUEST_TIMEOUT_MS',
|
|
33
33
|
description: 'The overall timeout for a request response operation.',
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
|
-
import { L2Block } from '@aztec/stdlib/block';
|
|
3
|
-
import { MAX_L2_BLOCK_SIZE_KB } from '@aztec/stdlib/p2p';
|
|
4
1
|
import { TxArray, TxHashArray } from '@aztec/stdlib/tx';
|
|
5
2
|
|
|
6
3
|
import type { PeerId } from '@libp2p/interface';
|
|
@@ -24,7 +21,6 @@ export const PING_PROTOCOL = '/aztec/req/ping/1.0.0';
|
|
|
24
21
|
export const STATUS_PROTOCOL = '/aztec/req/status/1.0.0';
|
|
25
22
|
export const GOODBYE_PROTOCOL = '/aztec/req/goodbye/1.0.0';
|
|
26
23
|
export const TX_REQ_PROTOCOL = '/aztec/req/tx/1.0.0';
|
|
27
|
-
export const BLOCK_REQ_PROTOCOL = '/aztec/req/block/1.0.0';
|
|
28
24
|
export const AUTH_PROTOCOL = '/aztec/req/auth/1.0.0';
|
|
29
25
|
export const BLOCK_TXS_REQ_PROTOCOL = '/aztec/req/block_txs/1.0.0';
|
|
30
26
|
|
|
@@ -33,7 +29,6 @@ export enum ReqRespSubProtocol {
|
|
|
33
29
|
STATUS = STATUS_PROTOCOL,
|
|
34
30
|
GOODBYE = GOODBYE_PROTOCOL,
|
|
35
31
|
TX = TX_REQ_PROTOCOL,
|
|
36
|
-
BLOCK = BLOCK_REQ_PROTOCOL,
|
|
37
32
|
AUTH = AUTH_PROTOCOL,
|
|
38
33
|
BLOCK_TXS = BLOCK_TXS_REQ_PROTOCOL,
|
|
39
34
|
}
|
|
@@ -83,32 +78,28 @@ export interface ProtocolRateLimitQuota {
|
|
|
83
78
|
globalLimit: RateLimitQuota;
|
|
84
79
|
}
|
|
85
80
|
|
|
86
|
-
export const noopValidator = () => Promise.resolve(true);
|
|
87
|
-
|
|
88
81
|
/**
|
|
89
82
|
* A type mapping from supprotocol to it's handling function
|
|
90
83
|
*/
|
|
91
84
|
export type ReqRespSubProtocolHandlers = Record<ReqRespSubProtocol, ReqRespSubProtocolHandler>;
|
|
92
85
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
86
|
+
/**
|
|
87
|
+
* Protocols that are always allowed without authentication, even when p2pAllowOnlyValidators is enabled.
|
|
88
|
+
* These are needed for the handshake and connection management flow.
|
|
89
|
+
* All other protocols require the remote peer to be authenticated.
|
|
90
|
+
*/
|
|
91
|
+
export const UNAUTHENTICATED_ALLOWED_PROTOCOLS: ReadonlySet<ReqRespSubProtocol> = new Set([
|
|
92
|
+
ReqRespSubProtocol.PING,
|
|
93
|
+
ReqRespSubProtocol.STATUS,
|
|
94
|
+
ReqRespSubProtocol.AUTH,
|
|
95
|
+
ReqRespSubProtocol.GOODBYE,
|
|
96
|
+
]);
|
|
102
97
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
[ReqRespSubProtocol.BLOCK]: noopValidator,
|
|
109
|
-
[ReqRespSubProtocol.AUTH]: noopValidator,
|
|
110
|
-
[ReqRespSubProtocol.BLOCK_TXS]: noopValidator,
|
|
111
|
-
};
|
|
98
|
+
/**
|
|
99
|
+
* Callback that checks whether a peer should be rejected from req/resp data protocols.
|
|
100
|
+
* Returns true if the peer should be rejected (i.e. p2pAllowOnlyValidators is on and peer is unauthenticated).
|
|
101
|
+
*/
|
|
102
|
+
export type ShouldRejectPeer = (peerId: string) => boolean;
|
|
112
103
|
|
|
113
104
|
/*
|
|
114
105
|
* Helper class to sub-protocol validation error*/
|
|
@@ -203,10 +194,6 @@ export const subProtocolMap = {
|
|
|
203
194
|
request: RequestableBuffer,
|
|
204
195
|
response: RequestableBuffer,
|
|
205
196
|
},
|
|
206
|
-
[ReqRespSubProtocol.BLOCK]: {
|
|
207
|
-
request: Fr, // block number
|
|
208
|
-
response: L2Block,
|
|
209
|
-
},
|
|
210
197
|
[ReqRespSubProtocol.AUTH]: {
|
|
211
198
|
request: AuthRequest,
|
|
212
199
|
response: AuthResponse,
|
|
@@ -229,7 +216,6 @@ export type ExpectedResponseSizeCalculator = (requestBuffer: Buffer) => number;
|
|
|
229
216
|
export const subProtocolSizeCalculators: Record<ReqRespSubProtocol, ExpectedResponseSizeCalculator> = {
|
|
230
217
|
[ReqRespSubProtocol.TX]: calculateTxResponseSize,
|
|
231
218
|
[ReqRespSubProtocol.BLOCK_TXS]: calculateBlockTxsResponseSize,
|
|
232
|
-
[ReqRespSubProtocol.BLOCK]: () => MAX_L2_BLOCK_SIZE_KB,
|
|
233
219
|
[ReqRespSubProtocol.STATUS]: () => 1,
|
|
234
220
|
[ReqRespSubProtocol.PING]: () => 1,
|
|
235
221
|
[ReqRespSubProtocol.AUTH]: () => 1,
|
|
@@ -237,24 +223,9 @@ export const subProtocolSizeCalculators: Record<ReqRespSubProtocol, ExpectedResp
|
|
|
237
223
|
};
|
|
238
224
|
|
|
239
225
|
export interface ReqRespInterface {
|
|
240
|
-
start(
|
|
241
|
-
|
|
242
|
-
subProtocolValidators: ReqRespSubProtocolValidators,
|
|
243
|
-
): Promise<void>;
|
|
244
|
-
addSubProtocol(
|
|
245
|
-
subProtocol: ReqRespSubProtocol,
|
|
246
|
-
handler: ReqRespSubProtocolHandler,
|
|
247
|
-
validator?: ReqRespSubProtocolValidators[ReqRespSubProtocol],
|
|
248
|
-
): Promise<void>;
|
|
226
|
+
start(subProtocolHandlers: Partial<ReqRespSubProtocolHandlers>): Promise<void>;
|
|
227
|
+
addSubProtocol(subProtocol: ReqRespSubProtocol, handler: ReqRespSubProtocolHandler): Promise<void>;
|
|
249
228
|
stop(): Promise<void>;
|
|
250
|
-
sendBatchRequest<SubProtocol extends ReqRespSubProtocol>(
|
|
251
|
-
subProtocol: SubProtocol,
|
|
252
|
-
requests: InstanceType<SubProtocolMap[SubProtocol]['request']>[],
|
|
253
|
-
pinnedPeer: PeerId | undefined,
|
|
254
|
-
timeoutMs?: number,
|
|
255
|
-
maxPeers?: number,
|
|
256
|
-
maxRetryAttempts?: number,
|
|
257
|
-
): Promise<InstanceType<SubProtocolMap[SubProtocol]['response']>[]>;
|
|
258
229
|
sendRequestToPeer(
|
|
259
230
|
peerId: PeerId,
|
|
260
231
|
subProtocol: ReqRespSubProtocol,
|
|
@@ -264,5 +235,8 @@ export interface ReqRespInterface {
|
|
|
264
235
|
|
|
265
236
|
updateConfig(config: Partial<P2PReqRespConfig>): void;
|
|
266
237
|
|
|
238
|
+
/** Sets the callback used to reject unauthenticated peers on gated req/resp protocols. */
|
|
239
|
+
setShouldRejectPeer(checker: ShouldRejectPeer): void;
|
|
240
|
+
|
|
267
241
|
getConnectionSampler(): Pick<ConnectionSampler, 'getPeerListSortedByConnectionCountAsc'>;
|
|
268
242
|
}
|
|
@@ -58,8 +58,9 @@ export class BitVector {
|
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
/**
|
|
61
|
-
* Returns all indices which are set to true
|
|
62
|
-
*
|
|
61
|
+
* Returns all indices which are set to true.
|
|
62
|
+
* Ordered by index. No duplicates.
|
|
63
|
+
*/
|
|
63
64
|
getTrueIndices(): number[] {
|
|
64
65
|
return Array.from({ length: this.length }, (_, i) => i).filter(i => this.isSet(i));
|
|
65
66
|
}
|