@aztec/p2p 0.0.1-commit.f2ce05ee → 0.0.1-commit.f81dbcf
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 +8 -8
- package/dest/client/factory.d.ts.map +1 -1
- package/dest/client/factory.js +42 -13
- package/dest/client/interface.d.ts +39 -33
- package/dest/client/interface.d.ts.map +1 -1
- package/dest/client/p2p_client.d.ts +37 -50
- package/dest/client/p2p_client.d.ts.map +1 -1
- package/dest/client/p2p_client.js +144 -223
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.js +6 -7
- package/dest/config.d.ts +47 -11
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +94 -31
- 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 +21 -12
- package/dest/mem_pools/attestation_pool/attestation_pool.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/attestation_pool.js +67 -37
- 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 +53 -53
- package/dest/mem_pools/attestation_pool/index.d.ts +2 -2
- package/dest/mem_pools/attestation_pool/index.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/index.js +1 -1
- 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 +2 -1
- package/dest/mem_pools/index.d.ts.map +1 -1
- package/dest/mem_pools/interface.d.ts +3 -3
- 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/priority.d.ts +2 -2
- package/dest/mem_pools/tx_pool/priority.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool/priority.js +4 -4
- 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 +3 -1
- 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 +3 -3
- package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.js +18 -9
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.d.ts +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.js +5 -2
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.d.ts +3 -3
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.js +12 -4
- package/dest/mem_pools/tx_pool_v2/eviction/index.d.ts +2 -2
- package/dest/mem_pools/tx_pool_v2/eviction/index.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/index.js +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/interfaces.d.ts +54 -5
- package/dest/mem_pools/tx_pool_v2/eviction/interfaces.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/interfaces.js +8 -0
- package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.js +7 -5
- package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.js +7 -5
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.d.ts +2 -2
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.js +14 -6
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.d.ts +4 -4
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.js +16 -4
- package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.d.ts +3 -3
- package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.js +3 -3
- package/dest/mem_pools/tx_pool_v2/index.d.ts +3 -2
- package/dest/mem_pools/tx_pool_v2/index.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/index.js +2 -1
- 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 +22 -8
- package/dest/mem_pools/tx_pool_v2/interfaces.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/interfaces.js +4 -1
- package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts +68 -11
- package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/tx_metadata.js +132 -17
- package/dest/mem_pools/tx_pool_v2/tx_pool_indices.d.ts +12 -3
- package/dest/mem_pools/tx_pool_v2/tx_pool_indices.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/tx_pool_indices.js +36 -14
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts +9 -4
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2.js +11 -6
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts +13 -5
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.js +336 -185
- package/dest/msg_validators/proposal_validator/block_proposal_validator.d.ts +6 -4
- package/dest/msg_validators/proposal_validator/block_proposal_validator.d.ts.map +1 -1
- package/dest/msg_validators/proposal_validator/block_proposal_validator.js +10 -2
- package/dest/msg_validators/proposal_validator/checkpoint_proposal_validator.d.ts +6 -4
- package/dest/msg_validators/proposal_validator/checkpoint_proposal_validator.d.ts.map +1 -1
- package/dest/msg_validators/proposal_validator/checkpoint_proposal_validator.js +16 -2
- package/dest/msg_validators/proposal_validator/proposal_validator.d.ts +13 -8
- package/dest/msg_validators/proposal_validator/proposal_validator.d.ts.map +1 -1
- package/dest/msg_validators/proposal_validator/proposal_validator.js +48 -36
- package/dest/msg_validators/tx_validator/aggregate_tx_validator.d.ts +4 -4
- package/dest/msg_validators/tx_validator/aggregate_tx_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/aggregate_tx_validator.js +3 -3
- package/dest/msg_validators/tx_validator/allowed_public_setup.d.ts +2 -1
- package/dest/msg_validators/tx_validator/allowed_public_setup.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/allowed_public_setup.js +24 -20
- package/dest/msg_validators/tx_validator/allowed_setup_helpers.d.ts +17 -0
- package/dest/msg_validators/tx_validator/allowed_setup_helpers.d.ts.map +1 -0
- package/dest/msg_validators/tx_validator/allowed_setup_helpers.js +24 -0
- 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/contract_instance_validator.d.ts +9 -0
- package/dest/msg_validators/tx_validator/contract_instance_validator.d.ts.map +1 -0
- package/dest/msg_validators/tx_validator/contract_instance_validator.js +48 -0
- 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/factory.d.ts +125 -6
- package/dest/msg_validators/tx_validator/factory.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/factory.js +233 -59
- package/dest/msg_validators/tx_validator/fee_payer_balance.d.ts +1 -1
- package/dest/msg_validators/tx_validator/fee_payer_balance.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/fee_payer_balance.js +6 -2
- package/dest/msg_validators/tx_validator/gas_validator.d.ts +67 -3
- package/dest/msg_validators/tx_validator/gas_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/gas_validator.js +104 -37
- package/dest/msg_validators/tx_validator/index.d.ts +3 -1
- package/dest/msg_validators/tx_validator/index.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/index.js +2 -0
- package/dest/msg_validators/tx_validator/nullifier_cache.d.ts +14 -0
- package/dest/msg_validators/tx_validator/nullifier_cache.d.ts.map +1 -0
- package/dest/msg_validators/tx_validator/nullifier_cache.js +24 -0
- package/dest/msg_validators/tx_validator/phases_validator.d.ts +2 -2
- package/dest/msg_validators/tx_validator/phases_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/phases_validator.js +44 -23
- 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 +9 -5
- package/dest/services/dummy_service.d.ts.map +1 -1
- package/dest/services/dummy_service.js +7 -4
- package/dest/services/encoding.d.ts +3 -3
- package/dest/services/encoding.d.ts.map +1 -1
- package/dest/services/encoding.js +11 -10
- package/dest/services/gossipsub/topic_score_params.d.ts +18 -6
- package/dest/services/gossipsub/topic_score_params.d.ts.map +1 -1
- package/dest/services/gossipsub/topic_score_params.js +32 -10
- package/dest/services/libp2p/libp2p_service.d.ts +25 -14
- package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
- package/dest/services/libp2p/libp2p_service.js +158 -123
- package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts +4 -3
- 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 +5 -9
- 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/batch-tx-requester/tx_validator.js +2 -2
- 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 +3 -3
- package/dest/services/reqresp/protocols/block_txs/block_txs_handler.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.d.ts +7 -1
- 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 +15 -0
- 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 +22 -3
- package/dest/services/service.d.ts.map +1 -1
- package/dest/services/tx_collection/config.d.ts +19 -1
- package/dest/services/tx_collection/config.d.ts.map +1 -1
- package/dest/services/tx_collection/config.js +46 -0
- package/dest/services/tx_collection/fast_tx_collection.d.ts +3 -1
- package/dest/services/tx_collection/fast_tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/fast_tx_collection.js +56 -36
- 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 +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 +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 +7 -6
- package/dest/services/tx_collection/proposal_tx_collector.d.ts.map +1 -1
- package/dest/services/tx_collection/proposal_tx_collector.js +5 -4
- 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 +4 -4
- package/dest/services/tx_provider.d.ts.map +1 -1
- package/dest/services/tx_provider.js +9 -8
- package/dest/test-helpers/make-test-p2p-clients.d.ts +7 -8
- package/dest/test-helpers/make-test-p2p-clients.d.ts.map +1 -1
- package/dest/test-helpers/make-test-p2p-clients.js +1 -2
- package/dest/test-helpers/mock-pubsub.d.ts +30 -4
- package/dest/test-helpers/mock-pubsub.d.ts.map +1 -1
- package/dest/test-helpers/mock-pubsub.js +105 -4
- package/dest/test-helpers/reqresp-nodes.d.ts +2 -3
- package/dest/test-helpers/reqresp-nodes.d.ts.map +1 -1
- package/dest/test-helpers/reqresp-nodes.js +2 -2
- package/dest/test-helpers/testbench-utils.d.ts +35 -24
- package/dest/test-helpers/testbench-utils.d.ts.map +1 -1
- package/dest/test-helpers/testbench-utils.js +95 -36
- 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 +16 -15
- package/dest/testbench/worker_client_manager.d.ts +3 -1
- package/dest/testbench/worker_client_manager.d.ts.map +1 -1
- package/dest/testbench/worker_client_manager.js +4 -1
- 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 +77 -23
- package/src/client/interface.ts +43 -33
- package/src/client/p2p_client.ts +165 -265
- package/src/client/test/tx_proposal_collector/proposal_tx_collector_worker.ts +19 -10
- package/src/config.ts +139 -33
- package/src/errors/tx-pool.error.ts +12 -0
- package/src/index.ts +1 -0
- package/src/mem_pools/attestation_pool/attestation_pool.ts +95 -44
- package/src/mem_pools/attestation_pool/attestation_pool_test_suite.ts +57 -53
- package/src/mem_pools/attestation_pool/index.ts +3 -3
- package/src/mem_pools/attestation_pool/mocks.ts +2 -1
- package/src/mem_pools/index.ts +3 -0
- package/src/mem_pools/interface.ts +2 -2
- 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/priority.ts +4 -4
- package/src/mem_pools/tx_pool/tx_pool_test_suite.ts +3 -1
- package/src/mem_pools/tx_pool_v2/README.md +85 -11
- package/src/mem_pools/tx_pool_v2/deleted_pool.ts +321 -0
- package/src/mem_pools/tx_pool_v2/eviction/eviction_manager.ts +21 -8
- package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.ts +5 -2
- package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.ts +18 -4
- package/src/mem_pools/tx_pool_v2/eviction/index.ts +4 -0
- package/src/mem_pools/tx_pool_v2/eviction/interfaces.ts +59 -4
- package/src/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.ts +5 -5
- package/src/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.ts +5 -5
- package/src/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.ts +14 -9
- package/src/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.ts +33 -6
- package/src/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.ts +4 -3
- package/src/mem_pools/tx_pool_v2/index.ts +2 -1
- package/src/mem_pools/tx_pool_v2/instrumentation.ts +69 -0
- package/src/mem_pools/tx_pool_v2/interfaces.ts +23 -8
- package/src/mem_pools/tx_pool_v2/tx_metadata.ts +189 -23
- package/src/mem_pools/tx_pool_v2/tx_pool_indices.ts +43 -16
- package/src/mem_pools/tx_pool_v2/tx_pool_v2.ts +18 -7
- package/src/mem_pools/tx_pool_v2/tx_pool_v2_impl.ts +379 -182
- package/src/msg_validators/proposal_validator/block_proposal_validator.ts +14 -4
- package/src/msg_validators/proposal_validator/checkpoint_proposal_validator.ts +20 -7
- package/src/msg_validators/proposal_validator/proposal_validator.ts +63 -40
- package/src/msg_validators/tx_validator/README.md +115 -0
- package/src/msg_validators/tx_validator/aggregate_tx_validator.ts +5 -5
- package/src/msg_validators/tx_validator/allowed_public_setup.ts +22 -27
- package/src/msg_validators/tx_validator/allowed_setup_helpers.ts +31 -0
- package/src/msg_validators/tx_validator/block_header_validator.ts +15 -3
- package/src/msg_validators/tx_validator/contract_instance_validator.ts +56 -0
- package/src/msg_validators/tx_validator/double_spend_validator.ts +11 -6
- package/src/msg_validators/tx_validator/factory.ts +373 -77
- package/src/msg_validators/tx_validator/fee_payer_balance.ts +6 -2
- package/src/msg_validators/tx_validator/gas_validator.ts +123 -27
- package/src/msg_validators/tx_validator/index.ts +2 -0
- package/src/msg_validators/tx_validator/nullifier_cache.ts +30 -0
- package/src/msg_validators/tx_validator/phases_validator.ts +51 -26
- package/src/msg_validators/tx_validator/timestamp_validator.ts +23 -18
- package/src/services/dummy_service.ts +12 -6
- package/src/services/encoding.ts +9 -9
- package/src/services/gossipsub/README.md +29 -14
- package/src/services/gossipsub/topic_score_params.ts +49 -13
- package/src/services/libp2p/libp2p_service.ts +170 -132
- package/src/services/reqresp/batch-tx-requester/batch_tx_requester.ts +6 -6
- 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/batch-tx-requester/tx_validator.ts +2 -2
- package/src/services/reqresp/interface.ts +26 -1
- package/src/services/reqresp/protocols/block_txs/block_txs_handler.ts +2 -2
- package/src/services/reqresp/protocols/block_txs/block_txs_reqresp.ts +17 -0
- package/src/services/reqresp/protocols/tx.ts +22 -0
- package/src/services/reqresp/reqresp.ts +13 -3
- package/src/services/service.ts +31 -2
- package/src/services/tx_collection/config.ts +68 -0
- package/src/services/tx_collection/fast_tx_collection.ts +65 -32
- 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 +1 -0
- 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 +8 -7
- 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 +10 -9
- package/src/test-helpers/make-test-p2p-clients.ts +3 -5
- package/src/test-helpers/mock-pubsub.ts +146 -9
- package/src/test-helpers/reqresp-nodes.ts +2 -5
- package/src/test-helpers/testbench-utils.ts +109 -40
- package/src/testbench/p2p_client_testbench_worker.ts +24 -20
- package/src/testbench/worker_client_manager.ts +11 -4
- package/src/util.ts +7 -1
- package/dest/msg_validators/proposal_validator/proposal_validator_test_suite.d.ts +0 -23
- package/dest/msg_validators/proposal_validator/proposal_validator_test_suite.d.ts.map +0 -1
- package/dest/msg_validators/proposal_validator/proposal_validator_test_suite.js +0 -212
- package/src/msg_validators/proposal_validator/proposal_validator_test_suite.ts +0 -230
|
@@ -6,7 +6,7 @@ import { type FileStore, createFileStore } from '@aztec/stdlib/file-store';
|
|
|
6
6
|
import type { Tx } from '@aztec/stdlib/tx';
|
|
7
7
|
import { type TelemetryClient, getTelemetryClient } from '@aztec/telemetry-client';
|
|
8
8
|
|
|
9
|
-
import type {
|
|
9
|
+
import type { TxPoolV2 } from '../../mem_pools/index.js';
|
|
10
10
|
import type { TxFileStoreConfig } from './config.js';
|
|
11
11
|
import { TxFileStoreInstrumentation } from './instrumentation.js';
|
|
12
12
|
|
|
@@ -18,7 +18,7 @@ export class TxFileStore {
|
|
|
18
18
|
private uploadQueue: Tx[] = [];
|
|
19
19
|
private activeUploads = 0;
|
|
20
20
|
private readonly queueProcessor: RunningPromise;
|
|
21
|
-
private readonly handleTxsAdded:
|
|
21
|
+
private readonly handleTxsAdded: (args: { txs: Tx[]; source?: string }) => void;
|
|
22
22
|
|
|
23
23
|
/** Recently uploaded tx hashes for deduplication. */
|
|
24
24
|
private recentUploads: Set<string> = new Set();
|
|
@@ -27,10 +27,11 @@ export class TxFileStore {
|
|
|
27
27
|
|
|
28
28
|
private constructor(
|
|
29
29
|
private readonly fileStore: FileStore,
|
|
30
|
-
private readonly txPool:
|
|
30
|
+
private readonly txPool: TxPoolV2,
|
|
31
31
|
private readonly config: TxFileStoreConfig,
|
|
32
32
|
private readonly instrumentation: TxFileStoreInstrumentation,
|
|
33
33
|
private readonly log: Logger,
|
|
34
|
+
private readonly basePath: string,
|
|
34
35
|
) {
|
|
35
36
|
this.handleTxsAdded = (args: { txs: Tx[]; source?: string }) => {
|
|
36
37
|
this.enqueueTxs(args.txs);
|
|
@@ -48,8 +49,9 @@ export class TxFileStore {
|
|
|
48
49
|
* @returns The file store instance, or undefined if not configured/enabled.
|
|
49
50
|
*/
|
|
50
51
|
static async create(
|
|
51
|
-
txPool:
|
|
52
|
+
txPool: TxPoolV2,
|
|
52
53
|
config: TxFileStoreConfig,
|
|
54
|
+
basePath: string,
|
|
53
55
|
log: Logger = createLogger('p2p:tx_file_store'),
|
|
54
56
|
telemetry: TelemetryClient = getTelemetryClient(),
|
|
55
57
|
fileStoreOverride?: FileStore,
|
|
@@ -71,8 +73,8 @@ export class TxFileStore {
|
|
|
71
73
|
}
|
|
72
74
|
|
|
73
75
|
const instrumentation = new TxFileStoreInstrumentation(telemetry, 'TxFileStore');
|
|
74
|
-
log.info('Created tx file store', { url: config.txFileStoreUrl });
|
|
75
|
-
return new TxFileStore(fileStore, txPool, config, instrumentation, log);
|
|
76
|
+
log.info('Created tx file store', { url: config.txFileStoreUrl, basePath });
|
|
77
|
+
return new TxFileStore(fileStore, txPool, config, instrumentation, log, basePath);
|
|
76
78
|
}
|
|
77
79
|
|
|
78
80
|
/** Starts listening to TxPool events and uploading txs. */
|
|
@@ -122,7 +124,7 @@ export class TxFileStore {
|
|
|
122
124
|
|
|
123
125
|
private async uploadTx(tx: Tx): Promise<void> {
|
|
124
126
|
const txHash = tx.getTxHash().toString();
|
|
125
|
-
const path =
|
|
127
|
+
const path = `${this.basePath}/txs/${txHash}.bin`;
|
|
126
128
|
const timer = new Timer();
|
|
127
129
|
|
|
128
130
|
if (this.recentUploads.has(txHash)) {
|
|
@@ -144,7 +146,7 @@ export class TxFileStore {
|
|
|
144
146
|
}
|
|
145
147
|
|
|
146
148
|
await retry(
|
|
147
|
-
() => this.fileStore.save(path, tx.toBuffer(), { compress:
|
|
149
|
+
() => this.fileStore.save(path, tx.toBuffer(), { compress: true }),
|
|
148
150
|
`Uploading tx ${txHash}`,
|
|
149
151
|
makeBackoff([0.1, 0.5, 2]),
|
|
150
152
|
this.log,
|
|
@@ -5,13 +5,13 @@ import { elapsed } from '@aztec/foundation/timer';
|
|
|
5
5
|
import type { L2Block, L2BlockInfo } from '@aztec/stdlib/block';
|
|
6
6
|
import type { ITxProvider } from '@aztec/stdlib/interfaces/server';
|
|
7
7
|
import type { BlockProposal } from '@aztec/stdlib/p2p';
|
|
8
|
-
import { Tx, TxHash } from '@aztec/stdlib/tx';
|
|
8
|
+
import { type BlockHeader, Tx, TxHash } from '@aztec/stdlib/tx';
|
|
9
9
|
import { type TelemetryClient, getTelemetryClient } from '@aztec/telemetry-client';
|
|
10
10
|
|
|
11
11
|
import type { PeerId } from '@libp2p/interface';
|
|
12
12
|
|
|
13
13
|
import type { P2PClient } from '../client/p2p_client.js';
|
|
14
|
-
import type {
|
|
14
|
+
import type { TxPoolV2 } from '../mem_pools/tx_pool_v2/interfaces.js';
|
|
15
15
|
import type { FastCollectionRequestInput, TxCollection } from './tx_collection/tx_collection.js';
|
|
16
16
|
import { TxProviderInstrumentation } from './tx_provider_instrumentation.js';
|
|
17
17
|
|
|
@@ -24,8 +24,8 @@ export class TxProvider implements ITxProvider {
|
|
|
24
24
|
|
|
25
25
|
constructor(
|
|
26
26
|
private txCollection: TxCollection,
|
|
27
|
-
private txPool:
|
|
28
|
-
private
|
|
27
|
+
private txPool: TxPoolV2,
|
|
28
|
+
private blockProposalTransactionValidator: Pick<P2PClient, 'validateTxsReceivedInBlockProposal'>,
|
|
29
29
|
private log: Logger = createLogger('p2p:tx-collector'),
|
|
30
30
|
client: TelemetryClient = getTelemetryClient(),
|
|
31
31
|
) {
|
|
@@ -144,6 +144,7 @@ export class TxProvider implements ITxProvider {
|
|
|
144
144
|
// Take txs from the proposal body if there are any
|
|
145
145
|
// Note that we still have to validate these txs, but we do it in parallel with tx collection
|
|
146
146
|
const proposal = request.type === 'proposal' ? request.blockProposal : undefined;
|
|
147
|
+
const proposalBlockHeader = proposal?.blockHeader;
|
|
147
148
|
const txsFromProposal = this.extractFromProposal(proposal, [...missingTxHashes]);
|
|
148
149
|
if (txsFromProposal.length > 0) {
|
|
149
150
|
this.instrumentation.incTxsFromProposals(txsFromProposal.length);
|
|
@@ -155,7 +156,7 @@ export class TxProvider implements ITxProvider {
|
|
|
155
156
|
}
|
|
156
157
|
|
|
157
158
|
if (missingTxHashes.size === 0) {
|
|
158
|
-
await this.processProposalTxs(txsFromProposal);
|
|
159
|
+
await this.processProposalTxs(txsFromProposal, proposalBlockHeader!);
|
|
159
160
|
this.instrumentation.incTxsFromP2P(0, txHashes.length);
|
|
160
161
|
return { txsFromMempool, txsFromProposal };
|
|
161
162
|
}
|
|
@@ -163,7 +164,7 @@ export class TxProvider implements ITxProvider {
|
|
|
163
164
|
// Start tx collection from the network if needed, while we validate the txs taken from the proposal in parallel
|
|
164
165
|
const [txsFromNetwork] = await Promise.all([
|
|
165
166
|
this.collectFromP2P(request, [...missingTxHashes], opts),
|
|
166
|
-
this.processProposalTxs(txsFromProposal),
|
|
167
|
+
this.processProposalTxs(txsFromProposal, proposalBlockHeader!),
|
|
167
168
|
] as const);
|
|
168
169
|
|
|
169
170
|
if (txsFromNetwork.length > 0) {
|
|
@@ -222,11 +223,11 @@ export class TxProvider implements ITxProvider {
|
|
|
222
223
|
return compactArray(proposal.txs ?? []).filter(tx => missingTxHashes.includes(tx.getTxHash().toString()));
|
|
223
224
|
}
|
|
224
225
|
|
|
225
|
-
private async processProposalTxs(txs: Tx[]): Promise<void> {
|
|
226
|
+
private async processProposalTxs(txs: Tx[], blockHeader: BlockHeader): Promise<void> {
|
|
226
227
|
if (txs.length === 0) {
|
|
227
228
|
return;
|
|
228
229
|
}
|
|
229
|
-
await this.
|
|
230
|
-
await this.txPool.
|
|
230
|
+
await this.blockProposalTransactionValidator.validateTxsReceivedInBlockProposal(txs);
|
|
231
|
+
await this.txPool.addProtectedTxs(txs, blockHeader);
|
|
231
232
|
}
|
|
232
233
|
}
|
|
@@ -7,13 +7,12 @@ import { sleep } from '@aztec/foundation/sleep';
|
|
|
7
7
|
import type { DataStoreConfig } from '@aztec/kv-store/config';
|
|
8
8
|
import { openTmpStore } from '@aztec/kv-store/lmdb-v2';
|
|
9
9
|
import type { WorldStateSynchronizer } from '@aztec/stdlib/interfaces/server';
|
|
10
|
-
import { P2PClientType } from '@aztec/stdlib/p2p';
|
|
11
10
|
|
|
12
11
|
import { createP2PClient } from '../client/index.js';
|
|
13
12
|
import type { P2PClient } from '../client/p2p_client.js';
|
|
14
13
|
import type { P2PConfig } from '../config.js';
|
|
15
14
|
import type { AttestationPool } from '../mem_pools/attestation_pool/attestation_pool.js';
|
|
16
|
-
import type {
|
|
15
|
+
import type { TxPoolV2 } from '../mem_pools/tx_pool_v2/interfaces.js';
|
|
17
16
|
import { generatePeerIdPrivateKeys } from '../test-helpers/generate-peer-id-private-keys.js';
|
|
18
17
|
import { getPorts } from './get-ports.js';
|
|
19
18
|
import { makeEnrs } from './make-enrs.js';
|
|
@@ -22,7 +21,7 @@ import { AlwaysFalseCircuitVerifier, AlwaysTrueCircuitVerifier } from './reqresp
|
|
|
22
21
|
|
|
23
22
|
export interface MakeTestP2PClientOptions {
|
|
24
23
|
mockAttestationPool: AttestationPool;
|
|
25
|
-
mockTxPool:
|
|
24
|
+
mockTxPool: TxPoolV2;
|
|
26
25
|
mockEpochCache: EpochCache;
|
|
27
26
|
mockWorldState: WorldStateSynchronizer;
|
|
28
27
|
alwaysTrueVerifier?: boolean;
|
|
@@ -98,7 +97,6 @@ export async function makeTestP2PClient(
|
|
|
98
97
|
const kvStore = await openTmpStore('test');
|
|
99
98
|
|
|
100
99
|
const client = await createP2PClient(
|
|
101
|
-
P2PClientType.Full,
|
|
102
100
|
config,
|
|
103
101
|
l2BlockSource,
|
|
104
102
|
proofVerifier,
|
|
@@ -108,7 +106,7 @@ export async function makeTestP2PClient(
|
|
|
108
106
|
undefined,
|
|
109
107
|
undefined,
|
|
110
108
|
{
|
|
111
|
-
txPool: mockTxPool as unknown as
|
|
109
|
+
txPool: mockTxPool as unknown as TxPoolV2,
|
|
112
110
|
attestationPool: mockAttestationPool as unknown as AttestationPool,
|
|
113
111
|
store: kvStore,
|
|
114
112
|
logger,
|
|
@@ -4,7 +4,6 @@ import type { AztecAsyncKVStore } from '@aztec/kv-store';
|
|
|
4
4
|
import type { L2BlockSource } from '@aztec/stdlib/block';
|
|
5
5
|
import type { ContractDataSource } from '@aztec/stdlib/contract';
|
|
6
6
|
import type { ClientProtocolCircuitVerifier, WorldStateSynchronizer } from '@aztec/stdlib/interfaces/server';
|
|
7
|
-
import { P2PClientType } from '@aztec/stdlib/p2p';
|
|
8
7
|
import type { TelemetryClient } from '@aztec/telemetry-client';
|
|
9
8
|
|
|
10
9
|
import type { GossipsubEvents, GossipsubMessage } from '@chainsafe/libp2p-gossipsub';
|
|
@@ -19,8 +18,20 @@ import {
|
|
|
19
18
|
|
|
20
19
|
import type { P2PConfig } from '../config.js';
|
|
21
20
|
import type { MemPools } from '../mem_pools/interface.js';
|
|
22
|
-
import { DummyPeerDiscoveryService, DummyPeerManager,
|
|
23
|
-
import type {
|
|
21
|
+
import { DummyPeerDiscoveryService, DummyPeerManager, LibP2PService } from '../services/index.js';
|
|
22
|
+
import type { P2PReqRespConfig } from '../services/reqresp/config.js';
|
|
23
|
+
import type { ConnectionSampler } from '../services/reqresp/connection-sampler/connection_sampler.js';
|
|
24
|
+
import {
|
|
25
|
+
type ReqRespInterface,
|
|
26
|
+
type ReqRespResponse,
|
|
27
|
+
type ReqRespSubProtocol,
|
|
28
|
+
type ReqRespSubProtocolHandler,
|
|
29
|
+
type ReqRespSubProtocolHandlers,
|
|
30
|
+
type ReqRespSubProtocolValidators,
|
|
31
|
+
type SubProtocolMap,
|
|
32
|
+
responseFromBuffer,
|
|
33
|
+
} from '../services/reqresp/interface.js';
|
|
34
|
+
import { ReqRespStatus } from '../services/reqresp/status.js';
|
|
24
35
|
import { GossipSubEvent } from '../types/index.js';
|
|
25
36
|
import type { PubSubLibp2p } from '../util.js';
|
|
26
37
|
|
|
@@ -30,11 +41,10 @@ type GossipSubService = PubSubLibp2p['services']['pubsub'];
|
|
|
30
41
|
* Given a mock gossip sub network, returns a factory function that creates an instance LibP2PService connected to it.
|
|
31
42
|
* Designed to be used in tests in P2PClientDeps.p2pServiceFactory.
|
|
32
43
|
*/
|
|
33
|
-
export function getMockPubSubP2PServiceFactory
|
|
44
|
+
export function getMockPubSubP2PServiceFactory(
|
|
34
45
|
network: MockGossipSubNetwork,
|
|
35
|
-
): (...args: Parameters<(typeof LibP2PService
|
|
46
|
+
): (...args: Parameters<(typeof LibP2PService)['new']>) => Promise<LibP2PService> {
|
|
36
47
|
return (
|
|
37
|
-
clientType: P2PClientType,
|
|
38
48
|
config: P2PConfig,
|
|
39
49
|
peerId: PeerId,
|
|
40
50
|
deps: {
|
|
@@ -52,10 +62,9 @@ export function getMockPubSubP2PServiceFactory<T extends P2PClientType>(
|
|
|
52
62
|
deps.logger.verbose('Creating mock PubSub service');
|
|
53
63
|
const libp2p = new MockPubSub(peerId, network);
|
|
54
64
|
const peerManager = new DummyPeerManager(peerId, network);
|
|
55
|
-
const reqresp: ReqRespInterface = new
|
|
65
|
+
const reqresp: ReqRespInterface = new MockReqResp(peerId, network);
|
|
56
66
|
const peerDiscoveryService = new DummyPeerDiscoveryService();
|
|
57
|
-
const service = new LibP2PService
|
|
58
|
-
clientType as T,
|
|
67
|
+
const service = new LibP2PService(
|
|
59
68
|
config,
|
|
60
69
|
libp2p,
|
|
61
70
|
peerDiscoveryService,
|
|
@@ -74,6 +83,115 @@ export function getMockPubSubP2PServiceFactory<T extends P2PClientType>(
|
|
|
74
83
|
};
|
|
75
84
|
}
|
|
76
85
|
|
|
86
|
+
/**
|
|
87
|
+
* Mock implementation of ReqRespInterface that routes requests to other peers' handlers through the mock network.
|
|
88
|
+
* When a peer calls sendBatchRequest, the mock iterates over network peers and invokes their registered handler
|
|
89
|
+
* for the sub-protocol, simulating the request-response protocol without actual libp2p streams.
|
|
90
|
+
*/
|
|
91
|
+
class MockReqResp implements ReqRespInterface {
|
|
92
|
+
private handlers: Partial<ReqRespSubProtocolHandlers> = {};
|
|
93
|
+
private logger = createLogger('p2p:test:mock-reqresp');
|
|
94
|
+
|
|
95
|
+
constructor(
|
|
96
|
+
private peerId: PeerId,
|
|
97
|
+
private network: MockGossipSubNetwork,
|
|
98
|
+
) {
|
|
99
|
+
network.registerReqRespPeer(this);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
updateConfig(_config: Partial<P2PReqRespConfig>): void {}
|
|
103
|
+
|
|
104
|
+
start(
|
|
105
|
+
subProtocolHandlers: Partial<ReqRespSubProtocolHandlers>,
|
|
106
|
+
_subProtocolValidators: ReqRespSubProtocolValidators,
|
|
107
|
+
): Promise<void> {
|
|
108
|
+
Object.assign(this.handlers, subProtocolHandlers);
|
|
109
|
+
return Promise.resolve();
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
addSubProtocol(
|
|
113
|
+
subProtocol: ReqRespSubProtocol,
|
|
114
|
+
handler: ReqRespSubProtocolHandler,
|
|
115
|
+
_validator?: ReqRespSubProtocolValidators[ReqRespSubProtocol],
|
|
116
|
+
): Promise<void> {
|
|
117
|
+
this.handlers[subProtocol] = handler;
|
|
118
|
+
return Promise.resolve();
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
stop(): Promise<void> {
|
|
122
|
+
this.handlers = {};
|
|
123
|
+
return Promise.resolve();
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
getHandler(subProtocol: ReqRespSubProtocol): ReqRespSubProtocolHandler | undefined {
|
|
127
|
+
return this.handlers[subProtocol];
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
async sendBatchRequest<SubProtocol extends ReqRespSubProtocol>(
|
|
131
|
+
subProtocol: SubProtocol,
|
|
132
|
+
requests: InstanceType<SubProtocolMap[SubProtocol]['request']>[],
|
|
133
|
+
pinnedPeer: PeerId | undefined,
|
|
134
|
+
_timeoutMs?: number,
|
|
135
|
+
_maxPeers?: number,
|
|
136
|
+
_maxRetryAttempts?: number,
|
|
137
|
+
): Promise<InstanceType<SubProtocolMap[SubProtocol]['response']>[]> {
|
|
138
|
+
const responses: InstanceType<SubProtocolMap[SubProtocol]['response']>[] = [];
|
|
139
|
+
const peers = this.network.getReqRespPeers().filter(p => !p.peerId.equals(this.peerId));
|
|
140
|
+
const targetPeers = pinnedPeer ? peers.filter(p => p.peerId.equals(pinnedPeer)) : peers;
|
|
141
|
+
|
|
142
|
+
for (const request of requests) {
|
|
143
|
+
const requestBuffer = request.toBuffer();
|
|
144
|
+
for (const peer of targetPeers) {
|
|
145
|
+
const handler = peer.getHandler(subProtocol);
|
|
146
|
+
if (!handler) {
|
|
147
|
+
continue;
|
|
148
|
+
}
|
|
149
|
+
try {
|
|
150
|
+
const responseBuffer = await handler(this.peerId, requestBuffer);
|
|
151
|
+
if (responseBuffer.length > 0) {
|
|
152
|
+
const response = responseFromBuffer(subProtocol, responseBuffer);
|
|
153
|
+
responses.push(response as InstanceType<SubProtocolMap[SubProtocol]['response']>);
|
|
154
|
+
break;
|
|
155
|
+
}
|
|
156
|
+
} catch (err) {
|
|
157
|
+
this.logger.debug(`Mock reqresp handler error from peer ${peer.peerId}`, { err });
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
return responses;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
async sendRequestToPeer(
|
|
166
|
+
peerId: PeerId,
|
|
167
|
+
subProtocol: ReqRespSubProtocol,
|
|
168
|
+
payload: Buffer,
|
|
169
|
+
_dialTimeout?: number,
|
|
170
|
+
): Promise<ReqRespResponse> {
|
|
171
|
+
const peer = this.network.getReqRespPeers().find(p => p.peerId.equals(peerId));
|
|
172
|
+
const handler = peer?.getHandler(subProtocol);
|
|
173
|
+
if (!handler) {
|
|
174
|
+
return { status: ReqRespStatus.SUCCESS, data: Buffer.from([]) };
|
|
175
|
+
}
|
|
176
|
+
try {
|
|
177
|
+
const data = await handler(this.peerId, payload);
|
|
178
|
+
return { status: ReqRespStatus.SUCCESS, data };
|
|
179
|
+
} catch {
|
|
180
|
+
return { status: ReqRespStatus.FAILURE };
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
getConnectionSampler(): Pick<ConnectionSampler, 'getPeerListSortedByConnectionCountAsc'> {
|
|
185
|
+
return {
|
|
186
|
+
getPeerListSortedByConnectionCountAsc: () =>
|
|
187
|
+
this.network
|
|
188
|
+
.getReqRespPeers()
|
|
189
|
+
.filter(p => !p.peerId.equals(this.peerId))
|
|
190
|
+
.map(p => p.peerId),
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
77
195
|
/**
|
|
78
196
|
* Implementation of PubSub services that relies on a mock gossip sub network.
|
|
79
197
|
* This is used in tests to simulate a gossip sub network without needing a real P2P network.
|
|
@@ -149,6 +267,16 @@ class MockGossipSubService extends TypedEventEmitter<GossipsubEvents> implements
|
|
|
149
267
|
{ msgId, propagationSource, acceptance },
|
|
150
268
|
);
|
|
151
269
|
}
|
|
270
|
+
|
|
271
|
+
getMeshPeers(topic?: TopicStr): PeerIdStr[] {
|
|
272
|
+
if (topic && !this.subscribedTopics.has(topic)) {
|
|
273
|
+
return [];
|
|
274
|
+
}
|
|
275
|
+
return this.network
|
|
276
|
+
.getPeers()
|
|
277
|
+
.filter(peer => !this.peerId.equals(peer))
|
|
278
|
+
.map(peer => peer.toString());
|
|
279
|
+
}
|
|
152
280
|
}
|
|
153
281
|
|
|
154
282
|
/**
|
|
@@ -157,6 +285,7 @@ class MockGossipSubService extends TypedEventEmitter<GossipsubEvents> implements
|
|
|
157
285
|
*/
|
|
158
286
|
export class MockGossipSubNetwork {
|
|
159
287
|
private peers: MockGossipSubService[] = [];
|
|
288
|
+
private reqRespPeers: MockReqResp[] = [];
|
|
160
289
|
private nextMsgId = 0;
|
|
161
290
|
|
|
162
291
|
private logger = createLogger('p2p:test:mock-gossipsub-network');
|
|
@@ -169,6 +298,14 @@ export class MockGossipSubNetwork {
|
|
|
169
298
|
this.peers.push(peer);
|
|
170
299
|
}
|
|
171
300
|
|
|
301
|
+
public registerReqRespPeer(peer: MockReqResp): void {
|
|
302
|
+
this.reqRespPeers.push(peer);
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
public getReqRespPeers(): MockReqResp[] {
|
|
306
|
+
return this.reqRespPeers;
|
|
307
|
+
}
|
|
308
|
+
|
|
172
309
|
public publishToPeers(topic: TopicStr, data: Uint8Array, sender: PeerId): void {
|
|
173
310
|
const msgId = (this.nextMsgId++).toString();
|
|
174
311
|
this.logger.debug(`Network is distributing message on topic ${topic}`, {
|
|
@@ -12,7 +12,6 @@ import type {
|
|
|
12
12
|
IVCProofVerificationResult,
|
|
13
13
|
WorldStateSynchronizer,
|
|
14
14
|
} from '@aztec/stdlib/interfaces/server';
|
|
15
|
-
import type { P2PClientType } from '@aztec/stdlib/p2p';
|
|
16
15
|
import type { Tx } from '@aztec/stdlib/tx';
|
|
17
16
|
import { compressComponentVersions } from '@aztec/stdlib/versioning';
|
|
18
17
|
import { type TelemetryClient, getTelemetryClient } from '@aztec/telemetry-client';
|
|
@@ -107,8 +106,7 @@ export async function createLibp2pNode(
|
|
|
107
106
|
*
|
|
108
107
|
*
|
|
109
108
|
*/
|
|
110
|
-
export async function createTestLibP2PService
|
|
111
|
-
clientType: T,
|
|
109
|
+
export async function createTestLibP2PService(
|
|
112
110
|
boostrapAddrs: string[] = [],
|
|
113
111
|
archiver: L2BlockSource & ContractDataSource,
|
|
114
112
|
worldStateSynchronizer: WorldStateSynchronizer,
|
|
@@ -159,8 +157,7 @@ export async function createTestLibP2PService<T extends P2PClientType>(
|
|
|
159
157
|
p2pNode.services.pubsub.score.params.appSpecificScore = (peerId: string) =>
|
|
160
158
|
peerManager.shouldDisableP2PGossip(peerId) ? -Infinity : peerManager.getPeerScore(peerId);
|
|
161
159
|
|
|
162
|
-
return new LibP2PService
|
|
163
|
-
clientType,
|
|
160
|
+
return new LibP2PService(
|
|
164
161
|
config,
|
|
165
162
|
p2pNode as PubSubLibp2p,
|
|
166
163
|
discoveryService,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { EpochCacheInterface } from '@aztec/epoch-cache';
|
|
2
|
-
import {
|
|
2
|
+
import { EpochNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
3
3
|
import type { Logger } from '@aztec/foundation/log';
|
|
4
|
+
import type { L2Block, L2BlockId } from '@aztec/stdlib/block';
|
|
4
5
|
import type { WorldStateSynchronizer } from '@aztec/stdlib/interfaces/server';
|
|
5
6
|
import type {
|
|
6
7
|
BlockProposal,
|
|
@@ -13,14 +14,16 @@ import { type BlockHeader, Tx, TxHash } from '@aztec/stdlib/tx';
|
|
|
13
14
|
import EventEmitter from 'events';
|
|
14
15
|
|
|
15
16
|
import type { TryAddResult } from '../mem_pools/attestation_pool/attestation_pool.js';
|
|
16
|
-
import type {
|
|
17
|
+
import type { AddTxsResult, TxPoolV2, TxPoolV2Config } from '../mem_pools/tx_pool_v2/interfaces.js';
|
|
18
|
+
import type { TxState } from '../mem_pools/tx_pool_v2/tx_metadata.js';
|
|
17
19
|
import { RateLimitStatus } from '../services/reqresp/rate-limiter/rate_limiter.js';
|
|
18
20
|
|
|
19
21
|
/**
|
|
20
22
|
* In-memory TxPool implementation for testing.
|
|
21
23
|
* Provides basic tx storage without persistence.
|
|
24
|
+
* Implements TxPoolV2 interface with stub implementations for testing.
|
|
22
25
|
*/
|
|
23
|
-
export class InMemoryTxPool extends EventEmitter implements
|
|
26
|
+
export class InMemoryTxPool extends EventEmitter implements TxPoolV2 {
|
|
24
27
|
private txsByHash = new Map<string, Tx>();
|
|
25
28
|
private logger: Logger | null = null;
|
|
26
29
|
|
|
@@ -54,93 +57,154 @@ export class InMemoryTxPool extends EventEmitter implements TxPool {
|
|
|
54
57
|
this.removeAllListeners();
|
|
55
58
|
}
|
|
56
59
|
|
|
57
|
-
|
|
60
|
+
// === Core Operations (TxPoolV2) ===
|
|
61
|
+
|
|
62
|
+
addPendingTxs(txs: Tx[], opts?: { source?: string; feeComparisonOnly?: boolean }): Promise<AddTxsResult> {
|
|
63
|
+
const accepted: TxHash[] = [];
|
|
58
64
|
const newTxs: Tx[] = [];
|
|
59
|
-
let added = 0;
|
|
60
65
|
for (const tx of txs) {
|
|
61
66
|
const key = tx.getTxHash().toString();
|
|
62
67
|
if (!this.txsByHash.has(key)) {
|
|
63
68
|
newTxs.push(tx);
|
|
64
|
-
|
|
69
|
+
accepted.push(tx.getTxHash());
|
|
65
70
|
}
|
|
66
71
|
this.txsByHash.set(key, tx);
|
|
67
72
|
}
|
|
68
73
|
if (newTxs.length > 0) {
|
|
69
74
|
this.emit('txs-added', { txs: newTxs, source: opts?.source });
|
|
70
75
|
}
|
|
71
|
-
return Promise.resolve(
|
|
76
|
+
return Promise.resolve({ accepted, ignored: [], rejected: [] });
|
|
72
77
|
}
|
|
73
78
|
|
|
74
|
-
|
|
75
|
-
|
|
79
|
+
canAddPendingTx(tx: Tx): Promise<'accepted' | 'ignored'> {
|
|
80
|
+
const key = tx.getTxHash().toString();
|
|
81
|
+
if (this.txsByHash.has(key)) {
|
|
82
|
+
return Promise.resolve('ignored');
|
|
83
|
+
}
|
|
84
|
+
return Promise.resolve('accepted');
|
|
76
85
|
}
|
|
77
86
|
|
|
78
|
-
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
87
|
+
addProtectedTxs(txs: Tx[], _block: BlockHeader, opts?: { source?: string }): Promise<void> {
|
|
88
|
+
for (const tx of txs) {
|
|
89
|
+
const key = tx.getTxHash().toString();
|
|
90
|
+
this.txsByHash.set(key, tx);
|
|
91
|
+
}
|
|
92
|
+
if (txs.length > 0) {
|
|
93
|
+
this.emit('txs-added', { txs, source: opts?.source });
|
|
94
|
+
}
|
|
95
|
+
return Promise.resolve();
|
|
83
96
|
}
|
|
84
97
|
|
|
85
|
-
|
|
86
|
-
|
|
98
|
+
protectTxs(txHashes: TxHash[], _block: BlockHeader): Promise<TxHash[]> {
|
|
99
|
+
const notFound: TxHash[] = [];
|
|
100
|
+
for (const txHash of txHashes) {
|
|
101
|
+
if (!this.txsByHash.has(txHash.toString())) {
|
|
102
|
+
notFound.push(txHash);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return Promise.resolve(notFound);
|
|
87
106
|
}
|
|
88
107
|
|
|
89
|
-
|
|
90
|
-
|
|
108
|
+
addMinedTxs(txs: Tx[], _block: BlockHeader, _opts?: { source?: string }): Promise<void> {
|
|
109
|
+
for (const tx of txs) {
|
|
110
|
+
const key = tx.getTxHash().toString();
|
|
111
|
+
this.txsByHash.set(key, tx);
|
|
112
|
+
}
|
|
113
|
+
return Promise.resolve();
|
|
91
114
|
}
|
|
92
115
|
|
|
93
|
-
|
|
94
|
-
|
|
116
|
+
// === State Transition Handlers (TxPoolV2) ===
|
|
117
|
+
|
|
118
|
+
handleMinedBlock(_block: L2Block): Promise<void> {
|
|
119
|
+
return Promise.resolve();
|
|
95
120
|
}
|
|
96
121
|
|
|
97
|
-
|
|
122
|
+
prepareForSlot(_slotNumber: SlotNumber): Promise<void> {
|
|
123
|
+
return Promise.resolve();
|
|
124
|
+
}
|
|
98
125
|
|
|
99
|
-
|
|
126
|
+
handlePrunedBlocks(_latestBlock: L2BlockId, _options?: { deleteAllTxs?: boolean }): Promise<void> {
|
|
127
|
+
return Promise.resolve();
|
|
128
|
+
}
|
|
100
129
|
|
|
101
|
-
|
|
130
|
+
handleFailedExecution(txHashes: TxHash[]): Promise<void> {
|
|
102
131
|
for (const txHash of txHashes) {
|
|
103
132
|
this.txsByHash.delete(txHash.toString());
|
|
104
133
|
}
|
|
105
134
|
return Promise.resolve();
|
|
106
135
|
}
|
|
107
136
|
|
|
108
|
-
|
|
109
|
-
return Promise.resolve(
|
|
137
|
+
handleFinalizedBlock(_block: BlockHeader): Promise<void> {
|
|
138
|
+
return Promise.resolve();
|
|
110
139
|
}
|
|
111
140
|
|
|
112
|
-
|
|
113
|
-
|
|
141
|
+
// === Query Operations (TxPoolV2) ===
|
|
142
|
+
|
|
143
|
+
getTxByHash(hash: TxHash): Promise<Tx | undefined> {
|
|
144
|
+
return Promise.resolve(this.txsByHash.get(hash.toString()));
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
getTxsByHash(hashes: TxHash[]): Promise<(Tx | undefined)[]> {
|
|
148
|
+
const result = hashes.map(h => this.txsByHash.get(h.toString()));
|
|
149
|
+
const found = result.filter(tx => tx !== undefined).length;
|
|
150
|
+
this.logger?.debug(`[TxPool] getTxsByHash: requested ${hashes.length}, found ${found}`);
|
|
151
|
+
return Promise.resolve(result);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
hasTxs(hashes: TxHash[]): Promise<boolean[]> {
|
|
155
|
+
return Promise.resolve(hashes.map(h => this.txsByHash.has(h.toString())));
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
getArchivedTxByHash(_hash: TxHash): Promise<Tx | undefined> {
|
|
159
|
+
return Promise.resolve(undefined);
|
|
114
160
|
}
|
|
115
161
|
|
|
116
162
|
getPendingTxHashes(): Promise<TxHash[]> {
|
|
117
163
|
return Promise.resolve([...this.txsByHash.keys()].map(key => TxHash.fromString(key)));
|
|
118
164
|
}
|
|
119
165
|
|
|
166
|
+
getEligiblePendingTxHashes(): Promise<TxHash[]> {
|
|
167
|
+
return this.getPendingTxHashes();
|
|
168
|
+
}
|
|
169
|
+
|
|
120
170
|
getPendingTxCount(): Promise<number> {
|
|
121
171
|
return Promise.resolve(this.txsByHash.size);
|
|
122
172
|
}
|
|
123
173
|
|
|
124
|
-
getMinedTxHashes(): Promise<[
|
|
174
|
+
getMinedTxHashes(): Promise<[TxHash, L2BlockId][]> {
|
|
125
175
|
return Promise.resolve([]);
|
|
126
176
|
}
|
|
127
177
|
|
|
128
|
-
|
|
129
|
-
return Promise.resolve(
|
|
178
|
+
getMinedTxCount(): Promise<number> {
|
|
179
|
+
return Promise.resolve(0);
|
|
130
180
|
}
|
|
131
181
|
|
|
132
|
-
|
|
182
|
+
getTxStatus(hash: TxHash): Promise<TxState | 'deleted' | undefined> {
|
|
183
|
+
return Promise.resolve(this.txsByHash.has(hash.toString()) ? 'pending' : undefined);
|
|
184
|
+
}
|
|
133
185
|
|
|
134
186
|
isEmpty(): Promise<boolean> {
|
|
135
187
|
return Promise.resolve(this.txsByHash.size === 0);
|
|
136
188
|
}
|
|
137
189
|
|
|
138
|
-
|
|
190
|
+
getLowestPriorityPending(_limit: number): Promise<TxHash[]> {
|
|
191
|
+
return Promise.resolve([]);
|
|
192
|
+
}
|
|
139
193
|
|
|
140
|
-
|
|
194
|
+
// === Configuration (TxPoolV2) ===
|
|
141
195
|
|
|
142
|
-
|
|
143
|
-
return Promise.resolve(
|
|
196
|
+
updateConfig(_config: Partial<TxPoolV2Config>): Promise<void> {
|
|
197
|
+
return Promise.resolve();
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
// === Lifecycle (TxPoolV2) ===
|
|
201
|
+
|
|
202
|
+
start(): Promise<void> {
|
|
203
|
+
return Promise.resolve();
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
stop(): Promise<void> {
|
|
207
|
+
return Promise.resolve();
|
|
144
208
|
}
|
|
145
209
|
}
|
|
146
210
|
|
|
@@ -155,10 +219,10 @@ export class InMemoryAttestationPool {
|
|
|
155
219
|
const id = blockProposal.archive.toString();
|
|
156
220
|
const alreadyExists = this.proposals.has(id);
|
|
157
221
|
if (alreadyExists) {
|
|
158
|
-
return Promise.resolve({ added: false, alreadyExists: true,
|
|
222
|
+
return Promise.resolve({ added: false, alreadyExists: true, count: 1 });
|
|
159
223
|
}
|
|
160
224
|
this.proposals.set(id, blockProposal);
|
|
161
|
-
return Promise.resolve({ added: true, alreadyExists: false,
|
|
225
|
+
return Promise.resolve({ added: true, alreadyExists: false, count: 1 });
|
|
162
226
|
}
|
|
163
227
|
|
|
164
228
|
getBlockProposal(id: string): Promise<BlockProposal | undefined> {
|
|
@@ -166,7 +230,7 @@ export class InMemoryAttestationPool {
|
|
|
166
230
|
}
|
|
167
231
|
|
|
168
232
|
tryAddCheckpointProposal(_proposal: CheckpointProposal): Promise<TryAddResult> {
|
|
169
|
-
return Promise.resolve({ added: true, alreadyExists: false,
|
|
233
|
+
return Promise.resolve({ added: true, alreadyExists: false, count: 1 });
|
|
170
234
|
}
|
|
171
235
|
|
|
172
236
|
getCheckpointProposal(_id: string): Promise<CheckpointProposalCore | undefined> {
|
|
@@ -188,8 +252,12 @@ export class InMemoryAttestationPool {
|
|
|
188
252
|
return Promise.resolve([]);
|
|
189
253
|
}
|
|
190
254
|
|
|
191
|
-
tryAddCheckpointAttestation(_attestation: CheckpointAttestation
|
|
192
|
-
return Promise.resolve({ added: true, alreadyExists: false,
|
|
255
|
+
tryAddCheckpointAttestation(_attestation: CheckpointAttestation): Promise<TryAddResult> {
|
|
256
|
+
return Promise.resolve({ added: true, alreadyExists: false, count: 1 });
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
hasBlockProposalsForSlot(_slot: SlotNumber): Promise<boolean> {
|
|
260
|
+
return Promise.resolve(false);
|
|
193
261
|
}
|
|
194
262
|
|
|
195
263
|
isEmpty(): Promise<boolean> {
|
|
@@ -224,6 +292,7 @@ export function createMockEpochCache(): EpochCacheInterface {
|
|
|
224
292
|
ethereumSlotDuration: 1,
|
|
225
293
|
proofSubmissionEpochs: 1,
|
|
226
294
|
targetCommitteeSize: 48,
|
|
295
|
+
rollupManaLimit: Number.MAX_SAFE_INTEGER,
|
|
227
296
|
}),
|
|
228
297
|
};
|
|
229
298
|
}
|