@aztec/p2p 0.0.0-test.0 → 0.0.1-commit.03f7ef2
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 +22 -9
- package/dest/client/factory.d.ts +15 -5
- package/dest/client/factory.d.ts.map +1 -1
- package/dest/client/factory.js +60 -25
- package/dest/client/index.d.ts +2 -1
- package/dest/client/index.d.ts.map +1 -1
- package/dest/client/index.js +1 -0
- package/dest/client/interface.d.ts +157 -0
- package/dest/client/interface.d.ts.map +1 -0
- package/dest/client/interface.js +9 -0
- package/dest/client/p2p_client.d.ts +75 -190
- package/dest/client/p2p_client.d.ts.map +1 -1
- package/dest/client/p2p_client.js +381 -183
- package/dest/config.d.ts +151 -125
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +183 -34
- package/dest/enr/generate-enr.d.ts +11 -3
- package/dest/enr/generate-enr.d.ts.map +1 -1
- package/dest/enr/generate-enr.js +27 -5
- 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 +4 -1
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +2 -0
- package/dest/mem_pools/attestation_pool/attestation_pool.d.ts +68 -8
- 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 +216 -65
- package/dest/mem_pools/attestation_pool/index.d.ts +1 -1
- package/dest/mem_pools/attestation_pool/kv_attestation_pool.d.ts +21 -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 +127 -26
- package/dest/mem_pools/attestation_pool/memory_attestation_pool.d.ts +19 -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 +111 -21
- package/dest/mem_pools/attestation_pool/mocks.d.ts +227 -7
- package/dest/mem_pools/attestation_pool/mocks.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/mocks.js +10 -16
- package/dest/mem_pools/index.d.ts +1 -1
- package/dest/mem_pools/instrumentation.d.ts +16 -12
- package/dest/mem_pools/instrumentation.d.ts.map +1 -1
- package/dest/mem_pools/instrumentation.js +57 -35
- 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 +64 -14
- 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 +472 -97
- package/dest/mem_pools/tx_pool/index.d.ts +1 -1
- package/dest/mem_pools/tx_pool/memory_tx_pool.d.ts +36 -11
- package/dest/mem_pools/tx_pool/memory_tx_pool.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool/memory_tx_pool.js +137 -36
- package/dest/mem_pools/tx_pool/priority.d.ts +1 -1
- package/dest/mem_pools/tx_pool/priority.js +1 -1
- package/dest/mem_pools/tx_pool/tx_pool.d.ts +67 -10
- 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 +273 -42
- 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 +45 -9
- 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 +6 -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 +73 -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 +10 -0
- package/dest/msg_validators/msg_seen_validator/msg_seen_validator.d.ts.map +1 -0
- package/dest/msg_validators/msg_seen_validator/msg_seen_validator.js +36 -0
- 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 +3 -0
- package/dest/msg_validators/tx_validator/allowed_public_setup.d.ts.map +1 -0
- package/dest/msg_validators/tx_validator/allowed_public_setup.js +27 -0
- package/dest/msg_validators/tx_validator/archive_cache.d.ts +14 -0
- package/dest/msg_validators/tx_validator/archive_cache.d.ts.map +1 -0
- package/dest/msg_validators/tx_validator/archive_cache.js +22 -0
- 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 +4 -4
- package/dest/msg_validators/tx_validator/data_validator.d.ts +1 -1
- package/dest/msg_validators/tx_validator/data_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/data_validator.js +56 -86
- package/dest/msg_validators/tx_validator/double_spend_validator.d.ts +1 -3
- package/dest/msg_validators/tx_validator/double_spend_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/double_spend_validator.js +21 -27
- package/dest/msg_validators/tx_validator/factory.d.ts +16 -0
- package/dest/msg_validators/tx_validator/factory.d.ts.map +1 -0
- package/dest/msg_validators/tx_validator/factory.js +74 -0
- package/dest/msg_validators/tx_validator/gas_validator.d.ts +11 -0
- package/dest/msg_validators/tx_validator/gas_validator.d.ts.map +1 -0
- package/dest/msg_validators/tx_validator/gas_validator.js +115 -0
- package/dest/msg_validators/tx_validator/index.d.ts +8 -1
- package/dest/msg_validators/tx_validator/index.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/index.js +7 -0
- package/dest/msg_validators/tx_validator/metadata_validator.d.ts +9 -5
- package/dest/msg_validators/tx_validator/metadata_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/metadata_validator.js +39 -20
- package/dest/msg_validators/tx_validator/phases_validator.d.ts +14 -0
- package/dest/msg_validators/tx_validator/phases_validator.d.ts.map +1 -0
- package/dest/msg_validators/tx_validator/phases_validator.js +93 -0
- package/dest/msg_validators/tx_validator/test_utils.d.ts +17 -0
- package/dest/msg_validators/tx_validator/test_utils.d.ts.map +1 -0
- package/dest/msg_validators/tx_validator/test_utils.js +22 -0
- 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 +8 -0
- package/dest/msg_validators/tx_validator/tx_permitted_validator.d.ts.map +1 -0
- package/dest/msg_validators/tx_validator/tx_permitted_validator.js +24 -0
- 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/msg_validators/tx_validator/tx_proof_validator.js +6 -5
- 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 +10 -9
- package/dest/services/discv5/discV5_service.d.ts.map +1 -1
- package/dest/services/discv5/discV5_service.js +63 -36
- package/dest/services/dummy_service.d.ts +50 -11
- package/dest/services/dummy_service.d.ts.map +1 -1
- package/dest/services/dummy_service.js +88 -5
- package/dest/services/encoding.d.ts +26 -7
- 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 +5 -1
- package/dest/services/index.d.ts.map +1 -1
- package/dest/services/index.js +4 -0
- package/dest/services/libp2p/instrumentation.d.ts +20 -0
- package/dest/services/libp2p/instrumentation.d.ts.map +1 -0
- package/dest/services/libp2p/instrumentation.js +164 -0
- package/dest/services/libp2p/libp2p_service.d.ts +78 -89
- package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
- package/dest/services/libp2p/libp2p_service.js +695 -248
- package/dest/services/peer-manager/interface.d.ts +23 -0
- package/dest/services/peer-manager/interface.d.ts.map +1 -0
- package/dest/services/peer-manager/interface.js +1 -0
- package/dest/services/peer-manager/metrics.d.ts +6 -2
- package/dest/services/peer-manager/metrics.d.ts.map +1 -1
- package/dest/services/peer-manager/metrics.js +22 -2
- package/dest/services/peer-manager/peer_manager.d.ts +102 -22
- package/dest/services/peer-manager/peer_manager.d.ts.map +1 -1
- package/dest/services/peer-manager/peer_manager.js +549 -72
- 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 +11 -9
- package/dest/services/reqresp/config.d.ts.map +1 -1
- package/dest/services/reqresp/config.js +18 -4
- package/dest/services/reqresp/connection-sampler/batch_connection_sampler.d.ts +2 -2
- package/dest/services/reqresp/connection-sampler/batch_connection_sampler.d.ts.map +1 -1
- package/dest/services/reqresp/connection-sampler/batch_connection_sampler.js +10 -6
- package/dest/services/reqresp/connection-sampler/connection_sampler.d.ts +31 -17
- package/dest/services/reqresp/connection-sampler/connection_sampler.d.ts.map +1 -1
- package/dest/services/reqresp/connection-sampler/connection_sampler.js +142 -84
- package/dest/services/reqresp/index.d.ts +3 -2
- package/dest/services/reqresp/index.d.ts.map +1 -1
- package/dest/services/reqresp/index.js +2 -1
- package/dest/services/reqresp/interface.d.ts +73 -24
- package/dest/services/reqresp/interface.d.ts.map +1 -1
- package/dest/services/reqresp/interface.js +46 -27
- 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 +43 -0
- package/dest/services/reqresp/protocols/auth.d.ts.map +1 -0
- package/dest/services/reqresp/protocols/auth.js +71 -0
- package/dest/services/reqresp/protocols/block.d.ts +6 -1
- package/dest/services/reqresp/protocols/block.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/block.js +30 -6
- package/dest/services/reqresp/protocols/block_txs/bitvector.d.ts +30 -0
- package/dest/services/reqresp/protocols/block_txs/bitvector.d.ts.map +1 -0
- package/dest/services/reqresp/protocols/block_txs/bitvector.js +75 -0
- package/dest/services/reqresp/protocols/block_txs/block_txs_handler.d.ts +11 -0
- package/dest/services/reqresp/protocols/block_txs/block_txs_handler.d.ts.map +1 -0
- package/dest/services/reqresp/protocols/block_txs/block_txs_handler.js +39 -0
- package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.d.ts +47 -0
- package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.d.ts.map +1 -0
- package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.js +75 -0
- package/dest/services/reqresp/protocols/block_txs/index.d.ts +4 -0
- package/dest/services/reqresp/protocols/block_txs/index.d.ts.map +1 -0
- package/dest/services/reqresp/protocols/block_txs/index.js +3 -0
- package/dest/services/reqresp/protocols/goodbye.d.ts +3 -5
- package/dest/services/reqresp/protocols/goodbye.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/goodbye.js +7 -7
- package/dest/services/reqresp/protocols/index.d.ts +3 -1
- package/dest/services/reqresp/protocols/index.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/index.js +2 -0
- package/dest/services/reqresp/protocols/ping.d.ts +1 -3
- package/dest/services/reqresp/protocols/ping.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/status.d.ts +40 -7
- package/dest/services/reqresp/protocols/status.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/status.js +73 -5
- package/dest/services/reqresp/protocols/tx.d.ts +14 -4
- package/dest/services/reqresp/protocols/tx.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/tx.js +34 -6
- package/dest/services/reqresp/rate-limiter/index.d.ts +1 -1
- package/dest/services/reqresp/rate-limiter/rate_limiter.d.ts +6 -4
- package/dest/services/reqresp/rate-limiter/rate_limiter.d.ts.map +1 -1
- package/dest/services/reqresp/rate-limiter/rate_limiter.js +10 -2
- 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 +21 -1
- package/dest/services/reqresp/reqresp.d.ts +24 -66
- package/dest/services/reqresp/reqresp.d.ts.map +1 -1
- package/dest/services/reqresp/reqresp.js +298 -207
- package/dest/services/reqresp/status.d.ts +10 -4
- package/dest/services/reqresp/status.d.ts.map +1 -1
- package/dest/services/reqresp/status.js +9 -2
- package/dest/services/service.d.ts +23 -19
- package/dest/services/service.d.ts.map +1 -1
- package/dest/services/tx_collection/config.d.ts +25 -0
- package/dest/services/tx_collection/config.d.ts.map +1 -0
- package/dest/services/tx_collection/config.js +58 -0
- package/dest/services/tx_collection/fast_tx_collection.d.ts +51 -0
- package/dest/services/tx_collection/fast_tx_collection.d.ts.map +1 -0
- package/dest/services/tx_collection/fast_tx_collection.js +300 -0
- package/dest/services/tx_collection/index.d.ts +3 -0
- package/dest/services/tx_collection/index.d.ts.map +1 -0
- package/dest/services/tx_collection/index.js +2 -0
- package/dest/services/tx_collection/instrumentation.d.ts +10 -0
- package/dest/services/tx_collection/instrumentation.d.ts.map +1 -0
- package/dest/services/tx_collection/instrumentation.js +34 -0
- package/dest/services/tx_collection/slow_tx_collection.d.ts +53 -0
- package/dest/services/tx_collection/slow_tx_collection.d.ts.map +1 -0
- package/dest/services/tx_collection/slow_tx_collection.js +177 -0
- package/dest/services/tx_collection/tx_collection.d.ts +110 -0
- package/dest/services/tx_collection/tx_collection.d.ts.map +1 -0
- package/dest/services/tx_collection/tx_collection.js +128 -0
- package/dest/services/tx_collection/tx_collection_sink.d.ts +30 -0
- package/dest/services/tx_collection/tx_collection_sink.d.ts.map +1 -0
- package/dest/services/tx_collection/tx_collection_sink.js +111 -0
- package/dest/services/tx_collection/tx_source.d.ts +18 -0
- package/dest/services/tx_collection/tx_source.d.ts.map +1 -0
- package/dest/services/tx_collection/tx_source.js +31 -0
- package/dest/services/tx_provider.d.ts +51 -0
- package/dest/services/tx_provider.d.ts.map +1 -0
- package/dest/services/tx_provider.js +217 -0
- package/dest/services/tx_provider_instrumentation.d.ts +16 -0
- package/dest/services/tx_provider_instrumentation.d.ts.map +1 -0
- package/dest/services/tx_provider_instrumentation.js +47 -0
- 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 +2 -1
- package/dest/test-helpers/index.d.ts.map +1 -1
- package/dest/test-helpers/index.js +1 -0
- package/dest/test-helpers/make-enrs.d.ts +1 -1
- package/dest/test-helpers/make-enrs.d.ts.map +1 -1
- package/dest/test-helpers/make-enrs.js +4 -5
- package/dest/test-helpers/make-test-p2p-clients.d.ts +33 -5
- package/dest/test-helpers/make-test-p2p-clients.d.ts.map +1 -1
- package/dest/test-helpers/make-test-p2p-clients.js +86 -16
- package/dest/test-helpers/mock-pubsub.d.ts +59 -0
- package/dest/test-helpers/mock-pubsub.d.ts.map +1 -0
- package/dest/test-helpers/mock-pubsub.js +130 -0
- 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 +15 -11
- package/dest/test-helpers/reqresp-nodes.d.ts.map +1 -1
- package/dest/test-helpers/reqresp-nodes.js +62 -28
- package/dest/testbench/p2p_client_testbench_worker.d.ts +1 -1
- package/dest/testbench/p2p_client_testbench_worker.js +103 -29
- package/dest/testbench/parse_log_file.d.ts +1 -1
- package/dest/testbench/parse_log_file.js +4 -4
- package/dest/testbench/testbench.d.ts +1 -1
- package/dest/testbench/testbench.js +4 -4
- package/dest/testbench/worker_client_manager.d.ts +1 -6
- package/dest/testbench/worker_client_manager.d.ts.map +1 -1
- package/dest/testbench/worker_client_manager.js +11 -19
- package/dest/types/index.d.ts +4 -2
- package/dest/types/index.d.ts.map +1 -1
- package/dest/types/index.js +2 -0
- package/dest/util.d.ts +24 -16
- package/dest/util.d.ts.map +1 -1
- package/dest/util.js +75 -69
- package/dest/versioning.d.ts +4 -4
- package/dest/versioning.d.ts.map +1 -1
- package/dest/versioning.js +8 -3
- package/package.json +32 -27
- package/src/bootstrap/bootstrap.ts +27 -11
- package/src/client/factory.ts +139 -53
- package/src/client/index.ts +1 -0
- package/src/client/interface.ts +198 -0
- package/src/client/p2p_client.ts +484 -348
- package/src/config.ts +305 -134
- package/src/enr/generate-enr.ts +39 -6
- package/src/errors/attestation-pool.error.ts +13 -0
- package/src/index.ts +4 -0
- package/src/mem_pools/attestation_pool/attestation_pool.ts +75 -7
- package/src/mem_pools/attestation_pool/attestation_pool_test_suite.ts +266 -67
- package/src/mem_pools/attestation_pool/kv_attestation_pool.ts +174 -35
- package/src/mem_pools/attestation_pool/memory_attestation_pool.ts +156 -30
- package/src/mem_pools/attestation_pool/mocks.ts +13 -12
- package/src/mem_pools/instrumentation.ts +70 -40
- package/src/mem_pools/interface.ts +2 -4
- package/src/mem_pools/tx_pool/aztec_kv_tx_pool.ts +555 -110
- package/src/mem_pools/tx_pool/memory_tx_pool.ts +160 -46
- package/src/mem_pools/tx_pool/priority.ts +1 -1
- package/src/mem_pools/tx_pool/tx_pool.ts +69 -9
- package/src/mem_pools/tx_pool/tx_pool_test_suite.ts +224 -35
- package/src/msg_validators/attestation_validator/attestation_validator.ts +54 -11
- 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 +82 -14
- package/src/msg_validators/msg_seen_validator/msg_seen_validator.ts +36 -0
- package/src/msg_validators/tx_validator/allowed_public_setup.ts +35 -0
- package/src/msg_validators/tx_validator/archive_cache.ts +28 -0
- package/src/msg_validators/tx_validator/block_header_validator.ts +5 -5
- package/src/msg_validators/tx_validator/data_validator.ts +81 -69
- package/src/msg_validators/tx_validator/double_spend_validator.ts +19 -17
- package/src/msg_validators/tx_validator/factory.ts +110 -0
- package/src/msg_validators/tx_validator/gas_validator.ts +134 -0
- package/src/msg_validators/tx_validator/index.ts +7 -0
- package/src/msg_validators/tx_validator/metadata_validator.ts +59 -22
- package/src/msg_validators/tx_validator/phases_validator.ts +116 -0
- package/src/msg_validators/tx_validator/test_utils.ts +43 -0
- package/src/msg_validators/tx_validator/timestamp_validator.ts +47 -0
- package/src/msg_validators/tx_validator/tx_permitted_validator.ts +17 -0
- package/src/msg_validators/tx_validator/tx_proof_validator.ts +6 -5
- package/src/services/discv5/discV5_service.ts +84 -38
- package/src/services/dummy_service.ts +147 -9
- package/src/services/encoding.ts +81 -6
- package/src/services/index.ts +4 -0
- package/src/services/libp2p/instrumentation.ts +167 -0
- package/src/services/libp2p/libp2p_service.ts +865 -298
- package/src/services/peer-manager/interface.ts +29 -0
- package/src/services/peer-manager/metrics.ts +26 -1
- package/src/services/peer-manager/peer_manager.ts +654 -78
- package/src/services/peer-manager/peer_scoring.ts +46 -3
- package/src/services/reqresp/config.ts +26 -9
- package/src/services/reqresp/connection-sampler/batch_connection_sampler.ts +12 -6
- package/src/services/reqresp/connection-sampler/connection_sampler.ts +148 -95
- package/src/services/reqresp/index.ts +2 -0
- package/src/services/reqresp/interface.ts +92 -37
- package/src/services/reqresp/metrics.ts +4 -1
- package/src/services/reqresp/protocols/auth.ts +83 -0
- package/src/services/reqresp/protocols/block.ts +26 -4
- package/src/services/reqresp/protocols/block_txs/bitvector.ts +90 -0
- package/src/services/reqresp/protocols/block_txs/block_txs_handler.ts +53 -0
- package/src/services/reqresp/protocols/block_txs/block_txs_reqresp.ts +79 -0
- package/src/services/reqresp/protocols/block_txs/index.ts +3 -0
- package/src/services/reqresp/protocols/goodbye.ts +9 -7
- package/src/services/reqresp/protocols/index.ts +2 -0
- package/src/services/reqresp/protocols/status.ts +118 -5
- package/src/services/reqresp/protocols/tx.ts +36 -8
- package/src/services/reqresp/rate-limiter/rate_limiter.ts +12 -3
- package/src/services/reqresp/rate-limiter/rate_limits.ts +21 -1
- package/src/services/reqresp/reqresp.ts +387 -256
- package/src/services/reqresp/status.ts +12 -3
- package/src/services/service.ts +45 -21
- package/src/services/tx_collection/config.ts +84 -0
- package/src/services/tx_collection/fast_tx_collection.ts +341 -0
- package/src/services/tx_collection/index.ts +2 -0
- package/src/services/tx_collection/instrumentation.ts +43 -0
- package/src/services/tx_collection/slow_tx_collection.ts +233 -0
- package/src/services/tx_collection/tx_collection.ts +216 -0
- package/src/services/tx_collection/tx_collection_sink.ts +129 -0
- package/src/services/tx_collection/tx_source.ts +37 -0
- package/src/services/tx_provider.ts +229 -0
- package/src/services/tx_provider_instrumentation.ts +61 -0
- package/src/test-helpers/index.ts +1 -0
- package/src/test-helpers/make-enrs.ts +4 -5
- package/src/test-helpers/make-test-p2p-clients.ts +111 -21
- package/src/test-helpers/mock-pubsub.ts +188 -0
- package/src/test-helpers/mock-tx-helpers.ts +24 -0
- package/src/test-helpers/reqresp-nodes.ts +87 -36
- package/src/testbench/p2p_client_testbench_worker.ts +151 -25
- package/src/testbench/parse_log_file.ts +4 -4
- package/src/testbench/testbench.ts +4 -4
- package/src/testbench/worker_client_manager.ts +17 -23
- package/src/types/index.ts +2 -0
- package/src/util.ts +105 -91
- package/src/versioning.ts +11 -4
package/src/util.ts
CHANGED
|
@@ -1,25 +1,41 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { SecretValue } from '@aztec/foundation/config';
|
|
2
|
+
import type { Logger } from '@aztec/foundation/log';
|
|
3
|
+
import type { AztecAsyncKVStore, AztecAsyncSingleton } from '@aztec/kv-store';
|
|
2
4
|
import type { DataStoreConfig } from '@aztec/kv-store/config';
|
|
3
5
|
|
|
4
6
|
import type { GossipSub } from '@chainsafe/libp2p-gossipsub';
|
|
5
7
|
import { generateKeyPair, marshalPrivateKey, unmarshalPrivateKey } from '@libp2p/crypto/keys';
|
|
8
|
+
import type { Identify } from '@libp2p/identify';
|
|
6
9
|
import type { PeerId, PrivateKey } from '@libp2p/interface';
|
|
7
10
|
import type { ConnectionManager } from '@libp2p/interface-internal';
|
|
8
11
|
import { createFromPrivKey } from '@libp2p/peer-id-factory';
|
|
9
12
|
import { resolve } from 'dns/promises';
|
|
13
|
+
import { promises as fs } from 'fs';
|
|
10
14
|
import type { Libp2p } from 'libp2p';
|
|
15
|
+
import net from 'net';
|
|
16
|
+
import path from 'path';
|
|
11
17
|
|
|
12
18
|
import type { P2PConfig } from './config.js';
|
|
13
19
|
|
|
14
|
-
|
|
20
|
+
const PEER_ID_DATA_DIR_FILE = 'p2p-private-key';
|
|
21
|
+
|
|
22
|
+
export interface PubSubLibp2p extends Pick<Libp2p, 'status' | 'start' | 'stop' | 'peerId'> {
|
|
15
23
|
services: {
|
|
16
|
-
pubsub:
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
};
|
|
24
|
+
pubsub: Pick<
|
|
25
|
+
GossipSub,
|
|
26
|
+
'addEventListener' | 'removeEventListener' | 'publish' | 'subscribe' | 'reportMessageValidationResult' | 'direct'
|
|
27
|
+
> & { score: Pick<GossipSub['score'], 'score'> };
|
|
20
28
|
};
|
|
21
29
|
}
|
|
22
30
|
|
|
31
|
+
export type FullLibp2p = Libp2p<{
|
|
32
|
+
identify: Identify;
|
|
33
|
+
pubsub: GossipSub;
|
|
34
|
+
components: {
|
|
35
|
+
connectionManager: ConnectionManager;
|
|
36
|
+
};
|
|
37
|
+
}>;
|
|
38
|
+
|
|
23
39
|
/**
|
|
24
40
|
* Converts an address string to a multiaddr string.
|
|
25
41
|
* Example usage:
|
|
@@ -28,59 +44,39 @@ export interface PubSubLibp2p extends Libp2p {
|
|
|
28
44
|
* @param address - The address string to convert. Has to be in the format <addr>:<port>.
|
|
29
45
|
* @param protocol - The protocol to use in the multiaddr string.
|
|
30
46
|
* @returns A multiaddr compliant string. */
|
|
31
|
-
export function convertToMultiaddr(address: string, protocol: 'tcp' | 'udp'): string {
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
const multiaddrPrefix = addressToMultiAddressType(addr);
|
|
47
|
+
export function convertToMultiaddr(address: string, port: number, protocol: 'tcp' | 'udp'): string {
|
|
48
|
+
const multiaddrPrefix = addressToMultiAddressType(address);
|
|
35
49
|
if (multiaddrPrefix === 'dns') {
|
|
36
50
|
throw new Error('Invalid address format. Expected an IPv4 or IPv6 address.');
|
|
37
51
|
}
|
|
38
52
|
|
|
39
|
-
return `/${multiaddrPrefix}/${
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Splits an <address>:<port> string into its components.
|
|
44
|
-
* @returns The ip6 or ip4 address & port separately
|
|
45
|
-
*/
|
|
46
|
-
export function splitAddressPort(address: string, allowEmptyAddress: boolean): [string, string] {
|
|
47
|
-
let addr: string;
|
|
48
|
-
let port: string;
|
|
49
|
-
|
|
50
|
-
if (address.startsWith('[')) {
|
|
51
|
-
// IPv6 address enclosed in square brackets
|
|
52
|
-
const match = address.match(/^\[([^\]]+)\]:(\d+)$/);
|
|
53
|
-
if (!match) {
|
|
54
|
-
throw new Error(`Invalid IPv6 address format:${address}. Expected format: [<addr>]:<port>`);
|
|
55
|
-
}
|
|
56
|
-
[, addr, port] = match;
|
|
57
|
-
} else {
|
|
58
|
-
// IPv4 address
|
|
59
|
-
[addr, port] = address.split(':');
|
|
60
|
-
if ((!addr && !allowEmptyAddress) || !port) {
|
|
61
|
-
throw new Error(`Invalid address format: ${address}. Expected format: <addr>:<port>`);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
return [addr, port];
|
|
53
|
+
return `/${multiaddrPrefix}/${address}/${protocol}/${port}`;
|
|
66
54
|
}
|
|
67
55
|
|
|
68
56
|
/**
|
|
69
57
|
* Queries the public IP address of the machine.
|
|
70
58
|
*/
|
|
71
59
|
export async function getPublicIp(): Promise<string> {
|
|
72
|
-
const resp = await fetch('
|
|
60
|
+
const resp = await fetch('https://checkip.amazonaws.com/');
|
|
73
61
|
const text = await resp.text();
|
|
74
|
-
|
|
62
|
+
const address = text.trim();
|
|
63
|
+
if (!isValidIpAddress(address)) {
|
|
64
|
+
throw new Error(`Received invalid IP address from checkip service: ${address}`);
|
|
65
|
+
}
|
|
66
|
+
return address;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export function isValidIpAddress(address: string): boolean {
|
|
70
|
+
const netType = net.isIP(address);
|
|
71
|
+
return netType === 4;
|
|
75
72
|
}
|
|
76
73
|
|
|
77
|
-
export async function resolveAddressIfNecessary(address: string): Promise<string> {
|
|
78
|
-
const
|
|
79
|
-
const multiaddrPrefix = addressToMultiAddressType(addr);
|
|
74
|
+
export async function resolveAddressIfNecessary(address: string, port: string): Promise<string> {
|
|
75
|
+
const multiaddrPrefix = addressToMultiAddressType(address);
|
|
80
76
|
if (multiaddrPrefix === 'dns') {
|
|
81
|
-
const resolvedAddresses = await resolve(
|
|
77
|
+
const resolvedAddresses = await resolve(address);
|
|
82
78
|
if (resolvedAddresses.length === 0) {
|
|
83
|
-
throw new Error(`Could not resolve address: ${
|
|
79
|
+
throw new Error(`Could not resolve address: ${address}`);
|
|
84
80
|
}
|
|
85
81
|
return `${resolvedAddresses[0]}:${port}`;
|
|
86
82
|
} else {
|
|
@@ -104,47 +100,21 @@ export async function configureP2PClientAddresses(
|
|
|
104
100
|
_config: P2PConfig & DataStoreConfig,
|
|
105
101
|
): Promise<P2PConfig & DataStoreConfig> {
|
|
106
102
|
const config = { ..._config };
|
|
107
|
-
const {
|
|
108
|
-
tcpAnnounceAddress: configTcpAnnounceAddress,
|
|
109
|
-
udpAnnounceAddress: configUdpAnnounceAddress,
|
|
110
|
-
queryForIp,
|
|
111
|
-
} = config;
|
|
112
|
-
|
|
113
|
-
config.tcpAnnounceAddress = configTcpAnnounceAddress
|
|
114
|
-
? await resolveAddressIfNecessary(configTcpAnnounceAddress)
|
|
115
|
-
: undefined;
|
|
116
|
-
config.udpAnnounceAddress = configUdpAnnounceAddress
|
|
117
|
-
? await resolveAddressIfNecessary(configUdpAnnounceAddress)
|
|
118
|
-
: undefined;
|
|
119
|
-
|
|
120
|
-
// create variable for re-use if needed
|
|
121
|
-
let publicIp;
|
|
103
|
+
const { p2pIp, queryForIp, p2pBroadcastPort, p2pPort } = config;
|
|
122
104
|
|
|
123
|
-
//
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
if (queryForIp) {
|
|
127
|
-
publicIp = await getPublicIp();
|
|
128
|
-
const tcpAnnounceAddress = `${publicIp}:${splitTcpAnnounceAddress[1]}`;
|
|
129
|
-
config.tcpAnnounceAddress = tcpAnnounceAddress;
|
|
130
|
-
} else {
|
|
131
|
-
throw new Error(
|
|
132
|
-
`Invalid announceTcpAddress provided: ${configTcpAnnounceAddress}. Expected format: <addr>:<port>`,
|
|
133
|
-
);
|
|
134
|
-
}
|
|
105
|
+
// If no broadcast port is provided, use the given p2p port as the broadcast port
|
|
106
|
+
if (!p2pBroadcastPort) {
|
|
107
|
+
config.p2pBroadcastPort = p2pPort;
|
|
135
108
|
}
|
|
136
109
|
|
|
137
|
-
|
|
138
|
-
if (
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
config.
|
|
142
|
-
} else if (queryForIp) {
|
|
143
|
-
const udpPublicIp = publicIp || (await getPublicIp());
|
|
144
|
-
const udpAnnounceAddress = `${udpPublicIp}:${splitUdpAnnounceAddress[1]}`;
|
|
145
|
-
config.udpAnnounceAddress = udpAnnounceAddress;
|
|
110
|
+
// check if no announce IP was provided
|
|
111
|
+
if (!p2pIp) {
|
|
112
|
+
if (queryForIp) {
|
|
113
|
+
const publicIp = await getPublicIp();
|
|
114
|
+
config.p2pIp = publicIp;
|
|
146
115
|
}
|
|
147
116
|
}
|
|
117
|
+
// TODO(md): guard against setting a local ip address as the announce ip
|
|
148
118
|
|
|
149
119
|
return config;
|
|
150
120
|
}
|
|
@@ -153,30 +123,74 @@ export async function configureP2PClientAddresses(
|
|
|
153
123
|
* Get the peer id private key
|
|
154
124
|
*
|
|
155
125
|
* 1. Check if we have a peer id private key in the config
|
|
156
|
-
* 2. If not, check we have a peer id private key persisted in
|
|
157
|
-
* 3. If
|
|
126
|
+
* 2. If not, check if we have a peer id private key persisted in a file
|
|
127
|
+
* 3. If no file path or data directory is provided, check if we have a peer id private key in the node's store
|
|
128
|
+
* 4. If not, create a new one, then persist it in a file if a file path or data directory is provided or in the node's store otherwise
|
|
158
129
|
*
|
|
159
130
|
*/
|
|
160
131
|
export async function getPeerIdPrivateKey(
|
|
161
|
-
config: { peerIdPrivateKey?: string },
|
|
132
|
+
config: { peerIdPrivateKey?: SecretValue<string>; peerIdPrivateKeyPath?: string; dataDirectory?: string },
|
|
162
133
|
store: AztecAsyncKVStore,
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
134
|
+
logger: Logger,
|
|
135
|
+
): Promise<SecretValue<string>> {
|
|
136
|
+
const peerIdPrivateKeyFilePath =
|
|
137
|
+
config.peerIdPrivateKeyPath ??
|
|
138
|
+
(config.dataDirectory ? path.join(config.dataDirectory, PEER_ID_DATA_DIR_FILE) : undefined);
|
|
139
|
+
let peerIdPrivateKeySingleton: AztecAsyncSingleton<string> | undefined;
|
|
140
|
+
|
|
141
|
+
const writePrivateKeyToFile = async (filePath: string, privateKey: string) => {
|
|
142
|
+
await fs.mkdir(path.dirname(filePath), { recursive: true });
|
|
143
|
+
await fs.writeFile(filePath, privateKey);
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
// If the peerIdPrivateKey is provided in the config, we use it and persist it in either a file or the node's store
|
|
147
|
+
if (config.peerIdPrivateKey && config.peerIdPrivateKey.getValue().trim()) {
|
|
148
|
+
if (peerIdPrivateKeyFilePath) {
|
|
149
|
+
await writePrivateKeyToFile(peerIdPrivateKeyFilePath, config.peerIdPrivateKey.getValue());
|
|
150
|
+
} else {
|
|
151
|
+
peerIdPrivateKeySingleton = store.openSingleton<string>('peerIdPrivateKey');
|
|
152
|
+
await peerIdPrivateKeySingleton.set(config.peerIdPrivateKey.getValue());
|
|
153
|
+
}
|
|
167
154
|
return config.peerIdPrivateKey;
|
|
168
155
|
}
|
|
169
156
|
|
|
170
|
-
|
|
157
|
+
// Check to see if we have a peer id private key stored in a file or the node's store
|
|
158
|
+
let storedPeerIdPrivateKey: string | undefined;
|
|
159
|
+
const privateKeyFileExists =
|
|
160
|
+
peerIdPrivateKeyFilePath &&
|
|
161
|
+
(await fs
|
|
162
|
+
.access(peerIdPrivateKeyFilePath)
|
|
163
|
+
.then(() => true)
|
|
164
|
+
.catch(() => false));
|
|
165
|
+
if (peerIdPrivateKeyFilePath && privateKeyFileExists) {
|
|
166
|
+
await fs.access(peerIdPrivateKeyFilePath);
|
|
167
|
+
storedPeerIdPrivateKey = await fs.readFile(peerIdPrivateKeyFilePath, 'utf8');
|
|
168
|
+
} else {
|
|
169
|
+
peerIdPrivateKeySingleton = store.openSingleton<string>('peerIdPrivateKey');
|
|
170
|
+
storedPeerIdPrivateKey = await peerIdPrivateKeySingleton.getAsync();
|
|
171
|
+
}
|
|
171
172
|
if (storedPeerIdPrivateKey) {
|
|
172
|
-
|
|
173
|
+
if (peerIdPrivateKeyFilePath && !privateKeyFileExists) {
|
|
174
|
+
logger.verbose(`Peer ID private key found in the node's store, persisting it to ${peerIdPrivateKeyFilePath}`);
|
|
175
|
+
await writePrivateKeyToFile(peerIdPrivateKeyFilePath, storedPeerIdPrivateKey);
|
|
176
|
+
}
|
|
177
|
+
return new SecretValue(storedPeerIdPrivateKey);
|
|
173
178
|
}
|
|
174
179
|
|
|
180
|
+
// Generate and persist a new private key
|
|
175
181
|
const newPeerIdPrivateKey = await generateKeyPair('secp256k1');
|
|
176
182
|
const privateKeyString = Buffer.from(marshalPrivateKey(newPeerIdPrivateKey)).toString('hex');
|
|
183
|
+
if (peerIdPrivateKeyFilePath) {
|
|
184
|
+
logger.verbose(`Creating new peer ID private key and persisting it to ${peerIdPrivateKeyFilePath}`);
|
|
185
|
+
await writePrivateKeyToFile(peerIdPrivateKeyFilePath, privateKeyString);
|
|
186
|
+
} else {
|
|
187
|
+
logger.warn(
|
|
188
|
+
'Creating new peer ID private key and persisting it to the lmdb store. Key will be lost on rollup upgrade, specify the peer id private key path and restart the node to persist the peer id private key to a file',
|
|
189
|
+
);
|
|
190
|
+
await peerIdPrivateKeySingleton!.set(privateKeyString);
|
|
191
|
+
}
|
|
177
192
|
|
|
178
|
-
|
|
179
|
-
return privateKeyString;
|
|
193
|
+
return new SecretValue(privateKeyString);
|
|
180
194
|
}
|
|
181
195
|
|
|
182
196
|
/**
|
package/src/versioning.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { toBufferBE } from '@aztec/foundation/bigint-buffer';
|
|
2
2
|
import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
|
|
3
|
-
import {
|
|
3
|
+
import { protocolContractsHash } from '@aztec/protocol-contracts';
|
|
4
4
|
import type { ChainConfig } from '@aztec/stdlib/config';
|
|
5
5
|
import {
|
|
6
6
|
type ComponentsVersions,
|
|
@@ -9,10 +9,10 @@ import {
|
|
|
9
9
|
getComponentsVersionsFromConfig,
|
|
10
10
|
} from '@aztec/stdlib/versioning';
|
|
11
11
|
|
|
12
|
-
import type { SignableENR } from '@
|
|
12
|
+
import type { SignableENR } from '@nethermindeth/enr';
|
|
13
13
|
import xxhashFactory from 'xxhash-wasm';
|
|
14
14
|
|
|
15
|
-
import { AZTEC_ENR_KEY } from './types/index.js';
|
|
15
|
+
import { AZTEC_ENR_CLIENT_VERSION_KEY, AZTEC_ENR_KEY } from './types/index.js';
|
|
16
16
|
|
|
17
17
|
const USE_XX_HASH = false; // Enable to reduce the size of the ENR record for production
|
|
18
18
|
const XX_HASH_LEN = 8;
|
|
@@ -20,7 +20,7 @@ const xxhash = await xxhashFactory();
|
|
|
20
20
|
|
|
21
21
|
/** Returns the component versions based on config and this build. */
|
|
22
22
|
export function getVersions(config: ChainConfig) {
|
|
23
|
-
return getComponentsVersionsFromConfig(config,
|
|
23
|
+
return getComponentsVersionsFromConfig(config, protocolContractsHash, getVKTreeRoot());
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
/** Sets the aztec key on the ENR record with versioning info. */
|
|
@@ -31,6 +31,13 @@ export function setAztecEnrKey(enr: SignableENR, config: ChainConfig, useXxHash
|
|
|
31
31
|
return versions;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
+
/** Sets the Aztec client version on ENR record **/
|
|
35
|
+
export function setAztecClientVersionEnrKey(enr: SignableENR, clientVersion: string) {
|
|
36
|
+
if (clientVersion) {
|
|
37
|
+
enr.set(AZTEC_ENR_CLIENT_VERSION_KEY, Buffer.from(clientVersion));
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
34
41
|
/** Checks the given value from an ENR record against the expected versions. */
|
|
35
42
|
export function checkAztecEnrVersion(enrValue: Buffer, expectedVersions: ComponentsVersions) {
|
|
36
43
|
if (enrValue.length === XX_HASH_LEN) {
|