@aztec/p2p 0.0.0-test.1 → 0.0.1-commit.24de95ac
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.map +1 -1
- package/dest/bootstrap/bootstrap.js +22 -9
- package/dest/client/factory.d.ts +13 -3
- package/dest/client/factory.d.ts.map +1 -1
- package/dest/client/factory.js +60 -24
- package/dest/client/index.d.ts +1 -0
- package/dest/client/index.d.ts.map +1 -1
- package/dest/client/index.js +1 -0
- package/dest/client/interface.d.ts +155 -0
- package/dest/client/interface.d.ts.map +1 -0
- package/dest/client/interface.js +9 -0
- package/dest/client/p2p_client.d.ts +72 -169
- package/dest/client/p2p_client.d.ts.map +1 -1
- package/dest/client/p2p_client.js +365 -174
- package/dest/config.d.ts +123 -103
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +173 -34
- package/dest/enr/generate-enr.d.ts +10 -2
- package/dest/enr/generate-enr.d.ts.map +1 -1
- package/dest/enr/generate-enr.js +27 -5
- package/dest/index.d.ts +3 -0
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +2 -0
- package/dest/mem_pools/attestation_pool/attestation_pool.d.ts +42 -4
- 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.map +1 -1
- package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.js +204 -54
- package/dest/mem_pools/attestation_pool/kv_attestation_pool.d.ts +10 -2
- package/dest/mem_pools/attestation_pool/kv_attestation_pool.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/kv_attestation_pool.js +93 -15
- package/dest/mem_pools/attestation_pool/memory_attestation_pool.d.ts +10 -2
- package/dest/mem_pools/attestation_pool/memory_attestation_pool.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/memory_attestation_pool.js +86 -18
- package/dest/mem_pools/attestation_pool/mocks.d.ts +1 -2
- package/dest/mem_pools/attestation_pool/mocks.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/mocks.js +9 -15
- package/dest/mem_pools/instrumentation.d.ts +7 -11
- package/dest/mem_pools/instrumentation.d.ts.map +1 -1
- package/dest/mem_pools/instrumentation.js +25 -37
- package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.d.ts +93 -9
- 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 +469 -97
- package/dest/mem_pools/tx_pool/memory_tx_pool.d.ts +33 -9
- package/dest/mem_pools/tx_pool/memory_tx_pool.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool/memory_tx_pool.js +133 -36
- package/dest/mem_pools/tx_pool/priority.js +1 -1
- package/dest/mem_pools/tx_pool/tx_pool.d.ts +64 -8
- 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.map +1 -1
- package/dest/mem_pools/tx_pool/tx_pool_test_suite.js +264 -39
- package/dest/msg_validators/attestation_validator/attestation_validator.d.ts +1 -0
- 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/block_proposal_validator/block_proposal_validator.d.ts +5 -1
- 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 +61 -12
- 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/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.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.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 +0 -2
- 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 +15 -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 +7 -0
- 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 +7 -3
- 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 +91 -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 +12 -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.map +1 -1
- package/dest/msg_validators/tx_validator/tx_proof_validator.js +6 -5
- package/dest/services/discv5/discV5_service.d.ts +9 -8
- 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 +49 -10
- package/dest/services/dummy_service.d.ts.map +1 -1
- package/dest/services/dummy_service.js +88 -5
- package/dest/services/encoding.d.ts +25 -6
- package/dest/services/encoding.d.ts.map +1 -1
- package/dest/services/encoding.js +73 -5
- package/dest/services/index.d.ts +4 -0
- package/dest/services/index.d.ts.map +1 -1
- package/dest/services/index.js +4 -0
- package/dest/services/libp2p/instrumentation.d.ts +18 -0
- package/dest/services/libp2p/instrumentation.d.ts.map +1 -0
- package/dest/services/libp2p/instrumentation.js +157 -0
- package/dest/services/libp2p/libp2p_service.d.ts +87 -42
- package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
- package/dest/services/libp2p/libp2p_service.js +500 -218
- 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 +3 -1
- package/dest/services/peer-manager/metrics.d.ts.map +1 -1
- package/dest/services/peer-manager/metrics.js +11 -2
- package/dest/services/peer-manager/peer_manager.d.ts +126 -15
- package/dest/services/peer-manager/peer_manager.d.ts.map +1 -1
- package/dest/services/peer-manager/peer_manager.js +547 -72
- package/dest/services/reqresp/config.d.ts +10 -8
- 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 +1 -1
- 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 +30 -13
- 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 +2 -1
- 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 +72 -23
- package/dest/services/reqresp/interface.d.ts.map +1 -1
- package/dest/services/reqresp/interface.js +45 -26
- 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 +5 -0
- package/dest/services/reqresp/protocols/block.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/block.js +28 -5
- 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 +49 -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 +2 -4
- 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 +2 -0
- 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 +0 -2
- package/dest/services/reqresp/protocols/ping.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/status.d.ts +38 -6
- package/dest/services/reqresp/protocols/status.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/status.js +72 -5
- package/dest/services/reqresp/protocols/tx.d.ts +12 -1
- 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/rate_limiter.d.ts +4 -2
- 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.map +1 -1
- package/dest/services/reqresp/rate-limiter/rate_limits.js +21 -1
- package/dest/services/reqresp/reqresp.d.ts +45 -47
- 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 +9 -3
- package/dest/services/reqresp/status.d.ts.map +1 -1
- package/dest/services/reqresp/status.js +9 -2
- package/dest/services/service.d.ts +22 -18
- 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 +56 -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 +54 -0
- package/dest/services/tx_collection/slow_tx_collection.d.ts.map +1 -0
- package/dest/services/tx_collection/slow_tx_collection.js +176 -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 +49 -0
- package/dest/services/tx_provider.d.ts.map +1 -0
- package/dest/services/tx_provider.js +210 -0
- package/dest/services/tx_provider_instrumentation.d.ts +13 -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/get-ports.d.ts.map +1 -1
- package/dest/test-helpers/index.d.ts +1 -0
- 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.map +1 -1
- package/dest/test-helpers/make-enrs.js +4 -5
- package/dest/test-helpers/make-test-p2p-clients.d.ts +32 -4
- 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 +14 -10
- 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.js +96 -25
- package/dest/testbench/parse_log_file.js +4 -4
- package/dest/testbench/testbench.js +4 -4
- package/dest/testbench/worker_client_manager.d.ts +0 -5
- 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 +3 -1
- package/dest/types/index.d.ts.map +1 -1
- package/dest/types/index.js +2 -0
- package/dest/util.d.ts +22 -15
- package/dest/util.d.ts.map +1 -1
- package/dest/util.js +64 -67
- package/dest/versioning.d.ts +3 -3
- package/dest/versioning.d.ts.map +1 -1
- package/dest/versioning.js +8 -3
- package/package.json +28 -24
- package/src/bootstrap/bootstrap.ts +27 -11
- package/src/client/factory.ts +136 -45
- package/src/client/index.ts +1 -0
- package/src/client/interface.ts +195 -0
- package/src/client/p2p_client.ts +460 -327
- package/src/config.ts +288 -134
- package/src/enr/generate-enr.ts +39 -6
- package/src/index.ts +4 -0
- package/src/mem_pools/attestation_pool/attestation_pool.ts +48 -4
- package/src/mem_pools/attestation_pool/attestation_pool_test_suite.ts +241 -55
- package/src/mem_pools/attestation_pool/kv_attestation_pool.ts +117 -20
- package/src/mem_pools/attestation_pool/memory_attestation_pool.ts +114 -22
- package/src/mem_pools/attestation_pool/mocks.ts +11 -10
- package/src/mem_pools/instrumentation.ts +32 -46
- package/src/mem_pools/tx_pool/aztec_kv_tx_pool.ts +549 -108
- package/src/mem_pools/tx_pool/memory_tx_pool.ts +153 -44
- package/src/mem_pools/tx_pool/priority.ts +1 -1
- package/src/mem_pools/tx_pool/tx_pool.ts +67 -8
- package/src/mem_pools/tx_pool/tx_pool_test_suite.ts +217 -34
- package/src/msg_validators/attestation_validator/attestation_validator.ts +55 -10
- package/src/msg_validators/block_proposal_validator/block_proposal_validator.ts +66 -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 +4 -4
- 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 +109 -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 +58 -21
- package/src/msg_validators/tx_validator/phases_validator.ts +114 -0
- package/src/msg_validators/tx_validator/test_utils.ts +43 -0
- package/src/msg_validators/tx_validator/timestamp_validator.ts +46 -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 +80 -5
- package/src/services/index.ts +4 -0
- package/src/services/libp2p/instrumentation.ts +158 -0
- package/src/services/libp2p/libp2p_service.ts +646 -263
- package/src/services/peer-manager/interface.ts +29 -0
- package/src/services/peer-manager/metrics.ts +16 -1
- package/src/services/peer-manager/peer_manager.ts +652 -78
- 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 +91 -36
- package/src/services/reqresp/metrics.ts +4 -1
- package/src/services/reqresp/protocols/auth.ts +83 -0
- package/src/services/reqresp/protocols/block.ts +24 -3
- 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 +117 -5
- package/src/services/reqresp/protocols/tx.ts +35 -6
- 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 +340 -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 +232 -0
- package/src/services/tx_collection/tx_collection.ts +215 -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 +216 -0
- package/src/services/tx_provider_instrumentation.ts +44 -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 +86 -35
- package/src/testbench/p2p_client_testbench_worker.ts +145 -22
- 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 +93 -89
- package/src/versioning.ts +11 -4
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { Fr } from '@aztec/foundation/fields';
|
|
2
|
+
import { BufferReader } from '@aztec/foundation/serialize';
|
|
3
|
+
import { TxArray } from '@aztec/stdlib/tx';
|
|
4
|
+
import { BitVector } from './bitvector.js';
|
|
5
|
+
/**
|
|
6
|
+
* Request message for requesting specific transactions from a block
|
|
7
|
+
*/
|
|
8
|
+
export declare class BlockTxsRequest {
|
|
9
|
+
readonly blockHash: Fr;
|
|
10
|
+
readonly txIndices: BitVector;
|
|
11
|
+
constructor(blockHash: Fr, // 32 byte hash of the proposed block header
|
|
12
|
+
txIndices: BitVector);
|
|
13
|
+
/**
|
|
14
|
+
* Deserializes the BlockTxRequest object from a Buffer
|
|
15
|
+
* @param buffer - Buffer or BufferReader object to deserialize
|
|
16
|
+
* @returns An instance of BlockTxRequest
|
|
17
|
+
*/
|
|
18
|
+
static fromBuffer(buffer: Buffer | BufferReader): BlockTxsRequest;
|
|
19
|
+
/**
|
|
20
|
+
* Serializes the BlockTxRequest object into a Buffer
|
|
21
|
+
* @returns Buffer representation of the BlockTxRequest object
|
|
22
|
+
*/
|
|
23
|
+
toBuffer(): Buffer;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Response message containing requested transactions from a block
|
|
27
|
+
*/
|
|
28
|
+
export declare class BlockTxsResponse {
|
|
29
|
+
readonly blockHash: Fr;
|
|
30
|
+
readonly txs: TxArray;
|
|
31
|
+
readonly txIndices: BitVector;
|
|
32
|
+
constructor(blockHash: Fr, txs: TxArray, // List of transactions we requested and peer has
|
|
33
|
+
txIndices: BitVector);
|
|
34
|
+
/**
|
|
35
|
+
* Deserializes the BlockTxResponse object from a Buffer
|
|
36
|
+
* @param buffer - Buffer or BufferReader object to deserialize
|
|
37
|
+
* @returns An instance of BlockTxResponse
|
|
38
|
+
*/
|
|
39
|
+
static fromBuffer(buffer: Buffer | BufferReader): BlockTxsResponse;
|
|
40
|
+
/**
|
|
41
|
+
* Serializes the BlockTxResponse object into a Buffer
|
|
42
|
+
* @dev: In current implementation, txIndices is serialized as Buffer of unknown length,
|
|
43
|
+
* thus we serialize it last
|
|
44
|
+
* @returns Buffer representation of the BlockTxResponse object
|
|
45
|
+
*/
|
|
46
|
+
toBuffer(): Buffer;
|
|
47
|
+
static empty(): BlockTxsResponse;
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=block_txs_reqresp.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"block_txs_reqresp.d.ts","sourceRoot":"","sources":["../../../../../src/services/reqresp/protocols/block_txs/block_txs_reqresp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAqB,MAAM,6BAA6B,CAAC;AAC9E,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAE3C,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C;;GAEG;AACH,qBAAa,eAAe;IAExB,QAAQ,CAAC,SAAS,EAAE,EAAE;IAGtB,QAAQ,CAAC,SAAS,EAAE,SAAS;gBAHpB,SAAS,EAAE,EAAE,EAAE,4CAA4C;IAG3D,SAAS,EAAE,SAAS;IAG/B;;;;OAIG;IACH,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY,GAAG,eAAe;IAQjE;;;OAGG;IACH,QAAQ,IAAI,MAAM;CAGnB;AAED;;GAEG;AACH,qBAAa,gBAAgB;IAEzB,QAAQ,CAAC,SAAS,EAAE,EAAE;IACtB,QAAQ,CAAC,GAAG,EAAE,OAAO;IAGrB,QAAQ,CAAC,SAAS,EAAE,SAAS;gBAJpB,SAAS,EAAE,EAAE,EACb,GAAG,EAAE,OAAO,EAAE,iDAAiD;IAG/D,SAAS,EAAE,SAAS;IAG/B;;;;OAIG;IACH,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY,GAAG,gBAAgB;IASlE;;;;;OAKG;IACH,QAAQ,IAAI,MAAM;IAIlB,MAAM,CAAC,KAAK,IAAI,gBAAgB;CAGjC"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { Fr } from '@aztec/foundation/fields';
|
|
2
|
+
import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
|
|
3
|
+
import { TxArray } from '@aztec/stdlib/tx';
|
|
4
|
+
import { BitVector } from './bitvector.js';
|
|
5
|
+
/**
|
|
6
|
+
* Request message for requesting specific transactions from a block
|
|
7
|
+
*/ export class BlockTxsRequest {
|
|
8
|
+
blockHash;
|
|
9
|
+
txIndices;
|
|
10
|
+
constructor(blockHash, // BitVector indicating which txs from the proposal we are requesting
|
|
11
|
+
// 1 means we want the tx, 0 means we don't
|
|
12
|
+
txIndices){
|
|
13
|
+
this.blockHash = blockHash;
|
|
14
|
+
this.txIndices = txIndices;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Deserializes the BlockTxRequest object from a Buffer
|
|
18
|
+
* @param buffer - Buffer or BufferReader object to deserialize
|
|
19
|
+
* @returns An instance of BlockTxRequest
|
|
20
|
+
*/ static fromBuffer(buffer) {
|
|
21
|
+
const reader = BufferReader.asReader(buffer);
|
|
22
|
+
const blockHash = Fr.fromBuffer(reader);
|
|
23
|
+
const txIndices = BitVector.fromBuffer(reader);
|
|
24
|
+
return new BlockTxsRequest(blockHash, txIndices);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Serializes the BlockTxRequest object into a Buffer
|
|
28
|
+
* @returns Buffer representation of the BlockTxRequest object
|
|
29
|
+
*/ toBuffer() {
|
|
30
|
+
return serializeToBuffer([
|
|
31
|
+
this.blockHash,
|
|
32
|
+
this.txIndices.toBuffer()
|
|
33
|
+
]);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Response message containing requested transactions from a block
|
|
38
|
+
*/ export class BlockTxsResponse {
|
|
39
|
+
blockHash;
|
|
40
|
+
txs;
|
|
41
|
+
txIndices;
|
|
42
|
+
constructor(blockHash, txs, // BitVector indicating which txs from the proposal are available at the peer
|
|
43
|
+
// 1 means the tx is available, 0 means it is not
|
|
44
|
+
txIndices){
|
|
45
|
+
this.blockHash = blockHash;
|
|
46
|
+
this.txs = txs;
|
|
47
|
+
this.txIndices = txIndices;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Deserializes the BlockTxResponse object from a Buffer
|
|
51
|
+
* @param buffer - Buffer or BufferReader object to deserialize
|
|
52
|
+
* @returns An instance of BlockTxResponse
|
|
53
|
+
*/ static fromBuffer(buffer) {
|
|
54
|
+
const reader = BufferReader.asReader(buffer);
|
|
55
|
+
const blockHash = Fr.fromBuffer(reader);
|
|
56
|
+
const txs = TxArray.fromBuffer(reader);
|
|
57
|
+
const txIndices = BitVector.fromBuffer(reader);
|
|
58
|
+
return new BlockTxsResponse(blockHash, txs, txIndices);
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Serializes the BlockTxResponse object into a Buffer
|
|
62
|
+
* @dev: In current implementation, txIndices is serialized as Buffer of unknown length,
|
|
63
|
+
* thus we serialize it last
|
|
64
|
+
* @returns Buffer representation of the BlockTxResponse object
|
|
65
|
+
*/ toBuffer() {
|
|
66
|
+
return serializeToBuffer([
|
|
67
|
+
this.blockHash,
|
|
68
|
+
this.txs.toBuffer(),
|
|
69
|
+
this.txIndices.toBuffer()
|
|
70
|
+
]);
|
|
71
|
+
}
|
|
72
|
+
static empty() {
|
|
73
|
+
return new BlockTxsResponse(Fr.ZERO, new TxArray(), BitVector.init(0, []));
|
|
74
|
+
}
|
|
75
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/services/reqresp/protocols/block_txs/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,wBAAwB,CAAC"}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
-
/// <reference types="node" resolution-mode="require"/>
|
|
3
1
|
import type { PeerId } from '@libp2p/interface';
|
|
4
|
-
import type {
|
|
2
|
+
import type { PeerManagerInterface } from '../../peer-manager/interface.js';
|
|
5
3
|
import { type ReqRespSubProtocolHandler } from '../interface.js';
|
|
6
4
|
import type { ReqResp } from '../reqresp.js';
|
|
7
5
|
/**
|
|
@@ -47,5 +45,5 @@ export declare class GoodbyeProtocolHandler {
|
|
|
47
45
|
* @param peerManager - The peer manager.
|
|
48
46
|
* @returns A resolved promise with the goodbye response.
|
|
49
47
|
*/
|
|
50
|
-
export declare function reqGoodbyeHandler(peerManager:
|
|
48
|
+
export declare function reqGoodbyeHandler(peerManager: PeerManagerInterface): ReqRespSubProtocolHandler;
|
|
51
49
|
//# sourceMappingURL=goodbye.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"goodbye.d.ts","sourceRoot":"","sources":["../../../../src/services/reqresp/protocols/goodbye.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"goodbye.d.ts","sourceRoot":"","sources":["../../../../src/services/reqresp/protocols/goodbye.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAC5E,OAAO,EAAsB,KAAK,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AACrF,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAE7C;;GAEG;AACH,oBAAY,aAAa;IACvB,0FAA0F;IAC1F,QAAQ,IAAM;IACd,sIAAsI;IACtI,SAAS,IAAM;IACf,gFAAgF;IAChF,SAAS,IAAM;IACf,2EAA2E;IAC3E,MAAM,IAAM;IACZ,2BAA2B;IAC3B,aAAa,IAAM;IACnB,qBAAqB;IACrB,OAAO,IAAM;CACd;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,aAAa,GAAG,MAAM,CAEjE;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,aAAa,CASjE;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,aAAa,GAAG,MAAM,CAgBjE;AAED;;GAEG;AACH,qBAAa,sBAAsB;IAGrB,OAAO,CAAC,OAAO;IAF3B,OAAO,CAAC,MAAM,CAAwC;gBAElC,OAAO,EAAE,OAAO;IAEvB,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;CAQ/E;AAED;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,oBAAoB,GAAG,yBAAyB,CAW9F"}
|
|
@@ -22,7 +22,7 @@ export function decodeGoodbyeReason(buffer) {
|
|
|
22
22
|
throw new Error('Invalid goodbye reason buffer length');
|
|
23
23
|
}
|
|
24
24
|
return buffer[0];
|
|
25
|
-
} catch
|
|
25
|
+
} catch {
|
|
26
26
|
return 6;
|
|
27
27
|
}
|
|
28
28
|
}
|
|
@@ -76,12 +76,12 @@ export function decodeGoodbyeReason(buffer) {
|
|
|
76
76
|
* @param peerManager - The peer manager.
|
|
77
77
|
* @returns A resolved promise with the goodbye response.
|
|
78
78
|
*/ export function reqGoodbyeHandler(peerManager) {
|
|
79
|
-
return (peerId,
|
|
80
|
-
const reason = decodeGoodbyeReason(
|
|
79
|
+
return (peerId, msg)=>{
|
|
80
|
+
const reason = decodeGoodbyeReason(msg);
|
|
81
81
|
peerManager.goodbyeReceived(peerId, reason);
|
|
82
|
-
//
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
82
|
+
// NOTE: In the current implementation this won't be sent to peer,
|
|
83
|
+
// as the connection to peer has been already closed by peerManager.goodbyeReceived
|
|
84
|
+
// We have this just to satisfy interface
|
|
85
|
+
return Promise.resolve(Buffer.alloc(0));
|
|
86
86
|
};
|
|
87
87
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/services/reqresp/protocols/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/services/reqresp/protocols/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,sBAAsB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ping.d.ts","sourceRoot":"","sources":["../../../../src/services/reqresp/protocols/ping.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ping.d.ts","sourceRoot":"","sources":["../../../../src/services/reqresp/protocols/ping.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,GAAG,GAAG,OAAO,CAAC,MAAM,CAAC,CAEtD"}
|
|
@@ -1,9 +1,41 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import type { Logger } from '@aztec/foundation/log';
|
|
2
|
+
import { BufferReader } from '@aztec/foundation/serialize';
|
|
3
|
+
import type { WorldStateSyncStatus, WorldStateSynchronizer } from '@aztec/stdlib/interfaces/server';
|
|
4
|
+
import type { PeerId } from '@libp2p/interface';
|
|
5
|
+
export declare class StatusMessage {
|
|
6
|
+
readonly compressedComponentsVersion: string;
|
|
7
|
+
readonly latestBlockNumber: number;
|
|
8
|
+
readonly latestBlockHash: string;
|
|
9
|
+
readonly finalizedBlockNumber: number;
|
|
10
|
+
constructor(compressedComponentsVersion: string, latestBlockNumber: number, latestBlockHash: string, finalizedBlockNumber: number);
|
|
11
|
+
/**
|
|
12
|
+
* Deserializes the StatusMessage object from a Buffer.
|
|
13
|
+
* @param buffer - Buffer or BufferReader object to deserialize.
|
|
14
|
+
* @returns An instance of StatusMessage.
|
|
15
|
+
*/
|
|
16
|
+
static fromBuffer(buffer: Buffer | BufferReader): StatusMessage;
|
|
17
|
+
/**
|
|
18
|
+
* Serializes the StatusMessage object into a Buffer.
|
|
19
|
+
* @returns Buffer representation of the StatusMessage object.
|
|
20
|
+
*/
|
|
21
|
+
toBuffer(): Buffer<ArrayBufferLike>;
|
|
22
|
+
/**
|
|
23
|
+
* Builds Status message
|
|
24
|
+
* @param version - Compressed Components Version
|
|
25
|
+
* @param worldStateSyncStatus - Info about the current sync status
|
|
26
|
+
* @returns StatusMessage instance
|
|
27
|
+
*/
|
|
28
|
+
static fromWorldStateSyncStatus(version: string, syncStatus: WorldStateSyncStatus): StatusMessage;
|
|
29
|
+
static random(): StatusMessage;
|
|
30
|
+
validate(peerStatus: StatusMessage): boolean;
|
|
31
|
+
equals(other: StatusMessage): boolean;
|
|
32
|
+
}
|
|
3
33
|
/**
|
|
4
|
-
* Handles the status request.
|
|
5
|
-
* @param
|
|
6
|
-
* @
|
|
34
|
+
* Handles the status request. By immediately responding with the current node status.
|
|
35
|
+
* @param compressedComponentsVersion - Compressed Components Version
|
|
36
|
+
* @param worldStateSynchronizer - World State Synchronizer to fetch the sync status from.
|
|
37
|
+
* Note the WorldStateSynchronizer must be injected to fetch the fresh sync status, we cannot pass in pre-built StatusMessage.
|
|
38
|
+
* @returns Status message handler
|
|
7
39
|
*/
|
|
8
|
-
export declare function
|
|
40
|
+
export declare function reqRespStatusHandler(compressedComponentsVersion: string, worldStateSynchronizer: WorldStateSynchronizer, logger?: Logger): (peerId: PeerId, _msg: Buffer) => Promise<Buffer<ArrayBufferLike>>;
|
|
9
41
|
//# sourceMappingURL=status.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../../../src/services/reqresp/protocols/status.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../../../src/services/reqresp/protocols/status.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAqB,MAAM,6BAA6B,CAAC;AAE9E,OAAO,KAAK,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AAEpG,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAQhD,qBAAa,aAAa;IAEtB,QAAQ,CAAC,2BAA2B,EAAE,MAAM;IAC5C,QAAQ,CAAC,iBAAiB,EAAE,MAAM;IAClC,QAAQ,CAAC,eAAe,EAAE,MAAM;IAChC,QAAQ,CAAC,oBAAoB,EAAE,MAAM;gBAH5B,2BAA2B,EAAE,MAAM,EACnC,iBAAiB,EAAE,MAAM,EACzB,eAAe,EAAE,MAAM,EACvB,oBAAoB,EAAE,MAAM;IAKvC;;;;OAIG;IACH,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY,GAAG,aAAa;IAY/D;;;OAGG;IACH,QAAQ;IAWR;;;;;OAKG;IACH,MAAM,CAAC,wBAAwB,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,oBAAoB,GAAG,aAAa;IAUjG,MAAM,CAAC,MAAM,IAAI,aAAa;IAU9B,QAAQ,CAAC,UAAU,EAAE,aAAa,GAAG,OAAO;IAK5C,MAAM,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO;CAQtC;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAClC,2BAA2B,EAAE,MAAM,EACnC,sBAAsB,EAAE,sBAAsB,EAC9C,MAAM,CAAC,EAAE,MAAM,IAED,QAAQ,MAAM,EAAE,MAAM,MAAM,sCAU3C"}
|
|
@@ -1,7 +1,74 @@
|
|
|
1
|
+
import { Buffer32 } from '@aztec/foundation/buffer';
|
|
2
|
+
import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
|
|
3
|
+
import { bufferToHex } from '@aztec/foundation/string';
|
|
4
|
+
/*
|
|
5
|
+
* P2P Status Message
|
|
6
|
+
* It is used to establish Status handshake between to peers
|
|
7
|
+
* By validating Status handshake we ensure peers are on the same Blockchain fork
|
|
8
|
+
* And get peer sync status
|
|
9
|
+
*/ export class StatusMessage {
|
|
10
|
+
compressedComponentsVersion;
|
|
11
|
+
latestBlockNumber;
|
|
12
|
+
latestBlockHash;
|
|
13
|
+
finalizedBlockNumber;
|
|
14
|
+
constructor(compressedComponentsVersion, latestBlockNumber, latestBlockHash, finalizedBlockNumber){
|
|
15
|
+
this.compressedComponentsVersion = compressedComponentsVersion;
|
|
16
|
+
this.latestBlockNumber = latestBlockNumber;
|
|
17
|
+
this.latestBlockHash = latestBlockHash;
|
|
18
|
+
this.finalizedBlockNumber = finalizedBlockNumber;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Deserializes the StatusMessage object from a Buffer.
|
|
22
|
+
* @param buffer - Buffer or BufferReader object to deserialize.
|
|
23
|
+
* @returns An instance of StatusMessage.
|
|
24
|
+
*/ static fromBuffer(buffer) {
|
|
25
|
+
const reader = BufferReader.asReader(buffer);
|
|
26
|
+
return new StatusMessage(reader.readString(), reader.readNumber(), reader.readString(), reader.readNumber());
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Serializes the StatusMessage object into a Buffer.
|
|
30
|
+
* @returns Buffer representation of the StatusMessage object.
|
|
31
|
+
*/ toBuffer() {
|
|
32
|
+
return serializeToBuffer([
|
|
33
|
+
this.compressedComponentsVersion,
|
|
34
|
+
this.latestBlockNumber,
|
|
35
|
+
this.latestBlockHash,
|
|
36
|
+
this.finalizedBlockNumber
|
|
37
|
+
]);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Builds Status message
|
|
41
|
+
* @param version - Compressed Components Version
|
|
42
|
+
* @param worldStateSyncStatus - Info about the current sync status
|
|
43
|
+
* @returns StatusMessage instance
|
|
44
|
+
*/ static fromWorldStateSyncStatus(version, syncStatus) {
|
|
45
|
+
return new StatusMessage(version, syncStatus.latestBlockNumber, syncStatus.latestBlockHash, syncStatus.finalizedBlockNumber);
|
|
46
|
+
}
|
|
47
|
+
static random() {
|
|
48
|
+
return new StatusMessage('1.0.0', Math.floor(Math.random() * 100), Buffer32.random().toString(), Math.floor(Math.random() * 100));
|
|
49
|
+
}
|
|
50
|
+
validate(peerStatus) {
|
|
51
|
+
// TODO: Validate other fields as well
|
|
52
|
+
return this.compressedComponentsVersion === peerStatus.compressedComponentsVersion;
|
|
53
|
+
}
|
|
54
|
+
equals(other) {
|
|
55
|
+
return this.compressedComponentsVersion === other.compressedComponentsVersion && this.latestBlockNumber === other.latestBlockNumber && this.latestBlockHash === other.latestBlockHash && this.finalizedBlockNumber === other.finalizedBlockNumber;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
1
58
|
/**
|
|
2
|
-
* Handles the status request.
|
|
3
|
-
* @param
|
|
4
|
-
* @
|
|
5
|
-
|
|
6
|
-
|
|
59
|
+
* Handles the status request. By immediately responding with the current node status.
|
|
60
|
+
* @param compressedComponentsVersion - Compressed Components Version
|
|
61
|
+
* @param worldStateSynchronizer - World State Synchronizer to fetch the sync status from.
|
|
62
|
+
* Note the WorldStateSynchronizer must be injected to fetch the fresh sync status, we cannot pass in pre-built StatusMessage.
|
|
63
|
+
* @returns Status message handler
|
|
64
|
+
*/ export function reqRespStatusHandler(compressedComponentsVersion, worldStateSynchronizer, logger) {
|
|
65
|
+
return async (peerId, _msg)=>{
|
|
66
|
+
logger?.trace(`Received status handshake request from ${peerId}`);
|
|
67
|
+
const status = StatusMessage.fromWorldStateSyncStatus(compressedComponentsVersion, (await worldStateSynchronizer.status()).syncSummary);
|
|
68
|
+
const response = status.toBuffer();
|
|
69
|
+
logger?.trace(`Responding status handshake from ${peerId}`, {
|
|
70
|
+
data: bufferToHex(response)
|
|
71
|
+
});
|
|
72
|
+
return response;
|
|
73
|
+
};
|
|
7
74
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { P2PClientType } from '@aztec/stdlib/p2p';
|
|
2
|
+
import { TxHash, TxHashArray } from '@aztec/stdlib/tx';
|
|
2
3
|
import type { MemPools } from '../../../mem_pools/interface.js';
|
|
3
4
|
import type { ReqRespSubProtocolHandler } from '../interface.js';
|
|
4
5
|
/**
|
|
@@ -7,7 +8,17 @@ import type { ReqRespSubProtocolHandler } from '../interface.js';
|
|
|
7
8
|
*
|
|
8
9
|
* Handler for tx requests
|
|
9
10
|
* @param mempools - the mempools
|
|
10
|
-
* @returns the
|
|
11
|
+
* @returns the Tx request handler
|
|
11
12
|
*/
|
|
12
13
|
export declare function reqRespTxHandler<T extends P2PClientType>(mempools: MemPools<T>): ReqRespSubProtocolHandler;
|
|
14
|
+
/**
|
|
15
|
+
* Helper function to chunk an array of transaction hashes into chunks of a specified size.
|
|
16
|
+
* This is mainly used in ReqResp in order not to request too many transactions at once from the single peer.
|
|
17
|
+
*
|
|
18
|
+
* @param hashes - The array of transaction hashes to chunk.
|
|
19
|
+
* @param chunkSize - The size of each chunk. Default is 8. Reasoning:
|
|
20
|
+
* Per: https://github.com/AztecProtocol/aztec-packages/issues/15149#issuecomment-2999054485
|
|
21
|
+
* we define Q as max number of transactions per batch, the comment explains why we use 8.
|
|
22
|
+
*/
|
|
23
|
+
export declare function chunkTxHashesRequest(hashes: TxHash[], chunkSize?: number): Array<TxHashArray>;
|
|
13
24
|
//# sourceMappingURL=tx.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tx.d.ts","sourceRoot":"","sources":["../../../../src/services/reqresp/protocols/tx.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"tx.d.ts","sourceRoot":"","sources":["../../../../src/services/reqresp/protocols/tx.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAW,MAAM,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAIhE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAChE,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AAGjE;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,aAAa,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,yBAAyB,CAwB1G;AAED;;;;;;;;GAQG;AAGH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,SAAS,SAAI,GAAG,KAAK,CAAC,WAAW,CAAC,CAExF"}
|
|
@@ -1,20 +1,48 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { chunk } from '@aztec/foundation/collection';
|
|
2
|
+
import { TxArray, TxHashArray } from '@aztec/stdlib/tx';
|
|
3
|
+
import { ReqRespStatus, ReqRespStatusError } from '../status.js';
|
|
2
4
|
/**
|
|
3
5
|
* We want to keep the logic of the req resp handler in this file, but we do not have a reference to the mempools here
|
|
4
6
|
* so we need to pass it in as a parameter.
|
|
5
7
|
*
|
|
6
8
|
* Handler for tx requests
|
|
7
9
|
* @param mempools - the mempools
|
|
8
|
-
* @returns the
|
|
10
|
+
* @returns the Tx request handler
|
|
9
11
|
*/ export function reqRespTxHandler(mempools) {
|
|
10
12
|
/**
|
|
11
13
|
* Handler for tx requests
|
|
12
14
|
* @param msg - the tx request message
|
|
13
15
|
* @returns the tx response message
|
|
16
|
+
* @throws if msg is not a valid tx hash
|
|
14
17
|
*/ return async (_peerId, msg)=>{
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
18
|
+
let txHashes;
|
|
19
|
+
try {
|
|
20
|
+
txHashes = TxHashArray.fromBuffer(msg);
|
|
21
|
+
} catch (err) {
|
|
22
|
+
throw new ReqRespStatusError(ReqRespStatus.BADLY_FORMED_REQUEST, {
|
|
23
|
+
cause: err
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
try {
|
|
27
|
+
const txs = new TxArray(...(await Promise.all(txHashes.map((txHash)=>mempools.txPool.getTxByHash(txHash)))).filter((t)=>!!t));
|
|
28
|
+
return txs.toBuffer();
|
|
29
|
+
} catch (err) {
|
|
30
|
+
throw new ReqRespStatusError(ReqRespStatus.INTERNAL_ERROR, {
|
|
31
|
+
cause: err
|
|
32
|
+
});
|
|
33
|
+
}
|
|
19
34
|
};
|
|
20
35
|
}
|
|
36
|
+
/**
|
|
37
|
+
* Helper function to chunk an array of transaction hashes into chunks of a specified size.
|
|
38
|
+
* This is mainly used in ReqResp in order not to request too many transactions at once from the single peer.
|
|
39
|
+
*
|
|
40
|
+
* @param hashes - The array of transaction hashes to chunk.
|
|
41
|
+
* @param chunkSize - The size of each chunk. Default is 8. Reasoning:
|
|
42
|
+
* Per: https://github.com/AztecProtocol/aztec-packages/issues/15149#issuecomment-2999054485
|
|
43
|
+
* we define Q as max number of transactions per batch, the comment explains why we use 8.
|
|
44
|
+
*/ //TODO: (mralj) chunk size should by default be 8, this is just temporary until the protocol is implemented correctly
|
|
45
|
+
//more info: https://github.com/AztecProtocol/aztec-packages/pull/15516#pullrequestreview-2995474321
|
|
46
|
+
export function chunkTxHashesRequest(hashes, chunkSize = 1) {
|
|
47
|
+
return chunk(hashes, chunkSize).map((chunk)=>new TxHashArray(...chunk));
|
|
48
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { PeerId } from '@libp2p/interface';
|
|
2
2
|
import type { PeerScoring } from '../../peer-manager/peer_scoring.js';
|
|
3
|
-
import type { ReqRespSubProtocol, ReqRespSubProtocolRateLimits } from '../interface.js';
|
|
3
|
+
import type { ProtocolRateLimitQuota, ReqRespSubProtocol, ReqRespSubProtocolRateLimits } from '../interface.js';
|
|
4
4
|
/**
|
|
5
5
|
* GCRARateLimiter: A Generic Cell Rate Algorithm (GCRA) based rate limiter.
|
|
6
6
|
*
|
|
@@ -89,8 +89,9 @@ export declare class SubProtocolRateLimiter {
|
|
|
89
89
|
export declare class RequestResponseRateLimiter {
|
|
90
90
|
private peerScoring;
|
|
91
91
|
private subProtocolRateLimiters;
|
|
92
|
+
private rateLimits;
|
|
92
93
|
private cleanupInterval;
|
|
93
|
-
constructor(peerScoring: PeerScoring, rateLimits?: ReqRespSubProtocolRateLimits);
|
|
94
|
+
constructor(peerScoring: PeerScoring, rateLimits?: Partial<ReqRespSubProtocolRateLimits>);
|
|
94
95
|
start(): void;
|
|
95
96
|
allow(subProtocol: ReqRespSubProtocol, peerId: PeerId): RateLimitStatus;
|
|
96
97
|
cleanupInactivePeers(): void;
|
|
@@ -98,5 +99,6 @@ export declare class RequestResponseRateLimiter {
|
|
|
98
99
|
* Make sure to call destroy on each of the sub protocol rate limiters when cleaning up
|
|
99
100
|
*/
|
|
100
101
|
stop(): void;
|
|
102
|
+
getRateLimits(protocol: ReqRespSubProtocol): ProtocolRateLimitQuota;
|
|
101
103
|
}
|
|
102
104
|
//# sourceMappingURL=rate_limiter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rate_limiter.d.ts","sourceRoot":"","sources":["../../../../src/services/reqresp/rate-limiter/rate_limiter.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AACtE,OAAO,KAAK,EAAE,kBAAkB,EAAE,4BAA4B,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"rate_limiter.d.ts","sourceRoot":"","sources":["../../../../src/services/reqresp/rate-limiter/rate_limiter.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AACtE,OAAO,KAAK,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,4BAA4B,EAAE,MAAM,iBAAiB,CAAC;AAMhH;;;;;;;;;;;;;;;;;;;GAmBG;AACH,qBAAa,eAAe;IAE1B,OAAO,CAAC,GAAG,CAAS;IAEpB,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAS;IAE1C,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAS;IAEvC;;;OAGG;gBACS,UAAU,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM;IAMnD,KAAK,IAAI,OAAO;CAWjB;AASD,oBAAY,eAAe;IACzB,YAAY,IAAA;IACZ,UAAU,IAAA;IACV,OAAO,IAAA;CACR;AAED,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,eAAe,6CASjE;AAED;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,sBAAsB;IACjC,OAAO,CAAC,YAAY,CAA2C;IAC/D,OAAO,CAAC,aAAa,CAAkB;IACvC,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAS;IACxC,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAS;gBAE7B,cAAc,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM;IAOhH,KAAK,CAAC,MAAM,EAAE,MAAM,GAAG,eAAe;IAwBtC,oBAAoB;CAQrB;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,qBAAa,0BAA0B;IAOnC,OAAO,CAAC,WAAW;IANrB,OAAO,CAAC,uBAAuB,CAAkD;IACjF,OAAO,CAAC,UAAU,CAA+B;IAEjD,OAAO,CAAC,eAAe,CAAyC;gBAGtD,WAAW,EAAE,WAAW,EAChC,UAAU,GAAE,OAAO,CAAC,4BAA4B,CAAM;IAkBxD,KAAK;IAML,KAAK,CAAC,WAAW,EAAE,kBAAkB,EAAE,MAAM,EAAE,MAAM,GAAG,eAAe;IAavE,oBAAoB;IAIpB;;OAEG;IACH,IAAI;IAIJ,aAAa,CAAC,QAAQ,EAAE,kBAAkB,GAAG,sBAAsB;CAGpE"}
|
|
@@ -148,12 +148,17 @@ export function prettyPrintRateLimitStatus(status) {
|
|
|
148
148
|
*/ export class RequestResponseRateLimiter {
|
|
149
149
|
peerScoring;
|
|
150
150
|
subProtocolRateLimiters;
|
|
151
|
+
rateLimits;
|
|
151
152
|
cleanupInterval;
|
|
152
|
-
constructor(peerScoring, rateLimits =
|
|
153
|
+
constructor(peerScoring, rateLimits = {}){
|
|
153
154
|
this.peerScoring = peerScoring;
|
|
154
155
|
this.cleanupInterval = undefined;
|
|
155
156
|
this.subProtocolRateLimiters = new Map();
|
|
156
|
-
|
|
157
|
+
this.rateLimits = {
|
|
158
|
+
...DEFAULT_RATE_LIMITS,
|
|
159
|
+
...rateLimits
|
|
160
|
+
};
|
|
161
|
+
for (const [subProtocol, protocolLimits] of Object.entries(this.rateLimits)){
|
|
157
162
|
this.subProtocolRateLimiters.set(subProtocol, new SubProtocolRateLimiter(protocolLimits.peerLimit.quotaCount, protocolLimits.peerLimit.quotaTimeMs, protocolLimits.globalLimit.quotaCount, protocolLimits.globalLimit.quotaTimeMs));
|
|
158
163
|
}
|
|
159
164
|
}
|
|
@@ -181,4 +186,7 @@ export function prettyPrintRateLimitStatus(status) {
|
|
|
181
186
|
*/ stop() {
|
|
182
187
|
clearInterval(this.cleanupInterval);
|
|
183
188
|
}
|
|
189
|
+
getRateLimits(protocol) {
|
|
190
|
+
return this.rateLimits[protocol];
|
|
191
|
+
}
|
|
184
192
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rate_limits.d.ts","sourceRoot":"","sources":["../../../../src/services/reqresp/rate-limiter/rate_limits.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,KAAK,4BAA4B,EAAE,MAAM,iBAAiB,CAAC;AAGxF,eAAO,MAAM,mBAAmB,EAAE,
|
|
1
|
+
{"version":3,"file":"rate_limits.d.ts","sourceRoot":"","sources":["../../../../src/services/reqresp/rate-limiter/rate_limits.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,KAAK,4BAA4B,EAAE,MAAM,iBAAiB,CAAC;AAGxF,eAAO,MAAM,mBAAmB,EAAE,4BAuEjC,CAAC"}
|
|
@@ -21,6 +21,16 @@ export const DEFAULT_RATE_LIMITS = {
|
|
|
21
21
|
quotaCount: 10
|
|
22
22
|
}
|
|
23
23
|
},
|
|
24
|
+
[ReqRespSubProtocol.AUTH]: {
|
|
25
|
+
peerLimit: {
|
|
26
|
+
quotaTimeMs: 1000,
|
|
27
|
+
quotaCount: 5
|
|
28
|
+
},
|
|
29
|
+
globalLimit: {
|
|
30
|
+
quotaTimeMs: 1000,
|
|
31
|
+
quotaCount: 10
|
|
32
|
+
}
|
|
33
|
+
},
|
|
24
34
|
[ReqRespSubProtocol.TX]: {
|
|
25
35
|
peerLimit: {
|
|
26
36
|
quotaTimeMs: 1000,
|
|
@@ -28,7 +38,7 @@ export const DEFAULT_RATE_LIMITS = {
|
|
|
28
38
|
},
|
|
29
39
|
globalLimit: {
|
|
30
40
|
quotaTimeMs: 1000,
|
|
31
|
-
quotaCount:
|
|
41
|
+
quotaCount: 200
|
|
32
42
|
}
|
|
33
43
|
},
|
|
34
44
|
[ReqRespSubProtocol.BLOCK]: {
|
|
@@ -50,5 +60,15 @@ export const DEFAULT_RATE_LIMITS = {
|
|
|
50
60
|
quotaTimeMs: 1000,
|
|
51
61
|
quotaCount: 10
|
|
52
62
|
}
|
|
63
|
+
},
|
|
64
|
+
[ReqRespSubProtocol.BLOCK_TXS]: {
|
|
65
|
+
peerLimit: {
|
|
66
|
+
quotaTimeMs: 1000,
|
|
67
|
+
quotaCount: 10
|
|
68
|
+
},
|
|
69
|
+
globalLimit: {
|
|
70
|
+
quotaTimeMs: 1000,
|
|
71
|
+
quotaCount: 200
|
|
72
|
+
}
|
|
53
73
|
}
|
|
54
74
|
};
|