@aztec/p2p 0.0.1-commit.4ad48494d → 0.0.1-commit.4d3c002
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +129 -3
- package/dest/client/factory.d.ts +7 -7
- package/dest/client/factory.d.ts.map +1 -1
- package/dest/client/factory.js +33 -29
- package/dest/client/interface.d.ts +18 -20
- package/dest/client/interface.d.ts.map +1 -1
- package/dest/client/p2p_client.d.ts +9 -19
- package/dest/client/p2p_client.d.ts.map +1 -1
- package/dest/client/p2p_client.js +72 -102
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.js +20 -10
- package/dest/config.d.ts +34 -15
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +86 -37
- package/dest/errors/p2p-service.error.d.ts +9 -0
- package/dest/errors/p2p-service.error.d.ts.map +1 -0
- package/dest/errors/p2p-service.error.js +10 -0
- package/dest/errors/tx-pool.error.d.ts +8 -0
- package/dest/errors/tx-pool.error.d.ts.map +1 -0
- package/dest/errors/tx-pool.error.js +9 -0
- package/dest/index.d.ts +1 -2
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +0 -1
- package/dest/mem_pools/attestation_pool/attestation_pool.d.ts +4 -4
- package/dest/mem_pools/attestation_pool/attestation_pool.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/attestation_pool.js +11 -6
- package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.js +6 -6
- package/dest/mem_pools/attestation_pool/mocks.d.ts +2 -2
- package/dest/mem_pools/attestation_pool/mocks.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/mocks.js +2 -2
- package/dest/mem_pools/index.d.ts +1 -2
- package/dest/mem_pools/index.d.ts.map +1 -1
- package/dest/mem_pools/instrumentation.d.ts +4 -2
- package/dest/mem_pools/instrumentation.d.ts.map +1 -1
- package/dest/mem_pools/instrumentation.js +16 -14
- package/dest/mem_pools/tx_pool_v2/deleted_pool.d.ts +3 -1
- package/dest/mem_pools/tx_pool_v2/deleted_pool.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/deleted_pool.js +9 -0
- package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.d.ts +3 -3
- package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.js +18 -9
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.d.ts +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.js +5 -4
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.d.ts +3 -3
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.js +12 -4
- package/dest/mem_pools/tx_pool_v2/eviction/index.d.ts +2 -2
- package/dest/mem_pools/tx_pool_v2/eviction/index.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/index.js +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/interfaces.d.ts +54 -5
- package/dest/mem_pools/tx_pool_v2/eviction/interfaces.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/interfaces.js +8 -0
- package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.js +4 -4
- package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.js +5 -5
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.d.ts +2 -2
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.js +12 -6
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.d.ts +4 -4
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.js +16 -4
- package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.d.ts +3 -3
- package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.js +3 -3
- package/dest/mem_pools/tx_pool_v2/index.d.ts +2 -2
- package/dest/mem_pools/tx_pool_v2/index.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/index.js +1 -1
- package/dest/mem_pools/tx_pool_v2/instrumentation.d.ts +15 -0
- package/dest/mem_pools/tx_pool_v2/instrumentation.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/instrumentation.js +43 -0
- package/dest/mem_pools/tx_pool_v2/interfaces.d.ts +24 -10
- package/dest/mem_pools/tx_pool_v2/interfaces.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/interfaces.js +4 -1
- package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts +54 -15
- package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/tx_metadata.js +111 -19
- package/dest/mem_pools/tx_pool_v2/tx_pool_indices.d.ts +5 -2
- package/dest/mem_pools/tx_pool_v2/tx_pool_indices.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/tx_pool_indices.js +38 -46
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts +9 -4
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2.js +12 -5
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts +12 -5
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.js +296 -153
- package/dest/msg_validators/attestation_validator/attestation_validator.d.ts +1 -1
- package/dest/msg_validators/attestation_validator/attestation_validator.d.ts.map +1 -1
- package/dest/msg_validators/attestation_validator/attestation_validator.js +5 -4
- package/dest/msg_validators/clock_tolerance.d.ts +1 -1
- package/dest/msg_validators/clock_tolerance.d.ts.map +1 -1
- package/dest/msg_validators/clock_tolerance.js +4 -3
- package/dest/msg_validators/proposal_validator/block_proposal_validator.d.ts +6 -4
- package/dest/msg_validators/proposal_validator/block_proposal_validator.d.ts.map +1 -1
- package/dest/msg_validators/proposal_validator/block_proposal_validator.js +10 -2
- package/dest/msg_validators/proposal_validator/checkpoint_proposal_validator.d.ts +6 -4
- package/dest/msg_validators/proposal_validator/checkpoint_proposal_validator.d.ts.map +1 -1
- package/dest/msg_validators/proposal_validator/checkpoint_proposal_validator.js +16 -2
- package/dest/msg_validators/proposal_validator/proposal_validator.d.ts +13 -8
- package/dest/msg_validators/proposal_validator/proposal_validator.d.ts.map +1 -1
- package/dest/msg_validators/proposal_validator/proposal_validator.js +53 -41
- package/dest/msg_validators/tx_validator/aggregate_tx_validator.d.ts +2 -2
- package/dest/msg_validators/tx_validator/aggregate_tx_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/aggregate_tx_validator.js +3 -3
- package/dest/msg_validators/tx_validator/allowed_public_setup.d.ts +2 -1
- package/dest/msg_validators/tx_validator/allowed_public_setup.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/allowed_public_setup.js +24 -20
- package/dest/msg_validators/tx_validator/allowed_setup_helpers.d.ts +17 -0
- package/dest/msg_validators/tx_validator/allowed_setup_helpers.d.ts.map +1 -0
- package/dest/msg_validators/tx_validator/allowed_setup_helpers.js +24 -0
- package/dest/msg_validators/tx_validator/contract_instance_validator.d.ts +9 -0
- package/dest/msg_validators/tx_validator/contract_instance_validator.d.ts.map +1 -0
- package/dest/msg_validators/tx_validator/contract_instance_validator.js +48 -0
- package/dest/msg_validators/tx_validator/data_validator.d.ts +1 -1
- package/dest/msg_validators/tx_validator/data_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/data_validator.js +35 -2
- package/dest/msg_validators/tx_validator/factory.d.ts +133 -6
- package/dest/msg_validators/tx_validator/factory.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/factory.js +247 -60
- package/dest/msg_validators/tx_validator/fee_payer_balance.d.ts +1 -1
- package/dest/msg_validators/tx_validator/fee_payer_balance.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/fee_payer_balance.js +6 -2
- package/dest/msg_validators/tx_validator/gas_validator.d.ts +67 -3
- package/dest/msg_validators/tx_validator/gas_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/gas_validator.js +104 -37
- package/dest/msg_validators/tx_validator/index.d.ts +3 -1
- package/dest/msg_validators/tx_validator/index.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/index.js +2 -0
- package/dest/msg_validators/tx_validator/metadata_validator.d.ts +1 -1
- package/dest/msg_validators/tx_validator/metadata_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/metadata_validator.js +4 -4
- package/dest/msg_validators/tx_validator/nullifier_cache.d.ts +14 -0
- package/dest/msg_validators/tx_validator/nullifier_cache.d.ts.map +1 -0
- package/dest/msg_validators/tx_validator/nullifier_cache.js +24 -0
- package/dest/msg_validators/tx_validator/phases_validator.d.ts +22 -2
- package/dest/msg_validators/tx_validator/phases_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/phases_validator.js +72 -24
- package/dest/msg_validators/tx_validator/timestamp_validator.d.ts +2 -2
- package/dest/msg_validators/tx_validator/timestamp_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/timestamp_validator.js +6 -6
- package/dest/services/discv5/discV5_service.d.ts +1 -1
- package/dest/services/discv5/discV5_service.d.ts.map +1 -1
- package/dest/services/discv5/discV5_service.js +5 -2
- package/dest/services/dummy_service.d.ts +7 -5
- package/dest/services/dummy_service.d.ts.map +1 -1
- package/dest/services/dummy_service.js +9 -5
- package/dest/services/encoding.d.ts +6 -2
- package/dest/services/encoding.d.ts.map +1 -1
- package/dest/services/encoding.js +16 -9
- package/dest/services/gossipsub/topic_score_params.d.ts +18 -6
- package/dest/services/gossipsub/topic_score_params.d.ts.map +1 -1
- package/dest/services/gossipsub/topic_score_params.js +32 -10
- package/dest/services/libp2p/libp2p_service.d.ts +30 -22
- package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
- package/dest/services/libp2p/libp2p_service.js +241 -151
- package/dest/services/peer-manager/metrics.d.ts +3 -1
- package/dest/services/peer-manager/metrics.d.ts.map +1 -1
- package/dest/services/peer-manager/metrics.js +6 -0
- package/dest/services/peer-manager/peer_manager.d.ts +6 -2
- package/dest/services/peer-manager/peer_manager.d.ts.map +1 -1
- package/dest/services/peer-manager/peer_manager.js +24 -9
- package/dest/services/peer-manager/peer_scoring.d.ts +5 -2
- package/dest/services/peer-manager/peer_scoring.d.ts.map +1 -1
- package/dest/services/peer-manager/peer_scoring.js +28 -10
- package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts +12 -8
- package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts.map +1 -1
- package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.js +83 -106
- package/dest/services/reqresp/batch-tx-requester/interface.d.ts +4 -7
- package/dest/services/reqresp/batch-tx-requester/interface.d.ts.map +1 -1
- package/dest/services/reqresp/batch-tx-requester/missing_txs.d.ts +11 -13
- package/dest/services/reqresp/batch-tx-requester/missing_txs.d.ts.map +1 -1
- package/dest/services/reqresp/batch-tx-requester/missing_txs.js +31 -46
- package/dest/services/reqresp/batch-tx-requester/peer_collection.d.ts +19 -11
- package/dest/services/reqresp/batch-tx-requester/peer_collection.d.ts.map +1 -1
- package/dest/services/reqresp/batch-tx-requester/peer_collection.js +52 -15
- package/dest/services/reqresp/batch-tx-requester/tx_validator.js +2 -2
- package/dest/services/reqresp/rate-limiter/rate_limiter.d.ts +5 -4
- package/dest/services/reqresp/rate-limiter/rate_limiter.d.ts.map +1 -1
- package/dest/services/reqresp/rate-limiter/rate_limiter.js +10 -8
- package/dest/services/reqresp/reqresp.d.ts +1 -1
- package/dest/services/reqresp/reqresp.d.ts.map +1 -1
- package/dest/services/reqresp/reqresp.js +19 -10
- package/dest/services/service.d.ts +11 -4
- package/dest/services/service.d.ts.map +1 -1
- package/dest/services/tx_collection/fast_tx_collection.d.ts +1 -4
- package/dest/services/tx_collection/fast_tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/fast_tx_collection.js +65 -75
- package/dest/services/tx_collection/file_store_tx_collection.d.ts +1 -1
- package/dest/services/tx_collection/file_store_tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/file_store_tx_collection.js +4 -2
- package/dest/services/tx_collection/file_store_tx_source.d.ts +16 -6
- package/dest/services/tx_collection/file_store_tx_source.d.ts.map +1 -1
- package/dest/services/tx_collection/file_store_tx_source.js +50 -9
- package/dest/services/tx_collection/instrumentation.d.ts +1 -1
- package/dest/services/tx_collection/instrumentation.d.ts.map +1 -1
- package/dest/services/tx_collection/instrumentation.js +2 -1
- package/dest/services/tx_collection/proposal_tx_collector.d.ts +7 -7
- package/dest/services/tx_collection/proposal_tx_collector.d.ts.map +1 -1
- package/dest/services/tx_collection/proposal_tx_collector.js +5 -4
- package/dest/services/tx_collection/request_tracker.d.ts +53 -0
- package/dest/services/tx_collection/request_tracker.d.ts.map +1 -0
- package/dest/services/tx_collection/request_tracker.js +84 -0
- package/dest/services/tx_collection/slow_tx_collection.d.ts +2 -2
- package/dest/services/tx_collection/slow_tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/slow_tx_collection.js +10 -8
- package/dest/services/tx_collection/tx_collection.d.ts +5 -7
- package/dest/services/tx_collection/tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/tx_collection_sink.d.ts +6 -5
- package/dest/services/tx_collection/tx_collection_sink.d.ts.map +1 -1
- package/dest/services/tx_collection/tx_collection_sink.js +13 -22
- package/dest/services/tx_collection/tx_source.d.ts +13 -7
- package/dest/services/tx_collection/tx_source.d.ts.map +1 -1
- package/dest/services/tx_collection/tx_source.js +26 -7
- package/dest/services/tx_file_store/tx_file_store.js +1 -1
- package/dest/services/tx_provider.d.ts +3 -3
- package/dest/services/tx_provider.d.ts.map +1 -1
- package/dest/services/tx_provider.js +4 -4
- package/dest/test-helpers/make-test-p2p-clients.d.ts +5 -6
- package/dest/test-helpers/make-test-p2p-clients.d.ts.map +1 -1
- package/dest/test-helpers/make-test-p2p-clients.js +1 -2
- package/dest/test-helpers/mock-pubsub.d.ts +11 -4
- package/dest/test-helpers/mock-pubsub.d.ts.map +1 -1
- package/dest/test-helpers/mock-pubsub.js +16 -3
- package/dest/test-helpers/reqresp-nodes.d.ts +2 -3
- package/dest/test-helpers/reqresp-nodes.d.ts.map +1 -1
- package/dest/test-helpers/reqresp-nodes.js +7 -3
- package/dest/test-helpers/testbench-utils.d.ts +6 -3
- package/dest/test-helpers/testbench-utils.d.ts.map +1 -1
- package/dest/test-helpers/testbench-utils.js +23 -4
- package/dest/testbench/p2p_client_testbench_worker.d.ts +2 -2
- package/dest/testbench/p2p_client_testbench_worker.d.ts.map +1 -1
- package/dest/testbench/p2p_client_testbench_worker.js +56 -26
- package/dest/testbench/worker_client_manager.d.ts +3 -1
- package/dest/testbench/worker_client_manager.d.ts.map +1 -1
- package/dest/testbench/worker_client_manager.js +6 -3
- package/dest/util.d.ts +9 -5
- package/dest/util.d.ts.map +1 -1
- package/dest/util.js +2 -10
- package/package.json +14 -14
- package/src/client/factory.ts +56 -48
- package/src/client/interface.ts +20 -21
- package/src/client/p2p_client.ts +78 -132
- package/src/client/test/tx_proposal_collector/proposal_tx_collector_worker.ts +33 -14
- package/src/config.ts +125 -43
- package/src/errors/p2p-service.error.ts +11 -0
- package/src/errors/tx-pool.error.ts +12 -0
- package/src/index.ts +0 -1
- package/src/mem_pools/attestation_pool/attestation_pool.ts +12 -9
- package/src/mem_pools/attestation_pool/attestation_pool_test_suite.ts +6 -6
- package/src/mem_pools/attestation_pool/mocks.ts +2 -1
- package/src/mem_pools/index.ts +0 -3
- package/src/mem_pools/instrumentation.ts +17 -13
- package/src/mem_pools/tx_pool_v2/README.md +10 -2
- package/src/mem_pools/tx_pool_v2/deleted_pool.ts +11 -0
- package/src/mem_pools/tx_pool_v2/eviction/eviction_manager.ts +21 -8
- package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.ts +5 -4
- package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.ts +18 -4
- package/src/mem_pools/tx_pool_v2/eviction/index.ts +4 -0
- package/src/mem_pools/tx_pool_v2/eviction/interfaces.ts +59 -4
- package/src/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.ts +4 -4
- package/src/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.ts +5 -5
- package/src/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.ts +12 -9
- package/src/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.ts +33 -6
- package/src/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.ts +4 -3
- package/src/mem_pools/tx_pool_v2/index.ts +1 -1
- package/src/mem_pools/tx_pool_v2/instrumentation.ts +69 -0
- package/src/mem_pools/tx_pool_v2/interfaces.ts +24 -10
- package/src/mem_pools/tx_pool_v2/tx_metadata.ts +159 -27
- package/src/mem_pools/tx_pool_v2/tx_pool_indices.ts +43 -46
- package/src/mem_pools/tx_pool_v2/tx_pool_v2.ts +28 -8
- package/src/mem_pools/tx_pool_v2/tx_pool_v2_impl.ts +330 -149
- package/src/msg_validators/attestation_validator/README.md +49 -0
- package/src/msg_validators/attestation_validator/attestation_validator.ts +5 -4
- package/src/msg_validators/clock_tolerance.ts +4 -3
- package/src/msg_validators/proposal_validator/README.md +123 -0
- package/src/msg_validators/proposal_validator/block_proposal_validator.ts +14 -4
- package/src/msg_validators/proposal_validator/checkpoint_proposal_validator.ts +20 -7
- package/src/msg_validators/proposal_validator/proposal_validator.ts +69 -45
- package/src/msg_validators/tx_validator/README.md +119 -0
- package/src/msg_validators/tx_validator/aggregate_tx_validator.ts +3 -3
- package/src/msg_validators/tx_validator/allowed_public_setup.ts +22 -27
- package/src/msg_validators/tx_validator/allowed_setup_helpers.ts +31 -0
- package/src/msg_validators/tx_validator/contract_instance_validator.ts +56 -0
- package/src/msg_validators/tx_validator/data_validator.ts +42 -1
- package/src/msg_validators/tx_validator/factory.ts +394 -78
- package/src/msg_validators/tx_validator/fee_payer_balance.ts +6 -2
- package/src/msg_validators/tx_validator/gas_validator.ts +123 -27
- package/src/msg_validators/tx_validator/index.ts +2 -0
- package/src/msg_validators/tx_validator/metadata_validator.ts +12 -4
- package/src/msg_validators/tx_validator/nullifier_cache.ts +30 -0
- package/src/msg_validators/tx_validator/phases_validator.ts +82 -27
- package/src/msg_validators/tx_validator/timestamp_validator.ts +7 -7
- package/src/services/discv5/discV5_service.ts +5 -2
- package/src/services/dummy_service.ts +12 -7
- package/src/services/encoding.ts +16 -8
- package/src/services/gossipsub/README.md +29 -14
- package/src/services/gossipsub/topic_score_params.ts +49 -13
- package/src/services/libp2p/libp2p_service.ts +262 -176
- package/src/services/peer-manager/metrics.ts +7 -0
- package/src/services/peer-manager/peer_manager.ts +28 -9
- package/src/services/peer-manager/peer_scoring.ts +21 -5
- package/src/services/reqresp/README.md +229 -0
- package/src/services/reqresp/batch-tx-requester/README.md +46 -7
- package/src/services/reqresp/batch-tx-requester/batch_tx_requester.ts +79 -112
- package/src/services/reqresp/batch-tx-requester/interface.ts +3 -6
- package/src/services/reqresp/batch-tx-requester/missing_txs.ts +30 -71
- package/src/services/reqresp/batch-tx-requester/peer_collection.ts +68 -24
- package/src/services/reqresp/batch-tx-requester/tx_validator.ts +2 -2
- package/src/services/reqresp/rate-limiter/rate_limiter.ts +13 -9
- package/src/services/reqresp/reqresp.ts +22 -12
- package/src/services/service.ts +20 -3
- package/src/services/tx_collection/fast_tx_collection.ts +71 -76
- package/src/services/tx_collection/file_store_tx_collection.ts +7 -3
- package/src/services/tx_collection/file_store_tx_source.ts +65 -9
- package/src/services/tx_collection/instrumentation.ts +7 -1
- package/src/services/tx_collection/proposal_tx_collector.ts +9 -13
- package/src/services/tx_collection/request_tracker.ts +127 -0
- package/src/services/tx_collection/slow_tx_collection.ts +8 -9
- package/src/services/tx_collection/tx_collection.ts +5 -6
- package/src/services/tx_collection/tx_collection_sink.ts +15 -29
- package/src/services/tx_collection/tx_source.ts +28 -8
- package/src/services/tx_file_store/tx_file_store.ts +1 -1
- package/src/services/tx_provider.ts +2 -2
- package/src/test-helpers/make-test-p2p-clients.ts +1 -3
- package/src/test-helpers/mock-pubsub.ts +20 -6
- package/src/test-helpers/reqresp-nodes.ts +7 -6
- package/src/test-helpers/testbench-utils.ts +32 -6
- package/src/testbench/p2p_client_testbench_worker.ts +62 -29
- package/src/testbench/worker_client_manager.ts +13 -6
- package/src/util.ts +15 -16
- package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.d.ts +0 -125
- package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.js +0 -596
- package/dest/mem_pools/tx_pool/eviction/eviction_manager.d.ts +0 -32
- package/dest/mem_pools/tx_pool/eviction/eviction_manager.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/eviction/eviction_manager.js +0 -112
- package/dest/mem_pools/tx_pool/eviction/eviction_strategy.d.ts +0 -157
- package/dest/mem_pools/tx_pool/eviction/eviction_strategy.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/eviction/eviction_strategy.js +0 -52
- package/dest/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.d.ts +0 -16
- package/dest/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.js +0 -122
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.d.ts +0 -17
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.js +0 -84
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.d.ts +0 -19
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.js +0 -78
- package/dest/mem_pools/tx_pool/eviction/low_priority_eviction_rule.d.ts +0 -26
- package/dest/mem_pools/tx_pool/eviction/low_priority_eviction_rule.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/eviction/low_priority_eviction_rule.js +0 -84
- package/dest/mem_pools/tx_pool/eviction/nullifier_conflict_pre_add_rule.d.ts +0 -25
- package/dest/mem_pools/tx_pool/eviction/nullifier_conflict_pre_add_rule.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/eviction/nullifier_conflict_pre_add_rule.js +0 -57
- package/dest/mem_pools/tx_pool/index.d.ts +0 -3
- package/dest/mem_pools/tx_pool/index.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/index.js +0 -2
- package/dest/mem_pools/tx_pool/priority.d.ts +0 -12
- package/dest/mem_pools/tx_pool/priority.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/priority.js +0 -15
- package/dest/mem_pools/tx_pool/tx_pool.d.ts +0 -127
- package/dest/mem_pools/tx_pool/tx_pool.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/tx_pool.js +0 -3
- package/dest/mem_pools/tx_pool/tx_pool_test_suite.d.ts +0 -7
- package/dest/mem_pools/tx_pool/tx_pool_test_suite.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/tx_pool_test_suite.js +0 -400
- package/dest/msg_validators/proposal_validator/proposal_validator_test_suite.d.ts +0 -23
- package/dest/msg_validators/proposal_validator/proposal_validator_test_suite.d.ts.map +0 -1
- package/dest/msg_validators/proposal_validator/proposal_validator_test_suite.js +0 -212
- package/src/mem_pools/tx_pool/README.md +0 -270
- package/src/mem_pools/tx_pool/aztec_kv_tx_pool.ts +0 -746
- package/src/mem_pools/tx_pool/eviction/eviction_manager.ts +0 -132
- package/src/mem_pools/tx_pool/eviction/eviction_strategy.ts +0 -208
- package/src/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.ts +0 -162
- package/src/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.ts +0 -104
- package/src/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.ts +0 -93
- package/src/mem_pools/tx_pool/eviction/low_priority_eviction_rule.ts +0 -106
- package/src/mem_pools/tx_pool/eviction/nullifier_conflict_pre_add_rule.ts +0 -75
- package/src/mem_pools/tx_pool/index.ts +0 -2
- package/src/mem_pools/tx_pool/priority.ts +0 -20
- package/src/mem_pools/tx_pool/tx_pool.ts +0 -141
- package/src/mem_pools/tx_pool/tx_pool_test_suite.ts +0 -319
- package/src/msg_validators/proposal_validator/proposal_validator_test_suite.ts +0 -230
package/src/client/interface.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { SlotNumber } from '@aztec/foundation/branded-types';
|
|
2
2
|
import type { EthAddress, L2BlockId } from '@aztec/stdlib/block';
|
|
3
|
-
import type {
|
|
4
|
-
import type { BlockProposal, CheckpointAttestation, CheckpointProposal,
|
|
3
|
+
import type { ITxProvider, P2PClient } from '@aztec/stdlib/interfaces/server';
|
|
4
|
+
import type { BlockProposal, CheckpointAttestation, CheckpointProposal, TopicType } from '@aztec/stdlib/p2p';
|
|
5
5
|
import type { BlockHeader, Tx, TxHash } from '@aztec/stdlib/tx';
|
|
6
6
|
|
|
7
7
|
import type { PeerId } from '@libp2p/interface';
|
|
@@ -48,7 +48,7 @@ export interface P2PSyncState {
|
|
|
48
48
|
/**
|
|
49
49
|
* Interface of a P2P client.
|
|
50
50
|
**/
|
|
51
|
-
export type P2P
|
|
51
|
+
export type P2P = P2PClient & {
|
|
52
52
|
/**
|
|
53
53
|
* Broadcasts a block proposal to other peers.
|
|
54
54
|
*
|
|
@@ -82,7 +82,15 @@ export type P2P<T extends P2PClientType = P2PClientType.Full> = P2PApiFull<T> &
|
|
|
82
82
|
*
|
|
83
83
|
* @param handler - A function taking a received checkpoint proposal and producing attestations
|
|
84
84
|
*/
|
|
85
|
-
|
|
85
|
+
registerValidatorCheckpointProposalHandler(callback: P2PCheckpointReceivedCallback): void;
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Registers a callback that runs for ALL nodes (not just validators) when a checkpoint proposal is received.
|
|
89
|
+
* Used to set the proposed checkpoint number on the archiver so the sequencer can build on top of it.
|
|
90
|
+
*
|
|
91
|
+
* @param handler - A function taking a received checkpoint proposal
|
|
92
|
+
*/
|
|
93
|
+
registerAllNodesCheckpointProposalHandler(callback: P2PCheckpointReceivedCallback): void;
|
|
86
94
|
|
|
87
95
|
/**
|
|
88
96
|
* Registers a callback invoked when a duplicate proposal is detected (equivocation).
|
|
@@ -107,13 +115,6 @@ export type P2P<T extends P2PClientType = P2PClientType.Full> = P2PApiFull<T> &
|
|
|
107
115
|
**/
|
|
108
116
|
sendTx(tx: Tx): Promise<void>;
|
|
109
117
|
|
|
110
|
-
/**
|
|
111
|
-
* Adds transactions to the pool. Does not send to peers or validate the tx.
|
|
112
|
-
* @param txs - The transactions.
|
|
113
|
-
* @returns The number of txs added to the pool. Note if the transaction already exists, it will not be added again.
|
|
114
|
-
**/
|
|
115
|
-
addTxsToPool(txs: Tx[]): Promise<number>;
|
|
116
|
-
|
|
117
118
|
/**
|
|
118
119
|
* Handles failed transaction execution by removing txs from the pool.
|
|
119
120
|
* @param txHashes - Hashes of the transactions that failed execution.
|
|
@@ -141,14 +142,6 @@ export type P2P<T extends P2PClientType = P2PClientType.Full> = P2PApiFull<T> &
|
|
|
141
142
|
*/
|
|
142
143
|
hasTxsInPool(txHashes: TxHash[]): Promise<boolean[]>;
|
|
143
144
|
|
|
144
|
-
/**
|
|
145
|
-
* Returns transactions in the transaction pool by hash, requesting from the network if not found.
|
|
146
|
-
* @param txHashes - Hashes of tx to return.
|
|
147
|
-
* @param pinnedPeerId - An optional peer id that will be used to request the tx from (in addition to other random peers).
|
|
148
|
-
* @returns An array of tx or undefined.
|
|
149
|
-
*/
|
|
150
|
-
getTxsByHash(txHashes: TxHash[], pinnedPeerId: PeerId | undefined): Promise<(Tx | undefined)[]>;
|
|
151
|
-
|
|
152
145
|
/**
|
|
153
146
|
* Returns an archived transaction from the transaction pool by its hash.
|
|
154
147
|
* @param txHash - Hash of tx to return.
|
|
@@ -220,10 +213,13 @@ export type P2P<T extends P2PClientType = P2PClientType.Full> = P2PApiFull<T> &
|
|
|
220
213
|
/** Identifies a p2p client. */
|
|
221
214
|
isP2PClient(): true;
|
|
222
215
|
|
|
216
|
+
/** Returns the tx provider used for fetching transactions. */
|
|
217
|
+
getTxProvider(): ITxProvider;
|
|
218
|
+
|
|
223
219
|
updateP2PConfig(config: Partial<P2PConfig>): Promise<void>;
|
|
224
220
|
|
|
225
|
-
/** Validates a set of txs. */
|
|
226
|
-
|
|
221
|
+
/** Validates a set of txs received in a block proposal. */
|
|
222
|
+
validateTxsReceivedInBlockProposal(txs: Tx[]): Promise<void>;
|
|
227
223
|
|
|
228
224
|
/** Clears the db. */
|
|
229
225
|
clear(): Promise<void>;
|
|
@@ -241,4 +237,7 @@ export type P2P<T extends P2PClientType = P2PClientType.Full> = P2PApiFull<T> &
|
|
|
241
237
|
|
|
242
238
|
/** If node running this P2P stack is validator, passes in validator address to P2P layer */
|
|
243
239
|
registerThisValidatorAddresses(address: EthAddress[]): void;
|
|
240
|
+
|
|
241
|
+
/** Returns the number of peers in the GossipSub mesh for a given topic type. */
|
|
242
|
+
getGossipMeshPeerCount(topicType: TopicType): Promise<number>;
|
|
244
243
|
};
|
package/src/client/p2p_client.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { GENESIS_BLOCK_HEADER_HASH } from '@aztec/constants';
|
|
2
2
|
import type { EpochCacheInterface } from '@aztec/epoch-cache';
|
|
3
|
-
import { BlockNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
3
|
+
import { BlockNumber, CheckpointNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
4
4
|
import { createLogger } from '@aztec/foundation/log';
|
|
5
5
|
import { RunningPromise } from '@aztec/foundation/promise';
|
|
6
6
|
import { DateProvider } from '@aztec/foundation/timer';
|
|
7
7
|
import type { AztecAsyncKVStore, AztecAsyncSingleton } from '@aztec/kv-store';
|
|
8
8
|
import { L2TipsKVStore } from '@aztec/kv-store/stores';
|
|
9
9
|
import {
|
|
10
|
+
type CheckpointId,
|
|
10
11
|
type EthAddress,
|
|
11
12
|
type L2Block,
|
|
12
13
|
type L2BlockId,
|
|
@@ -17,14 +18,8 @@ import {
|
|
|
17
18
|
type L2TipsStore,
|
|
18
19
|
} from '@aztec/stdlib/block';
|
|
19
20
|
import type { ContractDataSource } from '@aztec/stdlib/contract';
|
|
20
|
-
import { getTimestampForSlot } from '@aztec/stdlib/epoch-helpers';
|
|
21
21
|
import { type PeerInfo, tryStop } from '@aztec/stdlib/interfaces/server';
|
|
22
|
-
import {
|
|
23
|
-
type BlockProposal,
|
|
24
|
-
CheckpointAttestation,
|
|
25
|
-
type CheckpointProposal,
|
|
26
|
-
type P2PClientType,
|
|
27
|
-
} from '@aztec/stdlib/p2p';
|
|
22
|
+
import { type BlockProposal, CheckpointAttestation, type CheckpointProposal, type TopicType } from '@aztec/stdlib/p2p';
|
|
28
23
|
import type { BlockHeader, Tx, TxHash } from '@aztec/stdlib/tx';
|
|
29
24
|
import { Attributes, type TelemetryClient, WithTracer, getTelemetryClient, trackSpan } from '@aztec/telemetry-client';
|
|
30
25
|
|
|
@@ -32,6 +27,7 @@ import type { PeerId } from '@libp2p/interface';
|
|
|
32
27
|
import type { ENR } from '@nethermindeth/enr';
|
|
33
28
|
|
|
34
29
|
import { type P2PConfig, getP2PDefaultConfig } from '../config.js';
|
|
30
|
+
import { TxPoolError } from '../errors/tx-pool.error.js';
|
|
35
31
|
import type { AttestationPoolApi } from '../mem_pools/attestation_pool/attestation_pool.js';
|
|
36
32
|
import type { MemPools } from '../mem_pools/interface.js';
|
|
37
33
|
import type { TxPoolV2 } from '../mem_pools/tx_pool_v2/interfaces.js';
|
|
@@ -41,7 +37,6 @@ import {
|
|
|
41
37
|
type ReqRespSubProtocolHandler,
|
|
42
38
|
type ReqRespSubProtocolValidators,
|
|
43
39
|
} from '../services/reqresp/interface.js';
|
|
44
|
-
import { chunkTxHashesRequest } from '../services/reqresp/protocols/tx.js';
|
|
45
40
|
import type {
|
|
46
41
|
DuplicateAttestationInfo,
|
|
47
42
|
DuplicateProposalInfo,
|
|
@@ -57,10 +52,7 @@ import { type P2P, P2PClientState, type P2PSyncState } from './interface.js';
|
|
|
57
52
|
/**
|
|
58
53
|
* The P2P client implementation.
|
|
59
54
|
*/
|
|
60
|
-
export class P2PClient
|
|
61
|
-
extends WithTracer
|
|
62
|
-
implements P2P, P2P<P2PClientType.Prover>
|
|
63
|
-
{
|
|
55
|
+
export class P2PClient extends WithTracer implements P2P {
|
|
64
56
|
/** The JS promise that will be running to keep the client's data in sync. Can be interrupted if the client is stopped. */
|
|
65
57
|
private runningPromise!: Promise<void>;
|
|
66
58
|
|
|
@@ -92,7 +84,6 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
92
84
|
private slotMonitor: RunningPromise | undefined;
|
|
93
85
|
|
|
94
86
|
constructor(
|
|
95
|
-
_clientType: T,
|
|
96
87
|
private store: AztecAsyncKVStore,
|
|
97
88
|
private l2BlockSource: L2BlockSource & ContractDataSource,
|
|
98
89
|
mempools: MemPools,
|
|
@@ -119,27 +110,6 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
119
110
|
this.telemetry,
|
|
120
111
|
);
|
|
121
112
|
|
|
122
|
-
// Default to collecting all txs when we see a valid proposal
|
|
123
|
-
// This can be overridden by the validator client to validate, and it will call getTxsForBlockProposal on its own
|
|
124
|
-
// Note: Validators do NOT attest to individual blocks - attestations are only for checkpoint proposals.
|
|
125
|
-
// TODO(palla/txs): We should not trigger a request for txs on a proposal before fully validating it. We need to bring
|
|
126
|
-
// validator-client code into here so we can validate a proposal is reasonable.
|
|
127
|
-
this.registerBlockProposalHandler(async (block, sender) => {
|
|
128
|
-
this.log.debug(`Received block proposal from ${sender.toString()}`);
|
|
129
|
-
// TODO(palla/txs): Need to subtract validatorReexecuteDeadlineMs from this deadline (see ValidatorClient.getReexecutionDeadline)
|
|
130
|
-
const constants = this.txCollection.getConstants();
|
|
131
|
-
const nextSlotTimestampSeconds = Number(getTimestampForSlot(SlotNumber(block.slotNumber + 1), constants));
|
|
132
|
-
const deadline = new Date(nextSlotTimestampSeconds * 1000);
|
|
133
|
-
const parentBlock = await this.l2BlockSource.getBlockHeaderByArchive(block.blockHeader.lastArchive.root);
|
|
134
|
-
if (!parentBlock) {
|
|
135
|
-
this.log.debug(`Cannot collect txs for proposal as parent block not found`);
|
|
136
|
-
return false;
|
|
137
|
-
}
|
|
138
|
-
const blockNumber = BlockNumber(parentBlock.getBlockNumber() + 1);
|
|
139
|
-
await this.txProvider.getTxsForBlockProposal(block, blockNumber, { pinnedPeer: sender, deadline });
|
|
140
|
-
return true;
|
|
141
|
-
});
|
|
142
|
-
|
|
143
113
|
this.l2Tips = new L2TipsKVStore(store, 'p2p_client');
|
|
144
114
|
this.synchedLatestSlot = store.openSingleton('p2p_pool_last_l2_slot');
|
|
145
115
|
}
|
|
@@ -165,6 +135,10 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
165
135
|
return Promise.resolve(this.p2pService.getPeers(includePending));
|
|
166
136
|
}
|
|
167
137
|
|
|
138
|
+
public getGossipMeshPeerCount(topicType: TopicType): Promise<number> {
|
|
139
|
+
return Promise.resolve(this.p2pService.getGossipMeshPeerCount(topicType));
|
|
140
|
+
}
|
|
141
|
+
|
|
168
142
|
public getL2BlockHash(number: BlockNumber): Promise<string | undefined> {
|
|
169
143
|
return this.l2Tips.getL2BlockHash(number);
|
|
170
144
|
}
|
|
@@ -200,7 +174,7 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
200
174
|
break;
|
|
201
175
|
case 'chain-pruned':
|
|
202
176
|
this.txCollection.stopCollectingForBlocksAfter(event.block.number);
|
|
203
|
-
await this.handlePruneL2Blocks(event.block);
|
|
177
|
+
await this.handlePruneL2Blocks(event.block, event.checkpoint);
|
|
204
178
|
break;
|
|
205
179
|
case 'chain-checkpointed':
|
|
206
180
|
break;
|
|
@@ -383,6 +357,8 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
383
357
|
// Store our own last-block proposal so we can respond to req/resp requests for it.
|
|
384
358
|
await this.attestationPool.tryAddBlockProposal(blockProposal);
|
|
385
359
|
}
|
|
360
|
+
// Gossipsub doesn't deliver own messages, so fire the all-nodes handler locally
|
|
361
|
+
await this.p2pService.notifyOwnCheckpointProposal(proposal.toCore());
|
|
386
362
|
return this.p2pService.propagate(proposal);
|
|
387
363
|
}
|
|
388
364
|
|
|
@@ -414,8 +390,12 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
414
390
|
this.p2pService.registerBlockReceivedCallback(handler);
|
|
415
391
|
}
|
|
416
392
|
|
|
417
|
-
public
|
|
418
|
-
this.p2pService.
|
|
393
|
+
public registerValidatorCheckpointProposalHandler(handler: P2PCheckpointReceivedCallback): void {
|
|
394
|
+
this.p2pService.registerValidatorCheckpointReceivedCallback(handler);
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
public registerAllNodesCheckpointProposalHandler(handler: P2PCheckpointReceivedCallback): void {
|
|
398
|
+
this.p2pService.registerAllNodesCheckpointReceivedCallback(handler);
|
|
419
399
|
}
|
|
420
400
|
|
|
421
401
|
public registerDuplicateProposalCallback(callback: (info: DuplicateProposalInfo) => void): void {
|
|
@@ -426,36 +406,6 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
426
406
|
this.p2pService.registerDuplicateAttestationCallback(callback);
|
|
427
407
|
}
|
|
428
408
|
|
|
429
|
-
/**
|
|
430
|
-
* Uses the batched Request Response protocol to request a set of transactions from the network.
|
|
431
|
-
*/
|
|
432
|
-
private async requestTxsByHash(txHashes: TxHash[], pinnedPeerId: PeerId | undefined): Promise<Tx[]> {
|
|
433
|
-
const timeoutMs = 8000; // Longer timeout for now
|
|
434
|
-
const maxRetryAttempts = 10; // Keep retrying within the timeout
|
|
435
|
-
const requests = chunkTxHashesRequest(txHashes);
|
|
436
|
-
const maxPeers = Math.min(Math.ceil(requests.length / 3), 10);
|
|
437
|
-
|
|
438
|
-
const txBatches = await this.p2pService.sendBatchRequest(
|
|
439
|
-
ReqRespSubProtocol.TX,
|
|
440
|
-
requests,
|
|
441
|
-
pinnedPeerId,
|
|
442
|
-
timeoutMs,
|
|
443
|
-
maxPeers,
|
|
444
|
-
maxRetryAttempts,
|
|
445
|
-
);
|
|
446
|
-
|
|
447
|
-
const txs = txBatches.flat();
|
|
448
|
-
if (txs.length > 0) {
|
|
449
|
-
await this.txPool.addPendingTxs(txs);
|
|
450
|
-
}
|
|
451
|
-
|
|
452
|
-
const txHashesStr = txHashes.map(tx => tx.toString()).join(', ');
|
|
453
|
-
this.log.debug(`Requested txs ${txHashesStr} (${txs.length} / ${txHashes.length}) from peers`);
|
|
454
|
-
|
|
455
|
-
// We return all transactions, even the not found ones to the caller, such they can handle missing items themselves.
|
|
456
|
-
return txs;
|
|
457
|
-
}
|
|
458
|
-
|
|
459
409
|
public async getPendingTxs(limit?: number, after?: TxHash): Promise<Tx[]> {
|
|
460
410
|
if (limit !== undefined && limit <= 0) {
|
|
461
411
|
throw new TypeError('limit must be greater than 0');
|
|
@@ -523,49 +473,6 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
523
473
|
return this.txPool.hasTxs(txHashes);
|
|
524
474
|
}
|
|
525
475
|
|
|
526
|
-
/**
|
|
527
|
-
* Returns transactions in the transaction pool by hash.
|
|
528
|
-
* If a transaction is not in the pool, it will be requested from the network.
|
|
529
|
-
* @param txHashes - Hashes of the transactions to look for.
|
|
530
|
-
* @returns The txs found, or undefined if not found in the order requested.
|
|
531
|
-
*/
|
|
532
|
-
async getTxsByHash(txHashes: TxHash[], pinnedPeerId: PeerId | undefined): Promise<(Tx | undefined)[]> {
|
|
533
|
-
const txs = await Promise.all(txHashes.map(txHash => this.txPool.getTxByHash(txHash)));
|
|
534
|
-
const missingTxHashes = txs
|
|
535
|
-
.map((tx, index) => [tx, index] as const)
|
|
536
|
-
.filter(([tx, _index]) => !tx)
|
|
537
|
-
.map(([_tx, index]) => txHashes[index]);
|
|
538
|
-
|
|
539
|
-
if (missingTxHashes.length === 0) {
|
|
540
|
-
return txs as Tx[];
|
|
541
|
-
}
|
|
542
|
-
|
|
543
|
-
const missingTxs = await this.requestTxsByHash(missingTxHashes, pinnedPeerId);
|
|
544
|
-
// TODO: optimize
|
|
545
|
-
// Merge the found txs in order
|
|
546
|
-
const mergingTxs = txHashes.map(txHash => {
|
|
547
|
-
// Is it in the txs list from the mempool?
|
|
548
|
-
for (const tx of txs) {
|
|
549
|
-
if (tx !== undefined && tx.getTxHash().equals(txHash)) {
|
|
550
|
-
return tx;
|
|
551
|
-
}
|
|
552
|
-
}
|
|
553
|
-
|
|
554
|
-
// Is it in the fetched missing txs?
|
|
555
|
-
// Note: this is an O(n^2) operation, but we expect the number of missing txs to be small.
|
|
556
|
-
for (const tx of missingTxs) {
|
|
557
|
-
if (tx.getTxHash().equals(txHash)) {
|
|
558
|
-
return tx;
|
|
559
|
-
}
|
|
560
|
-
}
|
|
561
|
-
|
|
562
|
-
// Otherwise return undefined
|
|
563
|
-
return undefined;
|
|
564
|
-
});
|
|
565
|
-
|
|
566
|
-
return mergingTxs;
|
|
567
|
-
}
|
|
568
|
-
|
|
569
476
|
/**
|
|
570
477
|
* Returns an archived transaction in the transaction pool by its hash.
|
|
571
478
|
* @param txHash - Hash of the archived transaction to look for.
|
|
@@ -582,23 +489,22 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
582
489
|
**/
|
|
583
490
|
public async sendTx(tx: Tx): Promise<void> {
|
|
584
491
|
this.#assertIsReady();
|
|
585
|
-
const result = await this.txPool.addPendingTxs([tx]);
|
|
492
|
+
const result = await this.txPool.addPendingTxs([tx], { feeComparisonOnly: true });
|
|
586
493
|
if (result.accepted.length === 1) {
|
|
587
494
|
await this.p2pService.propagate(tx);
|
|
588
|
-
|
|
589
|
-
this.log.warn(
|
|
590
|
-
`Tx ${tx.getTxHash()} not propagated: accepted=${result.accepted.length} ignored=${result.ignored.length} rejected=${result.rejected.length}`,
|
|
591
|
-
);
|
|
495
|
+
return;
|
|
592
496
|
}
|
|
593
|
-
}
|
|
594
497
|
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
498
|
+
const txHashStr = tx.getTxHash().toString();
|
|
499
|
+
const reason = result.errors?.get(txHashStr);
|
|
500
|
+
if (reason) {
|
|
501
|
+
this.log.warn(`Tx ${txHashStr} not added to pool: ${reason.message}`);
|
|
502
|
+
throw new TxPoolError(reason);
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
this.log.warn(
|
|
506
|
+
`Tx ${txHashStr} not propagated: accepted=${result.accepted.length} ignored=${result.ignored.length} rejected=${result.rejected.length}`,
|
|
507
|
+
);
|
|
602
508
|
}
|
|
603
509
|
|
|
604
510
|
/**
|
|
@@ -759,20 +665,60 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
759
665
|
|
|
760
666
|
/**
|
|
761
667
|
* Updates the tx pool after a chain prune.
|
|
668
|
+
* Detects epoch prunes (checkpoint number changed) and deletes all txs in that case.
|
|
762
669
|
* @param latestBlock - The block ID the chain was pruned to.
|
|
670
|
+
* @param newCheckpoint - The checkpoint ID after the prune.
|
|
671
|
+
*/
|
|
672
|
+
private async handlePruneL2Blocks(latestBlock: L2BlockId, newCheckpoint: CheckpointId): Promise<void> {
|
|
673
|
+
const deleteAllTxs = this.config.txPoolDeleteTxsAfterReorg && (await this.isEpochPrune(newCheckpoint));
|
|
674
|
+
await this.txPool.handlePrunedBlocks(latestBlock, { deleteAllTxs });
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
/**
|
|
678
|
+
* Returns true if the prune is an epoch prune (new checkpoint number is less than old).
|
|
679
|
+
* If the checkpoint number stays the same or increases, the prune is within a checkpoint.
|
|
763
680
|
*/
|
|
764
|
-
private async
|
|
765
|
-
await this.
|
|
681
|
+
private async isEpochPrune(newCheckpoint: CheckpointId): Promise<boolean> {
|
|
682
|
+
const tips = await this.l2Tips.getL2Tips();
|
|
683
|
+
const oldCheckpointNumber = tips.checkpointed.checkpoint.number;
|
|
684
|
+
if (oldCheckpointNumber <= CheckpointNumber.INITIAL) {
|
|
685
|
+
return false;
|
|
686
|
+
}
|
|
687
|
+
const newCheckpointNumber = newCheckpoint.number;
|
|
688
|
+
// We check that the new checkpoint number is less than the old checkpoint number in order to consider it an epoch prune.
|
|
689
|
+
// To be more certain that it is an epoch prune, we will check that at least 2 checkpoints were removed.
|
|
690
|
+
// This means we should avoid thinking checkpoints removed by L1 re-orgs are epoch prunes
|
|
691
|
+
const thresholdForEpochPrune = CheckpointNumber(oldCheckpointNumber - 2);
|
|
692
|
+
const isEpochPrune = newCheckpointNumber <= thresholdForEpochPrune;
|
|
693
|
+
if (isEpochPrune) {
|
|
694
|
+
this.log.info(`Detected epoch prune to ${newCheckpointNumber}`, {
|
|
695
|
+
oldCheckpointNumber,
|
|
696
|
+
newCheckpointNumber,
|
|
697
|
+
thresholdForEpochPrune,
|
|
698
|
+
});
|
|
699
|
+
}
|
|
700
|
+
return isEpochPrune;
|
|
766
701
|
}
|
|
767
702
|
|
|
768
703
|
/** Checks if the slot has changed and calls prepareForSlot if so. */
|
|
769
704
|
private async maybeCallPrepareForSlot(): Promise<void> {
|
|
770
|
-
|
|
771
|
-
|
|
705
|
+
// If we have a proposed checkpoint available, we want to prepare the target slot - otherwise we prepare the current slot
|
|
706
|
+
const l2Tips = await this.l2Tips.getL2Tips();
|
|
707
|
+
const hasProposedCheckpoint = l2Tips.proposedCheckpoint.checkpoint.number > l2Tips.checkpointed.checkpoint.number;
|
|
708
|
+
|
|
709
|
+
let slot;
|
|
710
|
+
if (this.epochCache.isProposerPipeliningEnabled() && hasProposedCheckpoint) {
|
|
711
|
+
const { targetSlot } = this.epochCache.getTargetAndNextSlot();
|
|
712
|
+
slot = targetSlot;
|
|
713
|
+
} else {
|
|
714
|
+
const { currentSlot } = this.epochCache.getCurrentAndNextSlot();
|
|
715
|
+
slot = currentSlot;
|
|
716
|
+
}
|
|
717
|
+
if (slot <= this.lastSlotProcessed) {
|
|
772
718
|
return;
|
|
773
719
|
}
|
|
774
|
-
this.lastSlotProcessed =
|
|
775
|
-
await this.txPool.prepareForSlot(
|
|
720
|
+
this.lastSlotProcessed = slot;
|
|
721
|
+
await this.txPool.prepareForSlot(slot);
|
|
776
722
|
}
|
|
777
723
|
|
|
778
724
|
private async startServiceIfSynched() {
|
|
@@ -812,8 +758,8 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
812
758
|
this.log.debug(`Moved from state ${P2PClientState[oldState]} to ${P2PClientState[this.currentState]}`);
|
|
813
759
|
}
|
|
814
760
|
|
|
815
|
-
public
|
|
816
|
-
return this.p2pService.
|
|
761
|
+
public validateTxsReceivedInBlockProposal(txs: Tx[]): Promise<void> {
|
|
762
|
+
return this.p2pService.validateTxsReceivedInBlockProposal(txs);
|
|
817
763
|
}
|
|
818
764
|
|
|
819
765
|
/**
|
|
@@ -3,12 +3,12 @@ import { SecretValue } from '@aztec/foundation/config';
|
|
|
3
3
|
import { createLogger } from '@aztec/foundation/log';
|
|
4
4
|
import { sleep } from '@aztec/foundation/sleep';
|
|
5
5
|
import { DateProvider, Timer, executeTimeout } from '@aztec/foundation/timer';
|
|
6
|
-
import type { DataStoreConfig } from '@aztec/kv-store/config';
|
|
7
6
|
import { openTmpStore } from '@aztec/kv-store/lmdb-v2';
|
|
8
7
|
import type { L2BlockSource } from '@aztec/stdlib/block';
|
|
9
8
|
import type { ContractDataSource } from '@aztec/stdlib/contract';
|
|
10
9
|
import type { ClientProtocolCircuitVerifier } from '@aztec/stdlib/interfaces/server';
|
|
11
|
-
import {
|
|
10
|
+
import type { DataStoreConfig } from '@aztec/stdlib/kv-store';
|
|
11
|
+
import { PeerErrorSeverity } from '@aztec/stdlib/p2p';
|
|
12
12
|
import type { Tx, TxValidationResult } from '@aztec/stdlib/tx';
|
|
13
13
|
import { type TelemetryClient, getTelemetryClient } from '@aztec/telemetry-client';
|
|
14
14
|
|
|
@@ -16,14 +16,12 @@ import type { PeerId } from '@libp2p/interface';
|
|
|
16
16
|
import { peerIdFromString } from '@libp2p/peer-id';
|
|
17
17
|
|
|
18
18
|
import type { P2PConfig } from '../../../config.js';
|
|
19
|
+
import { BatchTxRequesterCollector, SendBatchRequestCollector } from '../../../services/index.js';
|
|
19
20
|
import type { IBatchRequestTxValidator } from '../../../services/reqresp/batch-tx-requester/tx_validator.js';
|
|
20
21
|
import { RateLimitStatus } from '../../../services/reqresp/rate-limiter/rate_limiter.js';
|
|
22
|
+
import { RequestTracker } from '../../../services/tx_collection/request_tracker.js';
|
|
21
23
|
import {
|
|
22
|
-
|
|
23
|
-
SendBatchRequestCollector,
|
|
24
|
-
} from '../../../services/tx_collection/proposal_tx_collector.js';
|
|
25
|
-
import { AlwaysTrueCircuitVerifier } from '../../../test-helpers/reqresp-nodes.js';
|
|
26
|
-
import {
|
|
24
|
+
AlwaysTrueCircuitVerifier,
|
|
27
25
|
BENCHMARK_CONSTANTS,
|
|
28
26
|
InMemoryAttestationPool,
|
|
29
27
|
InMemoryTxPool,
|
|
@@ -31,7 +29,7 @@ import {
|
|
|
31
29
|
calculateInternalTimeout,
|
|
32
30
|
createMockEpochCache,
|
|
33
31
|
createMockWorldStateSynchronizer,
|
|
34
|
-
} from '../../../test-helpers/
|
|
32
|
+
} from '../../../test-helpers/index.js';
|
|
35
33
|
import { createP2PClient } from '../../index.js';
|
|
36
34
|
import type { P2PClient } from '../../p2p_client.js';
|
|
37
35
|
import {
|
|
@@ -116,7 +114,6 @@ async function startClient(config: P2PConfig, clientIndex: number) {
|
|
|
116
114
|
};
|
|
117
115
|
|
|
118
116
|
client = await createP2PClient(
|
|
119
|
-
P2PClientType.Full,
|
|
120
117
|
config as P2PConfig & DataStoreConfig,
|
|
121
118
|
l2BlockSource as L2BlockSource & ContractDataSource,
|
|
122
119
|
proofVerifier as ClientProtocolCircuitVerifier,
|
|
@@ -214,7 +211,12 @@ async function runCollector(cmd: Extract<WorkerCommand, { type: 'RUN_COLLECTOR'
|
|
|
214
211
|
if (collectorType === 'batch-requester') {
|
|
215
212
|
const collector = new BatchTxRequesterCollector(p2pService, logger, new DateProvider(), noopTxValidator);
|
|
216
213
|
const fetched = await executeTimeout(
|
|
217
|
-
(_signal: AbortSignal) =>
|
|
214
|
+
(_signal: AbortSignal) =>
|
|
215
|
+
collector.collectTxs(
|
|
216
|
+
RequestTracker.create(parsedTxHashes, new Date(Date.now() + internalTimeoutMs)),
|
|
217
|
+
parsedProposal,
|
|
218
|
+
pinnedPeer,
|
|
219
|
+
),
|
|
218
220
|
timeoutMs,
|
|
219
221
|
() => new Error(`Collector timed out after ${timeoutMs}ms`),
|
|
220
222
|
);
|
|
@@ -226,7 +228,12 @@ async function runCollector(cmd: Extract<WorkerCommand, { type: 'RUN_COLLECTOR'
|
|
|
226
228
|
BENCHMARK_CONSTANTS.FIXED_MAX_RETRY_ATTEMPTS,
|
|
227
229
|
);
|
|
228
230
|
const fetched = await executeTimeout(
|
|
229
|
-
(_signal: AbortSignal) =>
|
|
231
|
+
(_signal: AbortSignal) =>
|
|
232
|
+
collector.collectTxs(
|
|
233
|
+
RequestTracker.create(parsedTxHashes, new Date(Date.now() + internalTimeoutMs)),
|
|
234
|
+
parsedProposal,
|
|
235
|
+
pinnedPeer,
|
|
236
|
+
),
|
|
230
237
|
timeoutMs,
|
|
231
238
|
() => new Error(`Collector timed out after ${timeoutMs}ms`),
|
|
232
239
|
);
|
|
@@ -252,9 +259,20 @@ async function stopClient() {
|
|
|
252
259
|
attestationPool = undefined;
|
|
253
260
|
}
|
|
254
261
|
|
|
262
|
+
function gracefulExit(code: number = 0) {
|
|
263
|
+
try {
|
|
264
|
+
if (process.connected) {
|
|
265
|
+
process.disconnect();
|
|
266
|
+
}
|
|
267
|
+
} catch {
|
|
268
|
+
// IPC channel already closed
|
|
269
|
+
}
|
|
270
|
+
setTimeout(() => process.exit(code), 5000).unref();
|
|
271
|
+
}
|
|
272
|
+
|
|
255
273
|
process.on('disconnect', () => {
|
|
256
274
|
ipcDisconnected = true;
|
|
257
|
-
void stopClient()
|
|
275
|
+
void stopClient();
|
|
258
276
|
});
|
|
259
277
|
|
|
260
278
|
process.on('error', err => {
|
|
@@ -318,7 +336,7 @@ process.on('message', (msg: WorkerCommand) => {
|
|
|
318
336
|
case 'STOP': {
|
|
319
337
|
await stopClient();
|
|
320
338
|
await sendMessage({ type: 'STOPPED', requestId });
|
|
321
|
-
|
|
339
|
+
gracefulExit(0);
|
|
322
340
|
break;
|
|
323
341
|
}
|
|
324
342
|
default: {
|
|
@@ -329,7 +347,8 @@ process.on('message', (msg: WorkerCommand) => {
|
|
|
329
347
|
} catch (err: any) {
|
|
330
348
|
await sendMessage({ type: 'ERROR', requestId, error: err?.message ?? String(err) });
|
|
331
349
|
if (msg.type === 'START') {
|
|
332
|
-
|
|
350
|
+
await stopClient();
|
|
351
|
+
gracefulExit(1);
|
|
333
352
|
}
|
|
334
353
|
}
|
|
335
354
|
})();
|