@aztec/p2p 0.0.1-commit.aada20e3 → 0.0.1-commit.b2a5d0dd1
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/README.md +129 -3
- package/dest/client/factory.d.ts +12 -11
- package/dest/client/factory.d.ts.map +1 -1
- package/dest/client/factory.js +55 -16
- package/dest/client/interface.d.ts +54 -34
- package/dest/client/interface.d.ts.map +1 -1
- package/dest/client/p2p_client.d.ts +41 -52
- package/dest/client/p2p_client.d.ts.map +1 -1
- package/dest/client/p2p_client.js +179 -226
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.js +24 -11
- package/dest/config.d.ts +133 -92
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +109 -40
- package/dest/errors/p2p-service.error.d.ts +9 -0
- package/dest/errors/p2p-service.error.d.ts.map +1 -0
- package/dest/errors/p2p-service.error.js +10 -0
- 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 -2
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +1 -1
- package/dest/mem_pools/attestation_pool/attestation_pool.d.ts +106 -88
- package/dest/mem_pools/attestation_pool/attestation_pool.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/attestation_pool.js +448 -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 -3
- 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 +4 -2
- package/dest/mem_pools/instrumentation.d.ts.map +1 -1
- package/dest/mem_pools/instrumentation.js +16 -14
- package/dest/mem_pools/interface.d.ts +5 -5
- package/dest/mem_pools/interface.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_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 +7 -3
- 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 +3 -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 +2 -1
- package/dest/mem_pools/tx_pool_v2/eviction/insufficient_fee_per_gas_eviction_rule.d.ts +16 -0
- package/dest/mem_pools/tx_pool_v2/eviction/insufficient_fee_per_gas_eviction_rule.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/eviction/insufficient_fee_per_gas_eviction_rule.js +62 -0
- package/dest/mem_pools/tx_pool_v2/eviction/interfaces.d.ts +54 -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 +9 -7
- 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 +16 -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 +3 -3
- 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 +37 -12
- package/dest/mem_pools/tx_pool_v2/interfaces.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/interfaces.js +5 -1
- package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts +81 -15
- package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/tx_metadata.js +147 -18
- package/dest/mem_pools/tx_pool_v2/tx_pool_indices.d.ts +108 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_indices.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_indices.js +337 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts +12 -5
- 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 +23 -6
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts +14 -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 +477 -594
- package/dest/msg_validators/attestation_validator/attestation_validator.d.ts +5 -2
- package/dest/msg_validators/attestation_validator/attestation_validator.d.ts.map +1 -1
- package/dest/msg_validators/attestation_validator/attestation_validator.js +20 -11
- package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.d.ts +5 -3
- package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.d.ts.map +1 -1
- package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.js +2 -2
- package/dest/msg_validators/clock_tolerance.d.ts +12 -1
- package/dest/msg_validators/clock_tolerance.d.ts.map +1 -1
- package/dest/msg_validators/clock_tolerance.js +54 -3
- package/dest/msg_validators/proposal_validator/block_proposal_validator.d.ts +7 -4
- package/dest/msg_validators/proposal_validator/block_proposal_validator.d.ts.map +1 -1
- package/dest/msg_validators/proposal_validator/block_proposal_validator.js +10 -2
- package/dest/msg_validators/proposal_validator/checkpoint_proposal_validator.d.ts +7 -4
- package/dest/msg_validators/proposal_validator/checkpoint_proposal_validator.d.ts.map +1 -1
- package/dest/msg_validators/proposal_validator/checkpoint_proposal_validator.js +16 -2
- package/dest/msg_validators/proposal_validator/proposal_validator.d.ts +15 -8
- package/dest/msg_validators/proposal_validator/proposal_validator.d.ts.map +1 -1
- package/dest/msg_validators/proposal_validator/proposal_validator.js +67 -47
- 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/allowed_public_setup.d.ts +2 -1
- package/dest/msg_validators/tx_validator/allowed_public_setup.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/allowed_public_setup.js +24 -20
- package/dest/msg_validators/tx_validator/allowed_setup_helpers.d.ts +17 -0
- package/dest/msg_validators/tx_validator/allowed_setup_helpers.d.ts.map +1 -0
- package/dest/msg_validators/tx_validator/allowed_setup_helpers.js +24 -0
- package/dest/msg_validators/tx_validator/archive_cache.js +1 -1
- 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/contract_instance_validator.d.ts +9 -0
- package/dest/msg_validators/tx_validator/contract_instance_validator.d.ts.map +1 -0
- package/dest/msg_validators/tx_validator/contract_instance_validator.js +48 -0
- package/dest/msg_validators/tx_validator/data_validator.d.ts +1 -1
- package/dest/msg_validators/tx_validator/data_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/data_validator.js +35 -2
- 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 +133 -6
- package/dest/msg_validators/tx_validator/factory.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/factory.js +247 -60
- package/dest/msg_validators/tx_validator/fee_payer_balance.d.ts +1 -1
- package/dest/msg_validators/tx_validator/fee_payer_balance.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/fee_payer_balance.js +6 -2
- package/dest/msg_validators/tx_validator/gas_validator.d.ts +99 -3
- package/dest/msg_validators/tx_validator/gas_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/gas_validator.js +137 -53
- package/dest/msg_validators/tx_validator/index.d.ts +3 -1
- package/dest/msg_validators/tx_validator/index.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/index.js +2 -0
- package/dest/msg_validators/tx_validator/metadata_validator.d.ts +1 -1
- package/dest/msg_validators/tx_validator/metadata_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/metadata_validator.js +4 -4
- 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/phases_validator.d.ts +22 -2
- package/dest/msg_validators/tx_validator/phases_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/phases_validator.js +72 -24
- 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/data_store.d.ts +1 -1
- package/dest/services/data_store.d.ts.map +1 -1
- package/dest/services/data_store.js +5 -5
- package/dest/services/dummy_service.d.ts +17 -6
- package/dest/services/dummy_service.d.ts.map +1 -1
- package/dest/services/dummy_service.js +16 -5
- package/dest/services/encoding.d.ts +7 -3
- package/dest/services/encoding.d.ts.map +1 -1
- package/dest/services/encoding.js +18 -11
- 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 +184 -0
- package/dest/services/gossipsub/topic_score_params.d.ts.map +1 -0
- package/dest/services/gossipsub/topic_score_params.js +363 -0
- package/dest/services/libp2p/instrumentation.d.ts +3 -1
- package/dest/services/libp2p/instrumentation.d.ts.map +1 -1
- package/dest/services/libp2p/instrumentation.js +14 -0
- package/dest/services/libp2p/libp2p_service.d.ts +95 -51
- package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
- package/dest/services/libp2p/libp2p_service.js +566 -442
- package/dest/services/peer-manager/metrics.d.ts +3 -1
- package/dest/services/peer-manager/metrics.d.ts.map +1 -1
- package/dest/services/peer-manager/metrics.js +6 -0
- package/dest/services/peer-manager/peer_manager.d.ts +6 -2
- package/dest/services/peer-manager/peer_manager.d.ts.map +1 -1
- package/dest/services/peer-manager/peer_manager.js +39 -11
- package/dest/services/peer-manager/peer_scoring.d.ts +7 -2
- package/dest/services/peer-manager/peer_scoring.d.ts.map +1 -1
- package/dest/services/peer-manager/peer_scoring.js +57 -12
- package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts +14 -10
- 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 +89 -112
- package/dest/services/reqresp/batch-tx-requester/interface.d.ts +4 -7
- package/dest/services/reqresp/batch-tx-requester/interface.d.ts.map +1 -1
- package/dest/services/reqresp/batch-tx-requester/missing_txs.d.ts +11 -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 +31 -46
- package/dest/services/reqresp/batch-tx-requester/peer_collection.d.ts +19 -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 +52 -15
- package/dest/services/reqresp/batch-tx-requester/tx_validator.js +2 -2
- package/dest/services/reqresp/config.d.ts +3 -3
- package/dest/services/reqresp/config.d.ts.map +1 -1
- package/dest/services/reqresp/interface.d.ts +23 -9
- package/dest/services/reqresp/interface.d.ts.map +1 -1
- package/dest/services/reqresp/interface.js +23 -10
- package/dest/services/reqresp/metrics.d.ts +1 -1
- package/dest/services/reqresp/metrics.d.ts.map +1 -1
- package/dest/services/reqresp/metrics.js +0 -1
- 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 +16 -11
- package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.d.ts +21 -10
- 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 +27 -11
- package/dest/services/reqresp/protocols/index.d.ts +1 -2
- package/dest/services/reqresp/protocols/index.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/index.js +0 -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 +21 -3
- package/dest/services/reqresp/rate-limiter/rate_limiter.d.ts +5 -4
- package/dest/services/reqresp/rate-limiter/rate_limiter.d.ts.map +1 -1
- package/dest/services/reqresp/rate-limiter/rate_limiter.js +10 -8
- package/dest/services/reqresp/rate-limiter/rate_limits.d.ts +1 -1
- package/dest/services/reqresp/rate-limiter/rate_limits.d.ts.map +1 -1
- package/dest/services/reqresp/rate-limiter/rate_limits.js +0 -10
- package/dest/services/reqresp/reqresp.d.ts +4 -2
- package/dest/services/reqresp/reqresp.d.ts.map +1 -1
- package/dest/services/reqresp/reqresp.js +40 -15
- package/dest/services/service.d.ts +43 -4
- package/dest/services/service.d.ts.map +1 -1
- package/dest/services/tx_collection/config.d.ts +22 -4
- package/dest/services/tx_collection/config.d.ts.map +1 -1
- package/dest/services/tx_collection/config.js +49 -3
- package/dest/services/tx_collection/fast_tx_collection.d.ts +6 -8
- package/dest/services/tx_collection/fast_tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/fast_tx_collection.js +88 -88
- 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 +38 -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 +100 -0
- package/dest/services/tx_collection/index.d.ts +3 -2
- 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/proposal_tx_collector.d.ts +15 -15
- package/dest/services/tx_collection/proposal_tx_collector.d.ts.map +1 -1
- package/dest/services/tx_collection/proposal_tx_collector.js +6 -6
- package/dest/services/tx_collection/request_tracker.d.ts +53 -0
- package/dest/services/tx_collection/request_tracker.d.ts.map +1 -0
- package/dest/services/tx_collection/request_tracker.js +84 -0
- 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 -13
- 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 +13 -7
- package/dest/services/tx_collection/tx_source.d.ts.map +1 -1
- package/dest/services/tx_collection/tx_source.js +26 -7
- 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 +4 -2
- package/dest/test-helpers/mock-pubsub.d.ts +40 -6
- package/dest/test-helpers/mock-pubsub.d.ts.map +1 -1
- package/dest/test-helpers/mock-pubsub.js +139 -13
- 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 +8 -5
- 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 +150 -61
- 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 +85 -28
- package/dest/testbench/worker_client_manager.d.ts +10 -1
- package/dest/testbench/worker_client_manager.d.ts.map +1 -1
- package/dest/testbench/worker_client_manager.js +55 -3
- package/dest/util.d.ts +3 -3
- package/dest/util.d.ts.map +1 -1
- package/package.json +14 -14
- package/src/client/factory.ts +110 -29
- package/src/client/interface.ts +65 -35
- package/src/client/p2p_client.ts +216 -272
- package/src/client/test/tx_proposal_collector/proposal_tx_collector_worker.ts +36 -15
- package/src/config.ts +172 -46
- package/src/errors/p2p-service.error.ts +11 -0
- package/src/errors/tx-pool.error.ts +12 -0
- package/src/index.ts +1 -1
- package/src/mem_pools/attestation_pool/attestation_pool.ts +501 -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 +2 -2
- package/src/mem_pools/instrumentation.ts +17 -13
- package/src/mem_pools/interface.ts +4 -4
- package/src/mem_pools/tx_pool_v2/README.md +112 -17
- 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 +7 -3
- 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 +5 -0
- package/src/mem_pools/tx_pool_v2/eviction/insufficient_fee_per_gas_eviction_rule.ts +65 -0
- package/src/mem_pools/tx_pool_v2/eviction/interfaces.ts +59 -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 +8 -8
- 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 +33 -6
- package/src/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.ts +4 -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 +37 -12
- package/src/mem_pools/tx_pool_v2/tx_metadata.ts +215 -26
- package/src/mem_pools/tx_pool_v2/tx_pool_indices.ts +430 -0
- package/src/mem_pools/tx_pool_v2/tx_pool_v2.ts +37 -8
- package/src/mem_pools/tx_pool_v2/tx_pool_v2_impl.ts +520 -678
- package/src/msg_validators/attestation_validator/README.md +49 -0
- package/src/msg_validators/attestation_validator/attestation_validator.ts +21 -9
- package/src/msg_validators/attestation_validator/fisherman_attestation_validator.ts +6 -3
- package/src/msg_validators/clock_tolerance.ts +72 -3
- package/src/msg_validators/proposal_validator/README.md +123 -0
- package/src/msg_validators/proposal_validator/block_proposal_validator.ts +17 -4
- package/src/msg_validators/proposal_validator/checkpoint_proposal_validator.ts +23 -7
- package/src/msg_validators/proposal_validator/proposal_validator.ts +79 -49
- package/src/msg_validators/tx_validator/README.md +127 -0
- package/src/msg_validators/tx_validator/aggregate_tx_validator.ts +5 -5
- package/src/msg_validators/tx_validator/allowed_public_setup.ts +22 -27
- package/src/msg_validators/tx_validator/allowed_setup_helpers.ts +31 -0
- package/src/msg_validators/tx_validator/archive_cache.ts +1 -1
- package/src/msg_validators/tx_validator/block_header_validator.ts +15 -3
- package/src/msg_validators/tx_validator/contract_instance_validator.ts +56 -0
- package/src/msg_validators/tx_validator/data_validator.ts +42 -1
- package/src/msg_validators/tx_validator/double_spend_validator.ts +11 -6
- package/src/msg_validators/tx_validator/factory.ts +396 -78
- package/src/msg_validators/tx_validator/fee_payer_balance.ts +6 -2
- package/src/msg_validators/tx_validator/gas_validator.ts +199 -54
- package/src/msg_validators/tx_validator/index.ts +2 -0
- package/src/msg_validators/tx_validator/metadata_validator.ts +12 -4
- package/src/msg_validators/tx_validator/nullifier_cache.ts +30 -0
- package/src/msg_validators/tx_validator/phases_validator.ts +82 -27
- package/src/msg_validators/tx_validator/timestamp_validator.ts +23 -18
- package/src/services/data_store.ts +5 -13
- package/src/services/dummy_service.ts +25 -7
- package/src/services/encoding.ts +18 -10
- 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 +519 -0
- package/src/services/libp2p/instrumentation.ts +14 -0
- package/src/services/libp2p/libp2p_service.ts +593 -477
- package/src/services/peer-manager/metrics.ts +7 -0
- package/src/services/peer-manager/peer_manager.ts +45 -11
- package/src/services/peer-manager/peer_scoring.ts +52 -5
- package/src/services/reqresp/README.md +229 -0
- package/src/services/reqresp/batch-tx-requester/README.md +53 -14
- package/src/services/reqresp/batch-tx-requester/batch_tx_requester.ts +89 -122
- package/src/services/reqresp/batch-tx-requester/interface.ts +3 -6
- package/src/services/reqresp/batch-tx-requester/missing_txs.ts +30 -71
- package/src/services/reqresp/batch-tx-requester/peer_collection.ts +68 -24
- package/src/services/reqresp/batch-tx-requester/tx_validator.ts +2 -2
- package/src/services/reqresp/config.ts +2 -2
- package/src/services/reqresp/interface.ts +45 -10
- package/src/services/reqresp/metrics.ts +0 -1
- package/src/services/reqresp/protocols/block_txs/block_txs_handler.ts +23 -14
- package/src/services/reqresp/protocols/block_txs/block_txs_reqresp.ts +38 -15
- package/src/services/reqresp/protocols/index.ts +0 -1
- package/src/services/reqresp/protocols/tx.ts +23 -3
- package/src/services/reqresp/rate-limiter/rate_limiter.ts +13 -9
- package/src/services/reqresp/rate-limiter/rate_limits.ts +0 -10
- package/src/services/reqresp/reqresp.ts +53 -16
- package/src/services/service.ts +57 -3
- package/src/services/tx_collection/config.ts +74 -6
- package/src/services/tx_collection/fast_tx_collection.ts +94 -97
- package/src/services/tx_collection/file_store_tx_collection.ts +202 -0
- package/src/services/tx_collection/file_store_tx_source.ts +129 -0
- package/src/services/tx_collection/index.ts +2 -1
- package/src/services/tx_collection/instrumentation.ts +7 -1
- package/src/services/tx_collection/proposal_tx_collector.ts +21 -27
- package/src/services/tx_collection/request_tracker.ts +127 -0
- package/src/services/tx_collection/slow_tx_collection.ts +66 -33
- package/src/services/tx_collection/tx_collection.ts +114 -19
- package/src/services/tx_collection/tx_collection_sink.ts +30 -34
- package/src/services/tx_collection/tx_source.ts +28 -8
- 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 +6 -6
- package/src/test-helpers/mock-pubsub.ts +180 -14
- package/src/test-helpers/reqresp-nodes.ts +9 -9
- package/src/test-helpers/testbench-utils.ts +157 -74
- package/src/testbench/p2p_client_testbench_worker.ts +94 -31
- package/src/testbench/worker_client_manager.ts +68 -6
- package/src/util.ts +8 -2
- 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/dest/mem_pools/tx_pool/aztec_kv_tx_pool.d.ts +0 -125
- package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.js +0 -596
- package/dest/mem_pools/tx_pool/eviction/eviction_manager.d.ts +0 -32
- package/dest/mem_pools/tx_pool/eviction/eviction_manager.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/eviction/eviction_manager.js +0 -112
- package/dest/mem_pools/tx_pool/eviction/eviction_strategy.d.ts +0 -157
- package/dest/mem_pools/tx_pool/eviction/eviction_strategy.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/eviction/eviction_strategy.js +0 -52
- package/dest/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.d.ts +0 -16
- package/dest/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.js +0 -122
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.d.ts +0 -17
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.js +0 -84
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.d.ts +0 -19
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.js +0 -78
- package/dest/mem_pools/tx_pool/eviction/low_priority_eviction_rule.d.ts +0 -26
- package/dest/mem_pools/tx_pool/eviction/low_priority_eviction_rule.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/eviction/low_priority_eviction_rule.js +0 -84
- package/dest/mem_pools/tx_pool/eviction/nullifier_conflict_pre_add_rule.d.ts +0 -25
- package/dest/mem_pools/tx_pool/eviction/nullifier_conflict_pre_add_rule.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/eviction/nullifier_conflict_pre_add_rule.js +0 -57
- package/dest/mem_pools/tx_pool/index.d.ts +0 -3
- package/dest/mem_pools/tx_pool/index.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/index.js +0 -2
- package/dest/mem_pools/tx_pool/priority.d.ts +0 -12
- package/dest/mem_pools/tx_pool/priority.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/priority.js +0 -15
- package/dest/mem_pools/tx_pool/tx_pool.d.ts +0 -127
- package/dest/mem_pools/tx_pool/tx_pool.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/tx_pool.js +0 -3
- package/dest/mem_pools/tx_pool/tx_pool_test_suite.d.ts +0 -7
- package/dest/mem_pools/tx_pool/tx_pool_test_suite.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/tx_pool_test_suite.js +0 -400
- package/dest/msg_validators/proposal_validator/proposal_validator_test_suite.d.ts +0 -23
- package/dest/msg_validators/proposal_validator/proposal_validator_test_suite.d.ts.map +0 -1
- package/dest/msg_validators/proposal_validator/proposal_validator_test_suite.js +0 -212
- package/dest/services/reqresp/protocols/block.d.ts +0 -9
- package/dest/services/reqresp/protocols/block.d.ts.map +0 -1
- package/dest/services/reqresp/protocols/block.js +0 -32
- package/src/mem_pools/attestation_pool/kv_attestation_pool.ts +0 -320
- package/src/mem_pools/attestation_pool/memory_attestation_pool.ts +0 -264
- package/src/mem_pools/tx_pool/README.md +0 -270
- package/src/mem_pools/tx_pool/aztec_kv_tx_pool.ts +0 -746
- package/src/mem_pools/tx_pool/eviction/eviction_manager.ts +0 -132
- package/src/mem_pools/tx_pool/eviction/eviction_strategy.ts +0 -208
- package/src/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.ts +0 -162
- package/src/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.ts +0 -104
- package/src/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.ts +0 -93
- package/src/mem_pools/tx_pool/eviction/low_priority_eviction_rule.ts +0 -106
- package/src/mem_pools/tx_pool/eviction/nullifier_conflict_pre_add_rule.ts +0 -75
- package/src/mem_pools/tx_pool/index.ts +0 -2
- package/src/mem_pools/tx_pool/priority.ts +0 -20
- package/src/mem_pools/tx_pool/tx_pool.ts +0 -141
- package/src/mem_pools/tx_pool/tx_pool_test_suite.ts +0 -319
- package/src/msg_validators/proposal_validator/proposal_validator_test_suite.ts +0 -230
- package/src/services/reqresp/protocols/block.ts +0 -37
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import type { SlotNumber } from '@aztec/foundation/branded-types';
|
|
2
2
|
import type { TypedEventEmitter } from '@aztec/foundation/types';
|
|
3
3
|
import type { L2Block, L2BlockId, L2BlockSource } from '@aztec/stdlib/block';
|
|
4
|
+
import type { BlockMinFeesProvider } from '@aztec/stdlib/gas';
|
|
4
5
|
import type { WorldStateSynchronizer } from '@aztec/stdlib/interfaces/server';
|
|
5
6
|
import type { BlockHeader, Tx, TxHash, TxValidator } from '@aztec/stdlib/tx';
|
|
6
7
|
|
|
8
|
+
import type { TxPoolRejectionError } from './eviction/interfaces.js';
|
|
7
9
|
import type { TxMetaData, TxState } from './tx_metadata.js';
|
|
8
10
|
|
|
9
11
|
/**
|
|
@@ -17,6 +19,8 @@ export type AddTxsResult = {
|
|
|
17
19
|
ignored: TxHash[];
|
|
18
20
|
/** Transactions rejected because they failed validation (e.g., invalid proof, expired timestamp) */
|
|
19
21
|
rejected: TxHash[];
|
|
22
|
+
/** Optional rejection errors, only present when there are rejections with structured errors. */
|
|
23
|
+
errors?: Map<string, TxPoolRejectionError>;
|
|
20
24
|
};
|
|
21
25
|
|
|
22
26
|
/**
|
|
@@ -25,6 +29,8 @@ export type AddTxsResult = {
|
|
|
25
29
|
export type TxPoolV2Events = {
|
|
26
30
|
/** Emitted when transactions are successfully added to the pool */
|
|
27
31
|
'txs-added': (args: { txs: Tx[]; source?: string }) => void;
|
|
32
|
+
/** Emitted when transactions are removed from the pool */
|
|
33
|
+
'txs-removed': (args: { txHashes: TxHash[] }) => void;
|
|
28
34
|
};
|
|
29
35
|
|
|
30
36
|
/**
|
|
@@ -35,6 +41,14 @@ export type TxPoolV2Config = {
|
|
|
35
41
|
maxPendingTxCount: number;
|
|
36
42
|
/** Maximum number of archived transactions to retain (0 = disabled) */
|
|
37
43
|
archivedTxLimit: number;
|
|
44
|
+
/** Minimum age (ms) a transaction must have been in the pool before it's eligible for block building */
|
|
45
|
+
minTxPoolAgeMs: number;
|
|
46
|
+
/** Maximum number of evicted tx hashes to remember for metrics tracking */
|
|
47
|
+
evictedTxCacheSize: number;
|
|
48
|
+
/** The probability (0-1) that a transaction is discarded. 0 disables dropping. For testing purposes only. */
|
|
49
|
+
dropTransactionsProbability: number;
|
|
50
|
+
/** Minimum percentage fee increase required to replace an existing tx via RPC (0 = no bump). */
|
|
51
|
+
priceBumpPercentage: bigint;
|
|
38
52
|
};
|
|
39
53
|
|
|
40
54
|
/**
|
|
@@ -43,6 +57,10 @@ export type TxPoolV2Config = {
|
|
|
43
57
|
export const DEFAULT_TX_POOL_V2_CONFIG: TxPoolV2Config = {
|
|
44
58
|
maxPendingTxCount: 0, // 0 = disabled
|
|
45
59
|
archivedTxLimit: 0, // 0 = disabled
|
|
60
|
+
minTxPoolAgeMs: 2_000,
|
|
61
|
+
evictedTxCacheSize: 10_000,
|
|
62
|
+
dropTransactionsProbability: 0,
|
|
63
|
+
priceBumpPercentage: 10n,
|
|
46
64
|
};
|
|
47
65
|
|
|
48
66
|
/**
|
|
@@ -53,8 +71,12 @@ export type TxPoolV2Dependencies = {
|
|
|
53
71
|
l2BlockSource: L2BlockSource;
|
|
54
72
|
/** World state synchronizer for validating transactions after chain prunes */
|
|
55
73
|
worldStateSynchronizer: WorldStateSynchronizer;
|
|
56
|
-
/**
|
|
57
|
-
|
|
74
|
+
/** Factory that creates a validator for re-validating pool transactions using metadata */
|
|
75
|
+
createTxValidator: () => Promise<TxValidator<TxMetaData>>;
|
|
76
|
+
/** Checks whether a tx's setup-phase calls are on the allow list. Precomputed at receipt time. */
|
|
77
|
+
checkAllowedSetupCalls: (tx: Tx) => Promise<boolean>;
|
|
78
|
+
/** Provides projected minimum fees for the next block. Used by eviction rules instead of stale block header fees. */
|
|
79
|
+
blockMinFeesProvider: BlockMinFeesProvider;
|
|
58
80
|
};
|
|
59
81
|
|
|
60
82
|
/**
|
|
@@ -93,15 +115,15 @@ export interface TxPoolV2 extends TypedEventEmitter<TxPoolV2Events> {
|
|
|
93
115
|
* @param opts - Optional metadata (e.g., source for logging)
|
|
94
116
|
* @returns Result categorizing each transaction as accepted, rejected, or ignored
|
|
95
117
|
*/
|
|
96
|
-
addPendingTxs(txs: Tx[], opts?: { source?: string }): Promise<AddTxsResult>;
|
|
118
|
+
addPendingTxs(txs: Tx[], opts?: { source?: string; feeComparisonOnly?: boolean }): Promise<AddTxsResult>;
|
|
97
119
|
|
|
98
120
|
/**
|
|
99
|
-
* Checks if
|
|
100
|
-
*
|
|
121
|
+
* Checks if the pool would accept a transaction without modifying state.
|
|
122
|
+
* Used as a pre-check before expensive proof verification.
|
|
101
123
|
* @param tx - Transaction to check
|
|
102
|
-
* @returns
|
|
124
|
+
* @returns 'accepted' if the pool would accept, 'ignored' if already in pool or undesirable
|
|
103
125
|
*/
|
|
104
|
-
canAddPendingTx(tx: Tx): Promise<'accepted' | 'ignored'
|
|
126
|
+
canAddPendingTx(tx: Tx): Promise<'accepted' | 'ignored'>;
|
|
105
127
|
|
|
106
128
|
/**
|
|
107
129
|
* Adds transactions as immediately protected for a given slot.
|
|
@@ -141,10 +163,10 @@ export interface TxPoolV2 extends TypedEventEmitter<TxPoolV2Events> {
|
|
|
141
163
|
handleMinedBlock(block: L2Block): Promise<void>;
|
|
142
164
|
|
|
143
165
|
/**
|
|
144
|
-
* Prepares the pool for a new slot
|
|
145
|
-
*
|
|
146
|
-
*
|
|
147
|
-
*
|
|
166
|
+
* Prepares the pool for a new slot by unprotecting transactions from earlier
|
|
167
|
+
* slots and re-validating them before returning to pending state.
|
|
168
|
+
* @param slotNumber - The pipeline slot we are building for (i.e. the slot
|
|
169
|
+
* the resulting blocks will target on L1).
|
|
148
170
|
*/
|
|
149
171
|
prepareForSlot(slotNumber: SlotNumber): Promise<void>;
|
|
150
172
|
|
|
@@ -154,7 +176,7 @@ export interface TxPoolV2 extends TypedEventEmitter<TxPoolV2Events> {
|
|
|
154
176
|
* and validates them before returning to pending.
|
|
155
177
|
* @param latestBlock - The latest valid block ID after the prune
|
|
156
178
|
*/
|
|
157
|
-
handlePrunedBlocks(latestBlock: L2BlockId): Promise<void>;
|
|
179
|
+
handlePrunedBlocks(latestBlock: L2BlockId, options?: { deleteAllTxs?: boolean }): Promise<void>;
|
|
158
180
|
|
|
159
181
|
/**
|
|
160
182
|
* Handles failed transaction execution.
|
|
@@ -185,6 +207,9 @@ export interface TxPoolV2 extends TypedEventEmitter<TxPoolV2Events> {
|
|
|
185
207
|
/** Gets pending transaction hashes sorted by priority (highest first) */
|
|
186
208
|
getPendingTxHashes(): Promise<TxHash[]>;
|
|
187
209
|
|
|
210
|
+
/** Gets pending transaction hashes that have been in the pool long enough per minTxPoolAgeMs, sorted by priority (highest first) */
|
|
211
|
+
getEligiblePendingTxHashes(): Promise<TxHash[]>;
|
|
212
|
+
|
|
188
213
|
/** Gets the count of pending transactions */
|
|
189
214
|
getPendingTxCount(): Promise<number>;
|
|
190
215
|
|
|
@@ -1,11 +1,32 @@
|
|
|
1
|
+
import { minBigint } from '@aztec/foundation/bigint';
|
|
2
|
+
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
1
3
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
4
|
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
3
|
-
import type
|
|
4
|
-
import
|
|
5
|
+
import { BlockHash, type L2BlockId } from '@aztec/stdlib/block';
|
|
6
|
+
import { Gas, GasFees } from '@aztec/stdlib/gas';
|
|
7
|
+
import { type Tx, TxHash } from '@aztec/stdlib/tx';
|
|
5
8
|
|
|
6
9
|
import { getFeePayerBalanceDelta } from '../../msg_validators/tx_validator/fee_payer_balance.js';
|
|
7
|
-
import {
|
|
8
|
-
|
|
10
|
+
import { type PreAddResult, TxPoolRejectionCode } from './eviction/interfaces.js';
|
|
11
|
+
|
|
12
|
+
/** Validator-compatible data interface, mirroring the subset of PrivateKernelTailCircuitPublicInputs used by validators. */
|
|
13
|
+
export type TxMetaValidationData = {
|
|
14
|
+
getNonEmptyNullifiers(): Fr[];
|
|
15
|
+
expirationTimestamp: bigint;
|
|
16
|
+
/** Whether the tx has public calls. Used to select the correct L2 gas minimum. */
|
|
17
|
+
forPublic?: unknown;
|
|
18
|
+
constants: {
|
|
19
|
+
anchorBlockHeader: {
|
|
20
|
+
hash(): Promise<BlockHash>;
|
|
21
|
+
globalVariables: {
|
|
22
|
+
blockNumber: BlockNumber;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
txContext: {
|
|
26
|
+
gasSettings: { gasLimits: Gas; maxFeesPerGas: GasFees };
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
};
|
|
9
30
|
|
|
10
31
|
/**
|
|
11
32
|
* Lightweight in-memory representation of a transaction.
|
|
@@ -19,6 +40,9 @@ export type TxMetaData = {
|
|
|
19
40
|
/** The transaction hash as hex string */
|
|
20
41
|
readonly txHash: string;
|
|
21
42
|
|
|
43
|
+
/** The transaction hash as bigint (for efficient Fr conversion in comparisons) */
|
|
44
|
+
readonly txHashBigInt: bigint;
|
|
45
|
+
|
|
22
46
|
/** Block ID (number and hash) in which the transaction was mined (undefined if not mined) */
|
|
23
47
|
minedL2BlockId?: L2BlockId;
|
|
24
48
|
|
|
@@ -41,46 +65,117 @@ export type TxMetaData = {
|
|
|
41
65
|
readonly nullifiers: readonly string[];
|
|
42
66
|
|
|
43
67
|
/** Timestamp by which the transaction must be included (for expiration checks) */
|
|
44
|
-
readonly
|
|
68
|
+
readonly expirationTimestamp: bigint;
|
|
69
|
+
|
|
70
|
+
/** Whether the tx's setup-phase calls pass the allow list check. Computed at receipt time. */
|
|
71
|
+
readonly allowedSetupCalls: boolean;
|
|
72
|
+
|
|
73
|
+
/** Validator-compatible data, providing the same access patterns as Tx.data */
|
|
74
|
+
readonly data: TxMetaValidationData;
|
|
75
|
+
|
|
76
|
+
/** Timestamp (ms) when the tx was received into the pool. 0 for hydrated txs (always eligible). */
|
|
77
|
+
receivedAt: number;
|
|
78
|
+
|
|
79
|
+
/** Estimated memory footprint of this metadata object in bytes */
|
|
80
|
+
readonly estimatedSizeBytes: number;
|
|
45
81
|
};
|
|
46
82
|
|
|
47
83
|
/** Transaction state derived from TxMetaData fields and pool protection status */
|
|
48
|
-
export type TxState = 'pending' | 'protected' | 'mined';
|
|
84
|
+
export type TxState = 'pending' | 'protected' | 'mined' | 'deleted';
|
|
49
85
|
|
|
50
86
|
/**
|
|
51
87
|
* Builds TxMetaData from a full Tx object.
|
|
52
88
|
* Extracts all relevant fields for efficient in-memory storage and querying.
|
|
89
|
+
* Fr values are captured in closures for zero-cost re-validation.
|
|
90
|
+
*
|
|
91
|
+
* @param allowedSetupCalls - Whether the tx's setup-phase calls pass the allow list.
|
|
92
|
+
* For gossip/RPC txs this is always `true` (already validated by PhasesTxValidator).
|
|
93
|
+
* For req/resp txs this should be computed by the caller using the phases validator.
|
|
53
94
|
*/
|
|
54
|
-
export async function buildTxMetaData(tx: Tx): Promise<TxMetaData> {
|
|
55
|
-
const
|
|
56
|
-
const
|
|
95
|
+
export async function buildTxMetaData(tx: Tx, allowedSetupCalls: boolean = true): Promise<TxMetaData> {
|
|
96
|
+
const txHashObj = tx.getTxHash();
|
|
97
|
+
const txHash = txHashObj.toString();
|
|
98
|
+
const txHashBigInt = txHashObj.toBigInt();
|
|
99
|
+
const nullifierFrs = tx.data.getNonEmptyNullifiers();
|
|
100
|
+
const nullifiers = nullifierFrs.map(n => n.toString());
|
|
101
|
+
const anchorBlockHeaderHashFr = await tx.data.constants.anchorBlockHeader.hash();
|
|
102
|
+
const anchorBlockHeaderHash = anchorBlockHeaderHashFr.toString();
|
|
103
|
+
const expirationTimestamp = tx.data.expirationTimestamp;
|
|
104
|
+
const anchorBlockNumber = tx.data.constants.anchorBlockHeader.globalVariables.blockNumber;
|
|
57
105
|
const priorityFee = getTxPriorityFee(tx);
|
|
58
106
|
const feePayer = tx.data.feePayer.toString();
|
|
59
|
-
const nullifiers = tx.data.getNonEmptyNullifiers().map(n => n.toString());
|
|
60
|
-
const includeByTimestamp = tx.data.includeByTimestamp;
|
|
61
107
|
|
|
62
108
|
const { feeLimit, claimAmount } = await getFeePayerBalanceDelta(tx, ProtocolContractAddress.FeeJuice);
|
|
63
109
|
|
|
110
|
+
const estimatedSizeBytes = estimateTxMetaDataSize(nullifiers.length);
|
|
111
|
+
|
|
64
112
|
return {
|
|
65
113
|
txHash,
|
|
114
|
+
txHashBigInt,
|
|
66
115
|
anchorBlockHeaderHash,
|
|
67
116
|
priorityFee,
|
|
68
117
|
feePayer,
|
|
69
118
|
claimAmount,
|
|
70
119
|
feeLimit,
|
|
71
120
|
nullifiers,
|
|
72
|
-
|
|
121
|
+
expirationTimestamp,
|
|
122
|
+
allowedSetupCalls,
|
|
123
|
+
receivedAt: 0,
|
|
124
|
+
estimatedSizeBytes,
|
|
125
|
+
data: {
|
|
126
|
+
getNonEmptyNullifiers: () => nullifierFrs,
|
|
127
|
+
expirationTimestamp,
|
|
128
|
+
forPublic: !!tx.data.forPublic,
|
|
129
|
+
constants: {
|
|
130
|
+
anchorBlockHeader: {
|
|
131
|
+
hash: () => Promise.resolve(anchorBlockHeaderHashFr),
|
|
132
|
+
globalVariables: { blockNumber: anchorBlockNumber },
|
|
133
|
+
},
|
|
134
|
+
txContext: {
|
|
135
|
+
gasSettings: {
|
|
136
|
+
gasLimits: tx.data.constants.txContext.gasSettings.gasLimits,
|
|
137
|
+
maxFeesPerGas: tx.data.constants.txContext.gasSettings.maxFeesPerGas,
|
|
138
|
+
},
|
|
139
|
+
},
|
|
140
|
+
},
|
|
141
|
+
},
|
|
73
142
|
};
|
|
74
143
|
}
|
|
75
144
|
|
|
145
|
+
// V8 JS object overhead (~64 bytes for a plain object with hidden class).
|
|
146
|
+
// String overhead: ~32 bytes header + 1 byte per ASCII char (V8 one-byte strings).
|
|
147
|
+
// Hex string (0x + 64 hex chars = 66 chars): ~98 bytes per string.
|
|
148
|
+
// bigint: ~32 bytes. number: 8 bytes. Fr: ~80 bytes (32 data + object overhead).
|
|
149
|
+
const OBJECT_OVERHEAD = 64;
|
|
150
|
+
const HEX_STRING_BYTES = 98;
|
|
151
|
+
const BIGINT_BYTES = 32;
|
|
152
|
+
const FR_BYTES = 80;
|
|
153
|
+
// Fixed cost: object shell + txHash + anchorBlockHeaderHash + feePayer (3 hex strings)
|
|
154
|
+
// + txHashBigInt + priorityFee + claimAmount + feeLimit + includeByTimestamp (5 bigints)
|
|
155
|
+
// + receivedAt (number, 8 bytes) + estimatedSizeBytes (number, 8 bytes)
|
|
156
|
+
// + data closure object (~OBJECT_OVERHEAD + anchorBlockHeaderHashFr Fr + anchorBlockNumber number)
|
|
157
|
+
const FIXED_METADATA_BYTES =
|
|
158
|
+
OBJECT_OVERHEAD + 3 * HEX_STRING_BYTES + 5 * BIGINT_BYTES + 8 + 8 + OBJECT_OVERHEAD + FR_BYTES + 8;
|
|
159
|
+
|
|
160
|
+
/** Estimates the in-memory size of a TxMetaData object based on the number of nullifiers. */
|
|
161
|
+
function estimateTxMetaDataSize(nullifierCount: number): number {
|
|
162
|
+
// Per nullifier: one hex string in nullifiers[] + one Fr in the captured nullifierFrs[]
|
|
163
|
+
return FIXED_METADATA_BYTES + nullifierCount * (HEX_STRING_BYTES + FR_BYTES);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/** Converts a txHash bigint back to the canonical 0x-prefixed 64-char hex string. */
|
|
167
|
+
export function txHashFromBigInt(value: bigint): string {
|
|
168
|
+
return TxHash.fromBigInt(value).toString();
|
|
169
|
+
}
|
|
170
|
+
|
|
76
171
|
/** Minimal fields required for priority comparison. */
|
|
77
|
-
type PriorityComparable = Pick<TxMetaData, 'txHash' | 'priorityFee'>;
|
|
172
|
+
export type PriorityComparable = Pick<TxMetaData, 'txHash' | 'txHashBigInt' | 'priorityFee'>;
|
|
78
173
|
|
|
79
174
|
/**
|
|
80
175
|
* Compares two priority fees in ascending order.
|
|
81
176
|
* Returns negative if a < b, positive if a > b, 0 if equal.
|
|
82
177
|
*/
|
|
83
|
-
export function compareFee(a: bigint, b: bigint):
|
|
178
|
+
export function compareFee(a: bigint, b: bigint): -1 | 0 | 1 {
|
|
84
179
|
return a < b ? -1 : a > b ? 1 : 0;
|
|
85
180
|
}
|
|
86
181
|
|
|
@@ -89,10 +184,8 @@ export function compareFee(a: bigint, b: bigint): number {
|
|
|
89
184
|
* Uses field element comparison for deterministic ordering.
|
|
90
185
|
* Returns negative if a < b, positive if a > b, 0 if equal.
|
|
91
186
|
*/
|
|
92
|
-
export function compareTxHash(a:
|
|
93
|
-
|
|
94
|
-
const fieldB = Fr.fromHexString(b);
|
|
95
|
-
return fieldA.cmp(fieldB);
|
|
187
|
+
export function compareTxHash(a: bigint, b: bigint): -1 | 0 | 1 {
|
|
188
|
+
return Fr.cmpAsBigInt(a, b);
|
|
96
189
|
}
|
|
97
190
|
|
|
98
191
|
/**
|
|
@@ -100,29 +193,46 @@ export function compareTxHash(a: string, b: string): number {
|
|
|
100
193
|
* Returns negative if a < b, positive if a > b, 0 if equal.
|
|
101
194
|
* Use with sort() for ascending order, or negate/reverse for descending.
|
|
102
195
|
*/
|
|
103
|
-
export function comparePriority(a: PriorityComparable, b: PriorityComparable):
|
|
196
|
+
export function comparePriority(a: PriorityComparable, b: PriorityComparable): -1 | 0 | 1 {
|
|
104
197
|
const feeComparison = compareFee(a.priorityFee, b.priorityFee);
|
|
105
198
|
if (feeComparison !== 0) {
|
|
106
199
|
return feeComparison;
|
|
107
200
|
}
|
|
108
|
-
return compareTxHash(a.
|
|
201
|
+
return compareTxHash(a.txHashBigInt, b.txHashBigInt);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* Returns the minimum fee required to replace an existing tx with the given price bump percentage.
|
|
206
|
+
* Uses integer arithmetic: `existingFee + existingFee * priceBumpPercentage / 100`.
|
|
207
|
+
*/
|
|
208
|
+
export function getMinimumPriceBumpFee(existingFee: bigint, priceBumpPercentage: bigint): bigint {
|
|
209
|
+
const bump = (existingFee * priceBumpPercentage) / 100n;
|
|
210
|
+
// Ensure the minimum bump is at least 1, so that replacement always requires
|
|
211
|
+
// paying strictly more — even with 0% bump or zero existing fee.
|
|
212
|
+
const effectiveBump = bump > 0n ? bump : 1n;
|
|
213
|
+
return existingFee + effectiveBump;
|
|
109
214
|
}
|
|
110
215
|
|
|
111
216
|
/**
|
|
112
217
|
* Checks for nullifier conflicts between an incoming transaction and existing pool state.
|
|
113
218
|
*
|
|
114
219
|
* When the incoming tx shares nullifiers with existing pending txs:
|
|
115
|
-
* - If the incoming tx
|
|
116
|
-
* -
|
|
220
|
+
* - If the incoming tx meets or exceeds the required priority, mark conflicting txs for eviction
|
|
221
|
+
* - Otherwise, ignore the incoming tx
|
|
222
|
+
*
|
|
223
|
+
* When `priceBumpPercentage` is provided (RPC path), uses fee-only comparison with the
|
|
224
|
+
* percentage bump instead of `comparePriority`.
|
|
117
225
|
*
|
|
118
226
|
* @param incomingMeta - Metadata for the incoming transaction
|
|
119
227
|
* @param getTxHashByNullifier - Accessor to find which tx uses a nullifier
|
|
120
228
|
* @param getMetadata - Accessor to get metadata for a tx hash
|
|
229
|
+
* @param priceBumpPercentage - Optional percentage bump required for fee-based replacement
|
|
121
230
|
*/
|
|
122
231
|
export function checkNullifierConflict(
|
|
123
232
|
incomingMeta: TxMetaData,
|
|
124
233
|
getTxHashByNullifier: (nullifier: string) => string | undefined,
|
|
125
234
|
getMetadata: (txHash: string) => TxMetaData | undefined,
|
|
235
|
+
priceBumpPercentage?: bigint,
|
|
126
236
|
): PreAddResult {
|
|
127
237
|
const txHashesToEvict: string[] = [];
|
|
128
238
|
|
|
@@ -143,18 +253,97 @@ export function checkNullifierConflict(
|
|
|
143
253
|
continue;
|
|
144
254
|
}
|
|
145
255
|
|
|
146
|
-
//
|
|
147
|
-
// Otherwise,
|
|
148
|
-
|
|
256
|
+
// When price bump is set (RPC path), require the incoming fee to meet the bumped threshold.
|
|
257
|
+
// Otherwise (P2P path), use full comparePriority with tx hash tiebreaker.
|
|
258
|
+
const isHigherPriority =
|
|
259
|
+
priceBumpPercentage !== undefined
|
|
260
|
+
? incomingMeta.priorityFee >= getMinimumPriceBumpFee(conflictingMeta.priorityFee, priceBumpPercentage)
|
|
261
|
+
: comparePriority(incomingMeta, conflictingMeta) > 0;
|
|
262
|
+
|
|
263
|
+
if (isHigherPriority) {
|
|
149
264
|
txHashesToEvict.push(conflictingHashStr);
|
|
150
265
|
} else {
|
|
266
|
+
const minimumFee =
|
|
267
|
+
priceBumpPercentage !== undefined
|
|
268
|
+
? getMinimumPriceBumpFee(conflictingMeta.priorityFee, priceBumpPercentage)
|
|
269
|
+
: undefined;
|
|
151
270
|
return {
|
|
152
271
|
shouldIgnore: true,
|
|
153
272
|
txHashesToEvict: [],
|
|
154
|
-
reason:
|
|
273
|
+
reason: {
|
|
274
|
+
code: TxPoolRejectionCode.NULLIFIER_CONFLICT,
|
|
275
|
+
message:
|
|
276
|
+
minimumFee !== undefined
|
|
277
|
+
? `Nullifier conflict with existing tx ${conflictingHashStr}. Minimum required fee: ${minimumFee}, got: ${incomingMeta.priorityFee}`
|
|
278
|
+
: `Nullifier conflict with existing tx ${conflictingHashStr}`,
|
|
279
|
+
conflictingTxHash: conflictingHashStr,
|
|
280
|
+
minimumPriceBumpFee: minimumFee,
|
|
281
|
+
txPriorityFee: minimumFee !== undefined ? incomingMeta.priorityFee : undefined,
|
|
282
|
+
},
|
|
155
283
|
};
|
|
156
284
|
}
|
|
157
285
|
}
|
|
158
286
|
|
|
159
287
|
return { shouldIgnore: false, txHashesToEvict };
|
|
160
288
|
}
|
|
289
|
+
|
|
290
|
+
/** Creates a stub TxMetaValidationData for tests that don't exercise validators. */
|
|
291
|
+
export function stubTxMetaValidationData(
|
|
292
|
+
overrides: { expirationTimestamp?: bigint; maxFeesPerGas?: GasFees } = {},
|
|
293
|
+
): TxMetaValidationData {
|
|
294
|
+
return {
|
|
295
|
+
getNonEmptyNullifiers: () => [],
|
|
296
|
+
expirationTimestamp: overrides.expirationTimestamp ?? 0n,
|
|
297
|
+
constants: {
|
|
298
|
+
anchorBlockHeader: {
|
|
299
|
+
hash: () => Promise.resolve(BlockHash.ZERO),
|
|
300
|
+
globalVariables: { blockNumber: BlockNumber(0) },
|
|
301
|
+
},
|
|
302
|
+
txContext: {
|
|
303
|
+
gasSettings: { gasLimits: Gas.empty(), maxFeesPerGas: overrides.maxFeesPerGas ?? GasFees.empty() },
|
|
304
|
+
},
|
|
305
|
+
},
|
|
306
|
+
};
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
/** Creates a stub TxMetaData for tests. All fields have sensible defaults and can be overridden. */
|
|
310
|
+
export function stubTxMetaData(
|
|
311
|
+
txHash: string,
|
|
312
|
+
overrides: {
|
|
313
|
+
priorityFee?: bigint;
|
|
314
|
+
feePayer?: string;
|
|
315
|
+
claimAmount?: bigint;
|
|
316
|
+
feeLimit?: bigint;
|
|
317
|
+
nullifiers?: string[];
|
|
318
|
+
expirationTimestamp?: bigint;
|
|
319
|
+
anchorBlockHeaderHash?: string;
|
|
320
|
+
allowedSetupCalls?: boolean;
|
|
321
|
+
maxFeesPerGas?: GasFees;
|
|
322
|
+
} = {},
|
|
323
|
+
): TxMetaData {
|
|
324
|
+
const txHashBigInt = Fr.fromHexString(txHash).toBigInt();
|
|
325
|
+
// Normalize to canonical zero-padded hex so txHashFromBigInt(txHashBigInt) === normalizedTxHash
|
|
326
|
+
const normalizedTxHash = txHashFromBigInt(txHashBigInt);
|
|
327
|
+
const expirationTimestamp = overrides.expirationTimestamp ?? 0n;
|
|
328
|
+
return {
|
|
329
|
+
txHash: normalizedTxHash,
|
|
330
|
+
txHashBigInt,
|
|
331
|
+
anchorBlockHeaderHash: overrides.anchorBlockHeaderHash ?? '0x1234',
|
|
332
|
+
priorityFee: overrides.priorityFee ?? 100n,
|
|
333
|
+
feePayer: overrides.feePayer ?? '0xfeepayer',
|
|
334
|
+
claimAmount: overrides.claimAmount ?? 0n,
|
|
335
|
+
feeLimit: overrides.feeLimit ?? 100n,
|
|
336
|
+
nullifiers: overrides.nullifiers ?? [`0x${normalizedTxHash.slice(2)}null1`],
|
|
337
|
+
expirationTimestamp,
|
|
338
|
+
allowedSetupCalls: overrides.allowedSetupCalls ?? true,
|
|
339
|
+
receivedAt: 0,
|
|
340
|
+
estimatedSizeBytes: 0,
|
|
341
|
+
data: stubTxMetaValidationData({ expirationTimestamp, maxFeesPerGas: overrides.maxFeesPerGas }),
|
|
342
|
+
};
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
/** Returns the priority fee for a tx, based on the L2 priority fee capped by the max fee per gas. */
|
|
346
|
+
function getTxPriorityFee(tx: Tx): bigint {
|
|
347
|
+
const { maxPriorityFeesPerGas: priorityFees, maxFeesPerGas } = tx.getGasSettings();
|
|
348
|
+
return minBigint(maxFeesPerGas.feePerL2Gas, priorityFees.feePerL2Gas);
|
|
349
|
+
}
|