@aztec/p2p 0.0.1-commit.9ef841308 → 0.0.1-commit.a4600f49
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -6
- package/dest/bootstrap/bootstrap.d.ts +1 -1
- package/dest/bootstrap/bootstrap.d.ts.map +1 -1
- package/dest/bootstrap/bootstrap.js +22 -6
- package/dest/client/factory.d.ts +4 -3
- package/dest/client/factory.d.ts.map +1 -1
- package/dest/client/factory.js +33 -24
- package/dest/client/interface.d.ts +48 -11
- package/dest/client/interface.d.ts.map +1 -1
- package/dest/client/p2p_client.d.ts +34 -19
- package/dest/client/p2p_client.d.ts.map +1 -1
- package/dest/client/p2p_client.js +105 -46
- package/dest/config.d.ts +143 -107
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +72 -26
- 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 +9 -16
- package/dest/errors/reqresp.error.d.ts.map +1 -1
- package/dest/errors/reqresp.error.js +10 -17
- package/dest/mem_pools/attestation_pool/attestation_pool.d.ts +98 -56
- package/dest/mem_pools/attestation_pool/attestation_pool.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/attestation_pool.js +269 -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 +218 -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/instrumentation.d.ts +9 -4
- package/dest/mem_pools/instrumentation.d.ts.map +1 -1
- package/dest/mem_pools/instrumentation.js +28 -9
- 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/deleted_pool.d.ts +3 -3
- package/dest/mem_pools/tx_pool_v2/deleted_pool.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/deleted_pool.js +6 -6
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.js +1 -1
- 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 +33 -5
- package/dest/mem_pools/tx_pool_v2/interfaces.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/interfaces.js +2 -1
- package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts +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 +8 -5
- package/dest/mem_pools/tx_pool_v2/tx_pool_indices.d.ts +15 -1
- package/dest/mem_pools/tx_pool_v2/tx_pool_indices.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/tx_pool_indices.js +31 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts +9 -3
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2.js +19 -8
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts +17 -4
- 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 +208 -118
- package/dest/msg_validators/attestation_validator/attestation_validator.d.ts +10 -3
- package/dest/msg_validators/attestation_validator/attestation_validator.d.ts.map +1 -1
- package/dest/msg_validators/attestation_validator/attestation_validator.js +38 -16
- 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/proposal_validator/block_proposal_validator.d.ts +8 -3
- package/dest/msg_validators/proposal_validator/block_proposal_validator.d.ts.map +1 -1
- package/dest/msg_validators/proposal_validator/block_proposal_validator.js +2 -2
- package/dest/msg_validators/proposal_validator/checkpoint_proposal_validator.d.ts +8 -3
- package/dest/msg_validators/proposal_validator/checkpoint_proposal_validator.d.ts.map +1 -1
- package/dest/msg_validators/proposal_validator/checkpoint_proposal_validator.js +8 -2
- package/dest/msg_validators/proposal_validator/proposal_validator.d.ts +25 -3
- package/dest/msg_validators/proposal_validator/proposal_validator.d.ts.map +1 -1
- package/dest/msg_validators/proposal_validator/proposal_validator.js +85 -15
- 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/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 +1 -0
- package/dest/msg_validators/tx_validator/factory.d.ts +14 -15
- package/dest/msg_validators/tx_validator/factory.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/factory.js +29 -16
- package/dest/msg_validators/tx_validator/gas_validator.d.ts +47 -10
- package/dest/msg_validators/tx_validator/gas_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/gas_validator.js +65 -48
- 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 +2 -2
- 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 +13 -2
- package/dest/services/discv5/discV5_service.d.ts.map +1 -1
- package/dest/services/discv5/discV5_service.js +119 -25
- package/dest/services/discv5/persisted_enr_store.d.ts +38 -0
- package/dest/services/discv5/persisted_enr_store.d.ts.map +1 -0
- package/dest/services/discv5/persisted_enr_store.js +145 -0
- package/dest/services/dummy_service.d.ts +15 -15
- package/dest/services/dummy_service.d.ts.map +1 -1
- package/dest/services/dummy_service.js +15 -16
- package/dest/services/encoding.d.ts +19 -6
- package/dest/services/encoding.d.ts.map +1 -1
- package/dest/services/encoding.js +25 -15
- package/dest/services/gossipsub/topic_score_params.d.ts +6 -12
- package/dest/services/gossipsub/topic_score_params.d.ts.map +1 -1
- package/dest/services/gossipsub/topic_score_params.js +4 -14
- 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 +40 -40
- package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
- package/dest/services/libp2p/libp2p_service.js +292 -264
- package/dest/services/peer-manager/peer_manager.d.ts +15 -2
- package/dest/services/peer-manager/peer_manager.d.ts.map +1 -1
- package/dest/services/peer-manager/peer_manager.js +59 -17
- package/dest/services/peer-manager/peer_scoring.d.ts +30 -1
- package/dest/services/peer-manager/peer_scoring.d.ts.map +1 -1
- package/dest/services/peer-manager/peer_scoring.js +74 -3
- 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 +35 -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 +15 -3
- package/dest/services/reqresp/config.d.ts.map +1 -1
- package/dest/services/reqresp/config.js +11 -0
- 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_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 +3 -13
- 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 +59 -209
- package/dest/services/service.d.ts +23 -16
- 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/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 +1 -1
- package/dest/services/tx_collection/tx_source.d.ts.map +1 -1
- package/dest/services/tx_collection/tx_source.js +4 -1
- 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 +21 -12
- package/dest/test-helpers/mock-pubsub.d.ts.map +1 -1
- package/dest/test-helpers/mock-pubsub.js +39 -47
- 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 +15 -14
- package/dest/test-helpers/testbench-utils.d.ts.map +1 -1
- package/dest/test-helpers/testbench-utils.js +28 -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 +60 -27
- 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 -8
- package/dest/util.d.ts +8 -8
- package/dest/util.d.ts.map +1 -1
- package/dest/util.js +38 -10
- package/dest/versioning.d.ts +3 -6
- package/dest/versioning.d.ts.map +1 -1
- package/dest/versioning.js +3 -24
- package/package.json +16 -16
- package/src/bootstrap/bootstrap.ts +17 -3
- package/src/client/factory.ts +49 -25
- package/src/client/interface.ts +44 -17
- package/src/client/p2p_client.ts +125 -79
- package/src/client/test/{tx_proposal_collector/README.md → p2p_client.batch_tx_requester.bench.README.md} +23 -53
- package/src/config.ts +146 -34
- package/src/errors/p2p-service.error.ts +11 -0
- package/src/errors/reqresp.error.ts +13 -19
- package/src/mem_pools/attestation_pool/attestation_pool.ts +324 -239
- package/src/mem_pools/attestation_pool/attestation_pool_test_suite.ts +238 -63
- package/src/mem_pools/attestation_pool/mocks.ts +13 -8
- package/src/mem_pools/instrumentation.ts +18 -12
- package/src/mem_pools/tx_pool_v2/archive/tx_archive.ts +1 -9
- package/src/mem_pools/tx_pool_v2/deleted_pool.ts +7 -7
- package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.ts +1 -1
- 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 +31 -4
- package/src/mem_pools/tx_pool_v2/tx_metadata.ts +13 -7
- package/src/mem_pools/tx_pool_v2/tx_pool_indices.ts +35 -0
- package/src/mem_pools/tx_pool_v2/tx_pool_v2.ts +22 -8
- package/src/mem_pools/tx_pool_v2/tx_pool_v2_impl.ts +233 -123
- package/src/msg_validators/attestation_validator/attestation_validator.ts +46 -15
- package/src/msg_validators/attestation_validator/fisherman_attestation_validator.ts +15 -7
- package/src/msg_validators/proposal_validator/block_proposal_validator.ts +15 -3
- package/src/msg_validators/proposal_validator/checkpoint_proposal_validator.ts +26 -3
- package/src/msg_validators/proposal_validator/proposal_validator.ts +94 -12
- package/src/msg_validators/tx_validator/README.md +13 -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/data_validator.ts +2 -0
- package/src/msg_validators/tx_validator/factory.ts +37 -20
- package/src/msg_validators/tx_validator/gas_validator.ts +99 -54
- package/src/msg_validators/tx_validator/index.ts +2 -0
- package/src/msg_validators/tx_validator/phases_validator.ts +2 -2
- 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 +126 -16
- package/src/services/discv5/persisted_enr_store.ts +158 -0
- package/src/services/dummy_service.ts +20 -39
- package/src/services/encoding.ts +28 -20
- package/src/services/gossipsub/README.md +33 -11
- package/src/services/gossipsub/topic_score_params.ts +9 -18
- package/src/services/libp2p/instrumentation.ts +14 -0
- package/src/services/libp2p/libp2p_service.ts +342 -290
- package/src/services/peer-manager/peer_manager.ts +63 -16
- package/src/services/peer-manager/peer_scoring.ts +81 -3
- package/src/services/reqresp/README.md +2 -37
- package/src/services/reqresp/batch-tx-requester/batch_tx_requester.ts +39 -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 +19 -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_limits.ts +3 -13
- package/src/services/reqresp/reqresp.ts +69 -252
- package/src/services/service.ts +28 -32
- 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/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 +2 -1
- 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 +41 -64
- 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 +35 -26
- package/src/testbench/p2p_client_testbench_worker.ts +68 -44
- package/src/testbench/worker_client_manager.ts +59 -19
- package/src/util.ts +33 -14
- 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 -315
- 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/msg_validators/clock_tolerance.d.ts +0 -21
- package/dest/msg_validators/clock_tolerance.d.ts.map +0 -1
- package/dest/msg_validators/clock_tolerance.js +0 -38
- 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 -355
- package/src/client/test/tx_proposal_collector/proposal_tx_collector_worker_protocol.ts +0 -43
- package/src/msg_validators/clock_tolerance.ts +0 -52
- 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
|
@@ -17,12 +17,14 @@ import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
|
|
|
17
17
|
import { protocolContractsHash } from '@aztec/protocol-contracts';
|
|
18
18
|
import type { L2BlockSource } from '@aztec/stdlib/block';
|
|
19
19
|
import type { ContractDataSource } from '@aztec/stdlib/contract';
|
|
20
|
+
import { EmptyL1RollupConstants, type L1RollupConstants } from '@aztec/stdlib/epoch-helpers';
|
|
21
|
+
import { GasFees } from '@aztec/stdlib/gas';
|
|
20
22
|
import type { ClientProtocolCircuitVerifier, WorldStateSynchronizer } from '@aztec/stdlib/interfaces/server';
|
|
21
23
|
import type { DataStoreConfig } from '@aztec/stdlib/kv-store';
|
|
22
24
|
import { type BlockProposal, P2PMessage } from '@aztec/stdlib/p2p';
|
|
23
25
|
import { ChonkProof } from '@aztec/stdlib/proofs';
|
|
24
26
|
import { makeAztecAddress, makeBlockHeader, makeBlockProposal, mockTx } from '@aztec/stdlib/testing';
|
|
25
|
-
import { Tx, TxHash, type TxValidationResult } from '@aztec/stdlib/tx';
|
|
27
|
+
import { Tx, TxHash, type TxValidationResult, type TxValidator } from '@aztec/stdlib/tx';
|
|
26
28
|
import { type TelemetryClient, getTelemetryClient } from '@aztec/telemetry-client';
|
|
27
29
|
|
|
28
30
|
import type { Message, PeerId } from '@libp2p/interface';
|
|
@@ -33,10 +35,10 @@ import type { P2PClient } from '../client/index.js';
|
|
|
33
35
|
import type { P2PConfig } from '../config.js';
|
|
34
36
|
import { createP2PClient } from '../index.js';
|
|
35
37
|
import type { MemPools } from '../mem_pools/index.js';
|
|
36
|
-
import {
|
|
38
|
+
import { LibP2PService } from '../services/index.js';
|
|
37
39
|
import type { PeerManager } from '../services/peer-manager/peer_manager.js';
|
|
40
|
+
import { BatchTxRequester } from '../services/reqresp/batch-tx-requester/batch_tx_requester.js';
|
|
38
41
|
import type { BatchTxRequesterLibP2PService } from '../services/reqresp/batch-tx-requester/interface.js';
|
|
39
|
-
import type { IBatchRequestTxValidator } from '../services/reqresp/batch-tx-requester/tx_validator.js';
|
|
40
42
|
import { RateLimitStatus } from '../services/reqresp/rate-limiter/rate_limiter.js';
|
|
41
43
|
import type { ReqResp } from '../services/reqresp/reqresp.js';
|
|
42
44
|
import type { PeerDiscoveryService } from '../services/service.js';
|
|
@@ -44,7 +46,6 @@ import { RequestTracker } from '../services/tx_collection/request_tracker.js';
|
|
|
44
46
|
import { AlwaysTrueCircuitVerifier } from '../test-helpers/index.js';
|
|
45
47
|
import {
|
|
46
48
|
BENCHMARK_CONSTANTS,
|
|
47
|
-
type CollectorType,
|
|
48
49
|
type DistributionPattern,
|
|
49
50
|
InMemoryAttestationPool,
|
|
50
51
|
InMemoryTxPool,
|
|
@@ -55,15 +56,13 @@ import {
|
|
|
55
56
|
} from '../test-helpers/index.js';
|
|
56
57
|
import type { PubSubLibp2p } from '../util.js';
|
|
57
58
|
|
|
58
|
-
export type { DistributionPattern
|
|
59
|
-
export { COLLECTOR_DISPLAY_NAMES } from '../test-helpers/testbench-utils.js';
|
|
59
|
+
export type { DistributionPattern } from '../test-helpers/testbench-utils.js';
|
|
60
60
|
|
|
61
61
|
export interface BenchReqRespCommand {
|
|
62
62
|
type: 'BENCH_REQRESP';
|
|
63
63
|
txCount: number;
|
|
64
64
|
peerCount: number;
|
|
65
65
|
distribution: DistributionPattern;
|
|
66
|
-
collectorType: CollectorType;
|
|
67
66
|
timeoutMs: number;
|
|
68
67
|
isAggregator: boolean;
|
|
69
68
|
peerIndex: number;
|
|
@@ -86,6 +85,25 @@ export interface BenchReadyMessage {
|
|
|
86
85
|
}
|
|
87
86
|
const txCache = new Map<number, Tx[]>();
|
|
88
87
|
|
|
88
|
+
const BENCH_L1_CONSTANTS: L1RollupConstants = {
|
|
89
|
+
...EmptyL1RollupConstants,
|
|
90
|
+
slotDuration: 12,
|
|
91
|
+
ethereumSlotDuration: 4,
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
class TestbenchL2BlockSource extends MockL2BlockSource {
|
|
95
|
+
public override getL1Constants(): Promise<L1RollupConstants> {
|
|
96
|
+
return Promise.resolve(BENCH_L1_CONSTANTS);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function createBenchmarkEpochCache(): EpochCacheInterface {
|
|
101
|
+
return {
|
|
102
|
+
...createMockEpochCache(),
|
|
103
|
+
getL1Constants: () => BENCH_L1_CONSTANTS,
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
|
|
89
107
|
class TestLibP2PService extends LibP2PService {
|
|
90
108
|
private disableTxValidation: boolean;
|
|
91
109
|
private gossipMessageCount = 0;
|
|
@@ -116,6 +134,7 @@ class TestLibP2PService extends LibP2PService {
|
|
|
116
134
|
epochCache,
|
|
117
135
|
proofVerifier,
|
|
118
136
|
worldStateSynchronizer,
|
|
137
|
+
{ getCurrentMinFees: () => Promise.resolve(GasFees.empty()) },
|
|
119
138
|
telemetry,
|
|
120
139
|
logger,
|
|
121
140
|
);
|
|
@@ -204,10 +223,28 @@ function installUnlimitedRateLimits(client: P2PClient): void {
|
|
|
204
223
|
rateLimiter.allow = () => RateLimitStatus.Allowed;
|
|
205
224
|
}
|
|
206
225
|
|
|
226
|
+
/** Resets peer scores to prevent cross-case contamination in benchmarks. */
|
|
227
|
+
function resetPeerScores(client: P2PClient): void {
|
|
228
|
+
const peerManager = (client as any).p2pService.peerManager;
|
|
229
|
+
const peerScoring = peerManager?.peerScoring;
|
|
230
|
+
if (peerScoring?.resetAllScores) {
|
|
231
|
+
peerScoring.resetAllScores();
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/** Returns the number of connected peers for connectivity checks. */
|
|
236
|
+
function getConnectedPeerCount(client: P2PClient): number {
|
|
237
|
+
const p2pService = (client as any).p2pService;
|
|
238
|
+
const connectionSampler = p2pService?.reqresp?.getConnectionSampler?.();
|
|
239
|
+
if (connectionSampler?.getPeerListSortedByConnectionCountAsc) {
|
|
240
|
+
return connectionSampler.getPeerListSortedByConnectionCountAsc().length;
|
|
241
|
+
}
|
|
242
|
+
return 0;
|
|
243
|
+
}
|
|
244
|
+
|
|
207
245
|
async function runAggregatorBenchmark(
|
|
208
246
|
client: P2PClient,
|
|
209
247
|
blockProposal: BlockProposal,
|
|
210
|
-
collectorType: CollectorType,
|
|
211
248
|
timeoutMs: number,
|
|
212
249
|
pinnedPeerId: string | undefined,
|
|
213
250
|
pinnedPeerIndex: number | undefined,
|
|
@@ -258,44 +295,22 @@ async function runAggregatorBenchmark(
|
|
|
258
295
|
}
|
|
259
296
|
}
|
|
260
297
|
|
|
261
|
-
const noopTxValidator:
|
|
262
|
-
|
|
263
|
-
validateRequestedTxs: (txs: Tx[]): Promise<TxValidationResult[]> =>
|
|
264
|
-
Promise.resolve(txs.map(() => ({ result: 'valid' }))),
|
|
298
|
+
const noopTxValidator: TxValidator = {
|
|
299
|
+
validateTx: (_tx: Tx): Promise<TxValidationResult> => Promise.resolve({ result: 'valid' }),
|
|
265
300
|
};
|
|
266
301
|
|
|
267
302
|
timer = new Timer();
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
logger,
|
|
272
|
-
new DateProvider(),
|
|
273
|
-
noopTxValidator,
|
|
274
|
-
);
|
|
275
|
-
const fetchedTxs = await collector.collectTxs(
|
|
276
|
-
RequestTracker.create(txHashes, new Date(Date.now() + timeoutMs)),
|
|
277
|
-
blockProposal,
|
|
278
|
-
pinnedPeer,
|
|
279
|
-
);
|
|
280
|
-
const durationMs = timer.ms();
|
|
281
|
-
return {
|
|
282
|
-
type: 'BENCH_RESULT',
|
|
283
|
-
durationMs,
|
|
284
|
-
fetchedCount: fetchedTxs.length,
|
|
285
|
-
success: fetchedTxs.length === txHashes.length,
|
|
286
|
-
};
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
const collector = new SendBatchRequestCollector(
|
|
290
|
-
batchTxRequesterService,
|
|
291
|
-
BENCHMARK_CONSTANTS.FIXED_MAX_PEERS,
|
|
292
|
-
BENCHMARK_CONSTANTS.FIXED_MAX_RETRY_ATTEMPTS,
|
|
293
|
-
);
|
|
294
|
-
const fetchedTxs = await collector.collectTxs(
|
|
295
|
-
RequestTracker.create(txHashes, new Date(Date.now() + timeoutMs)),
|
|
303
|
+
const tracker = RequestTracker.create(txHashes, new Date(Date.now() + timeoutMs));
|
|
304
|
+
const batchRequester = new BatchTxRequester(
|
|
305
|
+
tracker,
|
|
296
306
|
blockProposal,
|
|
297
307
|
pinnedPeer,
|
|
308
|
+
batchTxRequesterService,
|
|
309
|
+
logger,
|
|
310
|
+
new DateProvider(),
|
|
311
|
+
{ txValidator: noopTxValidator },
|
|
298
312
|
);
|
|
313
|
+
const fetchedTxs = await BatchTxRequester.collectAllTxs(batchRequester.run());
|
|
299
314
|
const durationMs = timer.ms();
|
|
300
315
|
return {
|
|
301
316
|
type: 'BENCH_RESULT',
|
|
@@ -375,9 +390,9 @@ process.on('message', async msg => {
|
|
|
375
390
|
workerConfig = config;
|
|
376
391
|
workerTxPool = new InMemoryTxPool();
|
|
377
392
|
workerAttestationPool = new InMemoryAttestationPool();
|
|
378
|
-
const epochCache =
|
|
393
|
+
const epochCache = createBenchmarkEpochCache();
|
|
379
394
|
const worldState = createMockWorldStateSynchronizer();
|
|
380
|
-
const l2BlockSource = new
|
|
395
|
+
const l2BlockSource = new TestbenchL2BlockSource();
|
|
381
396
|
|
|
382
397
|
const proofVerifier = new AlwaysTrueCircuitVerifier();
|
|
383
398
|
kvStore = await openTmpStore(`test-${clientIndex}`, true, BENCHMARK_CONSTANTS.KV_STORE_MAP_SIZE_KB);
|
|
@@ -398,10 +413,12 @@ process.on('message', async msg => {
|
|
|
398
413
|
proofVerifier as ClientProtocolCircuitVerifier,
|
|
399
414
|
worldState,
|
|
400
415
|
epochCache,
|
|
416
|
+
{ getCurrentMinFees: () => Promise.resolve(GasFees.empty()) },
|
|
401
417
|
'test-p2p-bench-worker',
|
|
402
418
|
undefined,
|
|
403
419
|
telemetry as TelemetryClient,
|
|
404
420
|
deps,
|
|
421
|
+
await l2BlockSource.getInitialHeader().hash(),
|
|
405
422
|
);
|
|
406
423
|
|
|
407
424
|
const testService = new TestLibP2PService(
|
|
@@ -452,6 +469,13 @@ process.on('message', async msg => {
|
|
|
452
469
|
}
|
|
453
470
|
break;
|
|
454
471
|
|
|
472
|
+
case 'GET_PEER_COUNT':
|
|
473
|
+
process.send!({
|
|
474
|
+
type: 'PEER_COUNT',
|
|
475
|
+
count: workerClient ? getConnectedPeerCount(workerClient) : 0,
|
|
476
|
+
});
|
|
477
|
+
break;
|
|
478
|
+
|
|
455
479
|
case 'BENCH_REQRESP': {
|
|
456
480
|
const benchCmd = cmd as BenchReqRespCommand;
|
|
457
481
|
if (!workerClient || !workerTxPool || !workerAttestationPool || !workerConfig || !workerLogger) {
|
|
@@ -468,6 +492,7 @@ process.on('message', async msg => {
|
|
|
468
492
|
// Reset state before each benchmark run to avoid cross-run contamination
|
|
469
493
|
workerTxPool.resetState();
|
|
470
494
|
workerAttestationPool.resetState();
|
|
495
|
+
resetPeerScores(workerClient);
|
|
471
496
|
|
|
472
497
|
installUnlimitedRateLimits(workerClient);
|
|
473
498
|
|
|
@@ -484,13 +509,12 @@ process.on('message', async msg => {
|
|
|
484
509
|
workerTxPool.clearTxs();
|
|
485
510
|
|
|
486
511
|
workerLogger.info(
|
|
487
|
-
`[BENCH] Aggregator starting benchmark: txCount=${benchCmd.txCount},
|
|
512
|
+
`[BENCH] Aggregator starting benchmark: txCount=${benchCmd.txCount}, distribution=${benchCmd.distribution}`,
|
|
488
513
|
);
|
|
489
514
|
|
|
490
515
|
const result = await runAggregatorBenchmark(
|
|
491
516
|
workerClient,
|
|
492
517
|
blockProposal,
|
|
493
|
-
benchCmd.collectorType,
|
|
494
518
|
benchCmd.timeoutMs,
|
|
495
519
|
benchCmd.pinnedPeerId,
|
|
496
520
|
benchCmd.pinnedPeerIndex,
|
|
@@ -13,12 +13,7 @@ import { generatePeerIdPrivateKeys } from '../test-helpers/generate-peer-id-priv
|
|
|
13
13
|
import { getPorts } from '../test-helpers/get-ports.js';
|
|
14
14
|
import { makeEnr, makeEnrs } from '../test-helpers/make-enrs.js';
|
|
15
15
|
import { BENCHMARK_CONSTANTS } from '../test-helpers/testbench-utils.js';
|
|
16
|
-
import type {
|
|
17
|
-
BenchReqRespCommand,
|
|
18
|
-
BenchResultMessage,
|
|
19
|
-
CollectorType,
|
|
20
|
-
DistributionPattern,
|
|
21
|
-
} from './p2p_client_testbench_worker.js';
|
|
16
|
+
import type { BenchReqRespCommand, BenchResultMessage, DistributionPattern } from './p2p_client_testbench_worker.js';
|
|
22
17
|
|
|
23
18
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
24
19
|
const p2pRoot = path.resolve(__dirname, '../..');
|
|
@@ -29,15 +24,12 @@ const tsconfigPath = path.join(p2pRoot, 'tsconfig.json');
|
|
|
29
24
|
const testChainConfig: ChainConfig = {
|
|
30
25
|
l1ChainId: 31337,
|
|
31
26
|
rollupVersion: 1,
|
|
32
|
-
|
|
33
|
-
rollupAddress: EthAddress.random(),
|
|
34
|
-
},
|
|
27
|
+
rollupAddress: EthAddress.random(),
|
|
35
28
|
};
|
|
36
29
|
|
|
37
30
|
export interface ReqRespBenchmarkConfig {
|
|
38
31
|
txCount: number;
|
|
39
32
|
distribution: DistributionPattern;
|
|
40
|
-
collectorType: CollectorType;
|
|
41
33
|
timeoutMs: number;
|
|
42
34
|
pinnedPeerIndex?: number;
|
|
43
35
|
blockNumber?: number;
|
|
@@ -47,7 +39,6 @@ export interface ReqRespBenchmarkConfig {
|
|
|
47
39
|
export interface ReqRespBenchmarkResult {
|
|
48
40
|
txCount: number;
|
|
49
41
|
distribution: DistributionPattern;
|
|
50
|
-
collector: CollectorType;
|
|
51
42
|
durationMs: number;
|
|
52
43
|
fetchedCount: number;
|
|
53
44
|
success: boolean;
|
|
@@ -424,6 +415,61 @@ class WorkerClientManager {
|
|
|
424
415
|
this.logger.info('All worker processes cleaned up');
|
|
425
416
|
}
|
|
426
417
|
|
|
418
|
+
/**
|
|
419
|
+
* Checks that the aggregator (client 0) has sufficient peer connections before running a benchmark.
|
|
420
|
+
* This prevents benchmark cases from starting with degraded connectivity after a previous case
|
|
421
|
+
* caused connection failures.
|
|
422
|
+
*/
|
|
423
|
+
async waitForConnectivity(minPeers: number, timeoutMs: number = 15_000): Promise<number> {
|
|
424
|
+
const waitInterval = 1000;
|
|
425
|
+
let waited = 0;
|
|
426
|
+
|
|
427
|
+
while (waited < timeoutMs) {
|
|
428
|
+
const count = await this.getPeerCount(0, 5000);
|
|
429
|
+
if (count >= minPeers) {
|
|
430
|
+
this.logger.info(`Connectivity check passed: ${count}/${minPeers} peers connected`);
|
|
431
|
+
return count;
|
|
432
|
+
}
|
|
433
|
+
this.logger.debug(`Waiting for connectivity: ${count}/${minPeers} (waited ${waited}ms)`);
|
|
434
|
+
await sleep(waitInterval);
|
|
435
|
+
waited += waitInterval;
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
const finalCount = await this.getPeerCount(0, 5000);
|
|
439
|
+
this.logger.warn(`Connectivity check: only ${finalCount}/${minPeers} peers after ${timeoutMs}ms`);
|
|
440
|
+
return finalCount;
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
private getPeerCount(clientIndex: number, timeoutMs: number): Promise<number> {
|
|
444
|
+
return new Promise<number>(resolve => {
|
|
445
|
+
let resolved = false;
|
|
446
|
+
|
|
447
|
+
const handler = (msg: any) => {
|
|
448
|
+
if (resolved) {
|
|
449
|
+
return;
|
|
450
|
+
}
|
|
451
|
+
if (msg.type === 'PEER_COUNT') {
|
|
452
|
+
resolved = true;
|
|
453
|
+
clearTimeout(timeout);
|
|
454
|
+
this.processes[clientIndex].off('message', handler);
|
|
455
|
+
resolve(msg.count as number);
|
|
456
|
+
}
|
|
457
|
+
};
|
|
458
|
+
|
|
459
|
+
const timeout = setTimeout(() => {
|
|
460
|
+
if (resolved) {
|
|
461
|
+
return;
|
|
462
|
+
}
|
|
463
|
+
resolved = true;
|
|
464
|
+
this.processes[clientIndex].off('message', handler);
|
|
465
|
+
resolve(0);
|
|
466
|
+
}, timeoutMs);
|
|
467
|
+
|
|
468
|
+
this.processes[clientIndex].on('message', handler);
|
|
469
|
+
this.processes[clientIndex].send({ type: 'GET_PEER_COUNT' });
|
|
470
|
+
});
|
|
471
|
+
}
|
|
472
|
+
|
|
427
473
|
/**
|
|
428
474
|
* Run a req/resp benchmark across all worker clients.
|
|
429
475
|
*
|
|
@@ -444,9 +490,7 @@ class WorkerClientManager {
|
|
|
444
490
|
const blockNumber = config.blockNumber ?? 1;
|
|
445
491
|
const pinnedPeerId = config.pinnedPeerIndex !== undefined ? this.peerIds[config.pinnedPeerIndex] : undefined;
|
|
446
492
|
|
|
447
|
-
this.logger.info(
|
|
448
|
-
`Starting req/resp benchmark: txCount=${config.txCount}, distribution=${config.distribution}, collector=${config.collectorType}`,
|
|
449
|
-
);
|
|
493
|
+
this.logger.info(`Starting req/resp benchmark: txCount=${config.txCount}, distribution=${config.distribution}`);
|
|
450
494
|
|
|
451
495
|
const readyPromises: Promise<void>[] = [];
|
|
452
496
|
|
|
@@ -456,7 +500,6 @@ class WorkerClientManager {
|
|
|
456
500
|
txCount: config.txCount,
|
|
457
501
|
peerCount,
|
|
458
502
|
distribution: config.distribution,
|
|
459
|
-
collectorType: config.collectorType,
|
|
460
503
|
timeoutMs: config.timeoutMs,
|
|
461
504
|
isAggregator: false,
|
|
462
505
|
peerIndex: i,
|
|
@@ -478,7 +521,6 @@ class WorkerClientManager {
|
|
|
478
521
|
txCount: config.txCount,
|
|
479
522
|
peerCount,
|
|
480
523
|
distribution: config.distribution,
|
|
481
|
-
collectorType: config.collectorType,
|
|
482
524
|
timeoutMs: config.timeoutMs,
|
|
483
525
|
isAggregator: true,
|
|
484
526
|
peerIndex: 0,
|
|
@@ -499,7 +541,6 @@ class WorkerClientManager {
|
|
|
499
541
|
return {
|
|
500
542
|
txCount: config.txCount,
|
|
501
543
|
distribution: config.distribution,
|
|
502
|
-
collector: config.collectorType,
|
|
503
544
|
durationMs: result.durationMs,
|
|
504
545
|
fetchedCount: result.fetchedCount,
|
|
505
546
|
success: result.success,
|
|
@@ -577,5 +618,4 @@ class WorkerClientManager {
|
|
|
577
618
|
}
|
|
578
619
|
|
|
579
620
|
export { WorkerClientManager, testChainConfig };
|
|
580
|
-
export type { DistributionPattern
|
|
581
|
-
export { COLLECTOR_DISPLAY_NAMES } from './p2p_client_testbench_worker.js';
|
|
621
|
+
export type { DistributionPattern } from './p2p_client_testbench_worker.js';
|
package/src/util.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SecretValue } from '@aztec/foundation/config';
|
|
2
|
-
import type
|
|
2
|
+
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
3
3
|
import type { AztecAsyncKVStore, AztecAsyncSingleton } from '@aztec/kv-store';
|
|
4
4
|
import type { DataStoreConfig } from '@aztec/stdlib/kv-store';
|
|
5
5
|
|
|
@@ -15,7 +15,7 @@ import type { Libp2p } from 'libp2p';
|
|
|
15
15
|
import net from 'net';
|
|
16
16
|
import path from 'path';
|
|
17
17
|
|
|
18
|
-
import type
|
|
18
|
+
import { DEFAULT_PUBLIC_IP_SERVICES, type P2PConfig } from './config.js';
|
|
19
19
|
|
|
20
20
|
const PEER_ID_DATA_DIR_FILE = 'p2p-private-key';
|
|
21
21
|
|
|
@@ -32,8 +32,7 @@ export interface PubSubLibp2p extends Pick<Libp2p, 'status' | 'start' | 'stop' |
|
|
|
32
32
|
| 'getMeshPeers'
|
|
33
33
|
> & { score: Pick<GossipSub['score'], 'score'> };
|
|
34
34
|
components: {
|
|
35
|
-
|
|
36
|
-
addressManager: AddressManager;
|
|
35
|
+
addressManager: Pick<AddressManager, 'addObservedAddr' | 'confirmObservedAddr' | 'removeObservedAddr'>;
|
|
37
36
|
};
|
|
38
37
|
};
|
|
39
38
|
}
|
|
@@ -65,16 +64,25 @@ export function convertToMultiaddr(address: string, port: number, protocol: 'tcp
|
|
|
65
64
|
}
|
|
66
65
|
|
|
67
66
|
/**
|
|
68
|
-
* Queries the public IP address of the machine.
|
|
67
|
+
* Queries the public IP address of the machine, trying multiple services in order.
|
|
68
|
+
* @param services - HTTPS URLs to try; defaults to {@link DEFAULT_PUBLIC_IP_SERVICES}.
|
|
69
69
|
*/
|
|
70
|
-
export async function getPublicIp(): Promise<string> {
|
|
71
|
-
const
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
70
|
+
export async function getPublicIp(services: string[] = DEFAULT_PUBLIC_IP_SERVICES): Promise<string> {
|
|
71
|
+
const errors: string[] = [];
|
|
72
|
+
for (const url of services) {
|
|
73
|
+
try {
|
|
74
|
+
const resp = await fetch(url, { signal: AbortSignal.timeout(5000) });
|
|
75
|
+
const text = await resp.text();
|
|
76
|
+
const address = text.trim();
|
|
77
|
+
if (isValidIpAddress(address)) {
|
|
78
|
+
return address;
|
|
79
|
+
}
|
|
80
|
+
errors.push(`${url}: invalid IP "${address}"`);
|
|
81
|
+
} catch (err: any) {
|
|
82
|
+
errors.push(`${url}: ${err.message ?? err}`);
|
|
83
|
+
}
|
|
76
84
|
}
|
|
77
|
-
|
|
85
|
+
throw new Error(`Failed to determine public IP from all services:\n${errors.join('\n')}`);
|
|
78
86
|
}
|
|
79
87
|
|
|
80
88
|
export function isValidIpAddress(address: string): boolean {
|
|
@@ -107,15 +115,26 @@ function addressToMultiAddressType(address: string): 'ip4' | 'ip6' | 'dns' {
|
|
|
107
115
|
}
|
|
108
116
|
}
|
|
109
117
|
|
|
110
|
-
export function configureP2PClientAddresses(
|
|
118
|
+
export async function configureP2PClientAddresses(
|
|
119
|
+
_config: P2PConfig & DataStoreConfig,
|
|
120
|
+
): Promise<P2PConfig & DataStoreConfig> {
|
|
111
121
|
const config = { ..._config };
|
|
112
|
-
const { p2pBroadcastPort, p2pPort } = config;
|
|
122
|
+
const { p2pIp, queryForIp, p2pBroadcastPort, p2pPort } = config;
|
|
123
|
+
const logger = createLogger('p2p:config');
|
|
113
124
|
|
|
114
125
|
// If no broadcast port is provided, use the given p2p port as the broadcast port
|
|
115
126
|
if (!p2pBroadcastPort) {
|
|
116
127
|
config.p2pBroadcastPort = p2pPort;
|
|
117
128
|
}
|
|
118
129
|
|
|
130
|
+
// Resolve the initial public IP so the ENR and announce address are set at startup.
|
|
131
|
+
// If queryForIp is enabled, discv5 will also track IP changes at runtime via enrUpdate.
|
|
132
|
+
if (!p2pIp && queryForIp) {
|
|
133
|
+
config.p2pIp = await getPublicIp(config.publicIpServices);
|
|
134
|
+
logger.info('Resolved initial public IP for P2P', { ip: config.p2pIp, queryForIp });
|
|
135
|
+
} else if (p2pIp) {
|
|
136
|
+
logger.info('Using configured static P2P IP', { ip: p2pIp, queryForIp });
|
|
137
|
+
}
|
|
119
138
|
// TODO(md): guard against setting a local ip address as the announce ip
|
|
120
139
|
|
|
121
140
|
return config;
|
package/src/versioning.ts
CHANGED
|
@@ -1,33 +1,21 @@
|
|
|
1
|
-
import { toBufferBE } from '@aztec/foundation/bigint-buffer';
|
|
2
1
|
import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
|
|
3
2
|
import { protocolContractsHash } from '@aztec/protocol-contracts';
|
|
4
3
|
import type { ChainConfig } from '@aztec/stdlib/config';
|
|
5
|
-
import {
|
|
6
|
-
type ComponentsVersions,
|
|
7
|
-
checkCompressedComponentVersion,
|
|
8
|
-
compressComponentVersions,
|
|
9
|
-
getComponentsVersionsFromConfig,
|
|
10
|
-
} from '@aztec/stdlib/versioning';
|
|
4
|
+
import { compressComponentVersions, getComponentsVersionsFromConfig } from '@aztec/stdlib/versioning';
|
|
11
5
|
|
|
12
6
|
import type { SignableENR } from '@nethermindeth/enr';
|
|
13
|
-
import xxhashFactory from 'xxhash-wasm';
|
|
14
7
|
|
|
15
8
|
import { AZTEC_ENR_CLIENT_VERSION_KEY, AZTEC_ENR_KEY } from './types/index.js';
|
|
16
9
|
|
|
17
|
-
const USE_XX_HASH = false; // Enable to reduce the size of the ENR record for production
|
|
18
|
-
const XX_HASH_LEN = 8;
|
|
19
|
-
const xxhash = await xxhashFactory();
|
|
20
|
-
|
|
21
10
|
/** Returns the component versions based on config and this build. */
|
|
22
11
|
export function getVersions(config: ChainConfig) {
|
|
23
12
|
return getComponentsVersionsFromConfig(config, protocolContractsHash, getVKTreeRoot());
|
|
24
13
|
}
|
|
25
14
|
|
|
26
15
|
/** Sets the aztec key on the ENR record with versioning info. */
|
|
27
|
-
export function setAztecEnrKey(enr: SignableENR, config: ChainConfig
|
|
16
|
+
export function setAztecEnrKey(enr: SignableENR, config: ChainConfig) {
|
|
28
17
|
const versions = getVersions(config);
|
|
29
|
-
|
|
30
|
-
enr.set(AZTEC_ENR_KEY, value);
|
|
18
|
+
enr.set(AZTEC_ENR_KEY, Buffer.from(compressComponentVersions(versions)));
|
|
31
19
|
return versions;
|
|
32
20
|
}
|
|
33
21
|
|
|
@@ -37,21 +25,3 @@ export function setAztecClientVersionEnrKey(enr: SignableENR, clientVersion: str
|
|
|
37
25
|
enr.set(AZTEC_ENR_CLIENT_VERSION_KEY, Buffer.from(clientVersion));
|
|
38
26
|
}
|
|
39
27
|
}
|
|
40
|
-
|
|
41
|
-
/** Checks the given value from an ENR record against the expected versions. */
|
|
42
|
-
export function checkAztecEnrVersion(enrValue: Buffer, expectedVersions: ComponentsVersions) {
|
|
43
|
-
if (enrValue.length === XX_HASH_LEN) {
|
|
44
|
-
const expected = versionsToEnrValue(expectedVersions, true);
|
|
45
|
-
if (!Buffer.from(enrValue).equals(expected)) {
|
|
46
|
-
throw new Error(`Expected ENR version ${expected.toString('hex')} but received ${enrValue.toString('hex')}`);
|
|
47
|
-
}
|
|
48
|
-
} else {
|
|
49
|
-
const actual = Buffer.from(enrValue).toString();
|
|
50
|
-
checkCompressedComponentVersion(actual, expectedVersions);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
function versionsToEnrValue(versions: ComponentsVersions, useXxHash: boolean) {
|
|
55
|
-
const compressed = compressComponentVersions(versions);
|
|
56
|
-
return useXxHash ? toBufferBE(xxhash.h64(compressed), XX_HASH_LEN) : Buffer.from(compressed);
|
|
57
|
-
}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
export {};
|
|
2
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHJvcG9zYWxfdHhfY29sbGVjdG9yX3dvcmtlci5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vc3JjL2NsaWVudC90ZXN0L3R4X3Byb3Bvc2FsX2NvbGxlY3Rvci9wcm9wb3NhbF90eF9jb2xsZWN0b3Jfd29ya2VyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiIifQ==
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"proposal_tx_collector_worker.d.ts","sourceRoot":"","sources":["../../../../src/client/test/tx_proposal_collector/proposal_tx_collector_worker.ts"],"names":[],"mappings":""}
|