@aztec/p2p 0.0.1-commit.d6f2b3f94 → 0.0.1-commit.d939eb5aa
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 +37 -30
- package/dest/client/interface.d.ts +22 -20
- package/dest/client/interface.d.ts.map +1 -1
- package/dest/client/p2p_client.d.ts +11 -19
- package/dest/client/p2p_client.d.ts.map +1 -1
- package/dest/client/p2p_client.js +92 -104
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.js +20 -10
- package/dest/config.d.ts +128 -96
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +97 -38
- 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 +10 -6
- package/dest/mem_pools/attestation_pool/attestation_pool.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/attestation_pool.js +21 -9
- 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 +30 -13
- package/dest/mem_pools/tx_pool_v2/deleted_pool.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/deleted_pool.js +91 -20
- 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 +7 -3
- 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 +9 -7
- 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 +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 +28 -10
- package/dest/mem_pools/tx_pool_v2/interfaces.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/interfaces.js +5 -1
- package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts +56 -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 +113 -20
- 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 +50 -45
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts +12 -5
- 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 +17 -6
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts +14 -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 +319 -147
- package/dest/msg_validators/attestation_validator/attestation_validator.d.ts +5 -2
- package/dest/msg_validators/attestation_validator/attestation_validator.d.ts.map +1 -1
- package/dest/msg_validators/attestation_validator/attestation_validator.js +20 -11
- package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.d.ts +4 -2
- package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.d.ts.map +1 -1
- package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.js +2 -2
- package/dest/msg_validators/clock_tolerance.d.ts +12 -1
- package/dest/msg_validators/clock_tolerance.d.ts.map +1 -1
- package/dest/msg_validators/clock_tolerance.js +54 -3
- package/dest/msg_validators/proposal_validator/block_proposal_validator.d.ts +7 -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 +7 -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 +15 -8
- package/dest/msg_validators/proposal_validator/proposal_validator.d.ts.map +1 -1
- package/dest/msg_validators/proposal_validator/proposal_validator.js +67 -47
- 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/archive_cache.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/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 +112 -43
- 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/data_store.d.ts +1 -1
- package/dest/services/data_store.d.ts.map +1 -1
- package/dest/services/data_store.js +5 -5
- package/dest/services/dummy_service.d.ts +8 -5
- package/dest/services/dummy_service.d.ts.map +1 -1
- package/dest/services/dummy_service.js +10 -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 +30 -7
- package/dest/services/gossipsub/topic_score_params.d.ts.map +1 -1
- package/dest/services/gossipsub/topic_score_params.js +53 -14
- package/dest/services/libp2p/libp2p_service.d.ts +29 -36
- package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
- package/dest/services/libp2p/libp2p_service.js +224 -197
- 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 +39 -11
- package/dest/services/peer-manager/peer_scoring.d.ts +7 -2
- package/dest/services/peer-manager/peer_scoring.d.ts.map +1 -1
- package/dest/services/peer-manager/peer_scoring.js +32 -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/config.d.ts +3 -3
- package/dest/services/reqresp/config.d.ts.map +1 -1
- package/dest/services/reqresp/interface.d.ts +14 -9
- package/dest/services/reqresp/interface.d.ts.map +1 -1
- package/dest/services/reqresp/interface.js +10 -11
- package/dest/services/reqresp/metrics.d.ts +1 -1
- package/dest/services/reqresp/metrics.d.ts.map +1 -1
- package/dest/services/reqresp/metrics.js +0 -1
- package/dest/services/reqresp/protocols/index.d.ts +1 -2
- package/dest/services/reqresp/protocols/index.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/index.js +0 -1
- package/dest/services/reqresp/protocols/tx.d.ts +1 -1
- package/dest/services/reqresp/protocols/tx.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/tx.js +1 -3
- package/dest/services/reqresp/rate-limiter/rate_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/rate-limiter/rate_limits.d.ts +1 -1
- package/dest/services/reqresp/rate-limiter/rate_limits.d.ts.map +1 -1
- package/dest/services/reqresp/rate-limiter/rate_limits.js +0 -10
- package/dest/services/reqresp/reqresp.d.ts +4 -2
- package/dest/services/reqresp/reqresp.d.ts.map +1 -1
- package/dest/services/reqresp/reqresp.js +30 -12
- package/dest/services/service.d.ts +9 -4
- package/dest/services/service.d.ts.map +1 -1
- package/dest/services/tx_collection/config.d.ts +13 -1
- package/dest/services/tx_collection/config.d.ts.map +1 -1
- package/dest/services/tx_collection/config.js +30 -0
- 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 +38 -29
- package/dest/services/tx_collection/file_store_tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/file_store_tx_collection.js +126 -77
- package/dest/services/tx_collection/file_store_tx_source.d.ts +17 -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 +53 -10
- 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 +5 -3
- package/dest/services/tx_collection/slow_tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/slow_tx_collection.js +17 -12
- package/dest/services/tx_collection/tx_collection.d.ts +9 -9
- package/dest/services/tx_collection/tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/tx_collection.js +26 -10
- 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.d.ts +3 -2
- package/dest/services/tx_file_store/tx_file_store.d.ts.map +1 -1
- package/dest/services/tx_file_store/tx_file_store.js +9 -6
- package/dest/services/tx_provider.d.ts +3 -3
- package/dest/services/tx_provider.d.ts.map +1 -1
- package/dest/services/tx_provider.js +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 +14 -6
- package/dest/test-helpers/mock-pubsub.d.ts.map +1 -1
- package/dest/test-helpers/mock-pubsub.js +43 -12
- 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 +3 -4
- package/dest/test-helpers/testbench-utils.d.ts +8 -3
- package/dest/test-helpers/testbench-utils.d.ts.map +1 -1
- package/dest/test-helpers/testbench-utils.js +30 -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 +78 -26
- package/dest/testbench/worker_client_manager.d.ts +10 -1
- package/dest/testbench/worker_client_manager.d.ts.map +1 -1
- package/dest/testbench/worker_client_manager.js +55 -3
- package/dest/util.d.ts +3 -3
- package/dest/util.d.ts.map +1 -1
- package/package.json +14 -14
- package/src/client/factory.ts +68 -48
- package/src/client/interface.ts +26 -21
- package/src/client/p2p_client.ts +102 -135
- package/src/client/test/tx_proposal_collector/proposal_tx_collector_worker.ts +33 -14
- package/src/config.ts +146 -44
- 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 +25 -12
- 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 +52 -28
- package/src/mem_pools/tx_pool_v2/deleted_pool.ts +109 -22
- 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 +7 -3
- 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 +8 -8
- 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 +1 -1
- package/src/mem_pools/tx_pool_v2/instrumentation.ts +69 -0
- package/src/mem_pools/tx_pool_v2/interfaces.ts +30 -10
- package/src/mem_pools/tx_pool_v2/tx_metadata.ts +164 -28
- package/src/mem_pools/tx_pool_v2/tx_pool_indices.ts +58 -45
- package/src/mem_pools/tx_pool_v2/tx_pool_v2.ts +34 -8
- package/src/mem_pools/tx_pool_v2/tx_pool_v2_impl.ts +353 -143
- package/src/msg_validators/attestation_validator/README.md +49 -0
- package/src/msg_validators/attestation_validator/attestation_validator.ts +21 -9
- package/src/msg_validators/attestation_validator/fisherman_attestation_validator.ts +4 -1
- package/src/msg_validators/clock_tolerance.ts +72 -3
- package/src/msg_validators/proposal_validator/README.md +123 -0
- package/src/msg_validators/proposal_validator/block_proposal_validator.ts +17 -4
- package/src/msg_validators/proposal_validator/checkpoint_proposal_validator.ts +23 -7
- package/src/msg_validators/proposal_validator/proposal_validator.ts +79 -49
- 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/archive_cache.ts +1 -1
- 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 +145 -33
- 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/data_store.ts +5 -13
- package/src/services/dummy_service.ts +13 -7
- package/src/services/encoding.ts +16 -8
- package/src/services/gossipsub/README.md +29 -14
- package/src/services/gossipsub/topic_score_params.ts +85 -17
- package/src/services/libp2p/libp2p_service.ts +240 -225
- package/src/services/peer-manager/metrics.ts +7 -0
- package/src/services/peer-manager/peer_manager.ts +45 -11
- package/src/services/peer-manager/peer_scoring.ts +27 -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/config.ts +2 -2
- package/src/services/reqresp/interface.ts +21 -11
- package/src/services/reqresp/metrics.ts +0 -1
- package/src/services/reqresp/protocols/index.ts +0 -1
- package/src/services/reqresp/protocols/tx.ts +1 -3
- package/src/services/reqresp/rate-limiter/rate_limiter.ts +13 -9
- package/src/services/reqresp/rate-limiter/rate_limits.ts +0 -10
- package/src/services/reqresp/reqresp.ts +40 -13
- package/src/services/service.ts +17 -3
- package/src/services/tx_collection/config.ts +42 -0
- package/src/services/tx_collection/fast_tx_collection.ts +71 -76
- package/src/services/tx_collection/file_store_tx_collection.ts +143 -93
- package/src/services/tx_collection/file_store_tx_source.ts +69 -10
- 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 +17 -13
- package/src/services/tx_collection/tx_collection.ts +46 -17
- 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 +6 -4
- 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 +44 -11
- package/src/test-helpers/reqresp-nodes.ts +5 -8
- package/src/test-helpers/testbench-utils.ts +41 -6
- package/src/testbench/p2p_client_testbench_worker.ts +89 -29
- package/src/testbench/worker_client_manager.ts +68 -6
- package/src/util.ts +8 -2
- 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/dest/services/reqresp/protocols/block.d.ts +0 -9
- package/dest/services/reqresp/protocols/block.d.ts.map +0 -1
- package/dest/services/reqresp/protocols/block.js +0 -32
- package/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
- package/src/services/reqresp/protocols/block.ts +0 -37
|
@@ -1,26 +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,
|
|
26
|
+
private readonly basePath: string,
|
|
27
|
+
private readonly txValidator: TxValidator,
|
|
12
28
|
private readonly log: Logger,
|
|
13
|
-
|
|
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
|
+
}
|
|
14
37
|
|
|
15
38
|
/**
|
|
16
39
|
* Creates a FileStoreTxSource from a URL.
|
|
17
40
|
* @param url - The file store URL (s3://, gs://, file://, http://, https://).
|
|
41
|
+
* @param basePath - Base path for tx files within the store.
|
|
18
42
|
* @param log - Optional logger.
|
|
43
|
+
* @param telemetry - Optional telemetry client.
|
|
19
44
|
* @returns The FileStoreTxSource instance, or undefined if creation fails.
|
|
20
45
|
*/
|
|
21
46
|
public static async create(
|
|
22
47
|
url: string,
|
|
48
|
+
basePath: string,
|
|
49
|
+
txValidator: TxValidator,
|
|
23
50
|
log: Logger = createLogger('p2p:file_store_tx_source'),
|
|
51
|
+
telemetry: TelemetryClient = getTelemetryClient(),
|
|
24
52
|
): Promise<FileStoreTxSource | undefined> {
|
|
25
53
|
try {
|
|
26
54
|
const fileStore = await createReadOnlyFileStore(url, log);
|
|
@@ -28,7 +56,7 @@ export class FileStoreTxSource implements TxSource {
|
|
|
28
56
|
log.warn(`Failed to create file store for URL: ${url}`);
|
|
29
57
|
return undefined;
|
|
30
58
|
}
|
|
31
|
-
return new FileStoreTxSource(fileStore, url, log);
|
|
59
|
+
return new FileStoreTxSource(fileStore, url, basePath, txValidator, log, telemetry);
|
|
32
60
|
} catch (err) {
|
|
33
61
|
log.warn(`Error creating file store for URL: ${url}`, { error: err });
|
|
34
62
|
return undefined;
|
|
@@ -39,32 +67,63 @@ export class FileStoreTxSource implements TxSource {
|
|
|
39
67
|
return `file-store:${this.baseUrl}`;
|
|
40
68
|
}
|
|
41
69
|
|
|
42
|
-
public getTxsByHash(txHashes: TxHash[]): Promise<
|
|
43
|
-
|
|
70
|
+
public async getTxsByHash(txHashes: TxHash[]): Promise<TxSourceCollectionResult> {
|
|
71
|
+
const results = await Promise.all(
|
|
44
72
|
txHashes.map(async txHash => {
|
|
45
|
-
const path =
|
|
73
|
+
const path = `${this.basePath}/txs/${txHash.toString()}.bin`;
|
|
74
|
+
const timer = new Timer();
|
|
46
75
|
try {
|
|
47
76
|
const buffer = await this.fileStore.read(path);
|
|
48
|
-
|
|
77
|
+
const tx = Tx.fromBuffer(buffer);
|
|
78
|
+
return { tx, downloadDuration: timer.ms(), downloadSize: buffer.length };
|
|
49
79
|
} catch {
|
|
50
|
-
|
|
80
|
+
this.downloadsFailed.add(1);
|
|
51
81
|
return undefined;
|
|
52
82
|
}
|
|
53
83
|
}),
|
|
54
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
|
+
};
|
|
55
107
|
}
|
|
56
108
|
}
|
|
57
109
|
|
|
58
110
|
/**
|
|
59
111
|
* Creates FileStoreTxSource instances from URLs.
|
|
60
112
|
* @param urls - Array of file store URLs.
|
|
113
|
+
* @param basePath - Base path for tx files within each store.
|
|
61
114
|
* @param log - Optional logger.
|
|
115
|
+
* @param telemetry - Optional telemetry client.
|
|
62
116
|
* @returns Array of successfully created FileStoreTxSource instances.
|
|
63
117
|
*/
|
|
64
118
|
export async function createFileStoreTxSources(
|
|
65
119
|
urls: string[],
|
|
120
|
+
basePath: string,
|
|
121
|
+
txValidator: TxValidator,
|
|
66
122
|
log: Logger = createLogger('p2p:file_store_tx_source'),
|
|
123
|
+
telemetry: TelemetryClient = getTelemetryClient(),
|
|
67
124
|
): Promise<FileStoreTxSource[]> {
|
|
68
|
-
const sources = await Promise.all(
|
|
125
|
+
const sources = await Promise.all(
|
|
126
|
+
urls.map(url => FileStoreTxSource.create(url, basePath, txValidator, log, telemetry)),
|
|
127
|
+
);
|
|
69
128
|
return sources.filter((s): s is FileStoreTxSource => s !== undefined);
|
|
70
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
|
|
@@ -254,9 +253,14 @@ export class SlowTxCollection {
|
|
|
254
253
|
|
|
255
254
|
/** Computes the proof submission deadline for a given slot, a tx mined in this slot is no longer interesting after this deadline */
|
|
256
255
|
private getDeadlineForSlot(slotNumber: SlotNumber): Date {
|
|
257
|
-
|
|
258
|
-
const submissionEndEpoch = EpochNumber(epoch + this.constants.proofSubmissionEpochs);
|
|
259
|
-
const submissionEndTimestamp = getTimestampRangeForEpoch(submissionEndEpoch, this.constants)[1];
|
|
260
|
-
return new Date(Number(submissionEndTimestamp) * 1000);
|
|
256
|
+
return getProofDeadlineForSlot(slotNumber, this.constants);
|
|
261
257
|
}
|
|
262
258
|
}
|
|
259
|
+
|
|
260
|
+
/** Computes the proof submission deadline for a given slot. A tx mined in this slot is no longer interesting after this deadline. */
|
|
261
|
+
export function getProofDeadlineForSlot(slotNumber: SlotNumber, constants: L1RollupConstants): Date {
|
|
262
|
+
const epoch = getEpochAtSlot(slotNumber, constants);
|
|
263
|
+
const submissionEndEpoch = EpochNumber(epoch + constants.proofSubmissionEpochs);
|
|
264
|
+
const submissionEndTimestamp = getTimestampRangeForEpoch(submissionEndEpoch, constants)[1];
|
|
265
|
+
return new Date(Number(submissionEndTimestamp) * 1000);
|
|
266
|
+
}
|
|
@@ -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,7 +19,8 @@ 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';
|
|
21
|
-
import {
|
|
22
|
+
import type { IRequestTracker } from './request_tracker.js';
|
|
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';
|
|
24
26
|
|
|
@@ -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
|
/**
|
|
@@ -56,8 +55,11 @@ export class TxCollection {
|
|
|
56
55
|
/** Fast collection methods */
|
|
57
56
|
protected readonly fastCollection: FastTxCollection;
|
|
58
57
|
|
|
59
|
-
/** File store collection */
|
|
60
|
-
protected readonly
|
|
58
|
+
/** File store collection for slow (mined block) path */
|
|
59
|
+
protected readonly fileStoreSlowCollection: FileStoreTxCollection;
|
|
60
|
+
|
|
61
|
+
/** File store collection for fast (proposal/proving) path */
|
|
62
|
+
protected readonly fileStoreFastCollection: FileStoreTxCollection;
|
|
61
63
|
|
|
62
64
|
/** Loop for periodically reconciling found transactions from the tx pool in case we missed some */
|
|
63
65
|
private readonly reconcileFoundTxsLoop: RunningPromise;
|
|
@@ -111,7 +113,28 @@ export class TxCollection {
|
|
|
111
113
|
);
|
|
112
114
|
|
|
113
115
|
this.hasFileStoreSources = fileStoreSources.length > 0;
|
|
114
|
-
this.
|
|
116
|
+
this.fileStoreSlowCollection = new FileStoreTxCollection(
|
|
117
|
+
fileStoreSources,
|
|
118
|
+
this.txCollectionSink,
|
|
119
|
+
{
|
|
120
|
+
workerCount: config.txCollectionFileStoreSlowWorkerCount,
|
|
121
|
+
backoffBaseMs: config.txCollectionFileStoreSlowBackoffBaseMs,
|
|
122
|
+
backoffMaxMs: config.txCollectionFileStoreSlowBackoffMaxMs,
|
|
123
|
+
},
|
|
124
|
+
this.dateProvider,
|
|
125
|
+
this.log,
|
|
126
|
+
);
|
|
127
|
+
this.fileStoreFastCollection = new FileStoreTxCollection(
|
|
128
|
+
fileStoreSources,
|
|
129
|
+
this.txCollectionSink,
|
|
130
|
+
{
|
|
131
|
+
workerCount: config.txCollectionFileStoreFastWorkerCount,
|
|
132
|
+
backoffBaseMs: config.txCollectionFileStoreFastBackoffBaseMs,
|
|
133
|
+
backoffMaxMs: config.txCollectionFileStoreFastBackoffMaxMs,
|
|
134
|
+
},
|
|
135
|
+
this.dateProvider,
|
|
136
|
+
this.log,
|
|
137
|
+
);
|
|
115
138
|
|
|
116
139
|
this.reconcileFoundTxsLoop = new RunningPromise(
|
|
117
140
|
() => this.reconcileFoundTxsWithPool(),
|
|
@@ -137,7 +160,8 @@ export class TxCollection {
|
|
|
137
160
|
public start(): Promise<void> {
|
|
138
161
|
this.started = true;
|
|
139
162
|
this.slowCollection.start();
|
|
140
|
-
this.
|
|
163
|
+
this.fileStoreSlowCollection.start();
|
|
164
|
+
this.fileStoreFastCollection.start();
|
|
141
165
|
this.reconcileFoundTxsLoop.start();
|
|
142
166
|
|
|
143
167
|
// TODO(palla/txs): Collect mined unproven tx hashes for txs we dont have in the pool and populate missingTxs on startup
|
|
@@ -150,7 +174,8 @@ export class TxCollection {
|
|
|
150
174
|
await Promise.all([
|
|
151
175
|
this.slowCollection.stop(),
|
|
152
176
|
this.fastCollection.stop(),
|
|
153
|
-
this.
|
|
177
|
+
this.fileStoreSlowCollection.stop(),
|
|
178
|
+
this.fileStoreFastCollection.stop(),
|
|
154
179
|
this.reconcileFoundTxsLoop.stop(),
|
|
155
180
|
]);
|
|
156
181
|
|
|
@@ -175,6 +200,7 @@ export class TxCollection {
|
|
|
175
200
|
// Delay file store collection to give P2P methods time to find txs first
|
|
176
201
|
if (this.hasFileStoreSources) {
|
|
177
202
|
const context: TxAddContext = { type: 'mined', block };
|
|
203
|
+
const deadline = getProofDeadlineForSlot(block.header.getSlot(), this.constants);
|
|
178
204
|
sleep(this.config.txCollectionFileStoreSlowDelayMs)
|
|
179
205
|
.then(() => {
|
|
180
206
|
if (this.started) {
|
|
@@ -182,7 +208,7 @@ export class TxCollection {
|
|
|
182
208
|
const stillMissing = new Set(this.slowCollection.getMissingTxHashes().map(h => h.toString()));
|
|
183
209
|
const remaining = txHashes.filter(h => stillMissing.has(h.toString()));
|
|
184
210
|
if (remaining.length > 0) {
|
|
185
|
-
this.
|
|
211
|
+
this.fileStoreSlowCollection.startCollecting(remaining, context, deadline);
|
|
186
212
|
}
|
|
187
213
|
}
|
|
188
214
|
})
|
|
@@ -223,7 +249,7 @@ export class TxCollection {
|
|
|
223
249
|
sleep(this.config.txCollectionFileStoreFastDelayMs)
|
|
224
250
|
.then(() => {
|
|
225
251
|
if (this.started) {
|
|
226
|
-
this.
|
|
252
|
+
this.fileStoreFastCollection.startCollecting(hashes, context, opts.deadline);
|
|
227
253
|
}
|
|
228
254
|
})
|
|
229
255
|
.catch(err => this.log.error('Error in file store fast delay', err));
|
|
@@ -245,7 +271,8 @@ export class TxCollection {
|
|
|
245
271
|
private foundTxs(txs: Tx[]) {
|
|
246
272
|
this.slowCollection.foundTxs(txs);
|
|
247
273
|
this.fastCollection.foundTxs(txs);
|
|
248
|
-
this.
|
|
274
|
+
this.fileStoreSlowCollection.foundTxs(txs);
|
|
275
|
+
this.fileStoreFastCollection.foundTxs(txs);
|
|
249
276
|
}
|
|
250
277
|
|
|
251
278
|
/**
|
|
@@ -255,7 +282,8 @@ export class TxCollection {
|
|
|
255
282
|
public stopCollectingForBlocksUpTo(blockNumber: BlockNumber): void {
|
|
256
283
|
this.slowCollection.stopCollectingForBlocksUpTo(blockNumber);
|
|
257
284
|
this.fastCollection.stopCollectingForBlocksUpTo(blockNumber);
|
|
258
|
-
this.
|
|
285
|
+
this.fileStoreSlowCollection.clearPending();
|
|
286
|
+
this.fileStoreFastCollection.clearPending();
|
|
259
287
|
}
|
|
260
288
|
|
|
261
289
|
/**
|
|
@@ -265,7 +293,8 @@ export class TxCollection {
|
|
|
265
293
|
public stopCollectingForBlocksAfter(blockNumber: BlockNumber): void {
|
|
266
294
|
this.slowCollection.stopCollectingForBlocksAfter(blockNumber);
|
|
267
295
|
this.fastCollection.stopCollectingForBlocksAfter(blockNumber);
|
|
268
|
-
this.
|
|
296
|
+
this.fileStoreSlowCollection.clearPending();
|
|
297
|
+
this.fileStoreFastCollection.clearPending();
|
|
269
298
|
}
|
|
270
299
|
|
|
271
300
|
/** Every now and then, check if the pool has received one of the txs we are looking for, just to catch any race conditions */
|