@aztec/p2p 0.0.1-commit.03f7ef2 → 0.0.1-commit.08c5969dc
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dest/bootstrap/bootstrap.d.ts +4 -3
- package/dest/bootstrap/bootstrap.d.ts.map +1 -1
- package/dest/bootstrap/bootstrap.js +4 -4
- package/dest/client/factory.d.ts +5 -5
- package/dest/client/factory.d.ts.map +1 -1
- package/dest/client/factory.js +50 -13
- package/dest/client/interface.d.ts +53 -18
- package/dest/client/interface.d.ts.map +1 -1
- package/dest/client/p2p_client.d.ts +44 -46
- package/dest/client/p2p_client.d.ts.map +1 -1
- package/dest/client/p2p_client.js +570 -252
- 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 +36 -9
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +29 -13
- 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 +3 -3
- package/dest/mem_pools/instrumentation.d.ts.map +1 -1
- package/dest/mem_pools/instrumentation.js +11 -18
- 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 +35 -26
- 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 +312 -336
- 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 +8 -4
- package/dest/mem_pools/tx_pool/tx_pool.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool/tx_pool_test_suite.js +7 -7
- 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 +102 -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 +242 -0
- package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.d.ts +47 -0
- package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.js +119 -0
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.d.ts +17 -0
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.js +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 +89 -0
- package/dest/mem_pools/tx_pool_v2/eviction/index.d.ts +10 -0
- package/dest/mem_pools/tx_pool_v2/eviction/index.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/eviction/index.js +11 -0
- package/dest/mem_pools/tx_pool_v2/eviction/interfaces.d.ts +131 -0
- package/dest/mem_pools/tx_pool_v2/eviction/interfaces.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/eviction/interfaces.js +17 -0
- package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.d.ts +15 -0
- package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.js +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 +72 -0
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.d.ts +20 -0
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.js +63 -0
- package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.d.ts +15 -0
- package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.js +19 -0
- package/dest/mem_pools/tx_pool_v2/index.d.ts +6 -0
- package/dest/mem_pools/tx_pool_v2/index.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/index.js +5 -0
- package/dest/mem_pools/tx_pool_v2/interfaces.d.ts +201 -0
- package/dest/mem_pools/tx_pool_v2/interfaces.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/interfaces.js +7 -0
- package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts +95 -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 +128 -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 +105 -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 +345 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts +57 -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 +160 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts +71 -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 +780 -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 +4 -4
- package/dest/msg_validators/tx_validator/tx_permitted_validator.d.ts +3 -2
- package/dest/msg_validators/tx_validator/tx_permitted_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/tx_permitted_validator.js +2 -2
- package/dest/msg_validators/tx_validator/tx_proof_validator.d.ts +3 -2
- package/dest/msg_validators/tx_validator/tx_proof_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/tx_proof_validator.js +2 -2
- package/dest/services/data_store.d.ts +1 -1
- package/dest/services/data_store.d.ts.map +1 -1
- package/dest/services/data_store.js +10 -6
- package/dest/services/discv5/discV5_service.js +1 -1
- package/dest/services/dummy_service.d.ts +26 -2
- package/dest/services/dummy_service.d.ts.map +1 -1
- package/dest/services/dummy_service.js +48 -0
- package/dest/services/encoding.d.ts +2 -2
- package/dest/services/encoding.d.ts.map +1 -1
- package/dest/services/encoding.js +8 -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 +161 -0
- package/dest/services/gossipsub/topic_score_params.d.ts.map +1 -0
- package/dest/services/gossipsub/topic_score_params.js +324 -0
- package/dest/services/index.d.ts +2 -1
- package/dest/services/index.d.ts.map +1 -1
- package/dest/services/index.js +1 -0
- package/dest/services/libp2p/instrumentation.d.ts +1 -1
- package/dest/services/libp2p/instrumentation.d.ts.map +1 -1
- package/dest/services/libp2p/instrumentation.js +30 -72
- package/dest/services/libp2p/libp2p_service.d.ts +105 -33
- package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
- package/dest/services/libp2p/libp2p_service.js +978 -315
- 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 +2 -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 +47 -0
- package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts.map +1 -0
- package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.js +566 -0
- package/dest/services/reqresp/batch-tx-requester/config.d.ts +17 -0
- package/dest/services/reqresp/batch-tx-requester/config.d.ts.map +1 -0
- package/dest/services/reqresp/batch-tx-requester/config.js +27 -0
- package/dest/services/reqresp/batch-tx-requester/interface.d.ts +50 -0
- package/dest/services/reqresp/batch-tx-requester/interface.d.ts.map +1 -0
- package/dest/services/reqresp/batch-tx-requester/interface.js +1 -0
- package/dest/services/reqresp/batch-tx-requester/missing_txs.d.ts +37 -0
- package/dest/services/reqresp/batch-tx-requester/missing_txs.d.ts.map +1 -0
- package/dest/services/reqresp/batch-tx-requester/missing_txs.js +151 -0
- package/dest/services/reqresp/batch-tx-requester/peer_collection.d.ts +54 -0
- package/dest/services/reqresp/batch-tx-requester/peer_collection.d.ts.map +1 -0
- package/dest/services/reqresp/batch-tx-requester/peer_collection.js +139 -0
- package/dest/services/reqresp/batch-tx-requester/tx_validator.d.ts +20 -0
- package/dest/services/reqresp/batch-tx-requester/tx_validator.d.ts.map +1 -0
- package/dest/services/reqresp/batch-tx-requester/tx_validator.js +21 -0
- package/dest/services/reqresp/connection-sampler/batch_connection_sampler.d.ts +22 -3
- package/dest/services/reqresp/connection-sampler/batch_connection_sampler.d.ts.map +1 -1
- package/dest/services/reqresp/connection-sampler/batch_connection_sampler.js +63 -4
- package/dest/services/reqresp/connection-sampler/connection_sampler.d.ts +2 -1
- package/dest/services/reqresp/connection-sampler/connection_sampler.d.ts.map +1 -1
- package/dest/services/reqresp/connection-sampler/connection_sampler.js +12 -0
- package/dest/services/reqresp/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 +53 -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 +34 -13
- 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 +165 -0
- package/dest/services/tx_collection/file_store_tx_source.d.ts +28 -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 +59 -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 +10 -13
- package/dest/services/tx_collection/proposal_tx_collector.d.ts +48 -0
- package/dest/services/tx_collection/proposal_tx_collector.d.ts.map +1 -0
- package/dest/services/tx_collection/proposal_tx_collector.js +49 -0
- package/dest/services/tx_collection/slow_tx_collection.d.ts +8 -4
- package/dest/services/tx_collection/slow_tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/slow_tx_collection.js +55 -23
- package/dest/services/tx_collection/tx_collection.d.ts +25 -13
- 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 +15 -6
- package/dest/services/tx_collection/tx_collection_sink.d.ts.map +1 -1
- package/dest/services/tx_collection/tx_collection_sink.js +13 -7
- package/dest/services/tx_file_store/config.d.ts +16 -0
- package/dest/services/tx_file_store/config.d.ts.map +1 -0
- package/dest/services/tx_file_store/config.js +22 -0
- package/dest/services/tx_file_store/index.d.ts +4 -0
- package/dest/services/tx_file_store/index.d.ts.map +1 -0
- package/dest/services/tx_file_store/index.js +3 -0
- package/dest/services/tx_file_store/instrumentation.d.ts +15 -0
- package/dest/services/tx_file_store/instrumentation.d.ts.map +1 -0
- package/dest/services/tx_file_store/instrumentation.js +29 -0
- package/dest/services/tx_file_store/tx_file_store.d.ts +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 +8 -5
- 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 +27 -1
- package/dest/test-helpers/mock-pubsub.d.ts.map +1 -1
- package/dest/test-helpers/mock-pubsub.js +97 -2
- package/dest/test-helpers/reqresp-nodes.d.ts +1 -1
- package/dest/test-helpers/reqresp-nodes.d.ts.map +1 -1
- package/dest/test-helpers/reqresp-nodes.js +2 -1
- package/dest/test-helpers/test_tx_provider.d.ts +40 -0
- package/dest/test-helpers/test_tx_provider.d.ts.map +1 -0
- package/dest/test-helpers/test_tx_provider.js +41 -0
- package/dest/test-helpers/testbench-utils.d.ts +160 -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 +219 -124
- 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/package.json +16 -16
- package/src/bootstrap/bootstrap.ts +7 -4
- package/src/client/factory.ts +91 -23
- package/src/client/interface.ts +63 -17
- package/src/client/p2p_client.ts +236 -284
- package/src/client/test/tx_proposal_collector/README.md +227 -0
- package/src/client/test/tx_proposal_collector/proposal_tx_collector_worker.ts +336 -0
- package/src/client/test/tx_proposal_collector/proposal_tx_collector_worker_protocol.ts +43 -0
- package/src/config.ts +56 -18
- 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 +19 -13
- package/src/mem_pools/index.ts +4 -1
- package/src/mem_pools/instrumentation.ts +19 -25
- package/src/mem_pools/interface.ts +4 -4
- package/src/mem_pools/tx_pool/README.md +270 -0
- package/src/mem_pools/tx_pool/aztec_kv_tx_pool.ts +360 -368
- 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 +8 -3
- package/src/mem_pools/tx_pool/tx_pool_test_suite.ts +7 -7
- 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 +310 -0
- package/src/mem_pools/tx_pool_v2/eviction/eviction_manager.ts +147 -0
- package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.ts +121 -0
- package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.ts +111 -0
- package/src/mem_pools/tx_pool_v2/eviction/index.ts +23 -0
- package/src/mem_pools/tx_pool_v2/eviction/interfaces.ts +164 -0
- package/src/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.ts +74 -0
- package/src/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.ts +101 -0
- package/src/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.ts +88 -0
- package/src/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.ts +72 -0
- package/src/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.ts +31 -0
- package/src/mem_pools/tx_pool_v2/index.ts +12 -0
- package/src/mem_pools/tx_pool_v2/interfaces.ts +233 -0
- package/src/mem_pools/tx_pool_v2/tx_metadata.ts +211 -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 +433 -0
- package/src/mem_pools/tx_pool_v2/tx_pool_v2.ts +218 -0
- package/src/mem_pools/tx_pool_v2/tx_pool_v2_impl.ts +924 -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 +25 -15
- 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 +63 -0
- package/src/services/encoding.ts +7 -6
- package/src/services/gossipsub/README.md +626 -0
- package/src/services/gossipsub/index.ts +2 -0
- package/src/services/gossipsub/scoring.ts +29 -5
- package/src/services/gossipsub/topic_score_params.ts +451 -0
- package/src/services/index.ts +1 -0
- package/src/services/libp2p/instrumentation.ts +32 -73
- package/src/services/libp2p/libp2p_service.ts +644 -299
- package/src/services/peer-manager/metrics.ts +39 -21
- package/src/services/peer-manager/peer_manager.ts +3 -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 +57 -0
- package/src/services/reqresp/batch-tx-requester/missing_txs.ts +209 -0
- package/src/services/reqresp/batch-tx-requester/peer_collection.ts +205 -0
- package/src/services/reqresp/batch-tx-requester/tx_validator.ts +37 -0
- package/src/services/reqresp/connection-sampler/batch_connection_sampler.ts +65 -4
- package/src/services/reqresp/connection-sampler/connection_sampler.ts +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 +63 -4
- package/src/services/tx_collection/config.ts +83 -1
- package/src/services/tx_collection/fast_tx_collection.ts +44 -19
- package/src/services/tx_collection/file_store_tx_collection.ts +198 -0
- package/src/services/tx_collection/file_store_tx_source.ts +73 -0
- package/src/services/tx_collection/index.ts +6 -0
- package/src/services/tx_collection/instrumentation.ts +5 -13
- package/src/services/tx_collection/proposal_tx_collector.ts +112 -0
- package/src/services/tx_collection/slow_tx_collection.ts +66 -32
- package/src/services/tx_collection/tx_collection.ts +117 -21
- package/src/services/tx_collection/tx_collection_sink.ts +17 -7
- package/src/services/tx_file_store/config.ts +37 -0
- package/src/services/tx_file_store/index.ts +3 -0
- package/src/services/tx_file_store/instrumentation.ts +36 -0
- package/src/services/tx_file_store/tx_file_store.ts +175 -0
- package/src/services/tx_provider.ts +14 -10
- 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 +133 -3
- package/src/test-helpers/reqresp-nodes.ts +2 -1
- package/src/test-helpers/test_tx_provider.ts +64 -0
- package/src/test-helpers/testbench-utils.ts +430 -0
- package/src/testbench/p2p_client_testbench_worker.ts +338 -119
- package/src/testbench/worker_client_manager.ts +304 -42
- 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 -81
- 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 -242
- 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 -288
- 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,15 +1,14 @@
|
|
|
1
|
+
import { insertIntoSortedArray } from '@aztec/foundation/array';
|
|
1
2
|
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
2
3
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
4
|
import { toArray } from '@aztec/foundation/iterable';
|
|
4
5
|
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
5
6
|
import type { TypedEventEmitter } from '@aztec/foundation/types';
|
|
6
|
-
import type { AztecAsyncKVStore, AztecAsyncMap, AztecAsyncMultiMap
|
|
7
|
-
import {
|
|
8
|
-
import { GasFees } from '@aztec/stdlib/gas';
|
|
7
|
+
import type { AztecAsyncKVStore, AztecAsyncMap, AztecAsyncMultiMap } from '@aztec/kv-store';
|
|
8
|
+
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
9
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
|
-
import { DatabasePublicStateSource } from '@aztec/stdlib/trees';
|
|
13
12
|
import { BlockHeader, Tx, TxHash } from '@aztec/stdlib/tx';
|
|
14
13
|
import { type TelemetryClient, getTelemetryClient } from '@aztec/telemetry-client';
|
|
15
14
|
|
|
@@ -17,25 +16,37 @@ import assert from 'assert';
|
|
|
17
16
|
import EventEmitter from 'node:events';
|
|
18
17
|
|
|
19
18
|
import { ArchiveCache } from '../../msg_validators/tx_validator/archive_cache.js';
|
|
20
|
-
import { GasTxValidator } from '../../msg_validators/tx_validator/gas_validator.js';
|
|
21
19
|
import { PoolInstrumentation, PoolName, type PoolStatsCallback } from '../instrumentation.js';
|
|
20
|
+
import { EvictionManager } from './eviction/eviction_manager.js';
|
|
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';
|
|
29
|
+
import { InvalidTxsAfterMiningRule } from './eviction/invalid_txs_after_mining_rule.js';
|
|
30
|
+
import { InvalidTxsAfterReorgRule } from './eviction/invalid_txs_after_reorg_rule.js';
|
|
31
|
+
import { LowPriorityEvictionRule } from './eviction/low_priority_eviction_rule.js';
|
|
32
|
+
import { NullifierConflictPreAddRule } from './eviction/nullifier_conflict_pre_add_rule.js';
|
|
22
33
|
import { getPendingTxPriority } from './priority.js';
|
|
23
34
|
import type { TxPool, TxPoolEvents, TxPoolOptions } from './tx_pool.js';
|
|
24
35
|
|
|
25
36
|
/**
|
|
26
37
|
* KV implementation of the Transaction Pool.
|
|
27
38
|
*/
|
|
28
|
-
export class AztecKVTxPool
|
|
39
|
+
export class AztecKVTxPool
|
|
40
|
+
extends (EventEmitter as new () => TypedEventEmitter<TxPoolEvents>)
|
|
41
|
+
implements TxPool, TxPoolOperations
|
|
42
|
+
{
|
|
29
43
|
#store: AztecAsyncKVStore;
|
|
30
44
|
|
|
31
45
|
/** Our tx pool, stored as a Map, with K: tx hash and V: the transaction. */
|
|
32
46
|
#txs: AztecAsyncMap<string, Buffer>;
|
|
33
47
|
|
|
34
|
-
/**
|
|
35
|
-
#
|
|
36
|
-
|
|
37
|
-
/** The tx evicion logic will kick after pool size is greater than maxTxPoolSize * txPoolOverflowFactor */
|
|
38
|
-
txPoolOverflowFactor: number = 1;
|
|
48
|
+
/** Holds the historical block for each tx */
|
|
49
|
+
#pendingTxHashToHistoricalBlockHeaderHash: AztecAsyncMap<string, string>;
|
|
39
50
|
|
|
40
51
|
/** Index from tx hash to the block number in which they were mined, filtered by mined txs. */
|
|
41
52
|
#minedTxHashToBlock: AztecAsyncMap<string, BlockNumber>;
|
|
@@ -43,23 +54,18 @@ export class AztecKVTxPool extends (EventEmitter as new () => TypedEventEmitter<
|
|
|
43
54
|
/** Index from tx priority (stored as hex) to its tx hash, filtered by pending txs. */
|
|
44
55
|
#pendingTxPriorityToHash: AztecAsyncMultiMap<string, string>;
|
|
45
56
|
|
|
46
|
-
/** Index from tx hash to its tx size (in bytes), filtered by pending txs. */
|
|
47
|
-
#pendingTxHashToSize: AztecAsyncMap<string, number>;
|
|
48
|
-
|
|
49
|
-
/** Index from tx hash to its header hash, filtered by pending txs. */
|
|
50
|
-
#pendingTxHashToHeaderHash: AztecAsyncMap<string, string>;
|
|
51
|
-
|
|
52
57
|
/** Map from tx hash to the block number it was originally mined in (for soft-deleted txs). */
|
|
53
58
|
#deletedMinedTxHashes: AztecAsyncMap<string, BlockNumber>;
|
|
54
59
|
|
|
55
60
|
/** MultiMap from block number to deleted mined tx hashes for efficient cleanup. */
|
|
56
61
|
#blockToDeletedMinedTxHash: AztecAsyncMultiMap<BlockNumber, string>;
|
|
57
62
|
|
|
58
|
-
|
|
59
|
-
|
|
63
|
+
#historicalHeaderToTxHash: AztecAsyncMultiMap<string, string>;
|
|
64
|
+
|
|
65
|
+
#feePayerToBalanceEntry: AztecAsyncMultiMap<string, Buffer>;
|
|
60
66
|
|
|
61
|
-
/**
|
|
62
|
-
#
|
|
67
|
+
/** Index from nullifier to pending tx hash */
|
|
68
|
+
#pendingNullifierToTxHash: AztecAsyncMap<string, string>;
|
|
63
69
|
|
|
64
70
|
/** In-memory set of txs that should not be evicted from the pool. */
|
|
65
71
|
#nonEvictableTxs: Set<string>;
|
|
@@ -76,8 +82,7 @@ export class AztecKVTxPool extends (EventEmitter as new () => TypedEventEmitter<
|
|
|
76
82
|
/** Number of txs to archive. */
|
|
77
83
|
#archivedTxLimit: number = 0;
|
|
78
84
|
|
|
79
|
-
|
|
80
|
-
#worldStateSynchronizer: WorldStateSynchronizer;
|
|
85
|
+
#evictionManager: EvictionManager;
|
|
81
86
|
|
|
82
87
|
#log: Logger;
|
|
83
88
|
|
|
@@ -94,7 +99,7 @@ export class AztecKVTxPool extends (EventEmitter as new () => TypedEventEmitter<
|
|
|
94
99
|
constructor(
|
|
95
100
|
store: AztecAsyncKVStore,
|
|
96
101
|
archive: AztecAsyncKVStore,
|
|
97
|
-
|
|
102
|
+
worldState: WorldStateSynchronizer,
|
|
98
103
|
telemetry: TelemetryClient = getTelemetryClient(),
|
|
99
104
|
config: TxPoolOptions = {},
|
|
100
105
|
log = createLogger('p2p:tx_pool'),
|
|
@@ -102,18 +107,32 @@ export class AztecKVTxPool extends (EventEmitter as new () => TypedEventEmitter<
|
|
|
102
107
|
super();
|
|
103
108
|
|
|
104
109
|
this.#log = log;
|
|
110
|
+
|
|
111
|
+
this.#evictionManager = new EvictionManager(this);
|
|
112
|
+
this.#evictionManager.registerRule(new InvalidTxsAfterMiningRule());
|
|
113
|
+
this.#evictionManager.registerRule(new InvalidTxsAfterReorgRule(worldState));
|
|
114
|
+
this.#evictionManager.registerRule(new FeePayerBalanceEvictionRule(worldState));
|
|
115
|
+
this.#evictionManager.registerRule(
|
|
116
|
+
new LowPriorityEvictionRule({
|
|
117
|
+
//NOTE: 0 effectively disables low priority eviction
|
|
118
|
+
maxPoolSize: config.maxPendingTxCount ?? 0,
|
|
119
|
+
}),
|
|
120
|
+
);
|
|
121
|
+
this.#evictionManager.registerPreAddRule(new NullifierConflictPreAddRule());
|
|
122
|
+
|
|
105
123
|
this.updateConfig(config);
|
|
106
124
|
|
|
107
125
|
this.#txs = store.openMap('txs');
|
|
108
126
|
this.#minedTxHashToBlock = store.openMap('txHashToBlockMined');
|
|
109
127
|
this.#pendingTxPriorityToHash = store.openMultiMap('pendingTxFeeToHash');
|
|
110
|
-
this.#pendingTxHashToSize = store.openMap('pendingTxHashToSize');
|
|
111
|
-
this.#pendingTxHashToHeaderHash = store.openMap('pendingTxHashToHeaderHash');
|
|
112
|
-
this.#pendingTxSize = store.openSingleton('pendingTxSize');
|
|
113
128
|
this.#deletedMinedTxHashes = store.openMap('deletedMinedTxHashes');
|
|
114
129
|
this.#blockToDeletedMinedTxHash = store.openMultiMap('blockToDeletedMinedTxHash');
|
|
115
130
|
|
|
116
|
-
this.#
|
|
131
|
+
this.#pendingTxHashToHistoricalBlockHeaderHash = store.openMap('txHistoricalBlock');
|
|
132
|
+
this.#historicalHeaderToTxHash = store.openMultiMap('historicalHeaderToPendingTxHash');
|
|
133
|
+
this.#feePayerToBalanceEntry = store.openMultiMap('feePayerToBalanceEntry');
|
|
134
|
+
this.#pendingNullifierToTxHash = store.openMap('pendingNullifierToTxHash');
|
|
135
|
+
|
|
117
136
|
this.#nonEvictableTxs = new Set<string>();
|
|
118
137
|
|
|
119
138
|
this.#archivedTxs = archive.openMap('archivedTxs');
|
|
@@ -121,7 +140,7 @@ export class AztecKVTxPool extends (EventEmitter as new () => TypedEventEmitter<
|
|
|
121
140
|
|
|
122
141
|
this.#store = store;
|
|
123
142
|
this.#archive = archive;
|
|
124
|
-
|
|
143
|
+
|
|
125
144
|
this.#metrics = new PoolInstrumentation(telemetry, PoolName.TX_POOL, this.countTxs, () => store.estimateSize());
|
|
126
145
|
}
|
|
127
146
|
|
|
@@ -142,6 +161,7 @@ export class AztecKVTxPool extends (EventEmitter as new () => TypedEventEmitter<
|
|
|
142
161
|
}
|
|
143
162
|
return true;
|
|
144
163
|
}
|
|
164
|
+
|
|
145
165
|
/**
|
|
146
166
|
* Marks transactions as mined in a block and updates the pool state accordingly.
|
|
147
167
|
* Removes the transactions from the pending set and adds them to the mined set.
|
|
@@ -154,69 +174,80 @@ export class AztecKVTxPool extends (EventEmitter as new () => TypedEventEmitter<
|
|
|
154
174
|
return Promise.resolve();
|
|
155
175
|
}
|
|
156
176
|
|
|
157
|
-
const
|
|
158
|
-
const
|
|
177
|
+
const uniqueMinedNullifiers: Fr[] = [];
|
|
178
|
+
const uniqueMinedFeePayers: AztecAddress[] = [];
|
|
159
179
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
180
|
+
try {
|
|
181
|
+
await this.#store.transactionAsync(async () => {
|
|
182
|
+
for (const hash of txHashes) {
|
|
183
|
+
const key = hash.toString();
|
|
184
|
+
await this.#minedTxHashToBlock.set(key, blockHeader.globalVariables.blockNumber);
|
|
185
|
+
|
|
186
|
+
const tx = await this.getTxByHash(hash);
|
|
187
|
+
if (tx) {
|
|
188
|
+
const nullifiers = tx.data.getNonEmptyNullifiers();
|
|
189
|
+
|
|
190
|
+
nullifiers.forEach(nullifier => insertIntoSortedArray(uniqueMinedNullifiers, nullifier, Fr.cmp, false));
|
|
191
|
+
insertIntoSortedArray(
|
|
192
|
+
uniqueMinedFeePayers,
|
|
193
|
+
tx.data.feePayer,
|
|
194
|
+
(a, b) => a.toField().cmp(b.toField()),
|
|
195
|
+
false,
|
|
196
|
+
);
|
|
197
|
+
|
|
198
|
+
await this.removePendingTxIndicesInDbTx(tx, key);
|
|
199
|
+
}
|
|
164
200
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
201
|
+
// If this tx was previously soft-deleted, remove it from the deleted sets
|
|
202
|
+
if (await this.#deletedMinedTxHashes.hasAsync(key)) {
|
|
203
|
+
const originalBlock = await this.#deletedMinedTxHashes.getAsync(key);
|
|
204
|
+
await this.#deletedMinedTxHashes.delete(key);
|
|
205
|
+
// Remove from block-to-hash mapping
|
|
206
|
+
if (originalBlock !== undefined) {
|
|
207
|
+
await this.#blockToDeletedMinedTxHash.deleteValue(originalBlock, key);
|
|
208
|
+
}
|
|
172
209
|
}
|
|
173
210
|
}
|
|
211
|
+
});
|
|
174
212
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
const tx = await this.getPendingTxByHash(hash);
|
|
178
|
-
if (tx) {
|
|
179
|
-
const nullifiers = tx.data.getNonEmptyNullifiers();
|
|
180
|
-
nullifiers.forEach(nullifier => minedNullifiers.add(nullifier.toString()));
|
|
181
|
-
minedFeePayers.add(tx.data.feePayer.toString());
|
|
182
|
-
pendingTxSize -= tx.getSize();
|
|
183
|
-
await this.removePendingTxIndices(tx, key);
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
await this.#pendingTxSize.set(pendingTxSize);
|
|
213
|
+
await this.#evictionManager.evictAfterNewBlock(blockHeader, uniqueMinedNullifiers, uniqueMinedFeePayers);
|
|
187
214
|
|
|
188
|
-
|
|
189
|
-
})
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
// until any that have been mined are marked as such.
|
|
193
|
-
// The non-evictable set is not considered when evicting transactions that are invalid after a block is mined.
|
|
194
|
-
this.#nonEvictableTxs.clear();
|
|
215
|
+
this.#metrics.transactionsRemoved(txHashes.map(hash => hash.toBigInt()));
|
|
216
|
+
} catch (err) {
|
|
217
|
+
this.#log.warn('Unexpected error when marking txs as mined', { err });
|
|
218
|
+
}
|
|
195
219
|
}
|
|
196
220
|
|
|
197
|
-
public async markMinedAsPending(txHashes: TxHash[]): Promise<void> {
|
|
221
|
+
public async markMinedAsPending(txHashes: TxHash[], latestBlock: BlockNumber): Promise<void> {
|
|
198
222
|
if (txHashes.length === 0) {
|
|
199
223
|
return Promise.resolve();
|
|
200
224
|
}
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
225
|
+
try {
|
|
226
|
+
await this.#store.transactionAsync(async () => {
|
|
227
|
+
for (const hash of txHashes) {
|
|
228
|
+
const key = hash.toString();
|
|
229
|
+
await this.#minedTxHashToBlock.delete(key);
|
|
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
|
+
}
|
|
206
238
|
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
239
|
+
// Rehydrate the tx in the in-memory pending txs mapping
|
|
240
|
+
const tx = await this.getTxByHash(hash);
|
|
241
|
+
if (tx) {
|
|
242
|
+
await this.addPendingTxIndicesInDbTx(tx, key);
|
|
243
|
+
}
|
|
212
244
|
}
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
await this.#pendingTxSize.set(pendingTxSize);
|
|
216
|
-
});
|
|
245
|
+
});
|
|
217
246
|
|
|
218
|
-
|
|
219
|
-
|
|
247
|
+
await this.#evictionManager.evictAfterChainPrune(latestBlock);
|
|
248
|
+
} catch (err) {
|
|
249
|
+
this.#log.warn('Unexpected error when marking mined txs as pending', { err });
|
|
250
|
+
}
|
|
220
251
|
}
|
|
221
252
|
|
|
222
253
|
public async getPendingTxHashes(): Promise<TxHash[]> {
|
|
@@ -224,38 +255,6 @@ export class AztecKVTxPool extends (EventEmitter as new () => TypedEventEmitter<
|
|
|
224
255
|
return vals.map(TxHash.fromString);
|
|
225
256
|
}
|
|
226
257
|
|
|
227
|
-
public async getMinedTxHashes(): Promise<[TxHash, BlockNumber][]> {
|
|
228
|
-
const vals = await toArray(this.#minedTxHashToBlock.entriesAsync());
|
|
229
|
-
return vals.map(([txHash, blockNumber]) => [TxHash.fromString(txHash), blockNumber]);
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
public async getPendingTxCount(): Promise<number> {
|
|
233
|
-
return (await this.#pendingTxHashToHeaderHash.sizeAsync()) ?? 0;
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
public async getMinedTxCount(): Promise<number> {
|
|
237
|
-
return (await this.#minedTxHashToBlock.sizeAsync()) ?? 0;
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
public async getTxStatus(txHash: TxHash): Promise<'pending' | 'mined' | 'deleted' | undefined> {
|
|
241
|
-
const key = txHash.toString();
|
|
242
|
-
const [isMined, isKnown, isDeleted] = await Promise.all([
|
|
243
|
-
this.#minedTxHashToBlock.hasAsync(key),
|
|
244
|
-
this.#txs.hasAsync(key),
|
|
245
|
-
this.#deletedMinedTxHashes.hasAsync(key),
|
|
246
|
-
]);
|
|
247
|
-
|
|
248
|
-
if (isDeleted) {
|
|
249
|
-
return 'deleted';
|
|
250
|
-
} else if (isMined) {
|
|
251
|
-
return 'mined';
|
|
252
|
-
} else if (isKnown) {
|
|
253
|
-
return 'pending';
|
|
254
|
-
} else {
|
|
255
|
-
return undefined;
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
|
|
259
258
|
/**
|
|
260
259
|
* Checks if a transaction exists in the pool and returns it.
|
|
261
260
|
* @param txHash - The generated tx hash.
|
|
@@ -292,42 +291,79 @@ export class AztecKVTxPool extends (EventEmitter as new () => TypedEventEmitter<
|
|
|
292
291
|
|
|
293
292
|
/**
|
|
294
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.
|
|
295
296
|
* @param txs - An array of txs to be added to the pool.
|
|
296
|
-
* @returns
|
|
297
|
+
* @returns count of added transactions
|
|
297
298
|
*/
|
|
298
299
|
public async addTxs(txs: Tx[], opts: { source?: string } = {}): Promise<number> {
|
|
300
|
+
if (txs.length === 0) {
|
|
301
|
+
return Promise.resolve(0);
|
|
302
|
+
}
|
|
303
|
+
|
|
299
304
|
const addedTxs: Tx[] = [];
|
|
305
|
+
const uniqueFeePayers: AztecAddress[] = [];
|
|
306
|
+
const replacedTxHashes: TxHash[] = [];
|
|
300
307
|
const hashesAndStats = txs.map(tx => ({ txHash: tx.getTxHash(), txStats: tx.getStats() }));
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
308
|
+
try {
|
|
309
|
+
await this.#store.transactionAsync(async () => {
|
|
310
|
+
for (let i = 0; i < txs.length; i++) {
|
|
311
|
+
const tx = txs[i];
|
|
305
312
|
const { txHash, txStats } = hashesAndStats[i];
|
|
306
313
|
const key = txHash.toString();
|
|
307
314
|
if (await this.#txs.hasAsync(key)) {
|
|
308
|
-
this.#log.debug(`Tx ${
|
|
309
|
-
|
|
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;
|
|
310
323
|
}
|
|
311
324
|
|
|
312
|
-
|
|
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}`);
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
this.#log.verbose(`Adding tx ${key} to pool`, {
|
|
313
336
|
eventName: 'tx-added-to-pool',
|
|
314
337
|
...txStats,
|
|
315
338
|
} satisfies TxAddedToPoolStats);
|
|
316
339
|
|
|
317
340
|
await this.#txs.set(key, tx.toBuffer());
|
|
318
|
-
addedTxs.push(tx
|
|
341
|
+
addedTxs.push(tx);
|
|
342
|
+
insertIntoSortedArray(uniqueFeePayers, tx.data.feePayer, (a, b) => a.toField().cmp(b.toField()), false);
|
|
343
|
+
|
|
344
|
+
await this.#pendingTxHashToHistoricalBlockHeaderHash.set(
|
|
345
|
+
key,
|
|
346
|
+
(await tx.data.constants.anchorBlockHeader.hash()).toString(),
|
|
347
|
+
);
|
|
319
348
|
|
|
320
349
|
if (!(await this.#minedTxHashToBlock.hasAsync(key))) {
|
|
321
|
-
|
|
322
|
-
await this.addPendingTxIndices(tx, key);
|
|
350
|
+
await this.addPendingTxIndicesInDbTx(tx, key);
|
|
323
351
|
this.#metrics.recordSize(tx);
|
|
324
352
|
}
|
|
325
|
-
}
|
|
353
|
+
}
|
|
354
|
+
});
|
|
355
|
+
|
|
356
|
+
await this.#evictionManager.evictAfterNewTxs(
|
|
357
|
+
addedTxs.map(({ txHash }) => txHash),
|
|
358
|
+
uniqueFeePayers,
|
|
326
359
|
);
|
|
360
|
+
} catch (err) {
|
|
361
|
+
this.#log.warn('Unexpected error when adding txs', { err });
|
|
362
|
+
}
|
|
327
363
|
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
}
|
|
364
|
+
if (replacedTxHashes.length > 0) {
|
|
365
|
+
this.#metrics.transactionsRemoved(replacedTxHashes.map(hash => hash.toBigInt()));
|
|
366
|
+
}
|
|
331
367
|
|
|
332
368
|
if (addedTxs.length > 0) {
|
|
333
369
|
this.#metrics.transactionsAdded(addedTxs);
|
|
@@ -342,55 +378,63 @@ export class AztecKVTxPool extends (EventEmitter as new () => TypedEventEmitter<
|
|
|
342
378
|
* @param txHashes - An array of tx hashes to be deleted from the tx pool.
|
|
343
379
|
* @returns Empty promise.
|
|
344
380
|
*/
|
|
345
|
-
public deleteTxs(txHashes: TxHash[], opts
|
|
381
|
+
public deleteTxs(txHashes: TxHash[], opts?: { permanently?: boolean }): Promise<void> {
|
|
346
382
|
if (txHashes.length === 0) {
|
|
347
383
|
return Promise.resolve();
|
|
348
384
|
}
|
|
385
|
+
|
|
349
386
|
const deletedTxs: Tx[] = [];
|
|
350
387
|
const poolDbTx = this.#store.transactionAsync(async () => {
|
|
351
|
-
let pendingTxSize = (await this.#pendingTxSize.getAsync()) ?? 0;
|
|
352
388
|
for (const hash of txHashes) {
|
|
353
389
|
const key = hash.toString();
|
|
354
390
|
const tx = await this.getTxByHash(hash);
|
|
391
|
+
if (!tx) {
|
|
392
|
+
this.#log.trace(`Skipping deletion of missing tx ${key} from pool`);
|
|
393
|
+
continue;
|
|
394
|
+
}
|
|
355
395
|
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
await this.#txs.delete(key);
|
|
365
|
-
} else {
|
|
366
|
-
// Soft-delete mined transactions: remove from mined set but keep in storage
|
|
367
|
-
this.#log.trace(`Soft-deleting mined tx ${key} from pool`);
|
|
368
|
-
await this.#deletedMinedTxHashes.set(key, minedBlockNumber);
|
|
369
|
-
await this.#blockToDeletedMinedTxHash.set(minedBlockNumber, key);
|
|
370
|
-
}
|
|
371
|
-
} else {
|
|
372
|
-
// Permanently delete pending transactions
|
|
373
|
-
this.#log.trace(`Deleting pending tx ${key} from pool`);
|
|
374
|
-
pendingTxSize -= tx.getSize();
|
|
375
|
-
await this.removePendingTxIndices(tx, key);
|
|
376
|
-
await this.#txs.delete(key);
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
if (!opts.eviction && this.#archivedTxLimit) {
|
|
396
|
+
const minedBlockNumber = await this.#minedTxHashToBlock.getAsync(key);
|
|
397
|
+
const txIsPending = minedBlockNumber === undefined;
|
|
398
|
+
if (txIsPending) {
|
|
399
|
+
await this.deletePendingTxInDbTx(tx, key);
|
|
400
|
+
} else {
|
|
401
|
+
await this.deleteMinedTx(key, minedBlockNumber!, opts?.permanently ?? false);
|
|
402
|
+
const shouldArchiveTx = this.#archivedTxLimit && !opts?.permanently;
|
|
403
|
+
if (shouldArchiveTx) {
|
|
380
404
|
deletedTxs.push(tx);
|
|
381
405
|
}
|
|
382
|
-
} else {
|
|
383
|
-
this.#log.trace(`Skipping deletion of missing tx ${key} from pool`);
|
|
384
406
|
}
|
|
385
407
|
}
|
|
386
|
-
|
|
387
|
-
await this.#pendingTxSize.set(pendingTxSize);
|
|
388
408
|
});
|
|
389
|
-
this.#metrics.transactionsRemoved(txHashes);
|
|
409
|
+
this.#metrics.transactionsRemoved(txHashes.map(hash => hash.toBigInt()));
|
|
390
410
|
this.#log.debug(`Deleted ${txHashes.length} txs from pool`, { txHashes });
|
|
411
|
+
|
|
391
412
|
return this.#archivedTxLimit ? poolDbTx.then(() => this.archiveTxs(deletedTxs)) : poolDbTx;
|
|
392
413
|
}
|
|
393
414
|
|
|
415
|
+
private async deleteMinedTx(txHash: `0x${string}`, minedBlockNumber: BlockNumber, permanently: boolean) {
|
|
416
|
+
await this.#minedTxHashToBlock.delete(txHash);
|
|
417
|
+
if (permanently) {
|
|
418
|
+
this.#log.trace(`Deleting mined tx ${txHash} from pool`);
|
|
419
|
+
await this.#txs.delete(txHash);
|
|
420
|
+
return;
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
// Soft-delete mined transactions: remove from mined set but keep in storage
|
|
424
|
+
this.#log.trace(`Soft-deleting mined tx ${txHash} from pool`);
|
|
425
|
+
await this.#deletedMinedTxHashes.set(txHash, minedBlockNumber);
|
|
426
|
+
await this.#blockToDeletedMinedTxHash.set(minedBlockNumber, txHash);
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
// Assumes being called within a DB transaction
|
|
430
|
+
private async deletePendingTxInDbTx(tx: Tx, txHash: `0x${string}`) {
|
|
431
|
+
// We always permanently delete pending transactions
|
|
432
|
+
this.#log.trace(`Deleting pending tx ${txHash} from pool`);
|
|
433
|
+
await this.removePendingTxIndicesInDbTx(tx, txHash);
|
|
434
|
+
await this.#txs.delete(txHash);
|
|
435
|
+
await this.#pendingTxHashToHistoricalBlockHeaderHash.delete(txHash);
|
|
436
|
+
}
|
|
437
|
+
|
|
394
438
|
/**
|
|
395
439
|
* Gets all the transactions stored in the pool.
|
|
396
440
|
* @returns Array of tx objects in the order they were added to the pool.
|
|
@@ -409,30 +453,107 @@ export class AztecKVTxPool extends (EventEmitter as new () => TypedEventEmitter<
|
|
|
409
453
|
return vals.map(x => TxHash.fromString(x));
|
|
410
454
|
}
|
|
411
455
|
|
|
412
|
-
public
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
456
|
+
public async getPendingTxInfos(): Promise<PendingTxInfo[]> {
|
|
457
|
+
const vals = await toArray(this.#pendingTxPriorityToHash.valuesAsync());
|
|
458
|
+
const results = await Promise.all(vals.map(val => this.getPendingTxInfo(TxHash.fromString(val))));
|
|
459
|
+
return results.filter((info): info is PendingTxInfo => info !== undefined);
|
|
460
|
+
}
|
|
416
461
|
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
462
|
+
private async getPendingTxInfo(txHash: TxHash): Promise<PendingTxInfo | undefined> {
|
|
463
|
+
let historicalBlockHash = await this.#pendingTxHashToHistoricalBlockHeaderHash.getAsync(txHash.toString());
|
|
464
|
+
// Not all tx might have this index created.
|
|
465
|
+
if (!historicalBlockHash) {
|
|
466
|
+
const tx = await this.getTxByHash(txHash);
|
|
467
|
+
if (!tx) {
|
|
468
|
+
this.#log.warn(`PendingTxInfo:tx ${txHash} not found`);
|
|
469
|
+
return undefined;
|
|
421
470
|
}
|
|
471
|
+
|
|
472
|
+
historicalBlockHash = (await tx.data.constants.anchorBlockHeader.hash()).toString();
|
|
473
|
+
await this.#pendingTxHashToHistoricalBlockHeaderHash.set(txHash.toString(), historicalBlockHash);
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
return {
|
|
477
|
+
txHash,
|
|
478
|
+
blockHash: Fr.fromString(historicalBlockHash),
|
|
479
|
+
isEvictable: !this.#nonEvictableTxs.has(txHash.toString()),
|
|
480
|
+
};
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
public async getPendingTxsReferencingBlocks(blockHashes: Fr[]): Promise<TxBlockReference[]> {
|
|
484
|
+
const result: TxBlockReference[] = [];
|
|
485
|
+
for (const blockHash of blockHashes) {
|
|
486
|
+
const chunk = await toArray(this.#historicalHeaderToTxHash.getValuesAsync(blockHash.toString()));
|
|
487
|
+
result.push(
|
|
488
|
+
...chunk.map(txHash => ({
|
|
489
|
+
txHash: TxHash.fromString(txHash),
|
|
490
|
+
blockHash,
|
|
491
|
+
isEvictable: !this.#nonEvictableTxs.has(txHash),
|
|
492
|
+
})),
|
|
493
|
+
);
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
return result;
|
|
497
|
+
}
|
|
498
|
+
|
|
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);
|
|
422
504
|
}
|
|
505
|
+
return feePayers;
|
|
506
|
+
}
|
|
423
507
|
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
this.#
|
|
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;
|
|
428
513
|
}
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
public async getMinedTxHashes(): Promise<[TxHash, BlockNumber][]> {
|
|
517
|
+
const vals = await toArray(this.#minedTxHashToBlock.entriesAsync());
|
|
518
|
+
return vals.map(([txHash, blockNumber]) => [TxHash.fromString(txHash), blockNumber]);
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
public async getPendingTxCount(): Promise<number> {
|
|
522
|
+
return (await this.#pendingTxPriorityToHash.sizeAsync()) ?? 0;
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
public async getMinedTxCount(): Promise<number> {
|
|
526
|
+
return (await this.#minedTxHashToBlock.sizeAsync()) ?? 0;
|
|
527
|
+
}
|
|
429
528
|
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
529
|
+
public async getTxStatus(txHash: TxHash): Promise<'pending' | 'mined' | 'deleted' | undefined> {
|
|
530
|
+
const key = txHash.toString();
|
|
531
|
+
const [isMined, isKnown, isDeleted] = await Promise.all([
|
|
532
|
+
this.#minedTxHashToBlock.hasAsync(key),
|
|
533
|
+
this.#txs.hasAsync(key),
|
|
534
|
+
this.#deletedMinedTxHashes.hasAsync(key),
|
|
535
|
+
]);
|
|
536
|
+
|
|
537
|
+
if (isDeleted) {
|
|
538
|
+
return 'deleted';
|
|
539
|
+
} else if (isMined) {
|
|
540
|
+
return 'mined';
|
|
541
|
+
} else if (isKnown) {
|
|
542
|
+
return 'pending';
|
|
543
|
+
} else {
|
|
544
|
+
return undefined;
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
public updateConfig(cfg: TxPoolOptions): void {
|
|
549
|
+
if (typeof cfg.archivedTxLimit === 'number') {
|
|
550
|
+
assert(cfg.archivedTxLimit >= 0, 'archivedTxLimit must be greater or equal to 0');
|
|
551
|
+
this.#archivedTxLimit = cfg.archivedTxLimit;
|
|
433
552
|
}
|
|
434
553
|
|
|
435
|
-
|
|
554
|
+
if (this.#evictionManager) {
|
|
555
|
+
this.#evictionManager.updateConfig(cfg);
|
|
556
|
+
}
|
|
436
557
|
}
|
|
437
558
|
|
|
438
559
|
public markTxsAsNonEvictable(txHashes: TxHash[]): Promise<void> {
|
|
@@ -440,6 +561,15 @@ export class AztecKVTxPool extends (EventEmitter as new () => TypedEventEmitter<
|
|
|
440
561
|
return Promise.resolve();
|
|
441
562
|
}
|
|
442
563
|
|
|
564
|
+
public clearNonEvictableTxs(): Promise<void> {
|
|
565
|
+
// Clear the non-evictable set after completing the DB updates above.
|
|
566
|
+
// This ensures pinned (non-evictable) txs are protected while we mark mined txs,
|
|
567
|
+
// but they won't remain pinned indefinitely across blocks. Note that eviction rules
|
|
568
|
+
// (including post-mining invalidation) respect the non-evictable flag while it is set.
|
|
569
|
+
this.#nonEvictableTxs.clear();
|
|
570
|
+
return Promise.resolve();
|
|
571
|
+
}
|
|
572
|
+
|
|
443
573
|
/**
|
|
444
574
|
* Permanently deletes deleted mined transactions from blocks up to and including the specified block number.
|
|
445
575
|
* @param blockNumber - Block number threshold. Deleted mined txs from this block or earlier will be permanently deleted.
|
|
@@ -447,10 +577,10 @@ export class AztecKVTxPool extends (EventEmitter as new () => TypedEventEmitter<
|
|
|
447
577
|
*/
|
|
448
578
|
public async cleanupDeletedMinedTxs(blockNumber: BlockNumber): Promise<number> {
|
|
449
579
|
let deletedCount = 0;
|
|
450
|
-
const txHashesToDelete: string[] = [];
|
|
451
|
-
const blocksToDelete: BlockNumber[] = [];
|
|
452
|
-
|
|
453
580
|
await this.#store.transactionAsync(async () => {
|
|
581
|
+
const txHashesToDelete: string[] = [];
|
|
582
|
+
const blocksToDelete: BlockNumber[] = [];
|
|
583
|
+
|
|
454
584
|
// Iterate through all entries and check block numbers
|
|
455
585
|
for await (const [block, txHash] of this.#blockToDeletedMinedTxHash.entriesAsync()) {
|
|
456
586
|
if (block <= blockNumber) {
|
|
@@ -464,6 +594,7 @@ export class AztecKVTxPool extends (EventEmitter as new () => TypedEventEmitter<
|
|
|
464
594
|
deletedCount++;
|
|
465
595
|
}
|
|
466
596
|
}
|
|
597
|
+
this.#metrics.transactionsRemoved(txHashesToDelete);
|
|
467
598
|
|
|
468
599
|
// Clean up block-to-hash mapping - delete all values for each block
|
|
469
600
|
for (const block of blocksToDelete) {
|
|
@@ -480,15 +611,6 @@ export class AztecKVTxPool extends (EventEmitter as new () => TypedEventEmitter<
|
|
|
480
611
|
return deletedCount;
|
|
481
612
|
}
|
|
482
613
|
|
|
483
|
-
/**
|
|
484
|
-
* Creates a GasTxValidator instance.
|
|
485
|
-
* @param db - DB for the validator to use
|
|
486
|
-
* @returns A GasTxValidator instance
|
|
487
|
-
*/
|
|
488
|
-
protected createGasTxValidator(db: MerkleTreeReadOperations): GasTxValidator {
|
|
489
|
-
return new GasTxValidator(new DatabasePublicStateSource(db), ProtocolContractAddress.FeeJuice, GasFees.empty());
|
|
490
|
-
}
|
|
491
|
-
|
|
492
614
|
/**
|
|
493
615
|
* Creates an ArchiveCache instance.
|
|
494
616
|
* @param db - DB for the cache to use
|
|
@@ -498,34 +620,9 @@ export class AztecKVTxPool extends (EventEmitter as new () => TypedEventEmitter<
|
|
|
498
620
|
return new ArchiveCache(db);
|
|
499
621
|
}
|
|
500
622
|
|
|
501
|
-
/**
|
|
502
|
-
* Checks if a cached transaction exists in the in-memory pending tx pool and returns it.
|
|
503
|
-
* Otherwise, it checks the tx pool, updates the pending tx pool, and returns the tx.
|
|
504
|
-
* @param txHash - The generated tx hash.
|
|
505
|
-
* @returns The transaction, if found, 'undefined' otherwise.
|
|
506
|
-
*/
|
|
507
|
-
private async getPendingTxByHash(txHash: TxHash | string): Promise<Tx | undefined> {
|
|
508
|
-
let key;
|
|
509
|
-
if (typeof txHash === 'string') {
|
|
510
|
-
key = txHash;
|
|
511
|
-
txHash = TxHash.fromString(txHash);
|
|
512
|
-
} else {
|
|
513
|
-
key = txHash.toString();
|
|
514
|
-
}
|
|
515
|
-
|
|
516
|
-
if (this.#pendingTxs.has(key)) {
|
|
517
|
-
return this.#pendingTxs.get(key);
|
|
518
|
-
}
|
|
519
|
-
const tx = await this.getTxByHash(txHash);
|
|
520
|
-
if (tx) {
|
|
521
|
-
this.#pendingTxs.set(key, tx);
|
|
522
|
-
return tx;
|
|
523
|
-
}
|
|
524
|
-
return undefined;
|
|
525
|
-
}
|
|
526
|
-
|
|
527
623
|
/**
|
|
528
624
|
* Archives a list of txs for future reference. The number of archived txs is limited by the specified archivedTxLimit.
|
|
625
|
+
* Note: Pending txs should not be archived, only finalized txs
|
|
529
626
|
* @param txs - The list of transactions to archive.
|
|
530
627
|
* @returns Empty promise.
|
|
531
628
|
*/
|
|
@@ -533,6 +630,10 @@ export class AztecKVTxPool extends (EventEmitter as new () => TypedEventEmitter<
|
|
|
533
630
|
if (txs.length === 0) {
|
|
534
631
|
return;
|
|
535
632
|
}
|
|
633
|
+
if (this.#archivedTxLimit === 0) {
|
|
634
|
+
return;
|
|
635
|
+
}
|
|
636
|
+
|
|
536
637
|
try {
|
|
537
638
|
const txHashes = await Promise.all(txs.map(tx => tx.getTxHash()));
|
|
538
639
|
await this.#archive.transactionAsync(async () => {
|
|
@@ -572,183 +673,74 @@ export class AztecKVTxPool extends (EventEmitter as new () => TypedEventEmitter<
|
|
|
572
673
|
}
|
|
573
674
|
}
|
|
574
675
|
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
* @returns The total number of txs evicted from the pool and the number of new txs that were evicted.
|
|
581
|
-
*/
|
|
582
|
-
private async evictLowPriorityTxs(
|
|
583
|
-
newTxHashes: TxHash[],
|
|
584
|
-
): Promise<{ numLowPriorityTxsEvicted: number; numNewTxsEvicted: number }> {
|
|
585
|
-
if (this.#maxTxPoolSize === undefined || this.#maxTxPoolSize === 0) {
|
|
586
|
-
return { numLowPriorityTxsEvicted: 0, numNewTxsEvicted: 0 };
|
|
587
|
-
}
|
|
588
|
-
|
|
589
|
-
let numNewTxsEvicted = 0;
|
|
590
|
-
const txsToEvict: TxHash[] = [];
|
|
591
|
-
|
|
592
|
-
let pendingTxsSize = (await this.#pendingTxSize.getAsync()) ?? 0;
|
|
593
|
-
if (pendingTxsSize > this.#maxTxPoolSize * this.txPoolOverflowFactor) {
|
|
594
|
-
for await (const txHash of this.#pendingTxPriorityToHash.valuesAsync()) {
|
|
595
|
-
if (this.#nonEvictableTxs.has(txHash.toString())) {
|
|
596
|
-
continue;
|
|
597
|
-
}
|
|
598
|
-
const txSize =
|
|
599
|
-
(await this.#pendingTxHashToSize.getAsync(txHash.toString())) ??
|
|
600
|
-
(await this.getPendingTxByHash(txHash))?.getSize();
|
|
601
|
-
|
|
602
|
-
this.#log.verbose(`Evicting tx ${txHash} from pool due to low priority to satisfy max tx size limit`, {
|
|
603
|
-
txHash,
|
|
604
|
-
txSize,
|
|
605
|
-
});
|
|
606
|
-
|
|
607
|
-
txsToEvict.push(TxHash.fromString(txHash));
|
|
676
|
+
// Assumes being called within a DB transaction
|
|
677
|
+
private async addPendingTxIndicesInDbTx(tx: Tx, txHash: string): Promise<void> {
|
|
678
|
+
await this.#pendingTxPriorityToHash.set(getPendingTxPriority(tx), txHash);
|
|
679
|
+
await this.#historicalHeaderToTxHash.set((await tx.data.constants.anchorBlockHeader.hash()).toString(), txHash);
|
|
680
|
+
await this.#feePayerToBalanceEntry.set(tx.data.feePayer.toString(), await FeePayerTxInfo.encode(tx, txHash));
|
|
608
681
|
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
}
|
|
614
|
-
}
|
|
615
|
-
}
|
|
616
|
-
numNewTxsEvicted += newTxHashes.filter(txHash => txsToEvict.includes(txHash)).length;
|
|
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);
|
|
617
686
|
}
|
|
687
|
+
}
|
|
618
688
|
|
|
619
|
-
|
|
620
|
-
|
|
689
|
+
// Assumes being called within a DB transaction
|
|
690
|
+
private async removePendingTxIndicesInDbTx(tx: Tx, txHash: string): Promise<void> {
|
|
691
|
+
await this.#pendingTxPriorityToHash.deleteValue(getPendingTxPriority(tx), txHash);
|
|
692
|
+
await this.#historicalHeaderToTxHash.deleteValue(
|
|
693
|
+
(await tx.data.constants.anchorBlockHeader.hash()).toString(),
|
|
694
|
+
txHash,
|
|
695
|
+
);
|
|
696
|
+
await this.#feePayerToBalanceEntry.deleteValue(
|
|
697
|
+
tx.data.feePayer.toString(),
|
|
698
|
+
await FeePayerTxInfo.encode(tx, txHash),
|
|
699
|
+
);
|
|
700
|
+
|
|
701
|
+
// Remove nullifier entries
|
|
702
|
+
const nullifiers = tx.data.getNonEmptyNullifiers();
|
|
703
|
+
for (const nullifier of nullifiers) {
|
|
704
|
+
await this.#pendingNullifierToTxHash.delete(nullifier.toString());
|
|
621
705
|
}
|
|
622
|
-
return {
|
|
623
|
-
numLowPriorityTxsEvicted: txsToEvict.length,
|
|
624
|
-
numNewTxsEvicted,
|
|
625
|
-
};
|
|
626
706
|
}
|
|
627
707
|
|
|
628
708
|
/**
|
|
629
|
-
*
|
|
630
|
-
*
|
|
631
|
-
* - txs with nullifiers that are already included in the mined block
|
|
632
|
-
* - txs with an insufficient fee payer balance
|
|
633
|
-
* - txs with an expiration timestamp lower than that of the mined block
|
|
634
|
-
*
|
|
635
|
-
* @param minedTxHashes - The tx hashes of the txs mined in the block.
|
|
636
|
-
* @param blockHeader - The header of the mined block.
|
|
637
|
-
* @returns The total number of txs evicted from the pool.
|
|
709
|
+
* Returns up to `limit` lowest-priority evictable pending tx hashes without hydrating transactions.
|
|
710
|
+
* Iterates the priority index in ascending order and skips non-evictable txs.
|
|
638
711
|
*/
|
|
639
|
-
|
|
640
|
-
minedTxHashes: TxHash[],
|
|
641
|
-
blockHeader: BlockHeader,
|
|
642
|
-
minedNullifiers: Set<string>,
|
|
643
|
-
minedFeePayers: Set<string>,
|
|
644
|
-
): Promise<number> {
|
|
645
|
-
if (minedTxHashes.length === 0) {
|
|
646
|
-
return 0;
|
|
647
|
-
}
|
|
648
|
-
|
|
649
|
-
const { blockNumber, timestamp } = blockHeader.globalVariables;
|
|
650
|
-
|
|
651
|
-
// Wait for world state to be synced to at least the mined block number
|
|
652
|
-
await this.#worldStateSynchronizer.syncImmediate(blockNumber);
|
|
653
|
-
|
|
654
|
-
const db = this.#worldStateSynchronizer.getCommitted();
|
|
655
|
-
const gasTxValidator = this.createGasTxValidator(db);
|
|
656
|
-
|
|
712
|
+
public async getLowestPriorityEvictable(limit: number): Promise<TxHash[]> {
|
|
657
713
|
const txsToEvict: TxHash[] = [];
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
continue;
|
|
662
|
-
}
|
|
663
|
-
|
|
664
|
-
// Evict pending txs that share nullifiers with mined txs
|
|
665
|
-
const txNullifiers = tx.data.getNonEmptyNullifiers();
|
|
666
|
-
if (txNullifiers.some(nullifier => minedNullifiers.has(nullifier.toString()))) {
|
|
667
|
-
this.#log.verbose(`Evicting tx ${txHash} from pool due to a duplicate nullifier with a mined tx`);
|
|
668
|
-
txsToEvict.push(TxHash.fromString(txHash));
|
|
669
|
-
continue;
|
|
670
|
-
}
|
|
714
|
+
if (limit <= 0) {
|
|
715
|
+
return txsToEvict;
|
|
716
|
+
}
|
|
671
717
|
|
|
672
|
-
|
|
673
|
-
if (
|
|
674
|
-
minedFeePayers.has(tx.data.feePayer.toString()) &&
|
|
675
|
-
(await gasTxValidator.validateTxFee(tx)).result === 'invalid'
|
|
676
|
-
) {
|
|
677
|
-
this.#log.verbose(`Evicting tx ${txHash} from pool due to an insufficient fee payer balance`);
|
|
678
|
-
txsToEvict.push(TxHash.fromString(txHash));
|
|
718
|
+
for await (const txHashStr of this.#pendingTxPriorityToHash.valuesAsync()) {
|
|
719
|
+
if (this.#nonEvictableTxs.has(txHashStr)) {
|
|
679
720
|
continue;
|
|
680
721
|
}
|
|
681
722
|
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
this.#log.verbose(
|
|
686
|
-
`Evicting tx ${txHash} from pool due to the tx being expired (includeByTimestamp: ${includeByTimestamp}, mined block timestamp: ${timestamp})`,
|
|
687
|
-
);
|
|
688
|
-
txsToEvict.push(TxHash.fromString(txHash));
|
|
689
|
-
continue;
|
|
723
|
+
txsToEvict.push(TxHash.fromString(txHashStr));
|
|
724
|
+
if (txsToEvict.length >= limit) {
|
|
725
|
+
break;
|
|
690
726
|
}
|
|
691
727
|
}
|
|
692
728
|
|
|
693
|
-
|
|
694
|
-
await this.deleteTxs(txsToEvict, { eviction: true });
|
|
695
|
-
}
|
|
696
|
-
return txsToEvict.length;
|
|
729
|
+
return txsToEvict;
|
|
697
730
|
}
|
|
698
731
|
|
|
699
732
|
/**
|
|
700
|
-
*
|
|
701
|
-
*
|
|
702
|
-
* @param txHashes - The tx hashes of the txs that were moved from mined to pending.
|
|
703
|
-
* @returns The total number of txs evicted from the pool.
|
|
733
|
+
* Creates a PreAddPoolAccess object for use by pre-add eviction rules.
|
|
734
|
+
* Provides read-only access to pool state during addTxs transaction.
|
|
704
735
|
*/
|
|
705
|
-
private
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
const txsToEvict: TxHash[] = [];
|
|
716
|
-
|
|
717
|
-
for await (const [txHash, headerHash] of this.#pendingTxHashToHeaderHash.entriesAsync()) {
|
|
718
|
-
const tx = await this.getPendingTxByHash(txHash);
|
|
719
|
-
if (!tx) {
|
|
720
|
-
continue;
|
|
721
|
-
}
|
|
722
|
-
|
|
723
|
-
const [index] = await archiveCache.getArchiveIndices([Fr.fromString(headerHash)]);
|
|
724
|
-
if (index === undefined) {
|
|
725
|
-
this.#log.verbose(`Evicting tx ${txHash} from pool due to an invalid archive root`);
|
|
726
|
-
txsToEvict.push(TxHash.fromString(txHash));
|
|
727
|
-
continue;
|
|
728
|
-
}
|
|
729
|
-
|
|
730
|
-
if ((await gasTxValidator.validateTxFee(tx)).result === 'invalid') {
|
|
731
|
-
this.#log.verbose(`Evicting tx ${txHash} from pool due to an insufficient fee payer balance`);
|
|
732
|
-
txsToEvict.push(TxHash.fromString(txHash));
|
|
733
|
-
}
|
|
734
|
-
}
|
|
735
|
-
|
|
736
|
-
if (txsToEvict.length > 0) {
|
|
737
|
-
await this.deleteTxs(txsToEvict, { eviction: true });
|
|
738
|
-
}
|
|
739
|
-
return txsToEvict.length;
|
|
740
|
-
}
|
|
741
|
-
|
|
742
|
-
private async addPendingTxIndices(tx: Tx, txHash: string): Promise<void> {
|
|
743
|
-
await this.#pendingTxPriorityToHash.set(getPendingTxPriority(tx), txHash);
|
|
744
|
-
await this.#pendingTxHashToSize.set(txHash, tx.getSize());
|
|
745
|
-
await this.#pendingTxHashToHeaderHash.set(txHash, (await tx.data.constants.anchorBlockHeader.hash()).toString());
|
|
746
|
-
}
|
|
747
|
-
|
|
748
|
-
private async removePendingTxIndices(tx: Tx, txHash: string): Promise<void> {
|
|
749
|
-
await this.#pendingTxPriorityToHash.deleteValue(getPendingTxPriority(tx), txHash);
|
|
750
|
-
await this.#pendingTxHashToSize.delete(txHash);
|
|
751
|
-
await this.#pendingTxHashToHeaderHash.delete(txHash);
|
|
752
|
-
this.#pendingTxs.delete(txHash);
|
|
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
|
+
};
|
|
753
745
|
}
|
|
754
746
|
}
|