@aztec/p2p 0.0.0-test.0 → 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
|
@@ -6,23 +6,24 @@ function _ts_decorate(decorators, target, key, desc) {
|
|
|
6
6
|
}
|
|
7
7
|
import { INITIAL_L2_BLOCK_NUM } from '@aztec/constants';
|
|
8
8
|
import { createLogger } from '@aztec/foundation/log';
|
|
9
|
+
import { DateProvider } from '@aztec/foundation/timer';
|
|
10
|
+
import { getTimestampForSlot } from '@aztec/stdlib/epoch-helpers';
|
|
11
|
+
import { tryStop } from '@aztec/stdlib/interfaces/server';
|
|
9
12
|
import { Attributes, TraceableL2BlockStream, WithTracer, getTelemetryClient, trackSpan } from '@aztec/telemetry-client';
|
|
10
13
|
import { getP2PDefaultConfig } from '../config.js';
|
|
11
14
|
import { ReqRespSubProtocol } from '../services/reqresp/interface.js';
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
P2PClientState[P2PClientState["IDLE"] = 0] = "IDLE";
|
|
16
|
-
P2PClientState[P2PClientState["SYNCHING"] = 1] = "SYNCHING";
|
|
17
|
-
P2PClientState[P2PClientState["RUNNING"] = 2] = "RUNNING";
|
|
18
|
-
P2PClientState[P2PClientState["STOPPED"] = 3] = "STOPPED";
|
|
19
|
-
return P2PClientState;
|
|
20
|
-
}({});
|
|
15
|
+
import { chunkTxHashesRequest } from '../services/reqresp/protocols/tx.js';
|
|
16
|
+
import { TxProvider } from '../services/tx_provider.js';
|
|
17
|
+
import { P2PClientState } from './interface.js';
|
|
21
18
|
/**
|
|
22
19
|
* The P2P client implementation.
|
|
23
20
|
*/ export class P2PClient extends WithTracer {
|
|
21
|
+
store;
|
|
24
22
|
l2BlockSource;
|
|
25
23
|
p2pService;
|
|
24
|
+
txCollection;
|
|
25
|
+
_dateProvider;
|
|
26
|
+
telemetry;
|
|
26
27
|
log;
|
|
27
28
|
/** The JS promise that will be running to keep the client's data in sync. Can be interrupted if the client is stopped. */ runningPromise;
|
|
28
29
|
currentState;
|
|
@@ -30,71 +31,115 @@ import { ReqRespSubProtocol } from '../services/reqresp/interface.js';
|
|
|
30
31
|
syncResolve;
|
|
31
32
|
latestBlockNumberAtStart;
|
|
32
33
|
provenBlockNumberAtStart;
|
|
34
|
+
finalizedBlockNumberAtStart;
|
|
33
35
|
synchedBlockHashes;
|
|
34
36
|
synchedLatestBlockNumber;
|
|
35
37
|
synchedProvenBlockNumber;
|
|
38
|
+
synchedFinalizedBlockNumber;
|
|
39
|
+
synchedLatestSlot;
|
|
36
40
|
txPool;
|
|
37
41
|
attestationPool;
|
|
38
|
-
|
|
39
|
-
/** How many slots to keep proven txs for. */ keepProvenTxsFor;
|
|
42
|
+
config;
|
|
40
43
|
blockStream;
|
|
44
|
+
txProvider;
|
|
45
|
+
validatorAddresses;
|
|
41
46
|
/**
|
|
42
47
|
* In-memory P2P client constructor.
|
|
43
48
|
* @param store - The client's instance of the KV store.
|
|
44
49
|
* @param l2BlockSource - P2P client's source for fetching existing blocks.
|
|
45
50
|
* @param txPool - The client's instance of a transaction pool. Defaults to in-memory implementation.
|
|
46
51
|
* @param p2pService - The concrete instance of p2p networking to use.
|
|
47
|
-
* @param keepProvenTxsFor - How many blocks have to pass after a block is proven before its txs are deleted (zero to delete immediately once proven).
|
|
48
52
|
* @param log - A logger.
|
|
49
|
-
*/ constructor(_clientType, store, l2BlockSource, mempools, p2pService, config = {}, telemetry = getTelemetryClient(), log = createLogger('p2p')){
|
|
50
|
-
super(telemetry, 'P2PClient'), this.l2BlockSource = l2BlockSource, this.p2pService = p2pService, this.log = log, this.currentState =
|
|
51
|
-
|
|
53
|
+
*/ constructor(_clientType, store, l2BlockSource, mempools, p2pService, txCollection, config = {}, _dateProvider = new DateProvider(), telemetry = getTelemetryClient(), log = createLogger('p2p')){
|
|
54
|
+
super(telemetry, 'P2PClient'), this.store = store, this.l2BlockSource = l2BlockSource, this.p2pService = p2pService, this.txCollection = txCollection, this._dateProvider = _dateProvider, this.telemetry = telemetry, this.log = log, this.currentState = P2PClientState.IDLE, this.syncPromise = Promise.resolve(), this.syncResolve = undefined, this.latestBlockNumberAtStart = -1, this.provenBlockNumberAtStart = -1, this.finalizedBlockNumberAtStart = -1, this.validatorAddresses = [];
|
|
55
|
+
this.config = {
|
|
52
56
|
...getP2PDefaultConfig(),
|
|
53
57
|
...config
|
|
54
58
|
};
|
|
55
|
-
this.
|
|
56
|
-
this.
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
59
|
+
this.txPool = mempools.txPool;
|
|
60
|
+
this.attestationPool = mempools.attestationPool;
|
|
61
|
+
this.txProvider = new TxProvider(this.txCollection, this.txPool, this, this.log.createChild('tx-provider'), this.telemetry);
|
|
62
|
+
// Default to collecting all txs when we see a valid proposal
|
|
63
|
+
// This can be overridden by the validator client to attest, and it will call getTxsForBlockProposal on its own
|
|
64
|
+
// TODO(palla/txs): We should not trigger a request for txs on a proposal before fully validating it. We need to bring
|
|
65
|
+
// validator-client code into here so we can validate a proposal is reasonable.
|
|
66
|
+
this.registerBlockProposalHandler(async (block, sender)=>{
|
|
67
|
+
this.log.debug(`Received block proposal from ${sender.toString()}`);
|
|
68
|
+
// TODO(palla/txs): Need to subtract validatorReexecuteDeadlineMs from this deadline (see ValidatorClient.getReexecutionDeadline)
|
|
69
|
+
const constants = this.txCollection.getConstants();
|
|
70
|
+
const nextSlotTimestampSeconds = Number(getTimestampForSlot(block.slotNumber.toBigInt() + 1n, constants));
|
|
71
|
+
const deadline = new Date(nextSlotTimestampSeconds * 1000);
|
|
72
|
+
const parentBlock = await this.l2BlockSource.getBlockHeaderByArchive(block.payload.header.lastArchiveRoot);
|
|
73
|
+
if (!parentBlock) {
|
|
74
|
+
this.log.debug(`Cannot collect txs for proposal as parent block not found`);
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
const blockNumber = parentBlock.getBlockNumber() + 1;
|
|
78
|
+
await this.txProvider.getTxsForBlockProposal(block, blockNumber, {
|
|
79
|
+
pinnedPeer: sender,
|
|
80
|
+
deadline
|
|
81
|
+
});
|
|
82
|
+
return undefined;
|
|
62
83
|
});
|
|
84
|
+
// REFACTOR: Try replacing these with an L2TipsStore
|
|
63
85
|
this.synchedBlockHashes = store.openMap('p2p_pool_block_hashes');
|
|
64
86
|
this.synchedLatestBlockNumber = store.openSingleton('p2p_pool_last_l2_block');
|
|
65
87
|
this.synchedProvenBlockNumber = store.openSingleton('p2p_pool_last_proven_l2_block');
|
|
66
|
-
this.
|
|
67
|
-
this.
|
|
88
|
+
this.synchedFinalizedBlockNumber = store.openSingleton('p2p_pool_last_finalized_l2_block');
|
|
89
|
+
this.synchedLatestSlot = store.openSingleton('p2p_pool_last_l2_slot');
|
|
90
|
+
}
|
|
91
|
+
registerThisValidatorAddresses(addresses) {
|
|
92
|
+
this.validatorAddresses = [
|
|
93
|
+
...addresses
|
|
94
|
+
];
|
|
95
|
+
this.p2pService.registerThisValidatorAddresses(this.validatorAddresses);
|
|
96
|
+
}
|
|
97
|
+
clear() {
|
|
98
|
+
return this.store.clear();
|
|
68
99
|
}
|
|
69
100
|
isP2PClient() {
|
|
70
101
|
return true;
|
|
71
102
|
}
|
|
103
|
+
getTxProvider() {
|
|
104
|
+
return this.txProvider;
|
|
105
|
+
}
|
|
72
106
|
getPeers(includePending) {
|
|
73
107
|
return Promise.resolve(this.p2pService.getPeers(includePending));
|
|
74
108
|
}
|
|
75
109
|
getL2BlockHash(number) {
|
|
76
110
|
return this.synchedBlockHashes.getAsync(number);
|
|
77
111
|
}
|
|
112
|
+
updateP2PConfig(config) {
|
|
113
|
+
this.txPool.updateConfig(config);
|
|
114
|
+
this.p2pService.updateConfig(config);
|
|
115
|
+
return Promise.resolve();
|
|
116
|
+
}
|
|
78
117
|
async getL2Tips() {
|
|
79
118
|
const latestBlockNumber = await this.getSyncedLatestBlockNum();
|
|
80
119
|
let latestBlockHash;
|
|
81
120
|
const provenBlockNumber = await this.getSyncedProvenBlockNum();
|
|
82
121
|
let provenBlockHash;
|
|
122
|
+
const finalizedBlockNumber = await this.getSyncedFinalizedBlockNum();
|
|
123
|
+
let finalizedBlockHash;
|
|
83
124
|
if (latestBlockNumber > 0) {
|
|
84
125
|
latestBlockHash = await this.synchedBlockHashes.getAsync(latestBlockNumber);
|
|
85
126
|
if (typeof latestBlockHash === 'undefined') {
|
|
86
|
-
|
|
87
|
-
throw new Error();
|
|
127
|
+
throw new Error(`Block hash for latest block ${latestBlockNumber} not found in p2p client`);
|
|
88
128
|
}
|
|
89
129
|
}
|
|
90
130
|
if (provenBlockNumber > 0) {
|
|
91
131
|
provenBlockHash = await this.synchedBlockHashes.getAsync(provenBlockNumber);
|
|
92
132
|
if (typeof provenBlockHash === 'undefined') {
|
|
93
|
-
|
|
94
|
-
throw new Error();
|
|
133
|
+
throw new Error(`Block hash for proven block ${provenBlockNumber} not found in p2p client`);
|
|
95
134
|
}
|
|
96
135
|
}
|
|
97
|
-
|
|
136
|
+
if (finalizedBlockNumber > 0) {
|
|
137
|
+
finalizedBlockHash = await this.synchedBlockHashes.getAsync(finalizedBlockNumber);
|
|
138
|
+
if (typeof finalizedBlockHash === 'undefined') {
|
|
139
|
+
throw new Error(`Block hash for finalized block ${finalizedBlockNumber} not found in p2p client`);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
return {
|
|
98
143
|
latest: {
|
|
99
144
|
hash: latestBlockHash,
|
|
100
145
|
number: latestBlockNumber
|
|
@@ -104,10 +149,10 @@ import { ReqRespSubProtocol } from '../services/reqresp/interface.js';
|
|
|
104
149
|
number: provenBlockNumber
|
|
105
150
|
},
|
|
106
151
|
finalized: {
|
|
107
|
-
hash:
|
|
108
|
-
number:
|
|
152
|
+
hash: finalizedBlockHash,
|
|
153
|
+
number: finalizedBlockNumber
|
|
109
154
|
}
|
|
110
|
-
}
|
|
155
|
+
};
|
|
111
156
|
}
|
|
112
157
|
async handleBlockStreamEvent(event) {
|
|
113
158
|
this.log.debug(`Handling block stream event ${event.type}`);
|
|
@@ -116,16 +161,27 @@ import { ReqRespSubProtocol } from '../services/reqresp/interface.js';
|
|
|
116
161
|
await this.handleLatestL2Blocks(event.blocks);
|
|
117
162
|
break;
|
|
118
163
|
case 'chain-finalized':
|
|
119
|
-
|
|
164
|
+
{
|
|
165
|
+
// TODO (alexg): I think we can prune the block hashes map here
|
|
166
|
+
await this.setBlockHash(event.block);
|
|
167
|
+
const from = await this.getSyncedFinalizedBlockNum() + 1;
|
|
168
|
+
const limit = event.block.number - from + 1;
|
|
169
|
+
if (limit > 0) {
|
|
170
|
+
await this.handleFinalizedL2Blocks(await this.l2BlockSource.getBlocks(from, limit));
|
|
171
|
+
}
|
|
172
|
+
break;
|
|
173
|
+
}
|
|
120
174
|
case 'chain-proven':
|
|
121
175
|
{
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
await this.
|
|
176
|
+
await this.setBlockHash(event.block);
|
|
177
|
+
this.txCollection.stopCollectingForBlocksUpTo(event.block.number);
|
|
178
|
+
await this.synchedProvenBlockNumber.set(event.block.number);
|
|
125
179
|
break;
|
|
126
180
|
}
|
|
127
181
|
case 'chain-pruned':
|
|
128
|
-
await this.
|
|
182
|
+
await this.setBlockHash(event.block);
|
|
183
|
+
this.txCollection.stopCollectingForBlocksAfter(event.block.number);
|
|
184
|
+
await this.handlePruneL2Blocks(event.block.number);
|
|
129
185
|
break;
|
|
130
186
|
default:
|
|
131
187
|
{
|
|
@@ -134,6 +190,11 @@ import { ReqRespSubProtocol } from '../services/reqresp/interface.js';
|
|
|
134
190
|
}
|
|
135
191
|
}
|
|
136
192
|
}
|
|
193
|
+
async setBlockHash(block) {
|
|
194
|
+
if (block.hash !== undefined) {
|
|
195
|
+
await this.synchedBlockHashes.set(block.number, block.hash.toString());
|
|
196
|
+
}
|
|
197
|
+
}
|
|
137
198
|
#assertIsReady() {
|
|
138
199
|
// this.log.info('Checking if p2p client is ready, current state: ', this.currentState);
|
|
139
200
|
if (!this.isReady()) {
|
|
@@ -144,54 +205,102 @@ import { ReqRespSubProtocol } from '../services/reqresp/interface.js';
|
|
|
144
205
|
* Starts the P2P client.
|
|
145
206
|
* @returns An empty promise signalling the synching process.
|
|
146
207
|
*/ async start() {
|
|
147
|
-
if (this.currentState ===
|
|
208
|
+
if (this.currentState === P2PClientState.STOPPED) {
|
|
148
209
|
throw new Error('P2P client already stopped');
|
|
149
210
|
}
|
|
150
|
-
if (this.currentState !==
|
|
211
|
+
if (this.currentState !== P2PClientState.IDLE) {
|
|
151
212
|
return this.syncPromise;
|
|
152
213
|
}
|
|
153
214
|
// get the current latest block numbers
|
|
154
|
-
|
|
155
|
-
this.
|
|
215
|
+
const latestBlockNumbers = await this.l2BlockSource.getL2Tips();
|
|
216
|
+
this.latestBlockNumberAtStart = latestBlockNumbers.latest.number;
|
|
217
|
+
this.provenBlockNumberAtStart = latestBlockNumbers.proven.number;
|
|
218
|
+
this.finalizedBlockNumberAtStart = latestBlockNumbers.finalized.number;
|
|
156
219
|
const syncedLatestBlock = await this.getSyncedLatestBlockNum() + 1;
|
|
157
220
|
const syncedProvenBlock = await this.getSyncedProvenBlockNum() + 1;
|
|
158
|
-
|
|
159
|
-
if (
|
|
160
|
-
|
|
221
|
+
const syncedFinalizedBlock = await this.getSyncedFinalizedBlockNum() + 1;
|
|
222
|
+
if (await this.txPool.isEmpty() && (this.attestationPool === undefined || await this.attestationPool?.isEmpty())) {
|
|
223
|
+
// if mempools are empty, we don't care about syncing prior blocks
|
|
224
|
+
this.initBlockStream(this.latestBlockNumberAtStart);
|
|
225
|
+
this.setCurrentState(P2PClientState.RUNNING);
|
|
226
|
+
this.syncPromise = Promise.resolve();
|
|
227
|
+
await this.p2pService.start();
|
|
228
|
+
this.log.info(`Starting p2p client from block ${this.latestBlockNumberAtStart} with empty mempools`);
|
|
229
|
+
} else if (syncedLatestBlock <= this.latestBlockNumberAtStart || syncedProvenBlock <= this.provenBlockNumberAtStart || syncedFinalizedBlock <= this.finalizedBlockNumberAtStart) {
|
|
230
|
+
// if there are blocks to be retrieved, go to a synching state
|
|
231
|
+
// this gets resolved on `startServiceIfSynched`
|
|
232
|
+
this.initBlockStream();
|
|
233
|
+
this.setCurrentState(P2PClientState.SYNCHING);
|
|
161
234
|
this.syncPromise = new Promise((resolve)=>{
|
|
162
235
|
this.syncResolve = resolve;
|
|
163
236
|
});
|
|
164
|
-
this.log.
|
|
237
|
+
this.log.info(`Initiating p2p sync from ${syncedLatestBlock}`, {
|
|
238
|
+
syncedLatestBlock,
|
|
239
|
+
syncedProvenBlock,
|
|
240
|
+
syncedFinalizedBlock
|
|
241
|
+
});
|
|
165
242
|
} else {
|
|
166
243
|
// if no blocks to be retrieved, go straight to running
|
|
167
|
-
this.
|
|
244
|
+
this.initBlockStream();
|
|
245
|
+
this.setCurrentState(P2PClientState.RUNNING);
|
|
168
246
|
this.syncPromise = Promise.resolve();
|
|
169
247
|
await this.p2pService.start();
|
|
170
|
-
this.log.
|
|
248
|
+
this.log.info(`Starting P2P client synced to ${syncedLatestBlock}`, {
|
|
249
|
+
syncedLatestBlock,
|
|
250
|
+
syncedProvenBlock,
|
|
251
|
+
syncedFinalizedBlock
|
|
252
|
+
});
|
|
171
253
|
}
|
|
172
254
|
this.blockStream.start();
|
|
173
|
-
this.
|
|
255
|
+
await this.txCollection.start();
|
|
174
256
|
return this.syncPromise;
|
|
175
257
|
}
|
|
258
|
+
addReqRespSubProtocol(subProtocol, handler, validator) {
|
|
259
|
+
return this.p2pService.addReqRespSubProtocol(subProtocol, handler, validator);
|
|
260
|
+
}
|
|
261
|
+
initBlockStream(startingBlock) {
|
|
262
|
+
if (!this.blockStream) {
|
|
263
|
+
const { blockRequestBatchSize: batchSize, blockCheckIntervalMS: pollIntervalMS } = this.config;
|
|
264
|
+
this.blockStream = new TraceableL2BlockStream(this.l2BlockSource, this, this, this.telemetry.getTracer('P2PL2BlockStream'), 'P2PL2BlockStream', createLogger(`${this.log.module}:l2-block-stream`), {
|
|
265
|
+
batchSize,
|
|
266
|
+
pollIntervalMS,
|
|
267
|
+
startingBlock
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
}
|
|
176
271
|
/**
|
|
177
272
|
* Allows consumers to stop the instance of the P2P client.
|
|
178
273
|
* 'ready' will now return 'false' and the running promise that keeps the client synced is interrupted.
|
|
179
274
|
*/ async stop() {
|
|
180
275
|
this.log.debug('Stopping p2p client...');
|
|
276
|
+
await tryStop(this.txCollection);
|
|
277
|
+
this.log.debug('Stopped tx collection service');
|
|
181
278
|
await this.p2pService.stop();
|
|
182
279
|
this.log.debug('Stopped p2p service');
|
|
183
|
-
await this.blockStream
|
|
280
|
+
await this.blockStream?.stop();
|
|
184
281
|
this.log.debug('Stopped block downloader');
|
|
185
282
|
await this.runningPromise;
|
|
186
|
-
this.setCurrentState(
|
|
187
|
-
this.log.info('P2P client stopped
|
|
283
|
+
this.setCurrentState(P2PClientState.STOPPED);
|
|
284
|
+
this.log.info('P2P client stopped');
|
|
285
|
+
}
|
|
286
|
+
/** Triggers a sync to the archiver. Used for testing. */ async sync() {
|
|
287
|
+
this.initBlockStream();
|
|
288
|
+
await this.blockStream.sync();
|
|
188
289
|
}
|
|
189
290
|
broadcastProposal(proposal) {
|
|
190
291
|
this.log.verbose(`Broadcasting proposal for slot ${proposal.slotNumber.toNumber()} to peers`);
|
|
191
292
|
return this.p2pService.propagate(proposal);
|
|
192
293
|
}
|
|
193
294
|
async getAttestationsForSlot(slot, proposalId) {
|
|
194
|
-
return await this.attestationPool?.
|
|
295
|
+
return await (proposalId ? this.attestationPool?.getAttestationsForSlotAndProposal(slot, proposalId) : this.attestationPool?.getAttestationsForSlot(slot)) ?? [];
|
|
296
|
+
}
|
|
297
|
+
addAttestations(attestations) {
|
|
298
|
+
return this.attestationPool?.addAttestations(attestations) ?? Promise.resolve();
|
|
299
|
+
}
|
|
300
|
+
deleteAttestation(attestation) {
|
|
301
|
+
return this.attestationPool?.deleteAttestations([
|
|
302
|
+
attestation
|
|
303
|
+
]) ?? Promise.resolve();
|
|
195
304
|
}
|
|
196
305
|
// REVIEW: https://github.com/AztecProtocol/aztec-packages/issues/7963
|
|
197
306
|
// ^ This pattern is not my favorite (md)
|
|
@@ -199,52 +308,27 @@ import { ReqRespSubProtocol } from '../services/reqresp/interface.js';
|
|
|
199
308
|
this.p2pService.registerBlockReceivedCallback(handler);
|
|
200
309
|
}
|
|
201
310
|
/**
|
|
202
|
-
* Requests the transactions with the given hashes from the network.
|
|
203
|
-
*
|
|
204
|
-
* If a transaction can be retrieved, it will be returned, if not an undefined
|
|
205
|
-
* will be returned. In place.
|
|
206
|
-
*
|
|
207
|
-
* @param txHashes - The hashes of the transactions to request.
|
|
208
|
-
* @returns A promise that resolves to an array of transactions or undefined.
|
|
209
|
-
*/ async requestTxs(txHashes) {
|
|
210
|
-
const res = await this.p2pService.sendBatchRequest(ReqRespSubProtocol.TX, txHashes);
|
|
211
|
-
return Promise.resolve(res ?? []);
|
|
212
|
-
}
|
|
213
|
-
/**
|
|
214
|
-
* Uses the Request Response protocol to request a transaction from the network.
|
|
215
|
-
*
|
|
216
|
-
* If the underlying request response protocol fails, then we return undefined.
|
|
217
|
-
* If it succeeds then we add the transaction to our transaction pool and return.
|
|
218
|
-
*
|
|
219
|
-
* @param txHash - The hash of the transaction to request.
|
|
220
|
-
* @returns A promise that resolves to a transaction or undefined.
|
|
221
|
-
*/ async requestTxByHash(txHash) {
|
|
222
|
-
const tx = await this.p2pService.sendRequest(ReqRespSubProtocol.TX, txHash);
|
|
223
|
-
if (tx) {
|
|
224
|
-
this.log.debug(`Received tx ${txHash.toString()} from peer`);
|
|
225
|
-
await this.txPool.addTxs([
|
|
226
|
-
tx
|
|
227
|
-
]);
|
|
228
|
-
} else {
|
|
229
|
-
this.log.debug(`Failed to receive tx ${txHash.toString()} from peer`);
|
|
230
|
-
}
|
|
231
|
-
return tx;
|
|
232
|
-
}
|
|
233
|
-
/**
|
|
234
311
|
* Uses the batched Request Response protocol to request a set of transactions from the network.
|
|
235
|
-
*/ async requestTxsByHash(txHashes) {
|
|
236
|
-
const
|
|
237
|
-
|
|
312
|
+
*/ async requestTxsByHash(txHashes, pinnedPeerId) {
|
|
313
|
+
const timeoutMs = 8000; // Longer timeout for now
|
|
314
|
+
const maxRetryAttempts = 10; // Keep retrying within the timeout
|
|
315
|
+
const requests = chunkTxHashesRequest(txHashes);
|
|
316
|
+
const maxPeers = Math.min(Math.ceil(requests.length / 3), 10);
|
|
317
|
+
const txBatches = await this.p2pService.sendBatchRequest(ReqRespSubProtocol.TX, requests, pinnedPeerId, timeoutMs, maxPeers, maxRetryAttempts);
|
|
318
|
+
const txs = txBatches.flat();
|
|
319
|
+
if (txs.length > 0) {
|
|
320
|
+
await this.txPool.addTxs(txs);
|
|
321
|
+
}
|
|
238
322
|
const txHashesStr = txHashes.map((tx)=>tx.toString()).join(', ');
|
|
239
|
-
this.log.debug(`
|
|
323
|
+
this.log.debug(`Requested txs ${txHashesStr} (${txs.length} / ${txHashes.length}) from peers`);
|
|
324
|
+
// We return all transactions, even the not found ones to the caller, such they can handle missing items themselves.
|
|
240
325
|
return txs;
|
|
241
326
|
}
|
|
242
|
-
getPendingTxs() {
|
|
243
|
-
return
|
|
327
|
+
getPendingTxs(limit, after) {
|
|
328
|
+
return this.getTxs('pending', limit, after);
|
|
244
329
|
}
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
return pendingTxs.length;
|
|
330
|
+
getPendingTxCount() {
|
|
331
|
+
return this.txPool.getPendingTxCount();
|
|
248
332
|
}
|
|
249
333
|
async *iteratePendingTxs() {
|
|
250
334
|
for (const txHash of (await this.txPool.getPendingTxHashes())){
|
|
@@ -256,22 +340,50 @@ import { ReqRespSubProtocol } from '../services/reqresp/interface.js';
|
|
|
256
340
|
}
|
|
257
341
|
/**
|
|
258
342
|
* Returns all transactions in the transaction pool.
|
|
343
|
+
* @param filter - The type of txs to return
|
|
344
|
+
* @param limit - How many txs to return
|
|
345
|
+
* @param after - If paginating, the last known tx hash. Will return txs after this hash
|
|
259
346
|
* @returns An array of Txs.
|
|
260
|
-
*/ async getTxs(filter) {
|
|
347
|
+
*/ async getTxs(filter, limit, after) {
|
|
348
|
+
if (limit !== undefined && limit <= 0) {
|
|
349
|
+
throw new TypeError('limit must be greater than 0');
|
|
350
|
+
}
|
|
351
|
+
let txs = undefined;
|
|
352
|
+
let txHashes;
|
|
261
353
|
if (filter === 'all') {
|
|
262
|
-
|
|
354
|
+
txs = await this.txPool.getAllTxs();
|
|
355
|
+
txHashes = await Promise.all(txs.map((tx)=>tx.getTxHash()));
|
|
263
356
|
} else if (filter === 'mined') {
|
|
264
|
-
const
|
|
265
|
-
|
|
266
|
-
return minedTx.filter((tx)=>!!tx);
|
|
357
|
+
const minedTxHashes = await this.txPool.getMinedTxHashes();
|
|
358
|
+
txHashes = minedTxHashes.map(([txHash])=>txHash);
|
|
267
359
|
} else if (filter === 'pending') {
|
|
268
|
-
|
|
269
|
-
const pendingTxs = await Promise.all(pendingHashses.map((txHash)=>this.txPool.getTxByHash(txHash)));
|
|
270
|
-
return pendingTxs.filter((tx)=>!!tx);
|
|
360
|
+
txHashes = await this.txPool.getPendingTxHashes();
|
|
271
361
|
} else {
|
|
272
362
|
const _ = filter;
|
|
273
363
|
throw new Error(`Unknown filter ${filter}`);
|
|
274
364
|
}
|
|
365
|
+
let startIndex = 0;
|
|
366
|
+
let endIndex = undefined;
|
|
367
|
+
if (after) {
|
|
368
|
+
startIndex = txHashes.findIndex((txHash)=>after.equals(txHash));
|
|
369
|
+
// if we can't find the last tx in our set then return an empty array as pagination is no longer valid.
|
|
370
|
+
if (startIndex === -1) {
|
|
371
|
+
return [];
|
|
372
|
+
}
|
|
373
|
+
// increment by one because we don't want to return the same tx again
|
|
374
|
+
startIndex++;
|
|
375
|
+
}
|
|
376
|
+
if (limit !== undefined) {
|
|
377
|
+
endIndex = startIndex + limit;
|
|
378
|
+
}
|
|
379
|
+
txHashes = txHashes.slice(startIndex, endIndex);
|
|
380
|
+
if (txs) {
|
|
381
|
+
txs = txs.slice(startIndex, endIndex);
|
|
382
|
+
} else {
|
|
383
|
+
const maybeTxs = await Promise.all(txHashes.map((txHash)=>this.txPool.getTxByHash(txHash)));
|
|
384
|
+
txs = maybeTxs.filter((tx)=>!!tx);
|
|
385
|
+
}
|
|
386
|
+
return txs;
|
|
275
387
|
}
|
|
276
388
|
/**
|
|
277
389
|
* Returns a transaction in the transaction pool by its hash.
|
|
@@ -281,23 +393,21 @@ import { ReqRespSubProtocol } from '../services/reqresp/interface.js';
|
|
|
281
393
|
return this.txPool.getTxByHash(txHash);
|
|
282
394
|
}
|
|
283
395
|
/**
|
|
284
|
-
* Returns
|
|
285
|
-
*
|
|
286
|
-
* @
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
}
|
|
293
|
-
return this.requestTxByHash(txHash);
|
|
396
|
+
* Returns transactions in the transaction pool by hash.
|
|
397
|
+
* @param txHashes - Hashes of the transactions to look for.
|
|
398
|
+
* @returns The txs found, in the same order as the requested hashes. If a tx is not found, it will be undefined.
|
|
399
|
+
*/ getTxsByHashFromPool(txHashes) {
|
|
400
|
+
return this.txPool.getTxsByHash(txHashes);
|
|
401
|
+
}
|
|
402
|
+
hasTxsInPool(txHashes) {
|
|
403
|
+
return this.txPool.hasTxs(txHashes);
|
|
294
404
|
}
|
|
295
405
|
/**
|
|
296
406
|
* Returns transactions in the transaction pool by hash.
|
|
297
407
|
* If a transaction is not in the pool, it will be requested from the network.
|
|
298
408
|
* @param txHashes - Hashes of the transactions to look for.
|
|
299
|
-
* @returns The txs found, not
|
|
300
|
-
*/ async getTxsByHash(txHashes) {
|
|
409
|
+
* @returns The txs found, or undefined if not found in the order requested.
|
|
410
|
+
*/ async getTxsByHash(txHashes, pinnedPeerId) {
|
|
301
411
|
const txs = await Promise.all(txHashes.map((txHash)=>this.txPool.getTxByHash(txHash)));
|
|
302
412
|
const missingTxHashes = txs.map((tx, index)=>[
|
|
303
413
|
tx,
|
|
@@ -306,8 +416,27 @@ import { ReqRespSubProtocol } from '../services/reqresp/interface.js';
|
|
|
306
416
|
if (missingTxHashes.length === 0) {
|
|
307
417
|
return txs;
|
|
308
418
|
}
|
|
309
|
-
const missingTxs = await this.requestTxsByHash(missingTxHashes);
|
|
310
|
-
|
|
419
|
+
const missingTxs = await this.requestTxsByHash(missingTxHashes, pinnedPeerId);
|
|
420
|
+
// TODO: optimize
|
|
421
|
+
// Merge the found txs in order
|
|
422
|
+
const mergingTxs = txHashes.map((txHash)=>{
|
|
423
|
+
// Is it in the txs list from the mempool?
|
|
424
|
+
for (const tx of txs){
|
|
425
|
+
if (tx !== undefined && tx.getTxHash().equals(txHash)) {
|
|
426
|
+
return tx;
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
// Is it in the fetched missing txs?
|
|
430
|
+
// Note: this is an O(n^2) operation, but we expect the number of missing txs to be small.
|
|
431
|
+
for (const tx of missingTxs){
|
|
432
|
+
if (tx.getTxHash().equals(txHash)) {
|
|
433
|
+
return tx;
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
// Otherwise return undefined
|
|
437
|
+
return undefined;
|
|
438
|
+
});
|
|
439
|
+
return mergingTxs;
|
|
311
440
|
}
|
|
312
441
|
/**
|
|
313
442
|
* Returns an archived transaction in the transaction pool by its hash.
|
|
@@ -321,11 +450,20 @@ import { ReqRespSubProtocol } from '../services/reqresp/interface.js';
|
|
|
321
450
|
* @param tx - The tx to verify.
|
|
322
451
|
* @returns Empty promise.
|
|
323
452
|
**/ async sendTx(tx) {
|
|
324
|
-
this
|
|
325
|
-
await this.txPool.addTxs([
|
|
453
|
+
const addedCount = await this.addTxsToPool([
|
|
326
454
|
tx
|
|
327
455
|
]);
|
|
328
|
-
|
|
456
|
+
const txAddedSuccessfully = addedCount === 1;
|
|
457
|
+
if (txAddedSuccessfully) {
|
|
458
|
+
await this.p2pService.propagate(tx);
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
/**
|
|
462
|
+
* Adds transactions to the pool. Does not send to peers or validate the txs.
|
|
463
|
+
* @param txs - The transactions.
|
|
464
|
+
**/ async addTxsToPool(txs) {
|
|
465
|
+
this.#assertIsReady();
|
|
466
|
+
return await this.txPool.addTxs(txs);
|
|
329
467
|
}
|
|
330
468
|
/**
|
|
331
469
|
* Returns whether the given tx hash is flagged as pending or mined.
|
|
@@ -353,7 +491,7 @@ import { ReqRespSubProtocol } from '../services/reqresp/interface.js';
|
|
|
353
491
|
* Public function to check if the p2p client is fully synced and ready to receive txs.
|
|
354
492
|
* @returns True if the P2P client is ready to receive txs.
|
|
355
493
|
*/ isReady() {
|
|
356
|
-
return this.currentState ===
|
|
494
|
+
return this.currentState === P2PClientState.RUNNING;
|
|
357
495
|
}
|
|
358
496
|
/**
|
|
359
497
|
* Public function to check the latest block number that the P2P client is synced to.
|
|
@@ -367,6 +505,12 @@ import { ReqRespSubProtocol } from '../services/reqresp/interface.js';
|
|
|
367
505
|
*/ async getSyncedProvenBlockNum() {
|
|
368
506
|
return await this.synchedProvenBlockNumber.getAsync() ?? INITIAL_L2_BLOCK_NUM - 1;
|
|
369
507
|
}
|
|
508
|
+
async getSyncedFinalizedBlockNum() {
|
|
509
|
+
return await this.synchedFinalizedBlockNumber.getAsync() ?? INITIAL_L2_BLOCK_NUM - 1;
|
|
510
|
+
}
|
|
511
|
+
/** Returns latest L2 slot for which we have seen an L2 block. */ async getSyncedLatestSlot() {
|
|
512
|
+
return await this.synchedLatestSlot.getAsync() ?? BigInt(0);
|
|
513
|
+
}
|
|
370
514
|
/**
|
|
371
515
|
* Method to check the status the p2p client.
|
|
372
516
|
* @returns Information about p2p client status: state & syncedToBlockNum.
|
|
@@ -388,18 +532,7 @@ import { ReqRespSubProtocol } from '../services/reqresp/interface.js';
|
|
|
388
532
|
*/ async markTxsAsMinedFromBlocks(blocks) {
|
|
389
533
|
for (const block of blocks){
|
|
390
534
|
const txHashes = block.body.txEffects.map((txEffect)=>txEffect.txHash);
|
|
391
|
-
await this.txPool.markAsMined(txHashes, block.
|
|
392
|
-
}
|
|
393
|
-
}
|
|
394
|
-
/**
|
|
395
|
-
* Deletes txs from these blocks.
|
|
396
|
-
* @param blocks - A list of existing blocks with txs that the P2P client needs to ensure the tx pool is reconciled with.
|
|
397
|
-
* @returns Empty promise.
|
|
398
|
-
*/ async deleteTxsFromBlocks(blocks) {
|
|
399
|
-
this.log.debug(`Deleting txs from blocks ${blocks[0].number} to ${blocks[blocks.length - 1].number}`);
|
|
400
|
-
for (const block of blocks){
|
|
401
|
-
const txHashes = block.body.txEffects.map((txEffect)=>txEffect.txHash);
|
|
402
|
-
await this.txPool.deleteTxs(txHashes);
|
|
535
|
+
await this.txPool.markAsMined(txHashes, block.getBlockHeader());
|
|
403
536
|
}
|
|
404
537
|
}
|
|
405
538
|
/**
|
|
@@ -410,76 +543,123 @@ import { ReqRespSubProtocol } from '../services/reqresp/interface.js';
|
|
|
410
543
|
if (!blocks.length) {
|
|
411
544
|
return Promise.resolve();
|
|
412
545
|
}
|
|
413
|
-
await this.markTxsAsMinedFromBlocks(blocks);
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
await
|
|
417
|
-
|
|
546
|
+
await this.markTxsAsMinedFromBlocks(blocks.map((b)=>b.block));
|
|
547
|
+
await this.startCollectingMissingTxs(blocks.map((b)=>b.block));
|
|
548
|
+
const lastBlock = blocks.at(-1).block;
|
|
549
|
+
await Promise.all(blocks.map(async (block)=>this.setBlockHash({
|
|
550
|
+
number: block.block.number,
|
|
551
|
+
hash: await block.block.hash().then((h)=>h.toString())
|
|
552
|
+
})));
|
|
553
|
+
await this.synchedLatestBlockNumber.set(lastBlock.number);
|
|
554
|
+
await this.synchedLatestSlot.set(lastBlock.header.getSlot());
|
|
555
|
+
this.log.verbose(`Synched to latest block ${lastBlock.number}`);
|
|
418
556
|
await this.startServiceIfSynched();
|
|
419
557
|
}
|
|
558
|
+
/** Request txs for unproven blocks so the prover node has more chances to get them. */ async startCollectingMissingTxs(blocks) {
|
|
559
|
+
try {
|
|
560
|
+
// TODO(#15435): If the archiver has lagged behind L1, the reported proven block number may
|
|
561
|
+
// be much lower than the actual one, and it does not update until the pending chain is
|
|
562
|
+
// fully synced. This could lead to a ton of tx collection requests for blocks that
|
|
563
|
+
// are already proven, but the archiver has not yet updated its state. Until this is properly
|
|
564
|
+
// fixed, it is mitigated by the expiration date of collection requests, which depends on
|
|
565
|
+
// the slot number of the block.
|
|
566
|
+
const provenBlockNumber = await this.l2BlockSource.getProvenBlockNumber();
|
|
567
|
+
const unprovenBlocks = blocks.filter((block)=>block.number > provenBlockNumber);
|
|
568
|
+
for (const block of unprovenBlocks){
|
|
569
|
+
const txHashes = block.body.txEffects.map((txEffect)=>txEffect.txHash);
|
|
570
|
+
const missingTxHashes = await this.txPool.hasTxs(txHashes).then((availability)=>txHashes.filter((_, index)=>!availability[index]));
|
|
571
|
+
if (missingTxHashes.length > 0) {
|
|
572
|
+
this.log.verbose(`Starting collection of ${missingTxHashes.length} missing txs for unproven mined block ${block.number}`, {
|
|
573
|
+
missingTxHashes,
|
|
574
|
+
blockNumber: block.number,
|
|
575
|
+
blockHash: await block.hash().then((h)=>h.toString())
|
|
576
|
+
});
|
|
577
|
+
this.txCollection.startCollecting(block, missingTxHashes);
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
} catch (err) {
|
|
581
|
+
this.log.error(`Error while starting collection of missing txs for unproven blocks`, err);
|
|
582
|
+
}
|
|
583
|
+
}
|
|
420
584
|
/**
|
|
421
|
-
* Handles new
|
|
422
|
-
* @param blocks - A list of
|
|
585
|
+
* Handles new finalized blocks by deleting the txs and attestations in them.
|
|
586
|
+
* @param blocks - A list of finalized L2 blocks.
|
|
423
587
|
* @returns Empty promise.
|
|
424
|
-
*/ async
|
|
588
|
+
*/ async handleFinalizedL2Blocks(blocks) {
|
|
425
589
|
if (!blocks.length) {
|
|
426
590
|
return Promise.resolve();
|
|
427
591
|
}
|
|
428
|
-
|
|
592
|
+
this.log.debug(`Handling finalized blocks ${blocks.length} up to ${blocks.at(-1)?.number}`);
|
|
429
593
|
const lastBlockNum = blocks[blocks.length - 1].number;
|
|
430
|
-
const lastBlockSlot = blocks[blocks.length - 1].header.
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
}
|
|
441
|
-
// We delete attestations older than the last block slot minus the number of slots we want to keep in the pool.
|
|
442
|
-
const lastBlockSlotMinusKeepAttestationsInPoolFor = lastBlockSlot - BigInt(this.keepAttestationsInPoolFor);
|
|
443
|
-
if (lastBlockSlotMinusKeepAttestationsInPoolFor >= BigInt(INITIAL_L2_BLOCK_NUM)) {
|
|
444
|
-
await this.attestationPool?.deleteAttestationsOlderThan(lastBlockSlotMinusKeepAttestationsInPoolFor);
|
|
445
|
-
}
|
|
446
|
-
await this.synchedProvenBlockNumber.set(lastBlockNum);
|
|
447
|
-
this.log.debug(`Synched to proven block ${lastBlockNum}`);
|
|
594
|
+
const lastBlockSlot = blocks[blocks.length - 1].header.getSlot();
|
|
595
|
+
const txHashes = blocks.flatMap((block)=>block.body.txEffects.map((txEffect)=>txEffect.txHash));
|
|
596
|
+
this.log.debug(`Deleting ${txHashes.length} txs from pool from finalized blocks up to ${lastBlockNum}`);
|
|
597
|
+
await this.txPool.deleteTxs(txHashes, {
|
|
598
|
+
permanently: true
|
|
599
|
+
});
|
|
600
|
+
await this.txPool.cleanupDeletedMinedTxs(lastBlockNum);
|
|
601
|
+
await this.attestationPool?.deleteAttestationsOlderThan(lastBlockSlot);
|
|
602
|
+
await this.synchedFinalizedBlockNumber.set(lastBlockNum);
|
|
603
|
+
this.log.debug(`Synched to finalized block ${lastBlockNum} at slot ${lastBlockSlot}`);
|
|
448
604
|
await this.startServiceIfSynched();
|
|
449
605
|
}
|
|
450
606
|
/**
|
|
451
607
|
* Updates the tx pool after a chain prune.
|
|
452
608
|
* @param latestBlock - The block number the chain was pruned to.
|
|
453
609
|
*/ async handlePruneL2Blocks(latestBlock) {
|
|
454
|
-
const txsToDelete =
|
|
610
|
+
const txsToDelete = new Map();
|
|
611
|
+
const minedTxs = await this.txPool.getMinedTxHashes();
|
|
612
|
+
// Find transactions that reference pruned blocks in their historical header
|
|
455
613
|
for (const tx of (await this.txPool.getAllTxs())){
|
|
456
614
|
// every tx that's been generated against a block that has now been pruned is no longer valid
|
|
457
|
-
if (tx.data.constants.
|
|
458
|
-
|
|
615
|
+
if (tx.data.constants.anchorBlockHeader.globalVariables.blockNumber > latestBlock) {
|
|
616
|
+
const txHash = tx.getTxHash();
|
|
617
|
+
txsToDelete.set(txHash.toString(), txHash);
|
|
459
618
|
}
|
|
460
619
|
}
|
|
461
|
-
this.log.info(`Detected chain prune. Removing
|
|
620
|
+
this.log.info(`Detected chain prune. Removing ${txsToDelete.size} txs built against pruned blocks.`, {
|
|
621
|
+
newLatestBlock: latestBlock,
|
|
622
|
+
previousLatestBlock: await this.getSyncedLatestBlockNum(),
|
|
623
|
+
txsToDelete: Array.from(txsToDelete.keys())
|
|
624
|
+
});
|
|
462
625
|
// delete invalid txs (both pending and mined)
|
|
463
|
-
await this.txPool.deleteTxs(txsToDelete);
|
|
626
|
+
await this.txPool.deleteTxs(Array.from(txsToDelete.values()));
|
|
464
627
|
// everything left in the mined set was built against a block on the proven chain so its still valid
|
|
465
|
-
// move back to pending the txs that were reorged out of the chain
|
|
628
|
+
// move back to pending the txs that were reorged out of the chain, unless txPoolDeleteTxsAfterReorg is set,
|
|
629
|
+
// in which case we clean them up to avoid potential reorg loops
|
|
466
630
|
// NOTE: we can't move _all_ txs back to pending because the tx pool could keep hold of mined txs for longer
|
|
467
631
|
// (see this.keepProvenTxsFor)
|
|
468
|
-
const
|
|
469
|
-
for (const [txHash, blockNumber] of
|
|
470
|
-
|
|
471
|
-
|
|
632
|
+
const minedTxsFromReorg = [];
|
|
633
|
+
for (const [txHash, blockNumber] of minedTxs){
|
|
634
|
+
// We keep the txsToDelete out of this list as they have already been deleted above
|
|
635
|
+
if (blockNumber > latestBlock && !txsToDelete.has(txHash.toString())) {
|
|
636
|
+
minedTxsFromReorg.push(txHash);
|
|
472
637
|
}
|
|
473
638
|
}
|
|
474
|
-
this.
|
|
475
|
-
|
|
639
|
+
if (this.config.txPoolDeleteTxsAfterReorg) {
|
|
640
|
+
this.log.info(`Deleting ${minedTxsFromReorg.length} mined txs from reorg`);
|
|
641
|
+
await this.txPool.deleteTxs(minedTxsFromReorg);
|
|
642
|
+
} else {
|
|
643
|
+
this.log.info(`Moving ${minedTxsFromReorg.length} mined txs from reorg back to pending`);
|
|
644
|
+
await this.txPool.markMinedAsPending(minedTxsFromReorg);
|
|
645
|
+
}
|
|
476
646
|
await this.synchedLatestBlockNumber.set(latestBlock);
|
|
477
647
|
// no need to update block hashes, as they will be updated as new blocks are added
|
|
478
648
|
}
|
|
479
649
|
async startServiceIfSynched() {
|
|
480
|
-
if (this.currentState
|
|
481
|
-
|
|
482
|
-
|
|
650
|
+
if (this.currentState !== P2PClientState.SYNCHING) {
|
|
651
|
+
return;
|
|
652
|
+
}
|
|
653
|
+
const syncedFinalizedBlock = await this.getSyncedFinalizedBlockNum();
|
|
654
|
+
const syncedProvenBlock = await this.getSyncedProvenBlockNum();
|
|
655
|
+
const syncedLatestBlock = await this.getSyncedLatestBlockNum();
|
|
656
|
+
if (syncedLatestBlock >= this.latestBlockNumberAtStart && syncedProvenBlock >= this.provenBlockNumberAtStart && syncedFinalizedBlock >= this.finalizedBlockNumberAtStart) {
|
|
657
|
+
this.log.info(`Completed P2P client sync to block ${syncedLatestBlock}. Starting service.`, {
|
|
658
|
+
syncedLatestBlock,
|
|
659
|
+
syncedProvenBlock,
|
|
660
|
+
syncedFinalizedBlock
|
|
661
|
+
});
|
|
662
|
+
this.setCurrentState(P2PClientState.RUNNING);
|
|
483
663
|
if (this.syncResolve !== undefined) {
|
|
484
664
|
this.syncResolve();
|
|
485
665
|
await this.p2pService.start();
|
|
@@ -494,10 +674,21 @@ import { ReqRespSubProtocol } from '../services/reqresp/interface.js';
|
|
|
494
674
|
this.currentState = newState;
|
|
495
675
|
this.log.debug(`Moved from state ${P2PClientState[oldState]} to ${P2PClientState[this.currentState]}`);
|
|
496
676
|
}
|
|
677
|
+
validate(txs) {
|
|
678
|
+
return this.p2pService.validate(txs);
|
|
679
|
+
}
|
|
680
|
+
/**
|
|
681
|
+
* Marks transactions as non-evictable in the pool.
|
|
682
|
+
* @param txHashes - Hashes of the transactions to mark as non-evictable.
|
|
683
|
+
*/ markTxsAsNonEvictable(txHashes) {
|
|
684
|
+
return this.txPool.markTxsAsNonEvictable(txHashes);
|
|
685
|
+
}
|
|
686
|
+
handleAuthRequestFromPeer(authRequest, peerId) {
|
|
687
|
+
return this.p2pService.handleAuthRequestFromPeer(authRequest, peerId);
|
|
688
|
+
}
|
|
497
689
|
}
|
|
498
690
|
_ts_decorate([
|
|
499
691
|
trackSpan('p2pClient.broadcastProposal', async (proposal)=>({
|
|
500
|
-
[Attributes.BLOCK_NUMBER]: proposal.blockNumber.toNumber(),
|
|
501
692
|
[Attributes.SLOT_NUMBER]: proposal.slotNumber.toNumber(),
|
|
502
693
|
[Attributes.BLOCK_ARCHIVE]: proposal.archive.toString(),
|
|
503
694
|
[Attributes.P2P_ID]: (await proposal.p2pMessageIdentifier()).toString()
|