@aztec/p2p 0.0.1-commit.6d63667d → 0.0.1-commit.72dcdcda8
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/client/factory.d.ts +10 -10
- package/dest/client/factory.d.ts.map +1 -1
- package/dest/client/factory.js +39 -15
- package/dest/client/interface.d.ts +46 -33
- package/dest/client/interface.d.ts.map +1 -1
- package/dest/client/p2p_client.d.ts +39 -51
- package/dest/client/p2p_client.d.ts.map +1 -1
- package/dest/client/p2p_client.js +145 -200
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.js +7 -8
- package/dest/config.d.ts +24 -8
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +16 -6
- 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 +104 -88
- 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 +353 -87
- package/dest/mem_pools/attestation_pool/index.d.ts +2 -3
- package/dest/mem_pools/attestation_pool/index.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/index.js +1 -2
- package/dest/mem_pools/attestation_pool/mocks.d.ts +2 -2
- package/dest/mem_pools/attestation_pool/mocks.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/mocks.js +2 -2
- package/dest/mem_pools/index.d.ts +3 -2
- package/dest/mem_pools/index.d.ts.map +1 -1
- package/dest/mem_pools/index.js +1 -1
- package/dest/mem_pools/interface.d.ts +5 -5
- package/dest/mem_pools/interface.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_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 +3 -3
- package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.js +18 -9
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.d.ts +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.js +5 -2
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.d.ts +3 -3
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.js +12 -4
- package/dest/mem_pools/tx_pool_v2/eviction/index.d.ts +2 -2
- package/dest/mem_pools/tx_pool_v2/eviction/index.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/index.js +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/interfaces.d.ts +48 -5
- package/dest/mem_pools/tx_pool_v2/eviction/interfaces.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/interfaces.js +8 -0
- package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.js +7 -5
- package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.js +7 -5
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.d.ts +2 -2
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.js +14 -6
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.d.ts +4 -4
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.js +14 -4
- package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.d.ts +3 -3
- package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.js +2 -2
- package/dest/mem_pools/tx_pool_v2/index.d.ts +3 -2
- package/dest/mem_pools/tx_pool_v2/index.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/index.js +2 -1
- 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 +22 -8
- package/dest/mem_pools/tx_pool_v2/interfaces.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/interfaces.js +4 -1
- package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts +56 -8
- package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/tx_metadata.js +108 -10
- package/dest/mem_pools/tx_pool_v2/tx_pool_indices.d.ts +12 -3
- package/dest/mem_pools/tx_pool_v2/tx_pool_indices.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/tx_pool_indices.js +36 -14
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts +9 -4
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2.js +11 -6
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts +13 -5
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.js +342 -185
- package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.d.ts +3 -3
- package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/aggregate_tx_validator.d.ts +4 -4
- package/dest/msg_validators/tx_validator/aggregate_tx_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/aggregate_tx_validator.js +3 -3
- package/dest/msg_validators/tx_validator/block_header_validator.d.ts +16 -3
- package/dest/msg_validators/tx_validator/block_header_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/block_header_validator.js +1 -1
- package/dest/msg_validators/tx_validator/double_spend_validator.d.ts +13 -3
- package/dest/msg_validators/tx_validator/double_spend_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/double_spend_validator.js +4 -4
- package/dest/msg_validators/tx_validator/factory.d.ts +114 -6
- package/dest/msg_validators/tx_validator/factory.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/factory.js +219 -58
- package/dest/msg_validators/tx_validator/gas_validator.d.ts +58 -3
- package/dest/msg_validators/tx_validator/gas_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/gas_validator.js +73 -36
- 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/nullifier_cache.d.ts +14 -0
- package/dest/msg_validators/tx_validator/nullifier_cache.d.ts.map +1 -0
- package/dest/msg_validators/tx_validator/nullifier_cache.js +24 -0
- package/dest/msg_validators/tx_validator/timestamp_validator.d.ts +20 -4
- package/dest/msg_validators/tx_validator/timestamp_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/timestamp_validator.js +6 -6
- package/dest/services/dummy_service.d.ts +13 -5
- package/dest/services/dummy_service.d.ts.map +1 -1
- package/dest/services/dummy_service.js +10 -4
- package/dest/services/encoding.d.ts +3 -3
- package/dest/services/encoding.d.ts.map +1 -1
- package/dest/services/encoding.js +11 -10
- 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/libp2p/libp2p_service.d.ts +95 -43
- package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
- package/dest/services/libp2p/libp2p_service.js +418 -331
- 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 +25 -2
- package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts +4 -3
- package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts.map +1 -1
- package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.js +19 -46
- package/dest/services/reqresp/batch-tx-requester/interface.d.ts +2 -6
- package/dest/services/reqresp/batch-tx-requester/interface.d.ts.map +1 -1
- package/dest/services/reqresp/batch-tx-requester/missing_txs.d.ts +10 -13
- package/dest/services/reqresp/batch-tx-requester/missing_txs.d.ts.map +1 -1
- package/dest/services/reqresp/batch-tx-requester/missing_txs.js +25 -46
- package/dest/services/reqresp/batch-tx-requester/peer_collection.d.ts +17 -11
- package/dest/services/reqresp/batch-tx-requester/peer_collection.d.ts.map +1 -1
- package/dest/services/reqresp/batch-tx-requester/peer_collection.js +49 -15
- package/dest/services/reqresp/batch-tx-requester/tx_validator.js +2 -2
- package/dest/services/reqresp/interface.d.ts +10 -1
- package/dest/services/reqresp/interface.d.ts.map +1 -1
- package/dest/services/reqresp/interface.js +15 -1
- package/dest/services/reqresp/protocols/block_txs/block_txs_handler.d.ts +4 -3
- package/dest/services/reqresp/protocols/block_txs/block_txs_handler.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.d.ts +7 -1
- 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 +15 -0
- 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 +1 -1
- package/dest/services/reqresp/reqresp.d.ts.map +1 -1
- package/dest/services/reqresp/reqresp.js +13 -5
- package/dest/services/service.d.ts +39 -3
- package/dest/services/service.d.ts.map +1 -1
- package/dest/services/tx_collection/config.d.ts +19 -1
- package/dest/services/tx_collection/config.d.ts.map +1 -1
- package/dest/services/tx_collection/config.js +46 -0
- package/dest/services/tx_collection/fast_tx_collection.d.ts +3 -1
- package/dest/services/tx_collection/fast_tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/fast_tx_collection.js +56 -36
- 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 +2 -1
- package/dest/services/tx_collection/index.d.ts.map +1 -1
- package/dest/services/tx_collection/index.js +1 -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 +2 -1
- 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 +7 -6
- package/dest/services/tx_collection/proposal_tx_collector.d.ts.map +1 -1
- package/dest/services/tx_collection/proposal_tx_collector.js +5 -4
- package/dest/services/tx_collection/slow_tx_collection.d.ts +7 -3
- 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 +23 -10
- package/dest/services/tx_collection/tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/tx_collection.js +75 -3
- 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 +1 -3
- package/dest/services/tx_file_store/config.d.ts.map +1 -1
- package/dest/services/tx_file_store/config.js +0 -4
- package/dest/services/tx_file_store/tx_file_store.d.ts +4 -3
- package/dest/services/tx_file_store/tx_file_store.d.ts.map +1 -1
- package/dest/services/tx_file_store/tx_file_store.js +9 -6
- package/dest/services/tx_provider.d.ts +4 -4
- package/dest/services/tx_provider.d.ts.map +1 -1
- package/dest/services/tx_provider.js +9 -8
- package/dest/test-helpers/make-test-p2p-clients.d.ts +7 -8
- package/dest/test-helpers/make-test-p2p-clients.d.ts.map +1 -1
- package/dest/test-helpers/make-test-p2p-clients.js +1 -2
- package/dest/test-helpers/mock-pubsub.d.ts +30 -4
- package/dest/test-helpers/mock-pubsub.d.ts.map +1 -1
- package/dest/test-helpers/mock-pubsub.js +105 -4
- package/dest/test-helpers/reqresp-nodes.d.ts +2 -3
- package/dest/test-helpers/reqresp-nodes.d.ts.map +1 -1
- package/dest/test-helpers/reqresp-nodes.js +4 -3
- package/dest/test-helpers/testbench-utils.d.ts +43 -38
- package/dest/test-helpers/testbench-utils.d.ts.map +1 -1
- package/dest/test-helpers/testbench-utils.js +128 -59
- package/dest/testbench/p2p_client_testbench_worker.d.ts +2 -2
- package/dest/testbench/p2p_client_testbench_worker.d.ts.map +1 -1
- package/dest/testbench/p2p_client_testbench_worker.js +15 -15
- package/dest/util.d.ts +2 -2
- package/dest/util.d.ts.map +1 -1
- package/package.json +14 -14
- package/src/client/factory.ts +74 -27
- package/src/client/interface.ts +56 -34
- package/src/client/p2p_client.ts +180 -247
- package/src/client/test/tx_proposal_collector/proposal_tx_collector_worker.ts +20 -11
- package/src/config.ts +35 -11
- package/src/errors/tx-pool.error.ts +12 -0
- package/src/index.ts +1 -0
- package/src/mem_pools/attestation_pool/attestation_pool.ts +496 -91
- package/src/mem_pools/attestation_pool/attestation_pool_test_suite.ts +442 -102
- package/src/mem_pools/attestation_pool/index.ts +9 -2
- package/src/mem_pools/attestation_pool/mocks.ts +2 -1
- package/src/mem_pools/index.ts +4 -1
- package/src/mem_pools/interface.ts +4 -4
- package/src/mem_pools/tx_pool/README.md +1 -1
- package/src/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.ts +3 -3
- package/src/mem_pools/tx_pool_v2/README.md +76 -10
- package/src/mem_pools/tx_pool_v2/deleted_pool.ts +321 -0
- package/src/mem_pools/tx_pool_v2/eviction/eviction_manager.ts +21 -8
- package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.ts +5 -2
- package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.ts +18 -4
- package/src/mem_pools/tx_pool_v2/eviction/index.ts +4 -0
- package/src/mem_pools/tx_pool_v2/eviction/interfaces.ts +49 -4
- package/src/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.ts +5 -5
- package/src/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.ts +5 -5
- package/src/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.ts +14 -9
- package/src/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.ts +24 -6
- package/src/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.ts +3 -3
- package/src/mem_pools/tx_pool_v2/index.ts +2 -1
- package/src/mem_pools/tx_pool_v2/instrumentation.ts +69 -0
- package/src/mem_pools/tx_pool_v2/interfaces.ts +23 -8
- package/src/mem_pools/tx_pool_v2/tx_metadata.ts +153 -17
- package/src/mem_pools/tx_pool_v2/tx_pool_indices.ts +43 -16
- package/src/mem_pools/tx_pool_v2/tx_pool_v2.ts +18 -7
- package/src/mem_pools/tx_pool_v2/tx_pool_v2_impl.ts +383 -182
- package/src/msg_validators/attestation_validator/fisherman_attestation_validator.ts +2 -2
- package/src/msg_validators/tx_validator/README.md +115 -0
- package/src/msg_validators/tx_validator/aggregate_tx_validator.ts +5 -5
- package/src/msg_validators/tx_validator/block_header_validator.ts +15 -3
- package/src/msg_validators/tx_validator/double_spend_validator.ts +11 -6
- package/src/msg_validators/tx_validator/factory.ts +353 -77
- package/src/msg_validators/tx_validator/gas_validator.ts +90 -27
- package/src/msg_validators/tx_validator/index.ts +1 -0
- package/src/msg_validators/tx_validator/nullifier_cache.ts +30 -0
- package/src/msg_validators/tx_validator/timestamp_validator.ts +23 -18
- package/src/services/dummy_service.ts +18 -6
- package/src/services/encoding.ts +9 -9
- 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/libp2p/libp2p_service.ts +436 -355
- package/src/services/peer-manager/peer_scoring.ts +25 -0
- package/src/services/reqresp/batch-tx-requester/batch_tx_requester.ts +20 -48
- package/src/services/reqresp/batch-tx-requester/interface.ts +1 -5
- package/src/services/reqresp/batch-tx-requester/missing_txs.ts +23 -71
- package/src/services/reqresp/batch-tx-requester/peer_collection.ts +63 -24
- package/src/services/reqresp/batch-tx-requester/tx_validator.ts +2 -2
- package/src/services/reqresp/interface.ts +26 -1
- package/src/services/reqresp/protocols/block_txs/block_txs_handler.ts +4 -3
- package/src/services/reqresp/protocols/block_txs/block_txs_reqresp.ts +17 -0
- package/src/services/reqresp/protocols/tx.ts +22 -0
- package/src/services/reqresp/reqresp.ts +16 -4
- package/src/services/service.ts +51 -2
- package/src/services/tx_collection/config.ts +68 -0
- package/src/services/tx_collection/fast_tx_collection.ts +65 -32
- 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 +1 -0
- package/src/services/tx_collection/instrumentation.ts +7 -1
- package/src/services/tx_collection/missing_txs_tracker.ts +52 -0
- package/src/services/tx_collection/proposal_tx_collector.ts +8 -7
- package/src/services/tx_collection/slow_tx_collection.ts +66 -33
- package/src/services/tx_collection/tx_collection.ts +113 -16
- 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 +0 -6
- package/src/services/tx_file_store/tx_file_store.ts +10 -8
- package/src/services/tx_provider.ts +10 -9
- package/src/test-helpers/make-test-p2p-clients.ts +3 -5
- package/src/test-helpers/mock-pubsub.ts +146 -9
- package/src/test-helpers/reqresp-nodes.ts +4 -6
- package/src/test-helpers/testbench-utils.ts +127 -71
- package/src/testbench/p2p_client_testbench_worker.ts +24 -21
- package/src/util.ts +7 -1
- package/dest/mem_pools/attestation_pool/kv_attestation_pool.d.ts +0 -40
- package/dest/mem_pools/attestation_pool/kv_attestation_pool.d.ts.map +0 -1
- package/dest/mem_pools/attestation_pool/kv_attestation_pool.js +0 -218
- package/dest/mem_pools/attestation_pool/memory_attestation_pool.d.ts +0 -31
- package/dest/mem_pools/attestation_pool/memory_attestation_pool.d.ts.map +0 -1
- package/dest/mem_pools/attestation_pool/memory_attestation_pool.js +0 -180
- package/src/mem_pools/attestation_pool/kv_attestation_pool.ts +0 -320
- package/src/mem_pools/attestation_pool/memory_attestation_pool.ts +0 -264
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { SlotNumber } from '@aztec/foundation/branded-types';
|
|
1
|
+
import { BlockNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
2
2
|
import type { Logger } from '@aztec/foundation/log';
|
|
3
|
+
import type { DateProvider } from '@aztec/foundation/timer';
|
|
3
4
|
import type { AztecAsyncKVStore, AztecAsyncMap } from '@aztec/kv-store';
|
|
4
5
|
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
5
6
|
import { computeFeePayerBalanceStorageSlot } from '@aztec/protocol-contracts/fee-juice';
|
|
@@ -8,8 +9,10 @@ import type { L2Block, L2BlockId, L2BlockSource } from '@aztec/stdlib/block';
|
|
|
8
9
|
import type { WorldStateSynchronizer } from '@aztec/stdlib/interfaces/server';
|
|
9
10
|
import { DatabasePublicStateSource } from '@aztec/stdlib/trees';
|
|
10
11
|
import { BlockHeader, Tx, TxHash, type TxValidator } from '@aztec/stdlib/tx';
|
|
12
|
+
import type { TelemetryClient } from '@aztec/telemetry-client';
|
|
11
13
|
|
|
12
14
|
import { TxArchive } from './archive/index.js';
|
|
15
|
+
import { DeletedPool } from './deleted_pool.js';
|
|
13
16
|
import {
|
|
14
17
|
EvictionManager,
|
|
15
18
|
FeePayerBalanceEvictionRule,
|
|
@@ -20,8 +23,12 @@ import {
|
|
|
20
23
|
LowPriorityPreAddRule,
|
|
21
24
|
NullifierConflictRule,
|
|
22
25
|
type PoolOperations,
|
|
26
|
+
type PreAddContext,
|
|
23
27
|
type PreAddPoolAccess,
|
|
28
|
+
TxPoolRejectionCode,
|
|
29
|
+
type TxPoolRejectionError,
|
|
24
30
|
} from './eviction/index.js';
|
|
31
|
+
import { TxPoolV2Instrumentation } from './instrumentation.js';
|
|
25
32
|
import {
|
|
26
33
|
type AddTxsResult,
|
|
27
34
|
DEFAULT_TX_POOL_V2_CONFIG,
|
|
@@ -53,7 +60,7 @@ export class TxPoolV2Impl {
|
|
|
53
60
|
// === Dependencies ===
|
|
54
61
|
#l2BlockSource: L2BlockSource;
|
|
55
62
|
#worldStateSynchronizer: WorldStateSynchronizer;
|
|
56
|
-
#
|
|
63
|
+
#createTxValidator: TxPoolV2Dependencies['createTxValidator'];
|
|
57
64
|
|
|
58
65
|
// === In-Memory Indices ===
|
|
59
66
|
#indices: TxPoolIndices = new TxPoolIndices();
|
|
@@ -61,7 +68,11 @@ export class TxPoolV2Impl {
|
|
|
61
68
|
// === Config & Services ===
|
|
62
69
|
#config: TxPoolV2Config;
|
|
63
70
|
#archive: TxArchive;
|
|
71
|
+
#deletedPool: DeletedPool;
|
|
64
72
|
#evictionManager: EvictionManager;
|
|
73
|
+
#dateProvider: DateProvider;
|
|
74
|
+
#instrumentation: TxPoolV2Instrumentation;
|
|
75
|
+
#evictedTxHashes: Set<string> = new Set();
|
|
65
76
|
#log: Logger;
|
|
66
77
|
#callbacks: TxPoolV2Callbacks;
|
|
67
78
|
|
|
@@ -70,7 +81,9 @@ export class TxPoolV2Impl {
|
|
|
70
81
|
archiveStore: AztecAsyncKVStore,
|
|
71
82
|
deps: TxPoolV2Dependencies,
|
|
72
83
|
callbacks: TxPoolV2Callbacks,
|
|
84
|
+
telemetry: TelemetryClient,
|
|
73
85
|
config: Partial<TxPoolV2Config> = {},
|
|
86
|
+
dateProvider: DateProvider,
|
|
74
87
|
log: Logger,
|
|
75
88
|
) {
|
|
76
89
|
this.#store = store;
|
|
@@ -78,10 +91,13 @@ export class TxPoolV2Impl {
|
|
|
78
91
|
|
|
79
92
|
this.#l2BlockSource = deps.l2BlockSource;
|
|
80
93
|
this.#worldStateSynchronizer = deps.worldStateSynchronizer;
|
|
81
|
-
this.#
|
|
94
|
+
this.#createTxValidator = deps.createTxValidator;
|
|
82
95
|
|
|
83
96
|
this.#config = { ...DEFAULT_TX_POOL_V2_CONFIG, ...config };
|
|
84
97
|
this.#archive = new TxArchive(archiveStore, this.#config.archivedTxLimit, log);
|
|
98
|
+
this.#deletedPool = new DeletedPool(store, this.#txsDB, log);
|
|
99
|
+
this.#dateProvider = dateProvider;
|
|
100
|
+
this.#instrumentation = new TxPoolV2Instrumentation(telemetry, () => this.#indices.getTotalMetadataBytes());
|
|
85
101
|
this.#log = log;
|
|
86
102
|
this.#callbacks = callbacks;
|
|
87
103
|
|
|
@@ -116,7 +132,10 @@ export class TxPoolV2Impl {
|
|
|
116
132
|
* by running pre-add rules to resolve nullifier conflicts, balance checks, and pool size limits.
|
|
117
133
|
*/
|
|
118
134
|
async hydrateFromDatabase(): Promise<void> {
|
|
119
|
-
// Step
|
|
135
|
+
// Step 0: Hydrate deleted pool state
|
|
136
|
+
await this.#deletedPool.hydrateFromDatabase();
|
|
137
|
+
|
|
138
|
+
// Step 1: Load all transactions from DB (excluding soft-deleted)
|
|
120
139
|
const { loaded, errors: deserializationErrors } = await this.#loadAllTxsFromDb();
|
|
121
140
|
|
|
122
141
|
// Step 2: Check mined status for each tx
|
|
@@ -134,7 +153,10 @@ export class TxPoolV2Impl {
|
|
|
134
153
|
}
|
|
135
154
|
|
|
136
155
|
// Step 4: Validate non-mined transactions
|
|
137
|
-
const { valid, invalid } = await this.#
|
|
156
|
+
const { valid, invalid } = await this.#revalidateMetadata(
|
|
157
|
+
nonMined.map(e => e.meta),
|
|
158
|
+
'on startup',
|
|
159
|
+
);
|
|
138
160
|
|
|
139
161
|
// Step 5: Populate mined indices (these don't need conflict resolution)
|
|
140
162
|
for (const meta of mined) {
|
|
@@ -155,16 +177,43 @@ export class TxPoolV2Impl {
|
|
|
155
177
|
await this.#txsDB.delete(txHashStr);
|
|
156
178
|
}
|
|
157
179
|
});
|
|
158
|
-
this.#log.info(`Deleted ${toDelete.length} invalid/rejected transactions on startup
|
|
180
|
+
this.#log.info(`Deleted ${toDelete.length} invalid/rejected transactions on startup`, { txHashes: toDelete });
|
|
159
181
|
}
|
|
160
182
|
|
|
161
|
-
async addPendingTxs(txs: Tx[], opts: { source?: string }): Promise<AddTxsResult> {
|
|
183
|
+
async addPendingTxs(txs: Tx[], opts: { source?: string; feeComparisonOnly?: boolean }): Promise<AddTxsResult> {
|
|
162
184
|
const accepted: TxHash[] = [];
|
|
163
185
|
const ignored: TxHash[] = [];
|
|
164
186
|
const rejected: TxHash[] = [];
|
|
187
|
+
const errors = new Map<string, TxPoolRejectionError>();
|
|
165
188
|
const acceptedPending = new Set<string>();
|
|
166
189
|
|
|
190
|
+
// Phase 1: Pre-compute all throwable I/O outside the transaction.
|
|
191
|
+
// If any pre-computation throws, the entire call fails before mutations happen.
|
|
192
|
+
const precomputed = new Map<string, { meta: TxMetaData; minedBlockId: L2BlockId | undefined; isValid: boolean }>();
|
|
193
|
+
|
|
194
|
+
const validator = await this.#createTxValidator();
|
|
195
|
+
|
|
196
|
+
for (const tx of txs) {
|
|
197
|
+
const txHash = tx.getTxHash();
|
|
198
|
+
const txHashStr = txHash.toString();
|
|
199
|
+
|
|
200
|
+
const meta = await buildTxMetaData(tx);
|
|
201
|
+
const minedBlockId = await this.#getMinedBlockId(txHash);
|
|
202
|
+
|
|
203
|
+
// Validate non-mined txs (mined and pre-protected txs bypass validation inside the transaction)
|
|
204
|
+
let isValid = true;
|
|
205
|
+
if (!minedBlockId) {
|
|
206
|
+
isValid = await this.#validateMeta(meta, validator);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
precomputed.set(txHashStr, { meta, minedBlockId, isValid });
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
// Phase 2: Apply mutations inside the transaction using only pre-computed results,
|
|
213
|
+
// in-memory reads, and buffered DB writes. Nothing here can throw an unhandled exception.
|
|
167
214
|
const poolAccess = this.#createPreAddPoolAccess();
|
|
215
|
+
const preAddContext: PreAddContext | undefined =
|
|
216
|
+
opts.feeComparisonOnly !== undefined ? { feeComparisonOnly: opts.feeComparisonOnly } : undefined;
|
|
168
217
|
|
|
169
218
|
await this.#store.transactionAsync(async () => {
|
|
170
219
|
for (const tx of txs) {
|
|
@@ -177,30 +226,46 @@ export class TxPoolV2Impl {
|
|
|
177
226
|
continue;
|
|
178
227
|
}
|
|
179
228
|
|
|
180
|
-
|
|
181
|
-
const minedBlockId = await this.#getMinedBlockId(txHash);
|
|
229
|
+
const { meta, minedBlockId, isValid } = precomputed.get(txHashStr)!;
|
|
182
230
|
const preProtectedSlot = this.#indices.getProtectionSlot(txHashStr);
|
|
183
231
|
|
|
184
232
|
if (minedBlockId) {
|
|
185
233
|
// Already mined - add directly (protection already set if pre-protected)
|
|
186
|
-
await this.#addTx(tx, { mined: minedBlockId }, opts);
|
|
234
|
+
await this.#addTx(tx, { mined: minedBlockId }, opts, meta);
|
|
187
235
|
accepted.push(txHash);
|
|
188
236
|
} else if (preProtectedSlot !== undefined) {
|
|
189
237
|
// Pre-protected and not mined - add as protected (bypass validation)
|
|
190
|
-
await this.#addTx(tx, { protected: preProtectedSlot }, opts);
|
|
238
|
+
await this.#addTx(tx, { protected: preProtectedSlot }, opts, meta);
|
|
191
239
|
accepted.push(txHash);
|
|
240
|
+
} else if (!isValid) {
|
|
241
|
+
// Failed pre-computed validation
|
|
242
|
+
rejected.push(txHash);
|
|
192
243
|
} else {
|
|
193
|
-
// Regular pending tx -
|
|
194
|
-
const result = await this.#tryAddRegularPendingTx(
|
|
244
|
+
// Regular pending tx - run pre-add rules using pre-computed metadata
|
|
245
|
+
const result = await this.#tryAddRegularPendingTx(
|
|
246
|
+
tx,
|
|
247
|
+
meta,
|
|
248
|
+
opts,
|
|
249
|
+
poolAccess,
|
|
250
|
+
acceptedPending,
|
|
251
|
+
ignored,
|
|
252
|
+
errors,
|
|
253
|
+
preAddContext,
|
|
254
|
+
);
|
|
195
255
|
if (result.status === 'accepted') {
|
|
196
256
|
acceptedPending.add(txHashStr);
|
|
197
|
-
} else if (result.status === 'rejected') {
|
|
198
|
-
rejected.push(txHash);
|
|
199
257
|
} else {
|
|
200
258
|
ignored.push(txHash);
|
|
201
259
|
}
|
|
202
260
|
}
|
|
203
261
|
}
|
|
262
|
+
|
|
263
|
+
// Run post-add eviction rules for pending txs (inside transaction for atomicity)
|
|
264
|
+
if (acceptedPending.size > 0) {
|
|
265
|
+
const feePayers = Array.from(acceptedPending).map(txHash => this.#indices.getMetadata(txHash)!.feePayer);
|
|
266
|
+
const uniqueFeePayers = new Set<string>(feePayers);
|
|
267
|
+
await this.#evictionManager.evictAfterNewTxs(Array.from(acceptedPending), [...uniqueFeePayers]);
|
|
268
|
+
}
|
|
204
269
|
});
|
|
205
270
|
|
|
206
271
|
// Build final accepted list for pending txs (excludes intra-batch evictions)
|
|
@@ -208,58 +273,80 @@ export class TxPoolV2Impl {
|
|
|
208
273
|
accepted.push(TxHash.fromString(txHashStr));
|
|
209
274
|
}
|
|
210
275
|
|
|
211
|
-
//
|
|
212
|
-
if (
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
276
|
+
// Record metrics
|
|
277
|
+
if (ignored.length > 0) {
|
|
278
|
+
this.#instrumentation.recordIgnored(ignored.length);
|
|
279
|
+
}
|
|
280
|
+
if (rejected.length > 0) {
|
|
281
|
+
this.#instrumentation.recordRejected(rejected.length);
|
|
216
282
|
}
|
|
217
283
|
|
|
218
|
-
return { accepted, ignored, rejected };
|
|
284
|
+
return { accepted, ignored, rejected, ...(errors.size > 0 ? { errors } : {}) };
|
|
219
285
|
}
|
|
220
286
|
|
|
221
|
-
/**
|
|
287
|
+
/** Adds a validated pending tx, running pre-add rules and evicting conflicts. */
|
|
222
288
|
async #tryAddRegularPendingTx(
|
|
223
289
|
tx: Tx,
|
|
290
|
+
precomputedMeta: TxMetaData,
|
|
224
291
|
opts: { source?: string },
|
|
225
292
|
poolAccess: PreAddPoolAccess,
|
|
226
293
|
acceptedPending: Set<string>,
|
|
227
294
|
ignored: TxHash[],
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
// Validate transaction
|
|
233
|
-
if (!(await this.#validateTx(tx))) {
|
|
234
|
-
return { status: 'rejected' };
|
|
235
|
-
}
|
|
295
|
+
errors: Map<string, TxPoolRejectionError>,
|
|
296
|
+
preAddContext?: PreAddContext,
|
|
297
|
+
): Promise<{ status: 'accepted' | 'ignored' }> {
|
|
298
|
+
const txHashStr = tx.getTxHash().toString();
|
|
236
299
|
|
|
237
|
-
//
|
|
238
|
-
const
|
|
239
|
-
const preAddResult = await this.#evictionManager.runPreAddRules(meta, poolAccess);
|
|
300
|
+
// Run pre-add rules
|
|
301
|
+
const preAddResult = await this.#evictionManager.runPreAddRules(precomputedMeta, poolAccess, preAddContext);
|
|
240
302
|
|
|
241
303
|
if (preAddResult.shouldIgnore) {
|
|
242
|
-
this.#log.debug(`Ignoring tx ${txHashStr}: ${preAddResult.reason}`);
|
|
304
|
+
this.#log.debug(`Ignoring tx ${txHashStr}: ${preAddResult.reason?.message ?? 'unknown reason'}`);
|
|
305
|
+
if (preAddResult.reason && preAddResult.reason.code !== TxPoolRejectionCode.INTERNAL_ERROR) {
|
|
306
|
+
errors.set(txHashStr, preAddResult.reason);
|
|
307
|
+
}
|
|
243
308
|
return { status: 'ignored' };
|
|
244
309
|
}
|
|
245
310
|
|
|
246
|
-
// Evict conflicts
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
311
|
+
// Evict conflicts, grouped by rule name for metrics
|
|
312
|
+
if (preAddResult.evictions && preAddResult.evictions.length > 0) {
|
|
313
|
+
const byReason = new Map<string, string[]>();
|
|
314
|
+
for (const { txHash: evictHash, reason } of preAddResult.evictions) {
|
|
315
|
+
const group = byReason.get(reason);
|
|
316
|
+
if (group) {
|
|
317
|
+
group.push(evictHash);
|
|
318
|
+
} else {
|
|
319
|
+
byReason.set(reason, [evictHash]);
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
for (const [reason, hashes] of byReason) {
|
|
323
|
+
await this.#evictTxs(hashes, reason);
|
|
254
324
|
}
|
|
325
|
+
for (const evictHashStr of preAddResult.txHashesToEvict) {
|
|
326
|
+
this.#log.debug(`Evicted tx ${evictHashStr} due to higher-fee tx ${txHashStr}`, {
|
|
327
|
+
evictedTxHash: evictHashStr,
|
|
328
|
+
replacementTxHash: txHashStr,
|
|
329
|
+
});
|
|
330
|
+
if (acceptedPending.has(evictHashStr)) {
|
|
331
|
+
// Evicted tx was from this batch - mark as ignored in result
|
|
332
|
+
acceptedPending.delete(evictHashStr);
|
|
333
|
+
ignored.push(TxHash.fromString(evictHashStr));
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
// Randomly drop the transaction for testing purposes (report as accepted so it propagates)
|
|
339
|
+
if (this.#config.dropTransactionsProbability > 0 && Math.random() < this.#config.dropTransactionsProbability) {
|
|
340
|
+
this.#log.debug(`Dropping tx ${txHashStr} (simulated drop for testing)`);
|
|
341
|
+
return { status: 'accepted' };
|
|
255
342
|
}
|
|
256
343
|
|
|
257
344
|
// Add the transaction
|
|
258
|
-
await this.#addTx(tx, 'pending', opts);
|
|
345
|
+
await this.#addTx(tx, 'pending', opts, precomputedMeta);
|
|
259
346
|
return { status: 'accepted' };
|
|
260
347
|
}
|
|
261
348
|
|
|
262
|
-
async canAddPendingTx(tx: Tx): Promise<'accepted' | 'ignored'
|
|
349
|
+
async canAddPendingTx(tx: Tx): Promise<'accepted' | 'ignored'> {
|
|
263
350
|
const txHashStr = tx.getTxHash().toString();
|
|
264
351
|
|
|
265
352
|
// Check if already in pool
|
|
@@ -267,13 +354,7 @@ export class TxPoolV2Impl {
|
|
|
267
354
|
return 'ignored';
|
|
268
355
|
}
|
|
269
356
|
|
|
270
|
-
//
|
|
271
|
-
const validationResult = await this.#pendingTxValidator.validateTx(tx);
|
|
272
|
-
if (validationResult.result !== 'valid') {
|
|
273
|
-
return 'rejected';
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
// Build metadata and use pre-add rules
|
|
357
|
+
// Build metadata and check pre-add rules
|
|
277
358
|
const meta = await buildTxMetaData(tx);
|
|
278
359
|
const poolAccess = this.#createPreAddPoolAccess();
|
|
279
360
|
const preAddResult = await this.#evictionManager.runPreAddRules(meta, poolAccess);
|
|
@@ -311,23 +392,58 @@ export class TxPoolV2Impl {
|
|
|
311
392
|
});
|
|
312
393
|
}
|
|
313
394
|
|
|
314
|
-
protectTxs(txHashes: TxHash[], block: BlockHeader): TxHash[] {
|
|
395
|
+
async protectTxs(txHashes: TxHash[], block: BlockHeader): Promise<TxHash[]> {
|
|
315
396
|
const slotNumber = block.globalVariables.slotNumber;
|
|
316
397
|
const missing: TxHash[] = [];
|
|
398
|
+
let softDeletedHits = 0;
|
|
399
|
+
let missingPreviouslyEvicted = 0;
|
|
317
400
|
|
|
318
|
-
|
|
319
|
-
const
|
|
401
|
+
await this.#store.transactionAsync(async () => {
|
|
402
|
+
for (const txHash of txHashes) {
|
|
403
|
+
const txHashStr = txHash.toString();
|
|
320
404
|
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
405
|
+
if (this.#indices.has(txHashStr)) {
|
|
406
|
+
// Update protection for existing tx
|
|
407
|
+
this.#indices.updateProtection(txHashStr, slotNumber);
|
|
408
|
+
} else if (this.#deletedPool.isSoftDeleted(txHashStr)) {
|
|
409
|
+
// Resurrect soft-deleted tx as protected
|
|
410
|
+
const buffer = await this.#txsDB.getAsync(txHashStr);
|
|
411
|
+
if (buffer) {
|
|
412
|
+
const tx = Tx.fromBuffer(buffer);
|
|
413
|
+
await this.#addTx(tx, { protected: slotNumber });
|
|
414
|
+
softDeletedHits++;
|
|
415
|
+
} else {
|
|
416
|
+
// Data missing despite soft-delete flag — treat as truly missing
|
|
417
|
+
this.#indices.setProtection(txHashStr, slotNumber);
|
|
418
|
+
missing.push(txHash);
|
|
419
|
+
}
|
|
420
|
+
} else {
|
|
421
|
+
// Truly missing — pre-record protection for tx we don't have yet
|
|
422
|
+
this.#indices.setProtection(txHashStr, slotNumber);
|
|
423
|
+
missing.push(txHash);
|
|
424
|
+
if (this.#evictedTxHashes.has(txHashStr)) {
|
|
425
|
+
missingPreviouslyEvicted++;
|
|
426
|
+
}
|
|
427
|
+
}
|
|
328
428
|
}
|
|
429
|
+
});
|
|
430
|
+
|
|
431
|
+
// Record metrics
|
|
432
|
+
if (softDeletedHits > 0) {
|
|
433
|
+
this.#instrumentation.recordSoftDeletedHits(softDeletedHits);
|
|
434
|
+
}
|
|
435
|
+
if (missing.length > 0) {
|
|
436
|
+
this.#log.debug(`protectTxs missing tx hashes: ${missing.map(h => h.toString()).join(', ')}`);
|
|
437
|
+
this.#instrumentation.recordMissingOnProtect(missing.length);
|
|
438
|
+
}
|
|
439
|
+
if (missingPreviouslyEvicted > 0) {
|
|
440
|
+
this.#instrumentation.recordMissingPreviouslyEvicted(missingPreviouslyEvicted);
|
|
329
441
|
}
|
|
330
442
|
|
|
443
|
+
this.#log.info(
|
|
444
|
+
`Protected ${txHashes.length} txs, missing: ${missing.length}, soft-deleted hits: ${softDeletedHits}`,
|
|
445
|
+
);
|
|
446
|
+
|
|
331
447
|
return missing;
|
|
332
448
|
}
|
|
333
449
|
|
|
@@ -347,6 +463,7 @@ export class TxPoolV2Impl {
|
|
|
347
463
|
// Add new mined tx (callback emitted by #addTx)
|
|
348
464
|
await this.#addTx(tx, { mined: blockId }, opts);
|
|
349
465
|
}
|
|
466
|
+
await this.#deletedPool.clearIfMinedHigher(txHashStr, blockId.number);
|
|
350
467
|
}
|
|
351
468
|
});
|
|
352
469
|
}
|
|
@@ -370,53 +487,63 @@ export class TxPoolV2Impl {
|
|
|
370
487
|
}
|
|
371
488
|
}
|
|
372
489
|
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
490
|
+
await this.#store.transactionAsync(async () => {
|
|
491
|
+
// Step 4: Mark txs as mined (only those we have in the pool)
|
|
492
|
+
for (const meta of found) {
|
|
493
|
+
this.#indices.markAsMined(meta, blockId);
|
|
494
|
+
await this.#deletedPool.clearIfMinedHigher(meta.txHash, blockId.number);
|
|
495
|
+
}
|
|
377
496
|
|
|
378
|
-
|
|
379
|
-
|
|
497
|
+
// Step 5: Run post-event eviction rules (inside transaction for atomicity)
|
|
498
|
+
await this.#evictionManager.evictAfterNewBlock(block.header, nullifiers, feePayers);
|
|
499
|
+
});
|
|
380
500
|
|
|
381
501
|
this.#log.info(`Marked ${found.length} txs as mined in block ${blockId.number}`);
|
|
382
502
|
}
|
|
383
503
|
|
|
384
504
|
async prepareForSlot(slotNumber: SlotNumber): Promise<void> {
|
|
385
|
-
|
|
386
|
-
|
|
505
|
+
await this.#store.transactionAsync(async () => {
|
|
506
|
+
// Step 0: Clean up slot-deleted txs from previous slots
|
|
507
|
+
await this.#deletedPool.cleanupSlotDeleted(slotNumber);
|
|
387
508
|
|
|
388
|
-
|
|
389
|
-
|
|
509
|
+
// Step 1: Find expired protected txs
|
|
510
|
+
const expiredProtected = this.#indices.findExpiredProtectedTxs(slotNumber);
|
|
390
511
|
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
if (txsToRestore.length === 0) {
|
|
394
|
-
return;
|
|
395
|
-
}
|
|
512
|
+
// Step 2: Clear protection for all expired entries (including those without metadata)
|
|
513
|
+
this.#indices.clearProtection(expiredProtected);
|
|
396
514
|
|
|
397
|
-
|
|
515
|
+
// Step 3: Filter to only txs that have metadata and are not mined
|
|
516
|
+
const txsToRestore = this.#indices.filterRestorable(expiredProtected);
|
|
517
|
+
if (txsToRestore.length === 0) {
|
|
518
|
+
this.#log.debug(`Preparing for slot ${slotNumber}, no txs to unprotect`);
|
|
519
|
+
return;
|
|
520
|
+
}
|
|
398
521
|
|
|
399
|
-
|
|
400
|
-
const { valid, invalid } = await this.#loadAndValidateTxs(txsToRestore, 'during prepareForSlot');
|
|
522
|
+
this.#log.info(`Preparing for slot ${slotNumber}: unprotecting ${txsToRestore.length} txs`);
|
|
401
523
|
|
|
402
|
-
|
|
403
|
-
|
|
524
|
+
// Step 4: Validate for pending pool
|
|
525
|
+
const { valid, invalid } = await this.#revalidateMetadata(txsToRestore, 'during prepareForSlot');
|
|
404
526
|
|
|
405
|
-
|
|
406
|
-
|
|
527
|
+
// Step 5: Resolve nullifier conflicts and add winners to pending indices
|
|
528
|
+
const { added, toEvict } = this.#applyNullifierConflictResolution(valid);
|
|
407
529
|
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
530
|
+
// Step 6: Delete invalid txs and evict conflict losers
|
|
531
|
+
await this.#deleteTxsBatch(invalid);
|
|
532
|
+
await this.#evictTxs(toEvict, 'NullifierConflict');
|
|
533
|
+
|
|
534
|
+
// Step 7: Run eviction rules (enforce pool size limit)
|
|
535
|
+
if (added.length > 0) {
|
|
536
|
+
const feePayers = added.map(meta => meta.feePayer);
|
|
537
|
+
const uniqueFeePayers = new Set<string>(feePayers);
|
|
538
|
+
await this.#evictionManager.evictAfterNewTxs(
|
|
539
|
+
added.map(m => m.txHash),
|
|
540
|
+
[...uniqueFeePayers],
|
|
541
|
+
);
|
|
542
|
+
}
|
|
543
|
+
});
|
|
417
544
|
}
|
|
418
545
|
|
|
419
|
-
async handlePrunedBlocks(latestBlock: L2BlockId): Promise<void> {
|
|
546
|
+
async handlePrunedBlocks(latestBlock: L2BlockId, options?: { deleteAllTxs?: boolean }): Promise<void> {
|
|
420
547
|
// Step 1: Find transactions mined after the prune point
|
|
421
548
|
const txsToUnmine = this.#indices.findTxsMinedAfter(latestBlock.number);
|
|
422
549
|
if (txsToUnmine.length === 0) {
|
|
@@ -426,64 +553,99 @@ export class TxPoolV2Impl {
|
|
|
426
553
|
|
|
427
554
|
this.#log.info(`Handling prune to block ${latestBlock.number}: un-mining ${txsToUnmine.length} txs`);
|
|
428
555
|
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
556
|
+
await this.#store.transactionAsync(async () => {
|
|
557
|
+
// Step 2: Mark ALL un-mined txs with their original mined block number
|
|
558
|
+
// This ensures they get soft-deleted if removed later, and only hard-deleted
|
|
559
|
+
// when their original mined block is finalized
|
|
560
|
+
await this.#deletedPool.markFromPrunedBlock(
|
|
561
|
+
txsToUnmine.map(m => ({
|
|
562
|
+
txHash: m.txHash,
|
|
563
|
+
minedAtBlock: BlockNumber(m.minedL2BlockId!.number),
|
|
564
|
+
})),
|
|
565
|
+
);
|
|
433
566
|
|
|
434
|
-
|
|
435
|
-
|
|
567
|
+
// Step 3: Unmine - clear mined status from metadata
|
|
568
|
+
for (const meta of txsToUnmine) {
|
|
569
|
+
this.#indices.markAsUnmined(meta);
|
|
570
|
+
}
|
|
436
571
|
|
|
437
|
-
|
|
438
|
-
|
|
572
|
+
// If deleteAllTxs is set (epoch prune), delete all un-mined txs and return early
|
|
573
|
+
if (options?.deleteAllTxs) {
|
|
574
|
+
const allTxHashes = txsToUnmine.map(m => m.txHash);
|
|
575
|
+
await this.#deleteTxsBatch(allTxHashes);
|
|
576
|
+
this.#log.info(
|
|
577
|
+
`Handled prune to block ${latestBlock.number} with deleteAllTxs: deleted ${allTxHashes.length} txs`,
|
|
578
|
+
);
|
|
579
|
+
return;
|
|
580
|
+
}
|
|
439
581
|
|
|
440
|
-
|
|
441
|
-
|
|
582
|
+
// Step 4: Filter out protected txs (they'll be handled by prepareForSlot)
|
|
583
|
+
const unprotectedTxs = this.#indices.filterUnprotected(txsToUnmine);
|
|
442
584
|
|
|
443
|
-
|
|
444
|
-
|
|
585
|
+
// Step 5: Validate for pending pool
|
|
586
|
+
const { valid, invalid } = await this.#revalidateMetadata(unprotectedTxs, 'during handlePrunedBlocks');
|
|
587
|
+
|
|
588
|
+
// Step 6: Resolve nullifier conflicts and add winners to pending indices
|
|
589
|
+
const { toEvict } = this.#applyNullifierConflictResolution(valid);
|
|
590
|
+
|
|
591
|
+
// Step 7: Delete invalid txs and evict conflict losers
|
|
592
|
+
await this.#deleteTxsBatch(invalid);
|
|
593
|
+
await this.#evictTxs(toEvict, 'NullifierConflict');
|
|
594
|
+
|
|
595
|
+
this.#log.info(
|
|
596
|
+
`Handled prune to block ${latestBlock.number}: ${valid.length} txs restored to pending, ${invalid.length} invalid, ${toEvict.length} evicted due to nullifier conflicts`,
|
|
597
|
+
{ txHashesRestored: valid.map(m => m.txHash), txHashesInvalid: invalid, txHashesEvicted: toEvict },
|
|
598
|
+
);
|
|
445
599
|
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
600
|
+
// Step 8: Run eviction rules for ALL pending txs (not just restored ones)
|
|
601
|
+
// This handles cases like existing pending txs with invalid fee payer balances
|
|
602
|
+
await this.#evictionManager.evictAfterChainPrune(latestBlock.number);
|
|
603
|
+
});
|
|
449
604
|
}
|
|
450
605
|
|
|
451
606
|
async handleFailedExecution(txHashes: TxHash[]): Promise<void> {
|
|
452
|
-
|
|
453
|
-
|
|
607
|
+
await this.#store.transactionAsync(async () => {
|
|
608
|
+
await this.#deleteTxsBatch(txHashes.map(h => h.toString()));
|
|
609
|
+
});
|
|
454
610
|
|
|
455
|
-
this.#log.info(`Deleted ${txHashes.length} failed txs
|
|
611
|
+
this.#log.info(`Deleted ${txHashes.length} failed txs`, { txHashes: txHashes.map(h => h.toString()) });
|
|
456
612
|
}
|
|
457
613
|
|
|
458
614
|
async handleFinalizedBlock(block: BlockHeader): Promise<void> {
|
|
459
615
|
const blockNumber = block.globalVariables.blockNumber;
|
|
460
616
|
|
|
461
|
-
// Step 1: Find txs
|
|
462
|
-
const
|
|
463
|
-
if (txsToFinalize.length === 0) {
|
|
464
|
-
return;
|
|
465
|
-
}
|
|
617
|
+
// Step 1: Find mined txs at or before finalized block
|
|
618
|
+
const minedTxsToFinalize = this.#indices.findTxsMinedAtOrBefore(blockNumber);
|
|
466
619
|
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
const
|
|
472
|
-
|
|
473
|
-
|
|
620
|
+
await this.#store.transactionAsync(async () => {
|
|
621
|
+
// Step 2: Collect mined txs for archiving (before deletion)
|
|
622
|
+
const txsToArchive: Tx[] = [];
|
|
623
|
+
if (this.#archive.isEnabled()) {
|
|
624
|
+
for (const txHashStr of minedTxsToFinalize) {
|
|
625
|
+
const buffer = await this.#txsDB.getAsync(txHashStr);
|
|
626
|
+
if (buffer) {
|
|
627
|
+
txsToArchive.push(Tx.fromBuffer(buffer));
|
|
628
|
+
}
|
|
474
629
|
}
|
|
475
630
|
}
|
|
476
|
-
}
|
|
477
631
|
|
|
478
|
-
|
|
479
|
-
|
|
632
|
+
// Step 3: Delete mined txs from active pool
|
|
633
|
+
await this.#deleteTxsBatch(minedTxsToFinalize);
|
|
480
634
|
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
635
|
+
// Step 4: Finalize soft-deleted txs
|
|
636
|
+
await this.#deletedPool.finalizeBlock(blockNumber);
|
|
637
|
+
|
|
638
|
+
// Step 5: Archive mined txs
|
|
639
|
+
if (txsToArchive.length > 0) {
|
|
640
|
+
await this.#archive.archiveTxs(txsToArchive);
|
|
641
|
+
}
|
|
642
|
+
});
|
|
485
643
|
|
|
486
|
-
|
|
644
|
+
if (minedTxsToFinalize.length > 0) {
|
|
645
|
+
this.#log.info(`Finalized ${minedTxsToFinalize.length} mined txs from blocks up to ${blockNumber}`, {
|
|
646
|
+
txHashes: minedTxsToFinalize,
|
|
647
|
+
});
|
|
648
|
+
}
|
|
487
649
|
}
|
|
488
650
|
|
|
489
651
|
// === Query Methods ===
|
|
@@ -503,21 +665,36 @@ export class TxPoolV2Impl {
|
|
|
503
665
|
}
|
|
504
666
|
|
|
505
667
|
hasTxs(txHashes: TxHash[]): boolean[] {
|
|
506
|
-
return txHashes.map(h =>
|
|
668
|
+
return txHashes.map(h => {
|
|
669
|
+
const hashStr = h.toString();
|
|
670
|
+
return this.#indices.has(hashStr) || this.#deletedPool.isSoftDeleted(hashStr);
|
|
671
|
+
});
|
|
507
672
|
}
|
|
508
673
|
|
|
509
674
|
getTxStatus(txHash: TxHash): TxState | undefined {
|
|
510
|
-
const
|
|
511
|
-
|
|
512
|
-
|
|
675
|
+
const txHashStr = txHash.toString();
|
|
676
|
+
const meta = this.#indices.getMetadata(txHashStr);
|
|
677
|
+
if (meta) {
|
|
678
|
+
return this.#indices.getTxState(meta);
|
|
513
679
|
}
|
|
514
|
-
|
|
680
|
+
// Check if soft-deleted
|
|
681
|
+
if (this.#deletedPool.isSoftDeleted(txHashStr)) {
|
|
682
|
+
return 'deleted';
|
|
683
|
+
}
|
|
684
|
+
return undefined;
|
|
515
685
|
}
|
|
516
686
|
|
|
517
687
|
getPendingTxHashes(): TxHash[] {
|
|
518
688
|
return [...this.#indices.iteratePendingByPriority('desc')].map(hash => TxHash.fromString(hash));
|
|
519
689
|
}
|
|
520
690
|
|
|
691
|
+
getEligiblePendingTxHashes(): TxHash[] {
|
|
692
|
+
const maxReceivedAt = this.#dateProvider.now() - this.#config.minTxPoolAgeMs;
|
|
693
|
+
return [...this.#indices.iterateEligiblePendingByPriority('desc', maxReceivedAt)].map(hash =>
|
|
694
|
+
TxHash.fromString(hash),
|
|
695
|
+
);
|
|
696
|
+
}
|
|
697
|
+
|
|
521
698
|
getPendingTxCount(): number {
|
|
522
699
|
return this.#indices.getPendingTxCount();
|
|
523
700
|
}
|
|
@@ -562,6 +739,9 @@ export class TxPoolV2Impl {
|
|
|
562
739
|
this.#config.archivedTxLimit = config.archivedTxLimit;
|
|
563
740
|
this.#archive.updateLimit(config.archivedTxLimit);
|
|
564
741
|
}
|
|
742
|
+
if (config.minTxPoolAgeMs !== undefined) {
|
|
743
|
+
this.#config.minTxPoolAgeMs = config.minTxPoolAgeMs;
|
|
744
|
+
}
|
|
565
745
|
// Update eviction rules with new config
|
|
566
746
|
this.#evictionManager.updateConfig(config);
|
|
567
747
|
}
|
|
@@ -579,8 +759,17 @@ export class TxPoolV2Impl {
|
|
|
579
759
|
|
|
580
760
|
// === Metrics ===
|
|
581
761
|
|
|
582
|
-
countTxs(): {
|
|
583
|
-
|
|
762
|
+
countTxs(): {
|
|
763
|
+
pending: number;
|
|
764
|
+
protected: number;
|
|
765
|
+
mined: number;
|
|
766
|
+
softDeleted: number;
|
|
767
|
+
totalMetadataBytes: number;
|
|
768
|
+
} {
|
|
769
|
+
return {
|
|
770
|
+
...this.#indices.countTxs(),
|
|
771
|
+
softDeleted: this.#deletedPool.getSoftDeletedCount(),
|
|
772
|
+
};
|
|
584
773
|
}
|
|
585
774
|
|
|
586
775
|
// ============================================================================
|
|
@@ -595,11 +784,14 @@ export class TxPoolV2Impl {
|
|
|
595
784
|
tx: Tx,
|
|
596
785
|
state: 'pending' | { protected: SlotNumber } | { mined: L2BlockId },
|
|
597
786
|
opts: { source?: string } = {},
|
|
787
|
+
precomputedMeta?: TxMetaData,
|
|
598
788
|
): Promise<TxMetaData> {
|
|
599
789
|
const txHashStr = tx.getTxHash().toString();
|
|
600
|
-
const meta = await buildTxMetaData(tx);
|
|
790
|
+
const meta = precomputedMeta ?? (await buildTxMetaData(tx));
|
|
791
|
+
meta.receivedAt = this.#dateProvider.now();
|
|
601
792
|
|
|
602
793
|
await this.#txsDB.set(txHashStr, tx.toBuffer());
|
|
794
|
+
await this.#deletedPool.clearSoftDeleted(txHashStr);
|
|
603
795
|
this.#callbacks.onTxsAdded([tx], opts);
|
|
604
796
|
|
|
605
797
|
if (state === 'pending') {
|
|
@@ -612,9 +804,11 @@ export class TxPoolV2Impl {
|
|
|
612
804
|
}
|
|
613
805
|
|
|
614
806
|
const stateStr = typeof state === 'string' ? state : Object.keys(state)[0];
|
|
615
|
-
this.#log.
|
|
807
|
+
this.#log.debug(`Added tx ${txHashStr} as ${stateStr}`, {
|
|
616
808
|
eventName: 'tx-added-to-pool',
|
|
809
|
+
txHash: txHashStr,
|
|
617
810
|
state: stateStr,
|
|
811
|
+
source: opts.source,
|
|
618
812
|
});
|
|
619
813
|
|
|
620
814
|
return meta;
|
|
@@ -624,10 +818,15 @@ export class TxPoolV2Impl {
|
|
|
624
818
|
* Deletes a transaction from both indices and DB.
|
|
625
819
|
* Emits onTxsRemoved callback immediately after DB delete.
|
|
626
820
|
*/
|
|
821
|
+
/**
|
|
822
|
+
* Deletes a transaction from the pool.
|
|
823
|
+
* Delegates to DeletedPool which decides soft vs hard delete based on whether
|
|
824
|
+
* the tx is from a pruned block.
|
|
825
|
+
*/
|
|
627
826
|
async #deleteTx(txHashStr: string): Promise<void> {
|
|
628
827
|
this.#indices.remove(txHashStr);
|
|
629
|
-
await this.#txsDB.delete(txHashStr);
|
|
630
828
|
this.#callbacks.onTxsRemoved([txHashStr]);
|
|
829
|
+
await this.#deletedPool.deleteTx(txHashStr);
|
|
631
830
|
}
|
|
632
831
|
|
|
633
832
|
/** Deletes a batch of transactions, emitting callbacks individually for each. */
|
|
@@ -637,68 +836,63 @@ export class TxPoolV2Impl {
|
|
|
637
836
|
}
|
|
638
837
|
}
|
|
639
838
|
|
|
839
|
+
/** Evicts transactions: records eviction metric with reason, caches hashes, then deletes. */
|
|
840
|
+
async #evictTxs(txHashes: string[], reason: string): Promise<void> {
|
|
841
|
+
if (txHashes.length === 0) {
|
|
842
|
+
return;
|
|
843
|
+
}
|
|
844
|
+
this.#instrumentation.recordEvictions(txHashes.length, reason);
|
|
845
|
+
for (const txHashStr of txHashes) {
|
|
846
|
+
this.#log.debug(`Evicting tx ${txHashStr}`, { txHash: txHashStr, reason });
|
|
847
|
+
this.#addToEvictedCache(txHashStr);
|
|
848
|
+
}
|
|
849
|
+
await this.#deleteTxsBatch(txHashes);
|
|
850
|
+
}
|
|
851
|
+
|
|
852
|
+
/** Adds a tx hash to the bounded evicted cache, evicting the oldest entry if at capacity. */
|
|
853
|
+
#addToEvictedCache(txHashStr: string): void {
|
|
854
|
+
if (this.#evictedTxHashes.size >= this.#config.evictedTxCacheSize) {
|
|
855
|
+
// FIFO eviction: remove the first (oldest) entry
|
|
856
|
+
const oldest = this.#evictedTxHashes.values().next().value!;
|
|
857
|
+
this.#evictedTxHashes.delete(oldest);
|
|
858
|
+
}
|
|
859
|
+
this.#evictedTxHashes.add(txHashStr);
|
|
860
|
+
}
|
|
861
|
+
|
|
640
862
|
// ============================================================================
|
|
641
863
|
// PRIVATE HELPERS - Validation & Conflict Resolution
|
|
642
864
|
// ============================================================================
|
|
643
865
|
|
|
644
|
-
/** Validates
|
|
645
|
-
async #
|
|
646
|
-
const
|
|
866
|
+
/** Validates transaction metadata, returning true if valid */
|
|
867
|
+
async #validateMeta(meta: TxMetaData, validator?: TxValidator<TxMetaData>, context?: string): Promise<boolean> {
|
|
868
|
+
const txValidator = validator ?? (await this.#createTxValidator());
|
|
869
|
+
const result = await txValidator.validateTx(meta);
|
|
647
870
|
if (result.result !== 'valid') {
|
|
648
871
|
const contextStr = context ? ` ${context}` : '';
|
|
649
|
-
this.#log.info(`Tx ${
|
|
872
|
+
this.#log.info(`Tx ${meta.txHash}${contextStr} failed validation: ${result.reason?.join(', ')}`);
|
|
650
873
|
return false;
|
|
651
874
|
}
|
|
652
875
|
return true;
|
|
653
876
|
}
|
|
654
877
|
|
|
655
|
-
/**
|
|
656
|
-
async #
|
|
657
|
-
|
|
658
|
-
const missing: string[] = [];
|
|
659
|
-
|
|
660
|
-
for (const meta of metas) {
|
|
661
|
-
const buffer = await this.#txsDB.getAsync(meta.txHash);
|
|
662
|
-
if (!buffer) {
|
|
663
|
-
this.#log.warn(`Tx ${meta.txHash} not found in DB`);
|
|
664
|
-
missing.push(meta.txHash);
|
|
665
|
-
continue;
|
|
666
|
-
}
|
|
667
|
-
loaded.push({ tx: Tx.fromBuffer(buffer), meta });
|
|
668
|
-
}
|
|
669
|
-
|
|
670
|
-
return { loaded, missing };
|
|
671
|
-
}
|
|
672
|
-
|
|
673
|
-
/** Validates a batch of transactions, returning valid and invalid groups */
|
|
674
|
-
async #validateTxBatch(
|
|
675
|
-
txs: { tx: Tx; meta: TxMetaData }[],
|
|
878
|
+
/** Validates metadata directly */
|
|
879
|
+
async #revalidateMetadata(
|
|
880
|
+
metas: TxMetaData[],
|
|
676
881
|
context?: string,
|
|
677
882
|
): Promise<{ valid: TxMetaData[]; invalid: string[] }> {
|
|
678
883
|
const valid: TxMetaData[] = [];
|
|
679
884
|
const invalid: string[] = [];
|
|
680
|
-
|
|
681
|
-
for (const
|
|
682
|
-
if (await this.#
|
|
885
|
+
const validator = await this.#createTxValidator();
|
|
886
|
+
for (const meta of metas) {
|
|
887
|
+
if (await this.#validateMeta(meta, validator, context)) {
|
|
683
888
|
valid.push(meta);
|
|
684
889
|
} else {
|
|
685
890
|
invalid.push(meta.txHash);
|
|
686
891
|
}
|
|
687
892
|
}
|
|
688
|
-
|
|
689
893
|
return { valid, invalid };
|
|
690
894
|
}
|
|
691
895
|
|
|
692
|
-
/** Loads transactions from DB and validates them */
|
|
693
|
-
async #loadAndValidateTxs(
|
|
694
|
-
metas: TxMetaData[],
|
|
695
|
-
context?: string,
|
|
696
|
-
): Promise<{ valid: TxMetaData[]; invalid: string[] }> {
|
|
697
|
-
const { loaded, missing } = await this.#loadTxsFromDb(metas);
|
|
698
|
-
const { valid, invalid } = await this.#validateTxBatch(loaded, context);
|
|
699
|
-
return { valid, invalid: [...missing, ...invalid] };
|
|
700
|
-
}
|
|
701
|
-
|
|
702
896
|
/**
|
|
703
897
|
* Resolves nullifier conflicts between incoming txs and existing pending txs.
|
|
704
898
|
* Modifies the pending indices during iteration to maintain consistent state
|
|
@@ -768,6 +962,11 @@ export class TxPoolV2Impl {
|
|
|
768
962
|
const errors: string[] = [];
|
|
769
963
|
|
|
770
964
|
for await (const [txHashStr, buffer] of this.#txsDB.entriesAsync()) {
|
|
965
|
+
// Skip soft-deleted transactions - they stay in DB but not in indices
|
|
966
|
+
if (this.#deletedPool.isSoftDeleted(txHashStr)) {
|
|
967
|
+
continue;
|
|
968
|
+
}
|
|
969
|
+
|
|
771
970
|
try {
|
|
772
971
|
const tx = Tx.fromBuffer(buffer);
|
|
773
972
|
const meta = await buildTxMetaData(tx);
|
|
@@ -815,7 +1014,9 @@ export class TxPoolV2Impl {
|
|
|
815
1014
|
if (preAddResult.shouldIgnore) {
|
|
816
1015
|
// Transaction rejected - mark for deletion from DB
|
|
817
1016
|
rejected.push(meta.txHash);
|
|
818
|
-
this.#log.debug(
|
|
1017
|
+
this.#log.debug(
|
|
1018
|
+
`Rejected tx ${meta.txHash} during rebuild: ${preAddResult.reason?.message ?? 'unknown reason'}`,
|
|
1019
|
+
);
|
|
819
1020
|
continue;
|
|
820
1021
|
}
|
|
821
1022
|
|
|
@@ -851,7 +1052,7 @@ export class TxPoolV2Impl {
|
|
|
851
1052
|
getFeePayerPendingTxs: (feePayer: string) => this.#indices.getFeePayerPendingTxs(feePayer),
|
|
852
1053
|
getPendingTxCount: () => this.#indices.getPendingTxCount(),
|
|
853
1054
|
getLowestPriorityPending: (limit: number) => this.#indices.getLowestPriorityPending(limit),
|
|
854
|
-
deleteTxs: (txHashes: string[]) => this.#
|
|
1055
|
+
deleteTxs: (txHashes: string[], reason?: string) => this.#evictTxs(txHashes, reason ?? 'unknown'),
|
|
855
1056
|
};
|
|
856
1057
|
}
|
|
857
1058
|
|