@aztec/p2p 0.0.1-commit.f504929 → 0.0.1-commit.f650c0a5c
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 +2 -2
- package/dest/client/factory.d.ts.map +1 -1
- package/dest/client/factory.js +25 -11
- package/dest/client/interface.d.ts +9 -2
- package/dest/client/interface.d.ts.map +1 -1
- package/dest/client/p2p_client.d.ts +3 -2
- package/dest/client/p2p_client.d.ts.map +1 -1
- package/dest/client/p2p_client.js +37 -36
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.js +17 -6
- package/dest/config.d.ts +24 -2
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +66 -7
- 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/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 +6 -5
- package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.js +6 -6
- package/dest/mem_pools/index.d.ts +1 -2
- package/dest/mem_pools/index.d.ts.map +1 -1
- 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 +2 -1
- package/dest/mem_pools/tx_pool_v2/eviction/interfaces.d.ts +7 -1
- package/dest/mem_pools/tx_pool_v2/eviction/interfaces.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.d.ts +1 -1
- 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 +8 -6
- package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.d.ts +2 -2
- 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 +2 -2
- package/dest/mem_pools/tx_pool_v2/interfaces.d.ts +9 -5
- package/dest/mem_pools/tx_pool_v2/interfaces.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/interfaces.js +2 -1
- package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts +25 -10
- package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/tx_metadata.js +38 -11
- package/dest/mem_pools/tx_pool_v2/tx_pool_indices.d.ts +1 -1
- 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 +26 -43
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts +4 -2
- 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 +3 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts +1 -1
- 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 +21 -6
- 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 +5 -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 +5 -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 +12 -9
- package/dest/msg_validators/proposal_validator/proposal_validator.d.ts.map +1 -1
- package/dest/msg_validators/proposal_validator/proposal_validator.js +51 -49
- package/dest/msg_validators/tx_validator/allowed_public_setup.d.ts +1 -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 +21 -32
- 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 +23 -4
- package/dest/msg_validators/tx_validator/factory.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/factory.js +36 -10
- 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 +13 -4
- package/dest/msg_validators/tx_validator/gas_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/gas_validator.js +49 -17
- package/dest/msg_validators/tx_validator/index.d.ts +2 -1
- package/dest/msg_validators/tx_validator/index.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/index.js +1 -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/phases_validator.d.ts +21 -1
- package/dest/msg_validators/tx_validator/phases_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/phases_validator.js +49 -2
- package/dest/services/dummy_service.d.ts +5 -3
- package/dest/services/dummy_service.d.ts.map +1 -1
- package/dest/services/dummy_service.js +5 -1
- package/dest/services/encoding.d.ts +5 -1
- package/dest/services/encoding.d.ts.map +1 -1
- package/dest/services/encoding.js +7 -1
- package/dest/services/libp2p/libp2p_service.d.ts +15 -25
- package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
- package/dest/services/libp2p/libp2p_service.js +149 -126
- 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 +22 -8
- package/dest/services/peer-manager/peer_scoring.d.ts +7 -2
- package/dest/services/peer-manager/peer_scoring.d.ts.map +1 -1
- package/dest/services/peer-manager/peer_scoring.js +32 -10
- package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts +11 -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 +69 -65
- package/dest/services/reqresp/batch-tx-requester/interface.d.ts +3 -2
- package/dest/services/reqresp/batch-tx-requester/interface.d.ts.map +1 -1
- package/dest/services/reqresp/batch-tx-requester/missing_txs.d.ts +5 -4
- package/dest/services/reqresp/batch-tx-requester/missing_txs.d.ts.map +1 -1
- package/dest/services/reqresp/batch-tx-requester/missing_txs.js +13 -7
- package/dest/services/reqresp/batch-tx-requester/peer_collection.d.ts +3 -1
- package/dest/services/reqresp/batch-tx-requester/peer_collection.d.ts.map +1 -1
- package/dest/services/reqresp/batch-tx-requester/peer_collection.js +3 -0
- package/dest/services/reqresp/interface.d.ts +1 -9
- package/dest/services/reqresp/interface.d.ts.map +1 -1
- package/dest/services/reqresp/interface.js +0 -11
- package/dest/services/reqresp/metrics.d.ts +1 -1
- package/dest/services/reqresp/metrics.d.ts.map +1 -1
- package/dest/services/reqresp/metrics.js +0 -1
- package/dest/services/reqresp/protocols/index.d.ts +1 -2
- package/dest/services/reqresp/protocols/index.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/index.js +0 -1
- package/dest/services/reqresp/protocols/tx.d.ts +1 -1
- package/dest/services/reqresp/protocols/tx.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/tx.js +1 -3
- package/dest/services/reqresp/rate-limiter/rate_limiter.d.ts +5 -4
- package/dest/services/reqresp/rate-limiter/rate_limiter.d.ts.map +1 -1
- package/dest/services/reqresp/rate-limiter/rate_limiter.js +10 -8
- package/dest/services/reqresp/rate-limiter/rate_limits.d.ts +1 -1
- package/dest/services/reqresp/rate-limiter/rate_limits.d.ts.map +1 -1
- package/dest/services/reqresp/rate-limiter/rate_limits.js +0 -10
- package/dest/services/reqresp/reqresp.d.ts +1 -1
- package/dest/services/reqresp/reqresp.d.ts.map +1 -1
- package/dest/services/reqresp/reqresp.js +18 -10
- package/dest/services/service.d.ts +5 -2
- 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 +57 -73
- package/dest/services/tx_collection/file_store_tx_source.d.ts +5 -4
- package/dest/services/tx_collection/file_store_tx_source.d.ts.map +1 -1
- package/dest/services/tx_collection/file_store_tx_source.js +39 -29
- package/dest/services/tx_collection/proposal_tx_collector.d.ts +6 -7
- package/dest/services/tx_collection/proposal_tx_collector.d.ts.map +1 -1
- package/dest/services/tx_collection/proposal_tx_collector.js +4 -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.js +1 -1
- package/dest/services/tx_collection/tx_collection.d.ts +3 -6
- package/dest/services/tx_collection/tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/tx_source.d.ts +6 -5
- package/dest/services/tx_collection/tx_source.d.ts.map +1 -1
- package/dest/services/tx_collection/tx_source.js +9 -7
- package/dest/test-helpers/make-test-p2p-clients.d.ts +1 -1
- package/dest/test-helpers/make-test-p2p-clients.d.ts.map +1 -1
- package/dest/test-helpers/reqresp-nodes.d.ts +1 -1
- package/dest/test-helpers/reqresp-nodes.d.ts.map +1 -1
- package/dest/test-helpers/reqresp-nodes.js +0 -2
- package/dest/test-helpers/testbench-utils.d.ts +1 -1
- package/dest/test-helpers/testbench-utils.d.ts.map +1 -1
- package/dest/test-helpers/testbench-utils.js +23 -3
- package/dest/testbench/p2p_client_testbench_worker.js +68 -16
- 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 +1 -1
- package/package.json +14 -14
- package/src/client/factory.ts +43 -14
- package/src/client/interface.ts +9 -1
- package/src/client/p2p_client.ts +39 -36
- package/src/client/test/tx_proposal_collector/proposal_tx_collector_worker.ts +19 -9
- package/src/config.ts +92 -4
- package/src/errors/p2p-service.error.ts +11 -0
- package/src/index.ts +0 -1
- package/src/mem_pools/attestation_pool/attestation_pool.ts +7 -5
- package/src/mem_pools/attestation_pool/attestation_pool_test_suite.ts +6 -6
- package/src/mem_pools/index.ts +0 -3
- package/src/mem_pools/tx_pool_v2/README.md +9 -1
- package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.ts +2 -1
- package/src/mem_pools/tx_pool_v2/eviction/interfaces.ts +11 -1
- package/src/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.ts +15 -6
- package/src/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.ts +2 -1
- package/src/mem_pools/tx_pool_v2/interfaces.ts +9 -4
- package/src/mem_pools/tx_pool_v2/tx_metadata.ts +59 -13
- package/src/mem_pools/tx_pool_v2/tx_pool_indices.ts +29 -43
- package/src/mem_pools/tx_pool_v2/tx_pool_v2.ts +13 -1
- package/src/mem_pools/tx_pool_v2/tx_pool_v2_impl.ts +23 -6
- 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 +13 -3
- package/src/msg_validators/proposal_validator/checkpoint_proposal_validator.ts +19 -6
- package/src/msg_validators/proposal_validator/proposal_validator.ts +63 -53
- package/src/msg_validators/tx_validator/README.md +5 -1
- package/src/msg_validators/tx_validator/allowed_public_setup.ts +16 -35
- 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 +43 -3
- package/src/msg_validators/tx_validator/fee_payer_balance.ts +6 -2
- package/src/msg_validators/tx_validator/gas_validator.ts +65 -16
- package/src/msg_validators/tx_validator/index.ts +1 -0
- package/src/msg_validators/tx_validator/metadata_validator.ts +12 -4
- package/src/msg_validators/tx_validator/phases_validator.ts +60 -1
- package/src/services/dummy_service.ts +7 -2
- package/src/services/encoding.ts +9 -1
- package/src/services/libp2p/libp2p_service.ts +148 -140
- package/src/services/peer-manager/peer_manager.ts +26 -8
- package/src/services/peer-manager/peer_scoring.ts +27 -5
- package/src/services/reqresp/README.md +229 -0
- package/src/services/reqresp/batch-tx-requester/README.md +46 -7
- package/src/services/reqresp/batch-tx-requester/batch_tx_requester.ts +64 -69
- package/src/services/reqresp/batch-tx-requester/interface.ts +2 -1
- package/src/services/reqresp/batch-tx-requester/missing_txs.ts +13 -6
- package/src/services/reqresp/batch-tx-requester/peer_collection.ts +5 -0
- package/src/services/reqresp/interface.ts +0 -11
- package/src/services/reqresp/metrics.ts +0 -1
- package/src/services/reqresp/protocols/index.ts +0 -1
- package/src/services/reqresp/protocols/tx.ts +1 -3
- package/src/services/reqresp/rate-limiter/rate_limiter.ts +13 -9
- package/src/services/reqresp/rate-limiter/rate_limits.ts +0 -10
- package/src/services/reqresp/reqresp.ts +20 -12
- package/src/services/service.ts +6 -1
- package/src/services/tx_collection/fast_tx_collection.ts +57 -83
- package/src/services/tx_collection/file_store_tx_source.ts +43 -31
- package/src/services/tx_collection/proposal_tx_collector.ts +8 -13
- package/src/services/tx_collection/request_tracker.ts +127 -0
- package/src/services/tx_collection/slow_tx_collection.ts +1 -1
- package/src/services/tx_collection/tx_collection.ts +3 -5
- package/src/services/tx_collection/tx_source.ts +8 -7
- package/src/test-helpers/make-test-p2p-clients.ts +1 -1
- package/src/test-helpers/reqresp-nodes.ts +1 -3
- package/src/test-helpers/testbench-utils.ts +30 -3
- package/src/testbench/p2p_client_testbench_worker.ts +72 -15
- package/src/testbench/worker_client_manager.ts +68 -6
- package/src/util.ts +1 -1
- 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 -24
- 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 -378
- 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/dest/services/tx_collection/missing_txs_tracker.d.ts +0 -32
- package/dest/services/tx_collection/missing_txs_tracker.d.ts.map +0 -1
- package/dest/services/tx_collection/missing_txs_tracker.js +0 -27
- 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 -373
- package/src/services/reqresp/protocols/block.ts +0 -37
- package/src/services/tx_collection/missing_txs_tracker.ts +0 -52
|
@@ -23,7 +23,7 @@ import { peerIdFromString } from '@libp2p/peer-id';
|
|
|
23
23
|
import { createP2PClient } from '../index.js';
|
|
24
24
|
import { BatchTxRequesterCollector, LibP2PService, SendBatchRequestCollector } from '../services/index.js';
|
|
25
25
|
import { RateLimitStatus } from '../services/reqresp/rate-limiter/rate_limiter.js';
|
|
26
|
-
import {
|
|
26
|
+
import { RequestTracker } from '../services/tx_collection/request_tracker.js';
|
|
27
27
|
import { AlwaysTrueCircuitVerifier } from '../test-helpers/index.js';
|
|
28
28
|
import { BENCHMARK_CONSTANTS, InMemoryAttestationPool, InMemoryTxPool, UNLIMITED_RATE_LIMIT_QUOTA, createMockEpochCache, createMockWorldStateSynchronizer, filterTxsByDistribution } from '../test-helpers/index.js';
|
|
29
29
|
export { COLLECTOR_DISPLAY_NAMES } from '../test-helpers/testbench-utils.js';
|
|
@@ -110,6 +110,21 @@ function installUnlimitedRateLimits(client) {
|
|
|
110
110
|
rateLimiter.getRateLimits = ()=>UNLIMITED_RATE_LIMIT_QUOTA;
|
|
111
111
|
rateLimiter.allow = ()=>RateLimitStatus.Allowed;
|
|
112
112
|
}
|
|
113
|
+
/** Resets peer scores to prevent cross-case contamination in benchmarks. */ function resetPeerScores(client) {
|
|
114
|
+
const peerManager = client.p2pService.peerManager;
|
|
115
|
+
const peerScoring = peerManager?.peerScoring;
|
|
116
|
+
if (peerScoring?.resetAllScores) {
|
|
117
|
+
peerScoring.resetAllScores();
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
/** Returns the number of connected peers for connectivity checks. */ function getConnectedPeerCount(client) {
|
|
121
|
+
const p2pService = client.p2pService;
|
|
122
|
+
const connectionSampler = p2pService?.reqresp?.getConnectionSampler?.();
|
|
123
|
+
if (connectionSampler?.getPeerListSortedByConnectionCountAsc) {
|
|
124
|
+
return connectionSampler.getPeerListSortedByConnectionCountAsc().length;
|
|
125
|
+
}
|
|
126
|
+
return 0;
|
|
127
|
+
}
|
|
113
128
|
async function runAggregatorBenchmark(client, blockProposal, collectorType, timeoutMs, pinnedPeerId, pinnedPeerIndex, logger, expectedPeerCount) {
|
|
114
129
|
let timer = new Timer();
|
|
115
130
|
try {
|
|
@@ -154,7 +169,7 @@ async function runAggregatorBenchmark(client, blockProposal, collectorType, time
|
|
|
154
169
|
timer = new Timer();
|
|
155
170
|
if (collectorType === 'batch-requester') {
|
|
156
171
|
const collector = new BatchTxRequesterCollector(batchTxRequesterService, logger, new DateProvider(), noopTxValidator);
|
|
157
|
-
const fetchedTxs = await collector.collectTxs(
|
|
172
|
+
const fetchedTxs = await collector.collectTxs(RequestTracker.create(txHashes, new Date(Date.now() + timeoutMs)), blockProposal, pinnedPeer);
|
|
158
173
|
const durationMs = timer.ms();
|
|
159
174
|
return {
|
|
160
175
|
type: 'BENCH_RESULT',
|
|
@@ -164,7 +179,7 @@ async function runAggregatorBenchmark(client, blockProposal, collectorType, time
|
|
|
164
179
|
};
|
|
165
180
|
}
|
|
166
181
|
const collector = new SendBatchRequestCollector(batchTxRequesterService, BENCHMARK_CONSTANTS.FIXED_MAX_PEERS, BENCHMARK_CONSTANTS.FIXED_MAX_RETRY_ATTEMPTS);
|
|
167
|
-
const fetchedTxs = await collector.collectTxs(
|
|
182
|
+
const fetchedTxs = await collector.collectTxs(RequestTracker.create(txHashes, new Date(Date.now() + timeoutMs)), blockProposal, pinnedPeer);
|
|
168
183
|
const durationMs = timer.ms();
|
|
169
184
|
return {
|
|
170
185
|
type: 'BENCH_RESULT',
|
|
@@ -188,6 +203,35 @@ let workerAttestationPool = null;
|
|
|
188
203
|
let workerConfig = null;
|
|
189
204
|
let workerLogger = null;
|
|
190
205
|
let kvStore = null;
|
|
206
|
+
async function stopWorker() {
|
|
207
|
+
try {
|
|
208
|
+
if (workerClient) {
|
|
209
|
+
await workerClient.stop();
|
|
210
|
+
workerClient = null;
|
|
211
|
+
}
|
|
212
|
+
} catch (e) {
|
|
213
|
+
workerLogger?.error('Error stopping worker client', e);
|
|
214
|
+
}
|
|
215
|
+
try {
|
|
216
|
+
if (kvStore?.close) {
|
|
217
|
+
await kvStore.close();
|
|
218
|
+
kvStore = null;
|
|
219
|
+
}
|
|
220
|
+
} catch (e) {
|
|
221
|
+
workerLogger?.error('Error closing kv store', e);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
function gracefulExit(code = 0) {
|
|
225
|
+
try {
|
|
226
|
+
if (process.connected) {
|
|
227
|
+
process.disconnect();
|
|
228
|
+
}
|
|
229
|
+
} catch {
|
|
230
|
+
// IPC channel already closed
|
|
231
|
+
}
|
|
232
|
+
// Safety fallback if lingering handles prevent the event loop from draining
|
|
233
|
+
setTimeout(()=>process.exit(code), 5000).unref();
|
|
234
|
+
}
|
|
191
235
|
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
|
192
236
|
process.on('message', async (msg)=>{
|
|
193
237
|
const { type, config: rawConfig, clientIndex } = msg;
|
|
@@ -195,7 +239,8 @@ process.on('message', async (msg)=>{
|
|
|
195
239
|
if (type === 'START') {
|
|
196
240
|
const config = {
|
|
197
241
|
...rawConfig,
|
|
198
|
-
peerIdPrivateKey: rawConfig.peerIdPrivateKey ? new SecretValue(rawConfig.peerIdPrivateKey) : undefined
|
|
242
|
+
peerIdPrivateKey: rawConfig.peerIdPrivateKey ? new SecretValue(rawConfig.peerIdPrivateKey) : undefined,
|
|
243
|
+
priceBumpPercentage: 10n
|
|
199
244
|
};
|
|
200
245
|
workerConfig = config;
|
|
201
246
|
workerTxPool = new InMemoryTxPool();
|
|
@@ -237,13 +282,8 @@ process.on('message', async (msg)=>{
|
|
|
237
282
|
const cmd = msg;
|
|
238
283
|
switch(cmd.type){
|
|
239
284
|
case 'STOP':
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
}
|
|
243
|
-
if (kvStore?.close) {
|
|
244
|
-
await kvStore.close();
|
|
245
|
-
}
|
|
246
|
-
process.exit(0);
|
|
285
|
+
await stopWorker();
|
|
286
|
+
gracefulExit(0);
|
|
247
287
|
break;
|
|
248
288
|
case 'SEND_TX':
|
|
249
289
|
if (workerClient) {
|
|
@@ -253,6 +293,12 @@ process.on('message', async (msg)=>{
|
|
|
253
293
|
});
|
|
254
294
|
}
|
|
255
295
|
break;
|
|
296
|
+
case 'GET_PEER_COUNT':
|
|
297
|
+
process.send({
|
|
298
|
+
type: 'PEER_COUNT',
|
|
299
|
+
count: workerClient ? getConnectedPeerCount(workerClient) : 0
|
|
300
|
+
});
|
|
301
|
+
break;
|
|
256
302
|
case 'BENCH_REQRESP':
|
|
257
303
|
{
|
|
258
304
|
const benchCmd = cmd;
|
|
@@ -269,6 +315,7 @@ process.on('message', async (msg)=>{
|
|
|
269
315
|
// Reset state before each benchmark run to avoid cross-run contamination
|
|
270
316
|
workerTxPool.resetState();
|
|
271
317
|
workerAttestationPool.resetState();
|
|
318
|
+
resetPeerScores(workerClient);
|
|
272
319
|
installUnlimitedRateLimits(workerClient);
|
|
273
320
|
const allTxs = await generateDeterministicTxs(benchCmd.txCount, benchCmd.seed, workerConfig);
|
|
274
321
|
const txHashes = allTxs.map((tx)=>tx.getTxHash());
|
|
@@ -292,10 +339,15 @@ process.on('message', async (msg)=>{
|
|
|
292
339
|
}
|
|
293
340
|
}
|
|
294
341
|
} catch (err) {
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
342
|
+
try {
|
|
343
|
+
process.send({
|
|
344
|
+
type: 'ERROR',
|
|
345
|
+
error: err.message
|
|
346
|
+
});
|
|
347
|
+
} catch {
|
|
348
|
+
// IPC channel may be closed
|
|
349
|
+
}
|
|
350
|
+
await stopWorker();
|
|
351
|
+
gracefulExit(1);
|
|
300
352
|
}
|
|
301
353
|
});
|
|
@@ -38,6 +38,8 @@ declare class WorkerClientManager {
|
|
|
38
38
|
* Note: We send the raw peerIdPrivateKey string instead of SecretValue
|
|
39
39
|
* because SecretValue.toJSON() returns '[Redacted]', losing the value.
|
|
40
40
|
* The worker must re-wrap it in SecretValue.
|
|
41
|
+
* We also omit priceBumpPercentage since it's a bigint and can't be
|
|
42
|
+
* serialized over IPC (which uses JSON under the hood).
|
|
41
43
|
*/
|
|
42
44
|
private createClientConfig;
|
|
43
45
|
/**
|
|
@@ -76,6 +78,13 @@ declare class WorkerClientManager {
|
|
|
76
78
|
* Cleans up all worker processes with timeout and force kill if needed
|
|
77
79
|
*/
|
|
78
80
|
cleanup(): Promise<void>;
|
|
81
|
+
/**
|
|
82
|
+
* Checks that the aggregator (client 0) has sufficient peer connections before running a benchmark.
|
|
83
|
+
* This prevents benchmark cases from starting with degraded connectivity after a previous case
|
|
84
|
+
* caused connection failures.
|
|
85
|
+
*/
|
|
86
|
+
waitForConnectivity(minPeers: number, timeoutMs?: number): Promise<number>;
|
|
87
|
+
private getPeerCount;
|
|
79
88
|
/**
|
|
80
89
|
* Run a req/resp benchmark across all worker clients.
|
|
81
90
|
*
|
|
@@ -93,4 +102,4 @@ declare class WorkerClientManager {
|
|
|
93
102
|
export { WorkerClientManager, testChainConfig };
|
|
94
103
|
export type { DistributionPattern, CollectorType } from './p2p_client_testbench_worker.js';
|
|
95
104
|
export { COLLECTOR_DISPLAY_NAMES } from './p2p_client_testbench_worker.js';
|
|
96
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
105
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoid29ya2VyX2NsaWVudF9tYW5hZ2VyLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvdGVzdGJlbmNoL3dvcmtlcl9jbGllbnRfbWFuYWdlci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFDQSxPQUFPLEtBQUssRUFBRSxNQUFNLEVBQUUsTUFBTSx1QkFBdUIsQ0FBQztBQUVwRCxPQUFPLEtBQUssRUFBRSxXQUFXLEVBQUUsTUFBTSxzQkFBc0IsQ0FBQztBQUV4RCxPQUFPLEVBQU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AQ,EAAE,MAAM,EAAE,SAAS,GAAE,MAAe,GAAG,OAAO,CAAC,MAAM,CAAC,CAkBvF;IAED,OAAO,CAAC,YAAY;IA8BpB;;;;;;;;;OASG;IACG,mBAAmB,CAAC,MAAM,EAAE,sBAAsB,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAuEzF;IAED,OAAO,CAAC,iBAAiB;IAkCzB,OAAO,CAAC,kBAAkB;CAiC3B;AAED,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,CAAC;AAChD,YAAY,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AAC3F,OAAO,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAC"}
|
|
@@ -37,7 +37,6 @@ class WorkerClientManager {
|
|
|
37
37
|
destroy() {
|
|
38
38
|
this.cleanup().catch((error)=>{
|
|
39
39
|
this.logger.error('Failed to cleanup worker client manager', error);
|
|
40
|
-
process.exit(1);
|
|
41
40
|
});
|
|
42
41
|
}
|
|
43
42
|
/**
|
|
@@ -45,8 +44,10 @@ class WorkerClientManager {
|
|
|
45
44
|
* Note: We send the raw peerIdPrivateKey string instead of SecretValue
|
|
46
45
|
* because SecretValue.toJSON() returns '[Redacted]', losing the value.
|
|
47
46
|
* The worker must re-wrap it in SecretValue.
|
|
47
|
+
* We also omit priceBumpPercentage since it's a bigint and can't be
|
|
48
|
+
* serialized over IPC (which uses JSON under the hood).
|
|
48
49
|
*/ createClientConfig(clientIndex, port, otherNodes) {
|
|
49
|
-
|
|
50
|
+
const { priceBumpPercentage: _, ...config } = {
|
|
50
51
|
...getP2PDefaultConfig(),
|
|
51
52
|
p2pEnabled: true,
|
|
52
53
|
peerIdPrivateKey: this.peerIdPrivateKeys[clientIndex],
|
|
@@ -58,6 +59,7 @@ class WorkerClientManager {
|
|
|
58
59
|
],
|
|
59
60
|
...this.p2pConfig
|
|
60
61
|
};
|
|
62
|
+
return config;
|
|
61
63
|
}
|
|
62
64
|
/**
|
|
63
65
|
* Spawns a worker process and returns a promise that resolves when the worker is ready.
|
|
@@ -315,6 +317,55 @@ class WorkerClientManager {
|
|
|
315
317
|
this.logger.info('All worker processes cleaned up');
|
|
316
318
|
}
|
|
317
319
|
/**
|
|
320
|
+
* Checks that the aggregator (client 0) has sufficient peer connections before running a benchmark.
|
|
321
|
+
* This prevents benchmark cases from starting with degraded connectivity after a previous case
|
|
322
|
+
* caused connection failures.
|
|
323
|
+
*/ async waitForConnectivity(minPeers, timeoutMs = 15_000) {
|
|
324
|
+
const waitInterval = 1000;
|
|
325
|
+
let waited = 0;
|
|
326
|
+
while(waited < timeoutMs){
|
|
327
|
+
const count = await this.getPeerCount(0, 5000);
|
|
328
|
+
if (count >= minPeers) {
|
|
329
|
+
this.logger.info(`Connectivity check passed: ${count}/${minPeers} peers connected`);
|
|
330
|
+
return count;
|
|
331
|
+
}
|
|
332
|
+
this.logger.debug(`Waiting for connectivity: ${count}/${minPeers} (waited ${waited}ms)`);
|
|
333
|
+
await sleep(waitInterval);
|
|
334
|
+
waited += waitInterval;
|
|
335
|
+
}
|
|
336
|
+
const finalCount = await this.getPeerCount(0, 5000);
|
|
337
|
+
this.logger.warn(`Connectivity check: only ${finalCount}/${minPeers} peers after ${timeoutMs}ms`);
|
|
338
|
+
return finalCount;
|
|
339
|
+
}
|
|
340
|
+
getPeerCount(clientIndex, timeoutMs) {
|
|
341
|
+
return new Promise((resolve)=>{
|
|
342
|
+
let resolved = false;
|
|
343
|
+
const handler = (msg)=>{
|
|
344
|
+
if (resolved) {
|
|
345
|
+
return;
|
|
346
|
+
}
|
|
347
|
+
if (msg.type === 'PEER_COUNT') {
|
|
348
|
+
resolved = true;
|
|
349
|
+
clearTimeout(timeout);
|
|
350
|
+
this.processes[clientIndex].off('message', handler);
|
|
351
|
+
resolve(msg.count);
|
|
352
|
+
}
|
|
353
|
+
};
|
|
354
|
+
const timeout = setTimeout(()=>{
|
|
355
|
+
if (resolved) {
|
|
356
|
+
return;
|
|
357
|
+
}
|
|
358
|
+
resolved = true;
|
|
359
|
+
this.processes[clientIndex].off('message', handler);
|
|
360
|
+
resolve(0);
|
|
361
|
+
}, timeoutMs);
|
|
362
|
+
this.processes[clientIndex].on('message', handler);
|
|
363
|
+
this.processes[clientIndex].send({
|
|
364
|
+
type: 'GET_PEER_COUNT'
|
|
365
|
+
});
|
|
366
|
+
});
|
|
367
|
+
}
|
|
368
|
+
/**
|
|
318
369
|
* Run a req/resp benchmark across all worker clients.
|
|
319
370
|
*
|
|
320
371
|
* This sends a BENCH_REQRESP command to all workers:
|
|
@@ -368,7 +419,8 @@ class WorkerClientManager {
|
|
|
368
419
|
seed
|
|
369
420
|
};
|
|
370
421
|
this.processes[0].send(aggregatorCmd);
|
|
371
|
-
const
|
|
422
|
+
const aggregatorBudgetMs = config.timeoutMs + BENCHMARK_CONSTANTS.MAX_PEER_WAIT_MS + 30000;
|
|
423
|
+
const result = await this.waitForBenchResult(0, aggregatorBudgetMs);
|
|
372
424
|
this.logger.info(`Benchmark complete: fetched=${result.fetchedCount}/${config.txCount}, duration=${result.durationMs.toFixed(0)}ms, success=${result.success}`);
|
|
373
425
|
return {
|
|
374
426
|
txCount: config.txCount,
|
package/dest/util.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { SecretValue } from '@aztec/foundation/config';
|
|
2
2
|
import type { Logger } from '@aztec/foundation/log';
|
|
3
3
|
import type { AztecAsyncKVStore } from '@aztec/kv-store';
|
|
4
|
-
import type { DataStoreConfig } from '@aztec/kv-store
|
|
4
|
+
import type { DataStoreConfig } from '@aztec/stdlib/kv-store';
|
|
5
5
|
import type { GossipSub } from '@chainsafe/libp2p-gossipsub';
|
|
6
6
|
import type { Identify } from '@libp2p/identify';
|
|
7
7
|
import type { PeerId } from '@libp2p/interface';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/p2p",
|
|
3
|
-
"version": "0.0.1-commit.
|
|
3
|
+
"version": "0.0.1-commit.f650c0a5c",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dest/index.js",
|
|
@@ -67,17 +67,17 @@
|
|
|
67
67
|
]
|
|
68
68
|
},
|
|
69
69
|
"dependencies": {
|
|
70
|
-
"@aztec/constants": "0.0.1-commit.
|
|
71
|
-
"@aztec/epoch-cache": "0.0.1-commit.
|
|
72
|
-
"@aztec/ethereum": "0.0.1-commit.
|
|
73
|
-
"@aztec/foundation": "0.0.1-commit.
|
|
74
|
-
"@aztec/kv-store": "0.0.1-commit.
|
|
75
|
-
"@aztec/noir-contracts.js": "0.0.1-commit.
|
|
76
|
-
"@aztec/noir-protocol-circuits-types": "0.0.1-commit.
|
|
77
|
-
"@aztec/protocol-contracts": "0.0.1-commit.
|
|
78
|
-
"@aztec/simulator": "0.0.1-commit.
|
|
79
|
-
"@aztec/stdlib": "0.0.1-commit.
|
|
80
|
-
"@aztec/telemetry-client": "0.0.1-commit.
|
|
70
|
+
"@aztec/constants": "0.0.1-commit.f650c0a5c",
|
|
71
|
+
"@aztec/epoch-cache": "0.0.1-commit.f650c0a5c",
|
|
72
|
+
"@aztec/ethereum": "0.0.1-commit.f650c0a5c",
|
|
73
|
+
"@aztec/foundation": "0.0.1-commit.f650c0a5c",
|
|
74
|
+
"@aztec/kv-store": "0.0.1-commit.f650c0a5c",
|
|
75
|
+
"@aztec/noir-contracts.js": "0.0.1-commit.f650c0a5c",
|
|
76
|
+
"@aztec/noir-protocol-circuits-types": "0.0.1-commit.f650c0a5c",
|
|
77
|
+
"@aztec/protocol-contracts": "0.0.1-commit.f650c0a5c",
|
|
78
|
+
"@aztec/simulator": "0.0.1-commit.f650c0a5c",
|
|
79
|
+
"@aztec/stdlib": "0.0.1-commit.f650c0a5c",
|
|
80
|
+
"@aztec/telemetry-client": "0.0.1-commit.f650c0a5c",
|
|
81
81
|
"@chainsafe/libp2p-gossipsub": "13.0.0",
|
|
82
82
|
"@chainsafe/libp2p-noise": "^15.0.0",
|
|
83
83
|
"@chainsafe/libp2p-yamux": "^6.0.2",
|
|
@@ -104,8 +104,8 @@
|
|
|
104
104
|
"xxhash-wasm": "^1.1.0"
|
|
105
105
|
},
|
|
106
106
|
"devDependencies": {
|
|
107
|
-
"@aztec/archiver": "0.0.1-commit.
|
|
108
|
-
"@aztec/world-state": "0.0.1-commit.
|
|
107
|
+
"@aztec/archiver": "0.0.1-commit.f650c0a5c",
|
|
108
|
+
"@aztec/world-state": "0.0.1-commit.f650c0a5c",
|
|
109
109
|
"@jest/globals": "^30.0.0",
|
|
110
110
|
"@types/jest": "^30.0.0",
|
|
111
111
|
"@types/node": "^22.15.17",
|
package/src/client/factory.ts
CHANGED
|
@@ -3,12 +3,12 @@ import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
|
3
3
|
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
4
4
|
import { DateProvider } from '@aztec/foundation/timer';
|
|
5
5
|
import type { AztecAsyncKVStore } from '@aztec/kv-store';
|
|
6
|
-
import type { DataStoreConfig } from '@aztec/kv-store/config';
|
|
7
6
|
import { AztecLMDBStoreV2, createStore } from '@aztec/kv-store/lmdb-v2';
|
|
8
7
|
import type { L2BlockSource } from '@aztec/stdlib/block';
|
|
9
8
|
import type { ChainConfig } from '@aztec/stdlib/config';
|
|
10
9
|
import type { ContractDataSource } from '@aztec/stdlib/contract';
|
|
11
10
|
import type { AztecNode, ClientProtocolCircuitVerifier, WorldStateSynchronizer } from '@aztec/stdlib/interfaces/server';
|
|
11
|
+
import type { DataStoreConfig } from '@aztec/stdlib/kv-store';
|
|
12
12
|
import { type TelemetryClient, getTelemetryClient } from '@aztec/telemetry-client';
|
|
13
13
|
|
|
14
14
|
import { P2PClient } from '../client/p2p_client.js';
|
|
@@ -17,7 +17,12 @@ import { AttestationPool, type AttestationPoolApi } from '../mem_pools/attestati
|
|
|
17
17
|
import type { MemPools } from '../mem_pools/interface.js';
|
|
18
18
|
import type { TxPoolV2 } from '../mem_pools/tx_pool_v2/interfaces.js';
|
|
19
19
|
import { AztecKVTxPoolV2 } from '../mem_pools/tx_pool_v2/tx_pool_v2.js';
|
|
20
|
-
import {
|
|
20
|
+
import {
|
|
21
|
+
createCheckAllowedSetupCalls,
|
|
22
|
+
createTxValidatorForReqResponseReceivedTxs,
|
|
23
|
+
createTxValidatorForTransactionsEnteringPendingTxPool,
|
|
24
|
+
getDefaultAllowedSetupFunctions,
|
|
25
|
+
} from '../msg_validators/index.js';
|
|
21
26
|
import { DummyP2PService } from '../services/dummy_service.js';
|
|
22
27
|
import { LibP2PService } from '../services/index.js';
|
|
23
28
|
import { createFileStoreTxSources } from '../services/tx_collection/file_store_tx_source.js';
|
|
@@ -75,6 +80,33 @@ export async function createP2PClient(
|
|
|
75
80
|
const rollupAddress = inputConfig.l1Contracts.rollupAddress.toString().toLowerCase().replace(/^0x/, '');
|
|
76
81
|
const txFileStoreBasePath = `aztec-${inputConfig.l1ChainId}-${inputConfig.rollupVersion}-0x${rollupAddress}`;
|
|
77
82
|
|
|
83
|
+
const allowedInSetup = [
|
|
84
|
+
...(await getDefaultAllowedSetupFunctions()),
|
|
85
|
+
...(inputConfig.txPublicSetupAllowListExtend ?? []),
|
|
86
|
+
];
|
|
87
|
+
const checkAllowedSetupCalls = createCheckAllowedSetupCalls(
|
|
88
|
+
archiver,
|
|
89
|
+
allowedInSetup,
|
|
90
|
+
() => epochCache.getEpochAndSlotInNextL1Slot().ts,
|
|
91
|
+
);
|
|
92
|
+
|
|
93
|
+
const createTxValidator = async () => {
|
|
94
|
+
// We accept transactions if they are not expired by the next slot and block number (checked based on the ExpirationTimestamp field)
|
|
95
|
+
const currentBlockNumber = await archiver.getBlockNumber();
|
|
96
|
+
const { ts: nextSlotTimestamp } = epochCache.getEpochAndSlotInNextL1Slot();
|
|
97
|
+
const l1Constants = await archiver.getL1Constants();
|
|
98
|
+
return createTxValidatorForTransactionsEnteringPendingTxPool(
|
|
99
|
+
worldStateSynchronizer,
|
|
100
|
+
nextSlotTimestamp,
|
|
101
|
+
BlockNumber(currentBlockNumber + 1),
|
|
102
|
+
{
|
|
103
|
+
rollupManaLimit: l1Constants.rollupManaLimit,
|
|
104
|
+
maxBlockL2Gas: config.validateMaxL2BlockGas,
|
|
105
|
+
maxBlockDAGas: config.validateMaxDABlockGas,
|
|
106
|
+
},
|
|
107
|
+
);
|
|
108
|
+
};
|
|
109
|
+
|
|
78
110
|
const txPool =
|
|
79
111
|
deps.txPool ??
|
|
80
112
|
new AztecKVTxPoolV2(
|
|
@@ -83,16 +115,8 @@ export async function createP2PClient(
|
|
|
83
115
|
{
|
|
84
116
|
l2BlockSource: archiver,
|
|
85
117
|
worldStateSynchronizer,
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
const currentBlockNumber = await archiver.getBlockNumber();
|
|
89
|
-
const { ts: nextSlotTimestamp } = epochCache.getEpochAndSlotInNextL1Slot();
|
|
90
|
-
return createTxValidatorForTransactionsEnteringPendingTxPool(
|
|
91
|
-
worldStateSynchronizer,
|
|
92
|
-
nextSlotTimestamp,
|
|
93
|
-
BlockNumber(currentBlockNumber + 1),
|
|
94
|
-
);
|
|
95
|
-
},
|
|
118
|
+
checkAllowedSetupCalls,
|
|
119
|
+
createTxValidator,
|
|
96
120
|
},
|
|
97
121
|
telemetry,
|
|
98
122
|
{
|
|
@@ -100,6 +124,7 @@ export async function createP2PClient(
|
|
|
100
124
|
archivedTxLimit: config.archivedTxLimit,
|
|
101
125
|
minTxPoolAgeMs: config.minTxPoolAgeMs,
|
|
102
126
|
dropTransactionsProbability: config.dropTransactionsProbability,
|
|
127
|
+
priceBumpPercentage: config.priceBumpPercentage,
|
|
103
128
|
},
|
|
104
129
|
dateProvider,
|
|
105
130
|
);
|
|
@@ -124,9 +149,12 @@ export async function createP2PClient(
|
|
|
124
149
|
telemetry,
|
|
125
150
|
);
|
|
126
151
|
|
|
152
|
+
const txValidatorForTxCollection = createTxValidatorForReqResponseReceivedTxs(proofVerifier, config);
|
|
127
153
|
const nodeSources = [
|
|
128
|
-
...createNodeRpcTxSources(config.txCollectionNodeRpcUrls, config),
|
|
129
|
-
...(deps.rpcTxProviders ?? []).map(
|
|
154
|
+
...createNodeRpcTxSources(config.txCollectionNodeRpcUrls, txValidatorForTxCollection, config),
|
|
155
|
+
...(deps.rpcTxProviders ?? []).map(
|
|
156
|
+
(node, i) => new NodeRpcTxSource(node, txValidatorForTxCollection, `node-rpc-provider-${i}`),
|
|
157
|
+
),
|
|
130
158
|
...(deps.txCollectionNodeSources ?? []),
|
|
131
159
|
];
|
|
132
160
|
if (nodeSources.length > 0) {
|
|
@@ -138,6 +166,7 @@ export async function createP2PClient(
|
|
|
138
166
|
const fileStoreSources = await createFileStoreTxSources(
|
|
139
167
|
config.txCollectionFileStoreUrls,
|
|
140
168
|
txFileStoreBasePath,
|
|
169
|
+
txValidatorForTxCollection,
|
|
141
170
|
logger.createChild('file-store-tx-source'),
|
|
142
171
|
telemetry,
|
|
143
172
|
);
|
package/src/client/interface.ts
CHANGED
|
@@ -82,7 +82,15 @@ export type P2P = P2PClient & {
|
|
|
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).
|
package/src/client/p2p_client.ts
CHANGED
|
@@ -18,7 +18,6 @@ import {
|
|
|
18
18
|
type L2TipsStore,
|
|
19
19
|
} from '@aztec/stdlib/block';
|
|
20
20
|
import type { ContractDataSource } from '@aztec/stdlib/contract';
|
|
21
|
-
import { getTimestampForSlot } from '@aztec/stdlib/epoch-helpers';
|
|
22
21
|
import { type PeerInfo, tryStop } from '@aztec/stdlib/interfaces/server';
|
|
23
22
|
import { type BlockProposal, CheckpointAttestation, type CheckpointProposal, type TopicType } from '@aztec/stdlib/p2p';
|
|
24
23
|
import type { BlockHeader, Tx, TxHash } from '@aztec/stdlib/tx';
|
|
@@ -111,27 +110,6 @@ export class P2PClient extends WithTracer implements P2P {
|
|
|
111
110
|
this.telemetry,
|
|
112
111
|
);
|
|
113
112
|
|
|
114
|
-
// Default to collecting all txs when we see a valid proposal
|
|
115
|
-
// This can be overridden by the validator client to validate, and it will call getTxsForBlockProposal on its own
|
|
116
|
-
// Note: Validators do NOT attest to individual blocks - attestations are only for checkpoint proposals.
|
|
117
|
-
// TODO(palla/txs): We should not trigger a request for txs on a proposal before fully validating it. We need to bring
|
|
118
|
-
// validator-client code into here so we can validate a proposal is reasonable.
|
|
119
|
-
this.registerBlockProposalHandler(async (block, sender) => {
|
|
120
|
-
this.log.debug(`Received block proposal from ${sender.toString()}`);
|
|
121
|
-
// TODO(palla/txs): Need to subtract validatorReexecuteDeadlineMs from this deadline (see ValidatorClient.getReexecutionDeadline)
|
|
122
|
-
const constants = this.txCollection.getConstants();
|
|
123
|
-
const nextSlotTimestampSeconds = Number(getTimestampForSlot(SlotNumber(block.slotNumber + 1), constants));
|
|
124
|
-
const deadline = new Date(nextSlotTimestampSeconds * 1000);
|
|
125
|
-
const parentBlock = await this.l2BlockSource.getBlockHeaderByArchive(block.blockHeader.lastArchive.root);
|
|
126
|
-
if (!parentBlock) {
|
|
127
|
-
this.log.debug(`Cannot collect txs for proposal as parent block not found`);
|
|
128
|
-
return false;
|
|
129
|
-
}
|
|
130
|
-
const blockNumber = BlockNumber(parentBlock.getBlockNumber() + 1);
|
|
131
|
-
await this.txProvider.getTxsForBlockProposal(block, blockNumber, { pinnedPeer: sender, deadline });
|
|
132
|
-
return true;
|
|
133
|
-
});
|
|
134
|
-
|
|
135
113
|
this.l2Tips = new L2TipsKVStore(store, 'p2p_client');
|
|
136
114
|
this.synchedLatestSlot = store.openSingleton('p2p_pool_last_l2_slot');
|
|
137
115
|
}
|
|
@@ -379,6 +357,8 @@ export class P2PClient extends WithTracer implements P2P {
|
|
|
379
357
|
// Store our own last-block proposal so we can respond to req/resp requests for it.
|
|
380
358
|
await this.attestationPool.tryAddBlockProposal(blockProposal);
|
|
381
359
|
}
|
|
360
|
+
// Gossipsub doesn't deliver own messages, so fire the all-nodes handler locally
|
|
361
|
+
await this.p2pService.notifyOwnCheckpointProposal(proposal.toCore());
|
|
382
362
|
return this.p2pService.propagate(proposal);
|
|
383
363
|
}
|
|
384
364
|
|
|
@@ -410,8 +390,12 @@ export class P2PClient extends WithTracer implements P2P {
|
|
|
410
390
|
this.p2pService.registerBlockReceivedCallback(handler);
|
|
411
391
|
}
|
|
412
392
|
|
|
413
|
-
public
|
|
414
|
-
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);
|
|
415
399
|
}
|
|
416
400
|
|
|
417
401
|
public registerDuplicateProposalCallback(callback: (info: DuplicateProposalInfo) => void): void {
|
|
@@ -691,31 +675,50 @@ export class P2PClient extends WithTracer implements P2P {
|
|
|
691
675
|
}
|
|
692
676
|
|
|
693
677
|
/**
|
|
694
|
-
* Returns true if the prune
|
|
695
|
-
* If the
|
|
696
|
-
* If they differ, the prune spans across checkpoints (epoch prune).
|
|
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.
|
|
697
680
|
*/
|
|
698
681
|
private async isEpochPrune(newCheckpoint: CheckpointId): Promise<boolean> {
|
|
699
682
|
const tips = await this.l2Tips.getL2Tips();
|
|
700
683
|
const oldCheckpointNumber = tips.checkpointed.checkpoint.number;
|
|
701
|
-
if (oldCheckpointNumber <= CheckpointNumber.
|
|
684
|
+
if (oldCheckpointNumber <= CheckpointNumber.INITIAL) {
|
|
702
685
|
return false;
|
|
703
686
|
}
|
|
704
|
-
const
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
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
|
+
}
|
|
708
700
|
return isEpochPrune;
|
|
709
701
|
}
|
|
710
702
|
|
|
711
703
|
/** Checks if the slot has changed and calls prepareForSlot if so. */
|
|
712
704
|
private async maybeCallPrepareForSlot(): Promise<void> {
|
|
713
|
-
|
|
714
|
-
|
|
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) {
|
|
715
718
|
return;
|
|
716
719
|
}
|
|
717
|
-
this.lastSlotProcessed =
|
|
718
|
-
await this.txPool.prepareForSlot(
|
|
720
|
+
this.lastSlotProcessed = slot;
|
|
721
|
+
await this.txPool.prepareForSlot(slot);
|
|
719
722
|
}
|
|
720
723
|
|
|
721
724
|
private async startServiceIfSynched() {
|