@aztec/p2p 0.0.1-commit.4d3c002 → 0.0.1-commit.4d9804df
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -6
- package/dest/bootstrap/bootstrap.d.ts +1 -1
- package/dest/bootstrap/bootstrap.d.ts.map +1 -1
- package/dest/bootstrap/bootstrap.js +22 -6
- package/dest/client/factory.d.ts +4 -3
- package/dest/client/factory.d.ts.map +1 -1
- package/dest/client/factory.js +33 -24
- package/dest/client/interface.d.ts +40 -10
- package/dest/client/interface.d.ts.map +1 -1
- package/dest/client/p2p_client.d.ts +32 -18
- package/dest/client/p2p_client.d.ts.map +1 -1
- package/dest/client/p2p_client.js +97 -51
- package/dest/config.d.ts +143 -107
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +72 -26
- package/dest/errors/reqresp.error.d.ts +9 -16
- package/dest/errors/reqresp.error.d.ts.map +1 -1
- package/dest/errors/reqresp.error.js +10 -17
- package/dest/mem_pools/attestation_pool/attestation_pool.d.ts +98 -56
- package/dest/mem_pools/attestation_pool/attestation_pool.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/attestation_pool.js +270 -198
- package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.d.ts +1 -1
- package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.js +218 -59
- package/dest/mem_pools/attestation_pool/mocks.d.ts +1 -1
- package/dest/mem_pools/attestation_pool/mocks.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/mocks.js +6 -4
- package/dest/mem_pools/instrumentation.d.ts +9 -4
- package/dest/mem_pools/instrumentation.d.ts.map +1 -1
- package/dest/mem_pools/instrumentation.js +28 -9
- package/dest/mem_pools/tx_pool_v2/archive/tx_archive.d.ts +1 -5
- package/dest/mem_pools/tx_pool_v2/archive/tx_archive.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/archive/tx_archive.js +1 -7
- package/dest/mem_pools/tx_pool_v2/deleted_pool.d.ts +3 -3
- package/dest/mem_pools/tx_pool_v2/deleted_pool.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/deleted_pool.js +6 -6
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.js +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/index.d.ts +2 -1
- package/dest/mem_pools/tx_pool_v2/eviction/index.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/index.js +1 -0
- package/dest/mem_pools/tx_pool_v2/eviction/insufficient_fee_per_gas_eviction_rule.d.ts +16 -0
- package/dest/mem_pools/tx_pool_v2/eviction/insufficient_fee_per_gas_eviction_rule.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/eviction/insufficient_fee_per_gas_eviction_rule.js +62 -0
- package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.js +2 -2
- package/dest/mem_pools/tx_pool_v2/interfaces.d.ts +33 -5
- package/dest/mem_pools/tx_pool_v2/interfaces.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/interfaces.js +2 -1
- package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts +5 -2
- package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/tx_metadata.js +8 -5
- package/dest/mem_pools/tx_pool_v2/tx_pool_indices.d.ts +15 -1
- package/dest/mem_pools/tx_pool_v2/tx_pool_indices.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/tx_pool_indices.js +31 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts +9 -3
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2.js +19 -8
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts +17 -4
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.js +208 -118
- package/dest/msg_validators/attestation_validator/attestation_validator.d.ts +10 -3
- package/dest/msg_validators/attestation_validator/attestation_validator.d.ts.map +1 -1
- package/dest/msg_validators/attestation_validator/attestation_validator.js +38 -16
- package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.d.ts +7 -3
- package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.d.ts.map +1 -1
- package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.js +4 -5
- package/dest/msg_validators/proposal_validator/block_proposal_validator.d.ts +8 -3
- package/dest/msg_validators/proposal_validator/block_proposal_validator.d.ts.map +1 -1
- package/dest/msg_validators/proposal_validator/block_proposal_validator.js +2 -2
- package/dest/msg_validators/proposal_validator/checkpoint_proposal_validator.d.ts +8 -3
- package/dest/msg_validators/proposal_validator/checkpoint_proposal_validator.d.ts.map +1 -1
- package/dest/msg_validators/proposal_validator/checkpoint_proposal_validator.js +8 -2
- package/dest/msg_validators/proposal_validator/proposal_validator.d.ts +25 -3
- package/dest/msg_validators/proposal_validator/proposal_validator.d.ts.map +1 -1
- package/dest/msg_validators/proposal_validator/proposal_validator.js +85 -15
- package/dest/msg_validators/tx_validator/aggregate_tx_validator.d.ts +1 -1
- package/dest/msg_validators/tx_validator/aggregate_tx_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/aggregate_tx_validator.js +8 -15
- package/dest/msg_validators/tx_validator/allowed_public_setup.js +3 -3
- package/dest/msg_validators/tx_validator/archive_cache.js +1 -1
- package/dest/msg_validators/tx_validator/cached_tx_validator.d.ts +15 -0
- package/dest/msg_validators/tx_validator/cached_tx_validator.d.ts.map +1 -0
- package/dest/msg_validators/tx_validator/cached_tx_validator.js +19 -0
- package/dest/msg_validators/tx_validator/data_validator.d.ts +2 -1
- package/dest/msg_validators/tx_validator/data_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/data_validator.js +1 -0
- package/dest/msg_validators/tx_validator/factory.d.ts +14 -15
- package/dest/msg_validators/tx_validator/factory.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/factory.js +29 -16
- package/dest/msg_validators/tx_validator/gas_validator.d.ts +47 -10
- package/dest/msg_validators/tx_validator/gas_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/gas_validator.js +65 -48
- package/dest/msg_validators/tx_validator/index.d.ts +3 -1
- package/dest/msg_validators/tx_validator/index.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/index.js +2 -0
- package/dest/msg_validators/tx_validator/phases_validator.js +2 -2
- package/dest/msg_validators/tx_validator/tx_proof_validator.d.ts +2 -1
- package/dest/msg_validators/tx_validator/tx_proof_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/tx_proof_validator.js +2 -0
- package/dest/msg_validators/tx_validator/tx_validation_cache.d.ts +48 -0
- package/dest/msg_validators/tx_validator/tx_validation_cache.d.ts.map +1 -0
- package/dest/msg_validators/tx_validator/tx_validation_cache.js +68 -0
- package/dest/services/data_store.d.ts +1 -1
- package/dest/services/data_store.d.ts.map +1 -1
- package/dest/services/data_store.js +5 -5
- package/dest/services/discv5/discV5_service.d.ts +13 -2
- package/dest/services/discv5/discV5_service.d.ts.map +1 -1
- package/dest/services/discv5/discV5_service.js +117 -24
- package/dest/services/discv5/persisted_enr_store.d.ts +38 -0
- package/dest/services/discv5/persisted_enr_store.d.ts.map +1 -0
- package/dest/services/discv5/persisted_enr_store.js +145 -0
- package/dest/services/dummy_service.d.ts +15 -17
- package/dest/services/dummy_service.d.ts.map +1 -1
- package/dest/services/dummy_service.js +13 -18
- package/dest/services/encoding.d.ts +19 -6
- package/dest/services/encoding.d.ts.map +1 -1
- package/dest/services/encoding.js +25 -15
- package/dest/services/gossipsub/topic_score_params.d.ts +6 -12
- package/dest/services/gossipsub/topic_score_params.d.ts.map +1 -1
- package/dest/services/gossipsub/topic_score_params.js +4 -14
- package/dest/services/libp2p/instrumentation.d.ts +3 -1
- package/dest/services/libp2p/instrumentation.d.ts.map +1 -1
- package/dest/services/libp2p/instrumentation.js +14 -0
- package/dest/services/libp2p/libp2p_service.d.ts +31 -38
- package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
- package/dest/services/libp2p/libp2p_service.js +268 -248
- package/dest/services/peer-manager/peer_manager.d.ts +15 -2
- package/dest/services/peer-manager/peer_manager.d.ts.map +1 -1
- package/dest/services/peer-manager/peer_manager.js +59 -17
- package/dest/services/peer-manager/peer_scoring.d.ts +30 -1
- package/dest/services/peer-manager/peer_scoring.d.ts.map +1 -1
- package/dest/services/peer-manager/peer_scoring.js +74 -3
- package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts +1 -8
- package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts.map +1 -1
- package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.js +35 -44
- package/dest/services/reqresp/batch-tx-requester/interface.d.ts +8 -5
- package/dest/services/reqresp/batch-tx-requester/interface.d.ts.map +1 -1
- package/dest/services/reqresp/batch-tx-requester/tx_validator.d.ts +5 -14
- package/dest/services/reqresp/batch-tx-requester/tx_validator.d.ts.map +1 -1
- package/dest/services/reqresp/batch-tx-requester/tx_validator.js +6 -20
- package/dest/services/reqresp/config.d.ts +15 -3
- package/dest/services/reqresp/config.d.ts.map +1 -1
- package/dest/services/reqresp/config.js +11 -0
- package/dest/services/reqresp/interface.d.ts +16 -18
- package/dest/services/reqresp/interface.d.ts.map +1 -1
- package/dest/services/reqresp/interface.js +10 -20
- package/dest/services/reqresp/metrics.d.ts +1 -1
- package/dest/services/reqresp/metrics.d.ts.map +1 -1
- package/dest/services/reqresp/metrics.js +0 -1
- package/dest/services/reqresp/protocols/block_txs/bitvector.d.ts +4 -3
- package/dest/services/reqresp/protocols/block_txs/bitvector.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/block_txs/bitvector.js +3 -2
- package/dest/services/reqresp/protocols/block_txs/block_txs_handler.d.ts +1 -1
- package/dest/services/reqresp/protocols/block_txs/block_txs_handler.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/block_txs/block_txs_handler.js +31 -28
- package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.d.ts +12 -7
- package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.js +42 -24
- package/dest/services/reqresp/protocols/index.d.ts +1 -2
- package/dest/services/reqresp/protocols/index.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/index.js +0 -1
- package/dest/services/reqresp/protocols/tx.d.ts +1 -1
- package/dest/services/reqresp/protocols/tx.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/tx.js +1 -3
- package/dest/services/reqresp/rate-limiter/rate_limits.d.ts +1 -1
- package/dest/services/reqresp/rate-limiter/rate_limits.d.ts.map +1 -1
- package/dest/services/reqresp/rate-limiter/rate_limits.js +3 -13
- package/dest/services/reqresp/reqresp.d.ts +7 -29
- package/dest/services/reqresp/reqresp.d.ts.map +1 -1
- package/dest/services/reqresp/reqresp.js +59 -209
- package/dest/services/service.d.ts +21 -13
- package/dest/services/service.d.ts.map +1 -1
- package/dest/services/tx_collection/config.d.ts +2 -23
- package/dest/services/tx_collection/config.d.ts.map +1 -1
- package/dest/services/tx_collection/config.js +2 -55
- package/dest/services/tx_collection/file_store_tx_collection.d.ts +12 -28
- package/dest/services/tx_collection/file_store_tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/file_store_tx_collection.js +43 -83
- package/dest/services/tx_collection/index.d.ts +2 -3
- package/dest/services/tx_collection/index.d.ts.map +1 -1
- package/dest/services/tx_collection/index.js +0 -1
- package/dest/services/tx_collection/instrumentation.d.ts +1 -1
- package/dest/services/tx_collection/instrumentation.d.ts.map +1 -1
- package/dest/services/tx_collection/instrumentation.js +0 -2
- package/dest/services/tx_collection/tx_collection.d.ts +35 -51
- package/dest/services/tx_collection/tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/tx_collection.js +275 -119
- package/dest/services/tx_collection/tx_collection_sink.d.ts +1 -1
- package/dest/services/tx_collection/tx_collection_sink.js +2 -2
- package/dest/services/tx_collection/tx_source.d.ts +1 -1
- package/dest/services/tx_collection/tx_source.d.ts.map +1 -1
- package/dest/services/tx_collection/tx_source.js +4 -1
- package/dest/services/tx_file_store/tx_file_store.d.ts +1 -3
- package/dest/services/tx_file_store/tx_file_store.d.ts.map +1 -1
- package/dest/services/tx_file_store/tx_file_store.js +4 -14
- package/dest/services/tx_provider.d.ts +3 -1
- package/dest/services/tx_provider.d.ts.map +1 -1
- package/dest/services/tx_provider.js +3 -0
- package/dest/test-helpers/make-test-p2p-clients.d.ts +1 -1
- package/dest/test-helpers/make-test-p2p-clients.d.ts.map +1 -1
- package/dest/test-helpers/make-test-p2p-clients.js +5 -2
- package/dest/test-helpers/mock-pubsub.d.ts +16 -9
- package/dest/test-helpers/mock-pubsub.d.ts.map +1 -1
- package/dest/test-helpers/mock-pubsub.js +36 -43
- package/dest/test-helpers/reqresp-nodes.d.ts +4 -5
- package/dest/test-helpers/reqresp-nodes.d.ts.map +1 -1
- package/dest/test-helpers/reqresp-nodes.js +11 -17
- package/dest/test-helpers/test_tx_provider.d.ts +3 -1
- package/dest/test-helpers/test_tx_provider.d.ts.map +1 -1
- package/dest/test-helpers/test_tx_provider.js +3 -0
- package/dest/test-helpers/testbench-utils.d.ts +15 -14
- package/dest/test-helpers/testbench-utils.d.ts.map +1 -1
- package/dest/test-helpers/testbench-utils.js +28 -13
- package/dest/testbench/p2p_client_testbench_worker.d.ts +3 -5
- package/dest/testbench/p2p_client_testbench_worker.d.ts.map +1 -1
- package/dest/testbench/p2p_client_testbench_worker.js +60 -27
- package/dest/testbench/worker_client_manager.d.ts +10 -6
- package/dest/testbench/worker_client_manager.d.ts.map +1 -1
- package/dest/testbench/worker_client_manager.js +51 -8
- package/dest/util.d.ts +7 -6
- package/dest/util.d.ts.map +1 -1
- package/dest/util.js +39 -10
- package/dest/versioning.d.ts +3 -6
- package/dest/versioning.d.ts.map +1 -1
- package/dest/versioning.js +3 -24
- package/package.json +16 -16
- package/src/bootstrap/bootstrap.ts +17 -3
- package/src/client/factory.ts +49 -25
- package/src/client/interface.ts +35 -16
- package/src/client/p2p_client.ts +116 -85
- package/src/client/test/{tx_proposal_collector/README.md → p2p_client.batch_tx_requester.bench.README.md} +23 -53
- package/src/config.ts +146 -34
- package/src/errors/reqresp.error.ts +13 -19
- package/src/mem_pools/attestation_pool/attestation_pool.ts +325 -242
- package/src/mem_pools/attestation_pool/attestation_pool_test_suite.ts +238 -63
- package/src/mem_pools/attestation_pool/mocks.ts +13 -8
- package/src/mem_pools/instrumentation.ts +18 -12
- package/src/mem_pools/tx_pool_v2/archive/tx_archive.ts +1 -9
- package/src/mem_pools/tx_pool_v2/deleted_pool.ts +7 -7
- package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.ts +1 -1
- package/src/mem_pools/tx_pool_v2/eviction/index.ts +1 -0
- package/src/mem_pools/tx_pool_v2/eviction/insufficient_fee_per_gas_eviction_rule.ts +65 -0
- package/src/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.ts +3 -3
- package/src/mem_pools/tx_pool_v2/interfaces.ts +31 -4
- package/src/mem_pools/tx_pool_v2/tx_metadata.ts +13 -7
- package/src/mem_pools/tx_pool_v2/tx_pool_indices.ts +35 -0
- package/src/mem_pools/tx_pool_v2/tx_pool_v2.ts +22 -8
- package/src/mem_pools/tx_pool_v2/tx_pool_v2_impl.ts +233 -123
- package/src/msg_validators/attestation_validator/attestation_validator.ts +46 -15
- package/src/msg_validators/attestation_validator/fisherman_attestation_validator.ts +15 -7
- package/src/msg_validators/proposal_validator/block_proposal_validator.ts +15 -3
- package/src/msg_validators/proposal_validator/checkpoint_proposal_validator.ts +26 -3
- package/src/msg_validators/proposal_validator/proposal_validator.ts +94 -12
- package/src/msg_validators/tx_validator/README.md +13 -3
- package/src/msg_validators/tx_validator/aggregate_tx_validator.ts +3 -12
- package/src/msg_validators/tx_validator/allowed_public_setup.ts +3 -3
- package/src/msg_validators/tx_validator/archive_cache.ts +1 -1
- package/src/msg_validators/tx_validator/cached_tx_validator.ts +31 -0
- package/src/msg_validators/tx_validator/data_validator.ts +2 -0
- package/src/msg_validators/tx_validator/factory.ts +37 -20
- package/src/msg_validators/tx_validator/gas_validator.ts +99 -54
- package/src/msg_validators/tx_validator/index.ts +2 -0
- package/src/msg_validators/tx_validator/phases_validator.ts +2 -2
- package/src/msg_validators/tx_validator/tx_proof_validator.ts +2 -0
- package/src/msg_validators/tx_validator/tx_validation_cache.ts +101 -0
- package/src/services/data_store.ts +5 -13
- package/src/services/discv5/discV5_service.ts +124 -15
- package/src/services/discv5/persisted_enr_store.ts +158 -0
- package/src/services/dummy_service.ts +19 -43
- package/src/services/encoding.ts +28 -20
- package/src/services/gossipsub/README.md +33 -11
- package/src/services/gossipsub/topic_score_params.ts +9 -18
- package/src/services/libp2p/instrumentation.ts +14 -0
- package/src/services/libp2p/libp2p_service.ts +311 -271
- package/src/services/peer-manager/peer_manager.ts +63 -16
- package/src/services/peer-manager/peer_scoring.ts +81 -3
- package/src/services/reqresp/README.md +2 -37
- package/src/services/reqresp/batch-tx-requester/batch_tx_requester.ts +39 -52
- package/src/services/reqresp/batch-tx-requester/interface.ts +11 -4
- package/src/services/reqresp/batch-tx-requester/tx_validator.ts +12 -25
- package/src/services/reqresp/config.ts +19 -2
- package/src/services/reqresp/interface.ts +21 -47
- package/src/services/reqresp/metrics.ts +0 -1
- package/src/services/reqresp/protocols/block_txs/bitvector.ts +3 -2
- package/src/services/reqresp/protocols/block_txs/block_txs_handler.ts +34 -30
- package/src/services/reqresp/protocols/block_txs/block_txs_reqresp.ts +47 -20
- package/src/services/reqresp/protocols/index.ts +0 -1
- package/src/services/reqresp/protocols/tx.ts +1 -3
- package/src/services/reqresp/rate-limiter/rate_limits.ts +3 -13
- package/src/services/reqresp/reqresp.ts +69 -252
- package/src/services/service.ts +25 -30
- package/src/services/tx_collection/config.ts +3 -80
- package/src/services/tx_collection/file_store_tx_collection.ts +54 -103
- package/src/services/tx_collection/index.ts +1 -6
- package/src/services/tx_collection/instrumentation.ts +1 -7
- package/src/services/tx_collection/tx_collection.ts +330 -173
- package/src/services/tx_collection/tx_collection_sink.ts +2 -2
- package/src/services/tx_collection/tx_source.ts +2 -1
- package/src/services/tx_file_store/tx_file_store.ts +5 -17
- package/src/services/tx_provider.ts +5 -0
- package/src/test-helpers/make-test-p2p-clients.ts +3 -0
- package/src/test-helpers/mock-pubsub.ts +39 -60
- package/src/test-helpers/reqresp-nodes.ts +8 -22
- package/src/test-helpers/test_tx_provider.ts +5 -0
- package/src/test-helpers/testbench-utils.ts +35 -26
- package/src/testbench/p2p_client_testbench_worker.ts +68 -44
- package/src/testbench/worker_client_manager.ts +59 -19
- package/src/util.ts +34 -12
- package/src/versioning.ts +3 -33
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.d.ts +0 -2
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.d.ts.map +0 -1
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.js +0 -315
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker_protocol.d.ts +0 -73
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker_protocol.d.ts.map +0 -1
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker_protocol.js +0 -8
- package/dest/msg_validators/clock_tolerance.d.ts +0 -21
- package/dest/msg_validators/clock_tolerance.d.ts.map +0 -1
- package/dest/msg_validators/clock_tolerance.js +0 -38
- package/dest/services/reqresp/connection-sampler/batch_connection_sampler.d.ts +0 -64
- package/dest/services/reqresp/connection-sampler/batch_connection_sampler.d.ts.map +0 -1
- package/dest/services/reqresp/connection-sampler/batch_connection_sampler.js +0 -151
- package/dest/services/reqresp/protocols/block.d.ts +0 -9
- package/dest/services/reqresp/protocols/block.d.ts.map +0 -1
- package/dest/services/reqresp/protocols/block.js +0 -32
- package/dest/services/tx_collection/fast_tx_collection.d.ts +0 -51
- package/dest/services/tx_collection/fast_tx_collection.d.ts.map +0 -1
- package/dest/services/tx_collection/fast_tx_collection.js +0 -311
- package/dest/services/tx_collection/proposal_tx_collector.d.ts +0 -48
- package/dest/services/tx_collection/proposal_tx_collector.d.ts.map +0 -1
- package/dest/services/tx_collection/proposal_tx_collector.js +0 -50
- package/dest/services/tx_collection/slow_tx_collection.d.ts +0 -57
- package/dest/services/tx_collection/slow_tx_collection.d.ts.map +0 -1
- package/dest/services/tx_collection/slow_tx_collection.js +0 -211
- package/src/client/test/tx_proposal_collector/proposal_tx_collector_worker.ts +0 -355
- package/src/client/test/tx_proposal_collector/proposal_tx_collector_worker_protocol.ts +0 -43
- package/src/msg_validators/clock_tolerance.ts +0 -52
- package/src/services/reqresp/connection-sampler/batch_connection_sampler.ts +0 -161
- package/src/services/reqresp/protocols/block.ts +0 -37
- package/src/services/tx_collection/fast_tx_collection.ts +0 -361
- package/src/services/tx_collection/proposal_tx_collector.ts +0 -108
- package/src/services/tx_collection/slow_tx_collection.ts +0 -266
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"p2p_client.d.ts","sourceRoot":"","sources":["../../src/client/p2p_client.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"p2p_client.d.ts","sourceRoot":"","sources":["../../src/client/p2p_client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EACL,WAAW,EAEX,KAAK,sBAAsB,EAC3B,UAAU,EACX,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,KAAK,EAAE,iBAAiB,EAAuB,MAAM,iBAAiB,CAAC;AAE9E,OAAO,EAEL,KAAK,SAAS,EAEd,KAAK,UAAU,EAIf,KAAK,aAAa,EAClB,KAAK,kBAAkB,EAEvB,KA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AC,CAG9D;IAED,iEAAiE;IACpD,mBAAmB,IAAI,OAAO,CAAC,MAAM,CAAC,CAElD;IAED;;;OAGG;IACU,SAAS,IAAI,OAAO,CAAC,YAAY,CAAC,CAW9C;YAOa,iBAAiB;YAWjB,oBAAoB;YAkBpB,oBAAoB;YA2CpB,uBAAuB;YAiBvB,mBAAmB;YASnB,YAAY;YAuBZ,uBAAuB;YAQvB,qBAAqB;IA2BnC;;;OAGG;IACH,OAAO,CAAC,eAAe;IAMhB,kCAAkC,CAAC,GAAG,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAElE;IAED;;;;;;OAMG;IACI,UAAU,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,WAAW,EAAE,WAAW,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAEjF;IAED;;;;OAIG;IACU,cAAc,CAAC,UAAU,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAEjE;IAEM,yBAAyB,CAAC,WAAW,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAEjG;CACF"}
|
|
@@ -371,13 +371,12 @@ function _apply_decs_2203_r(targetClass, memberDecs, classDecs, parentClass) {
|
|
|
371
371
|
return (_apply_decs_2203_r = applyDecs2203RFactory())(targetClass, memberDecs, classDecs, parentClass);
|
|
372
372
|
}
|
|
373
373
|
var _dec, _dec1, _initProto;
|
|
374
|
-
import { GENESIS_BLOCK_HEADER_HASH } from '@aztec/constants';
|
|
375
374
|
import { BlockNumber, CheckpointNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
376
375
|
import { createLogger } from '@aztec/foundation/log';
|
|
377
|
-
import { RunningPromise } from '@aztec/foundation/promise';
|
|
378
376
|
import { DateProvider } from '@aztec/foundation/timer';
|
|
379
377
|
import { L2TipsKVStore } from '@aztec/kv-store/stores';
|
|
380
|
-
import {
|
|
378
|
+
import { EventDrivenL2BlockStream } from '@aztec/stdlib/block';
|
|
379
|
+
import { getTimestampForSlot } from '@aztec/stdlib/epoch-helpers';
|
|
381
380
|
import { tryStop } from '@aztec/stdlib/interfaces/server';
|
|
382
381
|
import { Attributes, WithTracer, getTelemetryClient, trackSpan } from '@aztec/telemetry-client';
|
|
383
382
|
import { getP2PDefaultConfig } from '../config.js';
|
|
@@ -435,8 +434,7 @@ _dec = trackSpan('p2pClient.broadcastProposal', async (proposal)=>({
|
|
|
435
434
|
txProvider;
|
|
436
435
|
validatorAddresses;
|
|
437
436
|
/** Tracks the last slot for which we called prepareForSlot */ lastSlotProcessed;
|
|
438
|
-
|
|
439
|
-
constructor(store, l2BlockSource, mempools, p2pService, txCollection, txFileStore, epochCache, config = {}, _dateProvider = new DateProvider(), telemetry = getTelemetryClient(), log = createLogger('p2p')){
|
|
437
|
+
constructor(store, l2BlockSource, mempools, p2pService, txCollection, txFileStore, epochCache, config = {}, _dateProvider = new DateProvider(), telemetry = getTelemetryClient(), log = createLogger('p2p'), initialBlockHash){
|
|
440
438
|
super(telemetry, 'P2PClient'), this.store = store, this.l2BlockSource = l2BlockSource, this.p2pService = p2pService, this.txCollection = txCollection, this.txFileStore = txFileStore, this.epochCache = epochCache, this._dateProvider = _dateProvider, this.telemetry = telemetry, this.log = log, this.currentState = (_initProto(this), P2PClientState.IDLE), this.syncPromise = Promise.resolve(), this.syncResolve = undefined, this.latestBlockNumberAtStart = -1, this.provenBlockNumberAtStart = -1, this.finalizedBlockNumberAtStart = -1, this.validatorAddresses = [], this.lastSlotProcessed = SlotNumber.ZERO;
|
|
441
439
|
this.config = {
|
|
442
440
|
...getP2PDefaultConfig(),
|
|
@@ -445,7 +443,7 @@ _dec = trackSpan('p2pClient.broadcastProposal', async (proposal)=>({
|
|
|
445
443
|
this.txPool = mempools.txPool;
|
|
446
444
|
this.attestationPool = mempools.attestationPool;
|
|
447
445
|
this.txProvider = new TxProvider(this.txCollection, this.txPool, this, this.log.createChild('tx-provider'), this.telemetry);
|
|
448
|
-
this.l2Tips = new L2TipsKVStore(store, 'p2p_client');
|
|
446
|
+
this.l2Tips = new L2TipsKVStore(store, 'p2p_client', initialBlockHash);
|
|
449
447
|
this.synchedLatestSlot = store.openSingleton('p2p_pool_last_l2_slot');
|
|
450
448
|
}
|
|
451
449
|
registerThisValidatorAddresses(addresses) {
|
|
@@ -491,7 +489,10 @@ _dec = trackSpan('p2pClient.broadcastProposal', async (proposal)=>({
|
|
|
491
489
|
const from = BlockNumber(oldFinalizedBlockNum + 1);
|
|
492
490
|
const limit = event.block.number - from + 1;
|
|
493
491
|
if (limit > 0) {
|
|
494
|
-
const oldBlocks = await this.l2BlockSource.
|
|
492
|
+
const oldBlocks = await this.l2BlockSource.getBlocksData({
|
|
493
|
+
from,
|
|
494
|
+
limit
|
|
495
|
+
});
|
|
495
496
|
await this.handleFinalizedL2Blocks(oldBlocks);
|
|
496
497
|
}
|
|
497
498
|
break;
|
|
@@ -501,10 +502,12 @@ _dec = trackSpan('p2pClient.broadcastProposal', async (proposal)=>({
|
|
|
501
502
|
break;
|
|
502
503
|
case 'chain-pruned':
|
|
503
504
|
this.txCollection.stopCollectingForBlocksAfter(event.block.number);
|
|
504
|
-
await this.handlePruneL2Blocks(event.block, event.checkpoint);
|
|
505
|
+
await this.handlePruneL2Blocks(event.block, event.checkpointed.checkpoint);
|
|
505
506
|
break;
|
|
506
507
|
case 'chain-checkpointed':
|
|
507
508
|
break;
|
|
509
|
+
case 'chain-proposed':
|
|
510
|
+
break;
|
|
508
511
|
default:
|
|
509
512
|
{
|
|
510
513
|
const _ = event;
|
|
@@ -572,21 +575,21 @@ _dec = trackSpan('p2pClient.broadcastProposal', async (proposal)=>({
|
|
|
572
575
|
syncedFinalizedBlock
|
|
573
576
|
});
|
|
574
577
|
}
|
|
578
|
+
// Should never happen: all branches above call initBlockStream()
|
|
579
|
+
if (!this.blockStream) {
|
|
580
|
+
throw new Error('Block stream not initialized');
|
|
581
|
+
}
|
|
575
582
|
this.blockStream.start();
|
|
576
|
-
await this.txCollection.start();
|
|
577
583
|
this.txFileStore?.start();
|
|
578
|
-
// Start slot monitor to call prepareForSlot when the slot changes
|
|
579
|
-
this.slotMonitor = new RunningPromise(()=>this.maybeCallPrepareForSlot(), this.log, this.config.slotCheckIntervalMS);
|
|
580
|
-
this.slotMonitor.start();
|
|
581
584
|
return this.syncPromise;
|
|
582
585
|
}
|
|
583
|
-
addReqRespSubProtocol(subProtocol, handler
|
|
584
|
-
return this.p2pService.addReqRespSubProtocol(subProtocol, handler
|
|
586
|
+
addReqRespSubProtocol(subProtocol, handler) {
|
|
587
|
+
return this.p2pService.addReqRespSubProtocol(subProtocol, handler);
|
|
585
588
|
}
|
|
586
589
|
initBlockStream(startingBlock) {
|
|
587
590
|
if (!this.blockStream) {
|
|
588
591
|
const { blockRequestBatchSize: batchSize, blockCheckIntervalMS: pollIntervalMS } = this.config;
|
|
589
|
-
this.blockStream = new
|
|
592
|
+
this.blockStream = new EventDrivenL2BlockStream(this.l2BlockSource, this, this, createLogger(`${this.log.module}:l2-block-stream`), {
|
|
590
593
|
batchSize,
|
|
591
594
|
pollIntervalMS,
|
|
592
595
|
startingBlock
|
|
@@ -598,8 +601,6 @@ _dec = trackSpan('p2pClient.broadcastProposal', async (proposal)=>({
|
|
|
598
601
|
* 'ready' will now return 'false' and the running promise that keeps the client synced is interrupted.
|
|
599
602
|
*/ async stop() {
|
|
600
603
|
this.log.debug('Stopping p2p client...');
|
|
601
|
-
await this.slotMonitor?.stop();
|
|
602
|
-
this.log.debug('Stopped slot monitor');
|
|
603
604
|
await tryStop(this.txCollection);
|
|
604
605
|
this.log.debug('Stopped tx collection service');
|
|
605
606
|
await this.txFileStore?.stop();
|
|
@@ -616,6 +617,10 @@ _dec = trackSpan('p2pClient.broadcastProposal', async (proposal)=>({
|
|
|
616
617
|
}
|
|
617
618
|
/** Triggers a sync to the archiver. Used for testing. */ async sync() {
|
|
618
619
|
this.initBlockStream();
|
|
620
|
+
// Should never happen: initBlockStream() creates blockStream if absent
|
|
621
|
+
if (!this.blockStream) {
|
|
622
|
+
throw new Error('Block stream not initialized');
|
|
623
|
+
}
|
|
619
624
|
await this.blockStream.sync();
|
|
620
625
|
}
|
|
621
626
|
async broadcastProposal(proposal) {
|
|
@@ -642,23 +647,40 @@ _dec = trackSpan('p2pClient.broadcastProposal', async (proposal)=>({
|
|
|
642
647
|
// Store our own last-block proposal so we can respond to req/resp requests for it.
|
|
643
648
|
await this.attestationPool.tryAddBlockProposal(blockProposal);
|
|
644
649
|
}
|
|
645
|
-
|
|
646
|
-
await this.
|
|
650
|
+
const checkpointCore = proposal.toCore();
|
|
651
|
+
const { count } = await this.attestationPool.tryAddCheckpointProposal(checkpointCore);
|
|
652
|
+
if (count > 1) {
|
|
653
|
+
if (this.config.broadcastEquivocatedProposals) {
|
|
654
|
+
this.log.warn(`Broadcasting equivocated checkpoint proposal for slot ${proposal.slotNumber}`, {
|
|
655
|
+
slot: proposal.slotNumber,
|
|
656
|
+
archive: proposal.archive.toString(),
|
|
657
|
+
count
|
|
658
|
+
});
|
|
659
|
+
} else {
|
|
660
|
+
throw new Error(`Attempted to broadcast a duplicate checkpoint proposal for slot ${proposal.slotNumber}`);
|
|
661
|
+
}
|
|
662
|
+
}
|
|
647
663
|
return this.p2pService.propagate(proposal);
|
|
648
664
|
}
|
|
649
665
|
async broadcastCheckpointAttestations(attestations) {
|
|
650
666
|
this.log.verbose(`Broadcasting ${attestations.length} checkpoint attestations to peers`);
|
|
651
667
|
await Promise.all(attestations.map((att)=>this.p2pService.propagate(att)));
|
|
652
668
|
}
|
|
653
|
-
async getCheckpointAttestationsForSlot(slot,
|
|
654
|
-
return await (
|
|
669
|
+
async getCheckpointAttestationsForSlot(slot, proposalPayloadHash) {
|
|
670
|
+
return await (proposalPayloadHash ? this.attestationPool.getCheckpointAttestationsForSlotAndProposal(slot, proposalPayloadHash) : this.attestationPool.getCheckpointAttestationsForSlot(slot));
|
|
655
671
|
}
|
|
656
672
|
addOwnCheckpointAttestations(attestations) {
|
|
657
673
|
return this.attestationPool.addOwnCheckpointAttestations(attestations);
|
|
658
674
|
}
|
|
675
|
+
getProposalsForSlot(slot) {
|
|
676
|
+
return this.attestationPool.getProposalsForSlot(slot);
|
|
677
|
+
}
|
|
659
678
|
hasBlockProposalsForSlot(slot) {
|
|
660
679
|
return this.attestationPool.hasBlockProposalsForSlot(slot);
|
|
661
680
|
}
|
|
681
|
+
hasCheckpointProposalForSlot(slot) {
|
|
682
|
+
return this.attestationPool.hasCheckpointProposalForSlot(slot);
|
|
683
|
+
}
|
|
662
684
|
// REVIEW: https://github.com/AztecProtocol/aztec-packages/issues/7963
|
|
663
685
|
// ^ This pattern is not my favorite (md)
|
|
664
686
|
registerBlockProposalHandler(handler) {
|
|
@@ -673,10 +695,16 @@ _dec = trackSpan('p2pClient.broadcastProposal', async (proposal)=>({
|
|
|
673
695
|
registerDuplicateProposalCallback(callback) {
|
|
674
696
|
this.p2pService.registerDuplicateProposalCallback(callback);
|
|
675
697
|
}
|
|
698
|
+
registerOversizedProposalCallback(callback) {
|
|
699
|
+
this.p2pService.registerOversizedProposalCallback(callback);
|
|
700
|
+
}
|
|
676
701
|
registerDuplicateAttestationCallback(callback) {
|
|
677
702
|
this.p2pService.registerDuplicateAttestationCallback(callback);
|
|
678
703
|
}
|
|
679
|
-
|
|
704
|
+
registerCheckpointAttestationCallback(callback) {
|
|
705
|
+
this.p2pService.registerCheckpointAttestationCallback(callback);
|
|
706
|
+
}
|
|
707
|
+
async getPendingTxs(limit, after, options) {
|
|
680
708
|
if (limit !== undefined && limit <= 0) {
|
|
681
709
|
throw new TypeError('limit must be greater than 0');
|
|
682
710
|
}
|
|
@@ -691,23 +719,30 @@ _dec = trackSpan('p2pClient.broadcastProposal', async (proposal)=>({
|
|
|
691
719
|
}
|
|
692
720
|
const endIndex = limit !== undefined ? startIndex + limit : undefined;
|
|
693
721
|
txHashes = txHashes.slice(startIndex, endIndex);
|
|
694
|
-
|
|
722
|
+
// This is a public-facing API (exposed via both the node and the p2p RPC), so proofs are opt-in.
|
|
723
|
+
const includeProof = !!options?.includeProof;
|
|
724
|
+
const maybeTxs = await Promise.all(txHashes.map((txHash)=>this.txPool.getTxByHash(txHash, {
|
|
725
|
+
includeProof
|
|
726
|
+
})));
|
|
695
727
|
return maybeTxs.filter((tx)=>!!tx);
|
|
696
728
|
}
|
|
697
729
|
getPendingTxCount() {
|
|
698
730
|
return this.txPool.getPendingTxCount();
|
|
699
731
|
}
|
|
700
|
-
|
|
732
|
+
hasEligiblePendingTxs(minCount) {
|
|
733
|
+
return this.txPool.hasEligiblePendingTxs(minCount);
|
|
734
|
+
}
|
|
735
|
+
async *iteratePendingTxs(opts) {
|
|
701
736
|
for (const txHash of (await this.txPool.getPendingTxHashes())){
|
|
702
|
-
const tx = await this.txPool.getTxByHash(txHash);
|
|
737
|
+
const tx = await this.txPool.getTxByHash(txHash, opts);
|
|
703
738
|
if (tx) {
|
|
704
739
|
yield tx;
|
|
705
740
|
}
|
|
706
741
|
}
|
|
707
742
|
}
|
|
708
|
-
async *iterateEligiblePendingTxs() {
|
|
743
|
+
async *iterateEligiblePendingTxs(opts) {
|
|
709
744
|
for (const txHash of (await this.txPool.getEligiblePendingTxHashes())){
|
|
710
|
-
const tx = await this.txPool.getTxByHash(txHash);
|
|
745
|
+
const tx = await this.txPool.getTxByHash(txHash, opts);
|
|
711
746
|
if (tx) {
|
|
712
747
|
yield tx;
|
|
713
748
|
}
|
|
@@ -716,16 +751,18 @@ _dec = trackSpan('p2pClient.broadcastProposal', async (proposal)=>({
|
|
|
716
751
|
/**
|
|
717
752
|
* Returns a transaction in the transaction pool by its hash.
|
|
718
753
|
* @param txHash - Hash of the transaction to look for in the pool.
|
|
754
|
+
* @param opts - Set `includeProof: false` to skip loading the tx proof from the DB.
|
|
719
755
|
* @returns A single tx or undefined.
|
|
720
|
-
*/ getTxByHashFromPool(txHash) {
|
|
721
|
-
return this.txPool.getTxByHash(txHash);
|
|
756
|
+
*/ getTxByHashFromPool(txHash, opts) {
|
|
757
|
+
return this.txPool.getTxByHash(txHash, opts);
|
|
722
758
|
}
|
|
723
759
|
/**
|
|
724
760
|
* Returns transactions in the transaction pool by hash.
|
|
725
761
|
* @param txHashes - Hashes of the transactions to look for.
|
|
762
|
+
* @param opts - Set `includeProof: false` to skip loading tx proofs from the DB.
|
|
726
763
|
* @returns The txs found, in the same order as the requested hashes. If a tx is not found, it will be undefined.
|
|
727
|
-
*/ getTxsByHashFromPool(txHashes) {
|
|
728
|
-
return this.txPool.getTxsByHash(txHashes);
|
|
764
|
+
*/ getTxsByHashFromPool(txHashes, opts) {
|
|
765
|
+
return this.txPool.getTxsByHash(txHashes, opts);
|
|
729
766
|
}
|
|
730
767
|
hasTxsInPool(txHashes) {
|
|
731
768
|
return this.txPool.hasTxs(txHashes);
|
|
@@ -813,7 +850,9 @@ _dec = trackSpan('p2pClient.broadcastProposal', async (proposal)=>({
|
|
|
813
850
|
* @returns Information about p2p client status: state & syncedToBlockNum.
|
|
814
851
|
*/ async getStatus() {
|
|
815
852
|
const blockNumber = await this.getSyncedLatestBlockNum();
|
|
816
|
-
const blockHash =
|
|
853
|
+
const blockHash = await this.l2BlockSource.getBlockData({
|
|
854
|
+
number: blockNumber
|
|
855
|
+
}).then((data)=>data?.header.hash()).then((hash)=>hash?.toString());
|
|
817
856
|
return {
|
|
818
857
|
state: this.currentState,
|
|
819
858
|
syncedToL2Block: {
|
|
@@ -839,13 +878,17 @@ _dec = trackSpan('p2pClient.broadcastProposal', async (proposal)=>({
|
|
|
839
878
|
if (!blocks.length) {
|
|
840
879
|
return;
|
|
841
880
|
}
|
|
842
|
-
await this.handleMinedBlocks(blocks);
|
|
843
|
-
await this.maybeCallPrepareForSlot();
|
|
844
|
-
await this.startCollectingMissingTxs(blocks);
|
|
845
881
|
const lastBlock = blocks.at(-1);
|
|
846
|
-
|
|
882
|
+
const lastSlot = lastBlock.header.getSlot();
|
|
883
|
+
// Mark txs mined before releasing protections: a block landing at this slot supersedes any
|
|
884
|
+
// protection for txs it includes, so mined-marking must run first to keep just-landed txs from
|
|
885
|
+
// being unprotected into pending where they could be evicted before they are recorded as mined.
|
|
886
|
+
await this.handleMinedBlocks(blocks);
|
|
887
|
+
await this.maybeCallPrepareForSlot(lastSlot);
|
|
888
|
+
await this.collectingMissingTxs(blocks);
|
|
889
|
+
await this.synchedLatestSlot.set(BigInt(lastSlot));
|
|
847
890
|
}
|
|
848
|
-
/** Request txs for unproven blocks so the prover node
|
|
891
|
+
/** Request txs for unproven blocks so the prover node can prove. */ async collectingMissingTxs(blocks) {
|
|
849
892
|
try {
|
|
850
893
|
// TODO(#15435): If the archiver has lagged behind L1, the reported proven block number may
|
|
851
894
|
// be much lower than the actual one, and it does not update until the pending chain is
|
|
@@ -853,7 +896,9 @@ _dec = trackSpan('p2pClient.broadcastProposal', async (proposal)=>({
|
|
|
853
896
|
// are already proven, but the archiver has not yet updated its state. Until this is properly
|
|
854
897
|
// fixed, it is mitigated by the expiration date of collection requests, which depends on
|
|
855
898
|
// the slot number of the block.
|
|
856
|
-
const provenBlockNumber = await this.l2BlockSource.
|
|
899
|
+
const provenBlockNumber = await this.l2BlockSource.getBlockNumber({
|
|
900
|
+
tag: 'proven'
|
|
901
|
+
}) ?? BlockNumber.ZERO;
|
|
857
902
|
const unprovenBlocks = blocks.filter((block)=>block.number > provenBlockNumber);
|
|
858
903
|
for (const block of unprovenBlocks){
|
|
859
904
|
const txHashes = block.body.txEffects.map((txEffect)=>txEffect.txHash);
|
|
@@ -864,7 +909,19 @@ _dec = trackSpan('p2pClient.broadcastProposal', async (proposal)=>({
|
|
|
864
909
|
blockNumber: block.number,
|
|
865
910
|
blockHash: await block.hash().then((h)=>h.toString())
|
|
866
911
|
});
|
|
867
|
-
|
|
912
|
+
// Both `slashDataWithholdingToleranceSlots` and `p2pMissingTxCollectionDeadlineSlots`
|
|
913
|
+
// count *full slots after the block slot* — value N means collection runs until
|
|
914
|
+
// `slotStart(block.slot + N + 1)`. Take the larger of the two so collection never
|
|
915
|
+
// gives up before the data-withholding slash verdict is rendered.
|
|
916
|
+
const blockSlot = block.header.getSlot();
|
|
917
|
+
const toleranceSlots = this.config.slashDataWithholdingToleranceSlots;
|
|
918
|
+
const configuredSlots = this.config.p2pMissingTxCollectionDeadlineSlots ?? 0;
|
|
919
|
+
const deadlineSlot = SlotNumber(blockSlot + Math.max(toleranceSlots, configuredSlots) + 1);
|
|
920
|
+
const deadlineSeconds = getTimestampForSlot(deadlineSlot, this.epochCache.getL1Constants());
|
|
921
|
+
const deadline = new Date(Number(deadlineSeconds) * 1000);
|
|
922
|
+
await this.txCollection.collectFastForBlock(block, missingTxHashes, {
|
|
923
|
+
deadline
|
|
924
|
+
});
|
|
868
925
|
}
|
|
869
926
|
}
|
|
870
927
|
} catch (err) {
|
|
@@ -919,18 +976,7 @@ _dec = trackSpan('p2pClient.broadcastProposal', async (proposal)=>({
|
|
|
919
976
|
}
|
|
920
977
|
return isEpochPrune;
|
|
921
978
|
}
|
|
922
|
-
/**
|
|
923
|
-
// If we have a proposed checkpoint available, we want to prepare the target slot - otherwise we prepare the current slot
|
|
924
|
-
const l2Tips = await this.l2Tips.getL2Tips();
|
|
925
|
-
const hasProposedCheckpoint = l2Tips.proposedCheckpoint.checkpoint.number > l2Tips.checkpointed.checkpoint.number;
|
|
926
|
-
let slot;
|
|
927
|
-
if (this.epochCache.isProposerPipeliningEnabled() && hasProposedCheckpoint) {
|
|
928
|
-
const { targetSlot } = this.epochCache.getTargetAndNextSlot();
|
|
929
|
-
slot = targetSlot;
|
|
930
|
-
} else {
|
|
931
|
-
const { currentSlot } = this.epochCache.getCurrentAndNextSlot();
|
|
932
|
-
slot = currentSlot;
|
|
933
|
-
}
|
|
979
|
+
/** Calls prepareForSlot for the given slot if it advances past the last slot we prepared for. */ async maybeCallPrepareForSlot(slot) {
|
|
934
980
|
if (slot <= this.lastSlotProcessed) {
|
|
935
981
|
return;
|
|
936
982
|
}
|