@aztec/p2p 0.0.1-commit.42ee6df9b → 0.0.1-commit.431c48d
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 +32 -23
- package/dest/client/interface.d.ts +44 -11
- package/dest/client/interface.d.ts.map +1 -1
- package/dest/client/p2p_client.d.ts +34 -19
- package/dest/client/p2p_client.d.ts.map +1 -1
- package/dest/client/p2p_client.js +119 -59
- package/dest/config.d.ts +150 -107
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +77 -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 +10 -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 +29 -20
- 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.d.ts +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.js +3 -3
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.d.ts +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.js +3 -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 +64 -0
- package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.d.ts +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.js +3 -4
- package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.d.ts +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.js +6 -7
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.d.ts +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.js +6 -5
- package/dest/mem_pools/tx_pool_v2/instrumentation.d.ts +11 -1
- package/dest/mem_pools/tx_pool_v2/instrumentation.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/instrumentation.js +24 -0
- 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 +16 -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 +83 -32
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts +50 -6
- 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 +243 -127
- 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 +119 -23
- 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 +18 -18
- package/dest/services/dummy_service.d.ts.map +1 -1
- package/dest/services/dummy_service.js +19 -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 +6 -1
- package/dest/services/libp2p/instrumentation.d.ts.map +1 -1
- package/dest/services/libp2p/instrumentation.js +21 -0
- package/dest/services/libp2p/libp2p_service.d.ts +40 -43
- package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
- package/dest/services/libp2p/libp2p_service.js +370 -276
- package/dest/services/peer-manager/peer_manager.d.ts +26 -2
- package/dest/services/peer-manager/peer_manager.d.ts.map +1 -1
- package/dest/services/peer-manager/peer_manager.js +103 -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 +41 -19
- 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 +33 -9
- package/dest/test-helpers/mock-pubsub.d.ts.map +1 -1
- package/dest/test-helpers/mock-pubsub.js +57 -44
- 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 +16 -18
- 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 +11 -6
- package/dest/util.d.ts.map +1 -1
- package/dest/util.js +35 -14
- package/dest/versioning.d.ts +3 -6
- package/dest/versioning.d.ts.map +1 -1
- package/dest/versioning.js +3 -24
- package/package.json +17 -17
- package/src/bootstrap/bootstrap.ts +17 -3
- package/src/client/factory.ts +48 -24
- package/src/client/interface.ts +39 -17
- package/src/client/p2p_client.ts +135 -92
- package/src/client/test/{tx_proposal_collector/README.md → p2p_client.batch_tx_requester.bench.README.md} +23 -53
- package/src/config.ts +159 -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 +30 -20
- 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 +2 -4
- package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.ts +3 -2
- 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 +67 -0
- package/src/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.ts +1 -3
- package/src/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.ts +5 -7
- package/src/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.ts +5 -6
- package/src/mem_pools/tx_pool_v2/instrumentation.ts +27 -0
- 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 +94 -31
- package/src/mem_pools/tx_pool_v2/tx_pool_v2_impl.ts +270 -133
- 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 +126 -14
- package/src/services/discv5/persisted_enr_store.ts +158 -0
- package/src/services/dummy_service.ts +25 -44
- 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 +22 -0
- package/src/services/libp2p/libp2p_service.ts +433 -302
- package/src/services/peer-manager/peer_manager.ts +112 -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 +48 -37
- 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 +61 -60
- package/src/test-helpers/reqresp-nodes.ts +12 -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 +32 -17
- 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;AAGzC,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,KAAK,WAAW,EACjB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAEjE,OA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B,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;IAmCnC;;;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,13 @@ 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 {
|
|
376
|
+
import { promiseWithResolvers } from '@aztec/foundation/promise';
|
|
378
377
|
import { DateProvider } from '@aztec/foundation/timer';
|
|
379
378
|
import { L2TipsKVStore } from '@aztec/kv-store/stores';
|
|
380
|
-
import {
|
|
379
|
+
import { EventDrivenL2BlockStream } from '@aztec/stdlib/block';
|
|
380
|
+
import { getTimestampForSlot } from '@aztec/stdlib/epoch-helpers';
|
|
381
381
|
import { tryStop } from '@aztec/stdlib/interfaces/server';
|
|
382
382
|
import { Attributes, WithTracer, getTelemetryClient, trackSpan } from '@aztec/telemetry-client';
|
|
383
383
|
import { getP2PDefaultConfig } from '../config.js';
|
|
@@ -422,7 +422,7 @@ _dec = trackSpan('p2pClient.broadcastProposal', async (proposal)=>({
|
|
|
422
422
|
/** The JS promise that will be running to keep the client's data in sync. Can be interrupted if the client is stopped. */ runningPromise;
|
|
423
423
|
currentState;
|
|
424
424
|
syncPromise;
|
|
425
|
-
|
|
425
|
+
syncResolvers;
|
|
426
426
|
latestBlockNumberAtStart;
|
|
427
427
|
provenBlockNumberAtStart;
|
|
428
428
|
finalizedBlockNumberAtStart;
|
|
@@ -435,9 +435,8 @@ _dec = trackSpan('p2pClient.broadcastProposal', async (proposal)=>({
|
|
|
435
435
|
txProvider;
|
|
436
436
|
validatorAddresses;
|
|
437
437
|
/** Tracks the last slot for which we called prepareForSlot */ lastSlotProcessed;
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
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;
|
|
438
|
+
constructor(store, l2BlockSource, mempools, p2pService, txCollection, txFileStore, epochCache, config = {}, _dateProvider = new DateProvider(), telemetry = getTelemetryClient(), log = createLogger('p2p'), initialBlockHash){
|
|
439
|
+
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.syncResolvers = undefined, this.latestBlockNumberAtStart = -1, this.provenBlockNumberAtStart = -1, this.finalizedBlockNumberAtStart = -1, this.validatorAddresses = [], this.lastSlotProcessed = SlotNumber.ZERO;
|
|
441
440
|
this.config = {
|
|
442
441
|
...getP2PDefaultConfig(),
|
|
443
442
|
...config
|
|
@@ -445,7 +444,7 @@ _dec = trackSpan('p2pClient.broadcastProposal', async (proposal)=>({
|
|
|
445
444
|
this.txPool = mempools.txPool;
|
|
446
445
|
this.attestationPool = mempools.attestationPool;
|
|
447
446
|
this.txProvider = new TxProvider(this.txCollection, this.txPool, this, this.log.createChild('tx-provider'), this.telemetry);
|
|
448
|
-
this.l2Tips = new L2TipsKVStore(store, 'p2p_client');
|
|
447
|
+
this.l2Tips = new L2TipsKVStore(store, 'p2p_client', initialBlockHash);
|
|
449
448
|
this.synchedLatestSlot = store.openSingleton('p2p_pool_last_l2_slot');
|
|
450
449
|
}
|
|
451
450
|
registerThisValidatorAddresses(addresses) {
|
|
@@ -466,6 +465,9 @@ _dec = trackSpan('p2pClient.broadcastProposal', async (proposal)=>({
|
|
|
466
465
|
getPeers(includePending) {
|
|
467
466
|
return Promise.resolve(this.p2pService.getPeers(includePending));
|
|
468
467
|
}
|
|
468
|
+
getP2PConnectivity() {
|
|
469
|
+
return Promise.resolve(this.p2pService.getP2PConnectivity());
|
|
470
|
+
}
|
|
469
471
|
getGossipMeshPeerCount(topicType) {
|
|
470
472
|
return Promise.resolve(this.p2pService.getGossipMeshPeerCount(topicType));
|
|
471
473
|
}
|
|
@@ -491,7 +493,10 @@ _dec = trackSpan('p2pClient.broadcastProposal', async (proposal)=>({
|
|
|
491
493
|
const from = BlockNumber(oldFinalizedBlockNum + 1);
|
|
492
494
|
const limit = event.block.number - from + 1;
|
|
493
495
|
if (limit > 0) {
|
|
494
|
-
const oldBlocks = await this.l2BlockSource.
|
|
496
|
+
const oldBlocks = await this.l2BlockSource.getBlocksData({
|
|
497
|
+
from,
|
|
498
|
+
limit
|
|
499
|
+
});
|
|
495
500
|
await this.handleFinalizedL2Blocks(oldBlocks);
|
|
496
501
|
}
|
|
497
502
|
break;
|
|
@@ -501,10 +506,12 @@ _dec = trackSpan('p2pClient.broadcastProposal', async (proposal)=>({
|
|
|
501
506
|
break;
|
|
502
507
|
case 'chain-pruned':
|
|
503
508
|
this.txCollection.stopCollectingForBlocksAfter(event.block.number);
|
|
504
|
-
await this.handlePruneL2Blocks(event.block, event.checkpoint);
|
|
509
|
+
await this.handlePruneL2Blocks(event.block, event.checkpointed.checkpoint);
|
|
505
510
|
break;
|
|
506
511
|
case 'chain-checkpointed':
|
|
507
512
|
break;
|
|
513
|
+
case 'chain-proposed':
|
|
514
|
+
break;
|
|
508
515
|
default:
|
|
509
516
|
{
|
|
510
517
|
const _ = event;
|
|
@@ -552,9 +559,8 @@ _dec = trackSpan('p2pClient.broadcastProposal', async (proposal)=>({
|
|
|
552
559
|
// this gets resolved on `startServiceIfSynched`
|
|
553
560
|
this.initBlockStream();
|
|
554
561
|
this.setCurrentState(P2PClientState.SYNCHING);
|
|
555
|
-
this.
|
|
556
|
-
|
|
557
|
-
});
|
|
562
|
+
this.syncResolvers = promiseWithResolvers();
|
|
563
|
+
this.syncPromise = this.syncResolvers.promise;
|
|
558
564
|
this.log.info(`Initiating p2p sync from ${syncedLatestBlock}`, {
|
|
559
565
|
syncedLatestBlock,
|
|
560
566
|
syncedProvenBlock,
|
|
@@ -572,21 +578,21 @@ _dec = trackSpan('p2pClient.broadcastProposal', async (proposal)=>({
|
|
|
572
578
|
syncedFinalizedBlock
|
|
573
579
|
});
|
|
574
580
|
}
|
|
581
|
+
// Should never happen: all branches above call initBlockStream()
|
|
582
|
+
if (!this.blockStream) {
|
|
583
|
+
throw new Error('Block stream not initialized');
|
|
584
|
+
}
|
|
575
585
|
this.blockStream.start();
|
|
576
|
-
await this.txCollection.start();
|
|
577
586
|
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
587
|
return this.syncPromise;
|
|
582
588
|
}
|
|
583
|
-
addReqRespSubProtocol(subProtocol, handler
|
|
584
|
-
return this.p2pService.addReqRespSubProtocol(subProtocol, handler
|
|
589
|
+
addReqRespSubProtocol(subProtocol, handler) {
|
|
590
|
+
return this.p2pService.addReqRespSubProtocol(subProtocol, handler);
|
|
585
591
|
}
|
|
586
592
|
initBlockStream(startingBlock) {
|
|
587
593
|
if (!this.blockStream) {
|
|
588
594
|
const { blockRequestBatchSize: batchSize, blockCheckIntervalMS: pollIntervalMS } = this.config;
|
|
589
|
-
this.blockStream = new
|
|
595
|
+
this.blockStream = new EventDrivenL2BlockStream(this.l2BlockSource, this, this, createLogger(`${this.log.module}:l2-block-stream`), {
|
|
590
596
|
batchSize,
|
|
591
597
|
pollIntervalMS,
|
|
592
598
|
startingBlock
|
|
@@ -598,8 +604,6 @@ _dec = trackSpan('p2pClient.broadcastProposal', async (proposal)=>({
|
|
|
598
604
|
* 'ready' will now return 'false' and the running promise that keeps the client synced is interrupted.
|
|
599
605
|
*/ async stop() {
|
|
600
606
|
this.log.debug('Stopping p2p client...');
|
|
601
|
-
await this.slotMonitor?.stop();
|
|
602
|
-
this.log.debug('Stopped slot monitor');
|
|
603
607
|
await tryStop(this.txCollection);
|
|
604
608
|
this.log.debug('Stopped tx collection service');
|
|
605
609
|
await this.txFileStore?.stop();
|
|
@@ -616,6 +620,10 @@ _dec = trackSpan('p2pClient.broadcastProposal', async (proposal)=>({
|
|
|
616
620
|
}
|
|
617
621
|
/** Triggers a sync to the archiver. Used for testing. */ async sync() {
|
|
618
622
|
this.initBlockStream();
|
|
623
|
+
// Should never happen: initBlockStream() creates blockStream if absent
|
|
624
|
+
if (!this.blockStream) {
|
|
625
|
+
throw new Error('Block stream not initialized');
|
|
626
|
+
}
|
|
619
627
|
await this.blockStream.sync();
|
|
620
628
|
}
|
|
621
629
|
async broadcastProposal(proposal) {
|
|
@@ -642,23 +650,40 @@ _dec = trackSpan('p2pClient.broadcastProposal', async (proposal)=>({
|
|
|
642
650
|
// Store our own last-block proposal so we can respond to req/resp requests for it.
|
|
643
651
|
await this.attestationPool.tryAddBlockProposal(blockProposal);
|
|
644
652
|
}
|
|
645
|
-
|
|
646
|
-
await this.
|
|
653
|
+
const checkpointCore = proposal.toCore();
|
|
654
|
+
const { count } = await this.attestationPool.tryAddCheckpointProposal(checkpointCore);
|
|
655
|
+
if (count > 1) {
|
|
656
|
+
if (this.config.broadcastEquivocatedProposals) {
|
|
657
|
+
this.log.warn(`Broadcasting equivocated checkpoint proposal for slot ${proposal.slotNumber}`, {
|
|
658
|
+
slot: proposal.slotNumber,
|
|
659
|
+
archive: proposal.archive.toString(),
|
|
660
|
+
count
|
|
661
|
+
});
|
|
662
|
+
} else {
|
|
663
|
+
throw new Error(`Attempted to broadcast a duplicate checkpoint proposal for slot ${proposal.slotNumber}`);
|
|
664
|
+
}
|
|
665
|
+
}
|
|
647
666
|
return this.p2pService.propagate(proposal);
|
|
648
667
|
}
|
|
649
668
|
async broadcastCheckpointAttestations(attestations) {
|
|
650
669
|
this.log.verbose(`Broadcasting ${attestations.length} checkpoint attestations to peers`);
|
|
651
670
|
await Promise.all(attestations.map((att)=>this.p2pService.propagate(att)));
|
|
652
671
|
}
|
|
653
|
-
async getCheckpointAttestationsForSlot(slot,
|
|
654
|
-
return await (
|
|
672
|
+
async getCheckpointAttestationsForSlot(slot, proposalPayloadHash) {
|
|
673
|
+
return await (proposalPayloadHash ? this.attestationPool.getCheckpointAttestationsForSlotAndProposal(slot, proposalPayloadHash) : this.attestationPool.getCheckpointAttestationsForSlot(slot));
|
|
655
674
|
}
|
|
656
675
|
addOwnCheckpointAttestations(attestations) {
|
|
657
676
|
return this.attestationPool.addOwnCheckpointAttestations(attestations);
|
|
658
677
|
}
|
|
678
|
+
getProposalsForSlot(slot) {
|
|
679
|
+
return this.attestationPool.getProposalsForSlot(slot);
|
|
680
|
+
}
|
|
659
681
|
hasBlockProposalsForSlot(slot) {
|
|
660
682
|
return this.attestationPool.hasBlockProposalsForSlot(slot);
|
|
661
683
|
}
|
|
684
|
+
hasCheckpointProposalForSlot(slot) {
|
|
685
|
+
return this.attestationPool.hasCheckpointProposalForSlot(slot);
|
|
686
|
+
}
|
|
662
687
|
// REVIEW: https://github.com/AztecProtocol/aztec-packages/issues/7963
|
|
663
688
|
// ^ This pattern is not my favorite (md)
|
|
664
689
|
registerBlockProposalHandler(handler) {
|
|
@@ -673,10 +698,16 @@ _dec = trackSpan('p2pClient.broadcastProposal', async (proposal)=>({
|
|
|
673
698
|
registerDuplicateProposalCallback(callback) {
|
|
674
699
|
this.p2pService.registerDuplicateProposalCallback(callback);
|
|
675
700
|
}
|
|
701
|
+
registerOversizedProposalCallback(callback) {
|
|
702
|
+
this.p2pService.registerOversizedProposalCallback(callback);
|
|
703
|
+
}
|
|
676
704
|
registerDuplicateAttestationCallback(callback) {
|
|
677
705
|
this.p2pService.registerDuplicateAttestationCallback(callback);
|
|
678
706
|
}
|
|
679
|
-
|
|
707
|
+
registerCheckpointAttestationCallback(callback) {
|
|
708
|
+
this.p2pService.registerCheckpointAttestationCallback(callback);
|
|
709
|
+
}
|
|
710
|
+
async getPendingTxs(limit, after, options) {
|
|
680
711
|
if (limit !== undefined && limit <= 0) {
|
|
681
712
|
throw new TypeError('limit must be greater than 0');
|
|
682
713
|
}
|
|
@@ -691,23 +722,30 @@ _dec = trackSpan('p2pClient.broadcastProposal', async (proposal)=>({
|
|
|
691
722
|
}
|
|
692
723
|
const endIndex = limit !== undefined ? startIndex + limit : undefined;
|
|
693
724
|
txHashes = txHashes.slice(startIndex, endIndex);
|
|
694
|
-
|
|
725
|
+
// This is a public-facing API (exposed via both the node and the p2p RPC), so proofs are opt-in.
|
|
726
|
+
const includeProof = !!options?.includeProof;
|
|
727
|
+
const maybeTxs = await Promise.all(txHashes.map((txHash)=>this.txPool.getTxByHash(txHash, {
|
|
728
|
+
includeProof
|
|
729
|
+
})));
|
|
695
730
|
return maybeTxs.filter((tx)=>!!tx);
|
|
696
731
|
}
|
|
697
732
|
getPendingTxCount() {
|
|
698
733
|
return this.txPool.getPendingTxCount();
|
|
699
734
|
}
|
|
700
|
-
|
|
735
|
+
hasEligiblePendingTxs(minCount) {
|
|
736
|
+
return this.txPool.hasEligiblePendingTxs(minCount);
|
|
737
|
+
}
|
|
738
|
+
async *iteratePendingTxs(opts) {
|
|
701
739
|
for (const txHash of (await this.txPool.getPendingTxHashes())){
|
|
702
|
-
const tx = await this.txPool.getTxByHash(txHash);
|
|
740
|
+
const tx = await this.txPool.getTxByHash(txHash, opts);
|
|
703
741
|
if (tx) {
|
|
704
742
|
yield tx;
|
|
705
743
|
}
|
|
706
744
|
}
|
|
707
745
|
}
|
|
708
|
-
async *iterateEligiblePendingTxs() {
|
|
746
|
+
async *iterateEligiblePendingTxs(opts) {
|
|
709
747
|
for (const txHash of (await this.txPool.getEligiblePendingTxHashes())){
|
|
710
|
-
const tx = await this.txPool.getTxByHash(txHash);
|
|
748
|
+
const tx = await this.txPool.getTxByHash(txHash, opts);
|
|
711
749
|
if (tx) {
|
|
712
750
|
yield tx;
|
|
713
751
|
}
|
|
@@ -716,16 +754,18 @@ _dec = trackSpan('p2pClient.broadcastProposal', async (proposal)=>({
|
|
|
716
754
|
/**
|
|
717
755
|
* Returns a transaction in the transaction pool by its hash.
|
|
718
756
|
* @param txHash - Hash of the transaction to look for in the pool.
|
|
757
|
+
* @param opts - Set `includeProof: false` to skip loading the tx proof from the DB.
|
|
719
758
|
* @returns A single tx or undefined.
|
|
720
|
-
*/ getTxByHashFromPool(txHash) {
|
|
721
|
-
return this.txPool.getTxByHash(txHash);
|
|
759
|
+
*/ getTxByHashFromPool(txHash, opts) {
|
|
760
|
+
return this.txPool.getTxByHash(txHash, opts);
|
|
722
761
|
}
|
|
723
762
|
/**
|
|
724
763
|
* Returns transactions in the transaction pool by hash.
|
|
725
764
|
* @param txHashes - Hashes of the transactions to look for.
|
|
765
|
+
* @param opts - Set `includeProof: false` to skip loading tx proofs from the DB.
|
|
726
766
|
* @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);
|
|
767
|
+
*/ getTxsByHashFromPool(txHashes, opts) {
|
|
768
|
+
return this.txPool.getTxsByHash(txHashes, opts);
|
|
729
769
|
}
|
|
730
770
|
hasTxsInPool(txHashes) {
|
|
731
771
|
return this.txPool.hasTxs(txHashes);
|
|
@@ -813,7 +853,9 @@ _dec = trackSpan('p2pClient.broadcastProposal', async (proposal)=>({
|
|
|
813
853
|
* @returns Information about p2p client status: state & syncedToBlockNum.
|
|
814
854
|
*/ async getStatus() {
|
|
815
855
|
const blockNumber = await this.getSyncedLatestBlockNum();
|
|
816
|
-
const blockHash =
|
|
856
|
+
const blockHash = await this.l2BlockSource.getBlockData({
|
|
857
|
+
number: blockNumber
|
|
858
|
+
}).then((data)=>data?.header.hash()).then((hash)=>hash?.toString());
|
|
817
859
|
return {
|
|
818
860
|
state: this.currentState,
|
|
819
861
|
syncedToL2Block: {
|
|
@@ -839,13 +881,17 @@ _dec = trackSpan('p2pClient.broadcastProposal', async (proposal)=>({
|
|
|
839
881
|
if (!blocks.length) {
|
|
840
882
|
return;
|
|
841
883
|
}
|
|
842
|
-
await this.handleMinedBlocks(blocks);
|
|
843
|
-
await this.maybeCallPrepareForSlot();
|
|
844
|
-
await this.startCollectingMissingTxs(blocks);
|
|
845
884
|
const lastBlock = blocks.at(-1);
|
|
846
|
-
|
|
885
|
+
const lastSlot = lastBlock.header.getSlot();
|
|
886
|
+
// Mark txs mined before releasing protections: a block landing at this slot supersedes any
|
|
887
|
+
// protection for txs it includes, so mined-marking must run first to keep just-landed txs from
|
|
888
|
+
// being unprotected into pending where they could be evicted before they are recorded as mined.
|
|
889
|
+
await this.handleMinedBlocks(blocks);
|
|
890
|
+
await this.maybeCallPrepareForSlot(lastSlot);
|
|
891
|
+
await this.collectingMissingTxs(blocks);
|
|
892
|
+
await this.synchedLatestSlot.set(BigInt(lastSlot));
|
|
847
893
|
}
|
|
848
|
-
/** Request txs for unproven blocks so the prover node
|
|
894
|
+
/** Request txs for unproven blocks so the prover node can prove. */ async collectingMissingTxs(blocks) {
|
|
849
895
|
try {
|
|
850
896
|
// TODO(#15435): If the archiver has lagged behind L1, the reported proven block number may
|
|
851
897
|
// be much lower than the actual one, and it does not update until the pending chain is
|
|
@@ -853,7 +899,9 @@ _dec = trackSpan('p2pClient.broadcastProposal', async (proposal)=>({
|
|
|
853
899
|
// are already proven, but the archiver has not yet updated its state. Until this is properly
|
|
854
900
|
// fixed, it is mitigated by the expiration date of collection requests, which depends on
|
|
855
901
|
// the slot number of the block.
|
|
856
|
-
const provenBlockNumber = await this.l2BlockSource.
|
|
902
|
+
const provenBlockNumber = await this.l2BlockSource.getBlockNumber({
|
|
903
|
+
tag: 'proven'
|
|
904
|
+
}) ?? BlockNumber.ZERO;
|
|
857
905
|
const unprovenBlocks = blocks.filter((block)=>block.number > provenBlockNumber);
|
|
858
906
|
for (const block of unprovenBlocks){
|
|
859
907
|
const txHashes = block.body.txEffects.map((txEffect)=>txEffect.txHash);
|
|
@@ -864,7 +912,19 @@ _dec = trackSpan('p2pClient.broadcastProposal', async (proposal)=>({
|
|
|
864
912
|
blockNumber: block.number,
|
|
865
913
|
blockHash: await block.hash().then((h)=>h.toString())
|
|
866
914
|
});
|
|
867
|
-
|
|
915
|
+
// Both `slashDataWithholdingToleranceSlots` and `p2pMissingTxCollectionDeadlineSlots`
|
|
916
|
+
// count *full slots after the block slot* — value N means collection runs until
|
|
917
|
+
// `slotStart(block.slot + N + 1)`. Take the larger of the two so collection never
|
|
918
|
+
// gives up before the data-withholding slash verdict is rendered.
|
|
919
|
+
const blockSlot = block.header.getSlot();
|
|
920
|
+
const toleranceSlots = this.config.slashDataWithholdingToleranceSlots;
|
|
921
|
+
const configuredSlots = this.config.p2pMissingTxCollectionDeadlineSlots ?? 0;
|
|
922
|
+
const deadlineSlot = SlotNumber(blockSlot + Math.max(toleranceSlots, configuredSlots) + 1);
|
|
923
|
+
const deadlineSeconds = getTimestampForSlot(deadlineSlot, this.epochCache.getL1Constants());
|
|
924
|
+
const deadline = new Date(Number(deadlineSeconds) * 1000);
|
|
925
|
+
await this.txCollection.collectFastForBlock(block, missingTxHashes, {
|
|
926
|
+
deadline
|
|
927
|
+
});
|
|
868
928
|
}
|
|
869
929
|
}
|
|
870
930
|
} catch (err) {
|
|
@@ -919,18 +979,7 @@ _dec = trackSpan('p2pClient.broadcastProposal', async (proposal)=>({
|
|
|
919
979
|
}
|
|
920
980
|
return isEpochPrune;
|
|
921
981
|
}
|
|
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
|
-
}
|
|
982
|
+
/** Calls prepareForSlot for the given slot if it advances past the last slot we prepared for. */ async maybeCallPrepareForSlot(slot) {
|
|
934
983
|
if (slot <= this.lastSlotProcessed) {
|
|
935
984
|
return;
|
|
936
985
|
}
|
|
@@ -952,9 +1001,20 @@ _dec = trackSpan('p2pClient.broadcastProposal', async (proposal)=>({
|
|
|
952
1001
|
syncedFinalizedBlock
|
|
953
1002
|
});
|
|
954
1003
|
this.setCurrentState(P2PClientState.RUNNING);
|
|
955
|
-
if (this.
|
|
956
|
-
|
|
957
|
-
|
|
1004
|
+
if (this.syncResolvers !== undefined) {
|
|
1005
|
+
// A throw here would be swallowed by the block stream event handler, so we reject the promise returned by
|
|
1006
|
+
// start instead, which makes node startup fail rather than run on with a dead p2p stack.
|
|
1007
|
+
try {
|
|
1008
|
+
await this.p2pService.start();
|
|
1009
|
+
} catch (err) {
|
|
1010
|
+
this.log.fatal(`Failed to start p2p service`, {
|
|
1011
|
+
err,
|
|
1012
|
+
syncedLatestBlock
|
|
1013
|
+
});
|
|
1014
|
+
this.syncResolvers.reject(err);
|
|
1015
|
+
return;
|
|
1016
|
+
}
|
|
1017
|
+
this.syncResolvers.resolve();
|
|
958
1018
|
}
|
|
959
1019
|
}
|
|
960
1020
|
}
|