@aztec/p2p 4.0.0-nightly.20250907 → 4.0.0-nightly.20260107
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 +14 -4
- package/dest/client/factory.d.ts +3 -2
- package/dest/client/factory.d.ts.map +1 -1
- package/dest/client/factory.js +9 -5
- package/dest/client/index.d.ts +1 -1
- package/dest/client/interface.d.ts +8 -6
- package/dest/client/interface.d.ts.map +1 -1
- package/dest/client/p2p_client.d.ts +12 -35
- package/dest/client/p2p_client.d.ts.map +1 -1
- package/dest/client/p2p_client.js +457 -61
- package/dest/config.d.ts +67 -61
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +28 -15
- package/dest/enr/generate-enr.d.ts +2 -2
- package/dest/enr/generate-enr.d.ts.map +1 -1
- package/dest/enr/generate-enr.js +1 -1
- package/dest/enr/index.d.ts +1 -1
- package/dest/errors/attestation-pool.error.d.ts +7 -0
- package/dest/errors/attestation-pool.error.d.ts.map +1 -0
- package/dest/errors/attestation-pool.error.js +12 -0
- package/dest/errors/reqresp.error.d.ts +1 -1
- package/dest/errors/reqresp.error.d.ts.map +1 -1
- package/dest/index.d.ts +1 -1
- package/dest/mem_pools/attestation_pool/attestation_pool.d.ts +43 -6
- package/dest/mem_pools/attestation_pool/attestation_pool.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.d.ts +1 -1
- package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.js +72 -46
- package/dest/mem_pools/attestation_pool/index.d.ts +1 -1
- package/dest/mem_pools/attestation_pool/kv_attestation_pool.d.ts +15 -6
- package/dest/mem_pools/attestation_pool/kv_attestation_pool.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/kv_attestation_pool.js +73 -18
- package/dest/mem_pools/attestation_pool/memory_attestation_pool.d.ts +13 -6
- package/dest/mem_pools/attestation_pool/memory_attestation_pool.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/memory_attestation_pool.js +69 -11
- package/dest/mem_pools/attestation_pool/mocks.d.ts +226 -5
- package/dest/mem_pools/attestation_pool/mocks.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/mocks.js +9 -7
- package/dest/mem_pools/index.d.ts +1 -1
- package/dest/mem_pools/instrumentation.d.ts +9 -1
- package/dest/mem_pools/instrumentation.d.ts.map +1 -1
- package/dest/mem_pools/instrumentation.js +38 -2
- package/dest/mem_pools/interface.d.ts +3 -4
- package/dest/mem_pools/interface.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.d.ts +39 -58
- package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.js +314 -317
- package/dest/mem_pools/tx_pool/eviction/eviction_manager.d.ts +18 -0
- package/dest/mem_pools/tx_pool/eviction/eviction_manager.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool/eviction/eviction_manager.js +56 -0
- package/dest/mem_pools/tx_pool/eviction/eviction_strategy.d.ts +83 -0
- package/dest/mem_pools/tx_pool/eviction/eviction_strategy.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool/eviction/eviction_strategy.js +5 -0
- package/dest/mem_pools/tx_pool/eviction/insufficient_fee_payer_balance_rule.d.ts +15 -0
- package/dest/mem_pools/tx_pool/eviction/insufficient_fee_payer_balance_rule.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool/eviction/insufficient_fee_payer_balance_rule.js +88 -0
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.d.ts +17 -0
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.js +84 -0
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.d.ts +19 -0
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.js +76 -0
- package/dest/mem_pools/tx_pool/eviction/low_priority_eviction_rule.d.ts +26 -0
- package/dest/mem_pools/tx_pool/eviction/low_priority_eviction_rule.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool/eviction/low_priority_eviction_rule.js +84 -0
- package/dest/mem_pools/tx_pool/index.d.ts +1 -2
- package/dest/mem_pools/tx_pool/index.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool/index.js +0 -1
- package/dest/mem_pools/tx_pool/priority.d.ts +5 -1
- package/dest/mem_pools/tx_pool/priority.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool/priority.js +6 -1
- package/dest/mem_pools/tx_pool/tx_pool.d.ts +28 -9
- package/dest/mem_pools/tx_pool/tx_pool.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool/tx_pool_test_suite.d.ts +1 -1
- package/dest/mem_pools/tx_pool/tx_pool_test_suite.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool/tx_pool_test_suite.js +155 -25
- package/dest/msg_validators/attestation_validator/attestation_validator.d.ts +4 -2
- package/dest/msg_validators/attestation_validator/attestation_validator.d.ts.map +1 -1
- package/dest/msg_validators/attestation_validator/attestation_validator.js +32 -5
- package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.d.ts +20 -0
- package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.d.ts.map +1 -0
- package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.js +67 -0
- package/dest/msg_validators/attestation_validator/index.d.ts +2 -1
- package/dest/msg_validators/attestation_validator/index.d.ts.map +1 -1
- package/dest/msg_validators/attestation_validator/index.js +1 -0
- package/dest/msg_validators/block_proposal_validator/block_proposal_validator.d.ts +5 -2
- package/dest/msg_validators/block_proposal_validator/block_proposal_validator.d.ts.map +1 -1
- package/dest/msg_validators/block_proposal_validator/block_proposal_validator.js +44 -12
- package/dest/msg_validators/block_proposal_validator/index.d.ts +1 -1
- package/dest/msg_validators/index.d.ts +1 -1
- package/dest/msg_validators/msg_seen_validator/msg_seen_validator.d.ts +1 -1
- package/dest/msg_validators/msg_seen_validator/msg_seen_validator.d.ts.map +1 -1
- 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/allowed_public_setup.d.ts +1 -1
- package/dest/msg_validators/tx_validator/archive_cache.d.ts +2 -2
- package/dest/msg_validators/tx_validator/archive_cache.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/block_header_validator.d.ts +2 -2
- package/dest/msg_validators/tx_validator/block_header_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/block_header_validator.js +1 -1
- 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/double_spend_validator.d.ts +1 -1
- package/dest/msg_validators/tx_validator/double_spend_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/double_spend_validator.js +1 -1
- package/dest/msg_validators/tx_validator/factory.d.ts +4 -3
- package/dest/msg_validators/tx_validator/factory.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/factory.js +11 -5
- package/dest/msg_validators/tx_validator/gas_validator.d.ts +1 -1
- package/dest/msg_validators/tx_validator/gas_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/index.d.ts +2 -1
- package/dest/msg_validators/tx_validator/index.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/index.js +1 -0
- package/dest/msg_validators/tx_validator/metadata_validator.d.ts +3 -6
- package/dest/msg_validators/tx_validator/metadata_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/metadata_validator.js +6 -24
- package/dest/msg_validators/tx_validator/phases_validator.d.ts +1 -1
- package/dest/msg_validators/tx_validator/phases_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/phases_validator.js +3 -1
- package/dest/msg_validators/tx_validator/test_utils.d.ts +2 -2
- package/dest/msg_validators/tx_validator/test_utils.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/timestamp_validator.d.ts +13 -0
- package/dest/msg_validators/tx_validator/timestamp_validator.d.ts.map +1 -0
- package/dest/msg_validators/tx_validator/timestamp_validator.js +32 -0
- package/dest/msg_validators/tx_validator/tx_permitted_validator.d.ts +1 -1
- package/dest/msg_validators/tx_validator/tx_permitted_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/tx_proof_validator.d.ts +1 -1
- package/dest/msg_validators/tx_validator/tx_proof_validator.d.ts.map +1 -1
- package/dest/services/data_store.d.ts +1 -1
- package/dest/services/data_store.d.ts.map +1 -1
- package/dest/services/discv5/discV5_service.d.ts +3 -3
- package/dest/services/discv5/discV5_service.d.ts.map +1 -1
- package/dest/services/discv5/discV5_service.js +2 -2
- package/dest/services/dummy_service.d.ts +2 -2
- package/dest/services/dummy_service.d.ts.map +1 -1
- package/dest/services/encoding.d.ts +25 -4
- package/dest/services/encoding.d.ts.map +1 -1
- package/dest/services/encoding.js +74 -6
- package/dest/services/gossipsub/scoring.d.ts +1 -1
- package/dest/services/index.d.ts +1 -1
- 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 +9 -2
- package/dest/services/libp2p/libp2p_service.d.ts +32 -72
- package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
- package/dest/services/libp2p/libp2p_service.js +796 -171
- package/dest/services/peer-manager/interface.d.ts +1 -1
- package/dest/services/peer-manager/metrics.d.ts +8 -1
- package/dest/services/peer-manager/metrics.d.ts.map +1 -1
- package/dest/services/peer-manager/metrics.js +28 -0
- package/dest/services/peer-manager/peer_manager.d.ts +1 -32
- package/dest/services/peer-manager/peer_manager.d.ts.map +1 -1
- package/dest/services/peer-manager/peer_manager.js +412 -21
- 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 +40 -2
- package/dest/services/reqresp/config.d.ts +1 -1
- package/dest/services/reqresp/connection-sampler/batch_connection_sampler.d.ts +1 -1
- package/dest/services/reqresp/connection-sampler/batch_connection_sampler.d.ts.map +1 -1
- package/dest/services/reqresp/connection-sampler/connection_sampler.d.ts +1 -4
- package/dest/services/reqresp/connection-sampler/connection_sampler.d.ts.map +1 -1
- package/dest/services/reqresp/index.d.ts +1 -1
- package/dest/services/reqresp/interface.d.ts +2 -11
- package/dest/services/reqresp/interface.d.ts.map +1 -1
- package/dest/services/reqresp/interface.js +1 -18
- package/dest/services/reqresp/metrics.d.ts +1 -1
- package/dest/services/reqresp/metrics.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/auth.d.ts +2 -2
- package/dest/services/reqresp/protocols/auth.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/auth.js +2 -2
- package/dest/services/reqresp/protocols/block.d.ts +1 -1
- package/dest/services/reqresp/protocols/block.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/block.js +3 -2
- package/dest/services/reqresp/protocols/block_txs/bitvector.d.ts +1 -1
- package/dest/services/reqresp/protocols/block_txs/bitvector.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/block_txs/block_txs_handler.d.ts +1 -1
- package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.d.ts +4 -6
- package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.js +1 -1
- package/dest/services/reqresp/protocols/block_txs/index.d.ts +1 -1
- package/dest/services/reqresp/protocols/goodbye.d.ts +1 -1
- package/dest/services/reqresp/protocols/goodbye.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/index.d.ts +1 -1
- package/dest/services/reqresp/protocols/ping.d.ts +1 -1
- package/dest/services/reqresp/protocols/status.d.ts +6 -5
- package/dest/services/reqresp/protocols/status.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/status.js +4 -3
- package/dest/services/reqresp/protocols/tx.d.ts +2 -3
- package/dest/services/reqresp/protocols/tx.d.ts.map +1 -1
- package/dest/services/reqresp/rate-limiter/index.d.ts +1 -1
- package/dest/services/reqresp/rate-limiter/rate_limiter.d.ts +2 -2
- package/dest/services/reqresp/rate-limiter/rate_limiter.d.ts.map +1 -1
- package/dest/services/reqresp/rate-limiter/rate_limits.d.ts +1 -1
- package/dest/services/reqresp/reqresp.d.ts +1 -41
- package/dest/services/reqresp/reqresp.d.ts.map +1 -1
- package/dest/services/reqresp/reqresp.js +416 -34
- package/dest/services/reqresp/status.d.ts +2 -2
- package/dest/services/reqresp/status.d.ts.map +1 -1
- package/dest/services/service.d.ts +2 -2
- package/dest/services/service.d.ts.map +1 -1
- package/dest/services/tx_collection/config.d.ts +1 -1
- package/dest/services/tx_collection/config.js +1 -1
- package/dest/services/tx_collection/fast_tx_collection.d.ts +4 -9
- package/dest/services/tx_collection/fast_tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/fast_tx_collection.js +6 -1
- package/dest/services/tx_collection/index.d.ts +1 -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/slow_tx_collection.d.ts +6 -7
- package/dest/services/tx_collection/slow_tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/slow_tx_collection.js +2 -1
- package/dest/services/tx_collection/tx_collection.d.ts +12 -11
- package/dest/services/tx_collection/tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/tx_collection.js +3 -2
- package/dest/services/tx_collection/tx_collection_sink.d.ts +3 -3
- package/dest/services/tx_collection/tx_collection_sink.d.ts.map +1 -1
- package/dest/services/tx_collection/tx_collection_sink.js +34 -4
- package/dest/services/tx_collection/tx_source.d.ts +1 -1
- package/dest/services/tx_collection/tx_source.d.ts.map +1 -1
- package/dest/services/tx_collection/tx_source.js +2 -2
- package/dest/services/tx_provider.d.ts +6 -4
- package/dest/services/tx_provider.d.ts.map +1 -1
- package/dest/services/tx_provider.js +19 -6
- package/dest/services/tx_provider_instrumentation.d.ts +5 -2
- package/dest/services/tx_provider_instrumentation.d.ts.map +1 -1
- package/dest/services/tx_provider_instrumentation.js +14 -1
- package/dest/test-helpers/generate-peer-id-private-keys.d.ts +1 -1
- package/dest/test-helpers/get-ports.d.ts +1 -1
- package/dest/test-helpers/get-ports.d.ts.map +1 -1
- package/dest/test-helpers/index.d.ts +1 -1
- package/dest/test-helpers/make-enrs.d.ts +1 -1
- package/dest/test-helpers/make-enrs.js +1 -1
- package/dest/test-helpers/make-test-p2p-clients.d.ts +2 -2
- package/dest/test-helpers/make-test-p2p-clients.d.ts.map +1 -1
- package/dest/test-helpers/mock-pubsub.d.ts +4 -4
- package/dest/test-helpers/mock-pubsub.d.ts.map +1 -1
- package/dest/test-helpers/mock-tx-helpers.d.ts +12 -0
- package/dest/test-helpers/mock-tx-helpers.d.ts.map +1 -0
- package/dest/test-helpers/mock-tx-helpers.js +19 -0
- package/dest/test-helpers/reqresp-nodes.d.ts +3 -3
- package/dest/test-helpers/reqresp-nodes.d.ts.map +1 -1
- package/dest/test-helpers/reqresp-nodes.js +4 -3
- package/dest/testbench/p2p_client_testbench_worker.d.ts +1 -1
- package/dest/testbench/p2p_client_testbench_worker.js +17 -9
- package/dest/testbench/parse_log_file.d.ts +1 -1
- package/dest/testbench/testbench.d.ts +1 -1
- package/dest/testbench/testbench.js +2 -2
- package/dest/testbench/worker_client_manager.d.ts +1 -1
- package/dest/testbench/worker_client_manager.d.ts.map +1 -1
- package/dest/types/index.d.ts +1 -1
- package/dest/util.d.ts +2 -1
- package/dest/util.d.ts.map +1 -1
- package/dest/util.js +11 -2
- package/dest/versioning.d.ts +2 -2
- package/dest/versioning.d.ts.map +1 -1
- package/dest/versioning.js +2 -2
- package/package.json +21 -21
- package/src/bootstrap/bootstrap.ts +15 -4
- package/src/client/factory.ts +21 -12
- package/src/client/interface.ts +8 -5
- package/src/client/p2p_client.ts +97 -88
- package/src/config.ts +42 -21
- package/src/enr/generate-enr.ts +1 -1
- package/src/errors/attestation-pool.error.ts +13 -0
- package/src/mem_pools/attestation_pool/attestation_pool.ts +46 -5
- package/src/mem_pools/attestation_pool/attestation_pool_test_suite.ts +89 -48
- package/src/mem_pools/attestation_pool/kv_attestation_pool.ts +107 -24
- package/src/mem_pools/attestation_pool/memory_attestation_pool.ts +98 -19
- package/src/mem_pools/attestation_pool/mocks.ts +11 -8
- package/src/mem_pools/instrumentation.ts +46 -0
- package/src/mem_pools/interface.ts +2 -4
- package/src/mem_pools/tx_pool/README.md +255 -0
- package/src/mem_pools/tx_pool/aztec_kv_tx_pool.ts +368 -360
- package/src/mem_pools/tx_pool/eviction/eviction_manager.ts +71 -0
- package/src/mem_pools/tx_pool/eviction/eviction_strategy.ts +93 -0
- package/src/mem_pools/tx_pool/eviction/insufficient_fee_payer_balance_rule.ts +108 -0
- package/src/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.ts +104 -0
- package/src/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.ts +91 -0
- package/src/mem_pools/tx_pool/eviction/low_priority_eviction_rule.ts +106 -0
- package/src/mem_pools/tx_pool/index.ts +0 -1
- package/src/mem_pools/tx_pool/priority.ts +8 -1
- package/src/mem_pools/tx_pool/tx_pool.ts +28 -8
- package/src/mem_pools/tx_pool/tx_pool_test_suite.ts +131 -18
- package/src/msg_validators/attestation_validator/attestation_validator.ts +41 -6
- package/src/msg_validators/attestation_validator/fisherman_attestation_validator.ts +91 -0
- package/src/msg_validators/attestation_validator/index.ts +1 -0
- package/src/msg_validators/block_proposal_validator/block_proposal_validator.ts +53 -12
- package/src/msg_validators/tx_validator/archive_cache.ts +1 -1
- package/src/msg_validators/tx_validator/block_header_validator.ts +2 -2
- package/src/msg_validators/tx_validator/double_spend_validator.ts +1 -1
- package/src/msg_validators/tx_validator/factory.ts +13 -6
- package/src/msg_validators/tx_validator/index.ts +1 -0
- package/src/msg_validators/tx_validator/metadata_validator.ts +8 -42
- package/src/msg_validators/tx_validator/phases_validator.ts +3 -1
- package/src/msg_validators/tx_validator/test_utils.ts +1 -1
- package/src/msg_validators/tx_validator/timestamp_validator.ts +47 -0
- package/src/services/discv5/discV5_service.ts +2 -2
- package/src/services/dummy_service.ts +1 -1
- package/src/services/encoding.ts +81 -6
- package/src/services/libp2p/instrumentation.ts +10 -1
- package/src/services/libp2p/libp2p_service.ts +430 -165
- package/src/services/peer-manager/metrics.ts +32 -0
- package/src/services/peer-manager/peer_manager.ts +24 -14
- package/src/services/peer-manager/peer_scoring.ts +46 -3
- package/src/services/reqresp/interface.ts +1 -22
- package/src/services/reqresp/protocols/auth.ts +2 -2
- package/src/services/reqresp/protocols/block.ts +3 -2
- package/src/services/reqresp/protocols/block_txs/block_txs_reqresp.ts +1 -1
- package/src/services/reqresp/protocols/status.ts +9 -8
- package/src/services/reqresp/protocols/tx.ts +1 -2
- package/src/services/reqresp/reqresp.ts +15 -11
- package/src/services/service.ts +1 -1
- package/src/services/tx_collection/config.ts +1 -1
- package/src/services/tx_collection/fast_tx_collection.ts +8 -5
- package/src/services/tx_collection/slow_tx_collection.ts +7 -6
- package/src/services/tx_collection/tx_collection.ts +12 -10
- package/src/services/tx_collection/tx_collection_sink.ts +34 -3
- package/src/services/tx_collection/tx_source.ts +2 -2
- package/src/services/tx_provider.ts +26 -9
- package/src/services/tx_provider_instrumentation.ts +19 -2
- package/src/test-helpers/make-enrs.ts +1 -1
- package/src/test-helpers/mock-pubsub.ts +1 -1
- package/src/test-helpers/mock-tx-helpers.ts +24 -0
- package/src/test-helpers/reqresp-nodes.ts +4 -3
- package/src/testbench/p2p_client_testbench_worker.ts +14 -6
- package/src/testbench/testbench.ts +2 -2
- package/src/util.ts +12 -2
- package/src/versioning.ts +3 -3
- package/dest/mem_pools/tx_pool/memory_tx_pool.d.ts +0 -68
- package/dest/mem_pools/tx_pool/memory_tx_pool.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/memory_tx_pool.js +0 -160
- package/src/mem_pools/tx_pool/memory_tx_pool.ts +0 -199
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Attributes,
|
|
3
3
|
type Gauge,
|
|
4
|
+
type Histogram,
|
|
4
5
|
Metrics,
|
|
5
6
|
type TelemetryClient,
|
|
6
7
|
type Tracer,
|
|
@@ -9,12 +10,18 @@ import {
|
|
|
9
10
|
getTelemetryClient,
|
|
10
11
|
} from '@aztec/telemetry-client';
|
|
11
12
|
|
|
13
|
+
import type { PeerId } from '@libp2p/interface';
|
|
14
|
+
|
|
12
15
|
import { type GoodByeReason, prettyGoodbyeReason } from '../reqresp/protocols/index.js';
|
|
13
16
|
|
|
14
17
|
export class PeerManagerMetrics {
|
|
15
18
|
private sentGoodbyes: UpDownCounter;
|
|
16
19
|
private receivedGoodbyes: UpDownCounter;
|
|
17
20
|
private peerCount: Gauge;
|
|
21
|
+
private lowScoreDisconnects: UpDownCounter;
|
|
22
|
+
private peerConnectionDuration: Histogram;
|
|
23
|
+
|
|
24
|
+
private peerConnectedAt: Map<string, number> = new Map<string, number>();
|
|
18
25
|
|
|
19
26
|
public readonly tracer: Tracer;
|
|
20
27
|
|
|
@@ -40,6 +47,16 @@ export class PeerManagerMetrics {
|
|
|
40
47
|
unit: 'peers',
|
|
41
48
|
valueType: ValueType.INT,
|
|
42
49
|
});
|
|
50
|
+
this.lowScoreDisconnects = meter.createUpDownCounter(Metrics.PEER_MANAGER_LOW_SCORE_DISCONNECTS, {
|
|
51
|
+
description: 'Number of peers disconnected due to low score',
|
|
52
|
+
unit: 'peers',
|
|
53
|
+
valueType: ValueType.INT,
|
|
54
|
+
});
|
|
55
|
+
this.peerConnectionDuration = meter.createHistogram(Metrics.PEER_MANAGER_PEER_CONNECTION_DURATION, {
|
|
56
|
+
description: 'Time duration between peer connection and disconnection',
|
|
57
|
+
unit: 'ms',
|
|
58
|
+
valueType: ValueType.INT,
|
|
59
|
+
});
|
|
43
60
|
}
|
|
44
61
|
|
|
45
62
|
public recordGoodbyeSent(reason: GoodByeReason) {
|
|
@@ -53,4 +70,19 @@ export class PeerManagerMetrics {
|
|
|
53
70
|
public recordPeerCount(count: number) {
|
|
54
71
|
this.peerCount.record(count);
|
|
55
72
|
}
|
|
73
|
+
|
|
74
|
+
public recordLowScoreDisconnect(scoreState: 'Banned' | 'Disconnect') {
|
|
75
|
+
this.lowScoreDisconnects.add(1, { [Attributes.P2P_PEER_SCORE_STATE]: scoreState });
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
public peerConnected(id: PeerId) {
|
|
79
|
+
this.peerConnectedAt.set(id.toString(), Date.now());
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
public peerDisconnected(id: PeerId) {
|
|
83
|
+
const connectedAt = this.peerConnectedAt.get(id.toString());
|
|
84
|
+
if (connectedAt) {
|
|
85
|
+
this.peerConnectionDuration.record(Date.now() - connectedAt);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
56
88
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { EpochCacheInterface } from '@aztec/epoch-cache';
|
|
2
|
-
import { makeEthSignDigest,
|
|
2
|
+
import { makeEthSignDigest, tryRecoverAddress } from '@aztec/foundation/crypto/secp256k1-signer';
|
|
3
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
4
|
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
4
|
-
import { Fr } from '@aztec/foundation/fields';
|
|
5
5
|
import { createLogger } from '@aztec/foundation/log';
|
|
6
6
|
import { bufferToHex } from '@aztec/foundation/string';
|
|
7
7
|
import { DateProvider } from '@aztec/foundation/timer';
|
|
@@ -9,10 +9,10 @@ import type { PeerInfo, WorldStateSynchronizer } from '@aztec/stdlib/interfaces/
|
|
|
9
9
|
import type { PeerErrorSeverity } from '@aztec/stdlib/p2p';
|
|
10
10
|
import { type TelemetryClient, trackSpan } from '@aztec/telemetry-client';
|
|
11
11
|
|
|
12
|
-
import { ENR } from '@chainsafe/enr';
|
|
13
12
|
import type { Connection, PeerId } from '@libp2p/interface';
|
|
14
13
|
import { peerIdFromString } from '@libp2p/peer-id';
|
|
15
14
|
import type { Multiaddr } from '@multiformats/multiaddr';
|
|
15
|
+
import { ENR } from '@nethermindeth/enr';
|
|
16
16
|
import { inspect } from 'util';
|
|
17
17
|
|
|
18
18
|
import type { P2PConfig } from '../../config.js';
|
|
@@ -278,6 +278,7 @@ export class PeerManager implements PeerManagerInterface {
|
|
|
278
278
|
private handleConnectedPeerEvent(e: CustomEvent<PeerId>) {
|
|
279
279
|
const peerId = e.detail;
|
|
280
280
|
this.logger.verbose(`Connected to peer ${peerId.toString()}`);
|
|
281
|
+
this.metrics.peerConnected(peerId);
|
|
281
282
|
if (this.config.p2pDisableStatusHandshake) {
|
|
282
283
|
return;
|
|
283
284
|
}
|
|
@@ -303,6 +304,7 @@ export class PeerManager implements PeerManagerInterface {
|
|
|
303
304
|
*/
|
|
304
305
|
private handleDisconnectedPeerEvent(e: CustomEvent<PeerId>) {
|
|
305
306
|
const peerId = e.detail;
|
|
307
|
+
this.metrics.peerDisconnected(peerId);
|
|
306
308
|
this.logger.verbose(`Disconnected from peer ${peerId.toString()}`);
|
|
307
309
|
const validatorAddress = this.authenticatedPeerIdToValidatorAddress.get(peerId.toString());
|
|
308
310
|
if (validatorAddress !== undefined) {
|
|
@@ -577,9 +579,11 @@ export class PeerManager implements PeerManagerInterface {
|
|
|
577
579
|
const score = this.peerScoring.getScoreState(peer.remotePeer.toString());
|
|
578
580
|
switch (score) {
|
|
579
581
|
case PeerScoreState.Banned:
|
|
582
|
+
this.metrics.recordLowScoreDisconnect('Banned');
|
|
580
583
|
void this.goodbyeAndDisconnectPeer(peer.remotePeer, GoodByeReason.BANNED);
|
|
581
584
|
break;
|
|
582
585
|
case PeerScoreState.Disconnect:
|
|
586
|
+
this.metrics.recordLowScoreDisconnect('Disconnect');
|
|
583
587
|
void this.goodbyeAndDisconnectPeer(peer.remotePeer, GoodByeReason.LOW_SCORE);
|
|
584
588
|
break;
|
|
585
589
|
case PeerScoreState.Healthy:
|
|
@@ -883,7 +887,7 @@ export class PeerManager implements PeerManagerInterface {
|
|
|
883
887
|
const response = await this.reqresp.sendRequestToPeer(peerId, ReqRespSubProtocol.AUTH, authRequest.toBuffer());
|
|
884
888
|
const { status } = response;
|
|
885
889
|
if (status !== ReqRespStatus.SUCCESS) {
|
|
886
|
-
this.logger.
|
|
890
|
+
this.logger.verbose(`Disconnecting peer ${peerId} who failed to respond auth handshake`, {
|
|
887
891
|
peerId,
|
|
888
892
|
status: ReqRespStatus[status],
|
|
889
893
|
});
|
|
@@ -899,7 +903,7 @@ export class PeerManager implements PeerManagerInterface {
|
|
|
899
903
|
|
|
900
904
|
const peerStatusMessage = peerAuthResponse.status;
|
|
901
905
|
if (!ourStatus.validate(peerStatusMessage)) {
|
|
902
|
-
this.logger.
|
|
906
|
+
this.logger.verbose(`Disconnecting peer ${peerId} due to failed status handshake as part of auth.`, logData);
|
|
903
907
|
this.markAuthHandshakeFailed(peerId);
|
|
904
908
|
this.markPeerForDisconnect(peerId);
|
|
905
909
|
return;
|
|
@@ -907,16 +911,20 @@ export class PeerManager implements PeerManagerInterface {
|
|
|
907
911
|
|
|
908
912
|
const hashToRecover = authRequest.getPayloadToSign();
|
|
909
913
|
const ethSignedHash = makeEthSignDigest(hashToRecover);
|
|
910
|
-
const sender =
|
|
914
|
+
const sender = tryRecoverAddress(ethSignedHash, peerAuthResponse.signature);
|
|
915
|
+
if (!sender) {
|
|
916
|
+
this.logger.verbose(`Disconnecting peer ${peerId} due to failed auth handshake, invalid signature.`, logData);
|
|
917
|
+
this.markAuthHandshakeFailed(peerId);
|
|
918
|
+
this.markPeerForDisconnect(peerId);
|
|
919
|
+
return;
|
|
920
|
+
}
|
|
921
|
+
|
|
911
922
|
const registeredValidators = await this.epochCache.getRegisteredValidators();
|
|
912
923
|
const found = registeredValidators.find(v => v.toString() === sender.toString()) !== undefined;
|
|
913
924
|
if (!found) {
|
|
914
|
-
this.logger.
|
|
925
|
+
this.logger.verbose(
|
|
915
926
|
`Disconnecting peer ${peerId} due to failed auth handshake, peer is not a registered validator.`,
|
|
916
|
-
{
|
|
917
|
-
peerId,
|
|
918
|
-
address: sender.toString(),
|
|
919
|
-
},
|
|
927
|
+
{ ...logData, address: sender.toString() },
|
|
920
928
|
);
|
|
921
929
|
this.markAuthHandshakeFailed(peerId);
|
|
922
930
|
this.markPeerForDisconnect(peerId);
|
|
@@ -926,8 +934,9 @@ export class PeerManager implements PeerManagerInterface {
|
|
|
926
934
|
// Check to see that this validator address isn't already allocated to a different peer
|
|
927
935
|
const peerForAddress = this.authenticatedValidatorAddressToPeerId.get(sender.toString());
|
|
928
936
|
if (peerForAddress !== undefined && peerForAddress.toString() !== peerIdString) {
|
|
929
|
-
this.logger.
|
|
937
|
+
this.logger.verbose(
|
|
930
938
|
`Received auth for validator ${sender.toString()} from peer ${peerIdString}, but this validator is already authenticated to peer ${peerForAddress.toString()}`,
|
|
939
|
+
{ ...logData, address: sender.toString() },
|
|
931
940
|
);
|
|
932
941
|
return;
|
|
933
942
|
}
|
|
@@ -937,12 +946,13 @@ export class PeerManager implements PeerManagerInterface {
|
|
|
937
946
|
this.authenticatedValidatorAddressToPeerId.set(sender.toString(), peerId);
|
|
938
947
|
this.logger.info(
|
|
939
948
|
`Successfully completed auth handshake with peer ${peerId}, validator address ${sender.toString()}`,
|
|
940
|
-
logData,
|
|
949
|
+
{ ...logData, address: sender.toString() },
|
|
941
950
|
);
|
|
942
951
|
} catch (err: any) {
|
|
943
952
|
//TODO: maybe hard ban these peers in the future
|
|
944
|
-
this.logger.
|
|
953
|
+
this.logger.verbose(`Disconnecting peer ${peerId} due to error during auth handshake: ${err.message}`, {
|
|
945
954
|
peerId,
|
|
955
|
+
err,
|
|
946
956
|
});
|
|
947
957
|
this.markAuthHandshakeFailed(peerId);
|
|
948
958
|
this.markPeerForDisconnect(peerId);
|
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import { median } from '@aztec/foundation/collection';
|
|
2
2
|
import { createLogger } from '@aztec/foundation/log';
|
|
3
3
|
import { PeerErrorSeverity } from '@aztec/stdlib/p2p';
|
|
4
|
+
import {
|
|
5
|
+
Attributes,
|
|
6
|
+
Metrics,
|
|
7
|
+
type TelemetryClient,
|
|
8
|
+
type UpDownCounter,
|
|
9
|
+
ValueType,
|
|
10
|
+
getTelemetryClient,
|
|
11
|
+
} from '@aztec/telemetry-client';
|
|
4
12
|
|
|
5
13
|
import type { PeerId } from '@libp2p/interface';
|
|
6
14
|
|
|
@@ -30,7 +38,9 @@ export class PeerScoring {
|
|
|
30
38
|
private decayFactor = 0.9;
|
|
31
39
|
peerPenalties: { [key in PeerErrorSeverity]: number };
|
|
32
40
|
|
|
33
|
-
|
|
41
|
+
private peerStateCounter: UpDownCounter;
|
|
42
|
+
|
|
43
|
+
constructor(config: P2PConfig, telemetry: TelemetryClient = getTelemetryClient()) {
|
|
34
44
|
const orderedValues = config.peerPenaltyValues?.sort((a, b) => a - b);
|
|
35
45
|
this.peerPenalties = {
|
|
36
46
|
[PeerErrorSeverity.HighToleranceError]:
|
|
@@ -40,6 +50,13 @@ export class PeerScoring {
|
|
|
40
50
|
[PeerErrorSeverity.LowToleranceError]:
|
|
41
51
|
orderedValues?.[2] ?? DefaultPeerPenalties[PeerErrorSeverity.LowToleranceError],
|
|
42
52
|
};
|
|
53
|
+
|
|
54
|
+
const meter = telemetry.getMeter('PeerScoring');
|
|
55
|
+
|
|
56
|
+
this.peerStateCounter = meter.createUpDownCounter(Metrics.P2P_PEER_STATE_COUNT, {
|
|
57
|
+
description: 'Count of peers by state (Healthy, Disconnect, Banned)',
|
|
58
|
+
valueType: ValueType.INT,
|
|
59
|
+
});
|
|
43
60
|
}
|
|
44
61
|
|
|
45
62
|
public penalizePeer(peerId: PeerId, penalty: PeerErrorSeverity) {
|
|
@@ -99,7 +116,33 @@ export class PeerScoring {
|
|
|
99
116
|
return PeerScoreState.Healthy;
|
|
100
117
|
}
|
|
101
118
|
|
|
102
|
-
getStats(): { medianScore: number } {
|
|
103
|
-
|
|
119
|
+
getStats(): { medianScore: number; healthyCount: number; disconnectCount: number; bannedCount: number } {
|
|
120
|
+
const stateCounts = { healthy: 0, disconnect: 0, banned: 0 };
|
|
121
|
+
|
|
122
|
+
for (const peerId of this.scores.keys()) {
|
|
123
|
+
const state = this.getScoreState(peerId);
|
|
124
|
+
switch (state) {
|
|
125
|
+
case PeerScoreState.Healthy:
|
|
126
|
+
stateCounts.healthy++;
|
|
127
|
+
break;
|
|
128
|
+
case PeerScoreState.Disconnect:
|
|
129
|
+
stateCounts.disconnect++;
|
|
130
|
+
break;
|
|
131
|
+
case PeerScoreState.Banned:
|
|
132
|
+
stateCounts.banned++;
|
|
133
|
+
break;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
this.peerStateCounter.add(stateCounts.healthy, { [Attributes.P2P_PEER_SCORE_STATE]: 'Healthy' });
|
|
138
|
+
this.peerStateCounter.add(stateCounts.disconnect, { [Attributes.P2P_PEER_SCORE_STATE]: 'Disconnect' });
|
|
139
|
+
this.peerStateCounter.add(stateCounts.banned, { [Attributes.P2P_PEER_SCORE_STATE]: 'Banned' });
|
|
140
|
+
|
|
141
|
+
return {
|
|
142
|
+
medianScore: median(Array.from(this.scores.values())) ?? 0,
|
|
143
|
+
healthyCount: stateCounts.healthy,
|
|
144
|
+
disconnectCount: stateCounts.disconnect,
|
|
145
|
+
bannedCount: stateCounts.banned,
|
|
146
|
+
};
|
|
104
147
|
}
|
|
105
148
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Fr } from '@aztec/foundation/
|
|
1
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
2
|
import { L2Block } from '@aztec/stdlib/block';
|
|
3
3
|
import { TxArray, TxHashArray } from '@aztec/stdlib/tx';
|
|
4
4
|
|
|
@@ -122,27 +122,6 @@ export type SubProtocolMap = {
|
|
|
122
122
|
>;
|
|
123
123
|
};
|
|
124
124
|
|
|
125
|
-
/**
|
|
126
|
-
* Default handler for unimplemented sub protocols, this SHOULD be overwritten
|
|
127
|
-
* by the service, but is provided as a fallback
|
|
128
|
-
*/
|
|
129
|
-
export const defaultHandler = (_msg: any): Promise<Buffer> => {
|
|
130
|
-
return Promise.resolve(Buffer.from('unimplemented'));
|
|
131
|
-
};
|
|
132
|
-
|
|
133
|
-
/**
|
|
134
|
-
* Default sub protocol handlers - this SHOULD be overwritten by the service,
|
|
135
|
-
*/
|
|
136
|
-
export const DEFAULT_SUB_PROTOCOL_HANDLERS: ReqRespSubProtocolHandlers = {
|
|
137
|
-
[ReqRespSubProtocol.PING]: defaultHandler,
|
|
138
|
-
[ReqRespSubProtocol.STATUS]: defaultHandler,
|
|
139
|
-
[ReqRespSubProtocol.TX]: defaultHandler,
|
|
140
|
-
[ReqRespSubProtocol.GOODBYE]: defaultHandler,
|
|
141
|
-
[ReqRespSubProtocol.BLOCK]: defaultHandler,
|
|
142
|
-
[ReqRespSubProtocol.AUTH]: defaultHandler,
|
|
143
|
-
[ReqRespSubProtocol.BLOCK_TXS]: defaultHandler,
|
|
144
|
-
};
|
|
145
|
-
|
|
146
125
|
/**
|
|
147
126
|
* The Request Response Pair interface defines the methods that each
|
|
148
127
|
* request response pair must implement
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Buffer32 } from '@aztec/foundation/buffer';
|
|
2
|
-
import { keccak256 } from '@aztec/foundation/crypto';
|
|
2
|
+
import { keccak256 } from '@aztec/foundation/crypto/keccak';
|
|
3
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
4
|
import { Signature } from '@aztec/foundation/eth-signature';
|
|
4
|
-
import { Fr } from '@aztec/foundation/fields';
|
|
5
5
|
import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
|
|
6
6
|
|
|
7
7
|
import { StatusMessage } from './status.js';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
2
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
3
|
import type { L2BlockSource } from '@aztec/stdlib/block';
|
|
3
4
|
|
|
4
5
|
import type { PeerId } from '@libp2p/interface';
|
|
@@ -27,7 +28,7 @@ export function reqRespBlockHandler(l2BlockSource: L2BlockSource): ReqRespSubPro
|
|
|
27
28
|
}
|
|
28
29
|
|
|
29
30
|
try {
|
|
30
|
-
const foundBlock = await l2BlockSource.getBlock(Number(blockNumber));
|
|
31
|
+
const foundBlock = await l2BlockSource.getBlock(BlockNumber(Number(blockNumber)));
|
|
31
32
|
return foundBlock ? foundBlock.toBuffer() : Buffer.alloc(0);
|
|
32
33
|
} catch (err: any) {
|
|
33
34
|
throw new ReqRespStatusError(ReqRespStatus.INTERNAL_ERROR, { cause: err });
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
1
2
|
import { Buffer32 } from '@aztec/foundation/buffer';
|
|
2
3
|
import type { Logger } from '@aztec/foundation/log';
|
|
3
4
|
import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
|
|
@@ -15,9 +16,9 @@ import type { PeerId } from '@libp2p/interface';
|
|
|
15
16
|
export class StatusMessage {
|
|
16
17
|
constructor(
|
|
17
18
|
readonly compressedComponentsVersion: string,
|
|
18
|
-
readonly latestBlockNumber:
|
|
19
|
+
readonly latestBlockNumber: BlockNumber,
|
|
19
20
|
readonly latestBlockHash: string,
|
|
20
|
-
readonly finalizedBlockNumber:
|
|
21
|
+
readonly finalizedBlockNumber: BlockNumber,
|
|
21
22
|
//TODO: add finalizedBlockHash
|
|
22
23
|
//readonly finalizedBlockHash: string,
|
|
23
24
|
) {}
|
|
@@ -31,9 +32,9 @@ export class StatusMessage {
|
|
|
31
32
|
const reader = BufferReader.asReader(buffer);
|
|
32
33
|
return new StatusMessage(
|
|
33
34
|
reader.readString(), // compressedComponentsVersion
|
|
34
|
-
reader.readNumber(), // latestBlockNumber
|
|
35
|
+
BlockNumber(reader.readNumber()), // latestBlockNumber
|
|
35
36
|
reader.readString(), // latestBlockHash
|
|
36
|
-
reader.readNumber(), // finalizedBlockNumber
|
|
37
|
+
BlockNumber(reader.readNumber()), // finalizedBlockNumber
|
|
37
38
|
//TODO: add finalizedBlockHash
|
|
38
39
|
//reader.readString(), // finalizedBlockHash
|
|
39
40
|
);
|
|
@@ -63,9 +64,9 @@ export class StatusMessage {
|
|
|
63
64
|
static fromWorldStateSyncStatus(version: string, syncStatus: WorldStateSyncStatus): StatusMessage {
|
|
64
65
|
return new StatusMessage(
|
|
65
66
|
version,
|
|
66
|
-
syncStatus.latestBlockNumber,
|
|
67
|
+
BlockNumber(syncStatus.latestBlockNumber),
|
|
67
68
|
syncStatus.latestBlockHash,
|
|
68
|
-
syncStatus.finalizedBlockNumber,
|
|
69
|
+
BlockNumber(syncStatus.finalizedBlockNumber),
|
|
69
70
|
//TODO: add finalizedBlockHash
|
|
70
71
|
);
|
|
71
72
|
}
|
|
@@ -73,9 +74,9 @@ export class StatusMessage {
|
|
|
73
74
|
static random(): StatusMessage {
|
|
74
75
|
return new StatusMessage(
|
|
75
76
|
'1.0.0',
|
|
76
|
-
Math.floor(Math.random() * 100),
|
|
77
|
+
BlockNumber(Math.floor(Math.random() * 100)),
|
|
77
78
|
Buffer32.random().toString(),
|
|
78
|
-
Math.floor(Math.random() * 100),
|
|
79
|
+
BlockNumber(Math.floor(Math.random() * 100)),
|
|
79
80
|
//TODO: add finalizedBlockHash
|
|
80
81
|
);
|
|
81
82
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { chunk } from '@aztec/foundation/collection';
|
|
2
|
-
import type { P2PClientType } from '@aztec/stdlib/p2p';
|
|
3
2
|
import { TxArray, TxHash, TxHashArray } from '@aztec/stdlib/tx';
|
|
4
3
|
|
|
5
4
|
import type { PeerId } from '@libp2p/interface';
|
|
@@ -16,7 +15,7 @@ import { ReqRespStatus, ReqRespStatusError } from '../status.js';
|
|
|
16
15
|
* @param mempools - the mempools
|
|
17
16
|
* @returns the Tx request handler
|
|
18
17
|
*/
|
|
19
|
-
export function reqRespTxHandler
|
|
18
|
+
export function reqRespTxHandler(mempools: MemPools): ReqRespSubProtocolHandler {
|
|
20
19
|
/**
|
|
21
20
|
* Handler for tx requests
|
|
22
21
|
* @param msg - the tx request message
|
|
@@ -26,7 +26,6 @@ import {
|
|
|
26
26
|
import { BatchConnectionSampler } from './connection-sampler/batch_connection_sampler.js';
|
|
27
27
|
import { ConnectionSampler, RandomSampler } from './connection-sampler/connection_sampler.js';
|
|
28
28
|
import {
|
|
29
|
-
DEFAULT_SUB_PROTOCOL_HANDLERS,
|
|
30
29
|
DEFAULT_SUB_PROTOCOL_VALIDATORS,
|
|
31
30
|
type ReqRespInterface,
|
|
32
31
|
type ReqRespResponse,
|
|
@@ -64,9 +63,8 @@ export class ReqResp implements ReqRespInterface {
|
|
|
64
63
|
private individualRequestTimeoutMs: number = DEFAULT_INDIVIDUAL_REQUEST_TIMEOUT_MS;
|
|
65
64
|
private dialTimeoutMs: number = DEFAULT_REQRESP_DIAL_TIMEOUT_MS;
|
|
66
65
|
|
|
67
|
-
|
|
68
|
-
private
|
|
69
|
-
private subProtocolValidators: ReqRespSubProtocolValidators = DEFAULT_SUB_PROTOCOL_VALIDATORS;
|
|
66
|
+
private subProtocolHandlers: Partial<ReqRespSubProtocolHandlers> = {};
|
|
67
|
+
private subProtocolValidators: Partial<ReqRespSubProtocolValidators> = {};
|
|
70
68
|
|
|
71
69
|
private connectionSampler: ConnectionSampler;
|
|
72
70
|
private rateLimiter: RequestResponseRateLimiter;
|
|
@@ -117,11 +115,12 @@ export class ReqResp implements ReqRespInterface {
|
|
|
117
115
|
* Start the reqresp service
|
|
118
116
|
*/
|
|
119
117
|
async start(subProtocolHandlers: ReqRespSubProtocolHandlers, subProtocolValidators: ReqRespSubProtocolValidators) {
|
|
120
|
-
this.subProtocolHandlers
|
|
121
|
-
this.subProtocolValidators
|
|
118
|
+
Object.assign(this.subProtocolHandlers, subProtocolHandlers);
|
|
119
|
+
Object.assign(this.subProtocolValidators, subProtocolValidators);
|
|
122
120
|
|
|
123
121
|
// Register all protocol handlers
|
|
124
|
-
for (const subProtocol of Object.keys(
|
|
122
|
+
for (const subProtocol of Object.keys(subProtocolHandlers)) {
|
|
123
|
+
this.logger.debug(`Registering handler for sub protocol ${subProtocol}`);
|
|
125
124
|
await this.libp2p.handle(
|
|
126
125
|
subProtocol,
|
|
127
126
|
(data: IncomingStreamData) =>
|
|
@@ -140,6 +139,7 @@ export class ReqResp implements ReqRespInterface {
|
|
|
140
139
|
): Promise<void> {
|
|
141
140
|
this.subProtocolHandlers[subProtocol] = handler;
|
|
142
141
|
this.subProtocolValidators[subProtocol] = validator;
|
|
142
|
+
this.logger.debug(`Registering handler for sub protocol ${subProtocol}`);
|
|
143
143
|
await this.libp2p.handle(
|
|
144
144
|
subProtocol,
|
|
145
145
|
(data: IncomingStreamData) =>
|
|
@@ -209,7 +209,7 @@ export class ReqResp implements ReqRespInterface {
|
|
|
209
209
|
maxPeers = Math.max(10, Math.ceil(requests.length / 3)),
|
|
210
210
|
maxRetryAttempts = 3,
|
|
211
211
|
): Promise<InstanceType<SubProtocolMap[SubProtocol]['response']>[]> {
|
|
212
|
-
const responseValidator = this.subProtocolValidators[subProtocol];
|
|
212
|
+
const responseValidator = this.subProtocolValidators[subProtocol] ?? DEFAULT_SUB_PROTOCOL_VALIDATORS[subProtocol];
|
|
213
213
|
const responses: InstanceType<SubProtocolMap[SubProtocol]['response']>[] = new Array(requests.length);
|
|
214
214
|
const requestBuffers = requests.map(req => req.toBuffer());
|
|
215
215
|
|
|
@@ -489,7 +489,7 @@ export class ReqResp implements ReqRespInterface {
|
|
|
489
489
|
}
|
|
490
490
|
|
|
491
491
|
const messageData = Buffer.concat(chunks);
|
|
492
|
-
const message: Buffer = this.snappyTransform.
|
|
492
|
+
const message: Buffer = this.snappyTransform.inboundTransformData(messageData);
|
|
493
493
|
|
|
494
494
|
return {
|
|
495
495
|
status: status ?? ReqRespStatus.UNKNOWN,
|
|
@@ -594,7 +594,11 @@ export class ReqResp implements ReqRespInterface {
|
|
|
594
594
|
*
|
|
595
595
|
* */
|
|
596
596
|
private async processStream(protocol: ReqRespSubProtocol, { stream, connection }: IncomingStreamData): Promise<void> {
|
|
597
|
-
const handler = this.subProtocolHandlers[protocol]
|
|
597
|
+
const handler = this.subProtocolHandlers[protocol];
|
|
598
|
+
if (!handler) {
|
|
599
|
+
throw new Error(`No handler defined for reqresp subprotocol ${protocol}`);
|
|
600
|
+
}
|
|
601
|
+
|
|
598
602
|
const snappy = this.snappyTransform;
|
|
599
603
|
const SUCCESS = Uint8Array.of(ReqRespStatus.SUCCESS);
|
|
600
604
|
|
|
@@ -614,7 +618,7 @@ export class ReqResp implements ReqRespInterface {
|
|
|
614
618
|
stream.metadata.written = true; // Mark the stream as written to;
|
|
615
619
|
|
|
616
620
|
yield SUCCESS;
|
|
617
|
-
yield snappy.
|
|
621
|
+
yield snappy.outboundTransformData(response);
|
|
618
622
|
}
|
|
619
623
|
},
|
|
620
624
|
stream.sink,
|
package/src/services/service.ts
CHANGED
|
@@ -3,8 +3,8 @@ import type { PeerInfo } from '@aztec/stdlib/interfaces/server';
|
|
|
3
3
|
import type { BlockAttestation, BlockProposal, Gossipable } from '@aztec/stdlib/p2p';
|
|
4
4
|
import type { Tx } from '@aztec/stdlib/tx';
|
|
5
5
|
|
|
6
|
-
import type { ENR } from '@chainsafe/enr';
|
|
7
6
|
import type { PeerId } from '@libp2p/interface';
|
|
7
|
+
import type { ENR } from '@nethermindeth/enr';
|
|
8
8
|
import type EventEmitter from 'events';
|
|
9
9
|
|
|
10
10
|
import type { P2PReqRespConfig } from './reqresp/config.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type ConfigMappingsType, booleanConfigHelper, numberConfigHelper } from '@aztec/foundation/config';
|
|
2
|
-
import { MAX_RPC_TXS_LEN } from '@aztec/stdlib/interfaces/
|
|
2
|
+
import { MAX_RPC_TXS_LEN } from '@aztec/stdlib/interfaces/api-limit';
|
|
3
3
|
|
|
4
4
|
export type TxCollectionConfig = {
|
|
5
5
|
/** How long to wait before starting reqresp for fast collection */
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
1
2
|
import { times } from '@aztec/foundation/collection';
|
|
2
3
|
import { AbortError, TimeoutError } from '@aztec/foundation/error';
|
|
3
4
|
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
@@ -5,7 +6,7 @@ import { boundInclusive } from '@aztec/foundation/number';
|
|
|
5
6
|
import { promiseWithResolvers } from '@aztec/foundation/promise';
|
|
6
7
|
import { sleep } from '@aztec/foundation/sleep';
|
|
7
8
|
import { DateProvider, elapsed } from '@aztec/foundation/timer';
|
|
8
|
-
import type {
|
|
9
|
+
import type { L2BlockInfo } from '@aztec/stdlib/block';
|
|
9
10
|
import type { BlockProposal } from '@aztec/stdlib/p2p';
|
|
10
11
|
import { type Tx, TxHash } from '@aztec/stdlib/tx';
|
|
11
12
|
|
|
@@ -54,8 +55,10 @@ export class FastTxCollection {
|
|
|
54
55
|
return [];
|
|
55
56
|
}
|
|
56
57
|
|
|
57
|
-
const blockInfo:
|
|
58
|
-
input.type === 'proposal'
|
|
58
|
+
const blockInfo: L2BlockInfo =
|
|
59
|
+
input.type === 'proposal'
|
|
60
|
+
? { ...input.blockProposal.toBlockInfo(), blockNumber: input.blockNumber }
|
|
61
|
+
: { ...input.block.toBlockInfo() };
|
|
59
62
|
|
|
60
63
|
// This promise is used to await for the collection to finish during the main collectFast method.
|
|
61
64
|
// It gets resolved in `foundTxs` when all txs have been collected, or rejected if the request is aborted or hits the deadline.
|
|
@@ -314,7 +317,7 @@ export class FastTxCollection {
|
|
|
314
317
|
* Stop collecting all txs for blocks less than or requal to the block number specified.
|
|
315
318
|
* To be called when we no longer care about gathering txs up to a certain block, eg when they become proven or finalized.
|
|
316
319
|
*/
|
|
317
|
-
public stopCollectingForBlocksUpTo(blockNumber:
|
|
320
|
+
public stopCollectingForBlocksUpTo(blockNumber: BlockNumber): void {
|
|
318
321
|
for (const request of this.requests) {
|
|
319
322
|
if (request.blockInfo.blockNumber <= blockNumber) {
|
|
320
323
|
request.promise.reject(new AbortError(`Stopped collecting txs up to block ${blockNumber}`));
|
|
@@ -327,7 +330,7 @@ export class FastTxCollection {
|
|
|
327
330
|
* Stop collecting all txs for blocks greater than the block number specified.
|
|
328
331
|
* To be called when there is a chain prune and previously mined txs are no longer relevant.
|
|
329
332
|
*/
|
|
330
|
-
public stopCollectingForBlocksAfter(blockNumber:
|
|
333
|
+
public stopCollectingForBlocksAfter(blockNumber: BlockNumber): void {
|
|
331
334
|
for (const request of this.requests) {
|
|
332
335
|
if (request.blockInfo.blockNumber > blockNumber) {
|
|
333
336
|
request.promise.reject(new AbortError(`Stopped collecting txs after block ${blockNumber}`));
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { BlockNumber, EpochNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
1
2
|
import { chunk } from '@aztec/foundation/collection';
|
|
2
3
|
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
3
4
|
import { boundInclusive } from '@aztec/foundation/number';
|
|
4
5
|
import { RunningPromise } from '@aztec/foundation/promise';
|
|
5
6
|
import { DateProvider } from '@aztec/foundation/timer';
|
|
6
|
-
import type {
|
|
7
|
+
import type { L2BlockNew } from '@aztec/stdlib/block';
|
|
7
8
|
import { type L1RollupConstants, getEpochAtSlot, getTimestampRangeForEpoch } from '@aztec/stdlib/epoch-helpers';
|
|
8
9
|
import { type Tx, TxHash } from '@aztec/stdlib/tx';
|
|
9
10
|
|
|
@@ -75,7 +76,7 @@ export class SlowTxCollection {
|
|
|
75
76
|
}
|
|
76
77
|
|
|
77
78
|
/** Starts collecting the given tx hashes for the given L2Block in the slow loop */
|
|
78
|
-
public startCollecting(block:
|
|
79
|
+
public startCollecting(block: L2BlockNew, txHashes: TxHash[]) {
|
|
79
80
|
const slot = block.header.getSlot();
|
|
80
81
|
const deadline = this.getDeadlineForSlot(slot);
|
|
81
82
|
if (+deadline < this.dateProvider.now()) {
|
|
@@ -202,7 +203,7 @@ export class SlowTxCollection {
|
|
|
202
203
|
* Stop collecting all txs for blocks less than or requal to the block number specified.
|
|
203
204
|
* To be called when we no longer care about gathering txs up to a certain block, eg when they become proven or finalized.
|
|
204
205
|
*/
|
|
205
|
-
public stopCollectingForBlocksUpTo(blockNumber:
|
|
206
|
+
public stopCollectingForBlocksUpTo(blockNumber: BlockNumber): void {
|
|
206
207
|
for (const [txHash, info] of this.missingTxs.entries()) {
|
|
207
208
|
if (info.blockNumber <= blockNumber) {
|
|
208
209
|
this.missingTxs.delete(txHash);
|
|
@@ -214,7 +215,7 @@ export class SlowTxCollection {
|
|
|
214
215
|
* Stop collecting all txs for blocks greater than the block number specified.
|
|
215
216
|
* To be called when there is a chain prune and previously mined txs are no longer relevant.
|
|
216
217
|
*/
|
|
217
|
-
public stopCollectingForBlocksAfter(blockNumber:
|
|
218
|
+
public stopCollectingForBlocksAfter(blockNumber: BlockNumber): void {
|
|
218
219
|
for (const [txHash, info] of this.missingTxs.entries()) {
|
|
219
220
|
if (info.blockNumber > blockNumber) {
|
|
220
221
|
this.missingTxs.delete(txHash);
|
|
@@ -223,9 +224,9 @@ export class SlowTxCollection {
|
|
|
223
224
|
}
|
|
224
225
|
|
|
225
226
|
/** Computes the proof submission deadline for a given slot, a tx mined in this slot is no longer interesting after this deadline */
|
|
226
|
-
private getDeadlineForSlot(slotNumber:
|
|
227
|
+
private getDeadlineForSlot(slotNumber: SlotNumber): Date {
|
|
227
228
|
const epoch = getEpochAtSlot(slotNumber, this.constants);
|
|
228
|
-
const submissionEndEpoch = epoch +
|
|
229
|
+
const submissionEndEpoch = EpochNumber(epoch + this.constants.proofSubmissionEpochs);
|
|
229
230
|
const submissionEndTimestamp = getTimestampRangeForEpoch(submissionEndEpoch, this.constants)[1];
|
|
230
231
|
return new Date(Number(submissionEndTimestamp) * 1000);
|
|
231
232
|
}
|