@aztec/p2p 0.0.1-commit.24de95ac → 0.0.1-commit.2e2504e2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dest/bootstrap/bootstrap.d.ts +4 -3
- package/dest/bootstrap/bootstrap.d.ts.map +1 -1
- package/dest/bootstrap/bootstrap.js +4 -4
- package/dest/client/factory.d.ts +2 -2
- package/dest/client/factory.d.ts.map +1 -1
- package/dest/client/factory.js +11 -9
- package/dest/client/index.d.ts +1 -1
- package/dest/client/interface.d.ts +18 -3
- package/dest/client/interface.d.ts.map +1 -1
- package/dest/client/p2p_client.d.ts +18 -37
- package/dest/client/p2p_client.d.ts.map +1 -1
- package/dest/client/p2p_client.js +477 -128
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.d.ts +2 -0
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.d.ts.map +1 -0
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.js +305 -0
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker_protocol.d.ts +73 -0
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker_protocol.d.ts.map +1 -0
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker_protocol.js +8 -0
- package/dest/config.d.ts +75 -60
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +26 -15
- package/dest/enr/generate-enr.d.ts +1 -1
- package/dest/enr/index.d.ts +1 -1
- package/dest/errors/attestation-pool.error.d.ts +7 -0
- package/dest/errors/attestation-pool.error.d.ts.map +1 -0
- package/dest/errors/attestation-pool.error.js +12 -0
- package/dest/errors/reqresp.error.d.ts +1 -1
- package/dest/errors/reqresp.error.d.ts.map +1 -1
- package/dest/index.d.ts +1 -1
- package/dest/mem_pools/attestation_pool/attestation_pool.d.ts +77 -36
- package/dest/mem_pools/attestation_pool/attestation_pool.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.d.ts +1 -1
- package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.js +241 -266
- package/dest/mem_pools/attestation_pool/index.d.ts +1 -1
- package/dest/mem_pools/attestation_pool/kv_attestation_pool.d.ts +24 -14
- package/dest/mem_pools/attestation_pool/kv_attestation_pool.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/kv_attestation_pool.js +123 -95
- package/dest/mem_pools/attestation_pool/memory_attestation_pool.d.ts +18 -12
- package/dest/mem_pools/attestation_pool/memory_attestation_pool.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/memory_attestation_pool.js +91 -108
- package/dest/mem_pools/attestation_pool/mocks.d.ts +234 -10
- package/dest/mem_pools/attestation_pool/mocks.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/mocks.js +17 -13
- package/dest/mem_pools/index.d.ts +1 -1
- package/dest/mem_pools/instrumentation.d.ts +9 -1
- package/dest/mem_pools/instrumentation.d.ts.map +1 -1
- package/dest/mem_pools/instrumentation.js +37 -10
- package/dest/mem_pools/interface.d.ts +3 -4
- package/dest/mem_pools/interface.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.d.ts +33 -58
- 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 +314 -335
- package/dest/mem_pools/tx_pool/eviction/eviction_manager.d.ts +32 -0
- package/dest/mem_pools/tx_pool/eviction/eviction_manager.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool/eviction/eviction_manager.js +112 -0
- package/dest/mem_pools/tx_pool/eviction/eviction_strategy.d.ts +157 -0
- package/dest/mem_pools/tx_pool/eviction/eviction_strategy.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool/eviction/eviction_strategy.js +52 -0
- package/dest/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.d.ts +16 -0
- package/dest/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.js +122 -0
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.d.ts +17 -0
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.js +84 -0
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.d.ts +19 -0
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.js +78 -0
- package/dest/mem_pools/tx_pool/eviction/low_priority_eviction_rule.d.ts +26 -0
- package/dest/mem_pools/tx_pool/eviction/low_priority_eviction_rule.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool/eviction/low_priority_eviction_rule.js +84 -0
- package/dest/mem_pools/tx_pool/eviction/nullifier_conflict_pre_add_rule.d.ts +25 -0
- package/dest/mem_pools/tx_pool/eviction/nullifier_conflict_pre_add_rule.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool/eviction/nullifier_conflict_pre_add_rule.js +57 -0
- package/dest/mem_pools/tx_pool/index.d.ts +1 -2
- package/dest/mem_pools/tx_pool/index.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool/index.js +0 -1
- package/dest/mem_pools/tx_pool/priority.d.ts +5 -1
- package/dest/mem_pools/tx_pool/priority.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool/priority.js +6 -1
- package/dest/mem_pools/tx_pool/tx_pool.d.ts +11 -6
- package/dest/mem_pools/tx_pool/tx_pool.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool/tx_pool_test_suite.d.ts +1 -1
- package/dest/mem_pools/tx_pool/tx_pool_test_suite.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool/tx_pool_test_suite.js +30 -24
- package/dest/mem_pools/tx_pool_v2/archive/index.d.ts +2 -0
- package/dest/mem_pools/tx_pool_v2/archive/index.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/archive/index.js +1 -0
- package/dest/mem_pools/tx_pool_v2/archive/tx_archive.d.ts +43 -0
- package/dest/mem_pools/tx_pool_v2/archive/tx_archive.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/archive/tx_archive.js +103 -0
- package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.d.ts +47 -0
- package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.js +119 -0
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.d.ts +17 -0
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.js +90 -0
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.d.ts +19 -0
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.js +89 -0
- package/dest/mem_pools/tx_pool_v2/eviction/index.d.ts +10 -0
- package/dest/mem_pools/tx_pool_v2/eviction/index.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/eviction/index.js +11 -0
- package/dest/mem_pools/tx_pool_v2/eviction/interfaces.d.ts +131 -0
- package/dest/mem_pools/tx_pool_v2/eviction/interfaces.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/eviction/interfaces.js +17 -0
- package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.d.ts +15 -0
- package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.js +63 -0
- package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.d.ts +17 -0
- package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.js +91 -0
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.d.ts +16 -0
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.js +70 -0
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.d.ts +20 -0
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.js +63 -0
- package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.d.ts +15 -0
- package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.js +19 -0
- package/dest/mem_pools/tx_pool_v2/index.d.ts +5 -0
- package/dest/mem_pools/tx_pool_v2/index.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/index.js +4 -0
- package/dest/mem_pools/tx_pool_v2/interfaces.d.ts +193 -0
- package/dest/mem_pools/tx_pool_v2/interfaces.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/interfaces.js +6 -0
- package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts +71 -0
- package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/tx_metadata.js +94 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_bench_metrics.d.ts +26 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_bench_metrics.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_bench_metrics.js +70 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts +55 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2.js +150 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts +69 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.js +1041 -0
- package/dest/msg_validators/attestation_validator/attestation_validator.d.ts +7 -6
- package/dest/msg_validators/attestation_validator/attestation_validator.d.ts.map +1 -1
- package/dest/msg_validators/attestation_validator/attestation_validator.js +57 -24
- package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.d.ts +20 -0
- package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.d.ts.map +1 -0
- package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.js +76 -0
- package/dest/msg_validators/attestation_validator/index.d.ts +2 -1
- package/dest/msg_validators/attestation_validator/index.d.ts.map +1 -1
- package/dest/msg_validators/attestation_validator/index.js +1 -0
- package/dest/msg_validators/clock_tolerance.d.ts +21 -0
- package/dest/msg_validators/clock_tolerance.d.ts.map +1 -0
- package/dest/msg_validators/clock_tolerance.js +37 -0
- package/dest/msg_validators/index.d.ts +2 -2
- package/dest/msg_validators/index.d.ts.map +1 -1
- package/dest/msg_validators/index.js +1 -1
- package/dest/msg_validators/msg_seen_validator/msg_seen_validator.d.ts +1 -1
- package/dest/msg_validators/msg_seen_validator/msg_seen_validator.d.ts.map +1 -1
- package/dest/msg_validators/proposal_validator/block_proposal_validator.d.ts +9 -0
- package/dest/msg_validators/proposal_validator/block_proposal_validator.d.ts.map +1 -0
- package/dest/msg_validators/proposal_validator/block_proposal_validator.js +6 -0
- package/dest/msg_validators/proposal_validator/checkpoint_proposal_validator.d.ts +9 -0
- package/dest/msg_validators/proposal_validator/checkpoint_proposal_validator.d.ts.map +1 -0
- package/dest/msg_validators/proposal_validator/checkpoint_proposal_validator.js +6 -0
- package/dest/msg_validators/proposal_validator/index.d.ts +4 -0
- package/dest/msg_validators/proposal_validator/index.d.ts.map +1 -0
- package/dest/msg_validators/proposal_validator/index.js +3 -0
- package/dest/msg_validators/proposal_validator/proposal_validator.d.ts +13 -0
- package/dest/msg_validators/proposal_validator/proposal_validator.d.ts.map +1 -0
- package/dest/msg_validators/proposal_validator/proposal_validator.js +104 -0
- package/dest/msg_validators/proposal_validator/proposal_validator_test_suite.d.ts +23 -0
- package/dest/msg_validators/proposal_validator/proposal_validator_test_suite.d.ts.map +1 -0
- package/dest/msg_validators/proposal_validator/proposal_validator_test_suite.js +212 -0
- package/dest/msg_validators/tx_validator/aggregate_tx_validator.d.ts +1 -1
- package/dest/msg_validators/tx_validator/aggregate_tx_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/allowed_public_setup.d.ts +1 -1
- package/dest/msg_validators/tx_validator/archive_cache.d.ts +3 -3
- package/dest/msg_validators/tx_validator/archive_cache.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/archive_cache.js +1 -1
- package/dest/msg_validators/tx_validator/block_header_validator.d.ts +5 -4
- package/dest/msg_validators/tx_validator/block_header_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/block_header_validator.js +3 -2
- package/dest/msg_validators/tx_validator/data_validator.d.ts +3 -1
- package/dest/msg_validators/tx_validator/data_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/data_validator.js +4 -1
- package/dest/msg_validators/tx_validator/double_spend_validator.d.ts +3 -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 +3 -2
- package/dest/msg_validators/tx_validator/factory.d.ts +10 -4
- package/dest/msg_validators/tx_validator/factory.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/factory.js +22 -12
- package/dest/msg_validators/tx_validator/fee_payer_balance.d.ts +10 -0
- package/dest/msg_validators/tx_validator/fee_payer_balance.d.ts.map +1 -0
- package/dest/msg_validators/tx_validator/fee_payer_balance.js +20 -0
- package/dest/msg_validators/tx_validator/gas_validator.d.ts +3 -2
- package/dest/msg_validators/tx_validator/gas_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/gas_validator.js +11 -16
- package/dest/msg_validators/tx_validator/index.d.ts +2 -1
- package/dest/msg_validators/tx_validator/index.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/index.js +1 -0
- package/dest/msg_validators/tx_validator/metadata_validator.d.ts +4 -3
- package/dest/msg_validators/tx_validator/metadata_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/metadata_validator.js +2 -2
- package/dest/msg_validators/tx_validator/phases_validator.d.ts +3 -2
- package/dest/msg_validators/tx_validator/phases_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/phases_validator.js +6 -4
- package/dest/msg_validators/tx_validator/size_validator.d.ts +8 -0
- package/dest/msg_validators/tx_validator/size_validator.d.ts.map +1 -0
- package/dest/msg_validators/tx_validator/size_validator.js +23 -0
- package/dest/msg_validators/tx_validator/test_utils.d.ts +2 -2
- package/dest/msg_validators/tx_validator/test_utils.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/timestamp_validator.d.ts +5 -3
- package/dest/msg_validators/tx_validator/timestamp_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/timestamp_validator.js +2 -2
- package/dest/msg_validators/tx_validator/tx_permitted_validator.d.ts +3 -2
- package/dest/msg_validators/tx_validator/tx_permitted_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/tx_permitted_validator.js +2 -2
- package/dest/msg_validators/tx_validator/tx_proof_validator.d.ts +3 -2
- package/dest/msg_validators/tx_validator/tx_proof_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/tx_proof_validator.js +2 -2
- package/dest/services/data_store.d.ts +1 -1
- package/dest/services/data_store.d.ts.map +1 -1
- package/dest/services/data_store.js +10 -6
- package/dest/services/discv5/discV5_service.d.ts +1 -1
- package/dest/services/discv5/discV5_service.d.ts.map +1 -1
- package/dest/services/discv5/discV5_service.js +1 -1
- package/dest/services/dummy_service.d.ts +18 -2
- package/dest/services/dummy_service.d.ts.map +1 -1
- package/dest/services/dummy_service.js +42 -0
- package/dest/services/encoding.d.ts +1 -1
- package/dest/services/encoding.d.ts.map +1 -1
- package/dest/services/encoding.js +7 -6
- package/dest/services/gossipsub/scoring.d.ts +1 -1
- package/dest/services/index.d.ts +2 -1
- package/dest/services/index.d.ts.map +1 -1
- package/dest/services/index.js +1 -0
- 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 +36 -71
- package/dest/services/libp2p/libp2p_service.d.ts +48 -81
- package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
- package/dest/services/libp2p/libp2p_service.js +926 -193
- package/dest/services/peer-manager/interface.d.ts +1 -1
- package/dest/services/peer-manager/metrics.d.ts +9 -2
- package/dest/services/peer-manager/metrics.d.ts.map +1 -1
- package/dest/services/peer-manager/metrics.js +39 -16
- package/dest/services/peer-manager/peer_manager.d.ts +2 -33
- package/dest/services/peer-manager/peer_manager.d.ts.map +1 -1
- package/dest/services/peer-manager/peer_manager.js +6 -12
- package/dest/services/peer-manager/peer_scoring.d.ts +7 -2
- package/dest/services/peer-manager/peer_scoring.d.ts.map +1 -1
- package/dest/services/peer-manager/peer_scoring.js +43 -2
- package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts +47 -0
- package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts.map +1 -0
- package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.js +566 -0
- package/dest/services/reqresp/batch-tx-requester/config.d.ts +17 -0
- package/dest/services/reqresp/batch-tx-requester/config.d.ts.map +1 -0
- package/dest/services/reqresp/batch-tx-requester/config.js +27 -0
- package/dest/services/reqresp/batch-tx-requester/interface.d.ts +50 -0
- package/dest/services/reqresp/batch-tx-requester/interface.d.ts.map +1 -0
- package/dest/services/reqresp/batch-tx-requester/interface.js +1 -0
- package/dest/services/reqresp/batch-tx-requester/missing_txs.d.ts +37 -0
- package/dest/services/reqresp/batch-tx-requester/missing_txs.d.ts.map +1 -0
- package/dest/services/reqresp/batch-tx-requester/missing_txs.js +151 -0
- package/dest/services/reqresp/batch-tx-requester/peer_collection.d.ts +54 -0
- package/dest/services/reqresp/batch-tx-requester/peer_collection.d.ts.map +1 -0
- package/dest/services/reqresp/batch-tx-requester/peer_collection.js +139 -0
- package/dest/services/reqresp/batch-tx-requester/tx_validator.d.ts +20 -0
- package/dest/services/reqresp/batch-tx-requester/tx_validator.d.ts.map +1 -0
- package/dest/services/reqresp/batch-tx-requester/tx_validator.js +21 -0
- package/dest/services/reqresp/config.d.ts +1 -1
- package/dest/services/reqresp/connection-sampler/batch_connection_sampler.d.ts +22 -3
- package/dest/services/reqresp/connection-sampler/batch_connection_sampler.d.ts.map +1 -1
- package/dest/services/reqresp/connection-sampler/batch_connection_sampler.js +63 -4
- package/dest/services/reqresp/connection-sampler/connection_sampler.d.ts +2 -4
- package/dest/services/reqresp/connection-sampler/connection_sampler.d.ts.map +1 -1
- package/dest/services/reqresp/connection-sampler/connection_sampler.js +12 -0
- package/dest/services/reqresp/constants.d.ts +12 -0
- package/dest/services/reqresp/constants.d.ts.map +1 -0
- package/dest/services/reqresp/constants.js +7 -0
- package/dest/services/reqresp/index.d.ts +1 -1
- package/dest/services/reqresp/interface.d.ts +4 -2
- package/dest/services/reqresp/interface.d.ts.map +1 -1
- package/dest/services/reqresp/interface.js +1 -1
- package/dest/services/reqresp/metrics.d.ts +6 -5
- package/dest/services/reqresp/metrics.d.ts.map +1 -1
- package/dest/services/reqresp/metrics.js +17 -21
- package/dest/services/reqresp/protocols/auth.d.ts +2 -2
- package/dest/services/reqresp/protocols/auth.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/auth.js +2 -2
- package/dest/services/reqresp/protocols/block.d.ts +1 -1
- package/dest/services/reqresp/protocols/block.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/block.js +3 -2
- package/dest/services/reqresp/protocols/block_txs/bitvector.d.ts +5 -1
- package/dest/services/reqresp/protocols/block_txs/bitvector.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/block_txs/bitvector.js +12 -0
- 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 +16 -3
- package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.d.ts +19 -9
- 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 +44 -14
- package/dest/services/reqresp/protocols/block_txs/index.d.ts +1 -1
- package/dest/services/reqresp/protocols/goodbye.d.ts +1 -1
- package/dest/services/reqresp/protocols/goodbye.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/index.d.ts +1 -1
- package/dest/services/reqresp/protocols/ping.d.ts +1 -1
- package/dest/services/reqresp/protocols/status.d.ts +6 -5
- package/dest/services/reqresp/protocols/status.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/status.js +7 -3
- package/dest/services/reqresp/protocols/tx.d.ts +2 -3
- package/dest/services/reqresp/protocols/tx.d.ts.map +1 -1
- package/dest/services/reqresp/rate-limiter/index.d.ts +1 -1
- package/dest/services/reqresp/rate-limiter/rate_limiter.d.ts +2 -2
- package/dest/services/reqresp/rate-limiter/rate_limiter.d.ts.map +1 -1
- package/dest/services/reqresp/rate-limiter/rate_limits.d.ts +1 -1
- package/dest/services/reqresp/reqresp.d.ts +6 -41
- package/dest/services/reqresp/reqresp.d.ts.map +1 -1
- package/dest/services/reqresp/reqresp.js +460 -46
- package/dest/services/reqresp/status.d.ts +2 -2
- package/dest/services/reqresp/status.d.ts.map +1 -1
- package/dest/services/service.d.ts +19 -3
- package/dest/services/service.d.ts.map +1 -1
- package/dest/services/tx_collection/config.d.ts +4 -1
- package/dest/services/tx_collection/config.d.ts.map +1 -1
- package/dest/services/tx_collection/config.js +10 -2
- package/dest/services/tx_collection/fast_tx_collection.d.ts +9 -12
- package/dest/services/tx_collection/fast_tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/fast_tx_collection.js +16 -5
- package/dest/services/tx_collection/index.d.ts +2 -1
- package/dest/services/tx_collection/index.d.ts.map +1 -1
- package/dest/services/tx_collection/index.js +1 -0
- 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 +10 -13
- package/dest/services/tx_collection/proposal_tx_collector.d.ts +48 -0
- package/dest/services/tx_collection/proposal_tx_collector.d.ts.map +1 -0
- package/dest/services/tx_collection/proposal_tx_collector.js +50 -0
- package/dest/services/tx_collection/slow_tx_collection.d.ts +4 -5
- package/dest/services/tx_collection/slow_tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/slow_tx_collection.js +2 -1
- package/dest/services/tx_collection/tx_collection.d.ts +10 -10
- package/dest/services/tx_collection/tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/tx_collection.js +5 -5
- package/dest/services/tx_collection/tx_collection_sink.d.ts +3 -3
- package/dest/services/tx_collection/tx_collection_sink.d.ts.map +1 -1
- 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_file_store/config.d.ts +18 -0
- package/dest/services/tx_file_store/config.d.ts.map +1 -0
- package/dest/services/tx_file_store/config.js +26 -0
- package/dest/services/tx_file_store/index.d.ts +4 -0
- package/dest/services/tx_file_store/index.d.ts.map +1 -0
- package/dest/services/tx_file_store/index.js +3 -0
- package/dest/services/tx_file_store/instrumentation.d.ts +15 -0
- package/dest/services/tx_file_store/instrumentation.d.ts.map +1 -0
- package/dest/services/tx_file_store/instrumentation.js +29 -0
- package/dest/services/tx_file_store/tx_file_store.d.ts +47 -0
- package/dest/services/tx_file_store/tx_file_store.d.ts.map +1 -0
- package/dest/services/tx_file_store/tx_file_store.js +149 -0
- package/dest/services/tx_provider.d.ts +4 -2
- package/dest/services/tx_provider.d.ts.map +1 -1
- package/dest/services/tx_provider.js +11 -2
- package/dest/services/tx_provider_instrumentation.d.ts +5 -2
- package/dest/services/tx_provider_instrumentation.d.ts.map +1 -1
- package/dest/services/tx_provider_instrumentation.js +14 -14
- package/dest/test-helpers/generate-peer-id-private-keys.d.ts +1 -1
- package/dest/test-helpers/get-ports.d.ts +1 -1
- package/dest/test-helpers/get-ports.d.ts.map +1 -1
- package/dest/test-helpers/index.d.ts +3 -1
- package/dest/test-helpers/index.d.ts.map +1 -1
- package/dest/test-helpers/index.js +2 -0
- package/dest/test-helpers/make-enrs.d.ts +1 -1
- package/dest/test-helpers/make-test-p2p-clients.d.ts +2 -2
- package/dest/test-helpers/make-test-p2p-clients.d.ts.map +1 -1
- package/dest/test-helpers/mock-pubsub.d.ts +4 -4
- package/dest/test-helpers/mock-pubsub.d.ts.map +1 -1
- package/dest/test-helpers/mock-tx-helpers.d.ts +2 -2
- package/dest/test-helpers/mock-tx-helpers.d.ts.map +1 -1
- package/dest/test-helpers/mock-tx-helpers.js +1 -1
- package/dest/test-helpers/reqresp-nodes.d.ts +2 -2
- package/dest/test-helpers/reqresp-nodes.d.ts.map +1 -1
- package/dest/test-helpers/test_tx_provider.d.ts +40 -0
- package/dest/test-helpers/test_tx_provider.d.ts.map +1 -0
- package/dest/test-helpers/test_tx_provider.js +41 -0
- package/dest/test-helpers/testbench-utils.d.ts +158 -0
- package/dest/test-helpers/testbench-utils.d.ts.map +1 -0
- package/dest/test-helpers/testbench-utils.js +297 -0
- package/dest/testbench/p2p_client_testbench_worker.d.ts +28 -2
- package/dest/testbench/p2p_client_testbench_worker.d.ts.map +1 -1
- package/dest/testbench/p2p_client_testbench_worker.js +218 -120
- package/dest/testbench/parse_log_file.d.ts +1 -1
- package/dest/testbench/testbench.d.ts +1 -1
- package/dest/testbench/worker_client_manager.d.ts +51 -6
- package/dest/testbench/worker_client_manager.d.ts.map +1 -1
- package/dest/testbench/worker_client_manager.js +226 -39
- package/dest/types/index.d.ts +1 -1
- package/dest/util.d.ts +2 -1
- package/dest/util.d.ts.map +1 -1
- package/dest/util.js +11 -2
- package/dest/versioning.d.ts +1 -1
- package/package.json +19 -18
- package/src/bootstrap/bootstrap.ts +7 -4
- package/src/client/factory.ts +15 -20
- package/src/client/interface.ts +20 -2
- package/src/client/p2p_client.ts +121 -156
- package/src/client/test/tx_proposal_collector/README.md +227 -0
- package/src/client/test/tx_proposal_collector/proposal_tx_collector_worker.ts +336 -0
- package/src/client/test/tx_proposal_collector/proposal_tx_collector_worker_protocol.ts +43 -0
- package/src/config.ts +43 -20
- package/src/errors/attestation-pool.error.ts +13 -0
- package/src/mem_pools/attestation_pool/attestation_pool.ts +86 -35
- package/src/mem_pools/attestation_pool/attestation_pool_test_suite.ts +243 -278
- package/src/mem_pools/attestation_pool/kv_attestation_pool.ts +175 -111
- package/src/mem_pools/attestation_pool/memory_attestation_pool.ts +147 -136
- package/src/mem_pools/attestation_pool/mocks.ts +21 -15
- package/src/mem_pools/instrumentation.ts +48 -10
- package/src/mem_pools/interface.ts +2 -4
- package/src/mem_pools/tx_pool/README.md +270 -0
- package/src/mem_pools/tx_pool/aztec_kv_tx_pool.ts +367 -371
- package/src/mem_pools/tx_pool/eviction/eviction_manager.ts +132 -0
- package/src/mem_pools/tx_pool/eviction/eviction_strategy.ts +208 -0
- package/src/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.ts +162 -0
- package/src/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.ts +104 -0
- package/src/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.ts +93 -0
- package/src/mem_pools/tx_pool/eviction/low_priority_eviction_rule.ts +106 -0
- package/src/mem_pools/tx_pool/eviction/nullifier_conflict_pre_add_rule.ts +75 -0
- package/src/mem_pools/tx_pool/index.ts +0 -1
- package/src/mem_pools/tx_pool/priority.ts +8 -1
- package/src/mem_pools/tx_pool/tx_pool.ts +11 -5
- package/src/mem_pools/tx_pool/tx_pool_test_suite.ts +23 -17
- package/src/mem_pools/tx_pool_v2/README.md +188 -0
- package/src/mem_pools/tx_pool_v2/archive/index.ts +1 -0
- package/src/mem_pools/tx_pool_v2/archive/tx_archive.ts +120 -0
- package/src/mem_pools/tx_pool_v2/eviction/eviction_manager.ts +147 -0
- package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.ts +118 -0
- package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.ts +111 -0
- package/src/mem_pools/tx_pool_v2/eviction/index.ts +23 -0
- package/src/mem_pools/tx_pool_v2/eviction/interfaces.ts +164 -0
- package/src/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.ts +74 -0
- package/src/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.ts +101 -0
- package/src/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.ts +86 -0
- package/src/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.ts +72 -0
- package/src/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.ts +31 -0
- package/src/mem_pools/tx_pool_v2/index.ts +11 -0
- package/src/mem_pools/tx_pool_v2/interfaces.ts +225 -0
- package/src/mem_pools/tx_pool_v2/tx_metadata.ts +160 -0
- package/src/mem_pools/tx_pool_v2/tx_pool_bench_metrics.ts +77 -0
- package/src/mem_pools/tx_pool_v2/tx_pool_v2.ts +209 -0
- package/src/mem_pools/tx_pool_v2/tx_pool_v2_impl.ts +1265 -0
- package/src/msg_validators/attestation_validator/attestation_validator.ts +45 -32
- package/src/msg_validators/attestation_validator/fisherman_attestation_validator.ts +94 -0
- package/src/msg_validators/attestation_validator/index.ts +1 -0
- package/src/msg_validators/clock_tolerance.ts +51 -0
- package/src/msg_validators/index.ts +1 -1
- package/src/msg_validators/proposal_validator/block_proposal_validator.ts +10 -0
- package/src/msg_validators/proposal_validator/checkpoint_proposal_validator.ts +13 -0
- package/src/msg_validators/proposal_validator/index.ts +3 -0
- package/src/msg_validators/proposal_validator/proposal_validator.ts +92 -0
- package/src/msg_validators/proposal_validator/proposal_validator_test_suite.ts +230 -0
- package/src/msg_validators/tx_validator/archive_cache.ts +3 -3
- package/src/msg_validators/tx_validator/block_header_validator.ts +6 -5
- package/src/msg_validators/tx_validator/data_validator.ts +18 -6
- package/src/msg_validators/tx_validator/double_spend_validator.ts +4 -3
- package/src/msg_validators/tx_validator/factory.ts +67 -25
- package/src/msg_validators/tx_validator/fee_payer_balance.ts +40 -0
- package/src/msg_validators/tx_validator/gas_validator.ts +17 -28
- package/src/msg_validators/tx_validator/index.ts +1 -0
- package/src/msg_validators/tx_validator/metadata_validator.ts +19 -8
- package/src/msg_validators/tx_validator/phases_validator.ts +8 -4
- package/src/msg_validators/tx_validator/size_validator.ts +22 -0
- package/src/msg_validators/tx_validator/test_utils.ts +1 -1
- package/src/msg_validators/tx_validator/timestamp_validator.ts +11 -5
- package/src/msg_validators/tx_validator/tx_permitted_validator.ts +8 -3
- package/src/msg_validators/tx_validator/tx_proof_validator.ts +8 -3
- package/src/services/data_store.ts +10 -7
- package/src/services/discv5/discV5_service.ts +1 -1
- package/src/services/dummy_service.ts +51 -0
- package/src/services/encoding.ts +6 -5
- package/src/services/index.ts +1 -0
- package/src/services/libp2p/instrumentation.ts +39 -71
- package/src/services/libp2p/libp2p_service.ts +629 -195
- package/src/services/peer-manager/metrics.ts +44 -16
- package/src/services/peer-manager/peer_manager.ts +7 -4
- package/src/services/peer-manager/peer_scoring.ts +45 -3
- package/src/services/reqresp/batch-tx-requester/README.md +305 -0
- package/src/services/reqresp/batch-tx-requester/batch_tx_requester.ts +706 -0
- package/src/services/reqresp/batch-tx-requester/config.ts +40 -0
- package/src/services/reqresp/batch-tx-requester/interface.ts +57 -0
- package/src/services/reqresp/batch-tx-requester/missing_txs.ts +209 -0
- package/src/services/reqresp/batch-tx-requester/peer_collection.ts +205 -0
- package/src/services/reqresp/batch-tx-requester/tx_validator.ts +37 -0
- package/src/services/reqresp/connection-sampler/batch_connection_sampler.ts +65 -4
- package/src/services/reqresp/connection-sampler/connection_sampler.ts +19 -1
- package/src/services/reqresp/constants.ts +14 -0
- package/src/services/reqresp/interface.ts +4 -1
- package/src/services/reqresp/metrics.ts +36 -27
- package/src/services/reqresp/protocols/auth.ts +2 -2
- package/src/services/reqresp/protocols/block.ts +3 -2
- package/src/services/reqresp/protocols/block_txs/bitvector.ts +16 -0
- package/src/services/reqresp/protocols/block_txs/block_txs_handler.ts +18 -4
- package/src/services/reqresp/protocols/block_txs/block_txs_reqresp.ts +52 -10
- package/src/services/reqresp/protocols/status.ts +16 -12
- package/src/services/reqresp/protocols/tx.ts +1 -2
- package/src/services/reqresp/reqresp.ts +66 -19
- package/src/services/service.ts +23 -4
- package/src/services/tx_collection/config.ts +16 -2
- package/src/services/tx_collection/fast_tx_collection.ts +39 -15
- package/src/services/tx_collection/index.ts +5 -0
- package/src/services/tx_collection/instrumentation.ts +5 -13
- package/src/services/tx_collection/proposal_tx_collector.ts +114 -0
- package/src/services/tx_collection/slow_tx_collection.ts +5 -4
- package/src/services/tx_collection/tx_collection.ts +10 -9
- package/src/services/tx_file_store/config.ts +43 -0
- package/src/services/tx_file_store/index.ts +3 -0
- package/src/services/tx_file_store/instrumentation.ts +36 -0
- package/src/services/tx_file_store/tx_file_store.ts +173 -0
- package/src/services/tx_provider.ts +19 -3
- package/src/services/tx_provider_instrumentation.ts +24 -14
- package/src/test-helpers/index.ts +2 -0
- package/src/test-helpers/mock-pubsub.ts +1 -1
- package/src/test-helpers/mock-tx-helpers.ts +1 -1
- package/src/test-helpers/reqresp-nodes.ts +1 -1
- package/src/test-helpers/test_tx_provider.ts +64 -0
- package/src/test-helpers/testbench-utils.ts +374 -0
- package/src/testbench/p2p_client_testbench_worker.ts +338 -116
- package/src/testbench/worker_client_manager.ts +304 -42
- package/src/util.ts +12 -2
- package/dest/mem_pools/tx_pool/memory_tx_pool.d.ts +0 -80
- package/dest/mem_pools/tx_pool/memory_tx_pool.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/memory_tx_pool.js +0 -238
- package/dest/msg_validators/block_proposal_validator/block_proposal_validator.d.ts +0 -12
- package/dest/msg_validators/block_proposal_validator/block_proposal_validator.d.ts.map +0 -1
- package/dest/msg_validators/block_proposal_validator/block_proposal_validator.js +0 -70
- package/dest/msg_validators/block_proposal_validator/index.d.ts +0 -2
- package/dest/msg_validators/block_proposal_validator/index.d.ts.map +0 -1
- package/dest/msg_validators/block_proposal_validator/index.js +0 -1
- package/src/mem_pools/tx_pool/memory_tx_pool.ts +0 -283
- package/src/msg_validators/block_proposal_validator/block_proposal_validator.ts +0 -81
- package/src/msg_validators/block_proposal_validator/index.ts +0 -1
package/src/client/interface.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { EthAddress, L2BlockId } from '@aztec/stdlib/block';
|
|
2
2
|
import type { P2PApiFull } from '@aztec/stdlib/interfaces/server';
|
|
3
|
-
import type { BlockProposal, P2PClientType } from '@aztec/stdlib/p2p';
|
|
3
|
+
import type { BlockProposal, CheckpointAttestation, CheckpointProposal, P2PClientType } from '@aztec/stdlib/p2p';
|
|
4
4
|
import type { Tx, TxHash } from '@aztec/stdlib/tx';
|
|
5
5
|
|
|
6
6
|
import type { PeerId } from '@libp2p/interface';
|
|
@@ -13,7 +13,7 @@ import type {
|
|
|
13
13
|
ReqRespSubProtocolHandler,
|
|
14
14
|
ReqRespSubProtocolValidators,
|
|
15
15
|
} from '../services/reqresp/interface.js';
|
|
16
|
-
import type { P2PBlockReceivedCallback } from '../services/service.js';
|
|
16
|
+
import type { P2PBlockReceivedCallback, P2PCheckpointReceivedCallback } from '../services/service.js';
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
* Enum defining the possible states of the p2p client.
|
|
@@ -50,6 +50,16 @@ export type P2P<T extends P2PClientType = P2PClientType.Full> = P2PApiFull<T> &
|
|
|
50
50
|
*/
|
|
51
51
|
broadcastProposal(proposal: BlockProposal): Promise<void>;
|
|
52
52
|
|
|
53
|
+
/**
|
|
54
|
+
* Broadcasts a checkpoint proposal (last block in a checkpoint) to other peers.
|
|
55
|
+
*
|
|
56
|
+
* @param proposal - the checkpoint proposal
|
|
57
|
+
*/
|
|
58
|
+
broadcastCheckpointProposal(proposal: CheckpointProposal): Promise<void>;
|
|
59
|
+
|
|
60
|
+
/** Broadcasts checkpoint attestations to other peers. */
|
|
61
|
+
broadcastCheckpointAttestations(attestations: CheckpointAttestation[]): Promise<void>;
|
|
62
|
+
|
|
53
63
|
/**
|
|
54
64
|
* Registers a callback from the validator client that determines how to behave when
|
|
55
65
|
* foreign block proposals are received
|
|
@@ -60,6 +70,14 @@ export type P2P<T extends P2PClientType = P2PClientType.Full> = P2PApiFull<T> &
|
|
|
60
70
|
// ^ This pattern is not my favorite (md)
|
|
61
71
|
registerBlockProposalHandler(callback: P2PBlockReceivedCallback): void;
|
|
62
72
|
|
|
73
|
+
/**
|
|
74
|
+
* Registers a callback from the validator client that determines how to behave when
|
|
75
|
+
* foreign checkpoint proposals are received
|
|
76
|
+
*
|
|
77
|
+
* @param handler - A function taking a received checkpoint proposal and producing attestations
|
|
78
|
+
*/
|
|
79
|
+
registerCheckpointProposalHandler(callback: P2PCheckpointReceivedCallback): void;
|
|
80
|
+
|
|
63
81
|
/**
|
|
64
82
|
* Request a list of transactions from another peer by their tx hashes.
|
|
65
83
|
* @param txHashes - Hashes of the txs to query.
|
package/src/client/p2p_client.ts
CHANGED
|
@@ -1,30 +1,29 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { GENESIS_BLOCK_HEADER_HASH } from '@aztec/constants';
|
|
2
|
+
import { BlockNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
2
3
|
import { createLogger } from '@aztec/foundation/log';
|
|
3
4
|
import { DateProvider } from '@aztec/foundation/timer';
|
|
4
|
-
import type { AztecAsyncKVStore,
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
L2BlockSource,
|
|
5
|
+
import type { AztecAsyncKVStore, AztecAsyncSingleton } from '@aztec/kv-store';
|
|
6
|
+
import { L2TipsKVStore } from '@aztec/kv-store/stores';
|
|
7
|
+
import {
|
|
8
|
+
type EthAddress,
|
|
9
|
+
type L2Block,
|
|
10
|
+
type L2BlockSource,
|
|
10
11
|
L2BlockStream,
|
|
11
|
-
L2BlockStreamEvent,
|
|
12
|
-
L2Tips,
|
|
13
|
-
|
|
12
|
+
type L2BlockStreamEvent,
|
|
13
|
+
type L2Tips,
|
|
14
|
+
type L2TipsStore,
|
|
14
15
|
} from '@aztec/stdlib/block';
|
|
15
16
|
import type { ContractDataSource } from '@aztec/stdlib/contract';
|
|
16
17
|
import { getTimestampForSlot } from '@aztec/stdlib/epoch-helpers';
|
|
17
18
|
import { type PeerInfo, tryStop } from '@aztec/stdlib/interfaces/server';
|
|
18
|
-
import { BlockAttestation, type BlockProposal, type P2PClientType } from '@aztec/stdlib/p2p';
|
|
19
|
-
import type { Tx, TxHash } from '@aztec/stdlib/tx';
|
|
20
19
|
import {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
} from '@aztec/telemetry-client';
|
|
20
|
+
type BlockProposal,
|
|
21
|
+
CheckpointAttestation,
|
|
22
|
+
type CheckpointProposal,
|
|
23
|
+
type P2PClientType,
|
|
24
|
+
} from '@aztec/stdlib/p2p';
|
|
25
|
+
import type { Tx, TxHash } from '@aztec/stdlib/tx';
|
|
26
|
+
import { Attributes, type TelemetryClient, WithTracer, getTelemetryClient, trackSpan } from '@aztec/telemetry-client';
|
|
28
27
|
|
|
29
28
|
import type { PeerId } from '@libp2p/interface';
|
|
30
29
|
import type { ENR } from '@nethermindeth/enr';
|
|
@@ -40,8 +39,9 @@ import {
|
|
|
40
39
|
type ReqRespSubProtocolValidators,
|
|
41
40
|
} from '../services/reqresp/interface.js';
|
|
42
41
|
import { chunkTxHashesRequest } from '../services/reqresp/protocols/tx.js';
|
|
43
|
-
import type { P2PBlockReceivedCallback, P2PService } from '../services/service.js';
|
|
42
|
+
import type { P2PBlockReceivedCallback, P2PCheckpointReceivedCallback, P2PService } from '../services/service.js';
|
|
44
43
|
import { TxCollection } from '../services/tx_collection/tx_collection.js';
|
|
44
|
+
import type { TxFileStore } from '../services/tx_file_store/tx_file_store.js';
|
|
45
45
|
import { TxProvider } from '../services/tx_provider.js';
|
|
46
46
|
import { type P2P, P2PClientState, type P2PSyncState } from './interface.js';
|
|
47
47
|
|
|
@@ -62,14 +62,11 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
62
62
|
private provenBlockNumberAtStart = -1;
|
|
63
63
|
private finalizedBlockNumberAtStart = -1;
|
|
64
64
|
|
|
65
|
-
private
|
|
66
|
-
private synchedLatestBlockNumber: AztecAsyncSingleton<number>;
|
|
67
|
-
private synchedProvenBlockNumber: AztecAsyncSingleton<number>;
|
|
68
|
-
private synchedFinalizedBlockNumber: AztecAsyncSingleton<number>;
|
|
65
|
+
private l2Tips: L2TipsStore;
|
|
69
66
|
private synchedLatestSlot: AztecAsyncSingleton<bigint>;
|
|
70
67
|
|
|
71
68
|
private txPool: TxPool;
|
|
72
|
-
private attestationPool:
|
|
69
|
+
private attestationPool: AttestationPool;
|
|
73
70
|
|
|
74
71
|
private config: P2PConfig;
|
|
75
72
|
|
|
@@ -91,9 +88,10 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
91
88
|
_clientType: T,
|
|
92
89
|
private store: AztecAsyncKVStore,
|
|
93
90
|
private l2BlockSource: L2BlockSource & ContractDataSource,
|
|
94
|
-
mempools: MemPools
|
|
91
|
+
mempools: MemPools,
|
|
95
92
|
private p2pService: P2PService,
|
|
96
93
|
private txCollection: TxCollection,
|
|
94
|
+
private txFileStore: TxFileStore | undefined,
|
|
97
95
|
config: Partial<P2PConfig> = {},
|
|
98
96
|
private _dateProvider: DateProvider = new DateProvider(),
|
|
99
97
|
private telemetry: TelemetryClient = getTelemetryClient(),
|
|
@@ -103,7 +101,7 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
103
101
|
|
|
104
102
|
this.config = { ...getP2PDefaultConfig(), ...config };
|
|
105
103
|
this.txPool = mempools.txPool;
|
|
106
|
-
this.attestationPool = mempools.attestationPool
|
|
104
|
+
this.attestationPool = mempools.attestationPool;
|
|
107
105
|
|
|
108
106
|
this.txProvider = new TxProvider(
|
|
109
107
|
this.txCollection,
|
|
@@ -114,30 +112,27 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
114
112
|
);
|
|
115
113
|
|
|
116
114
|
// Default to collecting all txs when we see a valid proposal
|
|
117
|
-
// This can be overridden by the validator client to
|
|
115
|
+
// This can be overridden by the validator client to validate, and it will call getTxsForBlockProposal on its own
|
|
116
|
+
// Note: Validators do NOT attest to individual blocks - attestations are only for checkpoint proposals.
|
|
118
117
|
// TODO(palla/txs): We should not trigger a request for txs on a proposal before fully validating it. We need to bring
|
|
119
118
|
// validator-client code into here so we can validate a proposal is reasonable.
|
|
120
119
|
this.registerBlockProposalHandler(async (block, sender) => {
|
|
121
120
|
this.log.debug(`Received block proposal from ${sender.toString()}`);
|
|
122
121
|
// TODO(palla/txs): Need to subtract validatorReexecuteDeadlineMs from this deadline (see ValidatorClient.getReexecutionDeadline)
|
|
123
122
|
const constants = this.txCollection.getConstants();
|
|
124
|
-
const nextSlotTimestampSeconds = Number(getTimestampForSlot(block.slotNumber
|
|
123
|
+
const nextSlotTimestampSeconds = Number(getTimestampForSlot(SlotNumber(block.slotNumber + 1), constants));
|
|
125
124
|
const deadline = new Date(nextSlotTimestampSeconds * 1000);
|
|
126
|
-
const parentBlock = await this.l2BlockSource.getBlockHeaderByArchive(block.
|
|
125
|
+
const parentBlock = await this.l2BlockSource.getBlockHeaderByArchive(block.blockHeader.lastArchive.root);
|
|
127
126
|
if (!parentBlock) {
|
|
128
127
|
this.log.debug(`Cannot collect txs for proposal as parent block not found`);
|
|
129
|
-
return;
|
|
128
|
+
return false;
|
|
130
129
|
}
|
|
131
|
-
const blockNumber = parentBlock.getBlockNumber() + 1;
|
|
130
|
+
const blockNumber = BlockNumber(parentBlock.getBlockNumber() + 1);
|
|
132
131
|
await this.txProvider.getTxsForBlockProposal(block, blockNumber, { pinnedPeer: sender, deadline });
|
|
133
|
-
return
|
|
132
|
+
return true;
|
|
134
133
|
});
|
|
135
134
|
|
|
136
|
-
|
|
137
|
-
this.synchedBlockHashes = store.openMap('p2p_pool_block_hashes');
|
|
138
|
-
this.synchedLatestBlockNumber = store.openSingleton('p2p_pool_last_l2_block');
|
|
139
|
-
this.synchedProvenBlockNumber = store.openSingleton('p2p_pool_last_proven_l2_block');
|
|
140
|
-
this.synchedFinalizedBlockNumber = store.openSingleton('p2p_pool_last_finalized_l2_block');
|
|
135
|
+
this.l2Tips = new L2TipsKVStore(store, 'p2p_client');
|
|
141
136
|
this.synchedLatestSlot = store.openSingleton('p2p_pool_last_l2_slot');
|
|
142
137
|
}
|
|
143
138
|
|
|
@@ -162,8 +157,8 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
162
157
|
return Promise.resolve(this.p2pService.getPeers(includePending));
|
|
163
158
|
}
|
|
164
159
|
|
|
165
|
-
public getL2BlockHash(number:
|
|
166
|
-
return this.
|
|
160
|
+
public getL2BlockHash(number: BlockNumber): Promise<string | undefined> {
|
|
161
|
+
return this.l2Tips.getL2BlockHash(number);
|
|
167
162
|
}
|
|
168
163
|
|
|
169
164
|
public updateP2PConfig(config: Partial<P2PConfig>): Promise<void> {
|
|
@@ -172,82 +167,45 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
172
167
|
return Promise.resolve();
|
|
173
168
|
}
|
|
174
169
|
|
|
175
|
-
public
|
|
176
|
-
|
|
177
|
-
let latestBlockHash: string | undefined;
|
|
178
|
-
|
|
179
|
-
const provenBlockNumber = await this.getSyncedProvenBlockNum();
|
|
180
|
-
let provenBlockHash: string | undefined;
|
|
181
|
-
|
|
182
|
-
const finalizedBlockNumber = await this.getSyncedFinalizedBlockNum();
|
|
183
|
-
let finalizedBlockHash: string | undefined;
|
|
184
|
-
|
|
185
|
-
if (latestBlockNumber > 0) {
|
|
186
|
-
latestBlockHash = await this.synchedBlockHashes.getAsync(latestBlockNumber);
|
|
187
|
-
if (typeof latestBlockHash === 'undefined') {
|
|
188
|
-
throw new Error(`Block hash for latest block ${latestBlockNumber} not found in p2p client`);
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
if (provenBlockNumber > 0) {
|
|
193
|
-
provenBlockHash = await this.synchedBlockHashes.getAsync(provenBlockNumber);
|
|
194
|
-
if (typeof provenBlockHash === 'undefined') {
|
|
195
|
-
throw new Error(`Block hash for proven block ${provenBlockNumber} not found in p2p client`);
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
if (finalizedBlockNumber > 0) {
|
|
200
|
-
finalizedBlockHash = await this.synchedBlockHashes.getAsync(finalizedBlockNumber);
|
|
201
|
-
if (typeof finalizedBlockHash === 'undefined') {
|
|
202
|
-
throw new Error(`Block hash for finalized block ${finalizedBlockNumber} not found in p2p client`);
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
return {
|
|
207
|
-
latest: { hash: latestBlockHash!, number: latestBlockNumber },
|
|
208
|
-
proven: { hash: provenBlockHash!, number: provenBlockNumber },
|
|
209
|
-
finalized: { hash: finalizedBlockHash!, number: finalizedBlockNumber },
|
|
210
|
-
};
|
|
170
|
+
public getL2Tips(): Promise<L2Tips> {
|
|
171
|
+
return this.l2Tips.getL2Tips();
|
|
211
172
|
}
|
|
212
173
|
|
|
213
174
|
public async handleBlockStreamEvent(event: L2BlockStreamEvent): Promise<void> {
|
|
214
175
|
this.log.debug(`Handling block stream event ${event.type}`);
|
|
176
|
+
|
|
215
177
|
switch (event.type) {
|
|
216
178
|
case 'blocks-added':
|
|
217
179
|
await this.handleLatestL2Blocks(event.blocks);
|
|
218
180
|
break;
|
|
219
181
|
case 'chain-finalized': {
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
const from = (await this.getSyncedFinalizedBlockNum()) + 1;
|
|
182
|
+
const oldFinalizedBlockNum = await this.getSyncedFinalizedBlockNum();
|
|
183
|
+
const from = BlockNumber(oldFinalizedBlockNum + 1);
|
|
223
184
|
const limit = event.block.number - from + 1;
|
|
224
185
|
if (limit > 0) {
|
|
225
|
-
|
|
186
|
+
const oldBlocks = await this.l2BlockSource.getBlocks(from, limit);
|
|
187
|
+
await this.handleFinalizedL2Blocks(oldBlocks);
|
|
226
188
|
}
|
|
227
189
|
break;
|
|
228
190
|
}
|
|
229
|
-
case 'chain-proven':
|
|
230
|
-
await this.setBlockHash(event.block);
|
|
191
|
+
case 'chain-proven':
|
|
231
192
|
this.txCollection.stopCollectingForBlocksUpTo(event.block.number);
|
|
232
|
-
await this.synchedProvenBlockNumber.set(event.block.number);
|
|
233
193
|
break;
|
|
234
|
-
}
|
|
235
194
|
case 'chain-pruned':
|
|
236
|
-
await this.setBlockHash(event.block);
|
|
237
195
|
this.txCollection.stopCollectingForBlocksAfter(event.block.number);
|
|
238
196
|
await this.handlePruneL2Blocks(event.block.number);
|
|
239
197
|
break;
|
|
198
|
+
case 'chain-checkpointed':
|
|
199
|
+
break;
|
|
240
200
|
default: {
|
|
241
201
|
const _: never = event;
|
|
242
202
|
break;
|
|
243
203
|
}
|
|
244
204
|
}
|
|
245
|
-
}
|
|
246
205
|
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
}
|
|
206
|
+
// Pass the event through to our l2 tips store
|
|
207
|
+
await this.l2Tips.handleBlockStreamEvent(event);
|
|
208
|
+
await this.startServiceIfSynched();
|
|
251
209
|
}
|
|
252
210
|
|
|
253
211
|
#assertIsReady() {
|
|
@@ -271,20 +229,17 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
271
229
|
|
|
272
230
|
// get the current latest block numbers
|
|
273
231
|
const latestBlockNumbers = await this.l2BlockSource.getL2Tips();
|
|
274
|
-
this.latestBlockNumberAtStart = latestBlockNumbers.
|
|
275
|
-
this.provenBlockNumberAtStart = latestBlockNumbers.proven.number;
|
|
276
|
-
this.finalizedBlockNumberAtStart = latestBlockNumbers.finalized.number;
|
|
232
|
+
this.latestBlockNumberAtStart = latestBlockNumbers.proposed.number;
|
|
233
|
+
this.provenBlockNumberAtStart = latestBlockNumbers.proven.block.number;
|
|
234
|
+
this.finalizedBlockNumberAtStart = latestBlockNumbers.finalized.block.number;
|
|
277
235
|
|
|
278
236
|
const syncedLatestBlock = (await this.getSyncedLatestBlockNum()) + 1;
|
|
279
237
|
const syncedProvenBlock = (await this.getSyncedProvenBlockNum()) + 1;
|
|
280
238
|
const syncedFinalizedBlock = (await this.getSyncedFinalizedBlockNum()) + 1;
|
|
281
239
|
|
|
282
|
-
if (
|
|
283
|
-
(await this.txPool.isEmpty()) &&
|
|
284
|
-
(this.attestationPool === undefined || (await this.attestationPool?.isEmpty()))
|
|
285
|
-
) {
|
|
240
|
+
if ((await this.txPool.isEmpty()) && (await this.attestationPool.isEmpty())) {
|
|
286
241
|
// if mempools are empty, we don't care about syncing prior blocks
|
|
287
|
-
this.initBlockStream(this.latestBlockNumberAtStart);
|
|
242
|
+
this.initBlockStream(BlockNumber(this.latestBlockNumberAtStart));
|
|
288
243
|
this.setCurrentState(P2PClientState.RUNNING);
|
|
289
244
|
this.syncPromise = Promise.resolve();
|
|
290
245
|
await this.p2pService.start();
|
|
@@ -321,6 +276,7 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
321
276
|
|
|
322
277
|
this.blockStream!.start();
|
|
323
278
|
await this.txCollection.start();
|
|
279
|
+
this.txFileStore?.start();
|
|
324
280
|
return this.syncPromise;
|
|
325
281
|
}
|
|
326
282
|
|
|
@@ -332,15 +288,13 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
332
288
|
return this.p2pService.addReqRespSubProtocol(subProtocol, handler, validator);
|
|
333
289
|
}
|
|
334
290
|
|
|
335
|
-
private initBlockStream(startingBlock?:
|
|
291
|
+
private initBlockStream(startingBlock?: BlockNumber) {
|
|
336
292
|
if (!this.blockStream) {
|
|
337
293
|
const { blockRequestBatchSize: batchSize, blockCheckIntervalMS: pollIntervalMS } = this.config;
|
|
338
|
-
this.blockStream = new
|
|
294
|
+
this.blockStream = new L2BlockStream(
|
|
339
295
|
this.l2BlockSource,
|
|
340
296
|
this,
|
|
341
297
|
this,
|
|
342
|
-
this.telemetry.getTracer('P2PL2BlockStream'),
|
|
343
|
-
'P2PL2BlockStream',
|
|
344
298
|
createLogger(`${this.log.module}:l2-block-stream`),
|
|
345
299
|
{ batchSize, pollIntervalMS, startingBlock },
|
|
346
300
|
);
|
|
@@ -355,6 +309,8 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
355
309
|
this.log.debug('Stopping p2p client...');
|
|
356
310
|
await tryStop(this.txCollection);
|
|
357
311
|
this.log.debug('Stopped tx collection service');
|
|
312
|
+
await this.txFileStore?.stop();
|
|
313
|
+
this.log.debug('Stopped tx file store');
|
|
358
314
|
await this.p2pService.stop();
|
|
359
315
|
this.log.debug('Stopped p2p service');
|
|
360
316
|
await this.blockStream?.stop();
|
|
@@ -371,29 +327,48 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
371
327
|
}
|
|
372
328
|
|
|
373
329
|
@trackSpan('p2pClient.broadcastProposal', async proposal => ({
|
|
374
|
-
[Attributes.SLOT_NUMBER]: proposal.slotNumber
|
|
330
|
+
[Attributes.SLOT_NUMBER]: proposal.slotNumber,
|
|
375
331
|
[Attributes.BLOCK_ARCHIVE]: proposal.archive.toString(),
|
|
376
|
-
[Attributes.P2P_ID]: (await proposal.
|
|
332
|
+
[Attributes.P2P_ID]: (await proposal.p2pMessageLoggingIdentifier()).toString(),
|
|
377
333
|
}))
|
|
378
|
-
public broadcastProposal(proposal: BlockProposal): Promise<void> {
|
|
379
|
-
this.log.verbose(`Broadcasting proposal for slot ${proposal.slotNumber
|
|
334
|
+
public async broadcastProposal(proposal: BlockProposal): Promise<void> {
|
|
335
|
+
this.log.verbose(`Broadcasting proposal for slot ${proposal.slotNumber} to peers`);
|
|
336
|
+
// Store our own proposal so we can respond to req/resp requests for it
|
|
337
|
+
await this.attestationPool.addBlockProposal(proposal);
|
|
380
338
|
return this.p2pService.propagate(proposal);
|
|
381
339
|
}
|
|
382
340
|
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
341
|
+
@trackSpan('p2pClient.broadcastCheckpointProposal', async proposal => ({
|
|
342
|
+
[Attributes.SLOT_NUMBER]: proposal.slotNumber,
|
|
343
|
+
[Attributes.BLOCK_ARCHIVE]: proposal.archive.toString(),
|
|
344
|
+
[Attributes.P2P_ID]: (await proposal.p2pMessageLoggingIdentifier()).toString(),
|
|
345
|
+
}))
|
|
346
|
+
public async broadcastCheckpointProposal(proposal: CheckpointProposal): Promise<void> {
|
|
347
|
+
this.log.verbose(`Broadcasting checkpoint proposal for slot ${proposal.slotNumber} to peers`);
|
|
348
|
+
const blockProposal = proposal.getBlockProposal();
|
|
349
|
+
if (blockProposal) {
|
|
350
|
+
// Store our own last-block proposal so we can respond to req/resp requests for it.
|
|
351
|
+
await this.attestationPool.addBlockProposal(blockProposal);
|
|
352
|
+
}
|
|
353
|
+
return this.p2pService.propagate(proposal);
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
public async broadcastCheckpointAttestations(attestations: CheckpointAttestation[]): Promise<void> {
|
|
357
|
+
this.log.verbose(`Broadcasting ${attestations.length} checkpoint attestations to peers`);
|
|
358
|
+
await Promise.all(attestations.map(att => this.p2pService.propagate(att)));
|
|
389
359
|
}
|
|
390
360
|
|
|
391
|
-
public
|
|
392
|
-
|
|
361
|
+
public async getCheckpointAttestationsForSlot(
|
|
362
|
+
slot: SlotNumber,
|
|
363
|
+
proposalId?: string,
|
|
364
|
+
): Promise<CheckpointAttestation[]> {
|
|
365
|
+
return await (proposalId
|
|
366
|
+
? this.attestationPool.getCheckpointAttestationsForSlotAndProposal(slot, proposalId)
|
|
367
|
+
: this.attestationPool.getCheckpointAttestationsForSlot(slot));
|
|
393
368
|
}
|
|
394
369
|
|
|
395
|
-
public
|
|
396
|
-
return this.attestationPool
|
|
370
|
+
public addCheckpointAttestations(attestations: CheckpointAttestation[]): Promise<void> {
|
|
371
|
+
return this.attestationPool.addCheckpointAttestations(attestations);
|
|
397
372
|
}
|
|
398
373
|
|
|
399
374
|
// REVIEW: https://github.com/AztecProtocol/aztec-packages/issues/7963
|
|
@@ -402,6 +377,10 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
402
377
|
this.p2pService.registerBlockReceivedCallback(handler);
|
|
403
378
|
}
|
|
404
379
|
|
|
380
|
+
public registerCheckpointProposalHandler(handler: P2PCheckpointReceivedCallback): void {
|
|
381
|
+
this.p2pService.registerCheckpointReceivedCallback(handler);
|
|
382
|
+
}
|
|
383
|
+
|
|
405
384
|
/**
|
|
406
385
|
* Uses the batched Request Response protocol to request a set of transactions from the network.
|
|
407
386
|
*/
|
|
@@ -643,20 +622,23 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
643
622
|
* Public function to check the latest block number that the P2P client is synced to.
|
|
644
623
|
* @returns Block number of latest L2 Block we've synced with.
|
|
645
624
|
*/
|
|
646
|
-
public async getSyncedLatestBlockNum(): Promise<
|
|
647
|
-
|
|
625
|
+
public async getSyncedLatestBlockNum(): Promise<BlockNumber> {
|
|
626
|
+
const tips = await this.l2Tips.getL2Tips();
|
|
627
|
+
return tips.proposed.number;
|
|
648
628
|
}
|
|
649
629
|
|
|
650
630
|
/**
|
|
651
631
|
* Public function to check the latest proven block number that the P2P client is synced to.
|
|
652
632
|
* @returns Block number of latest proven L2 Block we've synced with.
|
|
653
633
|
*/
|
|
654
|
-
public async getSyncedProvenBlockNum(): Promise<
|
|
655
|
-
|
|
634
|
+
public async getSyncedProvenBlockNum(): Promise<BlockNumber> {
|
|
635
|
+
const tips = await this.l2Tips.getL2Tips();
|
|
636
|
+
return tips.proven.block.number;
|
|
656
637
|
}
|
|
657
638
|
|
|
658
|
-
public async getSyncedFinalizedBlockNum(): Promise<
|
|
659
|
-
|
|
639
|
+
public async getSyncedFinalizedBlockNum(): Promise<BlockNumber> {
|
|
640
|
+
const tips = await this.l2Tips.getL2Tips();
|
|
641
|
+
return tips.finalized.block.number;
|
|
660
642
|
}
|
|
661
643
|
|
|
662
644
|
/** Returns latest L2 slot for which we have seen an L2 block. */
|
|
@@ -672,7 +654,7 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
672
654
|
const blockNumber = await this.getSyncedLatestBlockNum();
|
|
673
655
|
const blockHash =
|
|
674
656
|
blockNumber === 0
|
|
675
|
-
?
|
|
657
|
+
? GENESIS_BLOCK_HEADER_HASH.toString()
|
|
676
658
|
: await this.l2BlockSource
|
|
677
659
|
.getBlockHeader(blockNumber)
|
|
678
660
|
.then(header => header?.hash())
|
|
@@ -680,8 +662,8 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
680
662
|
|
|
681
663
|
return {
|
|
682
664
|
state: this.currentState,
|
|
683
|
-
syncedToL2Block: { number: blockNumber, hash: blockHash },
|
|
684
|
-
}
|
|
665
|
+
syncedToL2Block: { number: blockNumber, hash: blockHash! },
|
|
666
|
+
};
|
|
685
667
|
}
|
|
686
668
|
|
|
687
669
|
/**
|
|
@@ -692,7 +674,7 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
692
674
|
private async markTxsAsMinedFromBlocks(blocks: L2Block[]): Promise<void> {
|
|
693
675
|
for (const block of blocks) {
|
|
694
676
|
const txHashes = block.body.txEffects.map(txEffect => txEffect.txHash);
|
|
695
|
-
await this.txPool.markAsMined(txHashes, block.
|
|
677
|
+
await this.txPool.markAsMined(txHashes, block.header);
|
|
696
678
|
}
|
|
697
679
|
}
|
|
698
680
|
|
|
@@ -701,29 +683,18 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
701
683
|
* @param blocks - A list of existing blocks with txs that the P2P client needs to ensure the tx pool is reconciled with.
|
|
702
684
|
* @returns Empty promise.
|
|
703
685
|
*/
|
|
704
|
-
private async handleLatestL2Blocks(blocks:
|
|
686
|
+
private async handleLatestL2Blocks(blocks: L2Block[]): Promise<void> {
|
|
705
687
|
if (!blocks.length) {
|
|
706
688
|
return Promise.resolve();
|
|
707
689
|
}
|
|
708
690
|
|
|
709
|
-
await this.markTxsAsMinedFromBlocks(blocks
|
|
710
|
-
await this.
|
|
711
|
-
|
|
712
|
-
const lastBlock = blocks.at(-1)!.block;
|
|
713
|
-
|
|
714
|
-
await Promise.all(
|
|
715
|
-
blocks.map(async block =>
|
|
716
|
-
this.setBlockHash({
|
|
717
|
-
number: block.block.number,
|
|
718
|
-
hash: await block.block.hash().then(h => h.toString()),
|
|
719
|
-
}),
|
|
720
|
-
),
|
|
721
|
-
);
|
|
691
|
+
await this.markTxsAsMinedFromBlocks(blocks);
|
|
692
|
+
await this.txPool.clearNonEvictableTxs();
|
|
693
|
+
await this.startCollectingMissingTxs(blocks);
|
|
722
694
|
|
|
723
|
-
|
|
724
|
-
await this.synchedLatestSlot.set(lastBlock.header.getSlot());
|
|
695
|
+
const lastBlock = blocks.at(-1)!;
|
|
696
|
+
await this.synchedLatestSlot.set(BigInt(lastBlock.header.getSlot()));
|
|
725
697
|
this.log.verbose(`Synched to latest block ${lastBlock.number}`);
|
|
726
|
-
await this.startServiceIfSynched();
|
|
727
698
|
}
|
|
728
699
|
|
|
729
700
|
/** Request txs for unproven blocks so the prover node has more chances to get them. */
|
|
@@ -774,19 +745,16 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
774
745
|
await this.txPool.deleteTxs(txHashes, { permanently: true });
|
|
775
746
|
await this.txPool.cleanupDeletedMinedTxs(lastBlockNum);
|
|
776
747
|
|
|
777
|
-
await this.attestationPool
|
|
748
|
+
await this.attestationPool.deleteCheckpointAttestationsOlderThan(lastBlockSlot);
|
|
778
749
|
|
|
779
|
-
await this.synchedFinalizedBlockNumber.set(lastBlockNum);
|
|
780
750
|
this.log.debug(`Synched to finalized block ${lastBlockNum} at slot ${lastBlockSlot}`);
|
|
781
|
-
|
|
782
|
-
await this.startServiceIfSynched();
|
|
783
751
|
}
|
|
784
752
|
|
|
785
753
|
/**
|
|
786
754
|
* Updates the tx pool after a chain prune.
|
|
787
755
|
* @param latestBlock - The block number the chain was pruned to.
|
|
788
756
|
*/
|
|
789
|
-
private async handlePruneL2Blocks(latestBlock:
|
|
757
|
+
private async handlePruneL2Blocks(latestBlock: BlockNumber): Promise<void> {
|
|
790
758
|
const txsToDelete = new Map<string, TxHash>();
|
|
791
759
|
const minedTxs = await this.txPool.getMinedTxHashes();
|
|
792
760
|
|
|
@@ -825,21 +793,18 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
825
793
|
this.log.info(`Deleting ${minedTxsFromReorg.length} mined txs from reorg`);
|
|
826
794
|
await this.txPool.deleteTxs(minedTxsFromReorg);
|
|
827
795
|
} else {
|
|
828
|
-
this.
|
|
829
|
-
await this.txPool.markMinedAsPending(minedTxsFromReorg);
|
|
796
|
+
await this.txPool.markMinedAsPending(minedTxsFromReorg, latestBlock);
|
|
830
797
|
}
|
|
831
|
-
|
|
832
|
-
await this.synchedLatestBlockNumber.set(latestBlock);
|
|
833
|
-
// no need to update block hashes, as they will be updated as new blocks are added
|
|
834
798
|
}
|
|
835
799
|
|
|
836
800
|
private async startServiceIfSynched() {
|
|
837
801
|
if (this.currentState !== P2PClientState.SYNCHING) {
|
|
838
802
|
return;
|
|
839
803
|
}
|
|
840
|
-
const
|
|
841
|
-
const
|
|
842
|
-
const
|
|
804
|
+
const tips = await this.l2Tips.getL2Tips();
|
|
805
|
+
const syncedFinalizedBlock = tips.finalized.block.number;
|
|
806
|
+
const syncedProvenBlock = tips.proven.block.number;
|
|
807
|
+
const syncedLatestBlock = tips.proposed.number;
|
|
843
808
|
|
|
844
809
|
if (
|
|
845
810
|
syncedLatestBlock >= this.latestBlockNumberAtStart &&
|