@aztec/p2p 0.0.1-commit.6230a0c → 0.0.1-commit.643667a5cb
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/client/factory.d.ts +7 -6
- package/dest/client/factory.d.ts.map +1 -1
- package/dest/client/factory.js +47 -11
- package/dest/client/interface.d.ts +43 -23
- package/dest/client/interface.d.ts.map +1 -1
- package/dest/client/p2p_client.d.ts +38 -42
- package/dest/client/p2p_client.d.ts.map +1 -1
- package/dest/client/p2p_client.js +145 -145
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.js +6 -6
- package/dest/config.d.ts +25 -9
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +16 -6
- package/dest/errors/tx-pool.error.d.ts +8 -0
- package/dest/errors/tx-pool.error.d.ts.map +1 -0
- package/dest/errors/tx-pool.error.js +9 -0
- package/dest/index.d.ts +2 -1
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +1 -0
- package/dest/mem_pools/attestation_pool/attestation_pool.d.ts +104 -88
- package/dest/mem_pools/attestation_pool/attestation_pool.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/attestation_pool.js +441 -3
- package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.d.ts +2 -2
- 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 +353 -87
- package/dest/mem_pools/attestation_pool/index.d.ts +2 -3
- package/dest/mem_pools/attestation_pool/index.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/index.js +1 -2
- package/dest/mem_pools/attestation_pool/mocks.d.ts +2 -2
- package/dest/mem_pools/attestation_pool/mocks.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/mocks.js +2 -2
- package/dest/mem_pools/index.d.ts +3 -2
- package/dest/mem_pools/index.d.ts.map +1 -1
- package/dest/mem_pools/index.js +1 -1
- package/dest/mem_pools/interface.d.ts +5 -5
- package/dest/mem_pools/interface.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.js +3 -3
- 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/deleted_pool.d.ts +104 -0
- package/dest/mem_pools/tx_pool_v2/deleted_pool.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/deleted_pool.js +251 -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 +128 -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 +93 -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 +95 -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 +174 -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 +25 -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 +65 -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 +93 -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 +78 -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 +73 -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 +6 -0
- package/dest/mem_pools/tx_pool_v2/index.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/index.js +5 -0
- package/dest/mem_pools/tx_pool_v2/instrumentation.d.ts +15 -0
- package/dest/mem_pools/tx_pool_v2/instrumentation.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/instrumentation.js +43 -0
- package/dest/mem_pools/tx_pool_v2/interfaces.d.ts +211 -0
- package/dest/mem_pools/tx_pool_v2/interfaces.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/interfaces.js +9 -0
- package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts +97 -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 +152 -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_indices.d.ts +108 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_indices.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_indices.js +355 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts +60 -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 +161 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts +77 -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 +896 -0
- package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.d.ts +3 -3
- package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/aggregate_tx_validator.d.ts +3 -3
- package/dest/msg_validators/tx_validator/aggregate_tx_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/block_header_validator.d.ts +16 -3
- package/dest/msg_validators/tx_validator/block_header_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/block_header_validator.js +1 -1
- package/dest/msg_validators/tx_validator/double_spend_validator.d.ts +13 -3
- package/dest/msg_validators/tx_validator/double_spend_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/double_spend_validator.js +4 -4
- package/dest/msg_validators/tx_validator/gas_validator.d.ts +1 -1
- package/dest/msg_validators/tx_validator/gas_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/gas_validator.js +3 -3
- package/dest/msg_validators/tx_validator/timestamp_validator.d.ts +20 -4
- package/dest/msg_validators/tx_validator/timestamp_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/timestamp_validator.js +6 -6
- package/dest/services/dummy_service.d.ts +12 -3
- package/dest/services/dummy_service.d.ts.map +1 -1
- package/dest/services/dummy_service.js +9 -0
- package/dest/services/encoding.d.ts +2 -2
- package/dest/services/encoding.d.ts.map +1 -1
- package/dest/services/encoding.js +4 -3
- package/dest/services/gossipsub/index.d.ts +3 -0
- package/dest/services/gossipsub/index.d.ts.map +1 -0
- package/dest/services/gossipsub/index.js +2 -0
- package/dest/services/gossipsub/scoring.d.ts +21 -3
- package/dest/services/gossipsub/scoring.d.ts.map +1 -1
- package/dest/services/gossipsub/scoring.js +24 -7
- package/dest/services/gossipsub/topic_score_params.d.ts +173 -0
- package/dest/services/gossipsub/topic_score_params.d.ts.map +1 -0
- package/dest/services/gossipsub/topic_score_params.js +346 -0
- package/dest/services/libp2p/libp2p_service.d.ts +85 -35
- package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
- package/dest/services/libp2p/libp2p_service.js +374 -275
- package/dest/services/peer-manager/peer_scoring.d.ts +1 -1
- package/dest/services/peer-manager/peer_scoring.d.ts.map +1 -1
- package/dest/services/peer-manager/peer_scoring.js +25 -2
- package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts +6 -5
- 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 +12 -16
- package/dest/services/reqresp/batch-tx-requester/interface.d.ts +2 -6
- package/dest/services/reqresp/batch-tx-requester/interface.d.ts.map +1 -1
- package/dest/services/reqresp/batch-tx-requester/missing_txs.d.ts +10 -13
- package/dest/services/reqresp/batch-tx-requester/missing_txs.d.ts.map +1 -1
- package/dest/services/reqresp/batch-tx-requester/missing_txs.js +25 -46
- package/dest/services/reqresp/interface.d.ts +10 -1
- package/dest/services/reqresp/interface.d.ts.map +1 -1
- package/dest/services/reqresp/interface.js +15 -1
- package/dest/services/reqresp/protocols/block_txs/block_txs_handler.d.ts +7 -5
- 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 -11
- package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.d.ts +21 -10
- 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 +27 -11
- package/dest/services/reqresp/protocols/tx.d.ts +7 -1
- package/dest/services/reqresp/protocols/tx.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/tx.js +20 -0
- package/dest/services/reqresp/reqresp.d.ts +1 -1
- package/dest/services/reqresp/reqresp.d.ts.map +1 -1
- package/dest/services/reqresp/reqresp.js +11 -4
- package/dest/services/service.d.ts +38 -2
- package/dest/services/service.d.ts.map +1 -1
- package/dest/services/tx_collection/config.d.ts +22 -4
- package/dest/services/tx_collection/config.d.ts.map +1 -1
- package/dest/services/tx_collection/config.js +49 -3
- package/dest/services/tx_collection/fast_tx_collection.d.ts +6 -5
- package/dest/services/tx_collection/fast_tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/fast_tx_collection.js +64 -48
- package/dest/services/tx_collection/file_store_tx_collection.d.ts +53 -0
- package/dest/services/tx_collection/file_store_tx_collection.d.ts.map +1 -0
- package/dest/services/tx_collection/file_store_tx_collection.js +167 -0
- package/dest/services/tx_collection/file_store_tx_source.d.ts +37 -0
- package/dest/services/tx_collection/file_store_tx_source.d.ts.map +1 -0
- package/dest/services/tx_collection/file_store_tx_source.js +90 -0
- package/dest/services/tx_collection/index.d.ts +3 -2
- 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 +2 -1
- package/dest/services/tx_collection/missing_txs_tracker.d.ts +32 -0
- package/dest/services/tx_collection/missing_txs_tracker.d.ts.map +1 -0
- package/dest/services/tx_collection/missing_txs_tracker.js +27 -0
- package/dest/services/tx_collection/proposal_tx_collector.d.ts +15 -14
- package/dest/services/tx_collection/proposal_tx_collector.d.ts.map +1 -1
- package/dest/services/tx_collection/proposal_tx_collector.js +6 -6
- package/dest/services/tx_collection/slow_tx_collection.d.ts +7 -3
- package/dest/services/tx_collection/slow_tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/slow_tx_collection.js +60 -26
- package/dest/services/tx_collection/tx_collection.d.ts +23 -10
- package/dest/services/tx_collection/tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/tx_collection.js +75 -3
- package/dest/services/tx_collection/tx_collection_sink.d.ts +18 -8
- package/dest/services/tx_collection/tx_collection_sink.d.ts.map +1 -1
- package/dest/services/tx_collection/tx_collection_sink.js +26 -29
- package/dest/services/tx_collection/tx_source.d.ts +8 -3
- package/dest/services/tx_collection/tx_source.d.ts.map +1 -1
- package/dest/services/tx_collection/tx_source.js +19 -2
- package/dest/services/tx_file_store/config.d.ts +1 -3
- package/dest/services/tx_file_store/config.d.ts.map +1 -1
- package/dest/services/tx_file_store/config.js +0 -4
- package/dest/services/tx_file_store/tx_file_store.d.ts +4 -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 +9 -6
- package/dest/services/tx_provider.d.ts +3 -3
- package/dest/services/tx_provider.d.ts.map +1 -1
- package/dest/services/tx_provider.js +5 -4
- package/dest/test-helpers/make-test-p2p-clients.d.ts +3 -3
- package/dest/test-helpers/make-test-p2p-clients.d.ts.map +1 -1
- package/dest/test-helpers/mock-pubsub.d.ts +29 -2
- package/dest/test-helpers/mock-pubsub.d.ts.map +1 -1
- package/dest/test-helpers/mock-pubsub.js +103 -2
- package/dest/test-helpers/reqresp-nodes.d.ts +1 -1
- package/dest/test-helpers/reqresp-nodes.d.ts.map +1 -1
- package/dest/test-helpers/reqresp-nodes.js +2 -1
- package/dest/test-helpers/testbench-utils.d.ts +43 -38
- package/dest/test-helpers/testbench-utils.d.ts.map +1 -1
- package/dest/test-helpers/testbench-utils.js +128 -59
- package/dest/testbench/p2p_client_testbench_worker.d.ts +2 -2
- package/dest/testbench/p2p_client_testbench_worker.d.ts.map +1 -1
- package/dest/testbench/p2p_client_testbench_worker.js +10 -10
- package/dest/util.d.ts +2 -2
- package/dest/util.d.ts.map +1 -1
- package/package.json +14 -14
- package/src/client/factory.ts +87 -15
- package/src/client/interface.ts +59 -23
- package/src/client/p2p_client.ts +184 -167
- package/src/client/test/tx_proposal_collector/proposal_tx_collector_worker.ts +19 -9
- package/src/config.ts +35 -11
- package/src/errors/tx-pool.error.ts +12 -0
- package/src/index.ts +1 -0
- package/src/mem_pools/attestation_pool/attestation_pool.ts +496 -91
- package/src/mem_pools/attestation_pool/attestation_pool_test_suite.ts +442 -102
- package/src/mem_pools/attestation_pool/index.ts +9 -2
- package/src/mem_pools/attestation_pool/mocks.ts +2 -1
- package/src/mem_pools/index.ts +4 -1
- package/src/mem_pools/interface.ts +4 -4
- package/src/mem_pools/tx_pool/README.md +1 -1
- package/src/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.ts +3 -3
- package/src/mem_pools/tx_pool_v2/README.md +275 -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/deleted_pool.ts +321 -0
- package/src/mem_pools/tx_pool_v2/eviction/eviction_manager.ts +160 -0
- package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.ts +121 -0
- package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.ts +122 -0
- package/src/mem_pools/tx_pool_v2/eviction/index.ts +27 -0
- package/src/mem_pools/tx_pool_v2/eviction/interfaces.ts +209 -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 +91 -0
- package/src/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.ts +90 -0
- package/src/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.ts +31 -0
- package/src/mem_pools/tx_pool_v2/index.ts +12 -0
- package/src/mem_pools/tx_pool_v2/instrumentation.ts +69 -0
- package/src/mem_pools/tx_pool_v2/interfaces.ts +242 -0
- package/src/mem_pools/tx_pool_v2/tx_metadata.ts +242 -0
- package/src/mem_pools/tx_pool_v2/tx_pool_bench_metrics.ts +77 -0
- package/src/mem_pools/tx_pool_v2/tx_pool_indices.ts +444 -0
- package/src/mem_pools/tx_pool_v2/tx_pool_v2.ts +223 -0
- package/src/mem_pools/tx_pool_v2/tx_pool_v2_impl.ts +1069 -0
- package/src/msg_validators/attestation_validator/fisherman_attestation_validator.ts +2 -2
- package/src/msg_validators/tx_validator/aggregate_tx_validator.ts +2 -2
- package/src/msg_validators/tx_validator/block_header_validator.ts +15 -3
- package/src/msg_validators/tx_validator/double_spend_validator.ts +11 -6
- package/src/msg_validators/tx_validator/gas_validator.ts +11 -3
- package/src/msg_validators/tx_validator/timestamp_validator.ts +23 -18
- package/src/services/dummy_service.ts +17 -1
- package/src/services/encoding.ts +4 -3
- package/src/services/gossipsub/README.md +641 -0
- package/src/services/gossipsub/index.ts +2 -0
- package/src/services/gossipsub/scoring.ts +29 -5
- package/src/services/gossipsub/topic_score_params.ts +487 -0
- package/src/services/libp2p/libp2p_service.ts +377 -277
- package/src/services/peer-manager/peer_scoring.ts +25 -0
- package/src/services/reqresp/batch-tx-requester/README.md +7 -7
- package/src/services/reqresp/batch-tx-requester/batch_tx_requester.ts +17 -17
- package/src/services/reqresp/batch-tx-requester/interface.ts +1 -5
- package/src/services/reqresp/batch-tx-requester/missing_txs.ts +23 -71
- package/src/services/reqresp/interface.ts +26 -1
- package/src/services/reqresp/protocols/block_txs/block_txs_handler.ts +23 -14
- package/src/services/reqresp/protocols/block_txs/block_txs_reqresp.ts +38 -15
- package/src/services/reqresp/protocols/tx.ts +22 -0
- package/src/services/reqresp/reqresp.ts +13 -3
- package/src/services/service.ts +50 -1
- package/src/services/tx_collection/config.ts +74 -6
- package/src/services/tx_collection/fast_tx_collection.ts +74 -51
- package/src/services/tx_collection/file_store_tx_collection.ts +202 -0
- package/src/services/tx_collection/file_store_tx_source.ts +117 -0
- package/src/services/tx_collection/index.ts +2 -1
- package/src/services/tx_collection/instrumentation.ts +7 -1
- package/src/services/tx_collection/missing_txs_tracker.ts +52 -0
- package/src/services/tx_collection/proposal_tx_collector.ts +20 -21
- package/src/services/tx_collection/slow_tx_collection.ts +66 -33
- package/src/services/tx_collection/tx_collection.ts +113 -16
- package/src/services/tx_collection/tx_collection_sink.ts +30 -34
- package/src/services/tx_collection/tx_source.ts +22 -3
- package/src/services/tx_file_store/config.ts +0 -6
- package/src/services/tx_file_store/tx_file_store.ts +10 -8
- package/src/services/tx_provider.ts +8 -7
- package/src/test-helpers/make-test-p2p-clients.ts +3 -3
- package/src/test-helpers/mock-pubsub.ts +143 -3
- package/src/test-helpers/reqresp-nodes.ts +2 -1
- package/src/test-helpers/testbench-utils.ts +127 -71
- package/src/testbench/p2p_client_testbench_worker.ts +22 -15
- package/src/util.ts +7 -1
- package/dest/mem_pools/attestation_pool/kv_attestation_pool.d.ts +0 -40
- package/dest/mem_pools/attestation_pool/kv_attestation_pool.d.ts.map +0 -1
- package/dest/mem_pools/attestation_pool/kv_attestation_pool.js +0 -218
- package/dest/mem_pools/attestation_pool/memory_attestation_pool.d.ts +0 -31
- package/dest/mem_pools/attestation_pool/memory_attestation_pool.d.ts.map +0 -1
- package/dest/mem_pools/attestation_pool/memory_attestation_pool.js +0 -180
- package/src/mem_pools/attestation_pool/kv_attestation_pool.ts +0 -320
- package/src/mem_pools/attestation_pool/memory_attestation_pool.ts +0 -264
|
@@ -372,8 +372,9 @@ function _apply_decs_2203_r(targetClass, memberDecs, classDecs, parentClass) {
|
|
|
372
372
|
}
|
|
373
373
|
var _dec, _dec1, _initProto;
|
|
374
374
|
import { GENESIS_BLOCK_HEADER_HASH } from '@aztec/constants';
|
|
375
|
-
import { BlockNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
375
|
+
import { BlockNumber, CheckpointNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
376
376
|
import { createLogger } from '@aztec/foundation/log';
|
|
377
|
+
import { RunningPromise } from '@aztec/foundation/promise';
|
|
377
378
|
import { DateProvider } from '@aztec/foundation/timer';
|
|
378
379
|
import { L2TipsKVStore } from '@aztec/kv-store/stores';
|
|
379
380
|
import { L2BlockStream } from '@aztec/stdlib/block';
|
|
@@ -381,6 +382,7 @@ import { getTimestampForSlot } from '@aztec/stdlib/epoch-helpers';
|
|
|
381
382
|
import { tryStop } from '@aztec/stdlib/interfaces/server';
|
|
382
383
|
import { Attributes, WithTracer, getTelemetryClient, trackSpan } from '@aztec/telemetry-client';
|
|
383
384
|
import { getP2PDefaultConfig } from '../config.js';
|
|
385
|
+
import { TxPoolError } from '../errors/tx-pool.error.js';
|
|
384
386
|
import { ReqRespSubProtocol } from '../services/reqresp/interface.js';
|
|
385
387
|
import { chunkTxHashesRequest } from '../services/reqresp/protocols/tx.js';
|
|
386
388
|
import { TxProvider } from '../services/tx_provider.js';
|
|
@@ -402,6 +404,7 @@ _dec = trackSpan('p2pClient.broadcastProposal', async (proposal)=>({
|
|
|
402
404
|
p2pService;
|
|
403
405
|
txCollection;
|
|
404
406
|
txFileStore;
|
|
407
|
+
epochCache;
|
|
405
408
|
_dateProvider;
|
|
406
409
|
telemetry;
|
|
407
410
|
log;
|
|
@@ -434,15 +437,10 @@ _dec = trackSpan('p2pClient.broadcastProposal', async (proposal)=>({
|
|
|
434
437
|
blockStream;
|
|
435
438
|
txProvider;
|
|
436
439
|
validatorAddresses;
|
|
437
|
-
/**
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
* @param txPool - The client's instance of a transaction pool. Defaults to in-memory implementation.
|
|
442
|
-
* @param p2pService - The concrete instance of p2p networking to use.
|
|
443
|
-
* @param log - A logger.
|
|
444
|
-
*/ constructor(_clientType, store, l2BlockSource, mempools, p2pService, txCollection, txFileStore, config = {}, _dateProvider = new DateProvider(), telemetry = getTelemetryClient(), log = createLogger('p2p')){
|
|
445
|
-
super(telemetry, 'P2PClient'), this.store = store, this.l2BlockSource = l2BlockSource, this.p2pService = p2pService, this.txCollection = txCollection, this.txFileStore = txFileStore, 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 = [];
|
|
440
|
+
/** Tracks the last slot for which we called prepareForSlot */ lastSlotProcessed;
|
|
441
|
+
/** Polls for slot changes and calls prepareForSlot on the tx pool */ slotMonitor;
|
|
442
|
+
constructor(_clientType, store, l2BlockSource, mempools, p2pService, txCollection, txFileStore, epochCache, config = {}, _dateProvider = new DateProvider(), telemetry = getTelemetryClient(), log = createLogger('p2p')){
|
|
443
|
+
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;
|
|
446
444
|
this.config = {
|
|
447
445
|
...getP2PDefaultConfig(),
|
|
448
446
|
...config
|
|
@@ -494,13 +492,15 @@ _dec = trackSpan('p2pClient.broadcastProposal', async (proposal)=>({
|
|
|
494
492
|
getPeers(includePending) {
|
|
495
493
|
return Promise.resolve(this.p2pService.getPeers(includePending));
|
|
496
494
|
}
|
|
495
|
+
getGossipMeshPeerCount(topicType) {
|
|
496
|
+
return Promise.resolve(this.p2pService.getGossipMeshPeerCount(topicType));
|
|
497
|
+
}
|
|
497
498
|
getL2BlockHash(number) {
|
|
498
499
|
return this.l2Tips.getL2BlockHash(number);
|
|
499
500
|
}
|
|
500
|
-
updateP2PConfig(config) {
|
|
501
|
-
this.txPool.updateConfig(config);
|
|
501
|
+
async updateP2PConfig(config) {
|
|
502
|
+
await this.txPool.updateConfig(config);
|
|
502
503
|
this.p2pService.updateConfig(config);
|
|
503
|
-
return Promise.resolve();
|
|
504
504
|
}
|
|
505
505
|
getL2Tips() {
|
|
506
506
|
return this.l2Tips.getL2Tips();
|
|
@@ -527,7 +527,7 @@ _dec = trackSpan('p2pClient.broadcastProposal', async (proposal)=>({
|
|
|
527
527
|
break;
|
|
528
528
|
case 'chain-pruned':
|
|
529
529
|
this.txCollection.stopCollectingForBlocksAfter(event.block.number);
|
|
530
|
-
await this.handlePruneL2Blocks(event.block.
|
|
530
|
+
await this.handlePruneL2Blocks(event.block, event.checkpoint);
|
|
531
531
|
break;
|
|
532
532
|
case 'chain-checkpointed':
|
|
533
533
|
break;
|
|
@@ -542,7 +542,6 @@ _dec = trackSpan('p2pClient.broadcastProposal', async (proposal)=>({
|
|
|
542
542
|
await this.startServiceIfSynched();
|
|
543
543
|
}
|
|
544
544
|
#assertIsReady() {
|
|
545
|
-
// this.log.info('Checking if p2p client is ready, current state: ', this.currentState);
|
|
546
545
|
if (!this.isReady()) {
|
|
547
546
|
throw new Error('P2P client not ready');
|
|
548
547
|
}
|
|
@@ -557,6 +556,8 @@ _dec = trackSpan('p2pClient.broadcastProposal', async (proposal)=>({
|
|
|
557
556
|
if (this.currentState !== P2PClientState.IDLE) {
|
|
558
557
|
return this.syncPromise;
|
|
559
558
|
}
|
|
559
|
+
// Start the tx pool first, as it needs to hydrate state from persistence
|
|
560
|
+
await this.txPool.start();
|
|
560
561
|
// get the current latest block numbers
|
|
561
562
|
const latestBlockNumbers = await this.l2BlockSource.getL2Tips();
|
|
562
563
|
this.latestBlockNumberAtStart = latestBlockNumbers.proposed.number;
|
|
@@ -600,6 +601,9 @@ _dec = trackSpan('p2pClient.broadcastProposal', async (proposal)=>({
|
|
|
600
601
|
this.blockStream.start();
|
|
601
602
|
await this.txCollection.start();
|
|
602
603
|
this.txFileStore?.start();
|
|
604
|
+
// Start slot monitor to call prepareForSlot when the slot changes
|
|
605
|
+
this.slotMonitor = new RunningPromise(()=>this.maybeCallPrepareForSlot(), this.log, this.config.slotCheckIntervalMS);
|
|
606
|
+
this.slotMonitor.start();
|
|
603
607
|
return this.syncPromise;
|
|
604
608
|
}
|
|
605
609
|
addReqRespSubProtocol(subProtocol, handler, validator) {
|
|
@@ -620,6 +624,8 @@ _dec = trackSpan('p2pClient.broadcastProposal', async (proposal)=>({
|
|
|
620
624
|
* 'ready' will now return 'false' and the running promise that keeps the client synced is interrupted.
|
|
621
625
|
*/ async stop() {
|
|
622
626
|
this.log.debug('Stopping p2p client...');
|
|
627
|
+
await this.slotMonitor?.stop();
|
|
628
|
+
this.log.debug('Stopped slot monitor');
|
|
623
629
|
await tryStop(this.txCollection);
|
|
624
630
|
this.log.debug('Stopped tx collection service');
|
|
625
631
|
await this.txFileStore?.stop();
|
|
@@ -628,6 +634,8 @@ _dec = trackSpan('p2pClient.broadcastProposal', async (proposal)=>({
|
|
|
628
634
|
this.log.debug('Stopped p2p service');
|
|
629
635
|
await this.blockStream?.stop();
|
|
630
636
|
this.log.debug('Stopped block downloader');
|
|
637
|
+
await this.txPool.stop();
|
|
638
|
+
this.log.debug('Stopped tx pool');
|
|
631
639
|
await this.runningPromise;
|
|
632
640
|
this.setCurrentState(P2PClientState.STOPPED);
|
|
633
641
|
this.log.info('P2P client stopped');
|
|
@@ -639,7 +647,18 @@ _dec = trackSpan('p2pClient.broadcastProposal', async (proposal)=>({
|
|
|
639
647
|
async broadcastProposal(proposal) {
|
|
640
648
|
this.log.verbose(`Broadcasting proposal for slot ${proposal.slotNumber} to peers`);
|
|
641
649
|
// Store our own proposal so we can respond to req/resp requests for it
|
|
642
|
-
await this.attestationPool.
|
|
650
|
+
const { count } = await this.attestationPool.tryAddBlockProposal(proposal);
|
|
651
|
+
if (count > 1) {
|
|
652
|
+
if (this.config.broadcastEquivocatedProposals) {
|
|
653
|
+
this.log.warn(`Broadcasting equivocated block proposal for slot ${proposal.slotNumber}`, {
|
|
654
|
+
slot: proposal.slotNumber,
|
|
655
|
+
archive: proposal.archive.toString(),
|
|
656
|
+
count
|
|
657
|
+
});
|
|
658
|
+
} else {
|
|
659
|
+
throw new Error(`Attempted to broadcast a duplicate block proposal for slot ${proposal.slotNumber}`);
|
|
660
|
+
}
|
|
661
|
+
}
|
|
643
662
|
return this.p2pService.propagate(proposal);
|
|
644
663
|
}
|
|
645
664
|
async broadcastCheckpointProposal(proposal) {
|
|
@@ -647,7 +666,7 @@ _dec = trackSpan('p2pClient.broadcastProposal', async (proposal)=>({
|
|
|
647
666
|
const blockProposal = proposal.getBlockProposal();
|
|
648
667
|
if (blockProposal) {
|
|
649
668
|
// Store our own last-block proposal so we can respond to req/resp requests for it.
|
|
650
|
-
await this.attestationPool.
|
|
669
|
+
await this.attestationPool.tryAddBlockProposal(blockProposal);
|
|
651
670
|
}
|
|
652
671
|
return this.p2pService.propagate(proposal);
|
|
653
672
|
}
|
|
@@ -658,8 +677,11 @@ _dec = trackSpan('p2pClient.broadcastProposal', async (proposal)=>({
|
|
|
658
677
|
async getCheckpointAttestationsForSlot(slot, proposalId) {
|
|
659
678
|
return await (proposalId ? this.attestationPool.getCheckpointAttestationsForSlotAndProposal(slot, proposalId) : this.attestationPool.getCheckpointAttestationsForSlot(slot));
|
|
660
679
|
}
|
|
661
|
-
|
|
662
|
-
return this.attestationPool.
|
|
680
|
+
addOwnCheckpointAttestations(attestations) {
|
|
681
|
+
return this.attestationPool.addOwnCheckpointAttestations(attestations);
|
|
682
|
+
}
|
|
683
|
+
hasBlockProposalsForSlot(slot) {
|
|
684
|
+
return this.attestationPool.hasBlockProposalsForSlot(slot);
|
|
663
685
|
}
|
|
664
686
|
// REVIEW: https://github.com/AztecProtocol/aztec-packages/issues/7963
|
|
665
687
|
// ^ This pattern is not my favorite (md)
|
|
@@ -669,6 +691,12 @@ _dec = trackSpan('p2pClient.broadcastProposal', async (proposal)=>({
|
|
|
669
691
|
registerCheckpointProposalHandler(handler) {
|
|
670
692
|
this.p2pService.registerCheckpointReceivedCallback(handler);
|
|
671
693
|
}
|
|
694
|
+
registerDuplicateProposalCallback(callback) {
|
|
695
|
+
this.p2pService.registerDuplicateProposalCallback(callback);
|
|
696
|
+
}
|
|
697
|
+
registerDuplicateAttestationCallback(callback) {
|
|
698
|
+
this.p2pService.registerDuplicateAttestationCallback(callback);
|
|
699
|
+
}
|
|
672
700
|
/**
|
|
673
701
|
* Uses the batched Request Response protocol to request a set of transactions from the network.
|
|
674
702
|
*/ async requestTxsByHash(txHashes, pinnedPeerId) {
|
|
@@ -679,15 +707,30 @@ _dec = trackSpan('p2pClient.broadcastProposal', async (proposal)=>({
|
|
|
679
707
|
const txBatches = await this.p2pService.sendBatchRequest(ReqRespSubProtocol.TX, requests, pinnedPeerId, timeoutMs, maxPeers, maxRetryAttempts);
|
|
680
708
|
const txs = txBatches.flat();
|
|
681
709
|
if (txs.length > 0) {
|
|
682
|
-
await this.txPool.
|
|
710
|
+
await this.txPool.addPendingTxs(txs);
|
|
683
711
|
}
|
|
684
712
|
const txHashesStr = txHashes.map((tx)=>tx.toString()).join(', ');
|
|
685
713
|
this.log.debug(`Requested txs ${txHashesStr} (${txs.length} / ${txHashes.length}) from peers`);
|
|
686
714
|
// We return all transactions, even the not found ones to the caller, such they can handle missing items themselves.
|
|
687
715
|
return txs;
|
|
688
716
|
}
|
|
689
|
-
getPendingTxs(limit, after) {
|
|
690
|
-
|
|
717
|
+
async getPendingTxs(limit, after) {
|
|
718
|
+
if (limit !== undefined && limit <= 0) {
|
|
719
|
+
throw new TypeError('limit must be greater than 0');
|
|
720
|
+
}
|
|
721
|
+
let txHashes = await this.txPool.getPendingTxHashes();
|
|
722
|
+
let startIndex = 0;
|
|
723
|
+
if (after) {
|
|
724
|
+
startIndex = txHashes.findIndex((txHash)=>after.equals(txHash));
|
|
725
|
+
if (startIndex === -1) {
|
|
726
|
+
return [];
|
|
727
|
+
}
|
|
728
|
+
startIndex++;
|
|
729
|
+
}
|
|
730
|
+
const endIndex = limit !== undefined ? startIndex + limit : undefined;
|
|
731
|
+
txHashes = txHashes.slice(startIndex, endIndex);
|
|
732
|
+
const maybeTxs = await Promise.all(txHashes.map((txHash)=>this.txPool.getTxByHash(txHash)));
|
|
733
|
+
return maybeTxs.filter((tx)=>!!tx);
|
|
691
734
|
}
|
|
692
735
|
getPendingTxCount() {
|
|
693
736
|
return this.txPool.getPendingTxCount();
|
|
@@ -700,52 +743,13 @@ _dec = trackSpan('p2pClient.broadcastProposal', async (proposal)=>({
|
|
|
700
743
|
}
|
|
701
744
|
}
|
|
702
745
|
}
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
* @returns An array of Txs.
|
|
709
|
-
*/ async getTxs(filter, limit, after) {
|
|
710
|
-
if (limit !== undefined && limit <= 0) {
|
|
711
|
-
throw new TypeError('limit must be greater than 0');
|
|
712
|
-
}
|
|
713
|
-
let txs = undefined;
|
|
714
|
-
let txHashes;
|
|
715
|
-
if (filter === 'all') {
|
|
716
|
-
txs = await this.txPool.getAllTxs();
|
|
717
|
-
txHashes = await Promise.all(txs.map((tx)=>tx.getTxHash()));
|
|
718
|
-
} else if (filter === 'mined') {
|
|
719
|
-
const minedTxHashes = await this.txPool.getMinedTxHashes();
|
|
720
|
-
txHashes = minedTxHashes.map(([txHash])=>txHash);
|
|
721
|
-
} else if (filter === 'pending') {
|
|
722
|
-
txHashes = await this.txPool.getPendingTxHashes();
|
|
723
|
-
} else {
|
|
724
|
-
const _ = filter;
|
|
725
|
-
throw new Error(`Unknown filter ${filter}`);
|
|
726
|
-
}
|
|
727
|
-
let startIndex = 0;
|
|
728
|
-
let endIndex = undefined;
|
|
729
|
-
if (after) {
|
|
730
|
-
startIndex = txHashes.findIndex((txHash)=>after.equals(txHash));
|
|
731
|
-
// if we can't find the last tx in our set then return an empty array as pagination is no longer valid.
|
|
732
|
-
if (startIndex === -1) {
|
|
733
|
-
return [];
|
|
746
|
+
async *iterateEligiblePendingTxs() {
|
|
747
|
+
for (const txHash of (await this.txPool.getEligiblePendingTxHashes())){
|
|
748
|
+
const tx = await this.txPool.getTxByHash(txHash);
|
|
749
|
+
if (tx) {
|
|
750
|
+
yield tx;
|
|
734
751
|
}
|
|
735
|
-
// increment by one because we don't want to return the same tx again
|
|
736
|
-
startIndex++;
|
|
737
|
-
}
|
|
738
|
-
if (limit !== undefined) {
|
|
739
|
-
endIndex = startIndex + limit;
|
|
740
752
|
}
|
|
741
|
-
txHashes = txHashes.slice(startIndex, endIndex);
|
|
742
|
-
if (txs) {
|
|
743
|
-
txs = txs.slice(startIndex, endIndex);
|
|
744
|
-
} else {
|
|
745
|
-
const maybeTxs = await Promise.all(txHashes.map((txHash)=>this.txPool.getTxByHash(txHash)));
|
|
746
|
-
txs = maybeTxs.filter((tx)=>!!tx);
|
|
747
|
-
}
|
|
748
|
-
return txs;
|
|
749
753
|
}
|
|
750
754
|
/**
|
|
751
755
|
* Returns a transaction in the transaction pool by its hash.
|
|
@@ -808,31 +812,35 @@ _dec = trackSpan('p2pClient.broadcastProposal', async (proposal)=>({
|
|
|
808
812
|
return this.txPool.getArchivedTxByHash(txHash);
|
|
809
813
|
}
|
|
810
814
|
/**
|
|
811
|
-
*
|
|
812
|
-
* @param tx - The tx to
|
|
815
|
+
* Accepts a transaction, adds it to local tx pool and forwards it to other peers.
|
|
816
|
+
* @param tx - The tx to send.
|
|
813
817
|
* @returns Empty promise.
|
|
814
818
|
**/ async sendTx(tx) {
|
|
815
|
-
|
|
819
|
+
this.#assertIsReady();
|
|
820
|
+
const result = await this.txPool.addPendingTxs([
|
|
816
821
|
tx
|
|
817
|
-
]
|
|
818
|
-
|
|
819
|
-
|
|
822
|
+
], {
|
|
823
|
+
feeComparisonOnly: true
|
|
824
|
+
});
|
|
825
|
+
if (result.accepted.length === 1) {
|
|
820
826
|
await this.p2pService.propagate(tx);
|
|
827
|
+
return;
|
|
821
828
|
}
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
+
const txHashStr = tx.getTxHash().toString();
|
|
830
|
+
const reason = result.errors?.get(txHashStr);
|
|
831
|
+
if (reason) {
|
|
832
|
+
this.log.warn(`Tx ${txHashStr} not added to pool: ${reason.message}`);
|
|
833
|
+
throw new TxPoolError(reason);
|
|
834
|
+
}
|
|
835
|
+
this.log.warn(`Tx ${txHashStr} not propagated: accepted=${result.accepted.length} ignored=${result.ignored.length} rejected=${result.rejected.length}`);
|
|
829
836
|
}
|
|
830
837
|
/**
|
|
831
838
|
* Returns whether the given tx hash is flagged as pending or mined.
|
|
832
839
|
* @param txHash - Hash of the tx to query.
|
|
833
840
|
* @returns Pending or mined depending on its status, or undefined if not found.
|
|
834
|
-
*/ getTxStatus(txHash) {
|
|
835
|
-
|
|
841
|
+
*/ async getTxStatus(txHash) {
|
|
842
|
+
const status = await this.txPool.getTxStatus(txHash);
|
|
843
|
+
return status === 'protected' ? 'pending' : status;
|
|
836
844
|
}
|
|
837
845
|
getEnr() {
|
|
838
846
|
return this.p2pService.getEnr();
|
|
@@ -841,13 +849,11 @@ _dec = trackSpan('p2pClient.broadcastProposal', async (proposal)=>({
|
|
|
841
849
|
return Promise.resolve(this.p2pService.getEnr()?.encodeTxt());
|
|
842
850
|
}
|
|
843
851
|
/**
|
|
844
|
-
*
|
|
845
|
-
*
|
|
846
|
-
|
|
847
|
-
* @returns Empty promise.
|
|
848
|
-
**/ async deleteTxs(txHashes) {
|
|
852
|
+
* Handles failed transaction execution by removing txs from the pool.
|
|
853
|
+
* @param txHashes - Hashes of the transactions that failed execution.
|
|
854
|
+
**/ async handleFailedExecution(txHashes) {
|
|
849
855
|
this.#assertIsReady();
|
|
850
|
-
await this.txPool.
|
|
856
|
+
await this.txPool.handleFailedExecution(txHashes);
|
|
851
857
|
}
|
|
852
858
|
/**
|
|
853
859
|
* Public function to check if the p2p client is fully synced and ready to receive txs.
|
|
@@ -891,13 +897,12 @@ _dec = trackSpan('p2pClient.broadcastProposal', async (proposal)=>({
|
|
|
891
897
|
};
|
|
892
898
|
}
|
|
893
899
|
/**
|
|
894
|
-
*
|
|
900
|
+
* Handles mined blocks by marking the txs in them as mined.
|
|
895
901
|
* @param blocks - A list of existing blocks with txs that the P2P client needs to ensure the tx pool is reconciled with.
|
|
896
902
|
* @returns Empty promise.
|
|
897
|
-
*/ async
|
|
903
|
+
*/ async handleMinedBlocks(blocks) {
|
|
898
904
|
for (const block of blocks){
|
|
899
|
-
|
|
900
|
-
await this.txPool.markAsMined(txHashes, block.header);
|
|
905
|
+
await this.txPool.handleMinedBlock(block);
|
|
901
906
|
}
|
|
902
907
|
}
|
|
903
908
|
/**
|
|
@@ -906,14 +911,13 @@ _dec = trackSpan('p2pClient.broadcastProposal', async (proposal)=>({
|
|
|
906
911
|
* @returns Empty promise.
|
|
907
912
|
*/ async handleLatestL2Blocks(blocks) {
|
|
908
913
|
if (!blocks.length) {
|
|
909
|
-
return
|
|
914
|
+
return;
|
|
910
915
|
}
|
|
911
|
-
await this.
|
|
912
|
-
await this.
|
|
916
|
+
await this.handleMinedBlocks(blocks);
|
|
917
|
+
await this.maybeCallPrepareForSlot();
|
|
913
918
|
await this.startCollectingMissingTxs(blocks);
|
|
914
919
|
const lastBlock = blocks.at(-1);
|
|
915
920
|
await this.synchedLatestSlot.set(BigInt(lastBlock.header.getSlot()));
|
|
916
|
-
this.log.verbose(`Synched to latest block ${lastBlock.number}`);
|
|
917
921
|
}
|
|
918
922
|
/** Request txs for unproven blocks so the prover node has more chances to get them. */ async startCollectingMissingTxs(blocks) {
|
|
919
923
|
try {
|
|
@@ -947,59 +951,45 @@ _dec = trackSpan('p2pClient.broadcastProposal', async (proposal)=>({
|
|
|
947
951
|
* @returns Empty promise.
|
|
948
952
|
*/ async handleFinalizedL2Blocks(blocks) {
|
|
949
953
|
if (!blocks.length) {
|
|
950
|
-
return
|
|
954
|
+
return;
|
|
951
955
|
}
|
|
952
|
-
|
|
953
|
-
const
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
this.log.debug(`Deleting ${txHashes.length} txs from pool from finalized blocks up to ${lastBlockNum}`);
|
|
957
|
-
await this.txPool.deleteTxs(txHashes, {
|
|
958
|
-
permanently: true
|
|
959
|
-
});
|
|
960
|
-
await this.txPool.cleanupDeletedMinedTxs(lastBlockNum);
|
|
961
|
-
await this.attestationPool.deleteCheckpointAttestationsOlderThan(lastBlockSlot);
|
|
962
|
-
this.log.debug(`Synched to finalized block ${lastBlockNum} at slot ${lastBlockSlot}`);
|
|
956
|
+
// Finalization is monotonic, so we only need to call with the last block
|
|
957
|
+
const lastBlock = blocks.at(-1);
|
|
958
|
+
await this.txPool.handleFinalizedBlock(lastBlock.header);
|
|
959
|
+
await this.attestationPool.deleteOlderThan(lastBlock.header.getSlot());
|
|
963
960
|
}
|
|
964
961
|
/**
|
|
965
962
|
* Updates the tx pool after a chain prune.
|
|
966
|
-
*
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
if (tx.data.constants.anchorBlockHeader.globalVariables.blockNumber > latestBlock) {
|
|
974
|
-
const txHash = tx.getTxHash();
|
|
975
|
-
txsToDelete.set(txHash.toString(), txHash);
|
|
976
|
-
}
|
|
977
|
-
}
|
|
978
|
-
this.log.info(`Detected chain prune. Removing ${txsToDelete.size} txs built against pruned blocks.`, {
|
|
979
|
-
newLatestBlock: latestBlock,
|
|
980
|
-
previousLatestBlock: await this.getSyncedLatestBlockNum(),
|
|
981
|
-
txsToDelete: Array.from(txsToDelete.keys())
|
|
963
|
+
* Detects epoch prunes (checkpoint number changed) and deletes all txs in that case.
|
|
964
|
+
* @param latestBlock - The block ID the chain was pruned to.
|
|
965
|
+
* @param newCheckpoint - The checkpoint ID after the prune.
|
|
966
|
+
*/ async handlePruneL2Blocks(latestBlock, newCheckpoint) {
|
|
967
|
+
const deleteAllTxs = this.config.txPoolDeleteTxsAfterReorg && await this.isEpochPrune(newCheckpoint);
|
|
968
|
+
await this.txPool.handlePrunedBlocks(latestBlock, {
|
|
969
|
+
deleteAllTxs
|
|
982
970
|
});
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
const
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
if (blockNumber > latestBlock && !txsToDelete.has(txHash.toString())) {
|
|
994
|
-
minedTxsFromReorg.push(txHash);
|
|
995
|
-
}
|
|
971
|
+
}
|
|
972
|
+
/**
|
|
973
|
+
* Returns true if the prune crossed a checkpoint boundary.
|
|
974
|
+
* If the old and new checkpoint numbers are the same, the prune is within a single checkpoint.
|
|
975
|
+
* If they differ, the prune spans across checkpoints (epoch prune).
|
|
976
|
+
*/ async isEpochPrune(newCheckpoint) {
|
|
977
|
+
const tips = await this.l2Tips.getL2Tips();
|
|
978
|
+
const oldCheckpointNumber = tips.checkpointed.checkpoint.number;
|
|
979
|
+
if (oldCheckpointNumber <= CheckpointNumber.ZERO) {
|
|
980
|
+
return false;
|
|
996
981
|
}
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
982
|
+
const isEpochPrune = oldCheckpointNumber !== newCheckpoint.number;
|
|
983
|
+
this.log.info(`Detected epoch prune: ${isEpochPrune}. Old checkpoint: ${oldCheckpointNumber}, new checkpoint: ${newCheckpoint.number}`);
|
|
984
|
+
return isEpochPrune;
|
|
985
|
+
}
|
|
986
|
+
/** Checks if the slot has changed and calls prepareForSlot if so. */ async maybeCallPrepareForSlot() {
|
|
987
|
+
const { currentSlot } = this.epochCache.getCurrentAndNextSlot();
|
|
988
|
+
if (currentSlot <= this.lastSlotProcessed) {
|
|
989
|
+
return;
|
|
1002
990
|
}
|
|
991
|
+
this.lastSlotProcessed = currentSlot;
|
|
992
|
+
await this.txPool.prepareForSlot(currentSlot);
|
|
1003
993
|
}
|
|
1004
994
|
async startServiceIfSynched() {
|
|
1005
995
|
if (this.currentState !== P2PClientState.SYNCHING) {
|
|
@@ -1034,10 +1024,20 @@ _dec = trackSpan('p2pClient.broadcastProposal', async (proposal)=>({
|
|
|
1034
1024
|
return this.p2pService.validate(txs);
|
|
1035
1025
|
}
|
|
1036
1026
|
/**
|
|
1037
|
-
*
|
|
1038
|
-
*
|
|
1039
|
-
|
|
1040
|
-
|
|
1027
|
+
* Protects existing transactions by hash for a given slot.
|
|
1028
|
+
* Returns hashes of transactions that weren't found in the pool.
|
|
1029
|
+
* @param txHashes - Hashes of the transactions to protect.
|
|
1030
|
+
* @param blockHeader - The block header providing slot context.
|
|
1031
|
+
* @returns Hashes of transactions not found in the pool.
|
|
1032
|
+
*/ protectTxs(txHashes, blockHeader) {
|
|
1033
|
+
return this.txPool.protectTxs(txHashes, blockHeader);
|
|
1034
|
+
}
|
|
1035
|
+
/**
|
|
1036
|
+
* Prepares the pool for a new slot.
|
|
1037
|
+
* Unprotects transactions from earlier slots and validates them.
|
|
1038
|
+
* @param slotNumber - The slot number to prepare for
|
|
1039
|
+
*/ async prepareForSlot(slotNumber) {
|
|
1040
|
+
await this.txPool.prepareForSlot(slotNumber);
|
|
1041
1041
|
}
|
|
1042
1042
|
handleAuthRequestFromPeer(authRequest, peerId) {
|
|
1043
1043
|
return this.p2pService.handleAuthRequestFromPeer(authRequest, peerId);
|
|
@@ -7,10 +7,10 @@ import { openTmpStore } from '@aztec/kv-store/lmdb-v2';
|
|
|
7
7
|
import { P2PClientType } from '@aztec/stdlib/p2p';
|
|
8
8
|
import { getTelemetryClient } from '@aztec/telemetry-client';
|
|
9
9
|
import { peerIdFromString } from '@libp2p/peer-id';
|
|
10
|
+
import { BatchTxRequesterCollector, SendBatchRequestCollector } from '../../../services/index.js';
|
|
10
11
|
import { RateLimitStatus } from '../../../services/reqresp/rate-limiter/rate_limiter.js';
|
|
11
|
-
import {
|
|
12
|
-
import { AlwaysTrueCircuitVerifier } from '../../../test-helpers/
|
|
13
|
-
import { BENCHMARK_CONSTANTS, InMemoryAttestationPool, InMemoryTxPool, UNLIMITED_RATE_LIMIT_QUOTA, calculateInternalTimeout, createMockEpochCache, createMockWorldStateSynchronizer } from '../../../test-helpers/testbench-utils.js';
|
|
12
|
+
import { MissingTxsTracker } from '../../../services/tx_collection/missing_txs_tracker.js';
|
|
13
|
+
import { AlwaysTrueCircuitVerifier, BENCHMARK_CONSTANTS, InMemoryAttestationPool, InMemoryTxPool, UNLIMITED_RATE_LIMIT_QUOTA, calculateInternalTimeout, createMockEpochCache, createMockWorldStateSynchronizer } from '../../../test-helpers/index.js';
|
|
14
14
|
import { createP2PClient } from '../../index.js';
|
|
15
15
|
import { deserializeBlockProposal, deserializeTx, deserializeTxHash } from './proposal_tx_collector_worker_protocol.js';
|
|
16
16
|
let client;
|
|
@@ -162,11 +162,11 @@ async function runCollector(cmd) {
|
|
|
162
162
|
try {
|
|
163
163
|
if (collectorType === 'batch-requester') {
|
|
164
164
|
const collector = new BatchTxRequesterCollector(p2pService, logger, new DateProvider(), noopTxValidator);
|
|
165
|
-
const fetched = await executeTimeout((_signal)=>collector.collectTxs(parsedTxHashes, parsedProposal, pinnedPeer, internalTimeoutMs), timeoutMs, ()=>new Error(`Collector timed out after ${timeoutMs}ms`));
|
|
165
|
+
const fetched = await executeTimeout((_signal)=>collector.collectTxs(MissingTxsTracker.fromArray(parsedTxHashes), parsedProposal, pinnedPeer, internalTimeoutMs), timeoutMs, ()=>new Error(`Collector timed out after ${timeoutMs}ms`));
|
|
166
166
|
fetchedCount = fetched.length;
|
|
167
167
|
} else {
|
|
168
168
|
const collector = new SendBatchRequestCollector(p2pService, BENCHMARK_CONSTANTS.FIXED_MAX_PEERS, BENCHMARK_CONSTANTS.FIXED_MAX_RETRY_ATTEMPTS);
|
|
169
|
-
const fetched = await executeTimeout((_signal)=>collector.collectTxs(parsedTxHashes, parsedProposal, pinnedPeer, internalTimeoutMs), timeoutMs, ()=>new Error(`Collector timed out after ${timeoutMs}ms`));
|
|
169
|
+
const fetched = await executeTimeout((_signal)=>collector.collectTxs(MissingTxsTracker.fromArray(parsedTxHashes), parsedProposal, pinnedPeer, internalTimeoutMs), timeoutMs, ()=>new Error(`Collector timed out after ${timeoutMs}ms`));
|
|
170
170
|
fetchedCount = fetched.length;
|
|
171
171
|
}
|
|
172
172
|
} catch (err) {
|
|
@@ -246,7 +246,7 @@ process.on('message', (msg)=>{
|
|
|
246
246
|
throw new Error('Attestation pool not initialized');
|
|
247
247
|
}
|
|
248
248
|
const proposal = deserializeBlockProposal(msg.blockProposal);
|
|
249
|
-
await attestationPool.
|
|
249
|
+
await attestationPool.tryAddBlockProposal(proposal);
|
|
250
250
|
await sendMessage({
|
|
251
251
|
type: 'BLOCK_PROPOSAL_SET',
|
|
252
252
|
requestId,
|