@aztec/p2p 0.0.0-test.1 → 0.0.1-commit.1142ef1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dest/bootstrap/bootstrap.d.ts +1 -1
- package/dest/bootstrap/bootstrap.d.ts.map +1 -1
- package/dest/bootstrap/bootstrap.js +22 -9
- package/dest/client/factory.d.ts +15 -5
- package/dest/client/factory.d.ts.map +1 -1
- package/dest/client/factory.js +60 -25
- package/dest/client/index.d.ts +2 -1
- package/dest/client/index.d.ts.map +1 -1
- package/dest/client/index.js +1 -0
- package/dest/client/interface.d.ts +170 -0
- package/dest/client/interface.d.ts.map +1 -0
- package/dest/client/interface.js +9 -0
- package/dest/client/p2p_client.d.ts +75 -193
- package/dest/client/p2p_client.d.ts.map +1 -1
- package/dest/client/p2p_client.js +757 -228
- package/dest/config.d.ts +148 -125
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +180 -34
- package/dest/enr/generate-enr.d.ts +11 -3
- package/dest/enr/generate-enr.d.ts.map +1 -1
- package/dest/enr/generate-enr.js +27 -5
- package/dest/enr/index.d.ts +1 -1
- package/dest/errors/attestation-pool.error.d.ts +7 -0
- package/dest/errors/attestation-pool.error.d.ts.map +1 -0
- package/dest/errors/attestation-pool.error.js +12 -0
- package/dest/errors/reqresp.error.d.ts +1 -1
- package/dest/errors/reqresp.error.d.ts.map +1 -1
- package/dest/index.d.ts +4 -1
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +2 -0
- package/dest/mem_pools/attestation_pool/attestation_pool.d.ts +104 -25
- package/dest/mem_pools/attestation_pool/attestation_pool.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.d.ts +1 -1
- 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 +288 -174
- package/dest/mem_pools/attestation_pool/index.d.ts +1 -1
- package/dest/mem_pools/attestation_pool/kv_attestation_pool.d.ts +29 -11
- package/dest/mem_pools/attestation_pool/kv_attestation_pool.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/kv_attestation_pool.js +168 -62
- package/dest/mem_pools/attestation_pool/memory_attestation_pool.d.ts +24 -10
- package/dest/mem_pools/attestation_pool/memory_attestation_pool.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/memory_attestation_pool.js +133 -82
- package/dest/mem_pools/attestation_pool/mocks.d.ts +232 -11
- package/dest/mem_pools/attestation_pool/mocks.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/mocks.js +15 -20
- package/dest/mem_pools/index.d.ts +1 -1
- package/dest/mem_pools/instrumentation.d.ts +16 -12
- package/dest/mem_pools/instrumentation.d.ts.map +1 -1
- package/dest/mem_pools/instrumentation.js +55 -40
- package/dest/mem_pools/interface.d.ts +3 -4
- package/dest/mem_pools/interface.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.d.ts +70 -16
- package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.js +452 -142
- package/dest/mem_pools/tx_pool/eviction/eviction_manager.d.ts +18 -0
- package/dest/mem_pools/tx_pool/eviction/eviction_manager.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool/eviction/eviction_manager.js +56 -0
- package/dest/mem_pools/tx_pool/eviction/eviction_strategy.d.ts +83 -0
- package/dest/mem_pools/tx_pool/eviction/eviction_strategy.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool/eviction/eviction_strategy.js +5 -0
- package/dest/mem_pools/tx_pool/eviction/insufficient_fee_payer_balance_rule.d.ts +15 -0
- package/dest/mem_pools/tx_pool/eviction/insufficient_fee_payer_balance_rule.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool/eviction/insufficient_fee_payer_balance_rule.js +88 -0
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.d.ts +17 -0
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.js +84 -0
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.d.ts +19 -0
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.js +76 -0
- package/dest/mem_pools/tx_pool/eviction/low_priority_eviction_rule.d.ts +26 -0
- package/dest/mem_pools/tx_pool/eviction/low_priority_eviction_rule.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool/eviction/low_priority_eviction_rule.js +84 -0
- package/dest/mem_pools/tx_pool/index.d.ts +1 -2
- package/dest/mem_pools/tx_pool/index.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool/index.js +0 -1
- package/dest/mem_pools/tx_pool/priority.d.ts +5 -1
- package/dest/mem_pools/tx_pool/priority.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool/priority.js +7 -2
- package/dest/mem_pools/tx_pool/tx_pool.d.ts +72 -11
- package/dest/mem_pools/tx_pool/tx_pool.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool/tx_pool_test_suite.d.ts +1 -1
- package/dest/mem_pools/tx_pool/tx_pool_test_suite.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool/tx_pool_test_suite.js +276 -45
- package/dest/msg_validators/attestation_validator/attestation_validator.d.ts +7 -5
- package/dest/msg_validators/attestation_validator/attestation_validator.d.ts.map +1 -1
- package/dest/msg_validators/attestation_validator/attestation_validator.js +48 -10
- package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.d.ts +20 -0
- package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.d.ts.map +1 -0
- package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.js +64 -0
- package/dest/msg_validators/attestation_validator/index.d.ts +2 -1
- package/dest/msg_validators/attestation_validator/index.d.ts.map +1 -1
- package/dest/msg_validators/attestation_validator/index.js +1 -0
- package/dest/msg_validators/index.d.ts +2 -2
- package/dest/msg_validators/index.d.ts.map +1 -1
- package/dest/msg_validators/index.js +1 -1
- package/dest/msg_validators/msg_seen_validator/msg_seen_validator.d.ts +10 -0
- package/dest/msg_validators/msg_seen_validator/msg_seen_validator.d.ts.map +1 -0
- package/dest/msg_validators/msg_seen_validator/msg_seen_validator.js +36 -0
- package/dest/msg_validators/proposal_validator/block_proposal_validator.d.ts +9 -0
- package/dest/msg_validators/proposal_validator/block_proposal_validator.d.ts.map +1 -0
- package/dest/msg_validators/proposal_validator/block_proposal_validator.js +6 -0
- package/dest/msg_validators/proposal_validator/checkpoint_proposal_validator.d.ts +9 -0
- package/dest/msg_validators/proposal_validator/checkpoint_proposal_validator.d.ts.map +1 -0
- package/dest/msg_validators/proposal_validator/checkpoint_proposal_validator.js +6 -0
- package/dest/msg_validators/proposal_validator/index.d.ts +4 -0
- package/dest/msg_validators/proposal_validator/index.d.ts.map +1 -0
- package/dest/msg_validators/proposal_validator/index.js +3 -0
- package/dest/msg_validators/proposal_validator/proposal_validator.d.ts +13 -0
- package/dest/msg_validators/proposal_validator/proposal_validator.d.ts.map +1 -0
- package/dest/msg_validators/proposal_validator/proposal_validator.js +80 -0
- package/dest/msg_validators/proposal_validator/proposal_validator_test_suite.d.ts +23 -0
- package/dest/msg_validators/proposal_validator/proposal_validator_test_suite.d.ts.map +1 -0
- package/dest/msg_validators/proposal_validator/proposal_validator_test_suite.js +183 -0
- package/dest/msg_validators/tx_validator/aggregate_tx_validator.d.ts +1 -1
- package/dest/msg_validators/tx_validator/aggregate_tx_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/allowed_public_setup.d.ts +3 -0
- package/dest/msg_validators/tx_validator/allowed_public_setup.d.ts.map +1 -0
- package/dest/msg_validators/tx_validator/allowed_public_setup.js +27 -0
- package/dest/msg_validators/tx_validator/archive_cache.d.ts +14 -0
- package/dest/msg_validators/tx_validator/archive_cache.d.ts.map +1 -0
- package/dest/msg_validators/tx_validator/archive_cache.js +22 -0
- package/dest/msg_validators/tx_validator/block_header_validator.d.ts +2 -2
- package/dest/msg_validators/tx_validator/block_header_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/block_header_validator.js +4 -4
- 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 +56 -86
- package/dest/msg_validators/tx_validator/double_spend_validator.d.ts +1 -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 +21 -27
- package/dest/msg_validators/tx_validator/factory.d.ts +16 -0
- package/dest/msg_validators/tx_validator/factory.d.ts.map +1 -0
- package/dest/msg_validators/tx_validator/factory.js +74 -0
- package/dest/msg_validators/tx_validator/gas_validator.d.ts +11 -0
- package/dest/msg_validators/tx_validator/gas_validator.d.ts.map +1 -0
- package/dest/msg_validators/tx_validator/gas_validator.js +115 -0
- package/dest/msg_validators/tx_validator/index.d.ts +8 -1
- package/dest/msg_validators/tx_validator/index.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/index.js +7 -0
- package/dest/msg_validators/tx_validator/metadata_validator.d.ts +9 -5
- package/dest/msg_validators/tx_validator/metadata_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/metadata_validator.js +39 -20
- package/dest/msg_validators/tx_validator/phases_validator.d.ts +14 -0
- package/dest/msg_validators/tx_validator/phases_validator.d.ts.map +1 -0
- package/dest/msg_validators/tx_validator/phases_validator.js +93 -0
- package/dest/msg_validators/tx_validator/test_utils.d.ts +17 -0
- package/dest/msg_validators/tx_validator/test_utils.d.ts.map +1 -0
- package/dest/msg_validators/tx_validator/test_utils.js +22 -0
- package/dest/msg_validators/tx_validator/timestamp_validator.d.ts +13 -0
- package/dest/msg_validators/tx_validator/timestamp_validator.d.ts.map +1 -0
- package/dest/msg_validators/tx_validator/timestamp_validator.js +32 -0
- package/dest/msg_validators/tx_validator/tx_permitted_validator.d.ts +8 -0
- package/dest/msg_validators/tx_validator/tx_permitted_validator.d.ts.map +1 -0
- package/dest/msg_validators/tx_validator/tx_permitted_validator.js +24 -0
- package/dest/msg_validators/tx_validator/tx_proof_validator.d.ts +1 -1
- package/dest/msg_validators/tx_validator/tx_proof_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/tx_proof_validator.js +6 -5
- package/dest/services/data_store.d.ts +1 -1
- package/dest/services/data_store.d.ts.map +1 -1
- package/dest/services/discv5/discV5_service.d.ts +10 -9
- package/dest/services/discv5/discV5_service.d.ts.map +1 -1
- package/dest/services/discv5/discV5_service.js +63 -36
- package/dest/services/dummy_service.d.ts +54 -11
- package/dest/services/dummy_service.d.ts.map +1 -1
- package/dest/services/dummy_service.js +91 -5
- package/dest/services/encoding.d.ts +26 -7
- package/dest/services/encoding.d.ts.map +1 -1
- package/dest/services/encoding.js +76 -6
- package/dest/services/gossipsub/scoring.d.ts +1 -1
- package/dest/services/index.d.ts +5 -1
- package/dest/services/index.d.ts.map +1 -1
- package/dest/services/index.js +4 -0
- package/dest/services/libp2p/instrumentation.d.ts +20 -0
- package/dest/services/libp2p/instrumentation.d.ts.map +1 -0
- package/dest/services/libp2p/instrumentation.js +111 -0
- package/dest/services/libp2p/libp2p_service.d.ts +102 -96
- package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
- package/dest/services/libp2p/libp2p_service.js +1307 -301
- package/dest/services/peer-manager/interface.d.ts +23 -0
- package/dest/services/peer-manager/interface.d.ts.map +1 -0
- package/dest/services/peer-manager/interface.js +1 -0
- package/dest/services/peer-manager/metrics.d.ts +11 -2
- package/dest/services/peer-manager/metrics.d.ts.map +1 -1
- package/dest/services/peer-manager/metrics.js +29 -12
- package/dest/services/peer-manager/peer_manager.d.ts +103 -23
- package/dest/services/peer-manager/peer_manager.d.ts.map +1 -1
- package/dest/services/peer-manager/peer_manager.js +551 -82
- 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 +37 -2
- package/dest/services/reqresp/config.d.ts +11 -9
- package/dest/services/reqresp/config.d.ts.map +1 -1
- package/dest/services/reqresp/config.js +18 -4
- package/dest/services/reqresp/connection-sampler/batch_connection_sampler.d.ts +2 -2
- package/dest/services/reqresp/connection-sampler/batch_connection_sampler.d.ts.map +1 -1
- package/dest/services/reqresp/connection-sampler/batch_connection_sampler.js +10 -6
- package/dest/services/reqresp/connection-sampler/connection_sampler.d.ts +31 -17
- package/dest/services/reqresp/connection-sampler/connection_sampler.d.ts.map +1 -1
- package/dest/services/reqresp/connection-sampler/connection_sampler.js +142 -84
- package/dest/services/reqresp/index.d.ts +3 -2
- package/dest/services/reqresp/index.d.ts.map +1 -1
- package/dest/services/reqresp/index.js +2 -1
- package/dest/services/reqresp/interface.d.ts +73 -24
- package/dest/services/reqresp/interface.d.ts.map +1 -1
- package/dest/services/reqresp/interface.js +46 -27
- 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 +5 -21
- package/dest/services/reqresp/protocols/auth.d.ts +43 -0
- package/dest/services/reqresp/protocols/auth.d.ts.map +1 -0
- package/dest/services/reqresp/protocols/auth.js +71 -0
- package/dest/services/reqresp/protocols/block.d.ts +6 -1
- package/dest/services/reqresp/protocols/block.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/block.js +30 -6
- package/dest/services/reqresp/protocols/block_txs/bitvector.d.ts +30 -0
- package/dest/services/reqresp/protocols/block_txs/bitvector.d.ts.map +1 -0
- package/dest/services/reqresp/protocols/block_txs/bitvector.js +75 -0
- package/dest/services/reqresp/protocols/block_txs/block_txs_handler.d.ts +11 -0
- package/dest/services/reqresp/protocols/block_txs/block_txs_handler.d.ts.map +1 -0
- package/dest/services/reqresp/protocols/block_txs/block_txs_handler.js +39 -0
- package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.d.ts +47 -0
- package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.d.ts.map +1 -0
- package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.js +75 -0
- package/dest/services/reqresp/protocols/block_txs/index.d.ts +4 -0
- package/dest/services/reqresp/protocols/block_txs/index.d.ts.map +1 -0
- package/dest/services/reqresp/protocols/block_txs/index.js +3 -0
- package/dest/services/reqresp/protocols/goodbye.d.ts +3 -5
- package/dest/services/reqresp/protocols/goodbye.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/goodbye.js +7 -7
- package/dest/services/reqresp/protocols/index.d.ts +3 -1
- package/dest/services/reqresp/protocols/index.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/index.js +2 -0
- package/dest/services/reqresp/protocols/ping.d.ts +1 -3
- package/dest/services/reqresp/protocols/ping.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/status.d.ts +40 -7
- package/dest/services/reqresp/protocols/status.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/status.js +75 -5
- package/dest/services/reqresp/protocols/tx.d.ts +14 -4
- package/dest/services/reqresp/protocols/tx.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/tx.js +34 -6
- package/dest/services/reqresp/rate-limiter/index.d.ts +1 -1
- package/dest/services/reqresp/rate-limiter/rate_limiter.d.ts +6 -4
- package/dest/services/reqresp/rate-limiter/rate_limiter.d.ts.map +1 -1
- package/dest/services/reqresp/rate-limiter/rate_limiter.js +10 -2
- 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 +21 -1
- package/dest/services/reqresp/reqresp.d.ts +24 -66
- package/dest/services/reqresp/reqresp.d.ts.map +1 -1
- package/dest/services/reqresp/reqresp.js +699 -230
- package/dest/services/reqresp/status.d.ts +10 -4
- package/dest/services/reqresp/status.d.ts.map +1 -1
- package/dest/services/reqresp/status.js +9 -2
- package/dest/services/service.d.ts +37 -20
- package/dest/services/service.d.ts.map +1 -1
- package/dest/services/tx_collection/config.d.ts +25 -0
- package/dest/services/tx_collection/config.d.ts.map +1 -0
- package/dest/services/tx_collection/config.js +58 -0
- package/dest/services/tx_collection/fast_tx_collection.d.ts +51 -0
- package/dest/services/tx_collection/fast_tx_collection.d.ts.map +1 -0
- package/dest/services/tx_collection/fast_tx_collection.js +300 -0
- package/dest/services/tx_collection/index.d.ts +3 -0
- package/dest/services/tx_collection/index.d.ts.map +1 -0
- package/dest/services/tx_collection/index.js +2 -0
- package/dest/services/tx_collection/instrumentation.d.ts +10 -0
- package/dest/services/tx_collection/instrumentation.d.ts.map +1 -0
- package/dest/services/tx_collection/instrumentation.js +24 -0
- package/dest/services/tx_collection/slow_tx_collection.d.ts +53 -0
- package/dest/services/tx_collection/slow_tx_collection.d.ts.map +1 -0
- package/dest/services/tx_collection/slow_tx_collection.js +177 -0
- package/dest/services/tx_collection/tx_collection.d.ts +110 -0
- package/dest/services/tx_collection/tx_collection.d.ts.map +1 -0
- package/dest/services/tx_collection/tx_collection.js +128 -0
- package/dest/services/tx_collection/tx_collection_sink.d.ts +30 -0
- package/dest/services/tx_collection/tx_collection_sink.d.ts.map +1 -0
- package/dest/services/tx_collection/tx_collection_sink.js +111 -0
- package/dest/services/tx_collection/tx_source.d.ts +18 -0
- package/dest/services/tx_collection/tx_source.d.ts.map +1 -0
- package/dest/services/tx_collection/tx_source.js +31 -0
- package/dest/services/tx_provider.d.ts +51 -0
- package/dest/services/tx_provider.d.ts.map +1 -0
- package/dest/services/tx_provider.js +219 -0
- package/dest/services/tx_provider_instrumentation.d.ts +16 -0
- package/dest/services/tx_provider_instrumentation.d.ts.map +1 -0
- package/dest/services/tx_provider_instrumentation.js +34 -0
- package/dest/test-helpers/generate-peer-id-private-keys.d.ts +1 -1
- package/dest/test-helpers/get-ports.d.ts +1 -1
- package/dest/test-helpers/get-ports.d.ts.map +1 -1
- package/dest/test-helpers/index.d.ts +2 -1
- package/dest/test-helpers/index.d.ts.map +1 -1
- package/dest/test-helpers/index.js +1 -0
- package/dest/test-helpers/make-enrs.d.ts +1 -1
- package/dest/test-helpers/make-enrs.d.ts.map +1 -1
- package/dest/test-helpers/make-enrs.js +4 -5
- package/dest/test-helpers/make-test-p2p-clients.d.ts +33 -5
- package/dest/test-helpers/make-test-p2p-clients.d.ts.map +1 -1
- package/dest/test-helpers/make-test-p2p-clients.js +86 -16
- package/dest/test-helpers/mock-pubsub.d.ts +59 -0
- package/dest/test-helpers/mock-pubsub.d.ts.map +1 -0
- package/dest/test-helpers/mock-pubsub.js +130 -0
- package/dest/test-helpers/mock-tx-helpers.d.ts +12 -0
- package/dest/test-helpers/mock-tx-helpers.d.ts.map +1 -0
- package/dest/test-helpers/mock-tx-helpers.js +19 -0
- package/dest/test-helpers/reqresp-nodes.d.ts +15 -11
- package/dest/test-helpers/reqresp-nodes.d.ts.map +1 -1
- package/dest/test-helpers/reqresp-nodes.js +62 -28
- package/dest/testbench/p2p_client_testbench_worker.d.ts +1 -1
- package/dest/testbench/p2p_client_testbench_worker.js +124 -35
- package/dest/testbench/parse_log_file.d.ts +1 -1
- package/dest/testbench/parse_log_file.js +4 -4
- package/dest/testbench/testbench.d.ts +1 -1
- package/dest/testbench/testbench.js +4 -4
- package/dest/testbench/worker_client_manager.d.ts +1 -6
- package/dest/testbench/worker_client_manager.d.ts.map +1 -1
- package/dest/testbench/worker_client_manager.js +17 -20
- package/dest/types/index.d.ts +4 -2
- package/dest/types/index.d.ts.map +1 -1
- package/dest/types/index.js +2 -0
- package/dest/util.d.ts +24 -16
- package/dest/util.d.ts.map +1 -1
- package/dest/util.js +75 -69
- package/dest/versioning.d.ts +4 -4
- package/dest/versioning.d.ts.map +1 -1
- package/dest/versioning.js +8 -3
- package/package.json +32 -27
- package/src/bootstrap/bootstrap.ts +27 -11
- package/src/client/factory.ts +139 -53
- package/src/client/index.ts +1 -0
- package/src/client/interface.ts +213 -0
- package/src/client/p2p_client.ts +471 -385
- package/src/config.ts +299 -134
- package/src/enr/generate-enr.ts +39 -6
- package/src/errors/attestation-pool.error.ts +13 -0
- package/src/index.ts +4 -0
- package/src/mem_pools/attestation_pool/attestation_pool.ts +119 -24
- package/src/mem_pools/attestation_pool/attestation_pool_test_suite.ts +344 -201
- package/src/mem_pools/attestation_pool/kv_attestation_pool.ts +233 -72
- package/src/mem_pools/attestation_pool/memory_attestation_pool.ts +199 -96
- package/src/mem_pools/attestation_pool/mocks.ts +21 -16
- package/src/mem_pools/instrumentation.ts +71 -48
- package/src/mem_pools/interface.ts +2 -4
- package/src/mem_pools/tx_pool/README.md +255 -0
- package/src/mem_pools/tx_pool/aztec_kv_tx_pool.ts +537 -155
- package/src/mem_pools/tx_pool/eviction/eviction_manager.ts +71 -0
- package/src/mem_pools/tx_pool/eviction/eviction_strategy.ts +93 -0
- package/src/mem_pools/tx_pool/eviction/insufficient_fee_payer_balance_rule.ts +108 -0
- package/src/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.ts +104 -0
- package/src/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.ts +91 -0
- package/src/mem_pools/tx_pool/eviction/low_priority_eviction_rule.ts +106 -0
- package/src/mem_pools/tx_pool/index.ts +0 -1
- package/src/mem_pools/tx_pool/priority.ts +9 -2
- package/src/mem_pools/tx_pool/tx_pool.ts +75 -10
- package/src/mem_pools/tx_pool/tx_pool_test_suite.ts +225 -36
- package/src/msg_validators/attestation_validator/attestation_validator.ts +60 -14
- package/src/msg_validators/attestation_validator/fisherman_attestation_validator.ts +88 -0
- package/src/msg_validators/attestation_validator/index.ts +1 -0
- package/src/msg_validators/index.ts +1 -1
- package/src/msg_validators/msg_seen_validator/msg_seen_validator.ts +36 -0
- package/src/msg_validators/proposal_validator/block_proposal_validator.ts +10 -0
- package/src/msg_validators/proposal_validator/checkpoint_proposal_validator.ts +13 -0
- package/src/msg_validators/proposal_validator/index.ts +3 -0
- package/src/msg_validators/proposal_validator/proposal_validator.ts +92 -0
- package/src/msg_validators/proposal_validator/proposal_validator_test_suite.ts +206 -0
- package/src/msg_validators/tx_validator/allowed_public_setup.ts +35 -0
- package/src/msg_validators/tx_validator/archive_cache.ts +28 -0
- package/src/msg_validators/tx_validator/block_header_validator.ts +5 -5
- package/src/msg_validators/tx_validator/data_validator.ts +89 -69
- package/src/msg_validators/tx_validator/double_spend_validator.ts +19 -17
- package/src/msg_validators/tx_validator/factory.ts +110 -0
- package/src/msg_validators/tx_validator/gas_validator.ts +134 -0
- package/src/msg_validators/tx_validator/index.ts +7 -0
- package/src/msg_validators/tx_validator/metadata_validator.ts +67 -22
- package/src/msg_validators/tx_validator/phases_validator.ts +116 -0
- package/src/msg_validators/tx_validator/test_utils.ts +43 -0
- package/src/msg_validators/tx_validator/timestamp_validator.ts +49 -0
- package/src/msg_validators/tx_validator/tx_permitted_validator.ts +17 -0
- package/src/msg_validators/tx_validator/tx_proof_validator.ts +6 -5
- package/src/services/discv5/discV5_service.ts +84 -38
- package/src/services/dummy_service.ts +153 -9
- package/src/services/encoding.ts +83 -6
- package/src/services/index.ts +4 -0
- package/src/services/libp2p/instrumentation.ts +113 -0
- package/src/services/libp2p/libp2p_service.ts +1120 -329
- package/src/services/peer-manager/interface.ts +29 -0
- package/src/services/peer-manager/metrics.ts +38 -12
- package/src/services/peer-manager/peer_manager.ts +657 -80
- package/src/services/peer-manager/peer_scoring.ts +42 -3
- package/src/services/reqresp/config.ts +26 -9
- package/src/services/reqresp/connection-sampler/batch_connection_sampler.ts +12 -6
- package/src/services/reqresp/connection-sampler/connection_sampler.ts +150 -95
- package/src/services/reqresp/index.ts +2 -0
- package/src/services/reqresp/interface.ts +92 -37
- package/src/services/reqresp/metrics.ts +11 -24
- package/src/services/reqresp/protocols/auth.ts +83 -0
- package/src/services/reqresp/protocols/block.ts +26 -4
- package/src/services/reqresp/protocols/block_txs/bitvector.ts +90 -0
- package/src/services/reqresp/protocols/block_txs/block_txs_handler.ts +53 -0
- package/src/services/reqresp/protocols/block_txs/block_txs_reqresp.ts +79 -0
- package/src/services/reqresp/protocols/block_txs/index.ts +3 -0
- package/src/services/reqresp/protocols/goodbye.ts +9 -7
- package/src/services/reqresp/protocols/index.ts +2 -0
- package/src/services/reqresp/protocols/status.ts +119 -5
- package/src/services/reqresp/protocols/tx.ts +36 -8
- package/src/services/reqresp/rate-limiter/rate_limiter.ts +12 -3
- package/src/services/reqresp/rate-limiter/rate_limits.ts +21 -1
- package/src/services/reqresp/reqresp.ts +387 -256
- package/src/services/reqresp/status.ts +12 -3
- package/src/services/service.ts +61 -22
- package/src/services/tx_collection/config.ts +84 -0
- package/src/services/tx_collection/fast_tx_collection.ts +341 -0
- package/src/services/tx_collection/index.ts +2 -0
- package/src/services/tx_collection/instrumentation.ts +26 -0
- package/src/services/tx_collection/slow_tx_collection.ts +233 -0
- package/src/services/tx_collection/tx_collection.ts +216 -0
- package/src/services/tx_collection/tx_collection_sink.ts +129 -0
- package/src/services/tx_collection/tx_source.ts +37 -0
- package/src/services/tx_provider.ts +232 -0
- package/src/services/tx_provider_instrumentation.ts +48 -0
- package/src/test-helpers/index.ts +1 -0
- package/src/test-helpers/make-enrs.ts +4 -5
- package/src/test-helpers/make-test-p2p-clients.ts +111 -21
- package/src/test-helpers/mock-pubsub.ts +188 -0
- package/src/test-helpers/mock-tx-helpers.ts +24 -0
- package/src/test-helpers/reqresp-nodes.ts +87 -36
- package/src/testbench/p2p_client_testbench_worker.ts +182 -32
- package/src/testbench/parse_log_file.ts +4 -4
- package/src/testbench/testbench.ts +4 -4
- package/src/testbench/worker_client_manager.ts +23 -24
- package/src/types/index.ts +2 -0
- package/src/util.ts +105 -91
- package/src/versioning.ts +11 -4
- package/dest/mem_pools/tx_pool/memory_tx_pool.d.ts +0 -56
- package/dest/mem_pools/tx_pool/memory_tx_pool.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/memory_tx_pool.js +0 -141
- package/dest/msg_validators/block_proposal_validator/block_proposal_validator.d.ts +0 -8
- package/dest/msg_validators/block_proposal_validator/block_proposal_validator.d.ts.map +0 -1
- package/dest/msg_validators/block_proposal_validator/block_proposal_validator.js +0 -21
- package/dest/msg_validators/block_proposal_validator/index.d.ts +0 -2
- package/dest/msg_validators/block_proposal_validator/index.d.ts.map +0 -1
- package/dest/msg_validators/block_proposal_validator/index.js +0 -1
- package/src/mem_pools/tx_pool/memory_tx_pool.ts +0 -174
- package/src/msg_validators/block_proposal_validator/block_proposal_validator.ts +0 -29
- package/src/msg_validators/block_proposal_validator/index.ts +0 -1
|
@@ -1,14 +1,26 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { BlockNumber } from '@aztec/foundation/branded-types';
|
|
2
|
+
import type { TypedEventEmitter } from '@aztec/foundation/types';
|
|
3
|
+
import type { BlockHeader, Tx, TxHash } from '@aztec/stdlib/tx';
|
|
4
|
+
|
|
5
|
+
export type TxPoolOptions = {
|
|
6
|
+
maxPendingTxCount?: number;
|
|
7
|
+
archivedTxLimit?: number;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export type TxPoolEvents = {
|
|
11
|
+
['txs-added']: (args: { txs: Tx[]; source?: string }) => void | Promise<void>;
|
|
12
|
+
};
|
|
2
13
|
|
|
3
14
|
/**
|
|
4
15
|
* Interface of a transaction pool. The pool includes tx requests and is kept up-to-date by a P2P client.
|
|
5
16
|
*/
|
|
6
|
-
export interface TxPool {
|
|
17
|
+
export interface TxPool extends TypedEventEmitter<TxPoolEvents> {
|
|
7
18
|
/**
|
|
8
19
|
* Adds a list of transactions to the pool. Duplicates are ignored.
|
|
9
20
|
* @param txs - An array of txs to be added to the pool.
|
|
21
|
+
* @returns The number of txs added to the pool. Note if the transaction already exists, it will not be added again.
|
|
10
22
|
*/
|
|
11
|
-
addTxs(txs: Tx[]): Promise<
|
|
23
|
+
addTxs(txs: Tx[], opts?: { source?: string }): Promise<number>;
|
|
12
24
|
|
|
13
25
|
/**
|
|
14
26
|
* Checks if a transaction exists in the pool and returns it.
|
|
@@ -17,6 +29,27 @@ export interface TxPool {
|
|
|
17
29
|
*/
|
|
18
30
|
getTxByHash(txHash: TxHash): Promise<Tx | undefined>;
|
|
19
31
|
|
|
32
|
+
/**
|
|
33
|
+
* Checks if transactions exist in the pool and returns them.
|
|
34
|
+
* @param txHashes - The hashes of the transactions
|
|
35
|
+
* @returns The transactions, if found, 'undefined' otherwise.
|
|
36
|
+
*/
|
|
37
|
+
getTxsByHash(txHashes: TxHash[]): Promise<(Tx | undefined)[]>;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Checks if transactions exist in the pool
|
|
41
|
+
* @param txHashes - The hashes of the transactions to check for
|
|
42
|
+
* @returns True or False for each tx hash
|
|
43
|
+
*/
|
|
44
|
+
hasTxs(txHashes: TxHash[]): Promise<boolean[]>;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Checks if a transaction exists in the pool
|
|
48
|
+
* @param txHash - The hash of the transaction to check for
|
|
49
|
+
* @returns True if the transaction exists, false otherwise
|
|
50
|
+
*/
|
|
51
|
+
hasTx(txHash: TxHash): Promise<boolean>;
|
|
52
|
+
|
|
20
53
|
/**
|
|
21
54
|
* Checks if an archived transaction exists in the pool and returns it.
|
|
22
55
|
* @param txHash - The hash of the transaction, used as an ID.
|
|
@@ -27,21 +60,23 @@ export interface TxPool {
|
|
|
27
60
|
/**
|
|
28
61
|
* Marks the set of txs as mined, as opposed to pending.
|
|
29
62
|
* @param txHashes - Hashes of the txs to flag as mined.
|
|
63
|
+
* @param blockHeader - The header of the mined block.
|
|
30
64
|
*/
|
|
31
|
-
markAsMined(txHashes: TxHash[],
|
|
65
|
+
markAsMined(txHashes: TxHash[], blockHeader: BlockHeader): Promise<void>;
|
|
32
66
|
|
|
33
67
|
/**
|
|
34
68
|
* Moves mined txs back to the pending set in the case of a reorg.
|
|
35
69
|
* Note: txs not known by this peer will be ignored.
|
|
36
70
|
* @param txHashes - Hashes of the txs to flag as pending.
|
|
71
|
+
* @param latestBlock - The block number the chain was pruned to.
|
|
37
72
|
*/
|
|
38
|
-
markMinedAsPending(txHashes: TxHash[]): Promise<void>;
|
|
73
|
+
markMinedAsPending(txHashes: TxHash[], latestBlock: BlockNumber): Promise<void>;
|
|
39
74
|
|
|
40
75
|
/**
|
|
41
76
|
* Deletes transactions from the pool. Tx hashes that are not present are ignored.
|
|
42
77
|
* @param txHashes - An array of tx hashes to be removed from the tx pool.
|
|
43
78
|
*/
|
|
44
|
-
deleteTxs(txHashes: TxHash[]): Promise<void>;
|
|
79
|
+
deleteTxs(txHashes: TxHash[], opts?: { permanently?: boolean }): Promise<void>;
|
|
45
80
|
|
|
46
81
|
/**
|
|
47
82
|
* Gets all transactions currently in the tx pool.
|
|
@@ -61,16 +96,46 @@ export interface TxPool {
|
|
|
61
96
|
*/
|
|
62
97
|
getPendingTxHashes(): Promise<TxHash[]>;
|
|
63
98
|
|
|
99
|
+
/** Returns the number of pending txs in the pool. */
|
|
100
|
+
getPendingTxCount(): Promise<number>;
|
|
101
|
+
|
|
64
102
|
/**
|
|
65
103
|
* Gets the hashes of mined transactions currently in the tx pool.
|
|
66
104
|
* @returns An array of mined transaction hashes found in the tx pool.
|
|
67
105
|
*/
|
|
68
|
-
getMinedTxHashes(): Promise<[tx: TxHash, blockNumber:
|
|
106
|
+
getMinedTxHashes(): Promise<[tx: TxHash, blockNumber: BlockNumber][]>;
|
|
69
107
|
|
|
70
108
|
/**
|
|
71
|
-
* Returns whether the given tx hash is flagged as pending or
|
|
109
|
+
* Returns whether the given tx hash is flagged as pending, mined, or deleted.
|
|
72
110
|
* @param txHash - Hash of the tx to query.
|
|
73
|
-
* @returns Pending or
|
|
111
|
+
* @returns Pending, mined, or deleted depending on its status, or undefined if not found.
|
|
112
|
+
*/
|
|
113
|
+
getTxStatus(txHash: TxHash): Promise<'pending' | 'mined' | 'deleted' | undefined>;
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Configure the maximum size of the tx pool
|
|
117
|
+
* @param maxSizeBytes - The maximum size in bytes of the mempool. Set to undefined to disable it
|
|
118
|
+
*/
|
|
119
|
+
updateConfig(config: TxPoolOptions): void;
|
|
120
|
+
|
|
121
|
+
/** Returns whether the pool is empty. */
|
|
122
|
+
isEmpty(): Promise<boolean>;
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Marks transactions as non-evictible in the pool.
|
|
126
|
+
* @param txHashes - Hashes of the transactions to mark as non-evictible.
|
|
127
|
+
*/
|
|
128
|
+
markTxsAsNonEvictable(txHashes: TxHash[]): Promise<void>;
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Clears collection of non-evictable transactions in the pool
|
|
132
|
+
*/
|
|
133
|
+
clearNonEvictableTxs(): Promise<void>;
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Permanently deletes deleted mined transactions from blocks up to and including the specified block number.
|
|
137
|
+
* @param blockNumber - Block number threshold. Deleted mined txs from this block or earlier will be permanently deleted.
|
|
138
|
+
* @returns The number of transactions permanently deleted.
|
|
74
139
|
*/
|
|
75
|
-
|
|
140
|
+
cleanupDeletedMinedTxs(blockNumber: BlockNumber): Promise<number>;
|
|
76
141
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
1
2
|
import { unfreeze } from '@aztec/foundation/types';
|
|
2
3
|
import { GasFees } from '@aztec/stdlib/gas';
|
|
3
4
|
import { mockTx } from '@aztec/stdlib/testing';
|
|
4
|
-
import type
|
|
5
|
+
import { BlockHeader, GlobalVariables, type Tx } from '@aztec/stdlib/tx';
|
|
5
6
|
|
|
6
7
|
import type { TxPool } from './tx_pool.js';
|
|
7
8
|
|
|
@@ -12,79 +13,123 @@ import type { TxPool } from './tx_pool.js';
|
|
|
12
13
|
export function describeTxPool(getTxPool: () => TxPool) {
|
|
13
14
|
let pool: TxPool;
|
|
14
15
|
|
|
16
|
+
const minedBlockHeader = BlockHeader.empty({
|
|
17
|
+
globalVariables: GlobalVariables.empty({ blockNumber: BlockNumber(1), timestamp: 0n }),
|
|
18
|
+
});
|
|
19
|
+
|
|
15
20
|
beforeEach(() => {
|
|
16
21
|
pool = getTxPool();
|
|
17
22
|
});
|
|
18
23
|
|
|
19
|
-
|
|
20
|
-
|
|
24
|
+
afterEach(() => {
|
|
25
|
+
pool.removeAllListeners('txs-added');
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it('adds txs to the pool as pending', async () => {
|
|
29
|
+
const tx1 = await mockTx(1);
|
|
21
30
|
|
|
22
31
|
await pool.addTxs([tx1]);
|
|
23
|
-
const poolTx = await pool.getTxByHash(
|
|
24
|
-
expect(
|
|
25
|
-
await expect(pool.getTxStatus(
|
|
26
|
-
await expect(pool.getPendingTxHashes()).resolves.toEqual([
|
|
32
|
+
const poolTx = await pool.getTxByHash(tx1.getTxHash());
|
|
33
|
+
expect(poolTx!.getTxHash()).toEqual(tx1.getTxHash());
|
|
34
|
+
await expect(pool.getTxStatus(tx1.getTxHash())).resolves.toEqual('pending');
|
|
35
|
+
await expect(pool.getPendingTxHashes()).resolves.toEqual([tx1.getTxHash()]);
|
|
36
|
+
await expect(pool.getPendingTxCount()).resolves.toEqual(1);
|
|
27
37
|
});
|
|
28
38
|
|
|
29
|
-
it('
|
|
30
|
-
const tx1 = await mockTx();
|
|
39
|
+
it('emits txs-added event with new txs', async () => {
|
|
40
|
+
const tx1 = await mockTx(1); // existing and pending
|
|
41
|
+
const tx2 = await mockTx(2); // mined but not known
|
|
42
|
+
const tx3 = await mockTx(3); // brand new
|
|
31
43
|
|
|
32
44
|
await pool.addTxs([tx1]);
|
|
33
|
-
await pool.
|
|
45
|
+
await pool.markAsMined([tx2.getTxHash()], minedBlockHeader);
|
|
46
|
+
|
|
47
|
+
let txsFromEvent: Tx[] | undefined = undefined;
|
|
48
|
+
pool.once('txs-added', ({ txs }) => {
|
|
49
|
+
txsFromEvent = txs;
|
|
50
|
+
});
|
|
34
51
|
|
|
35
|
-
await
|
|
36
|
-
|
|
52
|
+
await pool.addTxs([tx1, tx2, tx3]);
|
|
53
|
+
expect(txsFromEvent).toBeDefined();
|
|
54
|
+
expect(txsFromEvent).toHaveLength(2);
|
|
55
|
+
const eventHashes = txsFromEvent!.map(tx => tx.getTxHash());
|
|
56
|
+
expect(eventHashes).toEqual(expect.arrayContaining([tx2.getTxHash(), tx3.getTxHash()]));
|
|
37
57
|
});
|
|
38
58
|
|
|
39
|
-
it('
|
|
59
|
+
it('removes txs from the pool', async () => {
|
|
60
|
+
const pendingTx = await mockTx(1);
|
|
61
|
+
const minedTx = await mockTx(2);
|
|
62
|
+
|
|
63
|
+
await pool.addTxs([pendingTx, minedTx]);
|
|
64
|
+
await pool.markAsMined([minedTx.getTxHash()], minedBlockHeader);
|
|
65
|
+
|
|
66
|
+
// Delete a pending tx - should be permanently deleted
|
|
67
|
+
await pool.deleteTxs([pendingTx.getTxHash()]);
|
|
68
|
+
await expect(pool.getTxByHash(pendingTx.getTxHash())).resolves.toBeUndefined();
|
|
69
|
+
await expect(pool.getTxStatus(pendingTx.getTxHash())).resolves.toBeUndefined();
|
|
70
|
+
|
|
71
|
+
// Delete a mined tx - should be soft-deleted (still in storage)
|
|
72
|
+
await pool.deleteTxs([minedTx.getTxHash()]);
|
|
73
|
+
await expect(pool.getTxByHash(minedTx.getTxHash())).resolves.toBeDefined();
|
|
74
|
+
await expect(pool.getTxStatus(minedTx.getTxHash())).resolves.toEqual('deleted');
|
|
75
|
+
await expect(pool.getMinedTxHashes()).resolves.toEqual([]);
|
|
76
|
+
|
|
77
|
+
await expect(pool.getPendingTxCount()).resolves.toEqual(0);
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
it('marks txs as mined', async () => {
|
|
40
81
|
const tx1 = await mockTx(1);
|
|
41
82
|
const tx2 = await mockTx(2);
|
|
42
83
|
|
|
43
84
|
await pool.addTxs([tx1, tx2]);
|
|
44
|
-
await pool.markAsMined([
|
|
85
|
+
await pool.markAsMined([tx1.getTxHash()], minedBlockHeader);
|
|
45
86
|
|
|
46
|
-
await
|
|
47
|
-
|
|
48
|
-
await expect(pool.
|
|
49
|
-
await expect(pool.
|
|
87
|
+
const retrievedTx = await pool.getTxByHash(tx1.getTxHash());
|
|
88
|
+
expect(retrievedTx?.getTxHash()).toEqual(tx1.getTxHash());
|
|
89
|
+
await expect(pool.getTxStatus(tx1.getTxHash())).resolves.toEqual('mined');
|
|
90
|
+
await expect(pool.getMinedTxHashes()).resolves.toEqual([[tx1.getTxHash(), 1]]);
|
|
91
|
+
await expect(pool.getPendingTxHashes()).resolves.toEqual([tx2.getTxHash()]);
|
|
92
|
+
await expect(pool.getPendingTxCount()).resolves.toEqual(1);
|
|
50
93
|
});
|
|
51
94
|
|
|
52
|
-
it('
|
|
95
|
+
it('marks txs as pending after being mined', async () => {
|
|
53
96
|
const tx1 = await mockTx(1);
|
|
54
97
|
const tx2 = await mockTx(2);
|
|
55
98
|
|
|
56
99
|
await pool.addTxs([tx1, tx2]);
|
|
57
|
-
await pool.markAsMined([
|
|
100
|
+
await pool.markAsMined([tx1.getTxHash()], minedBlockHeader);
|
|
58
101
|
|
|
59
|
-
await pool.markMinedAsPending([
|
|
102
|
+
await pool.markMinedAsPending([tx1.getTxHash()], BlockNumber(1));
|
|
60
103
|
await expect(pool.getMinedTxHashes()).resolves.toEqual([]);
|
|
61
104
|
const pending = await pool.getPendingTxHashes();
|
|
62
105
|
expect(pending).toHaveLength(2);
|
|
63
|
-
expect(pending).toEqual(expect.arrayContaining([
|
|
106
|
+
expect(pending).toEqual(expect.arrayContaining([tx1.getTxHash(), tx2.getTxHash()]));
|
|
107
|
+
await expect(pool.getPendingTxCount()).resolves.toEqual(2);
|
|
64
108
|
});
|
|
65
109
|
|
|
66
|
-
it('
|
|
110
|
+
it('only marks txs as pending if they are known', async () => {
|
|
67
111
|
const tx1 = await mockTx(1);
|
|
68
112
|
// simulate a situation where not all peers have all the txs
|
|
69
113
|
const tx2 = await mockTx(2);
|
|
70
|
-
const someTxHashThatThisPeerDidNotSee =
|
|
114
|
+
const someTxHashThatThisPeerDidNotSee = tx2.getTxHash();
|
|
71
115
|
await pool.addTxs([tx1]);
|
|
72
116
|
// this peer knows that tx2 was mined, but it does not have the tx object
|
|
73
|
-
await pool.markAsMined([
|
|
117
|
+
await pool.markAsMined([tx1.getTxHash(), someTxHashThatThisPeerDidNotSee], minedBlockHeader);
|
|
74
118
|
expect(await pool.getMinedTxHashes()).toEqual(
|
|
75
119
|
expect.arrayContaining([
|
|
76
|
-
[
|
|
120
|
+
[tx1.getTxHash(), 1],
|
|
77
121
|
[someTxHashThatThisPeerDidNotSee, 1],
|
|
78
122
|
]),
|
|
79
123
|
);
|
|
80
124
|
|
|
81
125
|
// reorg: both txs should now become available again
|
|
82
|
-
await pool.markMinedAsPending([
|
|
126
|
+
await pool.markMinedAsPending([tx1.getTxHash(), someTxHashThatThisPeerDidNotSee], BlockNumber(1));
|
|
83
127
|
await expect(pool.getMinedTxHashes()).resolves.toEqual([]);
|
|
84
|
-
await expect(pool.getPendingTxHashes()).resolves.toEqual([
|
|
128
|
+
await expect(pool.getPendingTxHashes()).resolves.toEqual([tx1.getTxHash()]); // tx2 is not in the pool
|
|
129
|
+
await expect(pool.getPendingTxCount()).resolves.toEqual(1);
|
|
85
130
|
});
|
|
86
131
|
|
|
87
|
-
it('
|
|
132
|
+
it('returns all transactions in the pool', async () => {
|
|
88
133
|
const tx1 = await mockTx(1);
|
|
89
134
|
const tx2 = await mockTx(2);
|
|
90
135
|
const tx3 = await mockTx(3);
|
|
@@ -93,10 +138,12 @@ export function describeTxPool(getTxPool: () => TxPool) {
|
|
|
93
138
|
|
|
94
139
|
const poolTxs = await pool.getAllTxs();
|
|
95
140
|
expect(poolTxs).toHaveLength(3);
|
|
96
|
-
|
|
141
|
+
const poolHashes = poolTxs.map(tx => tx.getTxHash());
|
|
142
|
+
expect(poolHashes).toEqual(expect.arrayContaining([tx1.getTxHash(), tx2.getTxHash(), tx3.getTxHash()]));
|
|
143
|
+
await expect(pool.getPendingTxCount()).resolves.toEqual(3);
|
|
97
144
|
});
|
|
98
145
|
|
|
99
|
-
it('
|
|
146
|
+
it('returns all txHashes in the pool', async () => {
|
|
100
147
|
const tx1 = await mockTx(1);
|
|
101
148
|
const tx2 = await mockTx(2);
|
|
102
149
|
const tx3 = await mockTx(3);
|
|
@@ -104,13 +151,58 @@ export function describeTxPool(getTxPool: () => TxPool) {
|
|
|
104
151
|
await pool.addTxs([tx1, tx2, tx3]);
|
|
105
152
|
|
|
106
153
|
const poolTxHashes = await pool.getAllTxHashes();
|
|
154
|
+
const expectedHashes = [tx1, tx2, tx3].map(tx => tx.getTxHash());
|
|
107
155
|
expect(poolTxHashes).toHaveLength(3);
|
|
108
|
-
expect(poolTxHashes).toEqual(
|
|
109
|
-
|
|
110
|
-
);
|
|
156
|
+
expect(poolTxHashes).toEqual(expect.arrayContaining(expectedHashes));
|
|
157
|
+
await expect(pool.getPendingTxCount()).resolves.toEqual(3);
|
|
111
158
|
});
|
|
112
159
|
|
|
113
|
-
it('
|
|
160
|
+
it('returns txs by their hash', async () => {
|
|
161
|
+
const tx1 = await mockTx(1);
|
|
162
|
+
const tx2 = await mockTx(2);
|
|
163
|
+
const tx3 = await mockTx(3);
|
|
164
|
+
|
|
165
|
+
await pool.addTxs([tx1, tx2, tx3]);
|
|
166
|
+
|
|
167
|
+
const requestedTxs = await pool.getTxsByHash([tx1.getTxHash(), tx3.getTxHash()]);
|
|
168
|
+
expect(requestedTxs).toHaveLength(2);
|
|
169
|
+
const requestedHashes = requestedTxs.map(tx => tx!.getTxHash());
|
|
170
|
+
expect(requestedHashes).toEqual(expect.arrayContaining([tx1.getTxHash(), tx3.getTxHash()]));
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
it('returns a large number of transactions by their hash', async () => {
|
|
174
|
+
const numTxs = 1_000;
|
|
175
|
+
const txs = await Promise.all(Array.from({ length: numTxs }, (_, i) => mockTx(i)));
|
|
176
|
+
const hashes = txs.map(tx => tx.getTxHash());
|
|
177
|
+
await pool.addTxs(txs);
|
|
178
|
+
const requestedTxs = await pool.getTxsByHash(hashes);
|
|
179
|
+
expect(requestedTxs).toHaveLength(numTxs);
|
|
180
|
+
const requestedHashes = requestedTxs.map(tx => tx!.getTxHash());
|
|
181
|
+
expect(requestedHashes).toEqual(expect.arrayContaining(hashes));
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
it('returns whether or not txs exist', async () => {
|
|
185
|
+
const tx1 = await mockTx(1);
|
|
186
|
+
const tx2 = await mockTx(2);
|
|
187
|
+
const tx3 = await mockTx(3);
|
|
188
|
+
|
|
189
|
+
await pool.addTxs([tx1, tx2, tx3]);
|
|
190
|
+
|
|
191
|
+
const tx4 = await mockTx(4);
|
|
192
|
+
const tx5 = await mockTx(5);
|
|
193
|
+
|
|
194
|
+
const availability = await pool.hasTxs([
|
|
195
|
+
tx1.getTxHash(),
|
|
196
|
+
tx2.getTxHash(),
|
|
197
|
+
tx3.getTxHash(),
|
|
198
|
+
tx4.getTxHash(),
|
|
199
|
+
tx5.getTxHash(),
|
|
200
|
+
]);
|
|
201
|
+
expect(availability).toHaveLength(5);
|
|
202
|
+
expect(availability).toEqual(expect.arrayContaining([true, true, true, false, false]));
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
it('returns pending tx hashes sorted by priority', async () => {
|
|
114
206
|
const withPriorityFee = (tx: Tx, fee: number) => {
|
|
115
207
|
unfreeze(tx.data.constants.txContext.gasSettings).maxPriorityFeesPerGas = new GasFees(fee, fee);
|
|
116
208
|
return tx;
|
|
@@ -125,6 +217,103 @@ export function describeTxPool(getTxPool: () => TxPool) {
|
|
|
125
217
|
|
|
126
218
|
const poolTxHashes = await pool.getPendingTxHashes();
|
|
127
219
|
expect(poolTxHashes).toHaveLength(4);
|
|
128
|
-
expect(poolTxHashes).toEqual(
|
|
220
|
+
expect(poolTxHashes).toEqual([tx4, tx1, tx3, tx2].map(tx => tx.getTxHash()));
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
describe('soft-delete', () => {
|
|
224
|
+
it('soft-deletes mined txs and keeps them in storage', async () => {
|
|
225
|
+
const txs = await Promise.all([mockTx(1), mockTx(2), mockTx(3)]);
|
|
226
|
+
await pool.addTxs(txs);
|
|
227
|
+
|
|
228
|
+
// Mark first tx as mined
|
|
229
|
+
await pool.markAsMined([txs[0].getTxHash()], minedBlockHeader);
|
|
230
|
+
|
|
231
|
+
// Verify initial state
|
|
232
|
+
await expect(pool.getPendingTxCount()).resolves.toBe(2);
|
|
233
|
+
await expect(pool.getTxByHash(txs[0].getTxHash())).resolves.toBeDefined();
|
|
234
|
+
await expect(pool.getTxByHash(txs[1].getTxHash())).resolves.toBeDefined();
|
|
235
|
+
|
|
236
|
+
// Delete mined tx - should be soft-deleted
|
|
237
|
+
await pool.deleteTxs([txs[0].getTxHash()]);
|
|
238
|
+
|
|
239
|
+
// Delete pending tx - should be permanently deleted
|
|
240
|
+
await pool.deleteTxs([txs[1].getTxHash()]);
|
|
241
|
+
|
|
242
|
+
// Verify mined tx still exists in storage but has 'deleted' status
|
|
243
|
+
await expect(pool.getTxByHash(txs[0].getTxHash())).resolves.toBeDefined();
|
|
244
|
+
await expect(pool.getTxStatus(txs[0].getTxHash())).resolves.toEqual('deleted');
|
|
245
|
+
|
|
246
|
+
// Verify pending tx is permanently deleted
|
|
247
|
+
await expect(pool.getTxByHash(txs[1].getTxHash())).resolves.toBeUndefined();
|
|
248
|
+
await expect(pool.getTxStatus(txs[1].getTxHash())).resolves.toBeUndefined();
|
|
249
|
+
|
|
250
|
+
// Verify remaining pending count
|
|
251
|
+
await expect(pool.getPendingTxCount()).resolves.toBe(1);
|
|
252
|
+
|
|
253
|
+
// Verify pending hashes don't include deleted txs
|
|
254
|
+
const pendingHashes = await pool.getPendingTxHashes();
|
|
255
|
+
expect(pendingHashes).toHaveLength(1);
|
|
256
|
+
expect(pendingHashes.map(h => h.toString())).toContain(txs[2].getTxHash().toString());
|
|
257
|
+
});
|
|
258
|
+
|
|
259
|
+
it('cleans up old deleted mined transactions', async () => {
|
|
260
|
+
const txs = await Promise.all([mockTx(1), mockTx(2), mockTx(3)]);
|
|
261
|
+
await pool.addTxs(txs);
|
|
262
|
+
|
|
263
|
+
// Mark first two as mined in block 1
|
|
264
|
+
await pool.markAsMined([txs[0].getTxHash(), txs[1].getTxHash()], minedBlockHeader);
|
|
265
|
+
|
|
266
|
+
// Soft-delete mined transactions
|
|
267
|
+
await pool.deleteTxs([txs[0].getTxHash(), txs[1].getTxHash()]);
|
|
268
|
+
|
|
269
|
+
// Clean up deleted mined txs from block 1 and earlier
|
|
270
|
+
const deletedCount = await pool.cleanupDeletedMinedTxs(BlockNumber(1));
|
|
271
|
+
|
|
272
|
+
// Verify old transactions are permanently deleted
|
|
273
|
+
expect(deletedCount).toBe(2);
|
|
274
|
+
await expect(pool.getTxByHash(txs[0].getTxHash())).resolves.toBeUndefined();
|
|
275
|
+
await expect(pool.getTxByHash(txs[1].getTxHash())).resolves.toBeUndefined();
|
|
276
|
+
await expect(pool.getTxByHash(txs[2].getTxHash())).resolves.toBeDefined();
|
|
277
|
+
});
|
|
278
|
+
|
|
279
|
+
it('does not clean up recent deleted mined transactions', async () => {
|
|
280
|
+
const txs = await Promise.all([mockTx(1), mockTx(2)]);
|
|
281
|
+
await pool.addTxs(txs);
|
|
282
|
+
|
|
283
|
+
// Mark as mined in block 2
|
|
284
|
+
const laterBlockHeader = BlockHeader.empty({
|
|
285
|
+
globalVariables: GlobalVariables.empty({ blockNumber: BlockNumber(2), timestamp: 0n }),
|
|
286
|
+
});
|
|
287
|
+
await pool.markAsMined([txs[0].getTxHash()], laterBlockHeader);
|
|
288
|
+
|
|
289
|
+
// Soft-delete a mined transaction
|
|
290
|
+
await pool.deleteTxs([txs[0].getTxHash()]);
|
|
291
|
+
|
|
292
|
+
// Try to clean up with block 1 (before the mined block)
|
|
293
|
+
const deletedCount = await pool.cleanupDeletedMinedTxs(BlockNumber(1));
|
|
294
|
+
|
|
295
|
+
// Verify no transactions were cleaned up
|
|
296
|
+
expect(deletedCount).toBe(0);
|
|
297
|
+
await expect(pool.getTxByHash(txs[0].getTxHash())).resolves.toBeDefined();
|
|
298
|
+
});
|
|
299
|
+
|
|
300
|
+
it('restores deleted mined tx when it is mined again', async () => {
|
|
301
|
+
const tx = await mockTx(1);
|
|
302
|
+
await pool.addTxs([tx]);
|
|
303
|
+
|
|
304
|
+
// Mark as mined
|
|
305
|
+
await pool.markAsMined([tx.getTxHash()], minedBlockHeader);
|
|
306
|
+
|
|
307
|
+
// Soft-delete it
|
|
308
|
+
await pool.deleteTxs([tx.getTxHash()]);
|
|
309
|
+
await expect(pool.getTxStatus(tx.getTxHash())).resolves.toEqual('deleted');
|
|
310
|
+
|
|
311
|
+
// Mark as mined again (e.g., after a reorg)
|
|
312
|
+
await pool.markAsMined([tx.getTxHash()], minedBlockHeader);
|
|
313
|
+
|
|
314
|
+
// Should be back to mined status
|
|
315
|
+
await expect(pool.getTxStatus(tx.getTxHash())).resolves.toEqual('mined');
|
|
316
|
+
await expect(pool.getTxByHash(tx.getTxHash())).resolves.toBeDefined();
|
|
317
|
+
});
|
|
129
318
|
});
|
|
130
319
|
}
|
|
@@ -1,26 +1,72 @@
|
|
|
1
1
|
import type { EpochCacheInterface } from '@aztec/epoch-cache';
|
|
2
|
-
import {
|
|
2
|
+
import { NoCommitteeError } from '@aztec/ethereum/contracts';
|
|
3
|
+
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
4
|
+
import { type CheckpointAttestation, type P2PValidator, PeerErrorSeverity } from '@aztec/stdlib/p2p';
|
|
3
5
|
|
|
4
|
-
export class
|
|
5
|
-
|
|
6
|
+
export class CheckpointAttestationValidator implements P2PValidator<CheckpointAttestation> {
|
|
7
|
+
protected epochCache: EpochCacheInterface;
|
|
8
|
+
protected logger: Logger;
|
|
6
9
|
|
|
7
10
|
constructor(epochCache: EpochCacheInterface) {
|
|
8
11
|
this.epochCache = epochCache;
|
|
12
|
+
this.logger = createLogger('p2p:checkpoint-attestation-validator');
|
|
9
13
|
}
|
|
10
14
|
|
|
11
|
-
async validate(message:
|
|
12
|
-
const
|
|
15
|
+
async validate(message: CheckpointAttestation): Promise<PeerErrorSeverity | undefined> {
|
|
16
|
+
const slotNumber = message.payload.header.slotNumber;
|
|
13
17
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
return PeerErrorSeverity.HighToleranceError;
|
|
17
|
-
}
|
|
18
|
+
try {
|
|
19
|
+
const { currentSlot, nextSlot } = await this.epochCache.getProposerAttesterAddressInCurrentOrNextSlot();
|
|
18
20
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
if (slotNumber !== currentSlot && slotNumber !== nextSlot) {
|
|
22
|
+
this.logger.warn(
|
|
23
|
+
`Checkpoint attestation slot ${slotNumber} is not current (${currentSlot}) or next (${nextSlot}) slot`,
|
|
24
|
+
);
|
|
25
|
+
return PeerErrorSeverity.HighToleranceError;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// Verify the signature is valid
|
|
29
|
+
const attester = message.getSender();
|
|
30
|
+
if (attester === undefined) {
|
|
31
|
+
this.logger.warn(`Invalid signature in checkpoint attestation for slot ${slotNumber}`);
|
|
32
|
+
return PeerErrorSeverity.LowToleranceError;
|
|
33
|
+
}
|
|
23
34
|
|
|
24
|
-
|
|
35
|
+
// Verify the attester is in the committee for this slot
|
|
36
|
+
if (!(await this.epochCache.isInCommittee(slotNumber, attester))) {
|
|
37
|
+
this.logger.warn(`Attester ${attester.toString()} is not in committee for slot ${slotNumber}`);
|
|
38
|
+
return PeerErrorSeverity.HighToleranceError;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Verify the proposer signature matches the expected proposer for the attestation's slot
|
|
42
|
+
// We look up the proposer for the specific slot rather than using currentSlot/nextSlot
|
|
43
|
+
// since timing differences could cause mismatches
|
|
44
|
+
const proposer = message.getProposer();
|
|
45
|
+
const expectedProposer = await this.epochCache.getProposerAttesterAddressInSlot(slotNumber);
|
|
46
|
+
if (!expectedProposer) {
|
|
47
|
+
this.logger.warn(`No proposer defined for slot ${slotNumber}`);
|
|
48
|
+
return PeerErrorSeverity.HighToleranceError;
|
|
49
|
+
}
|
|
50
|
+
if (!proposer) {
|
|
51
|
+
this.logger.warn(`Invalid proposer signature in checkpoint attestation for slot ${slotNumber}`);
|
|
52
|
+
return PeerErrorSeverity.LowToleranceError;
|
|
53
|
+
}
|
|
54
|
+
if (!proposer.equals(expectedProposer)) {
|
|
55
|
+
this.logger.warn(
|
|
56
|
+
`Proposer signature mismatch in checkpoint attestation. ` +
|
|
57
|
+
`Expected ${expectedProposer?.toString() ?? 'none'} but got ${proposer.toString()} for slot ${slotNumber}`,
|
|
58
|
+
);
|
|
59
|
+
return PeerErrorSeverity.HighToleranceError;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return undefined;
|
|
63
|
+
} catch (e) {
|
|
64
|
+
// People shouldn't be sending us attestations if the committee doesn't exist
|
|
65
|
+
if (e instanceof NoCommitteeError) {
|
|
66
|
+
this.logger.warn(`No committee exists for checkpoint attestation for slot ${slotNumber}`);
|
|
67
|
+
return PeerErrorSeverity.LowToleranceError;
|
|
68
|
+
}
|
|
69
|
+
throw e;
|
|
70
|
+
}
|
|
25
71
|
}
|
|
26
72
|
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import type { EpochCacheInterface } from '@aztec/epoch-cache';
|
|
2
|
+
import { type CheckpointAttestation, PeerErrorSeverity } from '@aztec/stdlib/p2p';
|
|
3
|
+
import { Attributes, Metrics, type TelemetryClient } from '@aztec/telemetry-client';
|
|
4
|
+
|
|
5
|
+
import type { AttestationPool } from '../../mem_pools/attestation_pool/attestation_pool.js';
|
|
6
|
+
import { CheckpointAttestationValidator } from './attestation_validator.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* FishermanAttestationValidator extends the base AttestationValidator to add
|
|
10
|
+
* additional validation for fisherman nodes: verifying that attestations sign
|
|
11
|
+
* the same payload as the original proposal.
|
|
12
|
+
* Invalid attestations are rejected (not propagated), but peer penalization is
|
|
13
|
+
* handled by LibP2PService based on the fishermanMode config to ensure a better
|
|
14
|
+
* view of the network.
|
|
15
|
+
*/
|
|
16
|
+
export class FishermanAttestationValidator extends CheckpointAttestationValidator {
|
|
17
|
+
private invalidAttestationCounter;
|
|
18
|
+
|
|
19
|
+
constructor(
|
|
20
|
+
epochCache: EpochCacheInterface,
|
|
21
|
+
private attestationPool: AttestationPool,
|
|
22
|
+
telemetryClient: TelemetryClient,
|
|
23
|
+
) {
|
|
24
|
+
super(epochCache);
|
|
25
|
+
this.logger = this.logger.createChild('[FISHERMAN]');
|
|
26
|
+
|
|
27
|
+
const meter = telemetryClient.getMeter('FishermanAttestationValidator');
|
|
28
|
+
this.invalidAttestationCounter = meter.createUpDownCounter(Metrics.VALIDATOR_INVALID_ATTESTATION_RECEIVED_COUNT);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
override async validate(message: CheckpointAttestation): Promise<PeerErrorSeverity | undefined> {
|
|
32
|
+
// First run the standard validation
|
|
33
|
+
const baseValidationResult = await super.validate(message);
|
|
34
|
+
if (baseValidationResult !== undefined) {
|
|
35
|
+
// Track base validation failures (invalid signature, wrong committee, etc.)
|
|
36
|
+
this.invalidAttestationCounter.add(1, {
|
|
37
|
+
[Attributes.ERROR_TYPE]: 'base_validation_failed',
|
|
38
|
+
});
|
|
39
|
+
return baseValidationResult;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// fisherman validation: verify attestation payload matches proposal payload
|
|
43
|
+
const slotNumberBigInt = message.payload.header.slotNumber;
|
|
44
|
+
const attester = message.getSender();
|
|
45
|
+
const proposer = message.getProposer();
|
|
46
|
+
|
|
47
|
+
if (!attester || !proposer) {
|
|
48
|
+
return undefined;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const proposalId = message.archive.toString();
|
|
52
|
+
const proposal = await this.attestationPool.getCheckpointProposal(proposalId);
|
|
53
|
+
|
|
54
|
+
if (proposal) {
|
|
55
|
+
// Compare the attestation payload with the proposal payload
|
|
56
|
+
if (!message.payload.equals(proposal)) {
|
|
57
|
+
this.logger.error(
|
|
58
|
+
`Attestation payload mismatch for slot ${slotNumberBigInt}! ` +
|
|
59
|
+
`Attester ${attester.toString()} signed different data than the proposal.`,
|
|
60
|
+
{
|
|
61
|
+
slot: slotNumberBigInt.toString(),
|
|
62
|
+
attester: attester.toString(),
|
|
63
|
+
proposer: proposer.toString(),
|
|
64
|
+
proposalArchive: proposal.archive.toString(),
|
|
65
|
+
attestationArchive: message.archive.toString(),
|
|
66
|
+
proposalHeader: proposal.checkpointHeader.hash().toString(),
|
|
67
|
+
attestationHeader: message.payload.header.hash().toString(),
|
|
68
|
+
},
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
// Track invalid attestation metric
|
|
72
|
+
this.invalidAttestationCounter.add(1, {
|
|
73
|
+
[Attributes.ERROR_TYPE]: 'payload_mismatch',
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
// Return error to reject the message, but LibP2PService won't penalize in fisherman mode
|
|
77
|
+
return PeerErrorSeverity.LowToleranceError;
|
|
78
|
+
}
|
|
79
|
+
} else {
|
|
80
|
+
// We might receive attestations before proposals in some cases
|
|
81
|
+
this.logger.debug(
|
|
82
|
+
`Received attestation for slot ${slotNumberBigInt} but proposal not found yet. ` + `Proposal ID: ${proposalId}`,
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return undefined;
|
|
87
|
+
}
|
|
88
|
+
}
|