@aztec/p2p 0.0.1-commit.f295ac2 → 0.0.1-commit.f2ce05ee
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/dest/bootstrap/bootstrap.d.ts +4 -3
- package/dest/bootstrap/bootstrap.d.ts.map +1 -1
- package/dest/bootstrap/bootstrap.js +4 -4
- package/dest/client/factory.d.ts +3 -3
- package/dest/client/factory.d.ts.map +1 -1
- package/dest/client/factory.js +11 -8
- package/dest/client/interface.d.ts +9 -2
- package/dest/client/interface.d.ts.map +1 -1
- package/dest/client/p2p_client.d.ts +7 -4
- package/dest/client/p2p_client.d.ts.map +1 -1
- package/dest/client/p2p_client.js +24 -7
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.d.ts +2 -0
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.d.ts.map +1 -0
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.js +305 -0
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker_protocol.d.ts +73 -0
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker_protocol.d.ts.map +1 -0
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker_protocol.js +8 -0
- package/dest/config.d.ts +16 -3
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +7 -2
- package/dest/mem_pools/attestation_pool/attestation_pool.d.ts +94 -87
- package/dest/mem_pools/attestation_pool/attestation_pool.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/attestation_pool.js +411 -3
- package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.d.ts +2 -2
- package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.js +351 -85
- package/dest/mem_pools/attestation_pool/index.d.ts +2 -3
- package/dest/mem_pools/attestation_pool/index.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/index.js +1 -2
- package/dest/mem_pools/index.d.ts +2 -2
- package/dest/mem_pools/index.d.ts.map +1 -1
- package/dest/mem_pools/index.js +1 -1
- package/dest/mem_pools/instrumentation.d.ts +1 -1
- package/dest/mem_pools/instrumentation.d.ts.map +1 -1
- package/dest/mem_pools/instrumentation.js +2 -2
- package/dest/mem_pools/interface.d.ts +3 -3
- package/dest/mem_pools/interface.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.d.ts +3 -3
- package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool/eviction/eviction_manager.d.ts +3 -2
- package/dest/mem_pools/tx_pool/eviction/eviction_manager.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool/eviction/eviction_strategy.d.ts +3 -2
- package/dest/mem_pools/tx_pool/eviction/eviction_strategy.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.d.ts +3 -3
- package/dest/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.js +8 -1
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.d.ts +3 -3
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.js +2 -0
- package/dest/mem_pools/tx_pool_v2/archive/index.d.ts +2 -0
- package/dest/mem_pools/tx_pool_v2/archive/index.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/archive/index.js +1 -0
- package/dest/mem_pools/tx_pool_v2/archive/tx_archive.d.ts +43 -0
- package/dest/mem_pools/tx_pool_v2/archive/tx_archive.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/archive/tx_archive.js +103 -0
- package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.d.ts +47 -0
- package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.js +119 -0
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.d.ts +17 -0
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.js +90 -0
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.d.ts +19 -0
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.js +89 -0
- package/dest/mem_pools/tx_pool_v2/eviction/index.d.ts +10 -0
- package/dest/mem_pools/tx_pool_v2/eviction/index.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/eviction/index.js +11 -0
- package/dest/mem_pools/tx_pool_v2/eviction/interfaces.d.ts +131 -0
- package/dest/mem_pools/tx_pool_v2/eviction/interfaces.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/eviction/interfaces.js +17 -0
- package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.d.ts +15 -0
- package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.js +63 -0
- package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.d.ts +17 -0
- package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.js +91 -0
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.d.ts +16 -0
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.js +70 -0
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.d.ts +20 -0
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.js +63 -0
- package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.d.ts +15 -0
- package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.js +19 -0
- package/dest/mem_pools/tx_pool_v2/index.d.ts +5 -0
- package/dest/mem_pools/tx_pool_v2/index.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/index.js +4 -0
- package/dest/mem_pools/tx_pool_v2/interfaces.d.ts +197 -0
- package/dest/mem_pools/tx_pool_v2/interfaces.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/interfaces.js +6 -0
- package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts +71 -0
- package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/tx_metadata.js +95 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_bench_metrics.d.ts +26 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_bench_metrics.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_bench_metrics.js +70 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_indices.d.ts +99 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_indices.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_indices.js +332 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts +55 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2.js +156 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts +69 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.js +748 -0
- package/dest/msg_validators/attestation_validator/attestation_validator.d.ts +3 -3
- package/dest/msg_validators/attestation_validator/attestation_validator.d.ts.map +1 -1
- package/dest/msg_validators/attestation_validator/attestation_validator.js +41 -10
- package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.d.ts +5 -5
- package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.d.ts.map +1 -1
- package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.js +18 -6
- package/dest/msg_validators/clock_tolerance.d.ts +21 -0
- package/dest/msg_validators/clock_tolerance.d.ts.map +1 -0
- package/dest/msg_validators/clock_tolerance.js +37 -0
- package/dest/msg_validators/proposal_validator/proposal_validator.d.ts +3 -3
- package/dest/msg_validators/proposal_validator/proposal_validator.d.ts.map +1 -1
- package/dest/msg_validators/proposal_validator/proposal_validator.js +55 -31
- package/dest/msg_validators/proposal_validator/proposal_validator_test_suite.d.ts +3 -3
- package/dest/msg_validators/proposal_validator/proposal_validator_test_suite.d.ts.map +1 -1
- package/dest/msg_validators/proposal_validator/proposal_validator_test_suite.js +93 -64
- package/dest/msg_validators/tx_validator/archive_cache.d.ts +3 -3
- package/dest/msg_validators/tx_validator/archive_cache.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/archive_cache.js +1 -1
- package/dest/msg_validators/tx_validator/block_header_validator.d.ts +5 -4
- package/dest/msg_validators/tx_validator/block_header_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/block_header_validator.js +3 -2
- package/dest/msg_validators/tx_validator/data_validator.d.ts +3 -1
- package/dest/msg_validators/tx_validator/data_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/data_validator.js +4 -1
- package/dest/msg_validators/tx_validator/double_spend_validator.d.ts +3 -2
- package/dest/msg_validators/tx_validator/double_spend_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/double_spend_validator.js +3 -2
- package/dest/msg_validators/tx_validator/factory.d.ts +8 -3
- package/dest/msg_validators/tx_validator/factory.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/factory.js +21 -11
- package/dest/msg_validators/tx_validator/gas_validator.d.ts +3 -2
- package/dest/msg_validators/tx_validator/gas_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/gas_validator.js +3 -2
- 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 +3 -2
- package/dest/msg_validators/tx_validator/metadata_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/metadata_validator.js +2 -2
- package/dest/msg_validators/tx_validator/phases_validator.d.ts +3 -2
- package/dest/msg_validators/tx_validator/phases_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/phases_validator.js +3 -3
- package/dest/msg_validators/tx_validator/size_validator.d.ts +8 -0
- package/dest/msg_validators/tx_validator/size_validator.d.ts.map +1 -0
- package/dest/msg_validators/tx_validator/size_validator.js +23 -0
- package/dest/msg_validators/tx_validator/timestamp_validator.d.ts +3 -2
- package/dest/msg_validators/tx_validator/timestamp_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/timestamp_validator.js +2 -2
- package/dest/msg_validators/tx_validator/tx_permitted_validator.d.ts +3 -2
- package/dest/msg_validators/tx_validator/tx_permitted_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/tx_permitted_validator.js +2 -2
- package/dest/msg_validators/tx_validator/tx_proof_validator.d.ts +3 -2
- package/dest/msg_validators/tx_validator/tx_proof_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/tx_proof_validator.js +2 -2
- package/dest/services/data_store.d.ts +1 -1
- package/dest/services/data_store.d.ts.map +1 -1
- package/dest/services/data_store.js +10 -6
- package/dest/services/discv5/discV5_service.js +1 -1
- package/dest/services/dummy_service.d.ts +18 -2
- package/dest/services/dummy_service.d.ts.map +1 -1
- package/dest/services/dummy_service.js +42 -0
- package/dest/services/encoding.d.ts +1 -1
- package/dest/services/encoding.d.ts.map +1 -1
- package/dest/services/encoding.js +2 -3
- package/dest/services/gossipsub/index.d.ts +3 -0
- package/dest/services/gossipsub/index.d.ts.map +1 -0
- package/dest/services/gossipsub/index.js +2 -0
- package/dest/services/gossipsub/scoring.d.ts +21 -3
- package/dest/services/gossipsub/scoring.d.ts.map +1 -1
- package/dest/services/gossipsub/scoring.js +24 -7
- package/dest/services/gossipsub/topic_score_params.d.ts +161 -0
- package/dest/services/gossipsub/topic_score_params.d.ts.map +1 -0
- package/dest/services/gossipsub/topic_score_params.js +324 -0
- package/dest/services/index.d.ts +2 -1
- package/dest/services/index.d.ts.map +1 -1
- package/dest/services/index.js +1 -0
- package/dest/services/libp2p/instrumentation.d.ts +1 -1
- package/dest/services/libp2p/instrumentation.d.ts.map +1 -1
- package/dest/services/libp2p/instrumentation.js +14 -3
- package/dest/services/libp2p/libp2p_service.d.ts +81 -34
- package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
- package/dest/services/libp2p/libp2p_service.js +356 -288
- package/dest/services/peer-manager/metrics.d.ts +2 -2
- package/dest/services/peer-manager/metrics.d.ts.map +1 -1
- package/dest/services/peer-manager/metrics.js +20 -5
- package/dest/services/peer-manager/peer_scoring.d.ts +1 -1
- package/dest/services/peer-manager/peer_scoring.d.ts.map +1 -1
- package/dest/services/peer-manager/peer_scoring.js +33 -4
- package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts +47 -0
- package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts.map +1 -0
- package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.js +566 -0
- package/dest/services/reqresp/batch-tx-requester/config.d.ts +17 -0
- package/dest/services/reqresp/batch-tx-requester/config.d.ts.map +1 -0
- package/dest/services/reqresp/batch-tx-requester/config.js +27 -0
- package/dest/services/reqresp/batch-tx-requester/interface.d.ts +50 -0
- package/dest/services/reqresp/batch-tx-requester/interface.d.ts.map +1 -0
- package/dest/services/reqresp/batch-tx-requester/interface.js +1 -0
- package/dest/services/reqresp/batch-tx-requester/missing_txs.d.ts +37 -0
- package/dest/services/reqresp/batch-tx-requester/missing_txs.d.ts.map +1 -0
- package/dest/services/reqresp/batch-tx-requester/missing_txs.js +151 -0
- package/dest/services/reqresp/batch-tx-requester/peer_collection.d.ts +54 -0
- package/dest/services/reqresp/batch-tx-requester/peer_collection.d.ts.map +1 -0
- package/dest/services/reqresp/batch-tx-requester/peer_collection.js +139 -0
- package/dest/services/reqresp/batch-tx-requester/tx_validator.d.ts +20 -0
- package/dest/services/reqresp/batch-tx-requester/tx_validator.d.ts.map +1 -0
- package/dest/services/reqresp/batch-tx-requester/tx_validator.js +21 -0
- package/dest/services/reqresp/connection-sampler/batch_connection_sampler.d.ts +22 -3
- package/dest/services/reqresp/connection-sampler/batch_connection_sampler.d.ts.map +1 -1
- package/dest/services/reqresp/connection-sampler/batch_connection_sampler.js +63 -4
- package/dest/services/reqresp/connection-sampler/connection_sampler.d.ts +2 -1
- package/dest/services/reqresp/connection-sampler/connection_sampler.d.ts.map +1 -1
- package/dest/services/reqresp/connection-sampler/connection_sampler.js +12 -0
- package/dest/services/reqresp/interface.d.ts +5 -3
- package/dest/services/reqresp/interface.d.ts.map +1 -1
- package/dest/services/reqresp/interface.js +2 -2
- package/dest/services/reqresp/metrics.d.ts +6 -5
- package/dest/services/reqresp/metrics.d.ts.map +1 -1
- package/dest/services/reqresp/metrics.js +17 -5
- package/dest/services/reqresp/protocols/block_txs/bitvector.d.ts +5 -1
- package/dest/services/reqresp/protocols/block_txs/bitvector.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/block_txs/bitvector.js +5 -0
- package/dest/services/reqresp/protocols/block_txs/block_txs_handler.d.ts +6 -4
- package/dest/services/reqresp/protocols/block_txs/block_txs_handler.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/block_txs/block_txs_handler.js +27 -9
- package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.d.ts +23 -6
- package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.js +44 -13
- package/dest/services/reqresp/reqresp.d.ts +6 -1
- package/dest/services/reqresp/reqresp.d.ts.map +1 -1
- package/dest/services/reqresp/reqresp.js +58 -22
- package/dest/services/service.d.ts +21 -1
- package/dest/services/service.d.ts.map +1 -1
- package/dest/services/tx_collection/config.d.ts +4 -1
- package/dest/services/tx_collection/config.d.ts.map +1 -1
- package/dest/services/tx_collection/config.js +9 -1
- package/dest/services/tx_collection/fast_tx_collection.d.ts +5 -4
- package/dest/services/tx_collection/fast_tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/fast_tx_collection.js +17 -10
- package/dest/services/tx_collection/index.d.ts +2 -1
- package/dest/services/tx_collection/index.d.ts.map +1 -1
- package/dest/services/tx_collection/index.js +1 -0
- package/dest/services/tx_collection/instrumentation.d.ts +1 -1
- package/dest/services/tx_collection/instrumentation.d.ts.map +1 -1
- package/dest/services/tx_collection/instrumentation.js +9 -2
- package/dest/services/tx_collection/proposal_tx_collector.d.ts +48 -0
- package/dest/services/tx_collection/proposal_tx_collector.d.ts.map +1 -0
- package/dest/services/tx_collection/proposal_tx_collector.js +49 -0
- package/dest/services/tx_collection/slow_tx_collection.d.ts +3 -3
- package/dest/services/tx_collection/slow_tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/tx_collection.d.ts +8 -8
- package/dest/services/tx_collection/tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/tx_collection.js +5 -5
- package/dest/services/tx_file_store/config.d.ts +18 -0
- package/dest/services/tx_file_store/config.d.ts.map +1 -0
- package/dest/services/tx_file_store/config.js +26 -0
- package/dest/services/tx_file_store/index.d.ts +4 -0
- package/dest/services/tx_file_store/index.d.ts.map +1 -0
- package/dest/services/tx_file_store/index.js +3 -0
- package/dest/services/tx_file_store/instrumentation.d.ts +15 -0
- package/dest/services/tx_file_store/instrumentation.d.ts.map +1 -0
- package/dest/services/tx_file_store/instrumentation.js +29 -0
- package/dest/services/tx_file_store/tx_file_store.d.ts +47 -0
- package/dest/services/tx_file_store/tx_file_store.d.ts.map +1 -0
- package/dest/services/tx_file_store/tx_file_store.js +149 -0
- package/dest/services/tx_provider.d.ts +3 -3
- package/dest/services/tx_provider.d.ts.map +1 -1
- package/dest/services/tx_provider_instrumentation.d.ts +1 -1
- package/dest/services/tx_provider_instrumentation.d.ts.map +1 -1
- package/dest/services/tx_provider_instrumentation.js +5 -5
- package/dest/test-helpers/index.d.ts +3 -1
- package/dest/test-helpers/index.d.ts.map +1 -1
- package/dest/test-helpers/index.js +2 -0
- 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 +2 -1
- package/dest/test-helpers/test_tx_provider.d.ts +40 -0
- package/dest/test-helpers/test_tx_provider.d.ts.map +1 -0
- package/dest/test-helpers/test_tx_provider.js +41 -0
- package/dest/test-helpers/testbench-utils.d.ts +152 -0
- package/dest/test-helpers/testbench-utils.d.ts.map +1 -0
- package/dest/test-helpers/testbench-utils.js +308 -0
- package/dest/testbench/p2p_client_testbench_worker.d.ts +28 -2
- package/dest/testbench/p2p_client_testbench_worker.d.ts.map +1 -1
- package/dest/testbench/p2p_client_testbench_worker.js +212 -133
- package/dest/testbench/worker_client_manager.d.ts +51 -6
- package/dest/testbench/worker_client_manager.d.ts.map +1 -1
- package/dest/testbench/worker_client_manager.js +226 -44
- package/package.json +14 -14
- package/src/bootstrap/bootstrap.ts +7 -4
- package/src/client/factory.ts +13 -14
- package/src/client/interface.ts +13 -1
- package/src/client/p2p_client.ts +37 -13
- package/src/client/test/tx_proposal_collector/README.md +227 -0
- package/src/client/test/tx_proposal_collector/proposal_tx_collector_worker.ts +336 -0
- package/src/client/test/tx_proposal_collector/proposal_tx_collector_worker_protocol.ts +43 -0
- package/src/config.ts +22 -2
- package/src/mem_pools/attestation_pool/attestation_pool.ts +444 -90
- package/src/mem_pools/attestation_pool/attestation_pool_test_suite.ts +436 -100
- package/src/mem_pools/attestation_pool/index.ts +9 -2
- package/src/mem_pools/index.ts +1 -1
- package/src/mem_pools/instrumentation.ts +2 -1
- package/src/mem_pools/interface.ts +2 -2
- package/src/mem_pools/tx_pool/aztec_kv_tx_pool.ts +2 -2
- package/src/mem_pools/tx_pool/eviction/eviction_manager.ts +2 -1
- package/src/mem_pools/tx_pool/eviction/eviction_strategy.ts +2 -1
- package/src/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.ts +10 -7
- package/src/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.ts +4 -2
- package/src/mem_pools/tx_pool_v2/README.md +209 -0
- package/src/mem_pools/tx_pool_v2/archive/index.ts +1 -0
- package/src/mem_pools/tx_pool_v2/archive/tx_archive.ts +120 -0
- package/src/mem_pools/tx_pool_v2/eviction/eviction_manager.ts +147 -0
- package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.ts +118 -0
- package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.ts +111 -0
- package/src/mem_pools/tx_pool_v2/eviction/index.ts +23 -0
- package/src/mem_pools/tx_pool_v2/eviction/interfaces.ts +164 -0
- package/src/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.ts +74 -0
- package/src/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.ts +101 -0
- package/src/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.ts +86 -0
- package/src/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.ts +72 -0
- package/src/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.ts +31 -0
- package/src/mem_pools/tx_pool_v2/index.ts +11 -0
- package/src/mem_pools/tx_pool_v2/interfaces.ts +227 -0
- package/src/mem_pools/tx_pool_v2/tx_metadata.ts +161 -0
- package/src/mem_pools/tx_pool_v2/tx_pool_bench_metrics.ts +77 -0
- package/src/mem_pools/tx_pool_v2/tx_pool_indices.ts +417 -0
- package/src/mem_pools/tx_pool_v2/tx_pool_v2.ts +212 -0
- package/src/mem_pools/tx_pool_v2/tx_pool_v2_impl.ts +882 -0
- package/src/msg_validators/attestation_validator/attestation_validator.ts +26 -14
- package/src/msg_validators/attestation_validator/fisherman_attestation_validator.ts +16 -10
- package/src/msg_validators/clock_tolerance.ts +51 -0
- package/src/msg_validators/proposal_validator/proposal_validator.ts +31 -31
- package/src/msg_validators/proposal_validator/proposal_validator_test_suite.ts +91 -67
- package/src/msg_validators/tx_validator/archive_cache.ts +3 -3
- package/src/msg_validators/tx_validator/block_header_validator.ts +6 -5
- package/src/msg_validators/tx_validator/data_validator.ts +6 -2
- package/src/msg_validators/tx_validator/double_spend_validator.ts +4 -3
- package/src/msg_validators/tx_validator/factory.ts +64 -23
- package/src/msg_validators/tx_validator/gas_validator.ts +9 -3
- package/src/msg_validators/tx_validator/index.ts +1 -0
- package/src/msg_validators/tx_validator/metadata_validator.ts +6 -3
- package/src/msg_validators/tx_validator/phases_validator.ts +5 -3
- package/src/msg_validators/tx_validator/size_validator.ts +22 -0
- package/src/msg_validators/tx_validator/timestamp_validator.ts +6 -3
- package/src/msg_validators/tx_validator/tx_permitted_validator.ts +8 -3
- package/src/msg_validators/tx_validator/tx_proof_validator.ts +8 -3
- package/src/services/data_store.ts +10 -7
- package/src/services/discv5/discV5_service.ts +1 -1
- package/src/services/dummy_service.ts +51 -0
- package/src/services/encoding.ts +2 -3
- package/src/services/gossipsub/README.md +626 -0
- package/src/services/gossipsub/index.ts +2 -0
- package/src/services/gossipsub/scoring.ts +29 -5
- package/src/services/gossipsub/topic_score_params.ts +451 -0
- package/src/services/index.ts +1 -0
- package/src/services/libp2p/instrumentation.ts +15 -2
- package/src/services/libp2p/libp2p_service.ts +390 -302
- package/src/services/peer-manager/metrics.ts +21 -4
- package/src/services/peer-manager/peer_scoring.ts +29 -1
- package/src/services/reqresp/batch-tx-requester/README.md +305 -0
- package/src/services/reqresp/batch-tx-requester/batch_tx_requester.ts +706 -0
- package/src/services/reqresp/batch-tx-requester/config.ts +40 -0
- package/src/services/reqresp/batch-tx-requester/interface.ts +57 -0
- package/src/services/reqresp/batch-tx-requester/missing_txs.ts +209 -0
- package/src/services/reqresp/batch-tx-requester/peer_collection.ts +205 -0
- package/src/services/reqresp/batch-tx-requester/tx_validator.ts +37 -0
- package/src/services/reqresp/connection-sampler/batch_connection_sampler.ts +65 -4
- package/src/services/reqresp/connection-sampler/connection_sampler.ts +16 -0
- package/src/services/reqresp/interface.ts +5 -2
- package/src/services/reqresp/metrics.ts +34 -9
- package/src/services/reqresp/protocols/block_txs/bitvector.ts +7 -0
- package/src/services/reqresp/protocols/block_txs/block_txs_handler.ts +34 -11
- package/src/services/reqresp/protocols/block_txs/block_txs_reqresp.ts +57 -9
- package/src/services/reqresp/reqresp.ts +66 -19
- package/src/services/service.ts +24 -0
- package/src/services/tx_collection/config.ts +15 -1
- package/src/services/tx_collection/fast_tx_collection.ts +30 -17
- package/src/services/tx_collection/index.ts +5 -0
- package/src/services/tx_collection/instrumentation.ts +11 -2
- package/src/services/tx_collection/proposal_tx_collector.ts +112 -0
- package/src/services/tx_collection/slow_tx_collection.ts +2 -2
- package/src/services/tx_collection/tx_collection.ts +8 -8
- package/src/services/tx_file_store/config.ts +43 -0
- package/src/services/tx_file_store/index.ts +3 -0
- package/src/services/tx_file_store/instrumentation.ts +36 -0
- package/src/services/tx_file_store/tx_file_store.ts +173 -0
- package/src/services/tx_provider.ts +2 -2
- package/src/services/tx_provider_instrumentation.ts +11 -5
- package/src/test-helpers/index.ts +2 -0
- package/src/test-helpers/reqresp-nodes.ts +2 -1
- package/src/test-helpers/test_tx_provider.ts +64 -0
- package/src/test-helpers/testbench-utils.ts +362 -0
- package/src/testbench/p2p_client_testbench_worker.ts +321 -126
- package/src/testbench/worker_client_manager.ts +304 -47
- package/dest/mem_pools/attestation_pool/kv_attestation_pool.d.ts +0 -40
- package/dest/mem_pools/attestation_pool/kv_attestation_pool.d.ts.map +0 -1
- package/dest/mem_pools/attestation_pool/kv_attestation_pool.js +0 -218
- package/dest/mem_pools/attestation_pool/memory_attestation_pool.d.ts +0 -31
- package/dest/mem_pools/attestation_pool/memory_attestation_pool.d.ts.map +0 -1
- package/dest/mem_pools/attestation_pool/memory_attestation_pool.js +0 -180
- package/src/mem_pools/attestation_pool/kv_attestation_pool.ts +0 -320
- package/src/mem_pools/attestation_pool/memory_attestation_pool.ts +0 -264
|
@@ -1,2 +1,9 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
1
|
+
export {
|
|
2
|
+
AttestationPool,
|
|
3
|
+
type AttestationPoolApi,
|
|
4
|
+
type TryAddResult,
|
|
5
|
+
createTestAttestationPool,
|
|
6
|
+
MAX_PROPOSALS_PER_SLOT,
|
|
7
|
+
MAX_PROPOSALS_PER_POSITION,
|
|
8
|
+
ATTESTATION_CAP_BUFFER,
|
|
9
|
+
} from './attestation_pool.js';
|
package/src/mem_pools/index.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { type
|
|
1
|
+
export { AttestationPool, type AttestationPoolApi } from './attestation_pool/attestation_pool.js';
|
|
2
2
|
export { type MemPools } from './interface.js';
|
|
3
3
|
export { type TxPool } from './tx_pool/tx_pool.js';
|
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
type ObservableGauge,
|
|
13
13
|
type TelemetryClient,
|
|
14
14
|
type UpDownCounter,
|
|
15
|
+
createUpDownCounterWithDefault,
|
|
15
16
|
} from '@aztec/telemetry-client';
|
|
16
17
|
|
|
17
18
|
export enum PoolName {
|
|
@@ -97,7 +98,7 @@ export class PoolInstrumentation<PoolObject extends Gossipable> {
|
|
|
97
98
|
dbStats,
|
|
98
99
|
);
|
|
99
100
|
|
|
100
|
-
this.addObjectCounter = this.meter
|
|
101
|
+
this.addObjectCounter = createUpDownCounterWithDefault(this.meter, metricsLabels.itemsAdded);
|
|
101
102
|
|
|
102
103
|
this.minedDelay = this.meter.createHistogram(metricsLabels.itemMinedDelay);
|
|
103
104
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { AttestationPoolApi } from './attestation_pool/attestation_pool.js';
|
|
2
2
|
import type { TxPool } from './tx_pool/tx_pool.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -6,5 +6,5 @@ import type { TxPool } from './tx_pool/tx_pool.js';
|
|
|
6
6
|
*/
|
|
7
7
|
export type MemPools = {
|
|
8
8
|
txPool: TxPool;
|
|
9
|
-
attestationPool:
|
|
9
|
+
attestationPool: AttestationPoolApi;
|
|
10
10
|
};
|
|
@@ -6,7 +6,7 @@ import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
|
6
6
|
import type { TypedEventEmitter } from '@aztec/foundation/types';
|
|
7
7
|
import type { AztecAsyncKVStore, AztecAsyncMap, AztecAsyncMultiMap } from '@aztec/kv-store';
|
|
8
8
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
9
|
-
import type { MerkleTreeReadOperations,
|
|
9
|
+
import type { MerkleTreeReadOperations, WorldStateSynchronizer } from '@aztec/stdlib/interfaces/server';
|
|
10
10
|
import { ChonkProof } from '@aztec/stdlib/proofs';
|
|
11
11
|
import type { TxAddedToPoolStats } from '@aztec/stdlib/stats';
|
|
12
12
|
import { BlockHeader, Tx, TxHash } from '@aztec/stdlib/tx';
|
|
@@ -99,7 +99,7 @@ export class AztecKVTxPool
|
|
|
99
99
|
constructor(
|
|
100
100
|
store: AztecAsyncKVStore,
|
|
101
101
|
archive: AztecAsyncKVStore,
|
|
102
|
-
worldState:
|
|
102
|
+
worldState: WorldStateSynchronizer,
|
|
103
103
|
telemetry: TelemetryClient = getTelemetryClient(),
|
|
104
104
|
config: TxPoolOptions = {},
|
|
105
105
|
log = createLogger('p2p:tx_pool'),
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { findIndexInSortedArray, insertIntoSortedArray } from '@aztec/foundation/array';
|
|
2
|
+
import type { BlockNumber } from '@aztec/foundation/branded-types';
|
|
2
3
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
4
|
import { createLogger } from '@aztec/foundation/log';
|
|
4
5
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
@@ -50,7 +51,7 @@ export class EvictionManager {
|
|
|
50
51
|
await this.runEvictionRules(ctx);
|
|
51
52
|
}
|
|
52
53
|
|
|
53
|
-
public async evictAfterChainPrune(blockNumber:
|
|
54
|
+
public async evictAfterChainPrune(blockNumber: BlockNumber): Promise<void> {
|
|
54
55
|
const ctx: EvictionContext = {
|
|
55
56
|
event: EvictionEvent.CHAIN_PRUNED,
|
|
56
57
|
blockNumber,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { BlockNumber } from '@aztec/foundation/branded-types';
|
|
1
2
|
import { Buffer32 } from '@aztec/foundation/buffer';
|
|
2
3
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
4
|
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
@@ -24,7 +25,7 @@ export type EvictionContext =
|
|
|
24
25
|
}
|
|
25
26
|
| {
|
|
26
27
|
event: typeof EvictionEvent.CHAIN_PRUNED;
|
|
27
|
-
blockNumber:
|
|
28
|
+
blockNumber: BlockNumber;
|
|
28
29
|
}
|
|
29
30
|
| {
|
|
30
31
|
event: typeof EvictionEvent.BLOCK_MINED;
|
|
@@ -2,7 +2,7 @@ import { createLogger } from '@aztec/foundation/log';
|
|
|
2
2
|
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
3
3
|
import { computeFeePayerBalanceStorageSlot } from '@aztec/protocol-contracts/fee-juice';
|
|
4
4
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
5
|
-
import type {
|
|
5
|
+
import type { WorldStateSynchronizer } from '@aztec/stdlib/interfaces/server';
|
|
6
6
|
import { DatabasePublicStateSource, type MerkleTreeReadOperations } from '@aztec/stdlib/trees';
|
|
7
7
|
import type { TxHash } from '@aztec/stdlib/tx';
|
|
8
8
|
|
|
@@ -22,7 +22,7 @@ export class FeePayerBalanceEvictionRule implements EvictionRule {
|
|
|
22
22
|
|
|
23
23
|
private log = createLogger('p2p:mempool:tx_pool:fee_payer_balance_eviction_rule');
|
|
24
24
|
|
|
25
|
-
constructor(private worldState:
|
|
25
|
+
constructor(private worldState: WorldStateSynchronizer) {}
|
|
26
26
|
|
|
27
27
|
async evict(context: EvictionContext, txPool: TxPoolOperations): Promise<EvictionResult> {
|
|
28
28
|
try {
|
|
@@ -31,11 +31,12 @@ export class FeePayerBalanceEvictionRule implements EvictionRule {
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
if (context.event === EvictionEvent.BLOCK_MINED) {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
);
|
|
34
|
+
const blockNumber = context.block.getBlockNumber();
|
|
35
|
+
// Ensure world state is synced to this block before accessing the snapshot.
|
|
36
|
+
// This handles the race where a block is added to the archiver
|
|
37
|
+
// but the world state hasn't synced it yet.
|
|
38
|
+
await this.worldState.syncImmediate(blockNumber);
|
|
39
|
+
return await this.evictForFeePayers(context.feePayers, this.worldState.getSnapshot(blockNumber), txPool);
|
|
39
40
|
}
|
|
40
41
|
|
|
41
42
|
// TODO: fix this edge-case
|
|
@@ -49,6 +50,8 @@ export class FeePayerBalanceEvictionRule implements EvictionRule {
|
|
|
49
50
|
// -----
|
|
50
51
|
// Proposed fix: evict only if node is synched
|
|
51
52
|
if (context.event === EvictionEvent.CHAIN_PRUNED) {
|
|
53
|
+
// Ensure world state is synced to this block before accessing the snapshot.
|
|
54
|
+
await this.worldState.syncImmediate(context.blockNumber);
|
|
52
55
|
const feePayers = await txPool.getPendingFeePayers();
|
|
53
56
|
return await this.evictForFeePayers(feePayers, this.worldState.getSnapshot(context.blockNumber), txPool);
|
|
54
57
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { findIndexInSortedArray, insertIntoSortedArray } from '@aztec/foundation/array';
|
|
2
2
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
3
|
import { createLogger } from '@aztec/foundation/log';
|
|
4
|
-
import type {
|
|
4
|
+
import type { WorldStateSynchronizer } from '@aztec/stdlib/interfaces/server';
|
|
5
5
|
import { MerkleTreeId } from '@aztec/stdlib/trees';
|
|
6
6
|
import type { TxHash } from '@aztec/stdlib/tx';
|
|
7
7
|
|
|
@@ -26,7 +26,7 @@ export class InvalidTxsAfterReorgRule implements EvictionRule {
|
|
|
26
26
|
|
|
27
27
|
private log = createLogger('p2p:mempool:tx_pool:invalid_txs_after_reorg_rule');
|
|
28
28
|
|
|
29
|
-
public constructor(private worldState:
|
|
29
|
+
public constructor(private worldState: WorldStateSynchronizer) {}
|
|
30
30
|
|
|
31
31
|
async evict(context: EvictionContext, txPool: TxPoolOperations): Promise<EvictionResult> {
|
|
32
32
|
if (context.event !== EvictionEvent.CHAIN_PRUNED) {
|
|
@@ -46,6 +46,8 @@ export class InvalidTxsAfterReorgRule implements EvictionRule {
|
|
|
46
46
|
insertIntoSortedArray(uniqueBlockHashes, blockHash, Fr.cmp, false);
|
|
47
47
|
});
|
|
48
48
|
|
|
49
|
+
// Ensure world state is synced to this block before accessing the snapshot.
|
|
50
|
+
await this.worldState.syncImmediate(context.blockNumber);
|
|
49
51
|
const db = this.worldState.getSnapshot(context.blockNumber);
|
|
50
52
|
const blocksFromDb = await db.findLeafIndices(MerkleTreeId.ARCHIVE, uniqueBlockHashes);
|
|
51
53
|
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
# TxPoolV2
|
|
2
|
+
|
|
3
|
+
Transaction pool implementation with explicit state management and pluggable eviction rules.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
TxPoolV2 manages transactions through a state machine with clear transitions:
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
addPendingTxs()
|
|
11
|
+
│
|
|
12
|
+
▼
|
|
13
|
+
┌─────────────────────────────────────┐
|
|
14
|
+
│ PENDING │◄──────────────────┐
|
|
15
|
+
│ (awaiting block inclusion) │ │
|
|
16
|
+
└─────────────────────────────────────┘ │
|
|
17
|
+
│ │
|
|
18
|
+
│ protectTxs() / addProtectedTxs() │
|
|
19
|
+
▼ │
|
|
20
|
+
┌─────────────────────────────────────┐ │
|
|
21
|
+
│ PROTECTED │───────────────────┘
|
|
22
|
+
│ (in a block proposal) │ prepareForSlot()
|
|
23
|
+
└─────────────────────────────────────┘ (slot passed without mining)
|
|
24
|
+
│ │
|
|
25
|
+
│ handleMinedBlock() │
|
|
26
|
+
▼ │
|
|
27
|
+
┌─────────────────────────────────────┐ │
|
|
28
|
+
│ MINED │───────────────────┘
|
|
29
|
+
│ (included in a block) │ handlePrunedBlocks()
|
|
30
|
+
└─────────────────────────────────────┘ (reorg)
|
|
31
|
+
│
|
|
32
|
+
│ handleFinalizedBlock()
|
|
33
|
+
▼
|
|
34
|
+
┌─────────────────────────────────────┐
|
|
35
|
+
│ DELETED │
|
|
36
|
+
│ (optionally archived) │
|
|
37
|
+
└─────────────────────────────────────┘
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Key Components
|
|
41
|
+
|
|
42
|
+
### TxPoolV2 (`tx_pool_v2.ts`)
|
|
43
|
+
|
|
44
|
+
The public API wrapper that serializes all operations through a queue to prevent race conditions. Delegates to `TxPoolV2Impl` for actual logic.
|
|
45
|
+
|
|
46
|
+
### TxPoolV2Impl (`tx_pool_v2_impl.ts`)
|
|
47
|
+
|
|
48
|
+
Core implementation containing:
|
|
49
|
+
- KV store persistence for transactions and metadata
|
|
50
|
+
- In-memory indices for fast lookups (by nullifier, fee payer, priority)
|
|
51
|
+
- State transition logic
|
|
52
|
+
- Pre-add rule execution
|
|
53
|
+
- Post-event eviction rule execution
|
|
54
|
+
|
|
55
|
+
### TxMetaData (`tx_metadata.ts`)
|
|
56
|
+
|
|
57
|
+
Lightweight metadata stored alongside each transaction:
|
|
58
|
+
- `txHash`: Transaction identifier
|
|
59
|
+
- `anchorBlockHeaderHash`: Hash of the anchor block header
|
|
60
|
+
- `priorityFee`: For priority ordering and challenges
|
|
61
|
+
- `feePayer`: For balance-based eviction
|
|
62
|
+
- `claimAmount`: Fee payer's claim from bridging
|
|
63
|
+
- `feeLimit`: Maximum fee the tx can pay
|
|
64
|
+
- `nullifiers`: For conflict detection
|
|
65
|
+
- `includeByTimestamp`: Expiration timestamp
|
|
66
|
+
- `minedL2BlockId`: Set when mined (undefined otherwise)
|
|
67
|
+
|
|
68
|
+
State is derived by TxPoolIndices:
|
|
69
|
+
- `mined` if `minedL2BlockId` is set
|
|
70
|
+
- `protected` if in protection map
|
|
71
|
+
- `pending` otherwise
|
|
72
|
+
|
|
73
|
+
## Architecture: Pre-add vs Post-event Rules
|
|
74
|
+
|
|
75
|
+
**Pre-add rules** (run during `addPendingTxs`):
|
|
76
|
+
- Used for external transactions entering the pool
|
|
77
|
+
- Can reject the incoming tx entirely
|
|
78
|
+
- Can evict lower-priority existing txs to make room
|
|
79
|
+
- Rules: NullifierConflictRule, FeePayerBalancePreAddRule, LowPriorityPreAddRule
|
|
80
|
+
|
|
81
|
+
**Post-event rules** (run after state transitions):
|
|
82
|
+
- Used for internal state changes (block mined, reorg, slot change)
|
|
83
|
+
- Only evict txs already in the pool
|
|
84
|
+
- Rules: InvalidTxsAfterMiningRule, InvalidTxsAfterReorgRule, FeePayerBalanceEvictionRule, LowPriorityEvictionRule
|
|
85
|
+
|
|
86
|
+
This design choice means restored txs (from protected/mined states) use post-event rules only, because they were already validated on initial submission.
|
|
87
|
+
|
|
88
|
+
## Eviction Rules
|
|
89
|
+
|
|
90
|
+
The pool uses a pluggable rule system for managing transactions.
|
|
91
|
+
|
|
92
|
+
### Pre-Add Rules
|
|
93
|
+
|
|
94
|
+
Checked before adding a transaction to the pending pool:
|
|
95
|
+
|
|
96
|
+
| Rule | Purpose |
|
|
97
|
+
|------|---------|
|
|
98
|
+
| `NullifierConflictRule` | Handles transactions with conflicting nullifiers. Higher priority tx wins. |
|
|
99
|
+
| `FeePayerBalancePreAddRule` | Ensures fee payer has sufficient balance for all their pending txs. |
|
|
100
|
+
| `LowPriorityPreAddRule` | Rejects txs when pool is full and new tx has lowest priority. |
|
|
101
|
+
|
|
102
|
+
### Post-Event Eviction Rules
|
|
103
|
+
|
|
104
|
+
Run after events to clean up the pool:
|
|
105
|
+
|
|
106
|
+
| Rule | Trigger | Purpose |
|
|
107
|
+
|------|---------|---------|
|
|
108
|
+
| `LowPriorityEvictionRule` | `txs_added` | Evicts lowest priority txs when pool exceeds limit. |
|
|
109
|
+
| `FeePayerBalanceEvictionRule` | `txs_added`, `block_mined`, `chain_pruned` | Evicts txs when fee payer has insufficient balance. |
|
|
110
|
+
| `InvalidTxsAfterMiningRule` | `block_mined` | Evicts pending txs with: (1) nullifiers in mined block, (2) expired timestamp. |
|
|
111
|
+
| `InvalidTxsAfterReorgRule` | `chain_pruned` | Evicts txs with invalid anchor blocks after reorg. |
|
|
112
|
+
|
|
113
|
+
## Usage
|
|
114
|
+
|
|
115
|
+
### Creating a Pool
|
|
116
|
+
|
|
117
|
+
```typescript
|
|
118
|
+
import { AztecKVTxPoolV2 } from './tx_pool_v2.js';
|
|
119
|
+
|
|
120
|
+
const pool = new AztecKVTxPoolV2(txStore, archiveStore, {
|
|
121
|
+
l2BlockSource: archiver,
|
|
122
|
+
worldStateSynchronizer: worldState,
|
|
123
|
+
pendingTxValidator: validator,
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
await pool.start();
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
### Adding Transactions
|
|
130
|
+
|
|
131
|
+
```typescript
|
|
132
|
+
// Add to pending pool (validates and runs pre-add rules)
|
|
133
|
+
const result = await pool.addPendingTxs(txs, { source: 'gossip' });
|
|
134
|
+
// result: { accepted: TxHash[], ignored: TxHash[], rejected: TxHash[] }
|
|
135
|
+
|
|
136
|
+
// Check without modifying pool
|
|
137
|
+
const canAdd = await pool.canAddPendingTx(tx);
|
|
138
|
+
// canAdd: 'accepted' | 'ignored' | 'rejected'
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
### Block Building Flow
|
|
142
|
+
|
|
143
|
+
```typescript
|
|
144
|
+
// 1. Proposer protects txs for their block
|
|
145
|
+
await pool.protectTxs(selectedTxHashes, blockHeader);
|
|
146
|
+
|
|
147
|
+
// 2. On successful mining
|
|
148
|
+
await pool.handleMinedBlock(minedTxHashes, blockHeader);
|
|
149
|
+
|
|
150
|
+
// 3. If slot passes without mining
|
|
151
|
+
await pool.prepareForSlot(nextSlotNumber);
|
|
152
|
+
|
|
153
|
+
// 4. On finalization
|
|
154
|
+
await pool.handleFinalizedBlock(finalizedBlockHeader);
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
### Handling Reorgs
|
|
158
|
+
|
|
159
|
+
```typescript
|
|
160
|
+
// When blocks are pruned, un-mine affected transactions
|
|
161
|
+
await pool.handlePrunedBlocks(latestValidBlockId);
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
## Configuration
|
|
165
|
+
|
|
166
|
+
```typescript
|
|
167
|
+
await pool.updateConfig({
|
|
168
|
+
maxPendingTxCount: 10000, // 0 = unlimited
|
|
169
|
+
archivedTxLimit: 1000, // 0 = disabled
|
|
170
|
+
});
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
## Return Values
|
|
174
|
+
|
|
175
|
+
### AddTxsResult
|
|
176
|
+
|
|
177
|
+
When adding pending transactions, each tx is categorized:
|
|
178
|
+
|
|
179
|
+
| Status | Meaning |
|
|
180
|
+
|--------|---------|
|
|
181
|
+
| `accepted` | Successfully added to the pool |
|
|
182
|
+
| `ignored` | Valid but not added (duplicate, lost nullifier conflict, insufficient balance) |
|
|
183
|
+
| `rejected` | Failed validation (invalid proof, expired, etc.) |
|
|
184
|
+
|
|
185
|
+
## Archive
|
|
186
|
+
|
|
187
|
+
Finalized transactions can optionally be archived for historical queries:
|
|
188
|
+
|
|
189
|
+
```typescript
|
|
190
|
+
const archivedTx = await pool.getArchivedTxByHash(txHash);
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
The archive uses FIFO eviction when `archivedTxLimit` is reached.
|
|
194
|
+
|
|
195
|
+
## Testing
|
|
196
|
+
|
|
197
|
+
```bash
|
|
198
|
+
# Unit tests (131 tests)
|
|
199
|
+
yarn test src/mem_pools/tx_pool_v2/tx_pool_v2.test.ts
|
|
200
|
+
|
|
201
|
+
# Compatibility tests (25 tests)
|
|
202
|
+
yarn test src/mem_pools/tx_pool_v2/tx_pool_v2.compat.test.ts
|
|
203
|
+
|
|
204
|
+
# Eviction rule tests
|
|
205
|
+
yarn test src/mem_pools/tx_pool_v2/eviction/
|
|
206
|
+
|
|
207
|
+
# Benchmarks
|
|
208
|
+
yarn test src/mem_pools/tx_pool_v2/tx_pool_v2_bench.test.ts
|
|
209
|
+
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { TxArchive } from './tx_archive.js';
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
2
|
+
import type { AztecAsyncKVStore, AztecAsyncMap } from '@aztec/kv-store';
|
|
3
|
+
import { ChonkProof } from '@aztec/stdlib/proofs';
|
|
4
|
+
import { Tx, TxHash } from '@aztec/stdlib/tx';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Manages archived transactions with FIFO eviction.
|
|
8
|
+
* Archived transactions have their proofs stripped to save space.
|
|
9
|
+
*/
|
|
10
|
+
export class TxArchive {
|
|
11
|
+
#store: AztecAsyncKVStore;
|
|
12
|
+
#txs: AztecAsyncMap<string, Buffer>;
|
|
13
|
+
#indices: AztecAsyncMap<number, string>;
|
|
14
|
+
#limit: number;
|
|
15
|
+
#log: Logger;
|
|
16
|
+
|
|
17
|
+
constructor(store: AztecAsyncKVStore, limit: number, log?: Logger) {
|
|
18
|
+
this.#store = store;
|
|
19
|
+
this.#txs = store.openMap('archivedTxs');
|
|
20
|
+
this.#indices = store.openMap('archivedTxIndices');
|
|
21
|
+
this.#limit = limit;
|
|
22
|
+
this.#log = log ?? createLogger('p2p:tx_pool_v2:archive');
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Updates the maximum number of archived transactions.
|
|
27
|
+
*/
|
|
28
|
+
updateLimit(limit: number): void {
|
|
29
|
+
this.#limit = limit;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Gets the current archive limit.
|
|
34
|
+
*/
|
|
35
|
+
getLimit(): number {
|
|
36
|
+
return this.#limit;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Checks if archiving is enabled.
|
|
41
|
+
*/
|
|
42
|
+
isEnabled(): boolean {
|
|
43
|
+
return this.#limit > 0;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Archives transactions, stripping their proofs.
|
|
48
|
+
* Evicts oldest transactions if the limit is exceeded.
|
|
49
|
+
*/
|
|
50
|
+
async archiveTxs(txs: Tx[]): Promise<void> {
|
|
51
|
+
if (!this.isEnabled() || txs.length === 0) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
try {
|
|
56
|
+
await this.#store.transactionAsync(async () => {
|
|
57
|
+
// Get current head and tail indices
|
|
58
|
+
let headIdx = await this.getHeadIndex();
|
|
59
|
+
let tailIdx = await this.getTailIndex();
|
|
60
|
+
|
|
61
|
+
for (const tx of txs) {
|
|
62
|
+
// Evict oldest entries if at capacity
|
|
63
|
+
while (headIdx - tailIdx >= this.#limit) {
|
|
64
|
+
const txHashToEvict = await this.#indices.getAsync(tailIdx);
|
|
65
|
+
if (txHashToEvict) {
|
|
66
|
+
await this.#txs.delete(txHashToEvict);
|
|
67
|
+
await this.#indices.delete(tailIdx);
|
|
68
|
+
}
|
|
69
|
+
tailIdx++;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// Archive the transaction with stripped proof
|
|
73
|
+
const archivedTx = this.stripProof(tx);
|
|
74
|
+
const txHash = tx.getTxHash().toString();
|
|
75
|
+
await this.#txs.set(txHash, archivedTx.toBuffer());
|
|
76
|
+
await this.#indices.set(headIdx, txHash);
|
|
77
|
+
headIdx++;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
this.#log.debug(`Archived ${txs.length} txs, total: ${headIdx - tailIdx}`);
|
|
81
|
+
});
|
|
82
|
+
} catch (error) {
|
|
83
|
+
this.#log.error('Error archiving transactions', { error });
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Retrieves an archived transaction by its hash.
|
|
89
|
+
*/
|
|
90
|
+
async getTxByHash(txHash: TxHash): Promise<Tx | undefined> {
|
|
91
|
+
const buffer = await this.#txs.getAsync(txHash.toString());
|
|
92
|
+
return buffer ? Tx.fromBuffer(buffer) : undefined;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Gets the current count of archived transactions.
|
|
97
|
+
*/
|
|
98
|
+
async getCount(): Promise<number> {
|
|
99
|
+
const head = await this.getHeadIndex();
|
|
100
|
+
const tail = await this.getTailIndex();
|
|
101
|
+
return head - tail;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Strips the proof from a transaction for archival.
|
|
106
|
+
*/
|
|
107
|
+
private stripProof(tx: Tx): Tx {
|
|
108
|
+
return new Tx(tx.txHash, tx.data, ChonkProof.empty(), tx.contractClassLogFields, tx.publicFunctionCalldata);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
private async getHeadIndex(): Promise<number> {
|
|
112
|
+
const entry = await this.#indices.entriesAsync({ limit: 1, reverse: true }).next();
|
|
113
|
+
return (entry.value?.[0] ?? -1) + 1;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
private async getTailIndex(): Promise<number> {
|
|
117
|
+
const entry = await this.#indices.entriesAsync({ limit: 1 }).next();
|
|
118
|
+
return entry.value?.[0] ?? 0;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import type { BlockNumber } from '@aztec/foundation/branded-types';
|
|
2
|
+
import type { Logger } from '@aztec/foundation/log';
|
|
3
|
+
import type { BlockHeader } from '@aztec/stdlib/tx';
|
|
4
|
+
|
|
5
|
+
import type { TxMetaData } from '../tx_metadata.js';
|
|
6
|
+
import {
|
|
7
|
+
type EvictionConfig,
|
|
8
|
+
type EvictionContext,
|
|
9
|
+
EvictionEvent,
|
|
10
|
+
type EvictionRule,
|
|
11
|
+
type PoolOperations,
|
|
12
|
+
type PreAddPoolAccess,
|
|
13
|
+
type PreAddResult,
|
|
14
|
+
type PreAddRule,
|
|
15
|
+
} from './interfaces.js';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Manages eviction rules for the transaction pool.
|
|
19
|
+
* Coordinates pre-add rules (run during addPendingTxs) and post-event rules (run after events).
|
|
20
|
+
*/
|
|
21
|
+
export class EvictionManager {
|
|
22
|
+
private preAddRules: PreAddRule[] = [];
|
|
23
|
+
private postEventRules: EvictionRule[] = [];
|
|
24
|
+
|
|
25
|
+
constructor(
|
|
26
|
+
private pool: PoolOperations,
|
|
27
|
+
private log: Logger,
|
|
28
|
+
) {}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Registers a pre-add rule that runs during transaction addition.
|
|
32
|
+
*/
|
|
33
|
+
registerPreAddRule(rule: PreAddRule): void {
|
|
34
|
+
this.preAddRules.push(rule);
|
|
35
|
+
this.log.debug(`Registered pre-add rule: ${rule.name}`);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Registers a post-event eviction rule that runs after events.
|
|
40
|
+
*/
|
|
41
|
+
registerRule(rule: EvictionRule): void {
|
|
42
|
+
this.postEventRules.push(rule);
|
|
43
|
+
this.log.debug(`Registered eviction rule: ${rule.name}`);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Runs all pre-add rules for an incoming transaction.
|
|
48
|
+
* Returns combined result of all rules.
|
|
49
|
+
*/
|
|
50
|
+
async runPreAddRules(incomingMeta: TxMetaData, poolAccess: PreAddPoolAccess): Promise<PreAddResult> {
|
|
51
|
+
const allTxHashesToEvict: string[] = [];
|
|
52
|
+
|
|
53
|
+
for (const rule of this.preAddRules) {
|
|
54
|
+
try {
|
|
55
|
+
const result = await rule.check(incomingMeta, poolAccess);
|
|
56
|
+
|
|
57
|
+
if (result.shouldIgnore) {
|
|
58
|
+
return result;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// Collect txs to evict from all rules
|
|
62
|
+
for (const txHash of result.txHashesToEvict) {
|
|
63
|
+
if (!allTxHashesToEvict.includes(txHash)) {
|
|
64
|
+
allTxHashesToEvict.push(txHash);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
} catch (err) {
|
|
68
|
+
this.log.error(`Error running pre-add rule ${rule.name}`, { err, txHash: incomingMeta.txHash });
|
|
69
|
+
// On error, ignore the transaction to be safe
|
|
70
|
+
return {
|
|
71
|
+
shouldIgnore: true,
|
|
72
|
+
txHashesToEvict: [],
|
|
73
|
+
reason: `pre-add rule ${rule.name} error: ${err}`,
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return {
|
|
79
|
+
shouldIgnore: false,
|
|
80
|
+
txHashesToEvict: allTxHashesToEvict,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Runs post-event eviction after new transactions are added.
|
|
86
|
+
*/
|
|
87
|
+
async evictAfterNewTxs(newTxHashes: string[], feePayers: string[]): Promise<void> {
|
|
88
|
+
const context: EvictionContext = {
|
|
89
|
+
event: EvictionEvent.TXS_ADDED,
|
|
90
|
+
newTxHashes,
|
|
91
|
+
feePayers,
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
await this.runPostEventRules(context);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Runs post-event eviction after a block is mined.
|
|
99
|
+
*/
|
|
100
|
+
async evictAfterNewBlock(block: BlockHeader, newNullifiers: string[], feePayers: string[]): Promise<void> {
|
|
101
|
+
const context: EvictionContext = {
|
|
102
|
+
event: EvictionEvent.BLOCK_MINED,
|
|
103
|
+
block,
|
|
104
|
+
newNullifiers,
|
|
105
|
+
feePayers,
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
await this.runPostEventRules(context);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Runs post-event eviction after a chain prune (reorg).
|
|
113
|
+
*/
|
|
114
|
+
async evictAfterChainPrune(blockNumber: BlockNumber): Promise<void> {
|
|
115
|
+
const context: EvictionContext = {
|
|
116
|
+
event: EvictionEvent.CHAIN_PRUNED,
|
|
117
|
+
blockNumber,
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
await this.runPostEventRules(context);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Updates configuration for all rules.
|
|
125
|
+
*/
|
|
126
|
+
updateConfig(config: EvictionConfig): void {
|
|
127
|
+
for (const rule of this.preAddRules) {
|
|
128
|
+
rule.updateConfig?.(config);
|
|
129
|
+
}
|
|
130
|
+
for (const rule of this.postEventRules) {
|
|
131
|
+
rule.updateConfig?.(config);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
private async runPostEventRules(context: EvictionContext): Promise<void> {
|
|
136
|
+
for (const rule of this.postEventRules) {
|
|
137
|
+
try {
|
|
138
|
+
const result = await rule.evict(context, this.pool);
|
|
139
|
+
if (!result.success) {
|
|
140
|
+
this.log.warn(`Eviction rule ${rule.name} failed`, { error: result.error });
|
|
141
|
+
}
|
|
142
|
+
} catch (err) {
|
|
143
|
+
this.log.error(`Error running eviction rule ${rule.name}`, { err });
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|