@aztec/p2p 0.0.1-commit.f295ac2 → 0.0.1-commit.f8ca9b2f3
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 +5 -5
- package/dest/client/factory.d.ts.map +1 -1
- package/dest/client/factory.js +47 -13
- package/dest/client/interface.d.ts +33 -15
- package/dest/client/interface.d.ts.map +1 -1
- package/dest/client/p2p_client.d.ts +35 -36
- package/dest/client/p2p_client.d.ts.map +1 -1
- package/dest/client/p2p_client.js +115 -139
- 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 +24 -3
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +16 -2
- 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 +102 -88
- package/dest/mem_pools/attestation_pool/attestation_pool.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/attestation_pool.js +436 -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 +353 -87
- 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 +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 +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 +5 -5
- 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/deleted_pool.d.ts +87 -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 +180 -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 +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/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 +93 -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 +127 -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 +751 -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/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 +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 +22 -5
- package/dest/msg_validators/tx_validator/timestamp_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/timestamp_validator.js +4 -4
- 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 +22 -2
- package/dest/services/dummy_service.d.ts.map +1 -1
- package/dest/services/dummy_service.js +45 -0
- package/dest/services/encoding.d.ts +2 -2
- package/dest/services/encoding.d.ts.map +1 -1
- package/dest/services/encoding.js +4 -5
- 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 +91 -36
- package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
- package/dest/services/libp2p/libp2p_service.js +407 -303
- 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 +14 -3
- package/dest/services/reqresp/interface.d.ts.map +1 -1
- package/dest/services/reqresp/interface.js +17 -3
- 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 +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 +29 -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 +59 -13
- package/dest/services/reqresp/protocols/tx.d.ts +7 -1
- package/dest/services/reqresp/protocols/tx.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/tx.js +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 +69 -26
- package/dest/services/service.d.ts +38 -1
- package/dest/services/service.d.ts.map +1 -1
- package/dest/services/tx_collection/config.d.ts +10 -1
- package/dest/services/tx_collection/config.d.ts.map +1 -1
- package/dest/services/tx_collection/config.js +25 -1
- package/dest/services/tx_collection/fast_tx_collection.d.ts +7 -4
- package/dest/services/tx_collection/fast_tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/fast_tx_collection.js +34 -13
- package/dest/services/tx_collection/file_store_tx_collection.d.ts +44 -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 +118 -0
- package/dest/services/tx_collection/file_store_tx_source.d.ts +27 -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 +57 -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 +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 +5 -3
- package/dest/services/tx_collection/slow_tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/slow_tx_collection.js +48 -19
- package/dest/services/tx_collection/tx_collection.d.ts +23 -13
- package/dest/services/tx_collection/tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/tx_collection.js +62 -6
- package/dest/services/tx_collection/tx_collection_sink.d.ts +15 -6
- package/dest/services/tx_collection/tx_collection_sink.d.ts.map +1 -1
- package/dest/services/tx_collection/tx_collection_sink.js +13 -7
- 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 +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 +5 -5
- package/dest/services/tx_provider.d.ts.map +1 -1
- package/dest/services/tx_provider.js +5 -4
- 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/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 +27 -1
- package/dest/test-helpers/mock-pubsub.d.ts.map +1 -1
- package/dest/test-helpers/mock-pubsub.js +97 -2
- 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 +158 -0
- package/dest/test-helpers/testbench-utils.d.ts.map +1 -0
- package/dest/test-helpers/testbench-utils.js +360 -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 +213 -134
- 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 +78 -22
- package/src/client/interface.ts +39 -14
- package/src/client/p2p_client.ts +155 -166
- 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 +38 -2
- package/src/index.ts +1 -0
- package/src/mem_pools/attestation_pool/attestation_pool.ts +488 -91
- package/src/mem_pools/attestation_pool/attestation_pool_test_suite.ts +442 -102
- package/src/mem_pools/attestation_pool/index.ts +9 -2
- package/src/mem_pools/index.ts +4 -1
- package/src/mem_pools/instrumentation.ts +2 -1
- package/src/mem_pools/interface.ts +4 -4
- 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 +259 -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 +234 -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 +12 -0
- package/src/mem_pools/tx_pool_v2/interfaces.ts +227 -0
- package/src/mem_pools/tx_pool_v2/tx_metadata.ts +207 -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 +895 -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/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 +6 -2
- package/src/msg_validators/tx_validator/double_spend_validator.ts +15 -9
- 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 +25 -17
- 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 +57 -0
- package/src/services/encoding.ts +4 -5
- 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 +437 -316
- 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 +31 -3
- 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 +35 -12
- package/src/services/reqresp/protocols/block_txs/block_txs_reqresp.ts +74 -9
- package/src/services/reqresp/protocols/tx.ts +22 -0
- package/src/services/reqresp/reqresp.ts +79 -22
- package/src/services/service.ts +44 -0
- package/src/services/tx_collection/config.ts +41 -1
- package/src/services/tx_collection/fast_tx_collection.ts +44 -19
- package/src/services/tx_collection/file_store_tx_collection.ts +152 -0
- package/src/services/tx_collection/file_store_tx_source.ts +70 -0
- package/src/services/tx_collection/index.ts +6 -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 +57 -28
- package/src/services/tx_collection/tx_collection.ts +86 -20
- package/src/services/tx_collection/tx_collection_sink.ts +17 -7
- 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 +173 -0
- package/src/services/tx_provider.ts +10 -9
- package/src/services/tx_provider_instrumentation.ts +11 -5
- 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 +133 -3
- 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 +422 -0
- package/src/testbench/p2p_client_testbench_worker.ts +322 -127
- 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
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
2
|
+
/**
|
|
3
|
+
* Serializes DeletedTxState to a Buffer.
|
|
4
|
+
* Format: 4 bytes for blockNumber (uint32) + 1 byte for softDeleted (0 or 1)
|
|
5
|
+
*/ function serializeState(state) {
|
|
6
|
+
const buffer = Buffer.alloc(5);
|
|
7
|
+
buffer.writeUInt32BE(Number(state.minedAtBlock), 0);
|
|
8
|
+
buffer.writeUInt8(state.softDeleted ? 1 : 0, 4);
|
|
9
|
+
return buffer;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Deserializes a Buffer to DeletedTxState.
|
|
13
|
+
*/ function deserializeState(buffer) {
|
|
14
|
+
return {
|
|
15
|
+
minedAtBlock: BlockNumber(buffer.readUInt32BE(0)),
|
|
16
|
+
softDeleted: buffer.readUInt8(4) === 1
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Manages all transaction deletions in the pool.
|
|
21
|
+
*
|
|
22
|
+
* When a chain prune (reorg) happens, transactions from pruned blocks are tracked here.
|
|
23
|
+
* This class is responsible for ALL deletion decisions:
|
|
24
|
+
*
|
|
25
|
+
* - Transactions from pruned blocks are "soft deleted" - removed from indices but kept
|
|
26
|
+
* in the database for later re-execution
|
|
27
|
+
* - Transactions NOT from pruned blocks are "hard deleted" - completely removed from DB
|
|
28
|
+
*
|
|
29
|
+
* When a block is finalized, soft-deleted transactions that were originally mined at or
|
|
30
|
+
* before that block number are permanently (hard) deleted.
|
|
31
|
+
*/ export class DeletedPool {
|
|
32
|
+
/** Persisted map: txHash -> DeletedTxState (serialized) */ #deletedTxsDB;
|
|
33
|
+
/** Reference to the main txs database for hard deletion */ #txsDB;
|
|
34
|
+
/** In-memory state for transactions from pruned blocks */ #state = new Map();
|
|
35
|
+
#log;
|
|
36
|
+
constructor(store, txsDB, log){
|
|
37
|
+
this.#deletedTxsDB = store.openMap('deleted_txs');
|
|
38
|
+
this.#txsDB = txsDB;
|
|
39
|
+
this.#log = log;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Loads state from the database on startup.
|
|
43
|
+
*/ async hydrateFromDatabase() {
|
|
44
|
+
let prunedCount = 0;
|
|
45
|
+
let softDeletedCount = 0;
|
|
46
|
+
for await (const [txHash, buffer] of this.#deletedTxsDB.entriesAsync()){
|
|
47
|
+
const state = deserializeState(buffer);
|
|
48
|
+
this.#state.set(txHash, state);
|
|
49
|
+
prunedCount++;
|
|
50
|
+
if (state.softDeleted) {
|
|
51
|
+
softDeletedCount++;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
if (prunedCount > 0 || softDeletedCount > 0) {
|
|
55
|
+
this.#log.info(`Loaded ${prunedCount} txs from pruned blocks, ${softDeletedCount} soft-deleted`);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Marks transactions as being from a pruned block.
|
|
60
|
+
* Called during handlePrunedBlocks for ALL transactions that were un-mined.
|
|
61
|
+
*
|
|
62
|
+
* If a tx was previously tracked (e.g., mined at block 4, pruned, re-mined at block 5,
|
|
63
|
+
* pruned again), updates to the higher block number. This ensures the tx is kept until
|
|
64
|
+
* its most recent mined block is finalized.
|
|
65
|
+
*
|
|
66
|
+
* @param txs - Array of {txHash, minedAtBlock} pairs, where minedAtBlock is the block
|
|
67
|
+
* number in which the tx was mined before being un-mined
|
|
68
|
+
*/ async markFromPrunedBlock(txs) {
|
|
69
|
+
if (txs.length === 0) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
let count = 0;
|
|
73
|
+
for (const { txHash, minedAtBlock } of txs){
|
|
74
|
+
const existing = this.#state.get(txHash);
|
|
75
|
+
// Update if not tracked, or if this is a higher mined block (tx was re-mined then pruned again)
|
|
76
|
+
if (existing === undefined || minedAtBlock > existing.minedAtBlock) {
|
|
77
|
+
const state = {
|
|
78
|
+
minedAtBlock,
|
|
79
|
+
softDeleted: existing?.softDeleted ?? false
|
|
80
|
+
};
|
|
81
|
+
this.#state.set(txHash, state);
|
|
82
|
+
await this.#deletedTxsDB.set(txHash, serializeState(state));
|
|
83
|
+
count++;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
if (count > 0) {
|
|
87
|
+
this.#log.debug(`Marked ${count} transactions from pruned blocks`);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Deletes a transaction. This is the single entry point for ALL deletions.
|
|
92
|
+
*
|
|
93
|
+
* - If the tx is from a pruned block: soft-delete (keep in DB, mark as deleted)
|
|
94
|
+
* - If the tx is NOT from a pruned block: hard-delete (remove from DB)
|
|
95
|
+
*
|
|
96
|
+
* @returns 'soft' if soft-deleted, 'hard' if hard-deleted
|
|
97
|
+
*/ async deleteTx(txHash) {
|
|
98
|
+
const existing = this.#state.get(txHash);
|
|
99
|
+
if (existing !== undefined) {
|
|
100
|
+
// Soft delete - keep in DB
|
|
101
|
+
const state = {
|
|
102
|
+
minedAtBlock: existing.minedAtBlock,
|
|
103
|
+
softDeleted: true
|
|
104
|
+
};
|
|
105
|
+
this.#state.set(txHash, state);
|
|
106
|
+
await this.#deletedTxsDB.set(txHash, serializeState(state));
|
|
107
|
+
return 'soft';
|
|
108
|
+
} else {
|
|
109
|
+
// Hard delete - remove from DB
|
|
110
|
+
await this.#txsDB.delete(txHash);
|
|
111
|
+
return 'hard';
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Clears tracking for a transaction if it re-mines at a block number >= the tracked minedAtBlock.
|
|
116
|
+
*
|
|
117
|
+
* When a tx re-mines at a higher (or equal) block, the old high-water mark is no longer needed:
|
|
118
|
+
* any future prune would re-add the tx with an even higher block number. Clearing keeps
|
|
119
|
+
* DeletedPool consistent — only txs that are actually un-mined should be tracked here.
|
|
120
|
+
*
|
|
121
|
+
* When a tx re-mines at a lower block, we must preserve the existing entry to retain
|
|
122
|
+
* the high-water mark for re-execution purposes.
|
|
123
|
+
*/ async clearIfMinedHigher(txHash, minedAtBlock) {
|
|
124
|
+
const existing = this.#state.get(txHash);
|
|
125
|
+
if (existing !== undefined && minedAtBlock >= existing.minedAtBlock) {
|
|
126
|
+
this.#state.delete(txHash);
|
|
127
|
+
await this.#deletedTxsDB.delete(txHash);
|
|
128
|
+
this.#log.debug(`Cleared tracking for tx ${txHash}: re-mined at block ${minedAtBlock} (was ${existing.minedAtBlock})`);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Checks if a transaction is from a pruned block.
|
|
133
|
+
*/ isFromPrunedBlock(txHash) {
|
|
134
|
+
return this.#state.has(txHash);
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Checks if a transaction is soft-deleted.
|
|
138
|
+
*/ isSoftDeleted(txHash) {
|
|
139
|
+
return this.#state.get(txHash)?.softDeleted ?? false;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Gets the block number in which a transaction was originally mined.
|
|
143
|
+
*/ getMinedAtBlock(txHash) {
|
|
144
|
+
return this.#state.get(txHash)?.minedAtBlock;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Finalizes transactions when a block is finalized.
|
|
148
|
+
* Hard-deletes transactions that were originally mined at or before the finalized block.
|
|
149
|
+
*
|
|
150
|
+
* @returns The hashes of transactions that were hard-deleted
|
|
151
|
+
*/ async finalizeBlock(finalizedBlockNumber) {
|
|
152
|
+
const toHardDelete = [];
|
|
153
|
+
for (const [txHash, state] of this.#state){
|
|
154
|
+
if (state.softDeleted && state.minedAtBlock <= finalizedBlockNumber) {
|
|
155
|
+
toHardDelete.push(txHash);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
if (toHardDelete.length === 0) {
|
|
159
|
+
return [];
|
|
160
|
+
}
|
|
161
|
+
// Hard-delete from all stores
|
|
162
|
+
for (const txHash of toHardDelete){
|
|
163
|
+
this.#state.delete(txHash);
|
|
164
|
+
await this.#deletedTxsDB.delete(txHash);
|
|
165
|
+
await this.#txsDB.delete(txHash);
|
|
166
|
+
}
|
|
167
|
+
this.#log.debug(`Finalized ${toHardDelete.length} txs from pruned blocks at block ${finalizedBlockNumber}`);
|
|
168
|
+
return toHardDelete;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Gets the count of transactions from pruned blocks.
|
|
172
|
+
*/ getCount() {
|
|
173
|
+
return this.#state.size;
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Gets all transaction hashes from pruned blocks.
|
|
177
|
+
*/ getPrunedTxHashes() {
|
|
178
|
+
return Array.from(this.#state.keys());
|
|
179
|
+
}
|
|
180
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
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
|
+
import type { TxMetaData } from '../tx_metadata.js';
|
|
5
|
+
import { type EvictionConfig, type EvictionRule, type PoolOperations, type PreAddPoolAccess, type PreAddResult, type PreAddRule } from './interfaces.js';
|
|
6
|
+
/**
|
|
7
|
+
* Manages eviction rules for the transaction pool.
|
|
8
|
+
* Coordinates pre-add rules (run during addPendingTxs) and post-event rules (run after events).
|
|
9
|
+
*/
|
|
10
|
+
export declare class EvictionManager {
|
|
11
|
+
private pool;
|
|
12
|
+
private log;
|
|
13
|
+
private preAddRules;
|
|
14
|
+
private postEventRules;
|
|
15
|
+
constructor(pool: PoolOperations, log: Logger);
|
|
16
|
+
/**
|
|
17
|
+
* Registers a pre-add rule that runs during transaction addition.
|
|
18
|
+
*/
|
|
19
|
+
registerPreAddRule(rule: PreAddRule): void;
|
|
20
|
+
/**
|
|
21
|
+
* Registers a post-event eviction rule that runs after events.
|
|
22
|
+
*/
|
|
23
|
+
registerRule(rule: EvictionRule): void;
|
|
24
|
+
/**
|
|
25
|
+
* Runs all pre-add rules for an incoming transaction.
|
|
26
|
+
* Returns combined result of all rules.
|
|
27
|
+
*/
|
|
28
|
+
runPreAddRules(incomingMeta: TxMetaData, poolAccess: PreAddPoolAccess): Promise<PreAddResult>;
|
|
29
|
+
/**
|
|
30
|
+
* Runs post-event eviction after new transactions are added.
|
|
31
|
+
*/
|
|
32
|
+
evictAfterNewTxs(newTxHashes: string[], feePayers: string[]): Promise<void>;
|
|
33
|
+
/**
|
|
34
|
+
* Runs post-event eviction after a block is mined.
|
|
35
|
+
*/
|
|
36
|
+
evictAfterNewBlock(block: BlockHeader, newNullifiers: string[], feePayers: string[]): Promise<void>;
|
|
37
|
+
/**
|
|
38
|
+
* Runs post-event eviction after a chain prune (reorg).
|
|
39
|
+
*/
|
|
40
|
+
evictAfterChainPrune(blockNumber: BlockNumber): Promise<void>;
|
|
41
|
+
/**
|
|
42
|
+
* Updates configuration for all rules.
|
|
43
|
+
*/
|
|
44
|
+
updateConfig(config: EvictionConfig): void;
|
|
45
|
+
private runPostEventRules;
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZXZpY3Rpb25fbWFuYWdlci5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vc3JjL21lbV9wb29scy90eF9wb29sX3YyL2V2aWN0aW9uL2V2aWN0aW9uX21hbmFnZXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxLQUFLLEVBQUUsV0FBVyxFQUFFLE1BQU0saUNBQWlDLENBQUM7QUFDbkUsT0FBTyxLQUFLLEVBQUUsTUFBTSxFQUFFLE1BQU0sdUJBQXVCLENBQUM7QUFDcEQsT0FBTyxLQUFLLEVBQUUsV0FBVyxFQUFFLE1BQU0sa0JBQWtCLENBQUM7QUFFcEQsT0FBTyxLQUFLLEVBQUUsVUFBVSxFQUFFLE1BQU0sbUJBQW1CLENBQUM7QUFDcEQsT0FBTyxFQUNMLEtBQUssY0FBYyxFQUduQixLQUFLLFlBQVksRUFDakIsS0FBSyxjQUFjLEVBQ25CLEtBQUssZ0JBQWdCLEVBQ3JCLEtBQUssWUFBWSxFQUNqQixLQUFLLFVBQVUsRUFDaEIsTUFBTSxpQkFBaUIsQ0FBQztBQUV6Qjs7O0dBR0c7QUFDSCxxQkFBYSxlQUFlO0lBS3hCLE9BQU8sQ0FBQyxJQUFJO0lBQ1osT0FBTyxDQUFDLEdBQUc7SUFMYixPQUFPLENBQUMsV0FBVyxDQUFvQjtJQUN2QyxPQUFPLENBQUMsY0FBYyxDQUFzQjtJQUU1QyxZQUNVLElBQUksRUFBRSxjQUFjLEVBQ3BCLEdBQUcsRUFBRSxNQUFNLEVBQ2pCO0lBRUo7O09BRUc7SUFDSCxrQkFBa0IsQ0FBQyxJQUFJLEVBQUUsVUFBVSxHQUFHLElBQUksQ0FHekM7SUFFRDs7T0FFRztJQUNILFlBQVksQ0FBQyxJQUFJLEVBQUUsWUFBWSxHQUFHLElBQUksQ0FHckM7SUFFRDs7O09BR0c7SUFDRyxjQUFjLENBQUMsWUFBWSxFQUFFLFVBQVUsRUFBRSxVQUFVLEVBQUUsZ0JBQWdCLEdBQUcsT0FBTyxDQUFDLFlBQVksQ0FBQyxDQWdDbEc7SUFFRDs7T0FFRztJQUNHLGdCQUFnQixDQUFDLFdBQVcsRUFBRSxNQUFNLEVBQUUsRUFBRSxTQUFTLEVBQUUsTUFBTSxFQUFFLEdBQUcsT0FBTyxDQUFDLElBQUksQ0FBQyxDQVFoRjtJQUVEOztPQUVHO0lBQ0csa0JBQWtCLENBQUMsS0FBSyxFQUFFLFdBQVcsRUFBRSxhQUFhLEVBQUUsTUFBTSxFQUFFLEVBQUUsU0FBUyxFQUFFLE1BQU0sRUFBRSxHQUFHLE9BQU8sQ0FBQyxJQUFJLENBQUMsQ0FTeEc7SUFFRDs7T0FFRztJQUNHLG9CQUFvQixDQUFDLFdBQVcsRUFBRSxXQUFXLEdBQUcsT0FBTyxDQUFDLElBQUksQ0FBQyxDQU9sRTtJQUVEOztPQUVHO0lBQ0gsWUFBWSxDQUFDLE1BQU0sRUFBRSxjQUFjLEdBQUcsSUFBSSxDQU96QztZQUVhLGlCQUFpQjtDQVloQyJ9
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eviction_manager.d.ts","sourceRoot":"","sources":["../../../../src/mem_pools/tx_pool_v2/eviction/eviction_manager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEpD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EACL,KAAK,cAAc,EAGnB,KAAK,YAAY,EACjB,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,KAAK,YAAY,EACjB,KAAK,UAAU,EAChB,MAAM,iBAAiB,CAAC;AAEzB;;;GAGG;AACH,qBAAa,eAAe;IAKxB,OAAO,CAAC,IAAI;IACZ,OAAO,CAAC,GAAG;IALb,OAAO,CAAC,WAAW,CAAoB;IACvC,OAAO,CAAC,cAAc,CAAsB;IAE5C,YACU,IAAI,EAAE,cAAc,EACpB,GAAG,EAAE,MAAM,EACjB;IAEJ;;OAEG;IACH,kBAAkB,CAAC,IAAI,EAAE,UAAU,GAAG,IAAI,CAGzC;IAED;;OAEG;IACH,YAAY,CAAC,IAAI,EAAE,YAAY,GAAG,IAAI,CAGrC;IAED;;;OAGG;IACG,cAAc,CAAC,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,gBAAgB,GAAG,OAAO,CAAC,YAAY,CAAC,CAgClG;IAED;;OAEG;IACG,gBAAgB,CAAC,WAAW,EAAE,MAAM,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAQhF;IAED;;OAEG;IACG,kBAAkB,CAAC,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CASxG;IAED;;OAEG;IACG,oBAAoB,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAOlE;IAED;;OAEG;IACH,YAAY,CAAC,MAAM,EAAE,cAAc,GAAG,IAAI,CAOzC;YAEa,iBAAiB;CAYhC"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { EvictionEvent } from './interfaces.js';
|
|
2
|
+
/**
|
|
3
|
+
* Manages eviction rules for the transaction pool.
|
|
4
|
+
* Coordinates pre-add rules (run during addPendingTxs) and post-event rules (run after events).
|
|
5
|
+
*/ export class EvictionManager {
|
|
6
|
+
pool;
|
|
7
|
+
log;
|
|
8
|
+
preAddRules;
|
|
9
|
+
postEventRules;
|
|
10
|
+
constructor(pool, log){
|
|
11
|
+
this.pool = pool;
|
|
12
|
+
this.log = log;
|
|
13
|
+
this.preAddRules = [];
|
|
14
|
+
this.postEventRules = [];
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Registers a pre-add rule that runs during transaction addition.
|
|
18
|
+
*/ registerPreAddRule(rule) {
|
|
19
|
+
this.preAddRules.push(rule);
|
|
20
|
+
this.log.debug(`Registered pre-add rule: ${rule.name}`);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Registers a post-event eviction rule that runs after events.
|
|
24
|
+
*/ registerRule(rule) {
|
|
25
|
+
this.postEventRules.push(rule);
|
|
26
|
+
this.log.debug(`Registered eviction rule: ${rule.name}`);
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Runs all pre-add rules for an incoming transaction.
|
|
30
|
+
* Returns combined result of all rules.
|
|
31
|
+
*/ async runPreAddRules(incomingMeta, poolAccess) {
|
|
32
|
+
const allTxHashesToEvict = [];
|
|
33
|
+
for (const rule of this.preAddRules){
|
|
34
|
+
try {
|
|
35
|
+
const result = await rule.check(incomingMeta, poolAccess);
|
|
36
|
+
if (result.shouldIgnore) {
|
|
37
|
+
return result;
|
|
38
|
+
}
|
|
39
|
+
// Collect txs to evict from all rules
|
|
40
|
+
for (const txHash of result.txHashesToEvict){
|
|
41
|
+
if (!allTxHashesToEvict.includes(txHash)) {
|
|
42
|
+
allTxHashesToEvict.push(txHash);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
} catch (err) {
|
|
46
|
+
this.log.error(`Error running pre-add rule ${rule.name}`, {
|
|
47
|
+
err,
|
|
48
|
+
txHash: incomingMeta.txHash
|
|
49
|
+
});
|
|
50
|
+
// On error, ignore the transaction to be safe
|
|
51
|
+
return {
|
|
52
|
+
shouldIgnore: true,
|
|
53
|
+
txHashesToEvict: [],
|
|
54
|
+
reason: `pre-add rule ${rule.name} error: ${err}`
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return {
|
|
59
|
+
shouldIgnore: false,
|
|
60
|
+
txHashesToEvict: allTxHashesToEvict
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Runs post-event eviction after new transactions are added.
|
|
65
|
+
*/ async evictAfterNewTxs(newTxHashes, feePayers) {
|
|
66
|
+
const context = {
|
|
67
|
+
event: EvictionEvent.TXS_ADDED,
|
|
68
|
+
newTxHashes,
|
|
69
|
+
feePayers
|
|
70
|
+
};
|
|
71
|
+
await this.runPostEventRules(context);
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Runs post-event eviction after a block is mined.
|
|
75
|
+
*/ async evictAfterNewBlock(block, newNullifiers, feePayers) {
|
|
76
|
+
const context = {
|
|
77
|
+
event: EvictionEvent.BLOCK_MINED,
|
|
78
|
+
block,
|
|
79
|
+
newNullifiers,
|
|
80
|
+
feePayers
|
|
81
|
+
};
|
|
82
|
+
await this.runPostEventRules(context);
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Runs post-event eviction after a chain prune (reorg).
|
|
86
|
+
*/ async evictAfterChainPrune(blockNumber) {
|
|
87
|
+
const context = {
|
|
88
|
+
event: EvictionEvent.CHAIN_PRUNED,
|
|
89
|
+
blockNumber
|
|
90
|
+
};
|
|
91
|
+
await this.runPostEventRules(context);
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Updates configuration for all rules.
|
|
95
|
+
*/ updateConfig(config) {
|
|
96
|
+
for (const rule of this.preAddRules){
|
|
97
|
+
rule.updateConfig?.(config);
|
|
98
|
+
}
|
|
99
|
+
for (const rule of this.postEventRules){
|
|
100
|
+
rule.updateConfig?.(config);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
async runPostEventRules(context) {
|
|
104
|
+
for (const rule of this.postEventRules){
|
|
105
|
+
try {
|
|
106
|
+
const result = await rule.evict(context, this.pool);
|
|
107
|
+
if (!result.success) {
|
|
108
|
+
this.log.warn(`Eviction rule ${rule.name} failed`, {
|
|
109
|
+
error: result.error
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
} catch (err) {
|
|
113
|
+
this.log.error(`Error running eviction rule ${rule.name}`, {
|
|
114
|
+
err
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { WorldStateSynchronizer } from '@aztec/stdlib/interfaces/server';
|
|
2
|
+
import type { EvictionContext, EvictionResult, EvictionRule, PoolOperations } from './interfaces.js';
|
|
3
|
+
/**
|
|
4
|
+
* Eviction rule that removes transactions when fee payers have insufficient balance.
|
|
5
|
+
* Triggers on TXS_ADDED, BLOCK_MINED, and CHAIN_PRUNED events.
|
|
6
|
+
*/
|
|
7
|
+
export declare class FeePayerBalanceEvictionRule implements EvictionRule {
|
|
8
|
+
private worldState;
|
|
9
|
+
readonly name = "FeePayerBalanceEviction";
|
|
10
|
+
readonly reason = "fee_payer_balance";
|
|
11
|
+
private log;
|
|
12
|
+
constructor(worldState: WorldStateSynchronizer);
|
|
13
|
+
evict(context: EvictionContext, pool: PoolOperations): Promise<EvictionResult>;
|
|
14
|
+
private evictForFeePayers;
|
|
15
|
+
private getEvictionsForFeePayer;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZmVlX3BheWVyX2JhbGFuY2VfZXZpY3Rpb25fcnVsZS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vc3JjL21lbV9wb29scy90eF9wb29sX3YyL2V2aWN0aW9uL2ZlZV9wYXllcl9iYWxhbmNlX2V2aWN0aW9uX3J1bGUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBSUEsT0FBTyxLQUFLLEVBQUUsc0JBQXNCLEVBQUUsTUFBTSxpQ0FBaUMsQ0FBQztBQUk5RSxPQUFPLEtBQUssRUFBRSxlQUFlLEVBQUUsY0FBYyxFQUFFLFlBQVksRUFBRSxjQUFjLEVBQUUsTUFBTSxpQkFBaUIsQ0FBQztBQUdyRzs7O0dBR0c7QUFDSCxxQkFBYSwyQkFBNEIsWUFBVyxZQUFZO0lBTWxELE9BQU8sQ0FBQyxVQUFVO0lBTDlCLFNBQWdCLElBQUksNkJBQTZCO0lBQ2pELFNBQWdCLE1BQU0sdUJBQXVCO0lBRTdDLE9BQU8sQ0FBQyxHQUFHLENBQWtFO0lBRTdFLFlBQW9CLFVBQVUsRUFBRSxzQkFBc0IsRUFBSTtJQUVwRCxLQUFLLENBQUMsT0FBTyxFQUFFLGVBQWUsRUFBRSxJQUFJLEVBQUUsY0FBYyxHQUFHLE9BQU8sQ0FBQyxjQUFjLENBQUMsQ0FnQ25GO1lBRWEsaUJBQWlCO1lBc0JqQix1QkFBdUI7Q0FzQ3RDIn0=
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fee_payer_balance_eviction_rule.d.ts","sourceRoot":"","sources":["../../../../src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AAI9E,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAGrG;;;GAGG;AACH,qBAAa,2BAA4B,YAAW,YAAY;IAMlD,OAAO,CAAC,UAAU;IAL9B,SAAgB,IAAI,6BAA6B;IACjD,SAAgB,MAAM,uBAAuB;IAE7C,OAAO,CAAC,GAAG,CAAkE;IAE7E,YAAoB,UAAU,EAAE,sBAAsB,EAAI;IAEpD,KAAK,CAAC,OAAO,EAAE,eAAe,EAAE,IAAI,EAAE,cAAc,GAAG,OAAO,CAAC,cAAc,CAAC,CAgCnF;YAEa,iBAAiB;YAsBjB,uBAAuB;CAsCtC"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { createLogger } from '@aztec/foundation/log';
|
|
2
|
+
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
3
|
+
import { computeFeePayerBalanceStorageSlot } from '@aztec/protocol-contracts/fee-juice';
|
|
4
|
+
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
5
|
+
import { DatabasePublicStateSource } from '@aztec/stdlib/trees';
|
|
6
|
+
import { comparePriority } from '../tx_metadata.js';
|
|
7
|
+
import { EvictionEvent } from './interfaces.js';
|
|
8
|
+
/**
|
|
9
|
+
* Eviction rule that removes transactions when fee payers have insufficient balance.
|
|
10
|
+
* Triggers on TXS_ADDED, BLOCK_MINED, and CHAIN_PRUNED events.
|
|
11
|
+
*/ export class FeePayerBalanceEvictionRule {
|
|
12
|
+
worldState;
|
|
13
|
+
name;
|
|
14
|
+
reason;
|
|
15
|
+
log;
|
|
16
|
+
constructor(worldState){
|
|
17
|
+
this.worldState = worldState;
|
|
18
|
+
this.name = 'FeePayerBalanceEviction';
|
|
19
|
+
this.reason = 'fee_payer_balance';
|
|
20
|
+
this.log = createLogger('p2p:tx_pool_v2:fee_payer_balance_eviction_rule');
|
|
21
|
+
}
|
|
22
|
+
async evict(context, pool) {
|
|
23
|
+
try {
|
|
24
|
+
if (context.event === EvictionEvent.TXS_ADDED) {
|
|
25
|
+
return await this.evictForFeePayers(context.feePayers, this.worldState.getCommitted(), pool);
|
|
26
|
+
}
|
|
27
|
+
if (context.event === EvictionEvent.BLOCK_MINED) {
|
|
28
|
+
const blockNumber = context.block.getBlockNumber();
|
|
29
|
+
await this.worldState.syncImmediate(blockNumber);
|
|
30
|
+
return await this.evictForFeePayers(context.feePayers, this.worldState.getSnapshot(blockNumber), pool);
|
|
31
|
+
}
|
|
32
|
+
if (context.event === EvictionEvent.CHAIN_PRUNED) {
|
|
33
|
+
await this.worldState.syncImmediate(context.blockNumber);
|
|
34
|
+
const feePayers = pool.getPendingFeePayers();
|
|
35
|
+
return await this.evictForFeePayers(feePayers, this.worldState.getSnapshot(context.blockNumber), pool);
|
|
36
|
+
}
|
|
37
|
+
return {
|
|
38
|
+
reason: this.reason,
|
|
39
|
+
success: true,
|
|
40
|
+
txsEvicted: []
|
|
41
|
+
};
|
|
42
|
+
} catch (err) {
|
|
43
|
+
this.log.error('Failed to evict txs due to fee payer balance', {
|
|
44
|
+
err
|
|
45
|
+
});
|
|
46
|
+
return {
|
|
47
|
+
reason: this.reason,
|
|
48
|
+
success: false,
|
|
49
|
+
txsEvicted: [],
|
|
50
|
+
error: new Error('Failed to evict txs due to fee payer balance', {
|
|
51
|
+
cause: err
|
|
52
|
+
})
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
async evictForFeePayers(feePayers, db, pool) {
|
|
57
|
+
const publicStateSource = new DatabasePublicStateSource(db);
|
|
58
|
+
const txsToEvict = (await Promise.all(feePayers.map((feePayer)=>this.getEvictionsForFeePayer(feePayer, publicStateSource, pool)))).flat();
|
|
59
|
+
if (txsToEvict.length > 0) {
|
|
60
|
+
await pool.deleteTxs(txsToEvict);
|
|
61
|
+
}
|
|
62
|
+
return {
|
|
63
|
+
reason: this.reason,
|
|
64
|
+
success: true,
|
|
65
|
+
txsEvicted: txsToEvict
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
async getEvictionsForFeePayer(feePayerStr, publicStateSource, pool) {
|
|
69
|
+
const feePayer = AztecAddress.fromString(feePayerStr);
|
|
70
|
+
const initialBalance = (await publicStateSource.storageRead(ProtocolContractAddress.FeeJuice, await computeFeePayerBalanceStorageSlot(feePayer))).toBigInt();
|
|
71
|
+
const txs = pool.getFeePayerPendingTxs(feePayerStr);
|
|
72
|
+
if (txs.length === 0) {
|
|
73
|
+
return [];
|
|
74
|
+
}
|
|
75
|
+
const txsToEvict = [];
|
|
76
|
+
let balance = initialBalance;
|
|
77
|
+
// Sort by priority descending (highest first), with hash as tiebreaker
|
|
78
|
+
txs.sort((a, b)=>comparePriority(b, a));
|
|
79
|
+
for (const tx of txs){
|
|
80
|
+
const available = balance + tx.claimAmount;
|
|
81
|
+
if (available >= tx.feeLimit) {
|
|
82
|
+
balance = available - tx.feeLimit;
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
// This tx cannot be covered - mark for eviction
|
|
86
|
+
txsToEvict.push(tx.txHash);
|
|
87
|
+
}
|
|
88
|
+
return txsToEvict;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type TxMetaData } from '../tx_metadata.js';
|
|
2
|
+
import type { PreAddPoolAccess, PreAddResult, PreAddRule } from './interfaces.js';
|
|
3
|
+
/**
|
|
4
|
+
* Pre-add rule that checks if a fee payer has sufficient balance to cover the incoming transaction.
|
|
5
|
+
*
|
|
6
|
+
* When an incoming tx is added:
|
|
7
|
+
* - Get the fee payer's on-chain balance
|
|
8
|
+
* - Get all existing pending txs for this fee payer
|
|
9
|
+
* - Insert incoming tx in priority order
|
|
10
|
+
* - Walk through in priority order, tracking running balance
|
|
11
|
+
* - If incoming tx can be covered: accept, mark lower-priority txs for eviction if needed
|
|
12
|
+
* - If incoming tx cannot be covered: ignore it
|
|
13
|
+
*/
|
|
14
|
+
export declare class FeePayerBalancePreAddRule implements PreAddRule {
|
|
15
|
+
readonly name = "FeePayerBalancePreAdd";
|
|
16
|
+
private log;
|
|
17
|
+
check(incomingMeta: TxMetaData, poolAccess: PreAddPoolAccess): Promise<PreAddResult>;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZmVlX3BheWVyX2JhbGFuY2VfcHJlX2FkZF9ydWxlLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi9zcmMvbWVtX3Bvb2xzL3R4X3Bvb2xfdjIvZXZpY3Rpb24vZmVlX3BheWVyX2JhbGFuY2VfcHJlX2FkZF9ydWxlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUVBLE9BQU8sRUFBRSxLQUFLLFVBQVUsRUFBbUIsTUFBTSxtQkFBbUIsQ0FBQztBQUNyRSxPQUFPLEtBQUssRUFBRSxnQkFBZ0IsRUFBRSxZQUFZLEVBQUUsVUFBVSxFQUFFLE1BQU0saUJBQWlCLENBQUM7QUFFbEY7Ozs7Ozs7Ozs7R0FVRztBQUNILHFCQUFhLHlCQUEwQixZQUFXLFVBQVU7SUFDMUQsU0FBZ0IsSUFBSSwyQkFBMkI7SUFFL0MsT0FBTyxDQUFDLEdBQUcsQ0FBaUU7SUFFdEUsS0FBSyxDQUFDLFlBQVksRUFBRSxVQUFVLEVBQUUsVUFBVSxFQUFFLGdCQUFnQixHQUFHLE9BQU8sQ0FBQyxZQUFZLENBQUMsQ0F3RnpGO0NBQ0YifQ==
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fee_payer_balance_pre_add_rule.d.ts","sourceRoot":"","sources":["../../../../src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,UAAU,EAAmB,MAAM,mBAAmB,CAAC;AACrE,OAAO,KAAK,EAAE,gBAAgB,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElF;;;;;;;;;;GAUG;AACH,qBAAa,yBAA0B,YAAW,UAAU;IAC1D,SAAgB,IAAI,2BAA2B;IAE/C,OAAO,CAAC,GAAG,CAAiE;IAEtE,KAAK,CAAC,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,gBAAgB,GAAG,OAAO,CAAC,YAAY,CAAC,CAwFzF;CACF"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { createLogger } from '@aztec/foundation/log';
|
|
2
|
+
import { comparePriority } from '../tx_metadata.js';
|
|
3
|
+
/**
|
|
4
|
+
* Pre-add rule that checks if a fee payer has sufficient balance to cover the incoming transaction.
|
|
5
|
+
*
|
|
6
|
+
* When an incoming tx is added:
|
|
7
|
+
* - Get the fee payer's on-chain balance
|
|
8
|
+
* - Get all existing pending txs for this fee payer
|
|
9
|
+
* - Insert incoming tx in priority order
|
|
10
|
+
* - Walk through in priority order, tracking running balance
|
|
11
|
+
* - If incoming tx can be covered: accept, mark lower-priority txs for eviction if needed
|
|
12
|
+
* - If incoming tx cannot be covered: ignore it
|
|
13
|
+
*/ export class FeePayerBalancePreAddRule {
|
|
14
|
+
name = 'FeePayerBalancePreAdd';
|
|
15
|
+
log = createLogger('p2p:tx_pool_v2:fee_payer_balance_pre_add_rule');
|
|
16
|
+
async check(incomingMeta, poolAccess) {
|
|
17
|
+
// Get fee payer's on-chain balance
|
|
18
|
+
const initialBalance = await poolAccess.getFeePayerBalance(incomingMeta.feePayer);
|
|
19
|
+
// Get existing pending txs for this fee payer
|
|
20
|
+
const existingTxs = poolAccess.getFeePayerPendingTxs(incomingMeta.feePayer);
|
|
21
|
+
// Create combined list with incoming tx
|
|
22
|
+
const allTxs = [
|
|
23
|
+
...existingTxs.map((t)=>({
|
|
24
|
+
txHash: t.txHash,
|
|
25
|
+
priorityFee: t.priorityFee,
|
|
26
|
+
feeLimit: t.feeLimit,
|
|
27
|
+
claimAmount: t.claimAmount,
|
|
28
|
+
isIncoming: false
|
|
29
|
+
})),
|
|
30
|
+
{
|
|
31
|
+
txHash: incomingMeta.txHash,
|
|
32
|
+
priorityFee: incomingMeta.priorityFee,
|
|
33
|
+
feeLimit: incomingMeta.feeLimit,
|
|
34
|
+
claimAmount: incomingMeta.claimAmount,
|
|
35
|
+
isIncoming: true
|
|
36
|
+
}
|
|
37
|
+
];
|
|
38
|
+
// Sort by priority descending (highest first), with hash as tiebreaker
|
|
39
|
+
allTxs.sort((a, b)=>comparePriority(b, a));
|
|
40
|
+
// Walk through in priority order, tracking balance
|
|
41
|
+
let balance = initialBalance;
|
|
42
|
+
let incomingTxCovered = false;
|
|
43
|
+
const txsToEvict = [];
|
|
44
|
+
for (const txInfo of allTxs){
|
|
45
|
+
const available = balance + txInfo.claimAmount;
|
|
46
|
+
if (available >= txInfo.feeLimit) {
|
|
47
|
+
// This tx can be covered
|
|
48
|
+
balance = available - txInfo.feeLimit;
|
|
49
|
+
if (txInfo.isIncoming) {
|
|
50
|
+
incomingTxCovered = true;
|
|
51
|
+
}
|
|
52
|
+
} else {
|
|
53
|
+
// This tx cannot be covered
|
|
54
|
+
if (txInfo.isIncoming) {
|
|
55
|
+
// Incoming tx cannot be covered - ignore it
|
|
56
|
+
this.log.debug(`Ignoring tx ${incomingMeta.txHash}: fee payer ${incomingMeta.feePayer} has insufficient balance`, {
|
|
57
|
+
balance: initialBalance,
|
|
58
|
+
feeLimit: incomingMeta.feeLimit,
|
|
59
|
+
claimAmount: incomingMeta.claimAmount
|
|
60
|
+
});
|
|
61
|
+
return {
|
|
62
|
+
shouldIgnore: true,
|
|
63
|
+
txHashesToEvict: [],
|
|
64
|
+
reason: `fee payer ${incomingMeta.feePayer} has insufficient balance`
|
|
65
|
+
};
|
|
66
|
+
} else {
|
|
67
|
+
// Existing tx cannot be covered after adding incoming - mark for eviction
|
|
68
|
+
txsToEvict.push(txInfo.txHash);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
if (!incomingTxCovered) {
|
|
73
|
+
// This shouldn't happen if the logic above is correct, but just in case
|
|
74
|
+
this.log.warn(`Incoming tx ${incomingMeta.txHash} was not covered but also not ignored - this is a bug`);
|
|
75
|
+
return {
|
|
76
|
+
shouldIgnore: true,
|
|
77
|
+
txHashesToEvict: [],
|
|
78
|
+
reason: 'internal error: tx coverage not determined'
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
if (txsToEvict.length > 0) {
|
|
82
|
+
this.log.debug(`Accepting tx ${incomingMeta.txHash}, evicting ${txsToEvict.length} lower-priority txs due to fee payer balance`);
|
|
83
|
+
}
|
|
84
|
+
return {
|
|
85
|
+
shouldIgnore: false,
|
|
86
|
+
txHashesToEvict: txsToEvict
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { EvictionManager } from './eviction_manager.js';
|
|
2
|
+
export { type EvictionConfig, type EvictionContext, EvictionEvent, type EvictionResult, type EvictionRule, type PoolOperations, type PreAddPoolAccess, type PreAddResult, type PreAddRule, } from './interfaces.js';
|
|
3
|
+
export { NullifierConflictRule } from './nullifier_conflict_rule.js';
|
|
4
|
+
export { FeePayerBalancePreAddRule } from './fee_payer_balance_pre_add_rule.js';
|
|
5
|
+
export { LowPriorityPreAddRule } from './low_priority_pre_add_rule.js';
|
|
6
|
+
export { InvalidTxsAfterMiningRule } from './invalid_txs_after_mining_rule.js';
|
|
7
|
+
export { InvalidTxsAfterReorgRule } from './invalid_txs_after_reorg_rule.js';
|
|
8
|
+
export { FeePayerBalanceEvictionRule } from './fee_payer_balance_eviction_rule.js';
|
|
9
|
+
export { LowPriorityEvictionRule } from './low_priority_eviction_rule.js';
|
|
10
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3NyYy9tZW1fcG9vbHMvdHhfcG9vbF92Mi9ldmljdGlvbi9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsZUFBZSxFQUFFLE1BQU0sdUJBQXVCLENBQUM7QUFDeEQsT0FBTyxFQUNMLEtBQUssY0FBYyxFQUNuQixLQUFLLGVBQWUsRUFDcEIsYUFBYSxFQUNiLEtBQUssY0FBYyxFQUNuQixLQUFLLFlBQVksRUFDakIsS0FBSyxjQUFjLEVBQ25CLEtBQUssZ0JBQWdCLEVBQ3JCLEtBQUssWUFBWSxFQUNqQixLQUFLLFVBQVUsR0FDaEIsTUFBTSxpQkFBaUIsQ0FBQztBQUd6QixPQUFPLEVBQUUscUJBQXFCLEVBQUUsTUFBTSw4QkFBOEIsQ0FBQztBQUNyRSxPQUFPLEVBQUUseUJBQXlCLEVBQUUsTUFBTSxxQ0FBcUMsQ0FBQztBQUNoRixPQUFPLEVBQUUscUJBQXFCLEVBQUUsTUFBTSxnQ0FBZ0MsQ0FBQztBQUd2RSxPQUFPLEVBQUUseUJBQXlCLEVBQUUsTUFBTSxvQ0FBb0MsQ0FBQztBQUMvRSxPQUFPLEVBQUUsd0JBQXdCLEVBQUUsTUFBTSxtQ0FBbUMsQ0FBQztBQUM3RSxPQUFPLEVBQUUsMkJBQTJCLEVBQUUsTUFBTSxzQ0FBc0MsQ0FBQztBQUNuRixPQUFPLEVBQUUsdUJBQXVCLEVBQUUsTUFBTSxpQ0FBaUMsQ0FBQyJ9
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/mem_pools/tx_pool_v2/eviction/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,aAAa,EACb,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,KAAK,YAAY,EACjB,KAAK,UAAU,GAChB,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,EAAE,yBAAyB,EAAE,MAAM,qCAAqC,CAAC;AAChF,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AAGvE,OAAO,EAAE,yBAAyB,EAAE,MAAM,oCAAoC,CAAC;AAC/E,OAAO,EAAE,wBAAwB,EAAE,MAAM,mCAAmC,CAAC;AAC7E,OAAO,EAAE,2BAA2B,EAAE,MAAM,sCAAsC,CAAC;AACnF,OAAO,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { EvictionManager } from './eviction_manager.js';
|
|
2
|
+
export { EvictionEvent } from './interfaces.js';
|
|
3
|
+
// Pre-add rules
|
|
4
|
+
export { NullifierConflictRule } from './nullifier_conflict_rule.js';
|
|
5
|
+
export { FeePayerBalancePreAddRule } from './fee_payer_balance_pre_add_rule.js';
|
|
6
|
+
export { LowPriorityPreAddRule } from './low_priority_pre_add_rule.js';
|
|
7
|
+
// Post-event eviction rules
|
|
8
|
+
export { InvalidTxsAfterMiningRule } from './invalid_txs_after_mining_rule.js';
|
|
9
|
+
export { InvalidTxsAfterReorgRule } from './invalid_txs_after_reorg_rule.js';
|
|
10
|
+
export { FeePayerBalanceEvictionRule } from './fee_payer_balance_eviction_rule.js';
|
|
11
|
+
export { LowPriorityEvictionRule } from './low_priority_eviction_rule.js';
|