@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,121 @@
|
|
|
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 type { WorldStateSynchronizer } from '@aztec/stdlib/interfaces/server';
|
|
6
|
+
import { DatabasePublicStateSource, type MerkleTreeReadOperations } from '@aztec/stdlib/trees';
|
|
7
|
+
|
|
8
|
+
import { type TxMetaData, comparePriority } from '../tx_metadata.js';
|
|
9
|
+
import type { EvictionContext, EvictionResult, EvictionRule, PoolOperations } from './interfaces.js';
|
|
10
|
+
import { EvictionEvent } from './interfaces.js';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Eviction rule that removes transactions when fee payers have insufficient balance.
|
|
14
|
+
* Triggers on TXS_ADDED, BLOCK_MINED, and CHAIN_PRUNED events.
|
|
15
|
+
*/
|
|
16
|
+
export class FeePayerBalanceEvictionRule implements EvictionRule {
|
|
17
|
+
public readonly name = 'FeePayerBalanceEviction';
|
|
18
|
+
public readonly reason = 'fee_payer_balance';
|
|
19
|
+
|
|
20
|
+
private log = createLogger('p2p:tx_pool_v2:fee_payer_balance_eviction_rule');
|
|
21
|
+
|
|
22
|
+
constructor(private worldState: WorldStateSynchronizer) {}
|
|
23
|
+
|
|
24
|
+
async evict(context: EvictionContext, pool: PoolOperations): Promise<EvictionResult> {
|
|
25
|
+
try {
|
|
26
|
+
if (context.event === EvictionEvent.TXS_ADDED) {
|
|
27
|
+
return await this.evictForFeePayers(context.feePayers, this.worldState.getCommitted(), pool);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (context.event === EvictionEvent.BLOCK_MINED) {
|
|
31
|
+
const blockNumber = context.block.getBlockNumber();
|
|
32
|
+
await this.worldState.syncImmediate(blockNumber);
|
|
33
|
+
return await this.evictForFeePayers(context.feePayers, this.worldState.getSnapshot(blockNumber), pool);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (context.event === EvictionEvent.CHAIN_PRUNED) {
|
|
37
|
+
await this.worldState.syncImmediate(context.blockNumber);
|
|
38
|
+
const feePayers = pool.getPendingFeePayers();
|
|
39
|
+
return await this.evictForFeePayers(feePayers, this.worldState.getSnapshot(context.blockNumber), pool);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return {
|
|
43
|
+
reason: this.reason,
|
|
44
|
+
success: true,
|
|
45
|
+
txsEvicted: [],
|
|
46
|
+
};
|
|
47
|
+
} catch (err) {
|
|
48
|
+
this.log.error('Failed to evict txs due to fee payer balance', { err });
|
|
49
|
+
return {
|
|
50
|
+
reason: this.reason,
|
|
51
|
+
success: false,
|
|
52
|
+
txsEvicted: [],
|
|
53
|
+
error: new Error('Failed to evict txs due to fee payer balance', { cause: err }),
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
private async evictForFeePayers(
|
|
59
|
+
feePayers: string[],
|
|
60
|
+
db: MerkleTreeReadOperations,
|
|
61
|
+
pool: PoolOperations,
|
|
62
|
+
): Promise<EvictionResult> {
|
|
63
|
+
const publicStateSource = new DatabasePublicStateSource(db);
|
|
64
|
+
|
|
65
|
+
const txsToEvict = (
|
|
66
|
+
await Promise.all(feePayers.map(feePayer => this.getEvictionsForFeePayer(feePayer, publicStateSource, pool)))
|
|
67
|
+
).flat();
|
|
68
|
+
|
|
69
|
+
if (txsToEvict.length > 0) {
|
|
70
|
+
await pool.deleteTxs(txsToEvict, this.name);
|
|
71
|
+
this.log.debug(`Evicted ${txsToEvict.length} txs due to insufficient fee payer balance`, {
|
|
72
|
+
txHashes: txsToEvict,
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return {
|
|
77
|
+
reason: this.reason,
|
|
78
|
+
success: true,
|
|
79
|
+
txsEvicted: txsToEvict,
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
private async getEvictionsForFeePayer(
|
|
84
|
+
feePayerStr: string,
|
|
85
|
+
publicStateSource: DatabasePublicStateSource,
|
|
86
|
+
pool: PoolOperations,
|
|
87
|
+
): Promise<string[]> {
|
|
88
|
+
const feePayer = AztecAddress.fromString(feePayerStr);
|
|
89
|
+
const initialBalance = (
|
|
90
|
+
await publicStateSource.storageRead(
|
|
91
|
+
ProtocolContractAddress.FeeJuice,
|
|
92
|
+
await computeFeePayerBalanceStorageSlot(feePayer),
|
|
93
|
+
)
|
|
94
|
+
).toBigInt();
|
|
95
|
+
|
|
96
|
+
const txs: TxMetaData[] = pool.getFeePayerPendingTxs(feePayerStr);
|
|
97
|
+
|
|
98
|
+
if (txs.length === 0) {
|
|
99
|
+
return [];
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const txsToEvict: string[] = [];
|
|
103
|
+
let balance = initialBalance;
|
|
104
|
+
|
|
105
|
+
// Sort by priority descending (highest first), with hash as tiebreaker
|
|
106
|
+
txs.sort((a, b) => comparePriority(b, a));
|
|
107
|
+
|
|
108
|
+
for (const tx of txs) {
|
|
109
|
+
const available = balance + tx.claimAmount;
|
|
110
|
+
if (available >= tx.feeLimit) {
|
|
111
|
+
balance = available - tx.feeLimit;
|
|
112
|
+
continue;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// This tx cannot be covered - mark for eviction
|
|
116
|
+
txsToEvict.push(tx.txHash);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
return txsToEvict;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { createLogger } from '@aztec/foundation/log';
|
|
2
|
+
|
|
3
|
+
import { type TxMetaData, comparePriority } from '../tx_metadata.js';
|
|
4
|
+
import {
|
|
5
|
+
type PreAddContext,
|
|
6
|
+
type PreAddPoolAccess,
|
|
7
|
+
type PreAddResult,
|
|
8
|
+
type PreAddRule,
|
|
9
|
+
TxPoolRejectionCode,
|
|
10
|
+
} from './interfaces.js';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Pre-add rule that checks if a fee payer has sufficient balance to cover the incoming transaction.
|
|
14
|
+
*
|
|
15
|
+
* When an incoming tx is added:
|
|
16
|
+
* - Get the fee payer's on-chain balance
|
|
17
|
+
* - Get all existing pending txs for this fee payer
|
|
18
|
+
* - Insert incoming tx in priority order
|
|
19
|
+
* - Walk through in priority order, tracking running balance
|
|
20
|
+
* - If incoming tx can be covered: accept, mark lower-priority txs for eviction if needed
|
|
21
|
+
* - If incoming tx cannot be covered: ignore it
|
|
22
|
+
*/
|
|
23
|
+
export class FeePayerBalancePreAddRule implements PreAddRule {
|
|
24
|
+
public readonly name = 'FeePayerBalancePreAdd';
|
|
25
|
+
|
|
26
|
+
private log = createLogger('p2p:tx_pool_v2:fee_payer_balance_pre_add_rule');
|
|
27
|
+
|
|
28
|
+
async check(incomingMeta: TxMetaData, poolAccess: PreAddPoolAccess, _context?: PreAddContext): Promise<PreAddResult> {
|
|
29
|
+
// Get fee payer's on-chain balance
|
|
30
|
+
const initialBalance = await poolAccess.getFeePayerBalance(incomingMeta.feePayer);
|
|
31
|
+
|
|
32
|
+
// Get existing pending txs for this fee payer
|
|
33
|
+
const existingTxs = poolAccess.getFeePayerPendingTxs(incomingMeta.feePayer);
|
|
34
|
+
|
|
35
|
+
// Create combined list with incoming tx
|
|
36
|
+
const allTxs: Array<{
|
|
37
|
+
txHash: string;
|
|
38
|
+
priorityFee: bigint;
|
|
39
|
+
feeLimit: bigint;
|
|
40
|
+
claimAmount: bigint;
|
|
41
|
+
isIncoming: boolean;
|
|
42
|
+
}> = [
|
|
43
|
+
...existingTxs.map(t => ({
|
|
44
|
+
txHash: t.txHash,
|
|
45
|
+
priorityFee: t.priorityFee,
|
|
46
|
+
feeLimit: t.feeLimit,
|
|
47
|
+
claimAmount: t.claimAmount,
|
|
48
|
+
isIncoming: false,
|
|
49
|
+
})),
|
|
50
|
+
{
|
|
51
|
+
txHash: incomingMeta.txHash,
|
|
52
|
+
priorityFee: incomingMeta.priorityFee,
|
|
53
|
+
feeLimit: incomingMeta.feeLimit,
|
|
54
|
+
claimAmount: incomingMeta.claimAmount,
|
|
55
|
+
isIncoming: true,
|
|
56
|
+
},
|
|
57
|
+
];
|
|
58
|
+
|
|
59
|
+
// Sort by priority descending (highest first), with hash as tiebreaker
|
|
60
|
+
allTxs.sort((a, b) => comparePriority(b, a));
|
|
61
|
+
|
|
62
|
+
// Walk through in priority order, tracking balance
|
|
63
|
+
let balance = initialBalance;
|
|
64
|
+
let incomingTxCovered = false;
|
|
65
|
+
const txsToEvict: string[] = [];
|
|
66
|
+
|
|
67
|
+
for (const txInfo of allTxs) {
|
|
68
|
+
const available = balance + txInfo.claimAmount;
|
|
69
|
+
|
|
70
|
+
if (available >= txInfo.feeLimit) {
|
|
71
|
+
// This tx can be covered
|
|
72
|
+
balance = available - txInfo.feeLimit;
|
|
73
|
+
if (txInfo.isIncoming) {
|
|
74
|
+
incomingTxCovered = true;
|
|
75
|
+
}
|
|
76
|
+
} else {
|
|
77
|
+
// This tx cannot be covered
|
|
78
|
+
if (txInfo.isIncoming) {
|
|
79
|
+
// Incoming tx cannot be covered - ignore it
|
|
80
|
+
this.log.debug(
|
|
81
|
+
`Ignoring tx ${incomingMeta.txHash}: fee payer ${incomingMeta.feePayer} has insufficient balance`,
|
|
82
|
+
{ balance: initialBalance, feeLimit: incomingMeta.feeLimit, claimAmount: incomingMeta.claimAmount },
|
|
83
|
+
);
|
|
84
|
+
return {
|
|
85
|
+
shouldIgnore: true,
|
|
86
|
+
txHashesToEvict: [],
|
|
87
|
+
reason: {
|
|
88
|
+
code: TxPoolRejectionCode.INSUFFICIENT_FEE_PAYER_BALANCE,
|
|
89
|
+
message: `Fee payer ${incomingMeta.feePayer} has insufficient balance. Balance at transaction: ${available}, required: ${incomingMeta.feeLimit}`,
|
|
90
|
+
currentBalance: initialBalance,
|
|
91
|
+
availableBalance: available,
|
|
92
|
+
feeLimit: incomingMeta.feeLimit,
|
|
93
|
+
},
|
|
94
|
+
};
|
|
95
|
+
} else {
|
|
96
|
+
// Existing tx cannot be covered after adding incoming - mark for eviction
|
|
97
|
+
txsToEvict.push(txInfo.txHash);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if (!incomingTxCovered) {
|
|
103
|
+
// This shouldn't happen if the logic above is correct, but just in case
|
|
104
|
+
this.log.warn(`Incoming tx ${incomingMeta.txHash} was not covered but also not ignored - this is a bug`);
|
|
105
|
+
return {
|
|
106
|
+
shouldIgnore: true,
|
|
107
|
+
txHashesToEvict: [],
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
if (txsToEvict.length > 0) {
|
|
112
|
+
this.log.debug(
|
|
113
|
+
`Accepting tx ${incomingMeta.txHash}, evicting ${txsToEvict.length} lower-priority txs due to fee payer balance`,
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
return {
|
|
118
|
+
shouldIgnore: false,
|
|
119
|
+
txHashesToEvict: txsToEvict,
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export { EvictionManager } from './eviction_manager.js';
|
|
2
|
+
export {
|
|
3
|
+
type EvictionConfig,
|
|
4
|
+
type EvictionContext,
|
|
5
|
+
EvictionEvent,
|
|
6
|
+
type EvictionResult,
|
|
7
|
+
type EvictionRule,
|
|
8
|
+
type PoolOperations,
|
|
9
|
+
type PreAddContext,
|
|
10
|
+
type PreAddPoolAccess,
|
|
11
|
+
type PreAddResult,
|
|
12
|
+
type PreAddRule,
|
|
13
|
+
type TaggedEviction,
|
|
14
|
+
TxPoolRejectionCode,
|
|
15
|
+
type TxPoolRejectionError,
|
|
16
|
+
} from './interfaces.js';
|
|
17
|
+
|
|
18
|
+
// Pre-add rules
|
|
19
|
+
export { NullifierConflictRule } from './nullifier_conflict_rule.js';
|
|
20
|
+
export { FeePayerBalancePreAddRule } from './fee_payer_balance_pre_add_rule.js';
|
|
21
|
+
export { LowPriorityPreAddRule } from './low_priority_pre_add_rule.js';
|
|
22
|
+
|
|
23
|
+
// Post-event eviction rules
|
|
24
|
+
export { InvalidTxsAfterMiningRule } from './invalid_txs_after_mining_rule.js';
|
|
25
|
+
export { InvalidTxsAfterReorgRule } from './invalid_txs_after_reorg_rule.js';
|
|
26
|
+
export { FeePayerBalanceEvictionRule } from './fee_payer_balance_eviction_rule.js';
|
|
27
|
+
export { LowPriorityEvictionRule } from './low_priority_eviction_rule.js';
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import type { BlockNumber } from '@aztec/foundation/branded-types';
|
|
2
|
+
import type { BlockHeader, TxHash } from '@aztec/stdlib/tx';
|
|
3
|
+
|
|
4
|
+
import type { TxMetaData } from '../tx_metadata.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Events that trigger eviction checks.
|
|
8
|
+
*/
|
|
9
|
+
export const EvictionEvent = {
|
|
10
|
+
TXS_ADDED: 'txs_added',
|
|
11
|
+
BLOCK_MINED: 'block_mined',
|
|
12
|
+
CHAIN_PRUNED: 'chain_pruned',
|
|
13
|
+
} as const;
|
|
14
|
+
|
|
15
|
+
export type EvictionEventType = (typeof EvictionEvent)[keyof typeof EvictionEvent];
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Context passed to eviction rules based on the triggering event.
|
|
19
|
+
*/
|
|
20
|
+
export type EvictionContext =
|
|
21
|
+
| {
|
|
22
|
+
event: typeof EvictionEvent.TXS_ADDED;
|
|
23
|
+
newTxHashes: string[];
|
|
24
|
+
feePayers: string[];
|
|
25
|
+
}
|
|
26
|
+
| {
|
|
27
|
+
event: typeof EvictionEvent.CHAIN_PRUNED;
|
|
28
|
+
blockNumber: BlockNumber;
|
|
29
|
+
}
|
|
30
|
+
| {
|
|
31
|
+
event: typeof EvictionEvent.BLOCK_MINED;
|
|
32
|
+
block: BlockHeader;
|
|
33
|
+
newNullifiers: string[];
|
|
34
|
+
feePayers: string[];
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Result of an eviction operation.
|
|
39
|
+
*/
|
|
40
|
+
export interface EvictionResult {
|
|
41
|
+
readonly txsEvicted: string[];
|
|
42
|
+
readonly reason: string;
|
|
43
|
+
readonly success: boolean;
|
|
44
|
+
readonly error?: Error;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Read-only access to pool state for pre-add checks.
|
|
49
|
+
*/
|
|
50
|
+
export interface PreAddPoolAccess {
|
|
51
|
+
/** Get metadata for a pending tx by its hash string */
|
|
52
|
+
getMetadata(txHashStr: string): TxMetaData | undefined;
|
|
53
|
+
|
|
54
|
+
/** Get the pending tx hash that uses a specific nullifier (as string) */
|
|
55
|
+
getTxHashByNullifier(nullifier: string): string | undefined;
|
|
56
|
+
|
|
57
|
+
/** Get on-chain balance for a fee payer address */
|
|
58
|
+
getFeePayerBalance(feePayer: string): Promise<bigint>;
|
|
59
|
+
|
|
60
|
+
/** Get metadata for all pending txs from a specific fee payer */
|
|
61
|
+
getFeePayerPendingTxs(feePayer: string): TxMetaData[];
|
|
62
|
+
|
|
63
|
+
/** Get current count of pending transactions */
|
|
64
|
+
getPendingTxCount(): number;
|
|
65
|
+
|
|
66
|
+
/** Get the lowest priority pending tx metadata */
|
|
67
|
+
getLowestPriorityPendingTx(): TxMetaData | undefined;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** A single eviction tagged with the rule that caused it. */
|
|
71
|
+
export interface TaggedEviction {
|
|
72
|
+
readonly txHash: string;
|
|
73
|
+
readonly reason: string;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Machine-readable rejection codes for pre-add rule rejections.
|
|
78
|
+
*/
|
|
79
|
+
export const TxPoolRejectionCode = {
|
|
80
|
+
LOW_PRIORITY_FEE: 'LOW_PRIORITY_FEE',
|
|
81
|
+
INSUFFICIENT_FEE_PAYER_BALANCE: 'INSUFFICIENT_FEE_PAYER_BALANCE',
|
|
82
|
+
NULLIFIER_CONFLICT: 'NULLIFIER_CONFLICT',
|
|
83
|
+
INTERNAL_ERROR: 'INTERNAL_ERROR',
|
|
84
|
+
} as const;
|
|
85
|
+
|
|
86
|
+
export type TxPoolRejectionCode = (typeof TxPoolRejectionCode)[keyof typeof TxPoolRejectionCode];
|
|
87
|
+
|
|
88
|
+
/** Structured rejection reason returned by pre-add rules. */
|
|
89
|
+
export type TxPoolRejectionError =
|
|
90
|
+
| {
|
|
91
|
+
code: typeof TxPoolRejectionCode.LOW_PRIORITY_FEE;
|
|
92
|
+
message: string;
|
|
93
|
+
minimumPriorityFee: bigint;
|
|
94
|
+
txPriorityFee: bigint;
|
|
95
|
+
}
|
|
96
|
+
| {
|
|
97
|
+
code: typeof TxPoolRejectionCode.INSUFFICIENT_FEE_PAYER_BALANCE;
|
|
98
|
+
message: string;
|
|
99
|
+
currentBalance: bigint;
|
|
100
|
+
availableBalance: bigint;
|
|
101
|
+
feeLimit: bigint;
|
|
102
|
+
}
|
|
103
|
+
| { code: typeof TxPoolRejectionCode.NULLIFIER_CONFLICT; message: string; conflictingTxHash: string }
|
|
104
|
+
| { code: typeof TxPoolRejectionCode.INTERNAL_ERROR; message: string };
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Result of a pre-add check for a single transaction.
|
|
108
|
+
*/
|
|
109
|
+
export interface PreAddResult {
|
|
110
|
+
/** Whether the incoming tx should be ignored (valid but not desired) */
|
|
111
|
+
readonly shouldIgnore: boolean;
|
|
112
|
+
/** Tx hashes (as strings) that should be evicted if this tx is added */
|
|
113
|
+
readonly txHashesToEvict: string[];
|
|
114
|
+
/** Evictions tagged with the rule name that produced them. Populated by EvictionManager. */
|
|
115
|
+
readonly evictions?: TaggedEviction[];
|
|
116
|
+
/** Optional reason for ignoring */
|
|
117
|
+
readonly reason?: TxPoolRejectionError;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/** Context passed to pre-add rules from addPendingTxs. */
|
|
121
|
+
export interface PreAddContext {
|
|
122
|
+
/** If true, compare priority fee only (no tx hash tiebreaker). Used for RPC submissions. */
|
|
123
|
+
feeComparisonOnly?: boolean;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Pre-add rule interface. Rules check incoming txs before they're added to the pool.
|
|
128
|
+
* All methods work with TxMetaData for efficiency.
|
|
129
|
+
*/
|
|
130
|
+
export interface PreAddRule {
|
|
131
|
+
readonly name: string;
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Check if incoming tx should be added and which existing txs to evict.
|
|
135
|
+
* @param incomingMeta - Metadata for the incoming transaction
|
|
136
|
+
* @param poolAccess - Read-only access to current pool state
|
|
137
|
+
* @param context - Optional context from addPendingTxs caller
|
|
138
|
+
* @returns Result indicating whether to ignore and what to evict
|
|
139
|
+
*/
|
|
140
|
+
check(incomingMeta: TxMetaData, poolAccess: PreAddPoolAccess, context?: PreAddContext): Promise<PreAddResult>;
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Updates the configuration for this rule.
|
|
144
|
+
*/
|
|
145
|
+
updateConfig?(config: EvictionConfig): void;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Operations that post-event eviction rules can perform on the pool.
|
|
150
|
+
* All methods work with metadata and strings for efficiency.
|
|
151
|
+
*/
|
|
152
|
+
export interface PoolOperations {
|
|
153
|
+
/** Get all pending tx metadata */
|
|
154
|
+
getPendingTxs(): TxMetaData[];
|
|
155
|
+
|
|
156
|
+
/** Get unique fee payers from pending transactions */
|
|
157
|
+
getPendingFeePayers(): string[];
|
|
158
|
+
|
|
159
|
+
/** Get metadata for all pending txs from a specific fee payer */
|
|
160
|
+
getFeePayerPendingTxs(feePayer: string): TxMetaData[];
|
|
161
|
+
|
|
162
|
+
/** Get current count of pending transactions */
|
|
163
|
+
getPendingTxCount(): number;
|
|
164
|
+
|
|
165
|
+
/** Get the N lowest priority pending tx hashes */
|
|
166
|
+
getLowestPriorityPending(limit: number): string[];
|
|
167
|
+
|
|
168
|
+
/** Delete transactions by hash, with an optional reason for metrics */
|
|
169
|
+
deleteTxs(txHashes: string[], reason?: string): Promise<void>;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Post-event eviction rule interface. Rules run after events to clean up the pool.
|
|
174
|
+
*/
|
|
175
|
+
export interface EvictionRule {
|
|
176
|
+
readonly name: string;
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Performs the eviction logic after an event.
|
|
180
|
+
*/
|
|
181
|
+
evict(context: EvictionContext, pool: PoolOperations): Promise<EvictionResult>;
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Updates the configuration for this rule.
|
|
185
|
+
*/
|
|
186
|
+
updateConfig?(config: EvictionConfig): void;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Configuration options for eviction rules.
|
|
191
|
+
*/
|
|
192
|
+
export interface EvictionConfig {
|
|
193
|
+
/** Maximum number of pending transactions (0 = unlimited) */
|
|
194
|
+
maxPendingTxCount?: number;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* Converts a TxHash to its string representation for use in eviction results.
|
|
199
|
+
*/
|
|
200
|
+
export function txHashToString(txHash: TxHash): string {
|
|
201
|
+
return txHash.toString();
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* Converts an array of TxHash to string array.
|
|
206
|
+
*/
|
|
207
|
+
export function txHashesToStrings(txHashes: TxHash[]): string[] {
|
|
208
|
+
return txHashes.map(h => h.toString());
|
|
209
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { createLogger } from '@aztec/foundation/log';
|
|
2
|
+
|
|
3
|
+
import type { EvictionContext, EvictionResult, EvictionRule, PoolOperations } from './interfaces.js';
|
|
4
|
+
import { EvictionEvent } from './interfaces.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Eviction rule that removes invalid transactions after a block is mined.
|
|
8
|
+
* Only triggers on BLOCK_MINED events.
|
|
9
|
+
*
|
|
10
|
+
* Eviction criteria includes:
|
|
11
|
+
* - Transactions with nullifiers that are already included in the mined block
|
|
12
|
+
* - Transactions with an expiration timestamp less than or equal to the mined block timestamp
|
|
13
|
+
*/
|
|
14
|
+
export class InvalidTxsAfterMiningRule implements EvictionRule {
|
|
15
|
+
public readonly name = 'InvalidTxsAfterMining';
|
|
16
|
+
|
|
17
|
+
private log = createLogger('p2p:tx_pool_v2:invalid_txs_after_mining_rule');
|
|
18
|
+
|
|
19
|
+
async evict(context: EvictionContext, pool: PoolOperations): Promise<EvictionResult> {
|
|
20
|
+
if (context.event !== EvictionEvent.BLOCK_MINED) {
|
|
21
|
+
return {
|
|
22
|
+
reason: 'block_mined_invalid_txs',
|
|
23
|
+
success: true,
|
|
24
|
+
txsEvicted: [],
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
try {
|
|
29
|
+
const { timestamp } = context.block.globalVariables;
|
|
30
|
+
const minedNullifiers = new Set(context.newNullifiers);
|
|
31
|
+
|
|
32
|
+
const txsToEvict: string[] = [];
|
|
33
|
+
const pendingTxs = pool.getPendingTxs();
|
|
34
|
+
|
|
35
|
+
for (const meta of pendingTxs) {
|
|
36
|
+
// Evict pending txs that share nullifiers with mined txs
|
|
37
|
+
if (meta.nullifiers.some(nullifier => minedNullifiers.has(nullifier))) {
|
|
38
|
+
txsToEvict.push(meta.txHash);
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// Evict pending txs with an expiration timestamp less than or equal to the mined block timestamp
|
|
43
|
+
if (meta.expirationTimestamp <= timestamp) {
|
|
44
|
+
this.log.verbose(
|
|
45
|
+
`Evicting tx ${meta.txHash} from pool due to the tx being expired (expirationTimestamp: ${meta.expirationTimestamp}, mined block timestamp: ${timestamp})`,
|
|
46
|
+
);
|
|
47
|
+
txsToEvict.push(meta.txHash);
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (txsToEvict.length > 0) {
|
|
53
|
+
this.log.info(`Evicted ${txsToEvict.length} invalid txs after block mined`);
|
|
54
|
+
await pool.deleteTxs(txsToEvict, this.name);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
this.log.debug(`Evicted ${txsToEvict.length} invalid txs after block mined`, { txHashes: txsToEvict });
|
|
58
|
+
|
|
59
|
+
return {
|
|
60
|
+
reason: 'block_mined_invalid_txs',
|
|
61
|
+
success: true,
|
|
62
|
+
txsEvicted: txsToEvict,
|
|
63
|
+
};
|
|
64
|
+
} catch (err) {
|
|
65
|
+
this.log.error('Failed to evict invalid transactions after mining', { err });
|
|
66
|
+
return {
|
|
67
|
+
reason: 'block_mined_invalid_txs',
|
|
68
|
+
success: false,
|
|
69
|
+
txsEvicted: [],
|
|
70
|
+
error: new Error('Failed to evict invalid txs after mining', { cause: err }),
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
|
+
import { createLogger } from '@aztec/foundation/log';
|
|
3
|
+
import type { WorldStateSynchronizer } from '@aztec/stdlib/interfaces/server';
|
|
4
|
+
import { MerkleTreeId } from '@aztec/stdlib/trees';
|
|
5
|
+
|
|
6
|
+
import type { EvictionContext, EvictionResult, EvictionRule, PoolOperations } from './interfaces.js';
|
|
7
|
+
import { EvictionEvent } from './interfaces.js';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Eviction rule that removes invalid transactions after a blockchain reorganization.
|
|
11
|
+
* Only triggers on CHAIN_PRUNED events.
|
|
12
|
+
*
|
|
13
|
+
* Eviction criteria includes:
|
|
14
|
+
* - Transactions that reference pruned block hashes (invalid by definition)
|
|
15
|
+
*/
|
|
16
|
+
export class InvalidTxsAfterReorgRule implements EvictionRule {
|
|
17
|
+
public readonly name = 'InvalidTxsAfterReorg';
|
|
18
|
+
|
|
19
|
+
private log = createLogger('p2p:tx_pool_v2:invalid_txs_after_reorg_rule');
|
|
20
|
+
|
|
21
|
+
constructor(private worldState: WorldStateSynchronizer) {}
|
|
22
|
+
|
|
23
|
+
async evict(context: EvictionContext, pool: PoolOperations): Promise<EvictionResult> {
|
|
24
|
+
if (context.event !== EvictionEvent.CHAIN_PRUNED) {
|
|
25
|
+
return {
|
|
26
|
+
reason: 'reorg_invalid_txs',
|
|
27
|
+
success: true,
|
|
28
|
+
txsEvicted: [],
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
try {
|
|
33
|
+
const pendingTxs = pool.getPendingTxs();
|
|
34
|
+
|
|
35
|
+
// Deduplicate block hashes to reduce redundant DB lookups
|
|
36
|
+
const uniqueBlockHashes = new Map<string, Fr>();
|
|
37
|
+
const txsByBlockHash = new Map<string, string[]>();
|
|
38
|
+
|
|
39
|
+
for (const meta of pendingTxs) {
|
|
40
|
+
const blockHashStr = meta.anchorBlockHeaderHash;
|
|
41
|
+
if (!txsByBlockHash.has(blockHashStr)) {
|
|
42
|
+
txsByBlockHash.set(blockHashStr, []);
|
|
43
|
+
uniqueBlockHashes.set(blockHashStr, Fr.fromHexString(blockHashStr));
|
|
44
|
+
}
|
|
45
|
+
txsByBlockHash.get(blockHashStr)!.push(meta.txHash);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// Ensure world state is synced to this block before accessing the snapshot
|
|
49
|
+
await this.worldState.syncImmediate(context.blockNumber);
|
|
50
|
+
const db = this.worldState.getSnapshot(context.blockNumber);
|
|
51
|
+
|
|
52
|
+
// Check which blocks exist in the archive
|
|
53
|
+
const blockHashArray = Array.from(uniqueBlockHashes.values());
|
|
54
|
+
const blocksFromDb = await db.findLeafIndices(MerkleTreeId.ARCHIVE, blockHashArray);
|
|
55
|
+
|
|
56
|
+
// Build set of pruned block hashes
|
|
57
|
+
const prunedBlockHashes = new Set<string>();
|
|
58
|
+
let i = 0;
|
|
59
|
+
for (const [blockHashStr] of uniqueBlockHashes) {
|
|
60
|
+
if (blocksFromDb[i] === undefined) {
|
|
61
|
+
prunedBlockHashes.add(blockHashStr);
|
|
62
|
+
}
|
|
63
|
+
i++;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// Identify txs whose anchor block was pruned
|
|
67
|
+
const txsToEvict: string[] = [];
|
|
68
|
+
for (const [blockHashStr, txHashes] of txsByBlockHash) {
|
|
69
|
+
if (prunedBlockHashes.has(blockHashStr)) {
|
|
70
|
+
txsToEvict.push(...txHashes);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (txsToEvict.length > 0) {
|
|
75
|
+
this.log.info(`Evicting ${txsToEvict.length} txs from pool due to referencing pruned blocks`);
|
|
76
|
+
await pool.deleteTxs(txsToEvict, this.name);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const keptCount = pendingTxs.length - txsToEvict.length;
|
|
80
|
+
if (keptCount > 0) {
|
|
81
|
+
this.log.verbose(`Kept ${keptCount} txs that did not reference pruned blocks`);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
this.log.debug(`Evicted ${txsToEvict.length} invalid txs after reorg`, { txHashes: txsToEvict });
|
|
85
|
+
|
|
86
|
+
return {
|
|
87
|
+
reason: 'reorg_invalid_txs',
|
|
88
|
+
success: true,
|
|
89
|
+
txsEvicted: txsToEvict,
|
|
90
|
+
};
|
|
91
|
+
} catch (err) {
|
|
92
|
+
this.log.error('Failed to evict invalid transactions after reorg', { err });
|
|
93
|
+
return {
|
|
94
|
+
reason: 'reorg_invalid_txs',
|
|
95
|
+
success: false,
|
|
96
|
+
txsEvicted: [],
|
|
97
|
+
error: new Error('Failed to evict invalid txs after reorg', { cause: err }),
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|