@aztec/p2p 0.0.1-commit.4ad48494d → 0.0.1-commit.4d3c002
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +129 -3
- package/dest/client/factory.d.ts +7 -7
- package/dest/client/factory.d.ts.map +1 -1
- package/dest/client/factory.js +33 -29
- package/dest/client/interface.d.ts +18 -20
- package/dest/client/interface.d.ts.map +1 -1
- package/dest/client/p2p_client.d.ts +9 -19
- package/dest/client/p2p_client.d.ts.map +1 -1
- package/dest/client/p2p_client.js +72 -102
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.js +20 -10
- package/dest/config.d.ts +34 -15
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +86 -37
- package/dest/errors/p2p-service.error.d.ts +9 -0
- package/dest/errors/p2p-service.error.d.ts.map +1 -0
- package/dest/errors/p2p-service.error.js +10 -0
- 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 +1 -2
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +0 -1
- package/dest/mem_pools/attestation_pool/attestation_pool.d.ts +4 -4
- package/dest/mem_pools/attestation_pool/attestation_pool.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/attestation_pool.js +11 -6
- package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.js +6 -6
- 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 +1 -2
- package/dest/mem_pools/index.d.ts.map +1 -1
- package/dest/mem_pools/instrumentation.d.ts +4 -2
- package/dest/mem_pools/instrumentation.d.ts.map +1 -1
- package/dest/mem_pools/instrumentation.js +16 -14
- package/dest/mem_pools/tx_pool_v2/deleted_pool.d.ts +3 -1
- package/dest/mem_pools/tx_pool_v2/deleted_pool.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/deleted_pool.js +9 -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 -4
- 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 +4 -4
- package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.js +5 -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 +12 -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 +2 -2
- package/dest/mem_pools/tx_pool_v2/index.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/index.js +1 -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 +24 -10
- 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 +54 -15
- package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/tx_metadata.js +111 -19
- package/dest/mem_pools/tx_pool_v2/tx_pool_indices.d.ts +5 -2
- 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 +38 -46
- 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 +12 -5
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts +12 -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 +296 -153
- package/dest/msg_validators/attestation_validator/attestation_validator.d.ts +1 -1
- package/dest/msg_validators/attestation_validator/attestation_validator.d.ts.map +1 -1
- package/dest/msg_validators/attestation_validator/attestation_validator.js +5 -4
- package/dest/msg_validators/clock_tolerance.d.ts +1 -1
- package/dest/msg_validators/clock_tolerance.d.ts.map +1 -1
- package/dest/msg_validators/clock_tolerance.js +4 -3
- 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 +53 -41
- package/dest/msg_validators/tx_validator/aggregate_tx_validator.d.ts +2 -2
- 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/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/data_validator.d.ts +1 -1
- package/dest/msg_validators/tx_validator/data_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/data_validator.js +35 -2
- package/dest/msg_validators/tx_validator/factory.d.ts +133 -6
- package/dest/msg_validators/tx_validator/factory.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/factory.js +247 -60
- 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/metadata_validator.d.ts +1 -1
- package/dest/msg_validators/tx_validator/metadata_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/metadata_validator.js +4 -4
- 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 +22 -2
- package/dest/msg_validators/tx_validator/phases_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/phases_validator.js +72 -24
- package/dest/msg_validators/tx_validator/timestamp_validator.d.ts +2 -2
- 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/discv5/discV5_service.d.ts +1 -1
- package/dest/services/discv5/discV5_service.d.ts.map +1 -1
- package/dest/services/discv5/discV5_service.js +5 -2
- package/dest/services/dummy_service.d.ts +7 -5
- package/dest/services/dummy_service.d.ts.map +1 -1
- package/dest/services/dummy_service.js +9 -5
- package/dest/services/encoding.d.ts +6 -2
- package/dest/services/encoding.d.ts.map +1 -1
- package/dest/services/encoding.js +16 -9
- 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 +30 -22
- package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
- package/dest/services/libp2p/libp2p_service.js +241 -151
- package/dest/services/peer-manager/metrics.d.ts +3 -1
- package/dest/services/peer-manager/metrics.d.ts.map +1 -1
- package/dest/services/peer-manager/metrics.js +6 -0
- package/dest/services/peer-manager/peer_manager.d.ts +6 -2
- package/dest/services/peer-manager/peer_manager.d.ts.map +1 -1
- package/dest/services/peer-manager/peer_manager.js +24 -9
- package/dest/services/peer-manager/peer_scoring.d.ts +5 -2
- package/dest/services/peer-manager/peer_scoring.d.ts.map +1 -1
- package/dest/services/peer-manager/peer_scoring.js +28 -10
- package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts +12 -8
- package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts.map +1 -1
- package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.js +83 -106
- package/dest/services/reqresp/batch-tx-requester/interface.d.ts +4 -7
- package/dest/services/reqresp/batch-tx-requester/interface.d.ts.map +1 -1
- package/dest/services/reqresp/batch-tx-requester/missing_txs.d.ts +11 -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 +31 -46
- package/dest/services/reqresp/batch-tx-requester/peer_collection.d.ts +19 -11
- package/dest/services/reqresp/batch-tx-requester/peer_collection.d.ts.map +1 -1
- package/dest/services/reqresp/batch-tx-requester/peer_collection.js +52 -15
- package/dest/services/reqresp/batch-tx-requester/tx_validator.js +2 -2
- package/dest/services/reqresp/rate-limiter/rate_limiter.d.ts +5 -4
- package/dest/services/reqresp/rate-limiter/rate_limiter.d.ts.map +1 -1
- package/dest/services/reqresp/rate-limiter/rate_limiter.js +10 -8
- 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 +19 -10
- package/dest/services/service.d.ts +11 -4
- package/dest/services/service.d.ts.map +1 -1
- package/dest/services/tx_collection/fast_tx_collection.d.ts +1 -4
- package/dest/services/tx_collection/fast_tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/fast_tx_collection.js +65 -75
- package/dest/services/tx_collection/file_store_tx_collection.d.ts +1 -1
- package/dest/services/tx_collection/file_store_tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/file_store_tx_collection.js +4 -2
- package/dest/services/tx_collection/file_store_tx_source.d.ts +16 -6
- package/dest/services/tx_collection/file_store_tx_source.d.ts.map +1 -1
- package/dest/services/tx_collection/file_store_tx_source.js +50 -9
- 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/proposal_tx_collector.d.ts +7 -7
- 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/request_tracker.d.ts +53 -0
- package/dest/services/tx_collection/request_tracker.d.ts.map +1 -0
- package/dest/services/tx_collection/request_tracker.js +84 -0
- package/dest/services/tx_collection/slow_tx_collection.d.ts +2 -2
- package/dest/services/tx_collection/slow_tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/slow_tx_collection.js +10 -8
- package/dest/services/tx_collection/tx_collection.d.ts +5 -7
- package/dest/services/tx_collection/tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/tx_collection_sink.d.ts +6 -5
- package/dest/services/tx_collection/tx_collection_sink.d.ts.map +1 -1
- package/dest/services/tx_collection/tx_collection_sink.js +13 -22
- package/dest/services/tx_collection/tx_source.d.ts +13 -7
- package/dest/services/tx_collection/tx_source.d.ts.map +1 -1
- package/dest/services/tx_collection/tx_source.js +26 -7
- package/dest/services/tx_file_store/tx_file_store.js +1 -1
- 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 +4 -4
- package/dest/test-helpers/make-test-p2p-clients.d.ts +5 -6
- 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 +11 -4
- package/dest/test-helpers/mock-pubsub.d.ts.map +1 -1
- package/dest/test-helpers/mock-pubsub.js +16 -3
- 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 +7 -3
- package/dest/test-helpers/testbench-utils.d.ts +6 -3
- package/dest/test-helpers/testbench-utils.d.ts.map +1 -1
- package/dest/test-helpers/testbench-utils.js +23 -4
- 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 +56 -26
- 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 +6 -3
- package/dest/util.d.ts +9 -5
- package/dest/util.d.ts.map +1 -1
- package/dest/util.js +2 -10
- package/package.json +14 -14
- package/src/client/factory.ts +56 -48
- package/src/client/interface.ts +20 -21
- package/src/client/p2p_client.ts +78 -132
- package/src/client/test/tx_proposal_collector/proposal_tx_collector_worker.ts +33 -14
- package/src/config.ts +125 -43
- package/src/errors/p2p-service.error.ts +11 -0
- package/src/errors/tx-pool.error.ts +12 -0
- package/src/index.ts +0 -1
- package/src/mem_pools/attestation_pool/attestation_pool.ts +12 -9
- package/src/mem_pools/attestation_pool/attestation_pool_test_suite.ts +6 -6
- package/src/mem_pools/attestation_pool/mocks.ts +2 -1
- package/src/mem_pools/index.ts +0 -3
- package/src/mem_pools/instrumentation.ts +17 -13
- package/src/mem_pools/tx_pool_v2/README.md +10 -2
- package/src/mem_pools/tx_pool_v2/deleted_pool.ts +11 -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 -4
- 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 +4 -4
- 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 +12 -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 +1 -1
- package/src/mem_pools/tx_pool_v2/instrumentation.ts +69 -0
- package/src/mem_pools/tx_pool_v2/interfaces.ts +24 -10
- package/src/mem_pools/tx_pool_v2/tx_metadata.ts +159 -27
- package/src/mem_pools/tx_pool_v2/tx_pool_indices.ts +43 -46
- package/src/mem_pools/tx_pool_v2/tx_pool_v2.ts +28 -8
- package/src/mem_pools/tx_pool_v2/tx_pool_v2_impl.ts +330 -149
- package/src/msg_validators/attestation_validator/README.md +49 -0
- package/src/msg_validators/attestation_validator/attestation_validator.ts +5 -4
- package/src/msg_validators/clock_tolerance.ts +4 -3
- package/src/msg_validators/proposal_validator/README.md +123 -0
- 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 +69 -45
- package/src/msg_validators/tx_validator/README.md +119 -0
- package/src/msg_validators/tx_validator/aggregate_tx_validator.ts +3 -3
- 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/contract_instance_validator.ts +56 -0
- package/src/msg_validators/tx_validator/data_validator.ts +42 -1
- package/src/msg_validators/tx_validator/factory.ts +394 -78
- 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/metadata_validator.ts +12 -4
- package/src/msg_validators/tx_validator/nullifier_cache.ts +30 -0
- package/src/msg_validators/tx_validator/phases_validator.ts +82 -27
- package/src/msg_validators/tx_validator/timestamp_validator.ts +7 -7
- package/src/services/discv5/discV5_service.ts +5 -2
- package/src/services/dummy_service.ts +12 -7
- package/src/services/encoding.ts +16 -8
- 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 +262 -176
- package/src/services/peer-manager/metrics.ts +7 -0
- package/src/services/peer-manager/peer_manager.ts +28 -9
- package/src/services/peer-manager/peer_scoring.ts +21 -5
- package/src/services/reqresp/README.md +229 -0
- package/src/services/reqresp/batch-tx-requester/README.md +46 -7
- package/src/services/reqresp/batch-tx-requester/batch_tx_requester.ts +79 -112
- package/src/services/reqresp/batch-tx-requester/interface.ts +3 -6
- package/src/services/reqresp/batch-tx-requester/missing_txs.ts +30 -71
- package/src/services/reqresp/batch-tx-requester/peer_collection.ts +68 -24
- package/src/services/reqresp/batch-tx-requester/tx_validator.ts +2 -2
- package/src/services/reqresp/rate-limiter/rate_limiter.ts +13 -9
- package/src/services/reqresp/reqresp.ts +22 -12
- package/src/services/service.ts +20 -3
- package/src/services/tx_collection/fast_tx_collection.ts +71 -76
- package/src/services/tx_collection/file_store_tx_collection.ts +7 -3
- package/src/services/tx_collection/file_store_tx_source.ts +65 -9
- package/src/services/tx_collection/instrumentation.ts +7 -1
- package/src/services/tx_collection/proposal_tx_collector.ts +9 -13
- package/src/services/tx_collection/request_tracker.ts +127 -0
- package/src/services/tx_collection/slow_tx_collection.ts +8 -9
- package/src/services/tx_collection/tx_collection.ts +5 -6
- package/src/services/tx_collection/tx_collection_sink.ts +15 -29
- package/src/services/tx_collection/tx_source.ts +28 -8
- package/src/services/tx_file_store/tx_file_store.ts +1 -1
- package/src/services/tx_provider.ts +2 -2
- package/src/test-helpers/make-test-p2p-clients.ts +1 -3
- package/src/test-helpers/mock-pubsub.ts +20 -6
- package/src/test-helpers/reqresp-nodes.ts +7 -6
- package/src/test-helpers/testbench-utils.ts +32 -6
- package/src/testbench/p2p_client_testbench_worker.ts +62 -29
- package/src/testbench/worker_client_manager.ts +13 -6
- package/src/util.ts +15 -16
- package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.d.ts +0 -125
- package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.js +0 -596
- package/dest/mem_pools/tx_pool/eviction/eviction_manager.d.ts +0 -32
- package/dest/mem_pools/tx_pool/eviction/eviction_manager.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/eviction/eviction_manager.js +0 -112
- package/dest/mem_pools/tx_pool/eviction/eviction_strategy.d.ts +0 -157
- package/dest/mem_pools/tx_pool/eviction/eviction_strategy.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/eviction/eviction_strategy.js +0 -52
- package/dest/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.d.ts +0 -16
- package/dest/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.js +0 -122
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.d.ts +0 -17
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.js +0 -84
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.d.ts +0 -19
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.js +0 -78
- package/dest/mem_pools/tx_pool/eviction/low_priority_eviction_rule.d.ts +0 -26
- package/dest/mem_pools/tx_pool/eviction/low_priority_eviction_rule.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/eviction/low_priority_eviction_rule.js +0 -84
- package/dest/mem_pools/tx_pool/eviction/nullifier_conflict_pre_add_rule.d.ts +0 -25
- package/dest/mem_pools/tx_pool/eviction/nullifier_conflict_pre_add_rule.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/eviction/nullifier_conflict_pre_add_rule.js +0 -57
- package/dest/mem_pools/tx_pool/index.d.ts +0 -3
- package/dest/mem_pools/tx_pool/index.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/index.js +0 -2
- package/dest/mem_pools/tx_pool/priority.d.ts +0 -12
- package/dest/mem_pools/tx_pool/priority.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/priority.js +0 -15
- package/dest/mem_pools/tx_pool/tx_pool.d.ts +0 -127
- package/dest/mem_pools/tx_pool/tx_pool.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/tx_pool.js +0 -3
- package/dest/mem_pools/tx_pool/tx_pool_test_suite.d.ts +0 -7
- package/dest/mem_pools/tx_pool/tx_pool_test_suite.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/tx_pool_test_suite.js +0 -400
- 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/mem_pools/tx_pool/README.md +0 -270
- package/src/mem_pools/tx_pool/aztec_kv_tx_pool.ts +0 -746
- package/src/mem_pools/tx_pool/eviction/eviction_manager.ts +0 -132
- package/src/mem_pools/tx_pool/eviction/eviction_strategy.ts +0 -208
- package/src/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.ts +0 -162
- package/src/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.ts +0 -104
- package/src/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.ts +0 -93
- package/src/mem_pools/tx_pool/eviction/low_priority_eviction_rule.ts +0 -106
- package/src/mem_pools/tx_pool/eviction/nullifier_conflict_pre_add_rule.ts +0 -75
- package/src/mem_pools/tx_pool/index.ts +0 -2
- package/src/mem_pools/tx_pool/priority.ts +0 -20
- package/src/mem_pools/tx_pool/tx_pool.ts +0 -141
- package/src/mem_pools/tx_pool/tx_pool_test_suite.ts +0 -319
- package/src/msg_validators/proposal_validator/proposal_validator_test_suite.ts +0 -230
|
@@ -126,9 +126,13 @@ export class FileStoreTxCollection {
|
|
|
126
126
|
|
|
127
127
|
try {
|
|
128
128
|
const result = await this.txCollectionSink.collect(
|
|
129
|
-
|
|
130
|
-
[
|
|
131
|
-
{
|
|
129
|
+
() => source.getTxsByHash([TxHash.fromString(entry.txHash)]),
|
|
130
|
+
[entry.txHash],
|
|
131
|
+
{
|
|
132
|
+
description: `file-store ${source.getInfo()}`,
|
|
133
|
+
method: 'file-store',
|
|
134
|
+
fileStore: source.getInfo(),
|
|
135
|
+
},
|
|
132
136
|
entry.context,
|
|
133
137
|
);
|
|
134
138
|
if (result.txs.length > 0) {
|
|
@@ -1,28 +1,54 @@
|
|
|
1
|
+
import { partitionAsync } from '@aztec/foundation/collection';
|
|
1
2
|
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
3
|
+
import { Timer } from '@aztec/foundation/timer';
|
|
2
4
|
import { type ReadOnlyFileStore, createReadOnlyFileStore } from '@aztec/stdlib/file-store';
|
|
3
|
-
import { Tx, type TxHash } from '@aztec/stdlib/tx';
|
|
5
|
+
import { Tx, type TxHash, type TxValidator } from '@aztec/stdlib/tx';
|
|
6
|
+
import {
|
|
7
|
+
type Histogram,
|
|
8
|
+
Metrics,
|
|
9
|
+
type TelemetryClient,
|
|
10
|
+
type UpDownCounter,
|
|
11
|
+
getTelemetryClient,
|
|
12
|
+
} from '@aztec/telemetry-client';
|
|
4
13
|
|
|
5
|
-
import type { TxSource } from './tx_source.js';
|
|
14
|
+
import type { TxSource, TxSourceCollectionResult } from './tx_source.js';
|
|
6
15
|
|
|
7
16
|
/** TxSource implementation that downloads txs from a file store. */
|
|
8
17
|
export class FileStoreTxSource implements TxSource {
|
|
18
|
+
private downloadsSuccess: UpDownCounter;
|
|
19
|
+
private downloadsFailed: UpDownCounter;
|
|
20
|
+
private downloadDuration: Histogram;
|
|
21
|
+
private downloadSize: Histogram;
|
|
22
|
+
|
|
9
23
|
private constructor(
|
|
10
24
|
private readonly fileStore: ReadOnlyFileStore,
|
|
11
25
|
private readonly baseUrl: string,
|
|
12
26
|
private readonly basePath: string,
|
|
27
|
+
private readonly txValidator: TxValidator,
|
|
13
28
|
private readonly log: Logger,
|
|
14
|
-
|
|
29
|
+
telemetry: TelemetryClient,
|
|
30
|
+
) {
|
|
31
|
+
const meter = telemetry.getMeter('file-store-tx-source');
|
|
32
|
+
this.downloadsSuccess = meter.createUpDownCounter(Metrics.TX_FILE_STORE_DOWNLOADS_SUCCESS);
|
|
33
|
+
this.downloadsFailed = meter.createUpDownCounter(Metrics.TX_FILE_STORE_DOWNLOADS_FAILED);
|
|
34
|
+
this.downloadDuration = meter.createHistogram(Metrics.TX_FILE_STORE_DOWNLOAD_DURATION);
|
|
35
|
+
this.downloadSize = meter.createHistogram(Metrics.TX_FILE_STORE_DOWNLOAD_SIZE);
|
|
36
|
+
}
|
|
15
37
|
|
|
16
38
|
/**
|
|
17
39
|
* Creates a FileStoreTxSource from a URL.
|
|
18
40
|
* @param url - The file store URL (s3://, gs://, file://, http://, https://).
|
|
41
|
+
* @param basePath - Base path for tx files within the store.
|
|
19
42
|
* @param log - Optional logger.
|
|
43
|
+
* @param telemetry - Optional telemetry client.
|
|
20
44
|
* @returns The FileStoreTxSource instance, or undefined if creation fails.
|
|
21
45
|
*/
|
|
22
46
|
public static async create(
|
|
23
47
|
url: string,
|
|
24
48
|
basePath: string,
|
|
49
|
+
txValidator: TxValidator,
|
|
25
50
|
log: Logger = createLogger('p2p:file_store_tx_source'),
|
|
51
|
+
telemetry: TelemetryClient = getTelemetryClient(),
|
|
26
52
|
): Promise<FileStoreTxSource | undefined> {
|
|
27
53
|
try {
|
|
28
54
|
const fileStore = await createReadOnlyFileStore(url, log);
|
|
@@ -30,7 +56,7 @@ export class FileStoreTxSource implements TxSource {
|
|
|
30
56
|
log.warn(`Failed to create file store for URL: ${url}`);
|
|
31
57
|
return undefined;
|
|
32
58
|
}
|
|
33
|
-
return new FileStoreTxSource(fileStore, url, basePath, log);
|
|
59
|
+
return new FileStoreTxSource(fileStore, url, basePath, txValidator, log, telemetry);
|
|
34
60
|
} catch (err) {
|
|
35
61
|
log.warn(`Error creating file store for URL: ${url}`, { error: err });
|
|
36
62
|
return undefined;
|
|
@@ -41,33 +67,63 @@ export class FileStoreTxSource implements TxSource {
|
|
|
41
67
|
return `file-store:${this.baseUrl}`;
|
|
42
68
|
}
|
|
43
69
|
|
|
44
|
-
public getTxsByHash(txHashes: TxHash[]): Promise<
|
|
45
|
-
|
|
70
|
+
public async getTxsByHash(txHashes: TxHash[]): Promise<TxSourceCollectionResult> {
|
|
71
|
+
const results = await Promise.all(
|
|
46
72
|
txHashes.map(async txHash => {
|
|
47
73
|
const path = `${this.basePath}/txs/${txHash.toString()}.bin`;
|
|
74
|
+
const timer = new Timer();
|
|
48
75
|
try {
|
|
49
76
|
const buffer = await this.fileStore.read(path);
|
|
50
|
-
|
|
77
|
+
const tx = Tx.fromBuffer(buffer);
|
|
78
|
+
return { tx, downloadDuration: timer.ms(), downloadSize: buffer.length };
|
|
51
79
|
} catch {
|
|
52
|
-
|
|
80
|
+
this.downloadsFailed.add(1);
|
|
53
81
|
return undefined;
|
|
54
82
|
}
|
|
55
83
|
}),
|
|
56
84
|
);
|
|
85
|
+
|
|
86
|
+
const txs = results.filter(tx => tx !== undefined);
|
|
87
|
+
const [validTxs, invalidTxs] = await partitionAsync(
|
|
88
|
+
txs,
|
|
89
|
+
async ({ tx, downloadDuration, downloadSize }): Promise<boolean> => {
|
|
90
|
+
const valid = await this.txValidator.validateTx(tx);
|
|
91
|
+
if (valid.result === 'valid') {
|
|
92
|
+
this.downloadsSuccess.add(1);
|
|
93
|
+
this.downloadDuration.record(Math.ceil(downloadDuration));
|
|
94
|
+
this.downloadSize.record(downloadSize);
|
|
95
|
+
return true;
|
|
96
|
+
} else {
|
|
97
|
+
this.downloadsFailed.add(1);
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
);
|
|
102
|
+
|
|
103
|
+
return {
|
|
104
|
+
validTxs: validTxs.map(({ tx }) => tx),
|
|
105
|
+
invalidTxHashes: invalidTxs.map(({ tx }) => tx.getTxHash().toString()),
|
|
106
|
+
};
|
|
57
107
|
}
|
|
58
108
|
}
|
|
59
109
|
|
|
60
110
|
/**
|
|
61
111
|
* Creates FileStoreTxSource instances from URLs.
|
|
62
112
|
* @param urls - Array of file store URLs.
|
|
113
|
+
* @param basePath - Base path for tx files within each store.
|
|
63
114
|
* @param log - Optional logger.
|
|
115
|
+
* @param telemetry - Optional telemetry client.
|
|
64
116
|
* @returns Array of successfully created FileStoreTxSource instances.
|
|
65
117
|
*/
|
|
66
118
|
export async function createFileStoreTxSources(
|
|
67
119
|
urls: string[],
|
|
68
120
|
basePath: string,
|
|
121
|
+
txValidator: TxValidator,
|
|
69
122
|
log: Logger = createLogger('p2p:file_store_tx_source'),
|
|
123
|
+
telemetry: TelemetryClient = getTelemetryClient(),
|
|
70
124
|
): Promise<FileStoreTxSource[]> {
|
|
71
|
-
const sources = await Promise.all(
|
|
125
|
+
const sources = await Promise.all(
|
|
126
|
+
urls.map(url => FileStoreTxSource.create(url, basePath, txValidator, log, telemetry)),
|
|
127
|
+
);
|
|
72
128
|
return sources.filter((s): s is FileStoreTxSource => s !== undefined);
|
|
73
129
|
}
|
|
@@ -18,7 +18,13 @@ export class TxCollectionInstrumentation {
|
|
|
18
18
|
const meter = client.getMeter(name);
|
|
19
19
|
|
|
20
20
|
this.txsCollected = createUpDownCounterWithDefault(meter, Metrics.TX_COLLECTOR_COUNT, {
|
|
21
|
-
[Attributes.TX_COLLECTION_METHOD]: [
|
|
21
|
+
[Attributes.TX_COLLECTION_METHOD]: [
|
|
22
|
+
'fast-req-resp',
|
|
23
|
+
'fast-node-rpc',
|
|
24
|
+
'slow-req-resp',
|
|
25
|
+
'slow-node-rpc',
|
|
26
|
+
'file-store',
|
|
27
|
+
],
|
|
22
28
|
});
|
|
23
29
|
|
|
24
30
|
this.collectionDurationPerTx = meter.createHistogram(Metrics.TX_COLLECTOR_DURATION_PER_TX);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Logger } from '@aztec/foundation/log';
|
|
2
2
|
import type { DateProvider } from '@aztec/foundation/timer';
|
|
3
|
-
import type
|
|
3
|
+
import { type Tx, TxHash } from '@aztec/stdlib/tx';
|
|
4
4
|
|
|
5
5
|
import type { PeerId } from '@libp2p/interface';
|
|
6
6
|
|
|
@@ -9,6 +9,7 @@ import type { BatchTxRequesterConfig } from '../reqresp/batch-tx-requester/confi
|
|
|
9
9
|
import type { BatchTxRequesterLibP2PService } from '../reqresp/batch-tx-requester/interface.js';
|
|
10
10
|
import type { IBatchRequestTxValidator } from '../reqresp/batch-tx-requester/tx_validator.js';
|
|
11
11
|
import { type BlockTxsSource, ReqRespSubProtocol, chunkTxHashesRequest } from '../reqresp/index.js';
|
|
12
|
+
import type { IRequestTracker } from './request_tracker.js';
|
|
12
13
|
|
|
13
14
|
/**
|
|
14
15
|
* Strategy interface for collecting missing transactions for a block or proposal.
|
|
@@ -17,17 +18,15 @@ import { type BlockTxsSource, ReqRespSubProtocol, chunkTxHashesRequest } from '.
|
|
|
17
18
|
export interface MissingTxsCollector {
|
|
18
19
|
/**
|
|
19
20
|
* Collect missing transactions for a block or proposal.
|
|
20
|
-
* @param
|
|
21
|
+
* @param requestTracker - The missing transactions tracker
|
|
21
22
|
* @param blockTxsSource - The block or proposal containing the transactions
|
|
22
23
|
* @param pinnedPeer - Optional peer expected to have the transactions
|
|
23
|
-
* @param timeoutMs - Timeout in milliseconds
|
|
24
24
|
* @returns The collected transactions
|
|
25
25
|
*/
|
|
26
26
|
collectTxs(
|
|
27
|
-
|
|
27
|
+
requestTracker: IRequestTracker,
|
|
28
28
|
blockTxsSource: BlockTxsSource,
|
|
29
29
|
pinnedPeer: PeerId | undefined,
|
|
30
|
-
timeoutMs: number,
|
|
31
30
|
): Promise<Tx[]>;
|
|
32
31
|
}
|
|
33
32
|
|
|
@@ -45,10 +44,9 @@ export class BatchTxRequesterCollector implements MissingTxsCollector {
|
|
|
45
44
|
) {}
|
|
46
45
|
|
|
47
46
|
async collectTxs(
|
|
48
|
-
|
|
47
|
+
requestTracker: IRequestTracker,
|
|
49
48
|
blockTxsSource: BlockTxsSource,
|
|
50
49
|
pinnedPeer: PeerId | undefined,
|
|
51
|
-
timeoutMs: number,
|
|
52
50
|
): Promise<Tx[]> {
|
|
53
51
|
const {
|
|
54
52
|
batchTxRequesterSmartParallelWorkerCount: smartParallelWorkerCount,
|
|
@@ -58,10 +56,9 @@ export class BatchTxRequesterCollector implements MissingTxsCollector {
|
|
|
58
56
|
} = this.batchTxRequesterConfig ?? {};
|
|
59
57
|
|
|
60
58
|
const batchRequester = new BatchTxRequester(
|
|
61
|
-
|
|
59
|
+
requestTracker,
|
|
62
60
|
blockTxsSource,
|
|
63
61
|
pinnedPeer,
|
|
64
|
-
timeoutMs,
|
|
65
62
|
this.p2pService,
|
|
66
63
|
this.log,
|
|
67
64
|
this.dateProvider,
|
|
@@ -93,16 +90,15 @@ export class SendBatchRequestCollector implements MissingTxsCollector {
|
|
|
93
90
|
) {}
|
|
94
91
|
|
|
95
92
|
async collectTxs(
|
|
96
|
-
|
|
93
|
+
requestTracker: IRequestTracker,
|
|
97
94
|
_blockTxsSource: BlockTxsSource,
|
|
98
95
|
pinnedPeer: PeerId | undefined,
|
|
99
|
-
timeoutMs: number,
|
|
100
96
|
): Promise<Tx[]> {
|
|
101
97
|
const txs = await this.p2pService.reqResp.sendBatchRequest<ReqRespSubProtocol.TX>(
|
|
102
98
|
ReqRespSubProtocol.TX,
|
|
103
|
-
chunkTxHashesRequest(
|
|
99
|
+
chunkTxHashesRequest(Array.from(requestTracker.missingTxHashes).map(TxHash.fromString)),
|
|
104
100
|
pinnedPeer,
|
|
105
|
-
timeoutMs,
|
|
101
|
+
requestTracker.timeoutMs,
|
|
106
102
|
this.maxPeers,
|
|
107
103
|
this.maxRetryAttempts,
|
|
108
104
|
);
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { type PromiseWithResolvers, promiseWithResolvers } from '@aztec/foundation/promise';
|
|
2
|
+
import type { DateProvider } from '@aztec/foundation/timer';
|
|
3
|
+
import { TxHash } from '@aztec/stdlib/tx';
|
|
4
|
+
import type { Tx } from '@aztec/stdlib/tx';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Tracks which transactions are still missing and need to be fetched.
|
|
8
|
+
* Manages the request deadline and serves as the sole source of cancellation signal.
|
|
9
|
+
* The request is cancelled when all txs are fetched or the deadline expires.
|
|
10
|
+
*/
|
|
11
|
+
export interface IRequestTracker {
|
|
12
|
+
/** Returns the set of transaction hashes that are still missing. */
|
|
13
|
+
get missingTxHashes(): Set<string>;
|
|
14
|
+
/** Size of this.missingTxHashes */
|
|
15
|
+
get numberOfMissingTxs(): number;
|
|
16
|
+
/** Are all requested txs fetched */
|
|
17
|
+
allFetched(): boolean;
|
|
18
|
+
/** Checks that transaction is still missing */
|
|
19
|
+
isMissing(txHash: string): boolean;
|
|
20
|
+
/** Marks a transaction as fetched. Returns true if it was previously missing. */
|
|
21
|
+
markFetched(tx: Tx): boolean;
|
|
22
|
+
/** Get list of collected txs */
|
|
23
|
+
get collectedTxs(): Tx[];
|
|
24
|
+
/** The deadline for this request. */
|
|
25
|
+
get deadline(): Date;
|
|
26
|
+
/** Remaining time in milliseconds until deadline. Returns 0 if already past. */
|
|
27
|
+
get timeoutMs(): number;
|
|
28
|
+
/** Checks whether the request is cancelled (deadline expired or all fetched). May trigger cancellation if deadline has passed. */
|
|
29
|
+
checkCancelled(): boolean;
|
|
30
|
+
/** Resolves when deadline expires or all txs are fetched. */
|
|
31
|
+
get cancellationToken(): Promise<void>;
|
|
32
|
+
/** Externally cancel the request. */
|
|
33
|
+
cancel(): void;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export class RequestTracker implements IRequestTracker {
|
|
37
|
+
public readonly collectedTxs: Tx[] = [];
|
|
38
|
+
private done = false;
|
|
39
|
+
private readonly cancellationTokenPromise: PromiseWithResolvers<void>;
|
|
40
|
+
private readonly deadlineTimer: ReturnType<typeof setTimeout> | undefined;
|
|
41
|
+
|
|
42
|
+
private constructor(
|
|
43
|
+
public readonly missingTxHashes: Set<string>,
|
|
44
|
+
public readonly deadline: Date,
|
|
45
|
+
private readonly dateProvider?: DateProvider,
|
|
46
|
+
) {
|
|
47
|
+
this.cancellationTokenPromise = promiseWithResolvers<void>();
|
|
48
|
+
|
|
49
|
+
if (missingTxHashes.size === 0) {
|
|
50
|
+
this.finish();
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const now = this.dateProvider?.now() ?? Date.now();
|
|
55
|
+
const remaining = deadline.getTime() - now;
|
|
56
|
+
if (remaining <= 0) {
|
|
57
|
+
this.finish();
|
|
58
|
+
} else {
|
|
59
|
+
this.deadlineTimer = setTimeout(() => this.finish(), remaining);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
public static create(hashes: TxHash[] | string[], deadline: Date, dateProvider?: DateProvider) {
|
|
64
|
+
return new RequestTracker(new Set(hashes.map(hash => hash.toString())), deadline, dateProvider);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
markFetched(tx: Tx): boolean {
|
|
68
|
+
if (this.missingTxHashes.delete(tx.txHash.toString())) {
|
|
69
|
+
this.collectedTxs.push(tx);
|
|
70
|
+
if (this.allFetched()) {
|
|
71
|
+
this.finish();
|
|
72
|
+
}
|
|
73
|
+
return true;
|
|
74
|
+
}
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
get numberOfMissingTxs(): number {
|
|
79
|
+
return this.missingTxHashes.size;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
allFetched(): boolean {
|
|
83
|
+
return this.numberOfMissingTxs === 0;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
isMissing(txHash: string): boolean {
|
|
87
|
+
return this.missingTxHashes.has(txHash.toString());
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
get timeoutMs(): number {
|
|
91
|
+
const now = this.dateProvider?.now() ?? Date.now();
|
|
92
|
+
return Math.max(0, this.deadline.getTime() - now);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
checkCancelled(): boolean {
|
|
96
|
+
if (this.done) {
|
|
97
|
+
return true;
|
|
98
|
+
}
|
|
99
|
+
// Synchronous fallback: check deadline even if setTimeout hasn't fired yet.
|
|
100
|
+
// This prevents macrotask starvation in tight async loops from blocking cancellation.
|
|
101
|
+
const now = this.dateProvider?.now() ?? Date.now();
|
|
102
|
+
if (now >= this.deadline.getTime()) {
|
|
103
|
+
this.finish();
|
|
104
|
+
return true;
|
|
105
|
+
}
|
|
106
|
+
return false;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
get cancellationToken(): Promise<void> {
|
|
110
|
+
return this.cancellationTokenPromise.promise;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
cancel(): void {
|
|
114
|
+
this.finish();
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
private finish() {
|
|
118
|
+
if (this.done) {
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
this.done = true;
|
|
122
|
+
if (this.deadlineTimer) {
|
|
123
|
+
clearTimeout(this.deadlineTimer);
|
|
124
|
+
}
|
|
125
|
+
this.cancellationTokenPromise.resolve();
|
|
126
|
+
}
|
|
127
|
+
}
|
|
@@ -8,8 +8,7 @@ import type { L2Block } from '@aztec/stdlib/block';
|
|
|
8
8
|
import { type L1RollupConstants, getEpochAtSlot, getTimestampRangeForEpoch } from '@aztec/stdlib/epoch-helpers';
|
|
9
9
|
import { type Tx, TxHash } from '@aztec/stdlib/tx';
|
|
10
10
|
|
|
11
|
-
import { type ReqRespInterface, ReqRespSubProtocol } from '../reqresp/
|
|
12
|
-
import { chunkTxHashesRequest } from '../reqresp/protocols/tx.js';
|
|
11
|
+
import { type ReqRespInterface, ReqRespSubProtocol, chunkTxHashesRequest } from '../reqresp/index.js';
|
|
13
12
|
import type { TxCollectionConfig } from './config.js';
|
|
14
13
|
import type { FastTxCollection } from './fast_tx_collection.js';
|
|
15
14
|
import type { MissingTxInfo } from './tx_collection.js';
|
|
@@ -120,8 +119,8 @@ export class SlowTxCollection {
|
|
|
120
119
|
const txHashes = entries.map(([txHash]) => TxHash.fromString(txHash));
|
|
121
120
|
for (const batch of chunk(txHashes, this.config.txCollectionNodeRpcMaxBatchSize)) {
|
|
122
121
|
await this.txCollectionSink.collect(
|
|
123
|
-
|
|
124
|
-
batch,
|
|
122
|
+
() => node.getTxsByHash(batch),
|
|
123
|
+
batch.map(h => h.toString()),
|
|
125
124
|
{
|
|
126
125
|
description: `node ${node.getInfo()}`,
|
|
127
126
|
node: node.getInfo(),
|
|
@@ -166,18 +165,18 @@ export class SlowTxCollection {
|
|
|
166
165
|
const txHashes = entries.map(([txHash]) => TxHash.fromString(txHash));
|
|
167
166
|
const maxPeers = boundInclusive(Math.ceil(txHashes.length / 3), 4, 16);
|
|
168
167
|
await this.txCollectionSink.collect(
|
|
169
|
-
async
|
|
168
|
+
async () => {
|
|
170
169
|
const txs = await this.reqResp.sendBatchRequest<ReqRespSubProtocol.TX>(
|
|
171
170
|
ReqRespSubProtocol.TX,
|
|
172
|
-
chunkTxHashesRequest(
|
|
171
|
+
chunkTxHashesRequest(txHashes),
|
|
173
172
|
pinnedPeer,
|
|
174
173
|
timeoutMs,
|
|
175
174
|
maxPeers,
|
|
176
175
|
maxRetryAttempts,
|
|
177
176
|
);
|
|
178
|
-
return txs.flat();
|
|
177
|
+
return { validTxs: txs.flat(), invalidTxHashes: [] };
|
|
179
178
|
},
|
|
180
|
-
txHashes,
|
|
179
|
+
txHashes.map(h => h.toString()),
|
|
181
180
|
{ description: 'slow reqresp', timeoutMs, method: 'slow-req-resp' },
|
|
182
181
|
{ type: 'mined', block },
|
|
183
182
|
);
|
|
@@ -197,7 +196,7 @@ export class SlowTxCollection {
|
|
|
197
196
|
// from mined unproven blocks it has seen in the past.
|
|
198
197
|
const fastRequests = this.fastCollection.getFastCollectionRequests();
|
|
199
198
|
const fastCollectionTxs: Set<string> = new Set(
|
|
200
|
-
|
|
199
|
+
fastRequests.values().flatMap(r => Array.from(r.requestTracker.missingTxHashes)),
|
|
201
200
|
);
|
|
202
201
|
|
|
203
202
|
// Return all missing txs that are not in fastCollectionTxs and are ready for reqresp if requested
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
2
2
|
import { compactArray } from '@aztec/foundation/collection';
|
|
3
3
|
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
4
|
-
import {
|
|
4
|
+
import { RunningPromise } from '@aztec/foundation/promise';
|
|
5
5
|
import { sleep } from '@aztec/foundation/sleep';
|
|
6
6
|
import { DateProvider } from '@aztec/foundation/timer';
|
|
7
7
|
import type { L2Block, L2BlockInfo } from '@aztec/stdlib/block';
|
|
8
8
|
import type { L1RollupConstants } from '@aztec/stdlib/epoch-helpers';
|
|
9
9
|
import type { BlockProposal } from '@aztec/stdlib/p2p';
|
|
10
|
-
import { Tx
|
|
10
|
+
import type { Tx } from '@aztec/stdlib/tx';
|
|
11
|
+
import { TxHash } from '@aztec/stdlib/tx';
|
|
11
12
|
import { type TelemetryClient, getTelemetryClient } from '@aztec/telemetry-client';
|
|
12
13
|
|
|
13
14
|
import type { PeerId } from '@libp2p/interface';
|
|
@@ -18,6 +19,7 @@ import type { TxCollectionConfig } from './config.js';
|
|
|
18
19
|
import { FastTxCollection } from './fast_tx_collection.js';
|
|
19
20
|
import { FileStoreTxCollection } from './file_store_tx_collection.js';
|
|
20
21
|
import type { FileStoreTxSource } from './file_store_tx_source.js';
|
|
22
|
+
import type { IRequestTracker } from './request_tracker.js';
|
|
21
23
|
import { SlowTxCollection, getProofDeadlineForSlot } from './slow_tx_collection.js';
|
|
22
24
|
import { type TxAddContext, TxCollectionSink } from './tx_collection_sink.js';
|
|
23
25
|
import type { TxSource } from './tx_source.js';
|
|
@@ -31,11 +33,8 @@ export type FastCollectionRequestInput =
|
|
|
31
33
|
| { type: 'proposal'; blockProposal: BlockProposal; blockNumber: BlockNumber };
|
|
32
34
|
|
|
33
35
|
export type FastCollectionRequest = FastCollectionRequestInput & {
|
|
34
|
-
|
|
35
|
-
deadline: Date;
|
|
36
|
+
requestTracker: IRequestTracker;
|
|
36
37
|
blockInfo: L2BlockInfo;
|
|
37
|
-
promise: PromiseWithResolvers<void>;
|
|
38
|
-
foundTxs: Map<string, Tx>;
|
|
39
38
|
};
|
|
40
39
|
|
|
41
40
|
/**
|
|
@@ -2,14 +2,15 @@ import type { Logger } from '@aztec/foundation/log';
|
|
|
2
2
|
import { elapsed } from '@aztec/foundation/timer';
|
|
3
3
|
import type { TypedEventEmitter } from '@aztec/foundation/types';
|
|
4
4
|
import type { L2Block } from '@aztec/stdlib/block';
|
|
5
|
-
import type { BlockHeader, Tx
|
|
5
|
+
import type { BlockHeader, Tx } from '@aztec/stdlib/tx';
|
|
6
6
|
import type { TelemetryClient } from '@aztec/telemetry-client';
|
|
7
7
|
|
|
8
8
|
import EventEmitter from 'node:events';
|
|
9
9
|
|
|
10
|
-
import type { TxPoolV2, TxPoolV2Events } from '../../mem_pools/
|
|
10
|
+
import type { TxPoolV2, TxPoolV2Events } from '../../mem_pools/index.js';
|
|
11
11
|
import { TxCollectionInstrumentation } from './instrumentation.js';
|
|
12
12
|
import type { CollectionMethod } from './tx_collection.js';
|
|
13
|
+
import type { TxSourceCollectionResult } from './tx_source.js';
|
|
13
14
|
|
|
14
15
|
/** Context determining how collected txs should be added to the pool. */
|
|
15
16
|
export type TxAddContext = { type: 'proposal'; blockHeader: BlockHeader } | { type: 'mined'; block: L2Block };
|
|
@@ -31,52 +32,37 @@ export class TxCollectionSink extends (EventEmitter as new () => TypedEventEmitt
|
|
|
31
32
|
}
|
|
32
33
|
|
|
33
34
|
public async collect(
|
|
34
|
-
collectValidTxsFn: (
|
|
35
|
-
requested:
|
|
35
|
+
collectValidTxsFn: () => Promise<TxSourceCollectionResult>,
|
|
36
|
+
requested: string[],
|
|
36
37
|
info: Record<string, any> & { description: string; method: CollectionMethod },
|
|
37
38
|
context: TxAddContext,
|
|
38
39
|
) {
|
|
39
40
|
this.log.trace(`Requesting ${requested.length} txs via ${info.description}`, {
|
|
40
41
|
...info,
|
|
41
|
-
requestedTxs: requested
|
|
42
|
+
requestedTxs: requested,
|
|
42
43
|
});
|
|
43
44
|
|
|
44
45
|
// Execute collection function and measure the time taken, catching any errors.
|
|
45
|
-
const [duration,
|
|
46
|
+
const [duration, { validTxs, invalidTxHashes }] = await elapsed(async () => {
|
|
46
47
|
try {
|
|
47
|
-
|
|
48
|
-
return response.filter(tx => tx !== undefined);
|
|
48
|
+
return await collectValidTxsFn();
|
|
49
49
|
} catch (err) {
|
|
50
50
|
this.log.error(`Error collecting txs via ${info.description}`, err, {
|
|
51
51
|
...info,
|
|
52
|
-
requestedTxs: requested
|
|
52
|
+
requestedTxs: requested,
|
|
53
53
|
});
|
|
54
|
-
return [] as Tx[];
|
|
54
|
+
return { validTxs: [] as Tx[], invalidTxHashes: [] as string[] };
|
|
55
55
|
}
|
|
56
56
|
});
|
|
57
57
|
|
|
58
|
-
if (
|
|
58
|
+
if (validTxs.length === 0 && invalidTxHashes.length === 0) {
|
|
59
59
|
this.log.trace(`No txs found via ${info.description}`, {
|
|
60
60
|
...info,
|
|
61
|
-
requestedTxs: requested
|
|
61
|
+
requestedTxs: requested,
|
|
62
62
|
});
|
|
63
|
-
return { txs, requested, duration };
|
|
63
|
+
return { txs: validTxs, requested, duration };
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
// Validate tx hashes for all collected txs from external sources
|
|
67
|
-
const validTxs: Tx[] = [];
|
|
68
|
-
const invalidTxHashes: string[] = [];
|
|
69
|
-
await Promise.all(
|
|
70
|
-
txs.map(async tx => {
|
|
71
|
-
const isValid = await tx.validateTxHash();
|
|
72
|
-
if (isValid) {
|
|
73
|
-
validTxs.push(tx);
|
|
74
|
-
} else {
|
|
75
|
-
invalidTxHashes.push(tx.getTxHash().toString());
|
|
76
|
-
}
|
|
77
|
-
}),
|
|
78
|
-
);
|
|
79
|
-
|
|
80
66
|
if (invalidTxHashes.length > 0) {
|
|
81
67
|
this.log.warn(`Rejecting ${invalidTxHashes.length} txs with invalid hashes from ${info.description}`, {
|
|
82
68
|
...info,
|
|
@@ -87,7 +73,7 @@ export class TxCollectionSink extends (EventEmitter as new () => TypedEventEmitt
|
|
|
87
73
|
if (validTxs.length === 0) {
|
|
88
74
|
this.log.trace(`No valid txs found via ${info.description} after validation`, {
|
|
89
75
|
...info,
|
|
90
|
-
requestedTxs: requested
|
|
76
|
+
requestedTxs: requested,
|
|
91
77
|
invalidTxHashes,
|
|
92
78
|
});
|
|
93
79
|
return { txs: [], requested, duration };
|
|
@@ -99,7 +85,7 @@ export class TxCollectionSink extends (EventEmitter as new () => TypedEventEmitt
|
|
|
99
85
|
...info,
|
|
100
86
|
duration,
|
|
101
87
|
txs: validTxs.map(t => t.getTxHash().toString()),
|
|
102
|
-
requestedTxs: requested
|
|
88
|
+
requestedTxs: requested,
|
|
103
89
|
rejectedCount: invalidTxHashes.length,
|
|
104
90
|
},
|
|
105
91
|
);
|
|
@@ -2,36 +2,56 @@ import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
|
|
|
2
2
|
import { protocolContractsHash } from '@aztec/protocol-contracts';
|
|
3
3
|
import type { ChainConfig } from '@aztec/stdlib/config';
|
|
4
4
|
import { type AztecNode, createAztecNodeClient } from '@aztec/stdlib/interfaces/client';
|
|
5
|
-
import type { Tx, TxHash } from '@aztec/stdlib/tx';
|
|
5
|
+
import type { Tx, TxHash, TxValidator } from '@aztec/stdlib/tx';
|
|
6
6
|
import { type ComponentsVersions, getComponentsVersionsFromConfig } from '@aztec/stdlib/versioning';
|
|
7
7
|
import { makeTracedFetch } from '@aztec/telemetry-client';
|
|
8
8
|
|
|
9
|
+
export type TxSourceCollectionResult = { validTxs: Tx[]; invalidTxHashes: string[] };
|
|
10
|
+
|
|
9
11
|
export interface TxSource {
|
|
10
12
|
getInfo(): string;
|
|
11
|
-
getTxsByHash(txHashes: TxHash[]): Promise<
|
|
13
|
+
getTxsByHash(txHashes: TxHash[]): Promise<TxSourceCollectionResult>;
|
|
12
14
|
}
|
|
13
15
|
|
|
14
16
|
export class NodeRpcTxSource implements TxSource {
|
|
15
17
|
constructor(
|
|
16
18
|
private readonly client: Pick<AztecNode, 'getTxsByHash'>,
|
|
19
|
+
private readonly txValidator: TxValidator,
|
|
17
20
|
private readonly info: string,
|
|
18
21
|
) {}
|
|
19
22
|
|
|
20
|
-
public static fromUrl(nodeUrl: string, versions: ComponentsVersions): NodeRpcTxSource {
|
|
23
|
+
public static fromUrl(nodeUrl: string, txValidator: TxValidator, versions: ComponentsVersions): NodeRpcTxSource {
|
|
21
24
|
const client = createAztecNodeClient(nodeUrl, versions, makeTracedFetch([1, 2, 3], false));
|
|
22
|
-
return new NodeRpcTxSource(client, nodeUrl);
|
|
25
|
+
return new NodeRpcTxSource(client, txValidator, nodeUrl);
|
|
23
26
|
}
|
|
24
27
|
|
|
25
28
|
public getInfo() {
|
|
26
29
|
return this.info;
|
|
27
30
|
}
|
|
28
31
|
|
|
29
|
-
public getTxsByHash(txHashes: TxHash[]): Promise<
|
|
30
|
-
return this.client.getTxsByHash(txHashes);
|
|
32
|
+
public async getTxsByHash(txHashes: TxHash[]): Promise<TxSourceCollectionResult> {
|
|
33
|
+
return this.verifyTxs(await this.client.getTxsByHash(txHashes));
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
private async verifyTxs(txs: Tx[]): Promise<TxSourceCollectionResult> {
|
|
37
|
+
// Validate tx hashes for all collected txs from external sources
|
|
38
|
+
const validTxs: Tx[] = [];
|
|
39
|
+
const invalidTxHashes: string[] = [];
|
|
40
|
+
await Promise.all(
|
|
41
|
+
txs.map(async tx => {
|
|
42
|
+
const validation = await this.txValidator.validateTx(tx);
|
|
43
|
+
if (validation.result === 'valid') {
|
|
44
|
+
validTxs.push(tx);
|
|
45
|
+
} else {
|
|
46
|
+
invalidTxHashes.push(tx.getTxHash().toString());
|
|
47
|
+
}
|
|
48
|
+
}),
|
|
49
|
+
);
|
|
50
|
+
return { validTxs: validTxs, invalidTxHashes: invalidTxHashes };
|
|
31
51
|
}
|
|
32
52
|
}
|
|
33
53
|
|
|
34
|
-
export function createNodeRpcTxSources(urls: string[], chainConfig: ChainConfig) {
|
|
54
|
+
export function createNodeRpcTxSources(urls: string[], txValidator: TxValidator, chainConfig: ChainConfig) {
|
|
35
55
|
const versions = getComponentsVersionsFromConfig(chainConfig, protocolContractsHash, getVKTreeRoot());
|
|
36
|
-
return urls.map(url => NodeRpcTxSource.fromUrl(url, versions));
|
|
56
|
+
return urls.map(url => NodeRpcTxSource.fromUrl(url, txValidator, versions));
|
|
37
57
|
}
|
|
@@ -146,7 +146,7 @@ export class TxFileStore {
|
|
|
146
146
|
}
|
|
147
147
|
|
|
148
148
|
await retry(
|
|
149
|
-
() => this.fileStore.save(path, tx.toBuffer(), { compress:
|
|
149
|
+
() => this.fileStore.save(path, tx.toBuffer(), { compress: true }),
|
|
150
150
|
`Uploading tx ${txHash}`,
|
|
151
151
|
makeBackoff([0.1, 0.5, 2]),
|
|
152
152
|
this.log,
|
|
@@ -25,7 +25,7 @@ export class TxProvider implements ITxProvider {
|
|
|
25
25
|
constructor(
|
|
26
26
|
private txCollection: TxCollection,
|
|
27
27
|
private txPool: TxPoolV2,
|
|
28
|
-
private
|
|
28
|
+
private blockProposalTransactionValidator: Pick<P2PClient, 'validateTxsReceivedInBlockProposal'>,
|
|
29
29
|
private log: Logger = createLogger('p2p:tx-collector'),
|
|
30
30
|
client: TelemetryClient = getTelemetryClient(),
|
|
31
31
|
) {
|
|
@@ -227,7 +227,7 @@ export class TxProvider implements ITxProvider {
|
|
|
227
227
|
if (txs.length === 0) {
|
|
228
228
|
return;
|
|
229
229
|
}
|
|
230
|
-
await this.
|
|
230
|
+
await this.blockProposalTransactionValidator.validateTxsReceivedInBlockProposal(txs);
|
|
231
231
|
await this.txPool.addProtectedTxs(txs, blockHeader);
|
|
232
232
|
}
|
|
233
233
|
}
|