@aztec/p2p 0.0.0-test.0 → 0.0.1-commit.023c3e5
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 +4 -3
- package/dest/bootstrap/bootstrap.d.ts.map +1 -1
- package/dest/bootstrap/bootstrap.js +26 -13
- package/dest/client/factory.d.ts +15 -5
- package/dest/client/factory.d.ts.map +1 -1
- package/dest/client/factory.js +61 -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 +170 -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 -193
- package/dest/client/p2p_client.d.ts.map +1 -1
- package/dest/client/p2p_client.js +765 -229
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.d.ts +2 -0
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.d.ts.map +1 -0
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.js +305 -0
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker_protocol.d.ts +73 -0
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker_protocol.d.ts.map +1 -0
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker_protocol.js +8 -0
- package/dest/config.d.ts +154 -125
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +182 -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 +104 -25
- 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 +299 -174
- package/dest/mem_pools/attestation_pool/index.d.ts +1 -1
- package/dest/mem_pools/attestation_pool/kv_attestation_pool.d.ts +29 -11
- package/dest/mem_pools/attestation_pool/kv_attestation_pool.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/kv_attestation_pool.js +168 -62
- package/dest/mem_pools/attestation_pool/memory_attestation_pool.d.ts +24 -10
- package/dest/mem_pools/attestation_pool/memory_attestation_pool.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/memory_attestation_pool.js +133 -82
- package/dest/mem_pools/attestation_pool/mocks.d.ts +234 -11
- package/dest/mem_pools/attestation_pool/mocks.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/mocks.js +19 -21
- 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 +56 -41
- 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 +75 -16
- 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 +493 -142
- package/dest/mem_pools/tx_pool/eviction/eviction_manager.d.ts +32 -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 +112 -0
- package/dest/mem_pools/tx_pool/eviction/eviction_strategy.d.ts +157 -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 +52 -0
- package/dest/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.d.ts +16 -0
- package/dest/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.js +122 -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 +78 -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/eviction/nullifier_conflict_pre_add_rule.d.ts +25 -0
- package/dest/mem_pools/tx_pool/eviction/nullifier_conflict_pre_add_rule.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool/eviction/nullifier_conflict_pre_add_rule.js +57 -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 +7 -2
- package/dest/mem_pools/tx_pool/tx_pool.d.ts +72 -11
- 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 +276 -45
- package/dest/msg_validators/attestation_validator/attestation_validator.d.ts +7 -5
- package/dest/msg_validators/attestation_validator/attestation_validator.d.ts.map +1 -1
- package/dest/msg_validators/attestation_validator/attestation_validator.js +79 -10
- 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 +76 -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/clock_tolerance.d.ts +21 -0
- package/dest/msg_validators/clock_tolerance.d.ts.map +1 -0
- package/dest/msg_validators/clock_tolerance.js +37 -0
- package/dest/msg_validators/index.d.ts +2 -2
- package/dest/msg_validators/index.d.ts.map +1 -1
- package/dest/msg_validators/index.js +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/proposal_validator/block_proposal_validator.d.ts +9 -0
- package/dest/msg_validators/proposal_validator/block_proposal_validator.d.ts.map +1 -0
- package/dest/msg_validators/proposal_validator/block_proposal_validator.js +6 -0
- package/dest/msg_validators/proposal_validator/checkpoint_proposal_validator.d.ts +9 -0
- package/dest/msg_validators/proposal_validator/checkpoint_proposal_validator.d.ts.map +1 -0
- package/dest/msg_validators/proposal_validator/checkpoint_proposal_validator.js +6 -0
- package/dest/msg_validators/proposal_validator/index.d.ts +4 -0
- package/dest/msg_validators/proposal_validator/index.d.ts.map +1 -0
- package/dest/msg_validators/proposal_validator/index.js +3 -0
- package/dest/msg_validators/proposal_validator/proposal_validator.d.ts +13 -0
- package/dest/msg_validators/proposal_validator/proposal_validator.d.ts.map +1 -0
- package/dest/msg_validators/proposal_validator/proposal_validator.js +104 -0
- package/dest/msg_validators/proposal_validator/proposal_validator_test_suite.d.ts +23 -0
- package/dest/msg_validators/proposal_validator/proposal_validator_test_suite.d.ts.map +1 -0
- package/dest/msg_validators/proposal_validator/proposal_validator_test_suite.js +212 -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 +5 -4
- package/dest/msg_validators/tx_validator/block_header_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/block_header_validator.js +7 -6
- package/dest/msg_validators/tx_validator/data_validator.d.ts +3 -1
- package/dest/msg_validators/tx_validator/data_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/data_validator.js +60 -87
- package/dest/msg_validators/tx_validator/double_spend_validator.d.ts +3 -4
- package/dest/msg_validators/tx_validator/double_spend_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/double_spend_validator.js +24 -29
- package/dest/msg_validators/tx_validator/factory.d.ts +21 -0
- package/dest/msg_validators/tx_validator/factory.d.ts.map +1 -0
- package/dest/msg_validators/tx_validator/factory.js +84 -0
- package/dest/msg_validators/tx_validator/fee_payer_balance.d.ts +10 -0
- package/dest/msg_validators/tx_validator/fee_payer_balance.d.ts.map +1 -0
- package/dest/msg_validators/tx_validator/fee_payer_balance.js +20 -0
- package/dest/msg_validators/tx_validator/gas_validator.d.ts +12 -0
- package/dest/msg_validators/tx_validator/gas_validator.d.ts.map +1 -0
- package/dest/msg_validators/tx_validator/gas_validator.js +110 -0
- package/dest/msg_validators/tx_validator/index.d.ts +9 -1
- package/dest/msg_validators/tx_validator/index.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/index.js +8 -0
- package/dest/msg_validators/tx_validator/metadata_validator.d.ts +10 -5
- package/dest/msg_validators/tx_validator/metadata_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/metadata_validator.js +40 -21
- package/dest/msg_validators/tx_validator/phases_validator.d.ts +15 -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/size_validator.d.ts +8 -0
- package/dest/msg_validators/tx_validator/size_validator.d.ts.map +1 -0
- package/dest/msg_validators/tx_validator/size_validator.js +23 -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 +14 -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 +9 -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 +3 -2
- package/dest/msg_validators/tx_validator/tx_proof_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/tx_proof_validator.js +8 -7
- 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 +10 -6
- 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 +64 -37
- package/dest/services/dummy_service.d.ts +66 -11
- package/dest/services/dummy_service.d.ts.map +1 -1
- package/dest/services/dummy_service.js +130 -5
- package/dest/services/encoding.d.ts +26 -7
- package/dest/services/encoding.d.ts.map +1 -1
- package/dest/services/encoding.js +75 -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 +122 -0
- package/dest/services/libp2p/libp2p_service.d.ts +107 -95
- package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
- package/dest/services/libp2p/libp2p_service.js +1328 -313
- 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 +12 -3
- package/dest/services/peer-manager/metrics.d.ts.map +1 -1
- package/dest/services/peer-manager/metrics.js +44 -12
- package/dest/services/peer-manager/peer_manager.d.ts +103 -23
- package/dest/services/peer-manager/peer_manager.d.ts.map +1 -1
- package/dest/services/peer-manager/peer_manager.js +551 -82
- 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 +43 -2
- package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts +47 -0
- package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts.map +1 -0
- package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.js +566 -0
- package/dest/services/reqresp/batch-tx-requester/config.d.ts +17 -0
- package/dest/services/reqresp/batch-tx-requester/config.d.ts.map +1 -0
- package/dest/services/reqresp/batch-tx-requester/config.js +27 -0
- package/dest/services/reqresp/batch-tx-requester/interface.d.ts +50 -0
- package/dest/services/reqresp/batch-tx-requester/interface.d.ts.map +1 -0
- package/dest/services/reqresp/batch-tx-requester/interface.js +1 -0
- package/dest/services/reqresp/batch-tx-requester/missing_txs.d.ts +37 -0
- package/dest/services/reqresp/batch-tx-requester/missing_txs.d.ts.map +1 -0
- package/dest/services/reqresp/batch-tx-requester/missing_txs.js +151 -0
- package/dest/services/reqresp/batch-tx-requester/peer_collection.d.ts +54 -0
- package/dest/services/reqresp/batch-tx-requester/peer_collection.d.ts.map +1 -0
- package/dest/services/reqresp/batch-tx-requester/peer_collection.js +139 -0
- package/dest/services/reqresp/batch-tx-requester/tx_validator.d.ts +20 -0
- package/dest/services/reqresp/batch-tx-requester/tx_validator.d.ts.map +1 -0
- package/dest/services/reqresp/batch-tx-requester/tx_validator.js +21 -0
- 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 +23 -4
- package/dest/services/reqresp/connection-sampler/batch_connection_sampler.d.ts.map +1 -1
- package/dest/services/reqresp/connection-sampler/batch_connection_sampler.js +73 -10
- package/dest/services/reqresp/connection-sampler/connection_sampler.d.ts +32 -17
- package/dest/services/reqresp/connection-sampler/connection_sampler.d.ts.map +1 -1
- package/dest/services/reqresp/connection-sampler/connection_sampler.js +154 -84
- package/dest/services/reqresp/constants.d.ts +12 -0
- package/dest/services/reqresp/constants.d.ts.map +1 -0
- package/dest/services/reqresp/constants.js +7 -0
- 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 +75 -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 +6 -5
- package/dest/services/reqresp/metrics.d.ts.map +1 -1
- package/dest/services/reqresp/metrics.js +17 -21
- 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 +34 -0
- package/dest/services/reqresp/protocols/block_txs/bitvector.d.ts.map +1 -0
- package/dest/services/reqresp/protocols/block_txs/bitvector.js +87 -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 +52 -0
- package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.d.ts +59 -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 +105 -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 +76 -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 +29 -66
- package/dest/services/reqresp/reqresp.d.ts.map +1 -1
- package/dest/services/reqresp/reqresp.js +753 -248
- 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 +40 -20
- package/dest/services/service.d.ts.map +1 -1
- package/dest/services/tx_collection/config.d.ts +28 -0
- package/dest/services/tx_collection/config.d.ts.map +1 -0
- package/dest/services/tx_collection/config.js +66 -0
- package/dest/services/tx_collection/fast_tx_collection.d.ts +53 -0
- package/dest/services/tx_collection/fast_tx_collection.d.ts.map +1 -0
- package/dest/services/tx_collection/fast_tx_collection.js +311 -0
- package/dest/services/tx_collection/index.d.ts +4 -0
- package/dest/services/tx_collection/index.d.ts.map +1 -0
- package/dest/services/tx_collection/index.js +3 -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 +31 -0
- package/dest/services/tx_collection/proposal_tx_collector.d.ts +48 -0
- package/dest/services/tx_collection/proposal_tx_collector.d.ts.map +1 -0
- package/dest/services/tx_collection/proposal_tx_collector.js +50 -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 +219 -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 +34 -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 +4 -1
- package/dest/test-helpers/index.d.ts.map +1 -1
- package/dest/test-helpers/index.js +3 -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/test-helpers/test_tx_provider.d.ts +40 -0
- package/dest/test-helpers/test_tx_provider.d.ts.map +1 -0
- package/dest/test-helpers/test_tx_provider.js +41 -0
- package/dest/test-helpers/testbench-utils.d.ts +158 -0
- package/dest/test-helpers/testbench-utils.d.ts.map +1 -0
- package/dest/test-helpers/testbench-utils.js +297 -0
- package/dest/testbench/p2p_client_testbench_worker.d.ts +28 -2
- package/dest/testbench/p2p_client_testbench_worker.d.ts.map +1 -1
- package/dest/testbench/p2p_client_testbench_worker.js +259 -90
- 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 +51 -11
- package/dest/testbench/worker_client_manager.d.ts.map +1 -1
- package/dest/testbench/worker_client_manager.js +232 -53
- 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 +34 -15
- package/src/client/factory.ts +135 -53
- package/src/client/index.ts +1 -0
- package/src/client/interface.ts +213 -0
- package/src/client/p2p_client.ts +476 -383
- package/src/client/test/tx_proposal_collector/README.md +227 -0
- package/src/client/test/tx_proposal_collector/proposal_tx_collector_worker.ts +336 -0
- package/src/client/test/tx_proposal_collector/proposal_tx_collector_worker_protocol.ts +43 -0
- package/src/config.ts +304 -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 +119 -24
- package/src/mem_pools/attestation_pool/attestation_pool_test_suite.ts +352 -201
- package/src/mem_pools/attestation_pool/kv_attestation_pool.ts +233 -72
- package/src/mem_pools/attestation_pool/memory_attestation_pool.ts +199 -96
- package/src/mem_pools/attestation_pool/mocks.ts +24 -17
- package/src/mem_pools/instrumentation.ts +72 -48
- package/src/mem_pools/interface.ts +2 -4
- package/src/mem_pools/tx_pool/README.md +270 -0
- package/src/mem_pools/tx_pool/aztec_kv_tx_pool.ts +580 -143
- package/src/mem_pools/tx_pool/eviction/eviction_manager.ts +132 -0
- package/src/mem_pools/tx_pool/eviction/eviction_strategy.ts +208 -0
- package/src/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.ts +162 -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 +93 -0
- package/src/mem_pools/tx_pool/eviction/low_priority_eviction_rule.ts +106 -0
- package/src/mem_pools/tx_pool/eviction/nullifier_conflict_pre_add_rule.ts +75 -0
- package/src/mem_pools/tx_pool/index.ts +0 -1
- package/src/mem_pools/tx_pool/priority.ts +9 -2
- package/src/mem_pools/tx_pool/tx_pool.ts +75 -10
- package/src/mem_pools/tx_pool/tx_pool_test_suite.ts +225 -36
- package/src/msg_validators/attestation_validator/attestation_validator.ts +72 -14
- package/src/msg_validators/attestation_validator/fisherman_attestation_validator.ts +94 -0
- package/src/msg_validators/attestation_validator/index.ts +1 -0
- package/src/msg_validators/clock_tolerance.ts +51 -0
- package/src/msg_validators/index.ts +1 -1
- package/src/msg_validators/msg_seen_validator/msg_seen_validator.ts +36 -0
- package/src/msg_validators/proposal_validator/block_proposal_validator.ts +10 -0
- package/src/msg_validators/proposal_validator/checkpoint_proposal_validator.ts +13 -0
- package/src/msg_validators/proposal_validator/index.ts +3 -0
- package/src/msg_validators/proposal_validator/proposal_validator.ts +92 -0
- package/src/msg_validators/proposal_validator/proposal_validator_test_suite.ts +230 -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 +10 -9
- package/src/msg_validators/tx_validator/data_validator.ts +95 -71
- package/src/msg_validators/tx_validator/double_spend_validator.ts +23 -20
- package/src/msg_validators/tx_validator/factory.ts +151 -0
- package/src/msg_validators/tx_validator/fee_payer_balance.ts +40 -0
- package/src/msg_validators/tx_validator/gas_validator.ts +123 -0
- package/src/msg_validators/tx_validator/index.ts +8 -0
- package/src/msg_validators/tx_validator/metadata_validator.ts +72 -24
- package/src/msg_validators/tx_validator/phases_validator.ts +118 -0
- package/src/msg_validators/tx_validator/size_validator.ts +22 -0
- package/src/msg_validators/tx_validator/test_utils.ts +43 -0
- package/src/msg_validators/tx_validator/timestamp_validator.ts +52 -0
- package/src/msg_validators/tx_validator/tx_permitted_validator.ts +22 -0
- package/src/msg_validators/tx_validator/tx_proof_validator.ts +14 -8
- package/src/services/data_store.ts +10 -7
- package/src/services/discv5/discV5_service.ts +85 -39
- package/src/services/dummy_service.ts +198 -9
- package/src/services/encoding.ts +82 -6
- package/src/services/index.ts +4 -0
- package/src/services/libp2p/instrumentation.ts +126 -0
- package/src/services/libp2p/libp2p_service.ts +1170 -353
- package/src/services/peer-manager/interface.ts +29 -0
- package/src/services/peer-manager/metrics.ts +55 -12
- package/src/services/peer-manager/peer_manager.ts +657 -80
- package/src/services/peer-manager/peer_scoring.ts +45 -3
- package/src/services/reqresp/batch-tx-requester/README.md +305 -0
- package/src/services/reqresp/batch-tx-requester/batch_tx_requester.ts +706 -0
- package/src/services/reqresp/batch-tx-requester/config.ts +40 -0
- package/src/services/reqresp/batch-tx-requester/interface.ts +57 -0
- package/src/services/reqresp/batch-tx-requester/missing_txs.ts +209 -0
- package/src/services/reqresp/batch-tx-requester/peer_collection.ts +205 -0
- package/src/services/reqresp/batch-tx-requester/tx_validator.ts +37 -0
- package/src/services/reqresp/config.ts +26 -9
- package/src/services/reqresp/connection-sampler/batch_connection_sampler.ts +77 -10
- package/src/services/reqresp/connection-sampler/connection_sampler.ts +166 -95
- package/src/services/reqresp/constants.ts +14 -0
- package/src/services/reqresp/index.ts +2 -0
- package/src/services/reqresp/interface.ts +95 -37
- package/src/services/reqresp/metrics.ts +40 -28
- 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 +106 -0
- package/src/services/reqresp/protocols/block_txs/block_txs_handler.ts +67 -0
- package/src/services/reqresp/protocols/block_txs/block_txs_reqresp.ts +121 -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 +121 -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 +449 -271
- package/src/services/reqresp/status.ts +12 -3
- package/src/services/service.ts +65 -22
- package/src/services/tx_collection/config.ts +98 -0
- package/src/services/tx_collection/fast_tx_collection.ts +364 -0
- package/src/services/tx_collection/index.ts +7 -0
- package/src/services/tx_collection/instrumentation.ts +35 -0
- package/src/services/tx_collection/proposal_tx_collector.ts +114 -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 +232 -0
- package/src/services/tx_provider_instrumentation.ts +54 -0
- package/src/test-helpers/index.ts +3 -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/test-helpers/test_tx_provider.ts +64 -0
- package/src/test-helpers/testbench-utils.ts +374 -0
- package/src/testbench/p2p_client_testbench_worker.ts +434 -89
- package/src/testbench/parse_log_file.ts +4 -4
- package/src/testbench/testbench.ts +4 -4
- package/src/testbench/worker_client_manager.ts +315 -59
- package/src/types/index.ts +2 -0
- package/src/util.ts +105 -91
- package/src/versioning.ts +11 -4
- package/dest/mem_pools/tx_pool/memory_tx_pool.d.ts +0 -56
- 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 -141
- package/dest/msg_validators/block_proposal_validator/block_proposal_validator.d.ts +0 -8
- package/dest/msg_validators/block_proposal_validator/block_proposal_validator.d.ts.map +0 -1
- package/dest/msg_validators/block_proposal_validator/block_proposal_validator.js +0 -21
- package/dest/msg_validators/block_proposal_validator/index.d.ts +0 -2
- package/dest/msg_validators/block_proposal_validator/index.d.ts.map +0 -1
- package/dest/msg_validators/block_proposal_validator/index.js +0 -1
- package/src/mem_pools/tx_pool/memory_tx_pool.ts +0 -174
- package/src/msg_validators/block_proposal_validator/block_proposal_validator.ts +0 -29
- package/src/msg_validators/block_proposal_validator/index.ts +0 -1
|
@@ -1,19 +1,26 @@
|
|
|
1
|
-
import { Fr } from '@aztec/foundation/
|
|
1
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
2
|
import { L2Block } from '@aztec/stdlib/block';
|
|
3
|
-
import {
|
|
3
|
+
import { TxArray, TxHashArray } from '@aztec/stdlib/tx';
|
|
4
4
|
|
|
5
5
|
import type { PeerId } from '@libp2p/interface';
|
|
6
6
|
|
|
7
|
+
import type { P2PReqRespConfig } from './config.js';
|
|
8
|
+
import type { ConnectionSampler } from './connection-sampler/connection_sampler.js';
|
|
9
|
+
import { AuthRequest, AuthResponse } from './protocols/auth.js';
|
|
10
|
+
import { BlockTxsRequest, BlockTxsResponse } from './protocols/block_txs/block_txs_reqresp.js';
|
|
11
|
+
import { StatusMessage } from './protocols/status.js';
|
|
7
12
|
import type { ReqRespStatus } from './status.js';
|
|
8
13
|
|
|
9
14
|
/*
|
|
10
15
|
* Request Response Sub Protocols
|
|
11
16
|
*/
|
|
12
|
-
export const PING_PROTOCOL = '/aztec/req/ping/
|
|
13
|
-
export const STATUS_PROTOCOL = '/aztec/req/status/
|
|
14
|
-
export const GOODBYE_PROTOCOL = '/aztec/req/goodbye/
|
|
15
|
-
export const TX_REQ_PROTOCOL = '/aztec/req/tx/
|
|
16
|
-
export const BLOCK_REQ_PROTOCOL = '/aztec/req/block/
|
|
17
|
+
export const PING_PROTOCOL = '/aztec/req/ping/1.0.0';
|
|
18
|
+
export const STATUS_PROTOCOL = '/aztec/req/status/1.0.0';
|
|
19
|
+
export const GOODBYE_PROTOCOL = '/aztec/req/goodbye/1.0.0';
|
|
20
|
+
export const TX_REQ_PROTOCOL = '/aztec/req/tx/1.0.0';
|
|
21
|
+
export const BLOCK_REQ_PROTOCOL = '/aztec/req/block/1.0.0';
|
|
22
|
+
export const AUTH_PROTOCOL = '/aztec/req/auth/1.0.0';
|
|
23
|
+
export const BLOCK_TXS_REQ_PROTOCOL = '/aztec/req/block_txs/1.0.0';
|
|
17
24
|
|
|
18
25
|
export enum ReqRespSubProtocol {
|
|
19
26
|
PING = PING_PROTOCOL,
|
|
@@ -21,6 +28,8 @@ export enum ReqRespSubProtocol {
|
|
|
21
28
|
GOODBYE = GOODBYE_PROTOCOL,
|
|
22
29
|
TX = TX_REQ_PROTOCOL,
|
|
23
30
|
BLOCK = BLOCK_REQ_PROTOCOL,
|
|
31
|
+
AUTH = AUTH_PROTOCOL,
|
|
32
|
+
BLOCK_TXS = BLOCK_TXS_REQ_PROTOCOL,
|
|
24
33
|
}
|
|
25
34
|
|
|
26
35
|
/**
|
|
@@ -36,12 +45,12 @@ export type ReqRespSubProtocolRateLimits = Record<ReqRespSubProtocol, ProtocolRa
|
|
|
36
45
|
|
|
37
46
|
/**
|
|
38
47
|
* The response from the ReqResp protocol
|
|
39
|
-
* Consists of a status
|
|
48
|
+
* Consists of a status
|
|
49
|
+
* And, optionally, a data buffer (in case status is SUCCESS)
|
|
40
50
|
*/
|
|
41
|
-
export
|
|
42
|
-
status: ReqRespStatus;
|
|
43
|
-
|
|
44
|
-
}
|
|
51
|
+
export type ReqRespResponse =
|
|
52
|
+
| { status: ReqRespStatus.SUCCESS; data: Buffer }
|
|
53
|
+
| { status: Exclude<ReqRespStatus, ReqRespStatus.SUCCESS> };
|
|
45
54
|
|
|
46
55
|
/**
|
|
47
56
|
* A rate limit quota
|
|
@@ -91,33 +100,27 @@ export const DEFAULT_SUB_PROTOCOL_VALIDATORS: ReqRespSubProtocolValidators = {
|
|
|
91
100
|
[ReqRespSubProtocol.TX]: noopValidator,
|
|
92
101
|
[ReqRespSubProtocol.GOODBYE]: noopValidator,
|
|
93
102
|
[ReqRespSubProtocol.BLOCK]: noopValidator,
|
|
103
|
+
[ReqRespSubProtocol.AUTH]: noopValidator,
|
|
104
|
+
[ReqRespSubProtocol.BLOCK_TXS]: noopValidator,
|
|
94
105
|
};
|
|
95
106
|
|
|
107
|
+
/*
|
|
108
|
+
* Helper class to sub-protocol validation error*/
|
|
109
|
+
export class ValidationError extends Error {
|
|
110
|
+
constructor(message: string) {
|
|
111
|
+
super(message);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
96
115
|
/**
|
|
97
116
|
* Sub protocol map determines the request and response types for each
|
|
98
117
|
* Req Resp protocol
|
|
99
118
|
*/
|
|
100
119
|
export type SubProtocolMap = {
|
|
101
|
-
[S in ReqRespSubProtocol]: RequestResponsePair<
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
* Default handler for unimplemented sub protocols, this SHOULD be overwritten
|
|
106
|
-
* by the service, but is provided as a fallback
|
|
107
|
-
*/
|
|
108
|
-
const defaultHandler = (_msg: any): Promise<Buffer> => {
|
|
109
|
-
return Promise.resolve(Buffer.from('unimplemented'));
|
|
110
|
-
};
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* Default sub protocol handlers - this SHOULD be overwritten by the service,
|
|
114
|
-
*/
|
|
115
|
-
export const DEFAULT_SUB_PROTOCOL_HANDLERS: ReqRespSubProtocolHandlers = {
|
|
116
|
-
[ReqRespSubProtocol.PING]: defaultHandler,
|
|
117
|
-
[ReqRespSubProtocol.STATUS]: defaultHandler,
|
|
118
|
-
[ReqRespSubProtocol.TX]: defaultHandler,
|
|
119
|
-
[ReqRespSubProtocol.GOODBYE]: defaultHandler,
|
|
120
|
-
[ReqRespSubProtocol.BLOCK]: defaultHandler,
|
|
120
|
+
[S in ReqRespSubProtocol]: RequestResponsePair<
|
|
121
|
+
InstanceType<(typeof subProtocolMap)[S]['request']>,
|
|
122
|
+
InstanceType<(typeof subProtocolMap)[S]['response']>
|
|
123
|
+
>;
|
|
121
124
|
};
|
|
122
125
|
|
|
123
126
|
/**
|
|
@@ -138,6 +141,22 @@ interface RequestResponsePair<Req extends { toBuffer(): Buffer }, Res> {
|
|
|
138
141
|
};
|
|
139
142
|
}
|
|
140
143
|
|
|
144
|
+
/*
|
|
145
|
+
* Small helper function which parses buffer into specific response type
|
|
146
|
+
* It is needed to make TypeScript happy, as it cannot infer the type from the buffer
|
|
147
|
+
*
|
|
148
|
+
* @param proto - The sub protocol to parse the response for
|
|
149
|
+
* @param buffer - The buffer to parse
|
|
150
|
+
*
|
|
151
|
+
* @returns - The parsed response object
|
|
152
|
+
* */
|
|
153
|
+
export function responseFromBuffer<P extends ReqRespSubProtocol>(
|
|
154
|
+
proto: P,
|
|
155
|
+
buffer: Buffer,
|
|
156
|
+
): InstanceType<(typeof subProtocolMap)[P]['response']> {
|
|
157
|
+
return subProtocolMap[proto].response.fromBuffer(buffer) as InstanceType<(typeof subProtocolMap)[P]['response']>;
|
|
158
|
+
}
|
|
159
|
+
|
|
141
160
|
/**
|
|
142
161
|
* RequestableBuffer is a wrapper around a buffer that allows it to be
|
|
143
162
|
* used in generic request response protocols
|
|
@@ -161,18 +180,18 @@ export class RequestableBuffer {
|
|
|
161
180
|
* This defines the request and response types for each sub protocol, used primarily
|
|
162
181
|
* as a type rather than an object
|
|
163
182
|
*/
|
|
164
|
-
export const subProtocolMap
|
|
183
|
+
export const subProtocolMap = {
|
|
165
184
|
[ReqRespSubProtocol.PING]: {
|
|
166
185
|
request: RequestableBuffer,
|
|
167
186
|
response: RequestableBuffer,
|
|
168
187
|
},
|
|
169
188
|
[ReqRespSubProtocol.STATUS]: {
|
|
170
|
-
request:
|
|
171
|
-
response:
|
|
189
|
+
request: StatusMessage,
|
|
190
|
+
response: StatusMessage,
|
|
172
191
|
},
|
|
173
192
|
[ReqRespSubProtocol.TX]: {
|
|
174
|
-
request:
|
|
175
|
-
response:
|
|
193
|
+
request: TxHashArray,
|
|
194
|
+
response: TxArray,
|
|
176
195
|
},
|
|
177
196
|
[ReqRespSubProtocol.GOODBYE]: {
|
|
178
197
|
request: RequestableBuffer,
|
|
@@ -182,4 +201,43 @@ export const subProtocolMap: SubProtocolMap = {
|
|
|
182
201
|
request: Fr, // block number
|
|
183
202
|
response: L2Block,
|
|
184
203
|
},
|
|
204
|
+
[ReqRespSubProtocol.AUTH]: {
|
|
205
|
+
request: AuthRequest,
|
|
206
|
+
response: AuthResponse,
|
|
207
|
+
},
|
|
208
|
+
[ReqRespSubProtocol.BLOCK_TXS]: {
|
|
209
|
+
request: BlockTxsRequest,
|
|
210
|
+
response: BlockTxsResponse,
|
|
211
|
+
},
|
|
185
212
|
};
|
|
213
|
+
|
|
214
|
+
export interface ReqRespInterface {
|
|
215
|
+
start(
|
|
216
|
+
subProtocolHandlers: Partial<ReqRespSubProtocolHandlers>,
|
|
217
|
+
subProtocolValidators: ReqRespSubProtocolValidators,
|
|
218
|
+
): Promise<void>;
|
|
219
|
+
addSubProtocol(
|
|
220
|
+
subProtocol: ReqRespSubProtocol,
|
|
221
|
+
handler: ReqRespSubProtocolHandler,
|
|
222
|
+
validator?: ReqRespSubProtocolValidators[ReqRespSubProtocol],
|
|
223
|
+
): Promise<void>;
|
|
224
|
+
stop(): Promise<void>;
|
|
225
|
+
sendBatchRequest<SubProtocol extends ReqRespSubProtocol>(
|
|
226
|
+
subProtocol: SubProtocol,
|
|
227
|
+
requests: InstanceType<SubProtocolMap[SubProtocol]['request']>[],
|
|
228
|
+
pinnedPeer: PeerId | undefined,
|
|
229
|
+
timeoutMs?: number,
|
|
230
|
+
maxPeers?: number,
|
|
231
|
+
maxRetryAttempts?: number,
|
|
232
|
+
): Promise<InstanceType<SubProtocolMap[SubProtocol]['response']>[]>;
|
|
233
|
+
sendRequestToPeer(
|
|
234
|
+
peerId: PeerId,
|
|
235
|
+
subProtocol: ReqRespSubProtocol,
|
|
236
|
+
payload: Buffer,
|
|
237
|
+
dialTimeout?: number,
|
|
238
|
+
): Promise<ReqRespResponse>;
|
|
239
|
+
|
|
240
|
+
updateConfig(config: Partial<P2PReqRespConfig>): void;
|
|
241
|
+
|
|
242
|
+
getConnectionSampler(): Pick<ConnectionSampler, 'getPeerListSortedByConnectionCountAsc'>;
|
|
243
|
+
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
// Request response metrics
|
|
2
|
-
import { Attributes, Metrics,
|
|
2
|
+
import { Attributes, Metrics, createUpDownCounterWithDefault } from '@aztec/telemetry-client';
|
|
3
3
|
import type { TelemetryClient, Tracer, UpDownCounter } from '@aztec/telemetry-client';
|
|
4
4
|
|
|
5
|
+
import { ReqRespSubProtocol } from './interface.js';
|
|
6
|
+
|
|
5
7
|
export class ReqRespMetrics {
|
|
6
8
|
public readonly tracer: Tracer;
|
|
7
9
|
|
|
@@ -11,47 +13,57 @@ export class ReqRespMetrics {
|
|
|
11
13
|
private readonly failedOutboundRequests: UpDownCounter;
|
|
12
14
|
private readonly failedInboundRequests: UpDownCounter;
|
|
13
15
|
|
|
14
|
-
constructor(
|
|
16
|
+
constructor(
|
|
17
|
+
readonly telemetryClient: TelemetryClient,
|
|
18
|
+
name = 'ReqResp',
|
|
19
|
+
) {
|
|
15
20
|
this.tracer = telemetryClient.getTracer(name);
|
|
16
21
|
|
|
17
22
|
const meter = telemetryClient.getMeter(name);
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
this.
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
23
|
+
const protocolAttrs = {
|
|
24
|
+
[Attributes.P2P_REQ_RESP_PROTOCOL]: [
|
|
25
|
+
ReqRespSubProtocol.PING,
|
|
26
|
+
ReqRespSubProtocol.STATUS,
|
|
27
|
+
ReqRespSubProtocol.GOODBYE,
|
|
28
|
+
ReqRespSubProtocol.TX,
|
|
29
|
+
ReqRespSubProtocol.BLOCK,
|
|
30
|
+
ReqRespSubProtocol.AUTH,
|
|
31
|
+
ReqRespSubProtocol.BLOCK_TXS,
|
|
32
|
+
],
|
|
33
|
+
};
|
|
34
|
+
this.sentRequests = createUpDownCounterWithDefault(meter, Metrics.P2P_REQ_RESP_SENT_REQUESTS, protocolAttrs);
|
|
35
|
+
this.receivedRequests = createUpDownCounterWithDefault(
|
|
36
|
+
meter,
|
|
37
|
+
Metrics.P2P_REQ_RESP_RECEIVED_REQUESTS,
|
|
38
|
+
protocolAttrs,
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
this.failedOutboundRequests = createUpDownCounterWithDefault(
|
|
42
|
+
meter,
|
|
43
|
+
Metrics.P2P_REQ_RESP_FAILED_OUTBOUND_REQUESTS,
|
|
44
|
+
protocolAttrs,
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
this.failedInboundRequests = createUpDownCounterWithDefault(
|
|
48
|
+
meter,
|
|
49
|
+
Metrics.P2P_REQ_RESP_FAILED_INBOUND_REQUESTS,
|
|
50
|
+
protocolAttrs,
|
|
51
|
+
);
|
|
40
52
|
}
|
|
41
53
|
|
|
42
|
-
public recordRequestSent(protocol:
|
|
54
|
+
public recordRequestSent(protocol: ReqRespSubProtocol) {
|
|
43
55
|
this.sentRequests.add(1, { [Attributes.P2P_REQ_RESP_PROTOCOL]: protocol });
|
|
44
56
|
}
|
|
45
57
|
|
|
46
|
-
public recordRequestReceived(protocol:
|
|
58
|
+
public recordRequestReceived(protocol: ReqRespSubProtocol) {
|
|
47
59
|
this.receivedRequests.add(1, { [Attributes.P2P_REQ_RESP_PROTOCOL]: protocol });
|
|
48
60
|
}
|
|
49
61
|
|
|
50
|
-
public recordRequestError(protocol:
|
|
62
|
+
public recordRequestError(protocol: ReqRespSubProtocol) {
|
|
51
63
|
this.failedOutboundRequests.add(1, { [Attributes.P2P_REQ_RESP_PROTOCOL]: protocol });
|
|
52
64
|
}
|
|
53
65
|
|
|
54
|
-
public recordResponseError(protocol:
|
|
66
|
+
public recordResponseError(protocol: ReqRespSubProtocol) {
|
|
55
67
|
this.failedInboundRequests.add(1, { [Attributes.P2P_REQ_RESP_PROTOCOL]: protocol });
|
|
56
68
|
}
|
|
57
69
|
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { Buffer32 } from '@aztec/foundation/buffer';
|
|
2
|
+
import { keccak256 } from '@aztec/foundation/crypto/keccak';
|
|
3
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
4
|
+
import { Signature } from '@aztec/foundation/eth-signature';
|
|
5
|
+
import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
|
|
6
|
+
|
|
7
|
+
import { StatusMessage } from './status.js';
|
|
8
|
+
|
|
9
|
+
export const VALIDATOR_AUTH_DOMAIN_SEPARATOR = 'Aztec Validator Challenge:';
|
|
10
|
+
export const VALIDATOR_AUTH_FULL_CHALLENGE_ENCODED_LENGTH =
|
|
11
|
+
VALIDATOR_AUTH_DOMAIN_SEPARATOR.length + Fr.random().toString().length;
|
|
12
|
+
|
|
13
|
+
/*
|
|
14
|
+
* P2P Auth Message
|
|
15
|
+
* Superset of the StatusMessage, used to establish a handshake between peers and authenticate them.
|
|
16
|
+
*/
|
|
17
|
+
export class AuthRequest {
|
|
18
|
+
constructor(
|
|
19
|
+
readonly status: StatusMessage,
|
|
20
|
+
readonly challenge: Fr,
|
|
21
|
+
) {}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Deserializes the AuthRequest object from a Buffer.
|
|
25
|
+
* @param buffer - Buffer or BufferReader object to deserialize.
|
|
26
|
+
* @returns An instance of StatusMessage.
|
|
27
|
+
*/
|
|
28
|
+
static fromBuffer(buffer: Buffer | BufferReader): AuthRequest {
|
|
29
|
+
const reader = BufferReader.asReader(buffer);
|
|
30
|
+
return new AuthRequest(
|
|
31
|
+
StatusMessage.fromBuffer(reader), // Deserialize StatusMessage
|
|
32
|
+
Fr.fromBuffer(reader), // challenge
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Serializes the AuthRequest object into a Buffer.
|
|
38
|
+
* @returns Buffer representation of the StatusMessage object.
|
|
39
|
+
*/
|
|
40
|
+
toBuffer() {
|
|
41
|
+
return serializeToBuffer([this.status, this.challenge]);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
getPayloadToSign(): Buffer32 {
|
|
45
|
+
const fullChallenge = VALIDATOR_AUTH_DOMAIN_SEPARATOR + this.challenge.toString();
|
|
46
|
+
return Buffer32.fromBuffer(keccak256(Buffer.from(fullChallenge, 'utf-8')));
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
static random(): AuthRequest {
|
|
50
|
+
return new AuthRequest(StatusMessage.random(), Fr.random());
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export class AuthResponse {
|
|
55
|
+
constructor(
|
|
56
|
+
readonly status: StatusMessage,
|
|
57
|
+
readonly signature: Signature,
|
|
58
|
+
) {}
|
|
59
|
+
/**
|
|
60
|
+
* Deserializes the AuthResponse object from a Buffer.
|
|
61
|
+
* @param buffer - Buffer or BufferReader object to deserialize.
|
|
62
|
+
* @returns An instance of StatusMessage.
|
|
63
|
+
*/
|
|
64
|
+
static fromBuffer(buffer: Buffer | BufferReader): AuthResponse {
|
|
65
|
+
const reader = BufferReader.asReader(buffer);
|
|
66
|
+
return new AuthResponse(
|
|
67
|
+
StatusMessage.fromBuffer(reader), // Deserialize StatusMessage
|
|
68
|
+
Signature.fromBuffer(reader), // response
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Serializes the AuthRequest object into a Buffer.
|
|
74
|
+
* @returns Buffer representation of the StatusMessage object.
|
|
75
|
+
*/
|
|
76
|
+
toBuffer() {
|
|
77
|
+
return serializeToBuffer([this.status, this.signature]);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
static random(): AuthResponse {
|
|
81
|
+
return new AuthResponse(StatusMessage.random(), Signature.random());
|
|
82
|
+
}
|
|
83
|
+
}
|
|
@@ -1,15 +1,37 @@
|
|
|
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';
|
|
5
6
|
|
|
6
7
|
import type { ReqRespSubProtocolHandler } from '../interface.js';
|
|
8
|
+
import { ReqRespStatus, ReqRespStatusError } from '../status.js';
|
|
7
9
|
|
|
10
|
+
/**
|
|
11
|
+
* Handler for L2 Block requests
|
|
12
|
+
* @param l2BlockSource - source for L2 blocks
|
|
13
|
+
* @returns the Block request handler
|
|
14
|
+
* */
|
|
8
15
|
export function reqRespBlockHandler(l2BlockSource: L2BlockSource): ReqRespSubProtocolHandler {
|
|
16
|
+
/**
|
|
17
|
+
* @param peerId - the peer ID of the requester
|
|
18
|
+
* @param msg - the block request message, which is expected to contain valid block number as a Buffer
|
|
19
|
+
* @returns a Buffer containing the requested block data, or an empty Buffer if the block is not found
|
|
20
|
+
* @throws ReqRespStatusError if the input msg is not a valid block number
|
|
21
|
+
* */
|
|
9
22
|
return async (_peerId: PeerId, msg: Buffer) => {
|
|
10
|
-
|
|
23
|
+
let blockNumber: Fr;
|
|
24
|
+
try {
|
|
25
|
+
blockNumber = Fr.fromBuffer(msg);
|
|
26
|
+
} catch (err: any) {
|
|
27
|
+
throw new ReqRespStatusError(ReqRespStatus.BADLY_FORMED_REQUEST, { cause: err });
|
|
28
|
+
}
|
|
11
29
|
|
|
12
|
-
|
|
13
|
-
|
|
30
|
+
try {
|
|
31
|
+
const foundBlock = await l2BlockSource.getBlock(BlockNumber(Number(blockNumber)));
|
|
32
|
+
return foundBlock ? foundBlock.toBuffer() : Buffer.alloc(0);
|
|
33
|
+
} catch (err: any) {
|
|
34
|
+
throw new ReqRespStatusError(ReqRespStatus.INTERNAL_ERROR, { cause: err });
|
|
35
|
+
}
|
|
14
36
|
};
|
|
15
37
|
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
|
|
2
|
+
|
|
3
|
+
import { MAX_TXS_PER_BLOCK } from '../../constants.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* BitVector helper class for representing and serializing bit vectors
|
|
7
|
+
*/
|
|
8
|
+
export class BitVector {
|
|
9
|
+
private buffer: Buffer;
|
|
10
|
+
private length: number;
|
|
11
|
+
|
|
12
|
+
constructor(buffer: Buffer, length: number) {
|
|
13
|
+
this.buffer = buffer;
|
|
14
|
+
this.length = length;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/*
|
|
18
|
+
* Creates new BitVector instance
|
|
19
|
+
* @param length - Length of the bit vector
|
|
20
|
+
* @param indices - Array of indices to set to 1 in the bit vector
|
|
21
|
+
*
|
|
22
|
+
* @returns A new BitVector instance with specified length and set indices
|
|
23
|
+
* */
|
|
24
|
+
static init(length: number, indices: number[]): BitVector {
|
|
25
|
+
if (indices.length > length) {
|
|
26
|
+
throw new Error('Indices length exceeds specified length');
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const buffer = Buffer.alloc(BitVector.byteLength(length));
|
|
30
|
+
|
|
31
|
+
indices.forEach(idx => {
|
|
32
|
+
const invalidIndex = idx < 0 || idx >= length;
|
|
33
|
+
if (invalidIndex) {
|
|
34
|
+
throw new Error(`Index ${idx} is out of bounds for BitVector of length ${length}`);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const byteIndex = Math.floor(idx / 8);
|
|
38
|
+
const bitIndex = idx % 8;
|
|
39
|
+
buffer[byteIndex] |= 1 << bitIndex;
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
return new BitVector(buffer, length);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
getLength(): number {
|
|
46
|
+
return this.length;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/*
|
|
50
|
+
* Checks if element at index is set to true
|
|
51
|
+
*
|
|
52
|
+
* @param index - Index of the bit to check
|
|
53
|
+
*
|
|
54
|
+
* @returns True if the bit at index is set, false otherwise
|
|
55
|
+
* */
|
|
56
|
+
isSet(index: number): boolean {
|
|
57
|
+
return index >= 0 && index < this.length && !!(this.buffer[Math.floor(index / 8)] & (1 << index % 8));
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Returns all indices which are set to true
|
|
62
|
+
* */
|
|
63
|
+
getTrueIndices(): number[] {
|
|
64
|
+
return Array.from({ length: this.length }, (_, i) => i).filter(i => this.isSet(i));
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Returns true if no indices are set to true
|
|
69
|
+
* */
|
|
70
|
+
isEmpty(): boolean {
|
|
71
|
+
return this.getTrueIndices().length === 0;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Serializes the BitVector object into a Buffer
|
|
76
|
+
*
|
|
77
|
+
* @returns Buffer representation of the BitVector object
|
|
78
|
+
* */
|
|
79
|
+
toBuffer(): Buffer {
|
|
80
|
+
return serializeToBuffer([this.length, this.buffer]);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Deserializes buffer into new BitVector
|
|
85
|
+
*
|
|
86
|
+
* @returns A new BitVector instance
|
|
87
|
+
* */
|
|
88
|
+
static fromBuffer(buffer: Buffer | BufferReader): BitVector {
|
|
89
|
+
const reader = BufferReader.asReader(buffer);
|
|
90
|
+
const length = reader.readNumber();
|
|
91
|
+
|
|
92
|
+
if (length < 0) {
|
|
93
|
+
throw new Error(`BitVector length ${length} cannot be negative`);
|
|
94
|
+
}
|
|
95
|
+
if (length > MAX_TXS_PER_BLOCK) {
|
|
96
|
+
throw new Error(`BitVector length ${length} exceeds maximum ${MAX_TXS_PER_BLOCK}`);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const bitBuffer = reader.readBytes(BitVector.byteLength(length));
|
|
100
|
+
return new BitVector(bitBuffer, length);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
static byteLength(length: number) {
|
|
104
|
+
return Math.ceil(length / 8);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
|
+
import { TxArray } from '@aztec/stdlib/tx';
|
|
3
|
+
|
|
4
|
+
import type { PeerId } from '@libp2p/interface';
|
|
5
|
+
|
|
6
|
+
import type { AttestationPool } from '../../../../mem_pools/attestation_pool/attestation_pool.js';
|
|
7
|
+
import type { TxPool } from '../../../../mem_pools/index.js';
|
|
8
|
+
import type { ReqRespSubProtocolHandler } from '../../interface.js';
|
|
9
|
+
import { ReqRespStatus, ReqRespStatusError } from '../../status.js';
|
|
10
|
+
import { BitVector } from './bitvector.js';
|
|
11
|
+
import { BlockTxsRequest, BlockTxsResponse } from './block_txs_reqresp.js';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Handler for block txs requests
|
|
15
|
+
* @param attestationPool - the attestation pool to check for block proposals
|
|
16
|
+
* @param mempools - the mempools containing the tx pool
|
|
17
|
+
* @returns the BlockTxs request handler
|
|
18
|
+
*/
|
|
19
|
+
export function reqRespBlockTxsHandler(attestationPool: AttestationPool, txPool: TxPool): ReqRespSubProtocolHandler {
|
|
20
|
+
/**
|
|
21
|
+
* Handler for block txs requests
|
|
22
|
+
* @param msg - the block txs request message
|
|
23
|
+
* @returns the block txs response message
|
|
24
|
+
* @throws if msg is not a valid block txs request
|
|
25
|
+
*/
|
|
26
|
+
return async (_peerId: PeerId, msg: Buffer) => {
|
|
27
|
+
let request: BlockTxsRequest;
|
|
28
|
+
try {
|
|
29
|
+
request = BlockTxsRequest.fromBuffer(msg);
|
|
30
|
+
} catch (err: any) {
|
|
31
|
+
throw new ReqRespStatusError(ReqRespStatus.BADLY_FORMED_REQUEST, { cause: err });
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const blockProposal = await attestationPool.getBlockProposal(request.archiveRoot.toString());
|
|
35
|
+
|
|
36
|
+
let requestedTxsHashes;
|
|
37
|
+
if (request.txHashes.length > 0) {
|
|
38
|
+
requestedTxsHashes = request.txHashes;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// This is scenario in which we don't have this block proposal the peer is requesting from us
|
|
42
|
+
// But peer has sent requested tx hashes, so we can send them the transactions
|
|
43
|
+
if (!blockProposal && requestedTxsHashes !== undefined) {
|
|
44
|
+
const responseTxs = (await txPool.getTxsByHash(requestedTxsHashes)).filter(tx => !!tx);
|
|
45
|
+
const response = new BlockTxsResponse(Fr.zero(), new TxArray(...responseTxs), BitVector.init(0, []));
|
|
46
|
+
return response.toBuffer();
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// If don't have this block proposal and peer has not sent requested tx hashes
|
|
50
|
+
if (!blockProposal) {
|
|
51
|
+
throw new ReqRespStatusError(ReqRespStatus.NOT_FOUND);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const txsAvailableInPool = await txPool.hasTxs(blockProposal.txHashes);
|
|
55
|
+
//Map txs in the pool to their indices in the block proposal
|
|
56
|
+
const availableIndices = txsAvailableInPool.map((hasTx, idx) => (hasTx ? idx : -1)).filter(idx => idx !== -1);
|
|
57
|
+
const responseBitVector = BitVector.init(blockProposal.txHashes.length, availableIndices);
|
|
58
|
+
|
|
59
|
+
const requestedIndices = new Set(request.txIndices.getTrueIndices());
|
|
60
|
+
requestedTxsHashes = blockProposal.txHashes.filter((_, idx) => requestedIndices.has(idx));
|
|
61
|
+
|
|
62
|
+
const responseTxs = (await txPool.getTxsByHash(requestedTxsHashes)).filter(tx => !!tx);
|
|
63
|
+
const response = new BlockTxsResponse(request.archiveRoot, new TxArray(...responseTxs), responseBitVector);
|
|
64
|
+
|
|
65
|
+
return response.toBuffer();
|
|
66
|
+
};
|
|
67
|
+
}
|