@aztec/p2p 0.0.1-commit.e558bd1c → 0.0.1-commit.e5a3663dd
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 +10 -9
- package/dest/client/factory.d.ts.map +1 -1
- package/dest/client/factory.js +54 -15
- package/dest/client/interface.d.ts +47 -34
- package/dest/client/interface.d.ts.map +1 -1
- package/dest/client/p2p_client.d.ts +39 -51
- package/dest/client/p2p_client.d.ts.map +1 -1
- package/dest/client/p2p_client.js +173 -226
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.js +23 -10
- package/dest/config.d.ts +137 -92
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +113 -40
- 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 +2 -2
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +1 -1
- package/dest/mem_pools/attestation_pool/attestation_pool.d.ts +24 -13
- package/dest/mem_pools/attestation_pool/attestation_pool.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/attestation_pool.js +80 -43
- package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.d.ts +1 -1
- package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.js +57 -57
- package/dest/mem_pools/attestation_pool/index.d.ts +2 -2
- package/dest/mem_pools/attestation_pool/index.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/index.js +1 -1
- package/dest/mem_pools/attestation_pool/mocks.d.ts +2 -2
- package/dest/mem_pools/attestation_pool/mocks.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/mocks.js +7 -5
- package/dest/mem_pools/index.d.ts +2 -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 +33 -15
- package/dest/mem_pools/interface.d.ts +3 -3
- package/dest/mem_pools/interface.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/deleted_pool.d.ts +104 -0
- package/dest/mem_pools/tx_pool_v2/deleted_pool.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/deleted_pool.js +251 -0
- package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.d.ts +3 -3
- package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.js +18 -9
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.d.ts +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.js +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 +3 -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 +2 -1
- package/dest/mem_pools/tx_pool_v2/eviction/insufficient_fee_per_gas_eviction_rule.d.ts +16 -0
- package/dest/mem_pools/tx_pool_v2/eviction/insufficient_fee_per_gas_eviction_rule.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/eviction/insufficient_fee_per_gas_eviction_rule.js +62 -0
- 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 +3 -2
- package/dest/mem_pools/tx_pool_v2/index.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/index.js +2 -1
- package/dest/mem_pools/tx_pool_v2/instrumentation.d.ts +15 -0
- package/dest/mem_pools/tx_pool_v2/instrumentation.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/instrumentation.js +43 -0
- package/dest/mem_pools/tx_pool_v2/interfaces.d.ts +33 -12
- 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 +81 -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 +147 -19
- 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 +365 -189
- package/dest/msg_validators/attestation_validator/attestation_validator.d.ts +9 -3
- package/dest/msg_validators/attestation_validator/attestation_validator.d.ts.map +1 -1
- package/dest/msg_validators/attestation_validator/attestation_validator.js +37 -12
- package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.d.ts +7 -3
- 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 +61 -3
- package/dest/msg_validators/proposal_validator/block_proposal_validator.d.ts +9 -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 +9 -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 +19 -8
- package/dest/msg_validators/proposal_validator/proposal_validator.d.ts.map +1 -1
- package/dest/msg_validators/proposal_validator/proposal_validator.js +88 -44
- package/dest/msg_validators/tx_validator/aggregate_tx_validator.d.ts +4 -4
- package/dest/msg_validators/tx_validator/aggregate_tx_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/aggregate_tx_validator.js +3 -3
- package/dest/msg_validators/tx_validator/allowed_public_setup.d.ts +2 -1
- package/dest/msg_validators/tx_validator/allowed_public_setup.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/allowed_public_setup.js +24 -20
- package/dest/msg_validators/tx_validator/allowed_setup_helpers.d.ts +17 -0
- package/dest/msg_validators/tx_validator/allowed_setup_helpers.d.ts.map +1 -0
- package/dest/msg_validators/tx_validator/allowed_setup_helpers.js +24 -0
- package/dest/msg_validators/tx_validator/archive_cache.js +1 -1
- package/dest/msg_validators/tx_validator/block_header_validator.d.ts +16 -3
- package/dest/msg_validators/tx_validator/block_header_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/block_header_validator.js +1 -1
- package/dest/msg_validators/tx_validator/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/double_spend_validator.d.ts +13 -3
- package/dest/msg_validators/tx_validator/double_spend_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/double_spend_validator.js +4 -4
- package/dest/msg_validators/tx_validator/factory.d.ts +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 +99 -3
- package/dest/msg_validators/tx_validator/gas_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/gas_validator.js +137 -53
- 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 +20 -4
- package/dest/msg_validators/tx_validator/timestamp_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/timestamp_validator.js +6 -6
- package/dest/services/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 +13 -6
- package/dest/services/dummy_service.d.ts.map +1 -1
- package/dest/services/dummy_service.js +13 -5
- package/dest/services/encoding.d.ts +7 -3
- package/dest/services/encoding.d.ts.map +1 -1
- package/dest/services/encoding.js +18 -11
- package/dest/services/gossipsub/index.d.ts +3 -0
- package/dest/services/gossipsub/index.d.ts.map +1 -0
- package/dest/services/gossipsub/index.js +2 -0
- package/dest/services/gossipsub/scoring.d.ts +21 -3
- package/dest/services/gossipsub/scoring.d.ts.map +1 -1
- package/dest/services/gossipsub/scoring.js +24 -7
- package/dest/services/gossipsub/topic_score_params.d.ts +184 -0
- package/dest/services/gossipsub/topic_score_params.d.ts.map +1 -0
- package/dest/services/gossipsub/topic_score_params.js +363 -0
- package/dest/services/libp2p/instrumentation.d.ts +3 -1
- package/dest/services/libp2p/instrumentation.d.ts.map +1 -1
- package/dest/services/libp2p/instrumentation.js +14 -0
- package/dest/services/libp2p/libp2p_service.d.ts +42 -39
- package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
- package/dest/services/libp2p/libp2p_service.js +336 -269
- 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 +57 -12
- 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 +23 -9
- package/dest/services/reqresp/interface.d.ts.map +1 -1
- package/dest/services/reqresp/interface.js +23 -10
- 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/block_txs/block_txs_handler.d.ts +3 -3
- package/dest/services/reqresp/protocols/block_txs/block_txs_handler.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.d.ts +7 -1
- package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.js +15 -0
- package/dest/services/reqresp/protocols/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 +7 -1
- package/dest/services/reqresp/protocols/tx.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/tx.js +21 -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 +40 -15
- package/dest/services/service.d.ts +26 -4
- package/dest/services/service.d.ts.map +1 -1
- package/dest/services/tx_collection/config.d.ts +19 -1
- package/dest/services/tx_collection/config.d.ts.map +1 -1
- package/dest/services/tx_collection/config.js +46 -0
- package/dest/services/tx_collection/fast_tx_collection.d.ts +3 -4
- package/dest/services/tx_collection/fast_tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/fast_tx_collection.js +80 -76
- package/dest/services/tx_collection/file_store_tx_collection.d.ts +53 -0
- package/dest/services/tx_collection/file_store_tx_collection.d.ts.map +1 -0
- package/dest/services/tx_collection/file_store_tx_collection.js +167 -0
- package/dest/services/tx_collection/file_store_tx_source.d.ts +38 -0
- package/dest/services/tx_collection/file_store_tx_source.d.ts.map +1 -0
- package/dest/services/tx_collection/file_store_tx_source.js +100 -0
- package/dest/services/tx_collection/index.d.ts +2 -1
- package/dest/services/tx_collection/index.d.ts.map +1 -1
- package/dest/services/tx_collection/index.js +1 -0
- package/dest/services/tx_collection/instrumentation.d.ts +1 -1
- package/dest/services/tx_collection/instrumentation.d.ts.map +1 -1
- package/dest/services/tx_collection/instrumentation.js +2 -1
- package/dest/services/tx_collection/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 +7 -3
- package/dest/services/tx_collection/slow_tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/slow_tx_collection.js +60 -26
- package/dest/services/tx_collection/tx_collection.d.ts +23 -13
- package/dest/services/tx_collection/tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/tx_collection.js +75 -3
- package/dest/services/tx_collection/tx_collection_sink.d.ts +18 -8
- package/dest/services/tx_collection/tx_collection_sink.d.ts.map +1 -1
- package/dest/services/tx_collection/tx_collection_sink.js +26 -29
- package/dest/services/tx_collection/tx_source.d.ts +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/config.d.ts +1 -3
- package/dest/services/tx_file_store/config.d.ts.map +1 -1
- package/dest/services/tx_file_store/config.js +0 -4
- package/dest/services/tx_file_store/tx_file_store.d.ts +4 -3
- package/dest/services/tx_file_store/tx_file_store.d.ts.map +1 -1
- package/dest/services/tx_file_store/tx_file_store.js +9 -6
- package/dest/services/tx_provider.d.ts +4 -4
- package/dest/services/tx_provider.d.ts.map +1 -1
- package/dest/services/tx_provider.js +9 -8
- package/dest/test-helpers/make-test-p2p-clients.d.ts +7 -8
- package/dest/test-helpers/make-test-p2p-clients.d.ts.map +1 -1
- package/dest/test-helpers/make-test-p2p-clients.js +4 -2
- package/dest/test-helpers/mock-pubsub.d.ts +40 -6
- package/dest/test-helpers/mock-pubsub.d.ts.map +1 -1
- package/dest/test-helpers/mock-pubsub.js +139 -13
- 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 +8 -5
- package/dest/test-helpers/testbench-utils.d.ts +35 -24
- package/dest/test-helpers/testbench-utils.d.ts.map +1 -1
- package/dest/test-helpers/testbench-utils.js +125 -38
- 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 +84 -27
- 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 +108 -26
- package/src/client/interface.ts +52 -34
- package/src/client/p2p_client.ts +201 -269
- package/src/client/test/tx_proposal_collector/proposal_tx_collector_worker.ts +35 -14
- package/src/config.ts +181 -46
- package/src/errors/p2p-service.error.ts +11 -0
- package/src/errors/tx-pool.error.ts +12 -0
- package/src/index.ts +1 -1
- package/src/mem_pools/attestation_pool/attestation_pool.ts +109 -53
- package/src/mem_pools/attestation_pool/attestation_pool_test_suite.ts +61 -57
- package/src/mem_pools/attestation_pool/index.ts +3 -3
- package/src/mem_pools/attestation_pool/mocks.ts +14 -8
- package/src/mem_pools/index.ts +1 -1
- package/src/mem_pools/instrumentation.ts +22 -14
- package/src/mem_pools/interface.ts +2 -2
- package/src/mem_pools/tx_pool_v2/README.md +85 -11
- package/src/mem_pools/tx_pool_v2/deleted_pool.ts +321 -0
- package/src/mem_pools/tx_pool_v2/eviction/eviction_manager.ts +21 -8
- package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.ts +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 +5 -0
- package/src/mem_pools/tx_pool_v2/eviction/insufficient_fee_per_gas_eviction_rule.ts +65 -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 +2 -1
- package/src/mem_pools/tx_pool_v2/instrumentation.ts +69 -0
- package/src/mem_pools/tx_pool_v2/interfaces.ts +35 -12
- package/src/mem_pools/tx_pool_v2/tx_metadata.ts +215 -27
- 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 +412 -187
- package/src/msg_validators/attestation_validator/README.md +49 -0
- package/src/msg_validators/attestation_validator/attestation_validator.ts +41 -9
- package/src/msg_validators/attestation_validator/fisherman_attestation_validator.ts +12 -2
- package/src/msg_validators/clock_tolerance.ts +79 -3
- package/src/msg_validators/proposal_validator/README.md +123 -0
- package/src/msg_validators/proposal_validator/block_proposal_validator.ts +23 -4
- package/src/msg_validators/proposal_validator/checkpoint_proposal_validator.ts +34 -7
- package/src/msg_validators/proposal_validator/proposal_validator.ts +111 -47
- package/src/msg_validators/tx_validator/README.md +127 -0
- package/src/msg_validators/tx_validator/aggregate_tx_validator.ts +5 -5
- package/src/msg_validators/tx_validator/allowed_public_setup.ts +22 -27
- package/src/msg_validators/tx_validator/allowed_setup_helpers.ts +31 -0
- package/src/msg_validators/tx_validator/archive_cache.ts +1 -1
- package/src/msg_validators/tx_validator/block_header_validator.ts +15 -3
- package/src/msg_validators/tx_validator/contract_instance_validator.ts +56 -0
- package/src/msg_validators/tx_validator/data_validator.ts +42 -1
- package/src/msg_validators/tx_validator/double_spend_validator.ts +11 -6
- package/src/msg_validators/tx_validator/factory.ts +396 -78
- package/src/msg_validators/tx_validator/fee_payer_balance.ts +6 -2
- package/src/msg_validators/tx_validator/gas_validator.ts +199 -54
- 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 +23 -18
- package/src/services/data_store.ts +5 -13
- package/src/services/dummy_service.ts +19 -7
- package/src/services/encoding.ts +18 -10
- package/src/services/gossipsub/README.md +641 -0
- package/src/services/gossipsub/index.ts +2 -0
- package/src/services/gossipsub/scoring.ts +29 -5
- package/src/services/gossipsub/topic_score_params.ts +519 -0
- package/src/services/libp2p/instrumentation.ts +14 -0
- package/src/services/libp2p/libp2p_service.ts +358 -298
- 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 +52 -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 +45 -10
- package/src/services/reqresp/metrics.ts +0 -1
- package/src/services/reqresp/protocols/block_txs/block_txs_handler.ts +2 -2
- package/src/services/reqresp/protocols/block_txs/block_txs_reqresp.ts +17 -0
- package/src/services/reqresp/protocols/index.ts +0 -1
- package/src/services/reqresp/protocols/tx.ts +23 -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 +53 -16
- package/src/services/service.ts +37 -3
- package/src/services/tx_collection/config.ts +68 -0
- package/src/services/tx_collection/fast_tx_collection.ts +83 -76
- package/src/services/tx_collection/file_store_tx_collection.ts +202 -0
- package/src/services/tx_collection/file_store_tx_source.ts +129 -0
- package/src/services/tx_collection/index.ts +1 -0
- 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 +66 -33
- package/src/services/tx_collection/tx_collection.ts +114 -19
- package/src/services/tx_collection/tx_collection_sink.ts +30 -34
- package/src/services/tx_collection/tx_source.ts +28 -8
- package/src/services/tx_file_store/config.ts +0 -6
- package/src/services/tx_file_store/tx_file_store.ts +10 -8
- package/src/services/tx_provider.ts +10 -9
- package/src/test-helpers/make-test-p2p-clients.ts +6 -6
- package/src/test-helpers/mock-pubsub.ts +180 -14
- package/src/test-helpers/reqresp-nodes.ts +9 -9
- package/src/test-helpers/testbench-utils.ts +147 -43
- package/src/testbench/p2p_client_testbench_worker.ts +93 -30
- 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
package/src/services/service.ts
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import type { SlotNumber } from '@aztec/foundation/branded-types';
|
|
2
2
|
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
3
3
|
import type { PeerInfo } from '@aztec/stdlib/interfaces/server';
|
|
4
|
-
import type {
|
|
4
|
+
import type {
|
|
5
|
+
BlockProposal,
|
|
6
|
+
CheckpointAttestation,
|
|
7
|
+
CheckpointProposalCore,
|
|
8
|
+
Gossipable,
|
|
9
|
+
TopicType,
|
|
10
|
+
} from '@aztec/stdlib/p2p';
|
|
5
11
|
import type { Tx } from '@aztec/stdlib/tx';
|
|
6
12
|
|
|
7
13
|
import type { PeerId } from '@libp2p/interface';
|
|
@@ -57,6 +63,19 @@ export type DuplicateProposalInfo = {
|
|
|
57
63
|
*/
|
|
58
64
|
export type P2PDuplicateProposalCallback = (info: DuplicateProposalInfo) => void;
|
|
59
65
|
|
|
66
|
+
/** Minimal info passed to the duplicate attestation callback. */
|
|
67
|
+
export type DuplicateAttestationInfo = {
|
|
68
|
+
slot: SlotNumber;
|
|
69
|
+
attester: EthAddress;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Callback for when a duplicate attestation is detected (equivocation).
|
|
74
|
+
* A validator signing attestations for different proposals at the same slot.
|
|
75
|
+
* Invoked on the first duplicate (when count goes from 1 to 2).
|
|
76
|
+
*/
|
|
77
|
+
export type P2PDuplicateAttestationCallback = (info: DuplicateAttestationInfo) => void;
|
|
78
|
+
|
|
60
79
|
/**
|
|
61
80
|
* The interface for a P2P service implementation.
|
|
62
81
|
*/
|
|
@@ -98,7 +117,12 @@ export interface P2PService {
|
|
|
98
117
|
// Leaky abstraction: fix https://github.com/AztecProtocol/aztec-packages/issues/7963
|
|
99
118
|
registerBlockReceivedCallback(callback: P2PBlockReceivedCallback): void;
|
|
100
119
|
|
|
101
|
-
|
|
120
|
+
registerValidatorCheckpointReceivedCallback(callback: P2PCheckpointReceivedCallback): void;
|
|
121
|
+
|
|
122
|
+
registerAllNodesCheckpointReceivedCallback(callback: P2PCheckpointReceivedCallback): void;
|
|
123
|
+
|
|
124
|
+
/** Fires the all-nodes checkpoint callback for our own proposal (gossipsub doesn't deliver own messages). */
|
|
125
|
+
notifyOwnCheckpointProposal(checkpoint: CheckpointProposalCore): Promise<void>;
|
|
102
126
|
|
|
103
127
|
/**
|
|
104
128
|
* Registers a callback invoked when a duplicate proposal is detected (equivocation).
|
|
@@ -106,11 +130,21 @@ export interface P2PService {
|
|
|
106
130
|
*/
|
|
107
131
|
registerDuplicateProposalCallback(callback: P2PDuplicateProposalCallback): void;
|
|
108
132
|
|
|
133
|
+
/**
|
|
134
|
+
* Registers a callback invoked when a duplicate attestation is detected (equivocation).
|
|
135
|
+
* A validator signing attestations for different proposals at the same slot.
|
|
136
|
+
* The callback is triggered on the first duplicate (when count goes from 1 to 2).
|
|
137
|
+
*/
|
|
138
|
+
registerDuplicateAttestationCallback(callback: P2PDuplicateAttestationCallback): void;
|
|
139
|
+
|
|
109
140
|
getEnr(): ENR | undefined;
|
|
110
141
|
|
|
111
142
|
getPeers(includePending?: boolean): PeerInfo[];
|
|
112
143
|
|
|
113
|
-
|
|
144
|
+
/** Returns the number of peers in the GossipSub mesh for a given topic type. */
|
|
145
|
+
getGossipMeshPeerCount(topicType: TopicType): number;
|
|
146
|
+
|
|
147
|
+
validateTxsReceivedInBlockProposal(txs: Tx[]): Promise<void>;
|
|
114
148
|
|
|
115
149
|
addReqRespSubProtocol(
|
|
116
150
|
subProtocol: ReqRespSubProtocol,
|
|
@@ -31,6 +31,24 @@ export type TxCollectionConfig = {
|
|
|
31
31
|
txCollectionNodeRpcMaxBatchSize: number;
|
|
32
32
|
/** Which collector implementation to use for missing txs collection */
|
|
33
33
|
txCollectionMissingTxsCollectorType: MissingTxsCollectorType;
|
|
34
|
+
/** A comma-separated list of file store URLs (s3://, gs://, file://, http://) for tx collection */
|
|
35
|
+
txCollectionFileStoreUrls: string[];
|
|
36
|
+
/** Delay in ms before file store collection starts after slow collection is triggered */
|
|
37
|
+
txCollectionFileStoreSlowDelayMs: number;
|
|
38
|
+
/** Delay in ms before file store collection starts after fast collection is triggered */
|
|
39
|
+
txCollectionFileStoreFastDelayMs: number;
|
|
40
|
+
/** Number of concurrent workers for fast file store collection */
|
|
41
|
+
txCollectionFileStoreFastWorkerCount: number;
|
|
42
|
+
/** Number of concurrent workers for slow file store collection */
|
|
43
|
+
txCollectionFileStoreSlowWorkerCount: number;
|
|
44
|
+
/** Base backoff time in ms for fast file store collection retries */
|
|
45
|
+
txCollectionFileStoreFastBackoffBaseMs: number;
|
|
46
|
+
/** Base backoff time in ms for slow file store collection retries */
|
|
47
|
+
txCollectionFileStoreSlowBackoffBaseMs: number;
|
|
48
|
+
/** Max backoff time in ms for fast file store collection retries */
|
|
49
|
+
txCollectionFileStoreFastBackoffMaxMs: number;
|
|
50
|
+
/** Max backoff time in ms for slow file store collection retries */
|
|
51
|
+
txCollectionFileStoreSlowBackoffMaxMs: number;
|
|
34
52
|
};
|
|
35
53
|
|
|
36
54
|
export const txCollectionConfigMappings: ConfigMappingsType<TxCollectionConfig> = {
|
|
@@ -95,4 +113,54 @@ export const txCollectionConfigMappings: ConfigMappingsType<TxCollectionConfig>
|
|
|
95
113
|
description: 'Which collector implementation to use for missing txs collection (new or old)',
|
|
96
114
|
...enumConfigHelper(['new', 'old'] as const, 'new'),
|
|
97
115
|
},
|
|
116
|
+
txCollectionFileStoreUrls: {
|
|
117
|
+
env: 'TX_COLLECTION_FILE_STORE_URLS',
|
|
118
|
+
description: 'A comma-separated list of file store URLs (s3://, gs://, file://, http://) for tx collection',
|
|
119
|
+
parseEnv: (val: string) =>
|
|
120
|
+
val
|
|
121
|
+
.split(',')
|
|
122
|
+
.map(url => url.trim())
|
|
123
|
+
.filter(url => url.length > 0),
|
|
124
|
+
defaultValue: [],
|
|
125
|
+
},
|
|
126
|
+
txCollectionFileStoreSlowDelayMs: {
|
|
127
|
+
env: 'TX_COLLECTION_FILE_STORE_SLOW_DELAY_MS',
|
|
128
|
+
description: 'Delay before file store collection starts after slow collection',
|
|
129
|
+
...numberConfigHelper(24_000),
|
|
130
|
+
},
|
|
131
|
+
txCollectionFileStoreFastDelayMs: {
|
|
132
|
+
env: 'TX_COLLECTION_FILE_STORE_FAST_DELAY_MS',
|
|
133
|
+
description: 'Delay before file store collection starts after fast collection',
|
|
134
|
+
...numberConfigHelper(2_000),
|
|
135
|
+
},
|
|
136
|
+
txCollectionFileStoreFastWorkerCount: {
|
|
137
|
+
env: 'TX_COLLECTION_FILE_STORE_FAST_WORKER_COUNT',
|
|
138
|
+
description: 'Number of concurrent workers for fast file store collection',
|
|
139
|
+
...numberConfigHelper(5),
|
|
140
|
+
},
|
|
141
|
+
txCollectionFileStoreSlowWorkerCount: {
|
|
142
|
+
env: 'TX_COLLECTION_FILE_STORE_SLOW_WORKER_COUNT',
|
|
143
|
+
description: 'Number of concurrent workers for slow file store collection',
|
|
144
|
+
...numberConfigHelper(2),
|
|
145
|
+
},
|
|
146
|
+
txCollectionFileStoreFastBackoffBaseMs: {
|
|
147
|
+
env: 'TX_COLLECTION_FILE_STORE_FAST_BACKOFF_BASE_MS',
|
|
148
|
+
description: 'Base backoff time in ms for fast file store collection retries',
|
|
149
|
+
...numberConfigHelper(1_000),
|
|
150
|
+
},
|
|
151
|
+
txCollectionFileStoreSlowBackoffBaseMs: {
|
|
152
|
+
env: 'TX_COLLECTION_FILE_STORE_SLOW_BACKOFF_BASE_MS',
|
|
153
|
+
description: 'Base backoff time in ms for slow file store collection retries',
|
|
154
|
+
...numberConfigHelper(5_000),
|
|
155
|
+
},
|
|
156
|
+
txCollectionFileStoreFastBackoffMaxMs: {
|
|
157
|
+
env: 'TX_COLLECTION_FILE_STORE_FAST_BACKOFF_MAX_MS',
|
|
158
|
+
description: 'Max backoff time in ms for fast file store collection retries',
|
|
159
|
+
...numberConfigHelper(5_000),
|
|
160
|
+
},
|
|
161
|
+
txCollectionFileStoreSlowBackoffMaxMs: {
|
|
162
|
+
env: 'TX_COLLECTION_FILE_STORE_SLOW_BACKOFF_MAX_MS',
|
|
163
|
+
description: 'Max backoff time in ms for slow file store collection retries',
|
|
164
|
+
...numberConfigHelper(30_000),
|
|
165
|
+
},
|
|
98
166
|
};
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
2
2
|
import { times } from '@aztec/foundation/collection';
|
|
3
|
-
import { AbortError, TimeoutError } from '@aztec/foundation/error';
|
|
4
3
|
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
5
|
-
import { promiseWithResolvers } from '@aztec/foundation/promise';
|
|
6
4
|
import { sleep } from '@aztec/foundation/sleep';
|
|
7
5
|
import { DateProvider, elapsed } from '@aztec/foundation/timer';
|
|
8
6
|
import type { L2BlockInfo } from '@aztec/stdlib/block';
|
|
9
|
-
import type { BlockProposal } from '@aztec/stdlib/p2p';
|
|
10
7
|
import { type Tx, TxHash } from '@aztec/stdlib/tx';
|
|
11
8
|
|
|
12
9
|
import type { PeerId } from '@libp2p/interface';
|
|
@@ -19,8 +16,9 @@ import {
|
|
|
19
16
|
type MissingTxsCollector,
|
|
20
17
|
SendBatchRequestCollector,
|
|
21
18
|
} from './proposal_tx_collector.js';
|
|
19
|
+
import { RequestTracker } from './request_tracker.js';
|
|
22
20
|
import type { FastCollectionRequest, FastCollectionRequestInput } from './tx_collection.js';
|
|
23
|
-
import type { TxCollectionSink } from './tx_collection_sink.js';
|
|
21
|
+
import type { TxAddContext, TxCollectionSink } from './tx_collection_sink.js';
|
|
24
22
|
import type { TxSource } from './tx_source.js';
|
|
25
23
|
|
|
26
24
|
export class FastTxCollection {
|
|
@@ -47,7 +45,9 @@ export class FastTxCollection {
|
|
|
47
45
|
}
|
|
48
46
|
|
|
49
47
|
public async stop() {
|
|
50
|
-
this.requests.forEach(request =>
|
|
48
|
+
this.requests.forEach(request => {
|
|
49
|
+
request.requestTracker.cancel();
|
|
50
|
+
});
|
|
51
51
|
await Promise.resolve();
|
|
52
52
|
}
|
|
53
53
|
|
|
@@ -74,81 +74,65 @@ export class FastTxCollection {
|
|
|
74
74
|
? { ...input.blockProposal.toBlockInfo(), blockNumber: input.blockNumber }
|
|
75
75
|
: { ...input.block.toBlockInfo() };
|
|
76
76
|
|
|
77
|
-
// This promise is used to await for the collection to finish during the main collectFast method.
|
|
78
|
-
// It gets resolved in `foundTxs` when all txs have been collected, or rejected if the request is aborted or hits the deadline.
|
|
79
|
-
const promise = promiseWithResolvers<void>();
|
|
80
|
-
setTimeout(() => promise.reject(new TimeoutError(`Timed out while collecting txs`)), timeout);
|
|
81
|
-
|
|
82
77
|
const request: FastCollectionRequest = {
|
|
83
78
|
...input,
|
|
84
79
|
blockInfo,
|
|
85
|
-
|
|
86
|
-
foundTxs: new Map<string, Tx>(),
|
|
87
|
-
missingTxHashes: new Set(txHashes.map(t => t.toString())),
|
|
88
|
-
deadline: opts.deadline,
|
|
80
|
+
requestTracker: RequestTracker.create(txHashes, opts.deadline, this.dateProvider),
|
|
89
81
|
};
|
|
90
82
|
|
|
91
83
|
const [duration] = await elapsed(() => this.collectFast(request, { ...opts }));
|
|
92
84
|
|
|
93
85
|
this.log.verbose(
|
|
94
|
-
`Collected ${request.
|
|
86
|
+
`Collected ${request.requestTracker.collectedTxs.length} txs out of ${txHashes.length} for ${input.type} at slot ${blockInfo.slotNumber}`,
|
|
95
87
|
{
|
|
96
88
|
...blockInfo,
|
|
97
89
|
duration,
|
|
98
90
|
requestType: input.type,
|
|
99
|
-
missingTxs: [...request.missingTxHashes],
|
|
91
|
+
missingTxs: [...request.requestTracker.missingTxHashes],
|
|
100
92
|
},
|
|
101
93
|
);
|
|
102
|
-
return
|
|
94
|
+
return request.requestTracker.collectedTxs;
|
|
103
95
|
}
|
|
104
96
|
|
|
105
|
-
protected async collectFast(
|
|
106
|
-
request: FastCollectionRequest,
|
|
107
|
-
opts: { proposal?: BlockProposal; deadline: Date; pinnedPeer?: PeerId },
|
|
108
|
-
) {
|
|
97
|
+
protected async collectFast(request: FastCollectionRequest, opts: { pinnedPeer?: PeerId }) {
|
|
109
98
|
this.requests.add(request);
|
|
110
99
|
const { blockInfo } = request;
|
|
111
100
|
|
|
112
101
|
this.log.debug(
|
|
113
|
-
`Starting fast collection of ${request.
|
|
114
|
-
{ ...blockInfo, requestType: request.type, deadline:
|
|
102
|
+
`Starting fast collection of ${request.requestTracker.numberOfMissingTxs} txs for ${request.type} at slot ${blockInfo.slotNumber}`,
|
|
103
|
+
{ ...blockInfo, requestType: request.type, deadline: request.requestTracker.deadline },
|
|
115
104
|
);
|
|
116
105
|
|
|
117
106
|
try {
|
|
118
107
|
// Start blasting all nodes for the txs. We give them a little time to respond before we start reqresp.
|
|
119
|
-
//
|
|
120
|
-
//
|
|
121
|
-
const nodeCollectionPromise = this.collectFastFromNodes(request
|
|
108
|
+
// We race against the cancellation token to exit as soon as all txs are collected, the deadline expires,
|
|
109
|
+
// or the request is externally cancelled.
|
|
110
|
+
const nodeCollectionPromise = this.collectFastFromNodes(request);
|
|
122
111
|
const waitBeforeReqResp = sleep(this.config.txCollectionFastNodesTimeoutBeforeReqRespMs);
|
|
123
|
-
await Promise.race([request.
|
|
112
|
+
await Promise.race([request.requestTracker.cancellationToken, waitBeforeReqResp]);
|
|
124
113
|
|
|
125
|
-
// If we have collected all txs, we can stop here
|
|
126
|
-
|
|
127
|
-
|
|
114
|
+
// If we have collected all txs or the request was cancelled, we can stop here.
|
|
115
|
+
// Wait for node collection to settle so inner tasks finish before we return.
|
|
116
|
+
if (request.requestTracker.checkCancelled()) {
|
|
117
|
+
if (request.requestTracker.allFetched()) {
|
|
118
|
+
this.log.debug(`All txs collected for slot ${blockInfo.slotNumber} without reqresp`, blockInfo);
|
|
119
|
+
}
|
|
120
|
+
await nodeCollectionPromise;
|
|
128
121
|
return;
|
|
129
122
|
}
|
|
130
123
|
|
|
131
124
|
// Start blasting reqresp for the remaining txs. Note that node collection keeps running in parallel.
|
|
132
125
|
// We stop when we have collected all txs, timed out, or both node collection and reqresp have given up.
|
|
133
|
-
|
|
134
|
-
await Promise.
|
|
126
|
+
// Inner tasks observe requestTracker.checkCancelled() and stop themselves, so this settles shortly after cancellation.
|
|
127
|
+
await Promise.allSettled([this.collectFastViaReqResp(request, opts), nodeCollectionPromise]);
|
|
135
128
|
} catch (err) {
|
|
136
|
-
|
|
137
|
-
const logCtx = {
|
|
129
|
+
this.log.error(`Error collecting txs for ${request.type} for slot ${blockInfo.slotNumber}`, err, {
|
|
138
130
|
...blockInfo,
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
};
|
|
142
|
-
if (err instanceof Error && err.name === 'TimeoutError') {
|
|
143
|
-
this.log.warn(`Timed out collecting txs for ${request.type} at slot ${blockInfo.slotNumber}`, logCtx);
|
|
144
|
-
} else if (err instanceof Error && err.name === 'AbortError') {
|
|
145
|
-
this.log.warn(`Aborted collecting txs for ${request.type} at slot ${blockInfo.slotNumber}`, logCtx);
|
|
146
|
-
} else {
|
|
147
|
-
this.log.error(`Error collecting txs for ${request.type} for slot ${blockInfo.slotNumber}`, err, logCtx);
|
|
148
|
-
}
|
|
131
|
+
missingTxs: request.requestTracker.missingTxHashes.values().map(txHash => txHash.toString()),
|
|
132
|
+
});
|
|
149
133
|
} finally {
|
|
150
134
|
// Ensure no unresolved promises and remove the request from the set
|
|
151
|
-
request.
|
|
135
|
+
request.requestTracker.cancel();
|
|
152
136
|
this.requests.delete(request);
|
|
153
137
|
}
|
|
154
138
|
}
|
|
@@ -159,26 +143,28 @@ export class FastTxCollection {
|
|
|
159
143
|
* the txs that have been requested less often whenever we need to send a new batch of requests. We ensure that no
|
|
160
144
|
* tx is requested more than once at the same time to the same node.
|
|
161
145
|
*/
|
|
162
|
-
private async collectFastFromNodes(request: FastCollectionRequest
|
|
146
|
+
private async collectFastFromNodes(request: FastCollectionRequest): Promise<void> {
|
|
163
147
|
if (this.nodes.length === 0) {
|
|
164
148
|
return;
|
|
165
149
|
}
|
|
166
150
|
|
|
167
151
|
// Keep a shared priority queue of all txs pending to be requested, sorted by the number of attempts made to collect them.
|
|
168
|
-
const attemptsPerTx = [...request.missingTxHashes].map(txHash => ({
|
|
152
|
+
const attemptsPerTx = [...request.requestTracker.missingTxHashes].map(txHash => ({
|
|
153
|
+
txHash,
|
|
154
|
+
attempts: 0,
|
|
155
|
+
found: false,
|
|
156
|
+
}));
|
|
169
157
|
|
|
170
158
|
// Returns once we have finished all node loops. Each loop finishes when the deadline is hit, or all txs have been collected.
|
|
171
|
-
await Promise.allSettled(this.nodes.map(node => this.collectFastFromNode(request, node, attemptsPerTx
|
|
159
|
+
await Promise.allSettled(this.nodes.map(node => this.collectFastFromNode(request, node, attemptsPerTx)));
|
|
172
160
|
}
|
|
173
161
|
|
|
174
162
|
private async collectFastFromNode(
|
|
175
163
|
request: FastCollectionRequest,
|
|
176
164
|
node: TxSource,
|
|
177
165
|
attemptsPerTx: { txHash: string; attempts: number; found: boolean }[],
|
|
178
|
-
opts: { deadline: Date },
|
|
179
166
|
) {
|
|
180
|
-
const notFinished = () =>
|
|
181
|
-
this.dateProvider.now() <= +opts.deadline && request.missingTxHashes.size > 0 && this.requests.has(request);
|
|
167
|
+
const notFinished = () => !request.requestTracker.checkCancelled();
|
|
182
168
|
|
|
183
169
|
const maxParallelRequests = this.config.txCollectionFastMaxParallelRequestsPerNode;
|
|
184
170
|
const maxBatchSize = this.config.txCollectionNodeRpcMaxBatchSize;
|
|
@@ -195,7 +181,7 @@ export class FastTxCollection {
|
|
|
195
181
|
if (!txToRequest) {
|
|
196
182
|
// No more txs to process
|
|
197
183
|
break;
|
|
198
|
-
} else if (!request.
|
|
184
|
+
} else if (!request.requestTracker.isMissing(txToRequest.txHash)) {
|
|
199
185
|
// Mark as found if it was found somewhere else, we'll then remove it from the array.
|
|
200
186
|
// We don't delete it now since 'array.splice' is pretty expensive, so we do it after sorting.
|
|
201
187
|
txToRequest.found = true;
|
|
@@ -224,16 +210,24 @@ export class FastTxCollection {
|
|
|
224
210
|
return;
|
|
225
211
|
}
|
|
226
212
|
|
|
213
|
+
const txHashes = batch.map(({ txHash }) => txHash);
|
|
227
214
|
// Collect this batch from the node
|
|
228
215
|
await this.txCollectionSink.collect(
|
|
229
|
-
|
|
230
|
-
|
|
216
|
+
async () => {
|
|
217
|
+
const result = await node.getTxsByHash(txHashes.map(TxHash.fromString));
|
|
218
|
+
for (const tx of result.validTxs) {
|
|
219
|
+
request.requestTracker.markFetched(tx);
|
|
220
|
+
}
|
|
221
|
+
return result;
|
|
222
|
+
},
|
|
223
|
+
txHashes,
|
|
231
224
|
{
|
|
232
225
|
description: `fast ${node.getInfo()}`,
|
|
233
226
|
node: node.getInfo(),
|
|
234
227
|
method: 'fast-node-rpc',
|
|
235
228
|
...request.blockInfo,
|
|
236
229
|
},
|
|
230
|
+
this.getAddContext(request),
|
|
237
231
|
);
|
|
238
232
|
|
|
239
233
|
// Clear from the active requests the txs we just requested
|
|
@@ -241,9 +235,12 @@ export class FastTxCollection {
|
|
|
241
235
|
activeRequestsToThisNode.delete(requestedTx.txHash);
|
|
242
236
|
}
|
|
243
237
|
|
|
244
|
-
// Sleep a bit until hitting the node again
|
|
238
|
+
// Sleep a bit until hitting the node again, but wake up immediately on cancellation
|
|
245
239
|
if (notFinished()) {
|
|
246
|
-
await
|
|
240
|
+
await Promise.race([
|
|
241
|
+
sleep(this.config.txCollectionFastNodeIntervalMs),
|
|
242
|
+
request.requestTracker.cancellationToken,
|
|
243
|
+
]);
|
|
247
244
|
}
|
|
248
245
|
}
|
|
249
246
|
};
|
|
@@ -253,49 +250,64 @@ export class FastTxCollection {
|
|
|
253
250
|
}
|
|
254
251
|
|
|
255
252
|
private async collectFastViaReqResp(request: FastCollectionRequest, opts: { pinnedPeer?: PeerId }) {
|
|
256
|
-
const timeoutMs = +request.deadline - this.dateProvider.now();
|
|
257
253
|
const pinnedPeer = opts.pinnedPeer;
|
|
258
254
|
const blockInfo = request.blockInfo;
|
|
259
255
|
const slotNumber = blockInfo.slotNumber;
|
|
260
|
-
if (timeoutMs < 100) {
|
|
256
|
+
if (request.requestTracker.timeoutMs < 100) {
|
|
261
257
|
this.log.warn(
|
|
262
258
|
`Not initiating fast reqresp for txs for ${request.type} at slot ${blockInfo.slotNumber} due to timeout`,
|
|
263
|
-
{ timeoutMs, ...blockInfo },
|
|
259
|
+
{ timeoutMs: request.requestTracker.timeoutMs, ...blockInfo },
|
|
264
260
|
);
|
|
265
261
|
return;
|
|
266
262
|
}
|
|
267
263
|
|
|
268
264
|
this.log.debug(
|
|
269
|
-
`Starting fast reqresp for ${request.
|
|
270
|
-
{ ...blockInfo, timeoutMs, pinnedPeer },
|
|
265
|
+
`Starting fast reqresp for ${request.requestTracker.numberOfMissingTxs} txs for ${request.type} at slot ${blockInfo.slotNumber}`,
|
|
266
|
+
{ ...blockInfo, timeoutMs: request.requestTracker.timeoutMs, pinnedPeer },
|
|
271
267
|
);
|
|
272
268
|
|
|
273
269
|
try {
|
|
274
270
|
await this.txCollectionSink.collect(
|
|
275
|
-
async
|
|
271
|
+
async () => {
|
|
272
|
+
let result: Tx[];
|
|
276
273
|
if (request.type === 'proposal') {
|
|
277
|
-
|
|
274
|
+
result = await this.missingTxsCollector.collectTxs(
|
|
275
|
+
request.requestTracker,
|
|
276
|
+
request.blockProposal,
|
|
277
|
+
pinnedPeer,
|
|
278
|
+
);
|
|
278
279
|
} else if (request.type === 'block') {
|
|
279
280
|
const blockTxsSource = {
|
|
280
281
|
txHashes: request.block.body.txEffects.map(e => e.txHash),
|
|
281
282
|
archive: request.block.archive.root,
|
|
282
283
|
};
|
|
283
|
-
|
|
284
|
+
result = await this.missingTxsCollector.collectTxs(request.requestTracker, blockTxsSource, pinnedPeer);
|
|
284
285
|
} else {
|
|
285
286
|
throw new Error(`Unknown request type: ${(request as any).type}`);
|
|
286
287
|
}
|
|
288
|
+
return { validTxs: result, invalidTxHashes: [] };
|
|
287
289
|
},
|
|
288
|
-
Array.from(request.missingTxHashes)
|
|
290
|
+
Array.from(request.requestTracker.missingTxHashes),
|
|
289
291
|
{ description: `reqresp for slot ${slotNumber}`, method: 'fast-req-resp', ...opts, ...request.blockInfo },
|
|
292
|
+
this.getAddContext(request),
|
|
290
293
|
);
|
|
291
294
|
} catch (err) {
|
|
292
295
|
this.log.error(`Error sending fast reqresp request for txs`, err, {
|
|
293
|
-
txs: [...request.missingTxHashes],
|
|
296
|
+
txs: [...request.requestTracker.missingTxHashes],
|
|
294
297
|
...blockInfo,
|
|
295
298
|
});
|
|
296
299
|
}
|
|
297
300
|
}
|
|
298
301
|
|
|
302
|
+
/** Returns the TxAddContext for the given request, used by the sink to add txs to the pool correctly. */
|
|
303
|
+
private getAddContext(request: FastCollectionRequest): TxAddContext {
|
|
304
|
+
if (request.type === 'proposal') {
|
|
305
|
+
return { type: 'proposal', blockHeader: request.blockProposal.blockHeader };
|
|
306
|
+
} else {
|
|
307
|
+
return { type: 'mined', block: request.block };
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
|
|
299
311
|
/**
|
|
300
312
|
* Handle txs by marking them as found for the requests that are waiting for them, and resolves the request if all its txs have been found.
|
|
301
313
|
* Called internally and from the main tx collection manager whenever the tx pool emits a tx-added event.
|
|
@@ -305,21 +317,18 @@ export class FastTxCollection {
|
|
|
305
317
|
for (const tx of txs) {
|
|
306
318
|
const txHash = tx.txHash.toString();
|
|
307
319
|
// Remove the tx hash from the missing set, and add it to the found set.
|
|
308
|
-
if (request.
|
|
309
|
-
request.missingTxHashes.delete(txHash);
|
|
310
|
-
request.foundTxs.set(txHash, tx);
|
|
320
|
+
if (request.requestTracker.markFetched(tx)) {
|
|
311
321
|
this.log.trace(`Found tx ${txHash} for fast collection request`, {
|
|
312
322
|
...request.blockInfo,
|
|
313
323
|
txHash: tx.txHash.toString(),
|
|
314
324
|
type: request.type,
|
|
315
325
|
});
|
|
316
|
-
|
|
317
|
-
if (request.missingTxHashes.size === 0) {
|
|
326
|
+
if (request.requestTracker.allFetched()) {
|
|
318
327
|
this.log.trace(`All txs found for fast collection request`, {
|
|
319
328
|
...request.blockInfo,
|
|
320
329
|
type: request.type,
|
|
321
330
|
});
|
|
322
|
-
|
|
331
|
+
break;
|
|
323
332
|
}
|
|
324
333
|
}
|
|
325
334
|
}
|
|
@@ -333,8 +342,7 @@ export class FastTxCollection {
|
|
|
333
342
|
public stopCollectingForBlocksUpTo(blockNumber: BlockNumber): void {
|
|
334
343
|
for (const request of this.requests) {
|
|
335
344
|
if (request.blockInfo.blockNumber <= blockNumber) {
|
|
336
|
-
request.
|
|
337
|
-
this.requests.delete(request);
|
|
345
|
+
request.requestTracker.cancel();
|
|
338
346
|
}
|
|
339
347
|
}
|
|
340
348
|
}
|
|
@@ -346,8 +354,7 @@ export class FastTxCollection {
|
|
|
346
354
|
public stopCollectingForBlocksAfter(blockNumber: BlockNumber): void {
|
|
347
355
|
for (const request of this.requests) {
|
|
348
356
|
if (request.blockInfo.blockNumber > blockNumber) {
|
|
349
|
-
request.
|
|
350
|
-
this.requests.delete(request);
|
|
357
|
+
request.requestTracker.cancel();
|
|
351
358
|
}
|
|
352
359
|
}
|
|
353
360
|
}
|