@aztec/p2p 0.0.1-commit.fce3e4f → 0.0.1-commit.ff7989d6c
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 +7 -6
- package/dest/client/factory.d.ts.map +1 -1
- package/dest/client/factory.js +53 -15
- package/dest/client/interface.d.ts +58 -25
- package/dest/client/interface.d.ts.map +1 -1
- package/dest/client/p2p_client.d.ts +51 -56
- package/dest/client/p2p_client.d.ts.map +1 -1
- package/dest/client/p2p_client.js +608 -264
- 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 +38 -13
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +31 -20
- package/dest/errors/tx-pool.error.d.ts +8 -0
- package/dest/errors/tx-pool.error.d.ts.map +1 -0
- package/dest/errors/tx-pool.error.js +9 -0
- package/dest/index.d.ts +2 -1
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +1 -0
- package/dest/mem_pools/attestation_pool/attestation_pool.d.ts +111 -76
- package/dest/mem_pools/attestation_pool/attestation_pool.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/attestation_pool.js +441 -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 +529 -289
- 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/attestation_pool/mocks.d.ts +11 -8
- package/dest/mem_pools/attestation_pool/mocks.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/mocks.js +17 -13
- package/dest/mem_pools/index.d.ts +3 -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 +7 -1
- package/dest/mem_pools/instrumentation.d.ts.map +1 -1
- package/dest/mem_pools/instrumentation.js +31 -13
- package/dest/mem_pools/interface.d.ts +6 -7
- package/dest/mem_pools/interface.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.d.ts +37 -27
- package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.js +314 -335
- package/dest/mem_pools/tx_pool/eviction/eviction_manager.d.ts +32 -0
- package/dest/mem_pools/tx_pool/eviction/eviction_manager.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool/eviction/eviction_manager.js +112 -0
- package/dest/mem_pools/tx_pool/eviction/eviction_strategy.d.ts +157 -0
- package/dest/mem_pools/tx_pool/eviction/eviction_strategy.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool/eviction/eviction_strategy.js +52 -0
- package/dest/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.d.ts +16 -0
- package/dest/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.js +122 -0
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.d.ts +17 -0
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.js +84 -0
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.d.ts +19 -0
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.js +78 -0
- package/dest/mem_pools/tx_pool/eviction/low_priority_eviction_rule.d.ts +26 -0
- package/dest/mem_pools/tx_pool/eviction/low_priority_eviction_rule.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool/eviction/low_priority_eviction_rule.js +84 -0
- package/dest/mem_pools/tx_pool/eviction/nullifier_conflict_pre_add_rule.d.ts +25 -0
- package/dest/mem_pools/tx_pool/eviction/nullifier_conflict_pre_add_rule.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool/eviction/nullifier_conflict_pre_add_rule.js +57 -0
- package/dest/mem_pools/tx_pool/index.d.ts +1 -2
- package/dest/mem_pools/tx_pool/index.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool/index.js +0 -1
- package/dest/mem_pools/tx_pool/priority.d.ts +5 -1
- package/dest/mem_pools/tx_pool/priority.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool/priority.js +6 -1
- package/dest/mem_pools/tx_pool/tx_pool.d.ts +11 -6
- package/dest/mem_pools/tx_pool/tx_pool.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool/tx_pool_test_suite.d.ts +1 -1
- package/dest/mem_pools/tx_pool/tx_pool_test_suite.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool/tx_pool_test_suite.js +30 -24
- 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/deleted_pool.d.ts +104 -0
- package/dest/mem_pools/tx_pool_v2/deleted_pool.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/deleted_pool.js +251 -0
- package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.d.ts +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 +128 -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 +93 -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 +95 -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 +174 -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 +25 -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 +65 -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 +93 -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 +78 -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 +73 -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 +6 -0
- package/dest/mem_pools/tx_pool_v2/index.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/index.js +5 -0
- package/dest/mem_pools/tx_pool_v2/instrumentation.d.ts +15 -0
- package/dest/mem_pools/tx_pool_v2/instrumentation.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/instrumentation.js +43 -0
- package/dest/mem_pools/tx_pool_v2/interfaces.d.ts +211 -0
- package/dest/mem_pools/tx_pool_v2/interfaces.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/interfaces.js +9 -0
- package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts +97 -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 +152 -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 +108 -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 +355 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts +60 -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 +161 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts +77 -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 +896 -0
- package/dest/msg_validators/attestation_validator/attestation_validator.d.ts +4 -4
- package/dest/msg_validators/attestation_validator/attestation_validator.d.ts.map +1 -1
- package/dest/msg_validators/attestation_validator/attestation_validator.js +52 -19
- package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.d.ts +7 -7
- package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.d.ts.map +1 -1
- package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.js +22 -13
- 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/index.d.ts +2 -2
- package/dest/msg_validators/index.d.ts.map +1 -1
- package/dest/msg_validators/index.js +1 -1
- package/dest/msg_validators/proposal_validator/block_proposal_validator.d.ts +9 -0
- package/dest/msg_validators/proposal_validator/block_proposal_validator.d.ts.map +1 -0
- package/dest/msg_validators/proposal_validator/block_proposal_validator.js +6 -0
- package/dest/msg_validators/proposal_validator/checkpoint_proposal_validator.d.ts +9 -0
- package/dest/msg_validators/proposal_validator/checkpoint_proposal_validator.d.ts.map +1 -0
- package/dest/msg_validators/proposal_validator/checkpoint_proposal_validator.js +6 -0
- package/dest/msg_validators/proposal_validator/index.d.ts +4 -0
- package/dest/msg_validators/proposal_validator/index.d.ts.map +1 -0
- package/dest/msg_validators/proposal_validator/index.js +3 -0
- package/dest/msg_validators/proposal_validator/proposal_validator.d.ts +13 -0
- package/dest/msg_validators/proposal_validator/proposal_validator.d.ts.map +1 -0
- package/dest/msg_validators/proposal_validator/proposal_validator.js +104 -0
- package/dest/msg_validators/proposal_validator/proposal_validator_test_suite.d.ts +23 -0
- package/dest/msg_validators/proposal_validator/proposal_validator_test_suite.d.ts.map +1 -0
- package/dest/msg_validators/proposal_validator/proposal_validator_test_suite.js +212 -0
- package/dest/msg_validators/tx_validator/aggregate_tx_validator.d.ts +3 -3
- package/dest/msg_validators/tx_validator/aggregate_tx_validator.d.ts.map +1 -1
- 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 +20 -6
- package/dest/msg_validators/tx_validator/block_header_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/block_header_validator.js +4 -3
- 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 +15 -4
- package/dest/msg_validators/tx_validator/double_spend_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/double_spend_validator.js +7 -6
- package/dest/msg_validators/tx_validator/factory.d.ts +10 -4
- package/dest/msg_validators/tx_validator/factory.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/factory.js +22 -12
- package/dest/msg_validators/tx_validator/fee_payer_balance.d.ts +10 -0
- package/dest/msg_validators/tx_validator/fee_payer_balance.d.ts.map +1 -0
- package/dest/msg_validators/tx_validator/fee_payer_balance.js +20 -0
- 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 +11 -16
- 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 +4 -3
- 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/test_utils.d.ts +2 -2
- package/dest/msg_validators/tx_validator/test_utils.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/timestamp_validator.d.ts +23 -5
- package/dest/msg_validators/tx_validator/timestamp_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/timestamp_validator.js +8 -8
- 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 +28 -3
- package/dest/services/dummy_service.d.ts.map +1 -1
- package/dest/services/dummy_service.js +51 -0
- package/dest/services/encoding.d.ts +2 -2
- package/dest/services/encoding.d.ts.map +1 -1
- package/dest/services/encoding.js +10 -8
- 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 +173 -0
- package/dest/services/gossipsub/topic_score_params.d.ts.map +1 -0
- package/dest/services/gossipsub/topic_score_params.js +346 -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 +30 -72
- package/dest/services/libp2p/libp2p_service.d.ts +109 -36
- package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
- package/dest/services/libp2p/libp2p_service.js +988 -326
- package/dest/services/peer-manager/metrics.d.ts +7 -2
- package/dest/services/peer-manager/metrics.d.ts.map +1 -1
- package/dest/services/peer-manager/metrics.js +33 -21
- package/dest/services/peer-manager/peer_manager.d.ts +2 -2
- package/dest/services/peer-manager/peer_manager.d.ts.map +1 -1
- package/dest/services/peer-manager/peer_manager.js +4 -12
- 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 +32 -6
- package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts +48 -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 +562 -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 +46 -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 +34 -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 +130 -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/constants.d.ts +12 -0
- package/dest/services/reqresp/constants.d.ts.map +1 -0
- package/dest/services/reqresp/constants.js +7 -0
- package/dest/services/reqresp/interface.d.ts +13 -2
- package/dest/services/reqresp/interface.d.ts.map +1 -1
- package/dest/services/reqresp/interface.js +16 -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 -21
- package/dest/services/reqresp/protocols/auth.d.ts +2 -2
- package/dest/services/reqresp/protocols/auth.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/auth.js +2 -2
- package/dest/services/reqresp/protocols/block.d.ts +1 -1
- package/dest/services/reqresp/protocols/block.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/block.js +3 -2
- 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 +12 -0
- package/dest/services/reqresp/protocols/block_txs/block_txs_handler.d.ts +7 -5
- 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 +30 -7
- 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 +60 -14
- package/dest/services/reqresp/protocols/status.d.ts +5 -4
- package/dest/services/reqresp/protocols/status.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/status.js +7 -3
- package/dest/services/reqresp/protocols/tx.d.ts +8 -3
- package/dest/services/reqresp/protocols/tx.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/tx.js +20 -0
- 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 +471 -50
- package/dest/services/service.d.ts +55 -3
- package/dest/services/service.d.ts.map +1 -1
- package/dest/services/tx_collection/config.d.ts +22 -1
- package/dest/services/tx_collection/config.d.ts.map +1 -1
- package/dest/services/tx_collection/config.js +56 -2
- package/dest/services/tx_collection/fast_tx_collection.d.ts +10 -6
- package/dest/services/tx_collection/fast_tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/fast_tx_collection.js +71 -44
- package/dest/services/tx_collection/file_store_tx_collection.d.ts +53 -0
- package/dest/services/tx_collection/file_store_tx_collection.d.ts.map +1 -0
- package/dest/services/tx_collection/file_store_tx_collection.js +167 -0
- package/dest/services/tx_collection/file_store_tx_source.d.ts +37 -0
- package/dest/services/tx_collection/file_store_tx_source.d.ts.map +1 -0
- package/dest/services/tx_collection/file_store_tx_source.js +90 -0
- package/dest/services/tx_collection/index.d.ts +3 -1
- package/dest/services/tx_collection/index.d.ts.map +1 -1
- package/dest/services/tx_collection/index.js +2 -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 +11 -13
- package/dest/services/tx_collection/missing_txs_tracker.d.ts +32 -0
- package/dest/services/tx_collection/missing_txs_tracker.d.ts.map +1 -0
- package/dest/services/tx_collection/missing_txs_tracker.js +27 -0
- package/dest/services/tx_collection/proposal_tx_collector.d.ts +49 -0
- package/dest/services/tx_collection/proposal_tx_collector.d.ts.map +1 -0
- package/dest/services/tx_collection/proposal_tx_collector.js +50 -0
- package/dest/services/tx_collection/slow_tx_collection.d.ts +9 -4
- package/dest/services/tx_collection/slow_tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/slow_tx_collection.js +60 -26
- package/dest/services/tx_collection/tx_collection.d.ts +31 -17
- package/dest/services/tx_collection/tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/tx_collection.js +79 -7
- package/dest/services/tx_collection/tx_collection_sink.d.ts +18 -8
- package/dest/services/tx_collection/tx_collection_sink.d.ts.map +1 -1
- package/dest/services/tx_collection/tx_collection_sink.js +26 -29
- package/dest/services/tx_collection/tx_source.d.ts +8 -3
- package/dest/services/tx_collection/tx_source.d.ts.map +1 -1
- package/dest/services/tx_collection/tx_source.js +19 -2
- package/dest/services/tx_file_store/config.d.ts +16 -0
- package/dest/services/tx_file_store/config.d.ts.map +1 -0
- package/dest/services/tx_file_store/config.js +22 -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 +48 -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 +152 -0
- package/dest/services/tx_provider.d.ts +6 -4
- package/dest/services/tx_provider.d.ts.map +1 -1
- package/dest/services/tx_provider.js +16 -6
- package/dest/services/tx_provider_instrumentation.d.ts +5 -2
- package/dest/services/tx_provider_instrumentation.d.ts.map +1 -1
- package/dest/services/tx_provider_instrumentation.js +14 -14
- 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/make-test-p2p-clients.d.ts +3 -3
- package/dest/test-helpers/make-test-p2p-clients.d.ts.map +1 -1
- package/dest/test-helpers/mock-pubsub.d.ts +29 -2
- package/dest/test-helpers/mock-pubsub.d.ts.map +1 -1
- package/dest/test-helpers/mock-pubsub.js +103 -2
- package/dest/test-helpers/mock-tx-helpers.js +1 -1
- package/dest/test-helpers/reqresp-nodes.d.ts +2 -2
- 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 +163 -0
- package/dest/test-helpers/testbench-utils.d.ts.map +1 -0
- package/dest/test-helpers/testbench-utils.js +366 -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 +221 -126
- 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 -39
- package/dest/util.d.ts +2 -2
- package/dest/util.d.ts.map +1 -1
- package/package.json +18 -18
- package/src/bootstrap/bootstrap.ts +7 -4
- package/src/client/factory.ts +98 -31
- package/src/client/interface.ts +76 -25
- package/src/client/p2p_client.ts +283 -307
- package/src/client/test/tx_proposal_collector/README.md +227 -0
- package/src/client/test/tx_proposal_collector/proposal_tx_collector_worker.ts +346 -0
- package/src/client/test/tx_proposal_collector/proposal_tx_collector_worker_protocol.ts +43 -0
- package/src/config.ts +59 -29
- package/src/errors/tx-pool.error.ts +12 -0
- package/src/index.ts +1 -0
- package/src/mem_pools/attestation_pool/attestation_pool.ts +510 -78
- package/src/mem_pools/attestation_pool/attestation_pool_test_suite.ts +614 -322
- package/src/mem_pools/attestation_pool/index.ts +9 -2
- package/src/mem_pools/attestation_pool/mocks.ts +22 -15
- package/src/mem_pools/index.ts +4 -1
- package/src/mem_pools/instrumentation.ts +39 -14
- package/src/mem_pools/interface.ts +5 -7
- package/src/mem_pools/tx_pool/README.md +270 -0
- package/src/mem_pools/tx_pool/aztec_kv_tx_pool.ts +367 -371
- package/src/mem_pools/tx_pool/eviction/eviction_manager.ts +132 -0
- package/src/mem_pools/tx_pool/eviction/eviction_strategy.ts +208 -0
- package/src/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.ts +162 -0
- package/src/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.ts +104 -0
- package/src/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.ts +93 -0
- package/src/mem_pools/tx_pool/eviction/low_priority_eviction_rule.ts +106 -0
- package/src/mem_pools/tx_pool/eviction/nullifier_conflict_pre_add_rule.ts +75 -0
- package/src/mem_pools/tx_pool/index.ts +0 -1
- package/src/mem_pools/tx_pool/priority.ts +8 -1
- package/src/mem_pools/tx_pool/tx_pool.ts +11 -5
- package/src/mem_pools/tx_pool/tx_pool_test_suite.ts +23 -17
- package/src/mem_pools/tx_pool_v2/README.md +275 -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/deleted_pool.ts +321 -0
- package/src/mem_pools/tx_pool_v2/eviction/eviction_manager.ts +160 -0
- package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.ts +121 -0
- package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.ts +122 -0
- package/src/mem_pools/tx_pool_v2/eviction/index.ts +27 -0
- package/src/mem_pools/tx_pool_v2/eviction/interfaces.ts +209 -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 +91 -0
- package/src/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.ts +90 -0
- package/src/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.ts +31 -0
- package/src/mem_pools/tx_pool_v2/index.ts +12 -0
- package/src/mem_pools/tx_pool_v2/instrumentation.ts +69 -0
- package/src/mem_pools/tx_pool_v2/interfaces.ts +242 -0
- package/src/mem_pools/tx_pool_v2/tx_metadata.ts +242 -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 +444 -0
- package/src/mem_pools/tx_pool_v2/tx_pool_v2.ts +223 -0
- package/src/mem_pools/tx_pool_v2/tx_pool_v2_impl.ts +1069 -0
- package/src/msg_validators/attestation_validator/attestation_validator.ts +37 -22
- package/src/msg_validators/attestation_validator/fisherman_attestation_validator.ts +21 -18
- package/src/msg_validators/clock_tolerance.ts +51 -0
- package/src/msg_validators/index.ts +1 -1
- package/src/msg_validators/proposal_validator/block_proposal_validator.ts +10 -0
- package/src/msg_validators/proposal_validator/checkpoint_proposal_validator.ts +13 -0
- package/src/msg_validators/proposal_validator/index.ts +3 -0
- package/src/msg_validators/proposal_validator/proposal_validator.ts +92 -0
- package/src/msg_validators/proposal_validator/proposal_validator_test_suite.ts +230 -0
- package/src/msg_validators/tx_validator/aggregate_tx_validator.ts +2 -2
- package/src/msg_validators/tx_validator/archive_cache.ts +3 -3
- package/src/msg_validators/tx_validator/block_header_validator.ts +21 -8
- package/src/msg_validators/tx_validator/data_validator.ts +18 -6
- package/src/msg_validators/tx_validator/double_spend_validator.ts +15 -9
- package/src/msg_validators/tx_validator/factory.ts +67 -25
- package/src/msg_validators/tx_validator/fee_payer_balance.ts +40 -0
- package/src/msg_validators/tx_validator/gas_validator.ts +17 -28
- package/src/msg_validators/tx_validator/index.ts +1 -0
- package/src/msg_validators/tx_validator/metadata_validator.ts +19 -8
- 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/test_utils.ts +1 -1
- package/src/msg_validators/tx_validator/timestamp_validator.ts +30 -19
- 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 +68 -1
- package/src/services/encoding.ts +9 -7
- package/src/services/gossipsub/README.md +641 -0
- package/src/services/gossipsub/index.ts +2 -0
- package/src/services/gossipsub/scoring.ts +29 -5
- package/src/services/gossipsub/topic_score_params.ts +487 -0
- package/src/services/index.ts +1 -0
- package/src/services/libp2p/instrumentation.ts +32 -73
- package/src/services/libp2p/libp2p_service.ts +661 -316
- package/src/services/peer-manager/metrics.ts +39 -21
- package/src/services/peer-manager/peer_manager.ts +5 -4
- package/src/services/peer-manager/peer_scoring.ts +28 -4
- 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 +53 -0
- package/src/services/reqresp/batch-tx-requester/missing_txs.ts +161 -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 +19 -1
- package/src/services/reqresp/constants.ts +14 -0
- package/src/services/reqresp/interface.ts +30 -2
- package/src/services/reqresp/metrics.ts +36 -27
- package/src/services/reqresp/protocols/auth.ts +2 -2
- package/src/services/reqresp/protocols/block.ts +3 -2
- package/src/services/reqresp/protocols/block_txs/bitvector.ts +16 -0
- package/src/services/reqresp/protocols/block_txs/block_txs_handler.ts +35 -12
- package/src/services/reqresp/protocols/block_txs/block_txs_reqresp.ts +75 -10
- package/src/services/reqresp/protocols/status.ts +16 -12
- package/src/services/reqresp/protocols/tx.ts +23 -2
- package/src/services/reqresp/reqresp.ts +79 -22
- package/src/services/service.ts +72 -4
- package/src/services/tx_collection/config.ts +84 -2
- package/src/services/tx_collection/fast_tx_collection.ts +96 -49
- package/src/services/tx_collection/file_store_tx_collection.ts +202 -0
- package/src/services/tx_collection/file_store_tx_source.ts +117 -0
- package/src/services/tx_collection/index.ts +6 -0
- package/src/services/tx_collection/instrumentation.ts +11 -13
- package/src/services/tx_collection/missing_txs_tracker.ts +52 -0
- package/src/services/tx_collection/proposal_tx_collector.ts +113 -0
- package/src/services/tx_collection/slow_tx_collection.ts +69 -36
- package/src/services/tx_collection/tx_collection.ts +122 -24
- package/src/services/tx_collection/tx_collection_sink.ts +30 -34
- package/src/services/tx_collection/tx_source.ts +22 -3
- package/src/services/tx_file_store/config.ts +37 -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 +175 -0
- package/src/services/tx_provider.ts +27 -10
- package/src/services/tx_provider_instrumentation.ts +24 -14
- package/src/test-helpers/index.ts +2 -0
- package/src/test-helpers/make-test-p2p-clients.ts +3 -3
- package/src/test-helpers/mock-pubsub.ts +144 -4
- package/src/test-helpers/mock-tx-helpers.ts +1 -1
- package/src/test-helpers/reqresp-nodes.ts +3 -2
- package/src/test-helpers/test_tx_provider.ts +64 -0
- package/src/test-helpers/testbench-utils.ts +430 -0
- package/src/testbench/p2p_client_testbench_worker.ts +349 -123
- package/src/testbench/worker_client_manager.ts +304 -42
- package/src/util.ts +7 -1
- package/dest/mem_pools/attestation_pool/kv_attestation_pool.d.ts +0 -37
- 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 -213
- package/dest/mem_pools/attestation_pool/memory_attestation_pool.d.ts +0 -30
- 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 -219
- package/dest/mem_pools/tx_pool/memory_tx_pool.d.ts +0 -80
- package/dest/mem_pools/tx_pool/memory_tx_pool.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/memory_tx_pool.js +0 -238
- package/dest/msg_validators/block_proposal_validator/block_proposal_validator.d.ts +0 -12
- package/dest/msg_validators/block_proposal_validator/block_proposal_validator.d.ts.map +0 -1
- package/dest/msg_validators/block_proposal_validator/block_proposal_validator.js +0 -82
- package/dest/msg_validators/block_proposal_validator/index.d.ts +0 -2
- package/dest/msg_validators/block_proposal_validator/index.d.ts.map +0 -1
- package/dest/msg_validators/block_proposal_validator/index.js +0 -1
- package/src/mem_pools/attestation_pool/kv_attestation_pool.ts +0 -298
- package/src/mem_pools/attestation_pool/memory_attestation_pool.ts +0 -287
- package/src/mem_pools/tx_pool/memory_tx_pool.ts +0 -283
- package/src/msg_validators/block_proposal_validator/block_proposal_validator.ts +0 -97
- package/src/msg_validators/block_proposal_validator/index.ts +0 -1
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { createLogger } from '@aztec/foundation/log';
|
|
2
|
+
import type { TxHash } from '@aztec/stdlib/tx';
|
|
3
|
+
|
|
4
|
+
import type { TxPoolOptions } from '../tx_pool.js';
|
|
5
|
+
import {
|
|
6
|
+
type EvictionContext,
|
|
7
|
+
EvictionEvent,
|
|
8
|
+
type EvictionResult,
|
|
9
|
+
type EvictionRule,
|
|
10
|
+
type TxPoolOperations,
|
|
11
|
+
} from './eviction_strategy.js';
|
|
12
|
+
|
|
13
|
+
export interface LowPriorityEvictionConfig {
|
|
14
|
+
/** Maximum number of pending transactions before eviction kicks in */
|
|
15
|
+
maxPoolSize: number;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Eviction rule that removes low-priority transactions when the number of pending transactions exceeds configured limits.
|
|
20
|
+
* Only triggers on TXS_ADDED events and respects non-evictable transactions.
|
|
21
|
+
*/
|
|
22
|
+
export class LowPriorityEvictionRule implements EvictionRule {
|
|
23
|
+
public readonly name = 'LowPriorityEviction';
|
|
24
|
+
|
|
25
|
+
private log = createLogger('p2p:mempool:tx_pool:low_priority_eviction_rule');
|
|
26
|
+
|
|
27
|
+
constructor(private config: LowPriorityEvictionConfig) {}
|
|
28
|
+
|
|
29
|
+
public async evict(context: EvictionContext, txPool: TxPoolOperations): Promise<EvictionResult> {
|
|
30
|
+
if (context.event !== EvictionEvent.TXS_ADDED) {
|
|
31
|
+
return {
|
|
32
|
+
reason: 'low_priority',
|
|
33
|
+
success: true,
|
|
34
|
+
txsEvicted: [],
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (this.config.maxPoolSize === 0) {
|
|
39
|
+
return {
|
|
40
|
+
reason: 'low_priority',
|
|
41
|
+
success: true,
|
|
42
|
+
txsEvicted: [],
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
try {
|
|
47
|
+
const currentTxCount = await txPool.getPendingTxCount();
|
|
48
|
+
const maxCount = this.config.maxPoolSize;
|
|
49
|
+
|
|
50
|
+
if (currentTxCount <= maxCount) {
|
|
51
|
+
this.log.trace(`Not evicting low priority txs. Pending tx count below limit ${currentTxCount} <= ${maxCount}`);
|
|
52
|
+
return {
|
|
53
|
+
reason: 'low_priority',
|
|
54
|
+
success: true,
|
|
55
|
+
txsEvicted: [],
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
this.log.verbose(`Evicting low priority txs. Pending tx count above limit: ${currentTxCount} > ${maxCount}`);
|
|
60
|
+
const numberToEvict = currentTxCount - maxCount;
|
|
61
|
+
const txsToEvict: TxHash[] = await txPool.getLowestPriorityEvictable(numberToEvict);
|
|
62
|
+
|
|
63
|
+
if (txsToEvict.length > 0) {
|
|
64
|
+
await txPool.deleteTxs(txsToEvict);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const numNewTxsEvicted = context.newTxs.filter(newTxHash =>
|
|
68
|
+
txsToEvict.some(evictedTx => evictedTx.equals(newTxHash)),
|
|
69
|
+
).length;
|
|
70
|
+
|
|
71
|
+
this.log.verbose(`Evicted ${txsToEvict.length} low priority txs, including ${numNewTxsEvicted} newly added txs`, {
|
|
72
|
+
txsEvicted: txsToEvict,
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
return {
|
|
76
|
+
reason: 'low_priority',
|
|
77
|
+
success: true,
|
|
78
|
+
txsEvicted: txsToEvict,
|
|
79
|
+
};
|
|
80
|
+
} catch (err) {
|
|
81
|
+
this.log.error('Failed to evict low priority transactions', { err });
|
|
82
|
+
return {
|
|
83
|
+
reason: 'low_priority',
|
|
84
|
+
success: false,
|
|
85
|
+
txsEvicted: [],
|
|
86
|
+
error: new Error('Failed to evict low priority txs', { cause: err }),
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Updates the configuration for this eviction rule
|
|
93
|
+
*/
|
|
94
|
+
updateConfig(config: TxPoolOptions): void {
|
|
95
|
+
if (config.maxPendingTxCount !== undefined) {
|
|
96
|
+
this.config.maxPoolSize = config.maxPendingTxCount;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Gets the current configuration
|
|
102
|
+
*/
|
|
103
|
+
getConfig(): LowPriorityEvictionConfig {
|
|
104
|
+
return { ...this.config };
|
|
105
|
+
}
|
|
106
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { findIndexInSortedArray, insertIntoSortedArray } from '@aztec/foundation/array';
|
|
2
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
|
+
import { createLogger } from '@aztec/foundation/log';
|
|
4
|
+
import { type Tx, TxHash } from '@aztec/stdlib/tx';
|
|
5
|
+
|
|
6
|
+
import type { PreAddEvictionResult, PreAddEvictionRule, PreAddPoolAccess } from './eviction_strategy.js';
|
|
7
|
+
|
|
8
|
+
const cmpTxHash = (a: TxHash, b: TxHash) => Fr.cmp(a.hash, b.hash);
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Pre-add eviction rule that checks for nullifier conflicts between incoming and existing transactions.
|
|
12
|
+
*
|
|
13
|
+
* When an incoming tx shares nullifiers with existing pending txs:
|
|
14
|
+
* - If the incoming tx has strictly higher priority fee, evict all conflicting txs
|
|
15
|
+
* - If any conflicting tx has equal or higher priority fee, reject the incoming tx
|
|
16
|
+
*
|
|
17
|
+
* This prevents nullifier spam attacks where an attacker floods the mempool with
|
|
18
|
+
* transactions spending the same nullifiers.
|
|
19
|
+
*/
|
|
20
|
+
export class NullifierConflictPreAddRule implements PreAddEvictionRule {
|
|
21
|
+
public readonly name = 'NullifierConflictPreAdd';
|
|
22
|
+
|
|
23
|
+
private log = createLogger('p2p:mempool:tx_pool:nullifier_conflict_pre_add_rule');
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Check if the incoming transaction conflicts with existing transactions via nullifiers.
|
|
27
|
+
*
|
|
28
|
+
* @param tx - The incoming transaction
|
|
29
|
+
* @param poolAccess - Read-only access to pool state
|
|
30
|
+
* @returns Result with rejection status and txs to evict
|
|
31
|
+
*/
|
|
32
|
+
async check(tx: Tx, poolAccess: PreAddPoolAccess): Promise<PreAddEvictionResult> {
|
|
33
|
+
const txHash = tx.getTxHash();
|
|
34
|
+
const nullifiers = tx.data.getNonEmptyNullifiers();
|
|
35
|
+
const txHashesToEvict: TxHash[] = [];
|
|
36
|
+
const incomingPriority = poolAccess.getTxPriority(tx);
|
|
37
|
+
|
|
38
|
+
for (const nullifier of nullifiers) {
|
|
39
|
+
const conflictingHash = await poolAccess.getTxHashByNullifier(nullifier);
|
|
40
|
+
|
|
41
|
+
if (
|
|
42
|
+
!conflictingHash ||
|
|
43
|
+
conflictingHash.equals(txHash) ||
|
|
44
|
+
findIndexInSortedArray(txHashesToEvict, conflictingHash, cmpTxHash) !== -1
|
|
45
|
+
) {
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// Get the conflicting tx's priority
|
|
50
|
+
const conflictingTx = await poolAccess.getPendingTxByHash(conflictingHash);
|
|
51
|
+
if (!conflictingTx) {
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const conflictingPriority = poolAccess.getTxPriority(conflictingTx);
|
|
56
|
+
|
|
57
|
+
// If incoming tx has strictly higher priority, mark for eviction
|
|
58
|
+
// Otherwise, reject incoming tx (ties go to existing tx)
|
|
59
|
+
if (incomingPriority > conflictingPriority) {
|
|
60
|
+
insertIntoSortedArray(txHashesToEvict, conflictingHash, cmpTxHash);
|
|
61
|
+
} else {
|
|
62
|
+
this.log.debug(
|
|
63
|
+
`Rejecting tx ${txHash.toString()}: nullifier conflict with ${conflictingHash.toString()} which has higher or equal fee`,
|
|
64
|
+
);
|
|
65
|
+
return {
|
|
66
|
+
shouldReject: true,
|
|
67
|
+
txHashesToEvict: [],
|
|
68
|
+
reason: `nullifier conflict with ${conflictingHash.toString()}`,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return { shouldReject: false, txHashesToEvict };
|
|
74
|
+
}
|
|
75
|
+
}
|
|
@@ -7,7 +7,14 @@ import type { Tx } from '@aztec/stdlib/tx';
|
|
|
7
7
|
* We currently use the sum of the priority fees for the tx for this value, represented as hex.
|
|
8
8
|
*/
|
|
9
9
|
export function getPendingTxPriority(tx: Tx): string {
|
|
10
|
+
return Buffer32.fromBigInt(getTxPriorityFee(tx)).toString();
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Returns the priority of a tx.
|
|
15
|
+
*/
|
|
16
|
+
export function getTxPriorityFee(tx: Tx): bigint {
|
|
10
17
|
const priorityFees = tx.getGasSettings().maxPriorityFeesPerGas;
|
|
11
18
|
const totalFees = priorityFees.feePerDaGas + priorityFees.feePerL2Gas;
|
|
12
|
-
return
|
|
19
|
+
return totalFees;
|
|
13
20
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import type { BlockNumber } from '@aztec/foundation/branded-types';
|
|
1
2
|
import type { TypedEventEmitter } from '@aztec/foundation/types';
|
|
2
3
|
import type { BlockHeader, Tx, TxHash } from '@aztec/stdlib/tx';
|
|
3
4
|
|
|
4
5
|
export type TxPoolOptions = {
|
|
5
|
-
|
|
6
|
-
txPoolOverflowFactor?: number;
|
|
6
|
+
maxPendingTxCount?: number;
|
|
7
7
|
archivedTxLimit?: number;
|
|
8
8
|
};
|
|
9
9
|
|
|
@@ -68,8 +68,9 @@ export interface TxPool extends TypedEventEmitter<TxPoolEvents> {
|
|
|
68
68
|
* Moves mined txs back to the pending set in the case of a reorg.
|
|
69
69
|
* Note: txs not known by this peer will be ignored.
|
|
70
70
|
* @param txHashes - Hashes of the txs to flag as pending.
|
|
71
|
+
* @param latestBlock - The block number the chain was pruned to.
|
|
71
72
|
*/
|
|
72
|
-
markMinedAsPending(txHashes: TxHash[]): Promise<void>;
|
|
73
|
+
markMinedAsPending(txHashes: TxHash[], latestBlock: BlockNumber): Promise<void>;
|
|
73
74
|
|
|
74
75
|
/**
|
|
75
76
|
* Deletes transactions from the pool. Tx hashes that are not present are ignored.
|
|
@@ -102,7 +103,7 @@ export interface TxPool extends TypedEventEmitter<TxPoolEvents> {
|
|
|
102
103
|
* Gets the hashes of mined transactions currently in the tx pool.
|
|
103
104
|
* @returns An array of mined transaction hashes found in the tx pool.
|
|
104
105
|
*/
|
|
105
|
-
getMinedTxHashes(): Promise<[tx: TxHash, blockNumber:
|
|
106
|
+
getMinedTxHashes(): Promise<[tx: TxHash, blockNumber: BlockNumber][]>;
|
|
106
107
|
|
|
107
108
|
/**
|
|
108
109
|
* Returns whether the given tx hash is flagged as pending, mined, or deleted.
|
|
@@ -126,10 +127,15 @@ export interface TxPool extends TypedEventEmitter<TxPoolEvents> {
|
|
|
126
127
|
*/
|
|
127
128
|
markTxsAsNonEvictable(txHashes: TxHash[]): Promise<void>;
|
|
128
129
|
|
|
130
|
+
/**
|
|
131
|
+
* Clears collection of non-evictable transactions in the pool
|
|
132
|
+
*/
|
|
133
|
+
clearNonEvictableTxs(): Promise<void>;
|
|
134
|
+
|
|
129
135
|
/**
|
|
130
136
|
* Permanently deletes deleted mined transactions from blocks up to and including the specified block number.
|
|
131
137
|
* @param blockNumber - Block number threshold. Deleted mined txs from this block or earlier will be permanently deleted.
|
|
132
138
|
* @returns The number of transactions permanently deleted.
|
|
133
139
|
*/
|
|
134
|
-
cleanupDeletedMinedTxs(blockNumber:
|
|
140
|
+
cleanupDeletedMinedTxs(blockNumber: BlockNumber): Promise<number>;
|
|
135
141
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
1
2
|
import { unfreeze } from '@aztec/foundation/types';
|
|
2
3
|
import { GasFees } from '@aztec/stdlib/gas';
|
|
3
4
|
import { mockTx } from '@aztec/stdlib/testing';
|
|
@@ -13,7 +14,7 @@ export function describeTxPool(getTxPool: () => TxPool) {
|
|
|
13
14
|
let pool: TxPool;
|
|
14
15
|
|
|
15
16
|
const minedBlockHeader = BlockHeader.empty({
|
|
16
|
-
globalVariables: GlobalVariables.empty({ blockNumber: 1, timestamp: 0n }),
|
|
17
|
+
globalVariables: GlobalVariables.empty({ blockNumber: BlockNumber(1), timestamp: 0n }),
|
|
17
18
|
});
|
|
18
19
|
|
|
19
20
|
beforeEach(() => {
|
|
@@ -25,7 +26,7 @@ export function describeTxPool(getTxPool: () => TxPool) {
|
|
|
25
26
|
});
|
|
26
27
|
|
|
27
28
|
it('adds txs to the pool as pending', async () => {
|
|
28
|
-
const tx1 = await mockTx();
|
|
29
|
+
const tx1 = await mockTx(1);
|
|
29
30
|
|
|
30
31
|
await pool.addTxs([tx1]);
|
|
31
32
|
const poolTx = await pool.getTxByHash(tx1.getTxHash());
|
|
@@ -36,9 +37,9 @@ export function describeTxPool(getTxPool: () => TxPool) {
|
|
|
36
37
|
});
|
|
37
38
|
|
|
38
39
|
it('emits txs-added event with new txs', async () => {
|
|
39
|
-
const tx1 = await mockTx(); // existing and pending
|
|
40
|
-
const tx2 = await mockTx(); // mined but not known
|
|
41
|
-
const tx3 = await mockTx(); // brand new
|
|
40
|
+
const tx1 = await mockTx(1); // existing and pending
|
|
41
|
+
const tx2 = await mockTx(2); // mined but not known
|
|
42
|
+
const tx3 = await mockTx(3); // brand new
|
|
42
43
|
|
|
43
44
|
await pool.addTxs([tx1]);
|
|
44
45
|
await pool.markAsMined([tx2.getTxHash()], minedBlockHeader);
|
|
@@ -51,10 +52,11 @@ export function describeTxPool(getTxPool: () => TxPool) {
|
|
|
51
52
|
await pool.addTxs([tx1, tx2, tx3]);
|
|
52
53
|
expect(txsFromEvent).toBeDefined();
|
|
53
54
|
expect(txsFromEvent).toHaveLength(2);
|
|
54
|
-
|
|
55
|
+
const eventHashes = txsFromEvent!.map(tx => tx.getTxHash());
|
|
56
|
+
expect(eventHashes).toEqual(expect.arrayContaining([tx2.getTxHash(), tx3.getTxHash()]));
|
|
55
57
|
});
|
|
56
58
|
|
|
57
|
-
it('
|
|
59
|
+
it('removes txs from the pool', async () => {
|
|
58
60
|
const pendingTx = await mockTx(1);
|
|
59
61
|
const minedTx = await mockTx(2);
|
|
60
62
|
|
|
@@ -82,7 +84,8 @@ export function describeTxPool(getTxPool: () => TxPool) {
|
|
|
82
84
|
await pool.addTxs([tx1, tx2]);
|
|
83
85
|
await pool.markAsMined([tx1.getTxHash()], minedBlockHeader);
|
|
84
86
|
|
|
85
|
-
await
|
|
87
|
+
const retrievedTx = await pool.getTxByHash(tx1.getTxHash());
|
|
88
|
+
expect(retrievedTx?.getTxHash()).toEqual(tx1.getTxHash());
|
|
86
89
|
await expect(pool.getTxStatus(tx1.getTxHash())).resolves.toEqual('mined');
|
|
87
90
|
await expect(pool.getMinedTxHashes()).resolves.toEqual([[tx1.getTxHash(), 1]]);
|
|
88
91
|
await expect(pool.getPendingTxHashes()).resolves.toEqual([tx2.getTxHash()]);
|
|
@@ -96,7 +99,7 @@ export function describeTxPool(getTxPool: () => TxPool) {
|
|
|
96
99
|
await pool.addTxs([tx1, tx2]);
|
|
97
100
|
await pool.markAsMined([tx1.getTxHash()], minedBlockHeader);
|
|
98
101
|
|
|
99
|
-
await pool.markMinedAsPending([tx1.getTxHash()]);
|
|
102
|
+
await pool.markMinedAsPending([tx1.getTxHash()], BlockNumber(1));
|
|
100
103
|
await expect(pool.getMinedTxHashes()).resolves.toEqual([]);
|
|
101
104
|
const pending = await pool.getPendingTxHashes();
|
|
102
105
|
expect(pending).toHaveLength(2);
|
|
@@ -120,7 +123,7 @@ export function describeTxPool(getTxPool: () => TxPool) {
|
|
|
120
123
|
);
|
|
121
124
|
|
|
122
125
|
// reorg: both txs should now become available again
|
|
123
|
-
await pool.markMinedAsPending([tx1.getTxHash(), someTxHashThatThisPeerDidNotSee]);
|
|
126
|
+
await pool.markMinedAsPending([tx1.getTxHash(), someTxHashThatThisPeerDidNotSee], BlockNumber(1));
|
|
124
127
|
await expect(pool.getMinedTxHashes()).resolves.toEqual([]);
|
|
125
128
|
await expect(pool.getPendingTxHashes()).resolves.toEqual([tx1.getTxHash()]); // tx2 is not in the pool
|
|
126
129
|
await expect(pool.getPendingTxCount()).resolves.toEqual(1);
|
|
@@ -135,7 +138,8 @@ export function describeTxPool(getTxPool: () => TxPool) {
|
|
|
135
138
|
|
|
136
139
|
const poolTxs = await pool.getAllTxs();
|
|
137
140
|
expect(poolTxs).toHaveLength(3);
|
|
138
|
-
|
|
141
|
+
const poolHashes = poolTxs.map(tx => tx.getTxHash());
|
|
142
|
+
expect(poolHashes).toEqual(expect.arrayContaining([tx1.getTxHash(), tx2.getTxHash(), tx3.getTxHash()]));
|
|
139
143
|
await expect(pool.getPendingTxCount()).resolves.toEqual(3);
|
|
140
144
|
});
|
|
141
145
|
|
|
@@ -162,17 +166,19 @@ export function describeTxPool(getTxPool: () => TxPool) {
|
|
|
162
166
|
|
|
163
167
|
const requestedTxs = await pool.getTxsByHash([tx1.getTxHash(), tx3.getTxHash()]);
|
|
164
168
|
expect(requestedTxs).toHaveLength(2);
|
|
165
|
-
|
|
169
|
+
const requestedHashes = requestedTxs.map(tx => tx!.getTxHash());
|
|
170
|
+
expect(requestedHashes).toEqual(expect.arrayContaining([tx1.getTxHash(), tx3.getTxHash()]));
|
|
166
171
|
});
|
|
167
172
|
|
|
168
173
|
it('returns a large number of transactions by their hash', async () => {
|
|
169
|
-
const numTxs =
|
|
174
|
+
const numTxs = 1_000;
|
|
170
175
|
const txs = await Promise.all(Array.from({ length: numTxs }, (_, i) => mockTx(i)));
|
|
171
176
|
const hashes = txs.map(tx => tx.getTxHash());
|
|
172
177
|
await pool.addTxs(txs);
|
|
173
178
|
const requestedTxs = await pool.getTxsByHash(hashes);
|
|
174
179
|
expect(requestedTxs).toHaveLength(numTxs);
|
|
175
|
-
|
|
180
|
+
const requestedHashes = requestedTxs.map(tx => tx!.getTxHash());
|
|
181
|
+
expect(requestedHashes).toEqual(expect.arrayContaining(hashes));
|
|
176
182
|
});
|
|
177
183
|
|
|
178
184
|
it('returns whether or not txs exist', async () => {
|
|
@@ -261,7 +267,7 @@ export function describeTxPool(getTxPool: () => TxPool) {
|
|
|
261
267
|
await pool.deleteTxs([txs[0].getTxHash(), txs[1].getTxHash()]);
|
|
262
268
|
|
|
263
269
|
// Clean up deleted mined txs from block 1 and earlier
|
|
264
|
-
const deletedCount = await pool.cleanupDeletedMinedTxs(1);
|
|
270
|
+
const deletedCount = await pool.cleanupDeletedMinedTxs(BlockNumber(1));
|
|
265
271
|
|
|
266
272
|
// Verify old transactions are permanently deleted
|
|
267
273
|
expect(deletedCount).toBe(2);
|
|
@@ -276,7 +282,7 @@ export function describeTxPool(getTxPool: () => TxPool) {
|
|
|
276
282
|
|
|
277
283
|
// Mark as mined in block 2
|
|
278
284
|
const laterBlockHeader = BlockHeader.empty({
|
|
279
|
-
globalVariables: GlobalVariables.empty({ blockNumber: 2, timestamp: 0n }),
|
|
285
|
+
globalVariables: GlobalVariables.empty({ blockNumber: BlockNumber(2), timestamp: 0n }),
|
|
280
286
|
});
|
|
281
287
|
await pool.markAsMined([txs[0].getTxHash()], laterBlockHeader);
|
|
282
288
|
|
|
@@ -284,7 +290,7 @@ export function describeTxPool(getTxPool: () => TxPool) {
|
|
|
284
290
|
await pool.deleteTxs([txs[0].getTxHash()]);
|
|
285
291
|
|
|
286
292
|
// Try to clean up with block 1 (before the mined block)
|
|
287
|
-
const deletedCount = await pool.cleanupDeletedMinedTxs(1);
|
|
293
|
+
const deletedCount = await pool.cleanupDeletedMinedTxs(BlockNumber(1));
|
|
288
294
|
|
|
289
295
|
// Verify no transactions were cleaned up
|
|
290
296
|
expect(deletedCount).toBe(0);
|
|
@@ -0,0 +1,275 @@
|
|
|
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() │ eviction after reorg
|
|
33
|
+
│ / eviction / failed exec │ (validation failure)
|
|
34
|
+
▼ ▼
|
|
35
|
+
┌─────────────────────────────────────┐ ┌─────────────────────────────────────┐
|
|
36
|
+
│ SLOT-SOFT-DELETED │ │ PRUNE-SOFT-DELETED │
|
|
37
|
+
│ (kept in DB until next slot) │ │ (kept in DB until finalized) │
|
|
38
|
+
└─────────────────────────────────────┘ └─────────────────────────────────────┘
|
|
39
|
+
│ │
|
|
40
|
+
│ prepareForSlot() │ handleFinalizedBlock()
|
|
41
|
+
│ (slot advanced) │ (mined block finalized)
|
|
42
|
+
▼ ▼
|
|
43
|
+
┌─────────────────────────────────────┐ ┌─────────────────────────────────────┐
|
|
44
|
+
│ HARD-DELETED │ │ HARD-DELETED │
|
|
45
|
+
│ (permanently removed from DB) │ │ (permanently removed from DB) │
|
|
46
|
+
└─────────────────────────────────────┘ └─────────────────────────────────────┘
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Key Components
|
|
50
|
+
|
|
51
|
+
### TxPoolV2 (`tx_pool_v2.ts`)
|
|
52
|
+
|
|
53
|
+
The public API wrapper that serializes all operations through a queue to prevent race conditions. Delegates to `TxPoolV2Impl` for actual logic.
|
|
54
|
+
|
|
55
|
+
### TxPoolV2Impl (`tx_pool_v2_impl.ts`)
|
|
56
|
+
|
|
57
|
+
Core implementation containing:
|
|
58
|
+
- KV store persistence for transactions and metadata
|
|
59
|
+
- In-memory indices for fast lookups (by nullifier, fee payer, priority)
|
|
60
|
+
- State transition logic
|
|
61
|
+
- Pre-add rule execution
|
|
62
|
+
- Post-event eviction rule execution
|
|
63
|
+
|
|
64
|
+
### DeletedPool (`deleted_pool.ts`)
|
|
65
|
+
|
|
66
|
+
Manages all transaction deletions in the pool with two soft-deletion mechanisms:
|
|
67
|
+
- **Slot-based**: Non-pruned txs are kept in DB until the next slot, allowing other nodes to fetch them via reqresp
|
|
68
|
+
- **Prune-based**: Txs from pruned blocks are kept in DB until their original mined block is finalized
|
|
69
|
+
|
|
70
|
+
All deletions go through `DeletedPool.deleteTx()`, which routes to the appropriate path based on whether the tx is tracked as being from a pruned block.
|
|
71
|
+
|
|
72
|
+
### TxMetaData (`tx_metadata.ts`)
|
|
73
|
+
|
|
74
|
+
Lightweight metadata stored alongside each transaction:
|
|
75
|
+
- `txHash`: Transaction identifier
|
|
76
|
+
- `anchorBlockHeaderHash`: Hash of the anchor block header
|
|
77
|
+
- `priorityFee`: For priority ordering and challenges
|
|
78
|
+
- `feePayer`: For balance-based eviction
|
|
79
|
+
- `claimAmount`: Fee payer's claim from bridging
|
|
80
|
+
- `feeLimit`: Maximum fee the tx can pay
|
|
81
|
+
- `nullifiers`: For conflict detection
|
|
82
|
+
- `expirationTimestamp`: Expiration timestamp
|
|
83
|
+
- `minedL2BlockId`: Set when mined (undefined otherwise)
|
|
84
|
+
|
|
85
|
+
State is derived by TxPoolIndices:
|
|
86
|
+
- `mined` if `minedL2BlockId` is set
|
|
87
|
+
- `protected` if in protection map
|
|
88
|
+
- `deleted` if soft-deleted (slot-based or prune-based, evicted but kept in DB)
|
|
89
|
+
- `pending` otherwise
|
|
90
|
+
|
|
91
|
+
## Soft Deletion
|
|
92
|
+
|
|
93
|
+
Deleted transactions are kept in the database for a grace period before being permanently removed. There are two soft-deletion mechanisms:
|
|
94
|
+
|
|
95
|
+
### Slot-Based Soft Deletion
|
|
96
|
+
|
|
97
|
+
When a transaction is deleted from the pool (eviction, validation failure, failed execution) and is **not** from a pruned block, it is "slot-soft-deleted":
|
|
98
|
+
|
|
99
|
+
1. **Soft Delete**: The tx is removed from indices but kept in the database, tagged with the current slot number
|
|
100
|
+
2. **Retrieval**: Slot-soft-deleted txs can still be retrieved via `getTxByHash` and return status `'deleted'` from `getTxStatus`
|
|
101
|
+
3. **Hard Delete**: When `prepareForSlot` advances to a new slot, txs deleted in earlier slots are permanently removed
|
|
102
|
+
4. **Re-addition**: If a slot-soft-deleted tx is re-added to the pool, the slot-deleted tracking is cleared
|
|
103
|
+
|
|
104
|
+
This allows other nodes to still fetch recently-deleted transactions via reqresp during the current slot.
|
|
105
|
+
|
|
106
|
+
### Prune-Based Soft Deletion
|
|
107
|
+
|
|
108
|
+
When a chain reorganization occurs, transactions that were mined in pruned blocks are handled with longer retention:
|
|
109
|
+
|
|
110
|
+
1. **Tracking**: When `handlePrunedBlocks` is called, all un-mined transactions are tracked by their original mined block number
|
|
111
|
+
2. **Soft Delete**: If these transactions are later evicted (failed validation, nullifier conflict, etc.), they are "prune-soft-deleted" - removed from indices but kept in the database
|
|
112
|
+
3. **Retrieval**: Prune-soft-deleted txs can still be retrieved via `getTxByHash` and return status `'deleted'` from `getTxStatus`
|
|
113
|
+
4. **Hard Delete**: When `handleFinalizedBlock` is called and the finalized block number reaches or exceeds the transaction's original mined block, the transaction is permanently removed
|
|
114
|
+
5. **Re-addition**: If a prune-soft-deleted tx is re-added, the `softDeleted` flag is reset to `false` but the prune tracking is preserved, so a subsequent deletion still uses the prune path
|
|
115
|
+
|
|
116
|
+
Prune-soft-deleted transactions are **not** affected by slot cleanup - they survive across slot boundaries until finalized.
|
|
117
|
+
|
|
118
|
+
**Prune example:**
|
|
119
|
+
1. Tx mined at block 10
|
|
120
|
+
2. Chain prunes to block 5 (tx becomes un-mined, tracked as minedAtBlock=10)
|
|
121
|
+
3. Tx fails validation and is prune-soft-deleted
|
|
122
|
+
4. Block 9 finalized → tx still in DB (minedAtBlock=10 > finalized=9)
|
|
123
|
+
5. Block 10 finalized → tx hard-deleted (minedAtBlock=10 ≤ finalized=10)
|
|
124
|
+
|
|
125
|
+
If the tx is re-mined at a higher block before being soft-deleted:
|
|
126
|
+
1. Tx mined at block 10, pruned (tracked as minedAtBlock=10)
|
|
127
|
+
2. Tx re-mined at block 15, pruned again (updated to minedAtBlock=15)
|
|
128
|
+
3. Tx soft-deleted
|
|
129
|
+
4. Block 10 finalized → tx still in DB
|
|
130
|
+
5. Block 15 finalized → tx hard-deleted
|
|
131
|
+
|
|
132
|
+
### Hydration
|
|
133
|
+
|
|
134
|
+
On node restart, slot-soft-deleted transactions are immediately hard-deleted (they are stale by definition). Prune-soft-deleted transactions are loaded from the database and tracked normally.
|
|
135
|
+
|
|
136
|
+
## Architecture: Pre-add vs Post-event Rules
|
|
137
|
+
|
|
138
|
+
**Pre-add rules** (run during `addPendingTxs`):
|
|
139
|
+
- Used for external transactions entering the pool
|
|
140
|
+
- Can reject the incoming tx entirely
|
|
141
|
+
- Can evict lower-priority existing txs to make room
|
|
142
|
+
- Rules: NullifierConflictRule, FeePayerBalancePreAddRule, LowPriorityPreAddRule
|
|
143
|
+
|
|
144
|
+
**Post-event rules** (run after state transitions):
|
|
145
|
+
- Used for internal state changes (block mined, reorg, slot change)
|
|
146
|
+
- Only evict txs already in the pool
|
|
147
|
+
- Rules: InvalidTxsAfterMiningRule, InvalidTxsAfterReorgRule, FeePayerBalanceEvictionRule, LowPriorityEvictionRule
|
|
148
|
+
|
|
149
|
+
This design choice means restored txs (from protected/mined states) use post-event rules only, because they were already validated on initial submission.
|
|
150
|
+
|
|
151
|
+
## Eviction Rules
|
|
152
|
+
|
|
153
|
+
The pool uses a pluggable rule system for managing transactions.
|
|
154
|
+
|
|
155
|
+
### Pre-Add Rules
|
|
156
|
+
|
|
157
|
+
Checked before adding a transaction to the pending pool:
|
|
158
|
+
|
|
159
|
+
| Rule | Purpose |
|
|
160
|
+
|------|---------|
|
|
161
|
+
| `NullifierConflictRule` | Handles transactions with conflicting nullifiers. Higher priority tx wins. |
|
|
162
|
+
| `FeePayerBalancePreAddRule` | Ensures fee payer has sufficient balance for all their pending txs. |
|
|
163
|
+
| `LowPriorityPreAddRule` | Rejects txs when pool is full and new tx has lowest priority. |
|
|
164
|
+
|
|
165
|
+
### Post-Event Eviction Rules
|
|
166
|
+
|
|
167
|
+
Run after events to clean up the pool:
|
|
168
|
+
|
|
169
|
+
| Rule | Trigger | Purpose |
|
|
170
|
+
|------|---------|---------|
|
|
171
|
+
| `LowPriorityEvictionRule` | `txs_added` | Evicts lowest priority txs when pool exceeds limit. |
|
|
172
|
+
| `FeePayerBalanceEvictionRule` | `txs_added`, `block_mined`, `chain_pruned` | Evicts txs when fee payer has insufficient balance. |
|
|
173
|
+
| `InvalidTxsAfterMiningRule` | `block_mined` | Evicts pending txs with: (1) nullifiers in mined block, (2) expired timestamp. |
|
|
174
|
+
| `InvalidTxsAfterReorgRule` | `chain_pruned` | Evicts txs with invalid anchor blocks after reorg. |
|
|
175
|
+
|
|
176
|
+
## Usage
|
|
177
|
+
|
|
178
|
+
### Creating a Pool
|
|
179
|
+
|
|
180
|
+
```typescript
|
|
181
|
+
import { AztecKVTxPoolV2 } from './tx_pool_v2.js';
|
|
182
|
+
|
|
183
|
+
const pool = new AztecKVTxPoolV2(txStore, archiveStore, {
|
|
184
|
+
l2BlockSource: archiver,
|
|
185
|
+
worldStateSynchronizer: worldState,
|
|
186
|
+
createTxValidator: () => validator,
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
await pool.start();
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
### Adding Transactions
|
|
193
|
+
|
|
194
|
+
```typescript
|
|
195
|
+
// Add to pending pool (validates and runs pre-add rules)
|
|
196
|
+
const result = await pool.addPendingTxs(txs, { source: 'gossip' });
|
|
197
|
+
// result: { accepted: TxHash[], ignored: TxHash[], rejected: TxHash[] }
|
|
198
|
+
|
|
199
|
+
// Check without modifying pool
|
|
200
|
+
const canAdd = await pool.canAddPendingTx(tx);
|
|
201
|
+
// canAdd: 'accepted' | 'ignored' | 'rejected'
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
### Block Building Flow
|
|
205
|
+
|
|
206
|
+
```typescript
|
|
207
|
+
// 1. Proposer protects txs for their block
|
|
208
|
+
await pool.protectTxs(selectedTxHashes, blockHeader);
|
|
209
|
+
|
|
210
|
+
// 2. On successful mining
|
|
211
|
+
await pool.handleMinedBlock(minedTxHashes, blockHeader);
|
|
212
|
+
|
|
213
|
+
// 3. If slot passes without mining
|
|
214
|
+
await pool.prepareForSlot(nextSlotNumber);
|
|
215
|
+
|
|
216
|
+
// 4. On finalization
|
|
217
|
+
await pool.handleFinalizedBlock(finalizedBlockHeader);
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
### Handling Reorgs
|
|
221
|
+
|
|
222
|
+
```typescript
|
|
223
|
+
// When blocks are pruned, un-mine affected transactions
|
|
224
|
+
await pool.handlePrunedBlocks(latestValidBlockId);
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
## Configuration
|
|
228
|
+
|
|
229
|
+
```typescript
|
|
230
|
+
await pool.updateConfig({
|
|
231
|
+
maxPendingTxCount: 10000, // 0 = unlimited
|
|
232
|
+
archivedTxLimit: 1000, // 0 = disabled
|
|
233
|
+
});
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
## Return Values
|
|
237
|
+
|
|
238
|
+
### AddTxsResult
|
|
239
|
+
|
|
240
|
+
When adding pending transactions, each tx is categorized:
|
|
241
|
+
|
|
242
|
+
| Status | Meaning |
|
|
243
|
+
|--------|---------|
|
|
244
|
+
| `accepted` | Successfully added to the pool |
|
|
245
|
+
| `ignored` | Valid but not added (duplicate, lost nullifier conflict, insufficient balance) |
|
|
246
|
+
| `rejected` | Failed validation (invalid proof, expired, etc.) |
|
|
247
|
+
|
|
248
|
+
## Archive
|
|
249
|
+
|
|
250
|
+
Finalized transactions can optionally be archived for historical queries:
|
|
251
|
+
|
|
252
|
+
```typescript
|
|
253
|
+
const archivedTx = await pool.getArchivedTxByHash(txHash);
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
The archive uses FIFO eviction when `archivedTxLimit` is reached.
|
|
257
|
+
|
|
258
|
+
## Testing
|
|
259
|
+
|
|
260
|
+
```bash
|
|
261
|
+
# Unit tests (177 tests)
|
|
262
|
+
yarn test src/mem_pools/tx_pool_v2/tx_pool_v2.test.ts
|
|
263
|
+
|
|
264
|
+
# Deleted pool tests (17 tests)
|
|
265
|
+
yarn test src/mem_pools/tx_pool_v2/deleted_pool.test.ts
|
|
266
|
+
|
|
267
|
+
# Compatibility tests (25 tests)
|
|
268
|
+
yarn test src/mem_pools/tx_pool_v2/tx_pool_v2.compat.test.ts
|
|
269
|
+
|
|
270
|
+
# Eviction rule tests
|
|
271
|
+
yarn test src/mem_pools/tx_pool_v2/eviction/
|
|
272
|
+
|
|
273
|
+
# Benchmarks
|
|
274
|
+
yarn test src/mem_pools/tx_pool_v2/tx_pool_v2_bench.test.ts
|
|
275
|
+
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { TxArchive } from './tx_archive.js';
|