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