@aztec/p2p 0.0.1-commit.fcb71a6 → 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 -14
- package/dest/client/interface.d.ts +58 -25
- package/dest/client/interface.d.ts.map +1 -1
- package/dest/client/p2p_client.d.ts +46 -51
- package/dest/client/p2p_client.d.ts.map +1 -1
- package/dest/client/p2p_client.js +601 -259
- 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 +35 -7
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +23 -9
- 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 +527 -287
- 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 +9 -6
- package/dest/mem_pools/attestation_pool/mocks.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/mocks.js +16 -12
- 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 +5 -14
- 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 +15 -10
- 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 +91 -50
- package/dest/mem_pools/tx_pool/eviction/eviction_manager.d.ts +19 -5
- package/dest/mem_pools/tx_pool/eviction/eviction_manager.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool/eviction/eviction_manager.js +59 -3
- package/dest/mem_pools/tx_pool/eviction/eviction_strategy.d.ts +79 -5
- package/dest/mem_pools/tx_pool/eviction/eviction_strategy.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool/eviction/eviction_strategy.js +47 -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 +2 -2
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.js +3 -3
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.d.ts +4 -4
- 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/eviction/low_priority_eviction_rule.d.ts +2 -2
- package/dest/mem_pools/tx_pool/eviction/low_priority_eviction_rule.d.ts.map +1 -1
- 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_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 +51 -18
- 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 +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/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 +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 +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 +9 -7
- 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 +106 -33
- package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
- package/dest/services/libp2p/libp2p_service.js +984 -317
- 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 +21 -26
- 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 +0 -10
- 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 +12 -1
- package/dest/services/reqresp/interface.d.ts.map +1 -1
- package/dest/services/reqresp/interface.js +15 -1
- 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/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 +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/status.d.ts +1 -1
- package/dest/services/reqresp/protocols/status.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/status.js +4 -1
- 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 +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 +55 -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 +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 -5
- 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 +29 -16
- 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 +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 +7 -20
- 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/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 +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 -127
- 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 +16 -16
- package/src/bootstrap/bootstrap.ts +7 -4
- package/src/client/factory.ts +96 -24
- package/src/client/interface.ts +76 -25
- package/src/client/p2p_client.ts +269 -290
- 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 +49 -13
- 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 +612 -320
- package/src/mem_pools/attestation_pool/index.ts +9 -2
- package/src/mem_pools/attestation_pool/mocks.ts +20 -13
- package/src/mem_pools/index.ts +4 -1
- package/src/mem_pools/instrumentation.ts +10 -18
- package/src/mem_pools/interface.ts +4 -4
- package/src/mem_pools/tx_pool/README.md +29 -14
- package/src/mem_pools/tx_pool/aztec_kv_tx_pool.ts +130 -75
- package/src/mem_pools/tx_pool/eviction/eviction_manager.ts +66 -5
- package/src/mem_pools/tx_pool/eviction/eviction_strategy.ts +119 -4
- 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 +3 -3
- package/src/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.ts +4 -2
- package/src/mem_pools/tx_pool/eviction/nullifier_conflict_pre_add_rule.ts +75 -0
- 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 +36 -21
- 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 +64 -23
- 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 +18 -7
- 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 +29 -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 +8 -6
- 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 +651 -301
- package/src/services/peer-manager/metrics.ts +22 -26
- package/src/services/peer-manager/peer_manager.ts +1 -2
- 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 +29 -1
- package/src/services/reqresp/metrics.ts +36 -27
- 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 +74 -9
- package/src/services/reqresp/protocols/status.ts +7 -4
- package/src/services/reqresp/protocols/tx.ts +22 -0
- package/src/services/reqresp/reqresp.ts +79 -22
- package/src/services/service.ts +72 -4
- package/src/services/tx_collection/config.ts +83 -1
- package/src/services/tx_collection/fast_tx_collection.ts +93 -47
- 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 +68 -35
- package/src/services/tx_collection/tx_collection.ts +121 -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 +10 -9
- package/src/services/tx_provider_instrumentation.ts +13 -20
- 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 +143 -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 +430 -0
- package/src/testbench/p2p_client_testbench_worker.ts +348 -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/eviction/insufficient_fee_payer_balance_rule.d.ts +0 -15
- package/dest/mem_pools/tx_pool/eviction/insufficient_fee_payer_balance_rule.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/eviction/insufficient_fee_payer_balance_rule.js +0 -88
- 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/eviction/insufficient_fee_payer_balance_rule.ts +0 -108
- package/src/msg_validators/block_proposal_validator/block_proposal_validator.ts +0 -97
- package/src/msg_validators/block_proposal_validator/index.ts +0 -1
|
@@ -1,2 +1,9 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
1
|
+
export {
|
|
2
|
+
AttestationPool,
|
|
3
|
+
type AttestationPoolApi,
|
|
4
|
+
type TryAddResult,
|
|
5
|
+
createTestAttestationPool,
|
|
6
|
+
MAX_CHECKPOINT_PROPOSALS_PER_SLOT,
|
|
7
|
+
MAX_BLOCK_PROPOSALS_PER_POSITION,
|
|
8
|
+
MAX_ATTESTATIONS_PER_SLOT_AND_SIGNER,
|
|
9
|
+
} from './attestation_pool.js';
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
+
import { SlotNumber } from '@aztec/foundation/branded-types';
|
|
1
2
|
import type { Secp256k1Signer } from '@aztec/foundation/crypto/secp256k1-signer';
|
|
2
3
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
4
|
import {
|
|
4
|
-
|
|
5
|
+
CheckpointAttestation,
|
|
5
6
|
ConsensusPayload,
|
|
6
7
|
SignatureDomainSeparator,
|
|
7
8
|
getHashedSignaturePayloadEthSignedMessage,
|
|
8
9
|
} from '@aztec/stdlib/p2p';
|
|
9
|
-
import {
|
|
10
|
+
import { CheckpointHeader } from '@aztec/stdlib/rollup';
|
|
10
11
|
|
|
11
12
|
import { type LocalAccount, generatePrivateKey, privateKeyToAccount } from 'viem/accounts';
|
|
12
13
|
|
|
@@ -20,26 +21,32 @@ export const generateAccount = (): LocalAccount => {
|
|
|
20
21
|
return privateKeyToAccount(privateKey);
|
|
21
22
|
};
|
|
22
23
|
|
|
23
|
-
/** Mock Attestation
|
|
24
|
+
/** Mock Checkpoint Attestation
|
|
24
25
|
*
|
|
25
|
-
* @param signer A
|
|
26
|
+
* @param signer A Secp256k1Signer to create a signature
|
|
26
27
|
* @param slot The slot number the attestation is for
|
|
27
|
-
* @
|
|
28
|
+
* @param archive The archive root (defaults to random)
|
|
29
|
+
* @param header The checkpoint header (defaults to random with given slot)
|
|
30
|
+
* @returns A Checkpoint Attestation
|
|
28
31
|
*/
|
|
29
|
-
export const
|
|
32
|
+
export const mockCheckpointAttestation = (
|
|
30
33
|
signer: Secp256k1Signer,
|
|
31
34
|
slot: number = 0,
|
|
32
35
|
archive: Fr = Fr.random(),
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
36
|
+
header?: CheckpointHeader,
|
|
37
|
+
feeAssetPriceModifier: bigint = 0n,
|
|
38
|
+
): CheckpointAttestation => {
|
|
39
|
+
header = header ?? CheckpointHeader.random({ slotNumber: SlotNumber(slot) });
|
|
40
|
+
const payload = new ConsensusPayload(header, archive, feeAssetPriceModifier);
|
|
37
41
|
|
|
38
|
-
const attestationHash = getHashedSignaturePayloadEthSignedMessage(
|
|
42
|
+
const attestationHash = getHashedSignaturePayloadEthSignedMessage(
|
|
43
|
+
payload,
|
|
44
|
+
SignatureDomainSeparator.checkpointAttestation,
|
|
45
|
+
);
|
|
39
46
|
const attestationSignature = signer.sign(attestationHash);
|
|
40
47
|
|
|
41
|
-
const proposalHash = getHashedSignaturePayloadEthSignedMessage(payload, SignatureDomainSeparator.
|
|
48
|
+
const proposalHash = getHashedSignaturePayloadEthSignedMessage(payload, SignatureDomainSeparator.checkpointProposal);
|
|
42
49
|
const proposerSignature = signer.sign(proposalHash);
|
|
43
50
|
|
|
44
|
-
return new
|
|
51
|
+
return new CheckpointAttestation(payload, attestationSignature, proposerSignature);
|
|
45
52
|
};
|
package/src/mem_pools/index.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
-
export { type
|
|
1
|
+
export { AttestationPool, type AttestationPoolApi } from './attestation_pool/attestation_pool.js';
|
|
2
2
|
export { type MemPools } from './interface.js';
|
|
3
|
+
// Old TxPool exports - kept temporarily for external consumers
|
|
3
4
|
export { type TxPool } from './tx_pool/tx_pool.js';
|
|
5
|
+
// New TxPoolV2 exports
|
|
6
|
+
export { type TxPoolV2, type TxPoolV2Config, type TxPoolV2Events, type AddTxsResult } from './tx_pool_v2/index.js';
|
|
@@ -7,11 +7,12 @@ import {
|
|
|
7
7
|
LmdbMetrics,
|
|
8
8
|
type LmdbStatsCallback,
|
|
9
9
|
type Meter,
|
|
10
|
+
type MetricDefinition,
|
|
10
11
|
Metrics,
|
|
11
|
-
type MetricsType,
|
|
12
12
|
type ObservableGauge,
|
|
13
13
|
type TelemetryClient,
|
|
14
14
|
type UpDownCounter,
|
|
15
|
+
createUpDownCounterWithDefault,
|
|
15
16
|
} from '@aztec/telemetry-client';
|
|
16
17
|
|
|
17
18
|
export enum PoolName {
|
|
@@ -20,10 +21,10 @@ export enum PoolName {
|
|
|
20
21
|
}
|
|
21
22
|
|
|
22
23
|
type MetricsLabels = {
|
|
23
|
-
objectInMempool:
|
|
24
|
-
objectSize:
|
|
25
|
-
itemsAdded:
|
|
26
|
-
itemMinedDelay:
|
|
24
|
+
objectInMempool: MetricDefinition;
|
|
25
|
+
objectSize: MetricDefinition;
|
|
26
|
+
itemsAdded: MetricDefinition;
|
|
27
|
+
itemMinedDelay: MetricDefinition;
|
|
27
28
|
};
|
|
28
29
|
|
|
29
30
|
/**
|
|
@@ -85,14 +86,9 @@ export class PoolInstrumentation<PoolObject extends Gossipable> {
|
|
|
85
86
|
|
|
86
87
|
const metricsLabels = getMetricsLabels(name);
|
|
87
88
|
|
|
88
|
-
this.objectsInMempool = this.meter.createObservableGauge(metricsLabels.objectInMempool
|
|
89
|
-
description: 'The current number of transactions in the mempool',
|
|
90
|
-
});
|
|
89
|
+
this.objectsInMempool = this.meter.createObservableGauge(metricsLabels.objectInMempool);
|
|
91
90
|
|
|
92
|
-
this.objectSize = this.meter.createHistogram(metricsLabels.objectSize
|
|
93
|
-
unit: 'By',
|
|
94
|
-
description: 'The size of transactions in the mempool',
|
|
95
|
-
});
|
|
91
|
+
this.objectSize = this.meter.createHistogram(metricsLabels.objectSize);
|
|
96
92
|
|
|
97
93
|
this.dbMetrics = new LmdbMetrics(
|
|
98
94
|
this.meter,
|
|
@@ -102,13 +98,9 @@ export class PoolInstrumentation<PoolObject extends Gossipable> {
|
|
|
102
98
|
dbStats,
|
|
103
99
|
);
|
|
104
100
|
|
|
105
|
-
this.addObjectCounter = this.meter
|
|
106
|
-
description: 'The number of transactions added to the mempool',
|
|
107
|
-
});
|
|
101
|
+
this.addObjectCounter = createUpDownCounterWithDefault(this.meter, metricsLabels.itemsAdded);
|
|
108
102
|
|
|
109
|
-
this.minedDelay = this.meter.createHistogram(metricsLabels.itemMinedDelay
|
|
110
|
-
description: 'Delay between transaction added and evicted from the mempool',
|
|
111
|
-
});
|
|
103
|
+
this.minedDelay = this.meter.createHistogram(metricsLabels.itemMinedDelay);
|
|
112
104
|
|
|
113
105
|
this.meter.addBatchObservableCallback(this.observeStats, [this.objectsInMempool]);
|
|
114
106
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
1
|
+
import type { AttestationPoolApi } from './attestation_pool/attestation_pool.js';
|
|
2
|
+
import type { TxPoolV2 } from './tx_pool_v2/interfaces.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* A interface the combines all mempools
|
|
6
6
|
*/
|
|
7
7
|
export type MemPools = {
|
|
8
|
-
txPool:
|
|
9
|
-
attestationPool:
|
|
8
|
+
txPool: TxPoolV2;
|
|
9
|
+
attestationPool: AttestationPoolApi;
|
|
10
10
|
};
|
|
@@ -24,7 +24,7 @@ The lifecycle of transactions in the pool is summarised in the following table:
|
|
|
24
24
|
|
|
25
25
|
**Note on why Soft Delete:**
|
|
26
26
|
Mined transactions are soft-deleted rather than permanently removed to support:
|
|
27
|
-
1. Reorg handling — If a chain reorganization occurs, soft-deleted transactions are still available in the mempool
|
|
27
|
+
1. Reorg handling — If a chain reorganization occurs, soft-deleted transactions are still available in the mempool
|
|
28
28
|
2. Slash condition detection — The epoch prune watcher needs access to transactions from pruned epochs to correctly identify data withholding slash conditions. Without soft-delete, transactions invalidated by reorgs (e.g., built on removed blocks) would be lost, causing false positives for data withholding violations.
|
|
29
29
|
|
|
30
30
|
Mined transactions are permanently deleted via `cleanupDeletedMinedTxs()` once their original block is finalized on L1, ensuring theyremain available during the uncertainty window.
|
|
@@ -34,7 +34,7 @@ Alternatively, mined transactions can be permanently deleted immediately by pass
|
|
|
34
34
|
|
|
35
35
|
| Method | Description |
|
|
36
36
|
|--------|-------------|
|
|
37
|
-
| `addTxs(txs, opts?)` | Adds transactions to the pool. Duplicates are
|
|
37
|
+
| `addTxs(txs, opts?)` | Adds transactions to the pool. Duplicates and nullifier conflicts are handled. Returns count of newly added txs. |
|
|
38
38
|
| `deleteTxs(txHashes, opts?)` | Removes transactions from the pool. Supports soft-delete for mined txs. |
|
|
39
39
|
| `markAsMined(txHashes, blockHeader)` | Marks transactions as included in a block. |
|
|
40
40
|
| `markMinedAsPending(txHashes, blockNumber)` | Reverts mined transactions to pending (used during reorgs). |
|
|
@@ -91,6 +91,7 @@ The pool maintains several KV maps and indexes:
|
|
|
91
91
|
| `#txHashToHistoricalBlockHeaderHash` | Anchor block reference for each tx |
|
|
92
92
|
| `#historicalHeaderToTxHash` | Index from historical block → tx hashes |
|
|
93
93
|
| `#feePayerToTxHash` | Index from fee payer address → tx hashes |
|
|
94
|
+
| `#pendingNullifierToTxHash` | Index from nullifier → tx hash |
|
|
94
95
|
| `#archivedTxs` | Archived transactions for historical lookup |
|
|
95
96
|
|
|
96
97
|
#### In-Memory Caches
|
|
@@ -117,15 +118,17 @@ The priority is stored as a hex string derived from a 32-byte buffer representat
|
|
|
117
118
|
When `addTxs()` is called:
|
|
118
119
|
|
|
119
120
|
1. Check for duplicates (skip if tx already exists)
|
|
120
|
-
2.
|
|
121
|
-
3.
|
|
122
|
-
4.
|
|
121
|
+
2. Check for nullifier conflicts (see Nullifier Deduplication below)
|
|
122
|
+
3. Store the serialized tx in `#txs`
|
|
123
|
+
4. Index the tx by its anchor block hash
|
|
124
|
+
5. If not already mined, add to pending indexes:
|
|
123
125
|
- Priority-to-hash index (for ordering)
|
|
124
126
|
- Historical header index (for reorg handling)
|
|
125
127
|
- Fee payer index (for balance validation)
|
|
126
|
-
|
|
127
|
-
6.
|
|
128
|
-
7.
|
|
128
|
+
- Nullifier-to-tx-hash index (for conflict detection)
|
|
129
|
+
6. Record metrics
|
|
130
|
+
7. Trigger eviction rules for `TXS_ADDED` event
|
|
131
|
+
8. Emit `txs-added` event
|
|
129
132
|
|
|
130
133
|
### 2. Marking as Mined
|
|
131
134
|
|
|
@@ -152,6 +155,16 @@ The `deleteTxs()` method handles two cases:
|
|
|
152
155
|
|
|
153
156
|
Soft-deleted mined transactions are retained for potential future reference and can be permanently cleaned up later via `cleanupDeletedMinedTxs()`.
|
|
154
157
|
|
|
158
|
+
### Nullifier Deduplication
|
|
159
|
+
|
|
160
|
+
The pool prevents nullifier spam attacks by ensuring only one pending transaction can reference each unique nullifier. When an incoming transaction shares nullifiers with existing pending transactions:
|
|
161
|
+
|
|
162
|
+
- **Higher fee wins**: If the incoming tx has a higher priority fee than ALL conflicting txs, those conflicting txs are replaced
|
|
163
|
+
- **Existing tx wins on tie**: If any conflicting tx has an equal or higher fee, the incoming tx is rejected
|
|
164
|
+
- **Partial overlap counts**: Even a single shared nullifier triggers conflict resolution
|
|
165
|
+
|
|
166
|
+
This is enforced at entry time via the `#pendingNullifierToTxHash` index, which maps each nullifier to the tx hash that references it. The index is maintained atomically with tx additions and removals.
|
|
167
|
+
|
|
155
168
|
## Eviction System
|
|
156
169
|
|
|
157
170
|
The eviction system automatically removes invalid or low-priority transactions based on configurable rules. See the [`eviction/`](eviction/) subdirectory for implementation details.
|
|
@@ -189,7 +202,7 @@ The [`EvictionManager`](eviction/eviction_manager.ts) coordinates eviction by:
|
|
|
189
202
|
|-------|---------|---------|
|
|
190
203
|
| `TXS_ADDED` | New transactions added | Enforce pool size limits |
|
|
191
204
|
| `BLOCK_MINED` | Block finalized | Remove invalidated transactions |
|
|
192
|
-
| `CHAIN_PRUNED` | Chain reorganization | Remove txs referencing pruned blocks |
|
|
205
|
+
| `CHAIN_PRUNED` | Chain reorganization | Remove txs referencing pruned blocks and re-evaluate fee payer balances |
|
|
193
206
|
|
|
194
207
|
### Eviction Rules
|
|
195
208
|
|
|
@@ -200,7 +213,7 @@ The [`EvictionManager`](eviction/eviction_manager.ts) coordinates eviction by:
|
|
|
200
213
|
Evicts transactions that become invalid after a block is mined:
|
|
201
214
|
|
|
202
215
|
- Duplicate nullifiers: Txs with nullifiers already included in the mined block
|
|
203
|
-
- Expired transactions: Txs with `
|
|
216
|
+
- Expired transactions: Txs with `expirationTimestamp` ≤ mined block timestamp
|
|
204
217
|
|
|
205
218
|
#### 2. `InvalidTxsAfterReorgRule`
|
|
206
219
|
|
|
@@ -211,13 +224,15 @@ Evicts transactions that reference blocks no longer in the canonical chain:
|
|
|
211
224
|
- Checks each pending tx's anchor block hash against the archive tree
|
|
212
225
|
- Removes txs whose anchor blocks are not found (pruned)
|
|
213
226
|
|
|
214
|
-
#### 3. `
|
|
227
|
+
#### 3. `FeePayerBalanceEvictionRule`
|
|
215
228
|
|
|
216
|
-
**Triggers on:** `BLOCK_MINED`, `CHAIN_PRUNED`
|
|
229
|
+
**Triggers on:** `TXS_ADDED`, `BLOCK_MINED`, `CHAIN_PRUNED`
|
|
217
230
|
|
|
218
|
-
Evicts transactions
|
|
231
|
+
Evicts low-priority transactions when a fee payer's pending fee limits exceed their Fee Juice balance:
|
|
219
232
|
|
|
220
|
-
-
|
|
233
|
+
- Evaluates transactions in priority order so higher-priority claims can fund lower-priority spends
|
|
234
|
+
- Accounts for self-funding claims made during setup
|
|
235
|
+
- Removes evictable txs that do not fit within the running balance
|
|
221
236
|
|
|
222
237
|
#### 4. `LowPriorityEvictionRule`
|
|
223
238
|
|
|
@@ -5,8 +5,8 @@ import { toArray } from '@aztec/foundation/iterable';
|
|
|
5
5
|
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
6
6
|
import type { TypedEventEmitter } from '@aztec/foundation/types';
|
|
7
7
|
import type { AztecAsyncKVStore, AztecAsyncMap, AztecAsyncMultiMap } from '@aztec/kv-store';
|
|
8
|
-
import
|
|
9
|
-
import type { MerkleTreeReadOperations,
|
|
8
|
+
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
9
|
+
import type { MerkleTreeReadOperations, WorldStateSynchronizer } from '@aztec/stdlib/interfaces/server';
|
|
10
10
|
import { ChonkProof } from '@aztec/stdlib/proofs';
|
|
11
11
|
import type { TxAddedToPoolStats } from '@aztec/stdlib/stats';
|
|
12
12
|
import { BlockHeader, Tx, TxHash } from '@aztec/stdlib/tx';
|
|
@@ -18,11 +18,18 @@ import EventEmitter from 'node:events';
|
|
|
18
18
|
import { ArchiveCache } from '../../msg_validators/tx_validator/archive_cache.js';
|
|
19
19
|
import { PoolInstrumentation, PoolName, type PoolStatsCallback } from '../instrumentation.js';
|
|
20
20
|
import { EvictionManager } from './eviction/eviction_manager.js';
|
|
21
|
-
import
|
|
22
|
-
|
|
21
|
+
import {
|
|
22
|
+
FeePayerTxInfo,
|
|
23
|
+
type PendingTxInfo,
|
|
24
|
+
type PreAddPoolAccess,
|
|
25
|
+
type TxBlockReference,
|
|
26
|
+
type TxPoolOperations,
|
|
27
|
+
} from './eviction/eviction_strategy.js';
|
|
28
|
+
import { FeePayerBalanceEvictionRule } from './eviction/fee_payer_balance_eviction_rule.js';
|
|
23
29
|
import { InvalidTxsAfterMiningRule } from './eviction/invalid_txs_after_mining_rule.js';
|
|
24
30
|
import { InvalidTxsAfterReorgRule } from './eviction/invalid_txs_after_reorg_rule.js';
|
|
25
31
|
import { LowPriorityEvictionRule } from './eviction/low_priority_eviction_rule.js';
|
|
32
|
+
import { NullifierConflictPreAddRule } from './eviction/nullifier_conflict_pre_add_rule.js';
|
|
26
33
|
import { getPendingTxPriority } from './priority.js';
|
|
27
34
|
import type { TxPool, TxPoolEvents, TxPoolOptions } from './tx_pool.js';
|
|
28
35
|
|
|
@@ -55,7 +62,10 @@ export class AztecKVTxPool
|
|
|
55
62
|
|
|
56
63
|
#historicalHeaderToTxHash: AztecAsyncMultiMap<string, string>;
|
|
57
64
|
|
|
58
|
-
#
|
|
65
|
+
#feePayerToBalanceEntry: AztecAsyncMultiMap<string, Buffer>;
|
|
66
|
+
|
|
67
|
+
/** Index from nullifier to pending tx hash */
|
|
68
|
+
#pendingNullifierToTxHash: AztecAsyncMap<string, string>;
|
|
59
69
|
|
|
60
70
|
/** In-memory set of txs that should not be evicted from the pool. */
|
|
61
71
|
#nonEvictableTxs: Set<string>;
|
|
@@ -89,7 +99,7 @@ export class AztecKVTxPool
|
|
|
89
99
|
constructor(
|
|
90
100
|
store: AztecAsyncKVStore,
|
|
91
101
|
archive: AztecAsyncKVStore,
|
|
92
|
-
worldState:
|
|
102
|
+
worldState: WorldStateSynchronizer,
|
|
93
103
|
telemetry: TelemetryClient = getTelemetryClient(),
|
|
94
104
|
config: TxPoolOptions = {},
|
|
95
105
|
log = createLogger('p2p:tx_pool'),
|
|
@@ -101,13 +111,14 @@ export class AztecKVTxPool
|
|
|
101
111
|
this.#evictionManager = new EvictionManager(this);
|
|
102
112
|
this.#evictionManager.registerRule(new InvalidTxsAfterMiningRule());
|
|
103
113
|
this.#evictionManager.registerRule(new InvalidTxsAfterReorgRule(worldState));
|
|
104
|
-
this.#evictionManager.registerRule(new
|
|
114
|
+
this.#evictionManager.registerRule(new FeePayerBalanceEvictionRule(worldState));
|
|
105
115
|
this.#evictionManager.registerRule(
|
|
106
116
|
new LowPriorityEvictionRule({
|
|
107
117
|
//NOTE: 0 effectively disables low priority eviction
|
|
108
118
|
maxPoolSize: config.maxPendingTxCount ?? 0,
|
|
109
119
|
}),
|
|
110
120
|
);
|
|
121
|
+
this.#evictionManager.registerPreAddRule(new NullifierConflictPreAddRule());
|
|
111
122
|
|
|
112
123
|
this.updateConfig(config);
|
|
113
124
|
|
|
@@ -119,7 +130,8 @@ export class AztecKVTxPool
|
|
|
119
130
|
|
|
120
131
|
this.#pendingTxHashToHistoricalBlockHeaderHash = store.openMap('txHistoricalBlock');
|
|
121
132
|
this.#historicalHeaderToTxHash = store.openMultiMap('historicalHeaderToPendingTxHash');
|
|
122
|
-
this.#
|
|
133
|
+
this.#feePayerToBalanceEntry = store.openMultiMap('feePayerToBalanceEntry');
|
|
134
|
+
this.#pendingNullifierToTxHash = store.openMap('pendingNullifierToTxHash');
|
|
123
135
|
|
|
124
136
|
this.#nonEvictableTxs = new Set<string>();
|
|
125
137
|
|
|
@@ -171,7 +183,7 @@ export class AztecKVTxPool
|
|
|
171
183
|
const key = hash.toString();
|
|
172
184
|
await this.#minedTxHashToBlock.set(key, blockHeader.globalVariables.blockNumber);
|
|
173
185
|
|
|
174
|
-
const tx = await this.
|
|
186
|
+
const tx = await this.getTxByHash(hash);
|
|
175
187
|
if (tx) {
|
|
176
188
|
const nullifiers = tx.data.getNonEmptyNullifiers();
|
|
177
189
|
|
|
@@ -216,8 +228,16 @@ export class AztecKVTxPool
|
|
|
216
228
|
const key = hash.toString();
|
|
217
229
|
await this.#minedTxHashToBlock.delete(key);
|
|
218
230
|
|
|
231
|
+
// Clear soft-delete metadata if this tx was previously soft-deleted,
|
|
232
|
+
// so cleanupDeletedMinedTxs won't later hard-delete it while it's pending
|
|
233
|
+
const deletedBlock = await this.#deletedMinedTxHashes.getAsync(key);
|
|
234
|
+
if (deletedBlock !== undefined) {
|
|
235
|
+
await this.#deletedMinedTxHashes.delete(key);
|
|
236
|
+
await this.#blockToDeletedMinedTxHash.deleteValue(deletedBlock, key);
|
|
237
|
+
}
|
|
238
|
+
|
|
219
239
|
// Rehydrate the tx in the in-memory pending txs mapping
|
|
220
|
-
const tx = await this.
|
|
240
|
+
const tx = await this.getTxByHash(hash);
|
|
221
241
|
if (tx) {
|
|
222
242
|
await this.addPendingTxIndicesInDbTx(tx, key);
|
|
223
243
|
}
|
|
@@ -271,6 +291,8 @@ export class AztecKVTxPool
|
|
|
271
291
|
|
|
272
292
|
/**
|
|
273
293
|
* Adds a list of transactions to the pool. Duplicates are ignored.
|
|
294
|
+
* Handles nullifier deduplication: if an incoming tx has a nullifier conflict with
|
|
295
|
+
* existing pending txs, it will either replace them (if higher fee) or be rejected.
|
|
274
296
|
* @param txs - An array of txs to be added to the pool.
|
|
275
297
|
* @returns count of added transactions
|
|
276
298
|
*/
|
|
@@ -280,43 +302,69 @@ export class AztecKVTxPool
|
|
|
280
302
|
}
|
|
281
303
|
|
|
282
304
|
const addedTxs: Tx[] = [];
|
|
305
|
+
const uniqueFeePayers: AztecAddress[] = [];
|
|
306
|
+
const replacedTxHashes: TxHash[] = [];
|
|
283
307
|
const hashesAndStats = txs.map(tx => ({ txHash: tx.getTxHash(), txStats: tx.getStats() }));
|
|
284
308
|
try {
|
|
285
309
|
await this.#store.transactionAsync(async () => {
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
310
|
+
for (let i = 0; i < txs.length; i++) {
|
|
311
|
+
const tx = txs[i];
|
|
312
|
+
const { txHash, txStats } = hashesAndStats[i];
|
|
313
|
+
const key = txHash.toString();
|
|
314
|
+
if (await this.#txs.hasAsync(key)) {
|
|
315
|
+
this.#log.debug(`Tx ${key} already exists in the pool`);
|
|
316
|
+
continue;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
const poolAccess = this.getPreAddPoolAccess();
|
|
320
|
+
const { shouldReject, txHashesToEvict } = await this.#evictionManager.runPreAddRules(tx, poolAccess);
|
|
321
|
+
if (shouldReject) {
|
|
322
|
+
continue;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
for (const txHashToEvict of txHashesToEvict) {
|
|
326
|
+
const txToDelete = await this.getTxByHash(txHashToEvict);
|
|
327
|
+
if (txToDelete) {
|
|
328
|
+
const evictedKey = txHashToEvict.toString();
|
|
329
|
+
await this.deletePendingTxInDbTx(txToDelete, evictedKey);
|
|
330
|
+
replacedTxHashes.push(txHashToEvict);
|
|
331
|
+
this.#log.verbose(`Evicted tx ${evictedKey} due to higher-fee tx ${key}`);
|
|
293
332
|
}
|
|
333
|
+
}
|
|
294
334
|
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
335
|
+
this.#log.verbose(`Adding tx ${key} to pool`, {
|
|
336
|
+
eventName: 'tx-added-to-pool',
|
|
337
|
+
...txStats,
|
|
338
|
+
} satisfies TxAddedToPoolStats);
|
|
299
339
|
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
key,
|
|
304
|
-
(await tx.data.constants.anchorBlockHeader.hash()).toString(),
|
|
305
|
-
);
|
|
340
|
+
await this.#txs.set(key, tx.toBuffer());
|
|
341
|
+
addedTxs.push(tx);
|
|
342
|
+
insertIntoSortedArray(uniqueFeePayers, tx.data.feePayer, (a, b) => a.toField().cmp(b.toField()), false);
|
|
306
343
|
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
344
|
+
await this.#pendingTxHashToHistoricalBlockHeaderHash.set(
|
|
345
|
+
key,
|
|
346
|
+
(await tx.data.constants.anchorBlockHeader.hash()).toString(),
|
|
347
|
+
);
|
|
348
|
+
|
|
349
|
+
if (!(await this.#minedTxHashToBlock.hasAsync(key))) {
|
|
350
|
+
await this.addPendingTxIndicesInDbTx(tx, key);
|
|
351
|
+
this.#metrics.recordSize(tx);
|
|
352
|
+
}
|
|
353
|
+
}
|
|
313
354
|
});
|
|
314
355
|
|
|
315
|
-
await this.#evictionManager.evictAfterNewTxs(
|
|
356
|
+
await this.#evictionManager.evictAfterNewTxs(
|
|
357
|
+
addedTxs.map(({ txHash }) => txHash),
|
|
358
|
+
uniqueFeePayers,
|
|
359
|
+
);
|
|
316
360
|
} catch (err) {
|
|
317
361
|
this.#log.warn('Unexpected error when adding txs', { err });
|
|
318
362
|
}
|
|
319
363
|
|
|
364
|
+
if (replacedTxHashes.length > 0) {
|
|
365
|
+
this.#metrics.transactionsRemoved(replacedTxHashes.map(hash => hash.toBigInt()));
|
|
366
|
+
}
|
|
367
|
+
|
|
320
368
|
if (addedTxs.length > 0) {
|
|
321
369
|
this.#metrics.transactionsAdded(addedTxs);
|
|
322
370
|
this.emit('txs-added', { ...opts, txs: addedTxs });
|
|
@@ -348,7 +396,7 @@ export class AztecKVTxPool
|
|
|
348
396
|
const minedBlockNumber = await this.#minedTxHashToBlock.getAsync(key);
|
|
349
397
|
const txIsPending = minedBlockNumber === undefined;
|
|
350
398
|
if (txIsPending) {
|
|
351
|
-
await this.
|
|
399
|
+
await this.deletePendingTxInDbTx(tx, key);
|
|
352
400
|
} else {
|
|
353
401
|
await this.deleteMinedTx(key, minedBlockNumber!, opts?.permanently ?? false);
|
|
354
402
|
const shouldArchiveTx = this.#archivedTxLimit && !opts?.permanently;
|
|
@@ -378,10 +426,11 @@ export class AztecKVTxPool
|
|
|
378
426
|
await this.#blockToDeletedMinedTxHash.set(minedBlockNumber, txHash);
|
|
379
427
|
}
|
|
380
428
|
|
|
381
|
-
|
|
429
|
+
// Assumes being called within a DB transaction
|
|
430
|
+
private async deletePendingTxInDbTx(tx: Tx, txHash: `0x${string}`) {
|
|
382
431
|
// We always permanently delete pending transactions
|
|
383
432
|
this.#log.trace(`Deleting pending tx ${txHash} from pool`);
|
|
384
|
-
await this.
|
|
433
|
+
await this.removePendingTxIndicesInDbTx(tx, txHash);
|
|
385
434
|
await this.#txs.delete(txHash);
|
|
386
435
|
await this.#pendingTxHashToHistoricalBlockHeaderHash.delete(txHash);
|
|
387
436
|
}
|
|
@@ -414,7 +463,7 @@ export class AztecKVTxPool
|
|
|
414
463
|
let historicalBlockHash = await this.#pendingTxHashToHistoricalBlockHeaderHash.getAsync(txHash.toString());
|
|
415
464
|
// Not all tx might have this index created.
|
|
416
465
|
if (!historicalBlockHash) {
|
|
417
|
-
const tx = await this.
|
|
466
|
+
const tx = await this.getTxByHash(txHash);
|
|
418
467
|
if (!tx) {
|
|
419
468
|
this.#log.warn(`PendingTxInfo:tx ${txHash} not found`);
|
|
420
469
|
return undefined;
|
|
@@ -447,15 +496,21 @@ export class AztecKVTxPool
|
|
|
447
496
|
return result;
|
|
448
497
|
}
|
|
449
498
|
|
|
450
|
-
public async
|
|
451
|
-
const
|
|
452
|
-
for (const feePayer of
|
|
453
|
-
const
|
|
454
|
-
|
|
455
|
-
result.push(...infos.filter((info): info is PendingTxInfo => info !== undefined));
|
|
499
|
+
public async getPendingFeePayers(): Promise<AztecAddress[]> {
|
|
500
|
+
const feePayers: AztecAddress[] = [];
|
|
501
|
+
for await (const feePayer of this.#feePayerToBalanceEntry.keysAsync()) {
|
|
502
|
+
const address = AztecAddress.fromString(feePayer);
|
|
503
|
+
insertIntoSortedArray(feePayers, address, (a, b) => a.toField().cmp(b.toField()), false);
|
|
456
504
|
}
|
|
505
|
+
return feePayers;
|
|
506
|
+
}
|
|
457
507
|
|
|
458
|
-
|
|
508
|
+
public async *getFeePayerTxInfos(feePayer: AztecAddress): AsyncIterable<FeePayerTxInfo> {
|
|
509
|
+
for await (const value of this.#feePayerToBalanceEntry.getValuesAsync(feePayer.toString())) {
|
|
510
|
+
const info = FeePayerTxInfo.decode(value);
|
|
511
|
+
info.isEvictable = !this.#nonEvictableTxs.has(info.txHash.toString());
|
|
512
|
+
yield info;
|
|
513
|
+
}
|
|
459
514
|
}
|
|
460
515
|
|
|
461
516
|
public async getMinedTxHashes(): Promise<[TxHash, BlockNumber][]> {
|
|
@@ -565,24 +620,6 @@ export class AztecKVTxPool
|
|
|
565
620
|
return new ArchiveCache(db);
|
|
566
621
|
}
|
|
567
622
|
|
|
568
|
-
/**
|
|
569
|
-
* Checks if a cached transaction exists in the in-memory pending tx pool and returns it.
|
|
570
|
-
* Otherwise, it checks the tx pool, updates the pending tx pool, and returns the tx.
|
|
571
|
-
* @param txHash - The generated tx hash.
|
|
572
|
-
* @returns The transaction, if found, 'undefined' otherwise.
|
|
573
|
-
*/
|
|
574
|
-
private async getPendingTxByHash(txHash: TxHash | string): Promise<Tx | undefined> {
|
|
575
|
-
if (typeof txHash === 'string') {
|
|
576
|
-
txHash = TxHash.fromString(txHash);
|
|
577
|
-
}
|
|
578
|
-
|
|
579
|
-
const tx = await this.getTxByHash(txHash);
|
|
580
|
-
if (tx) {
|
|
581
|
-
return tx;
|
|
582
|
-
}
|
|
583
|
-
return undefined;
|
|
584
|
-
}
|
|
585
|
-
|
|
586
623
|
/**
|
|
587
624
|
* Archives a list of txs for future reference. The number of archived txs is limited by the specified archivedTxLimit.
|
|
588
625
|
* Note: Pending txs should not be archived, only finalized txs
|
|
@@ -640,13 +677,13 @@ export class AztecKVTxPool
|
|
|
640
677
|
private async addPendingTxIndicesInDbTx(tx: Tx, txHash: string): Promise<void> {
|
|
641
678
|
await this.#pendingTxPriorityToHash.set(getPendingTxPriority(tx), txHash);
|
|
642
679
|
await this.#historicalHeaderToTxHash.set((await tx.data.constants.anchorBlockHeader.hash()).toString(), txHash);
|
|
643
|
-
await this.#
|
|
644
|
-
}
|
|
680
|
+
await this.#feePayerToBalanceEntry.set(tx.data.feePayer.toString(), await FeePayerTxInfo.encode(tx, txHash));
|
|
645
681
|
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
682
|
+
// Add nullifier entries for conflict detection
|
|
683
|
+
const nullifiers = tx.data.getNonEmptyNullifiers();
|
|
684
|
+
for (const nullifier of nullifiers) {
|
|
685
|
+
await this.#pendingNullifierToTxHash.set(nullifier.toString(), txHash);
|
|
686
|
+
}
|
|
650
687
|
}
|
|
651
688
|
|
|
652
689
|
// Assumes being called within a DB transaction
|
|
@@ -656,13 +693,16 @@ export class AztecKVTxPool
|
|
|
656
693
|
(await tx.data.constants.anchorBlockHeader.hash()).toString(),
|
|
657
694
|
txHash,
|
|
658
695
|
);
|
|
659
|
-
await this.#
|
|
660
|
-
|
|
696
|
+
await this.#feePayerToBalanceEntry.deleteValue(
|
|
697
|
+
tx.data.feePayer.toString(),
|
|
698
|
+
await FeePayerTxInfo.encode(tx, txHash),
|
|
699
|
+
);
|
|
661
700
|
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
701
|
+
// Remove nullifier entries
|
|
702
|
+
const nullifiers = tx.data.getNonEmptyNullifiers();
|
|
703
|
+
for (const nullifier of nullifiers) {
|
|
704
|
+
await this.#pendingNullifierToTxHash.delete(nullifier.toString());
|
|
705
|
+
}
|
|
666
706
|
}
|
|
667
707
|
|
|
668
708
|
/**
|
|
@@ -688,4 +728,19 @@ export class AztecKVTxPool
|
|
|
688
728
|
|
|
689
729
|
return txsToEvict;
|
|
690
730
|
}
|
|
731
|
+
|
|
732
|
+
/**
|
|
733
|
+
* Creates a PreAddPoolAccess object for use by pre-add eviction rules.
|
|
734
|
+
* Provides read-only access to pool state during addTxs transaction.
|
|
735
|
+
*/
|
|
736
|
+
private getPreAddPoolAccess(): PreAddPoolAccess {
|
|
737
|
+
return {
|
|
738
|
+
getTxHashByNullifier: async nullifier => {
|
|
739
|
+
const hashStr = await this.#pendingNullifierToTxHash.getAsync(nullifier.toString());
|
|
740
|
+
return hashStr ? TxHash.fromString(hashStr) : undefined;
|
|
741
|
+
},
|
|
742
|
+
getPendingTxByHash: this.getTxByHash.bind(this),
|
|
743
|
+
getTxPriority: getPendingTxPriority,
|
|
744
|
+
};
|
|
745
|
+
}
|
|
691
746
|
}
|