@aztec/p2p 4.0.0-nightly.20250907 → 4.0.0-nightly.20260107
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 +14 -4
- package/dest/client/factory.d.ts +3 -2
- package/dest/client/factory.d.ts.map +1 -1
- package/dest/client/factory.js +9 -5
- package/dest/client/index.d.ts +1 -1
- package/dest/client/interface.d.ts +8 -6
- package/dest/client/interface.d.ts.map +1 -1
- package/dest/client/p2p_client.d.ts +12 -35
- package/dest/client/p2p_client.d.ts.map +1 -1
- package/dest/client/p2p_client.js +457 -61
- package/dest/config.d.ts +67 -61
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +28 -15
- package/dest/enr/generate-enr.d.ts +2 -2
- package/dest/enr/generate-enr.d.ts.map +1 -1
- package/dest/enr/generate-enr.js +1 -1
- 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 +1 -1
- package/dest/mem_pools/attestation_pool/attestation_pool.d.ts +43 -6
- 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 +72 -46
- package/dest/mem_pools/attestation_pool/index.d.ts +1 -1
- package/dest/mem_pools/attestation_pool/kv_attestation_pool.d.ts +15 -6
- package/dest/mem_pools/attestation_pool/kv_attestation_pool.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/kv_attestation_pool.js +73 -18
- package/dest/mem_pools/attestation_pool/memory_attestation_pool.d.ts +13 -6
- package/dest/mem_pools/attestation_pool/memory_attestation_pool.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/memory_attestation_pool.js +69 -11
- package/dest/mem_pools/attestation_pool/mocks.d.ts +226 -5
- package/dest/mem_pools/attestation_pool/mocks.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/mocks.js +9 -7
- package/dest/mem_pools/index.d.ts +1 -1
- package/dest/mem_pools/instrumentation.d.ts +9 -1
- package/dest/mem_pools/instrumentation.d.ts.map +1 -1
- package/dest/mem_pools/instrumentation.js +38 -2
- 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 +39 -58
- 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 +314 -317
- 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 +6 -1
- package/dest/mem_pools/tx_pool/tx_pool.d.ts +28 -9
- 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 +155 -25
- package/dest/msg_validators/attestation_validator/attestation_validator.d.ts +4 -2
- package/dest/msg_validators/attestation_validator/attestation_validator.d.ts.map +1 -1
- package/dest/msg_validators/attestation_validator/attestation_validator.js +32 -5
- 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 +67 -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/block_proposal_validator/block_proposal_validator.d.ts +5 -2
- package/dest/msg_validators/block_proposal_validator/block_proposal_validator.d.ts.map +1 -1
- package/dest/msg_validators/block_proposal_validator/block_proposal_validator.js +44 -12
- package/dest/msg_validators/block_proposal_validator/index.d.ts +1 -1
- package/dest/msg_validators/index.d.ts +1 -1
- package/dest/msg_validators/msg_seen_validator/msg_seen_validator.d.ts +1 -1
- package/dest/msg_validators/msg_seen_validator/msg_seen_validator.d.ts.map +1 -1
- 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 +1 -1
- package/dest/msg_validators/tx_validator/archive_cache.d.ts +2 -2
- package/dest/msg_validators/tx_validator/archive_cache.d.ts.map +1 -1
- 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 +1 -1
- 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/double_spend_validator.d.ts +1 -1
- package/dest/msg_validators/tx_validator/double_spend_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/double_spend_validator.js +1 -1
- package/dest/msg_validators/tx_validator/factory.d.ts +4 -3
- package/dest/msg_validators/tx_validator/factory.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/factory.js +11 -5
- package/dest/msg_validators/tx_validator/gas_validator.d.ts +1 -1
- package/dest/msg_validators/tx_validator/gas_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/index.d.ts +2 -1
- package/dest/msg_validators/tx_validator/index.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/index.js +1 -0
- package/dest/msg_validators/tx_validator/metadata_validator.d.ts +3 -6
- package/dest/msg_validators/tx_validator/metadata_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/metadata_validator.js +6 -24
- package/dest/msg_validators/tx_validator/phases_validator.d.ts +1 -1
- package/dest/msg_validators/tx_validator/phases_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/phases_validator.js +3 -1
- package/dest/msg_validators/tx_validator/test_utils.d.ts +2 -2
- package/dest/msg_validators/tx_validator/test_utils.d.ts.map +1 -1
- 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 +1 -1
- package/dest/msg_validators/tx_validator/tx_permitted_validator.d.ts.map +1 -1
- 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/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 +3 -3
- package/dest/services/discv5/discV5_service.d.ts.map +1 -1
- package/dest/services/discv5/discV5_service.js +2 -2
- package/dest/services/dummy_service.d.ts +2 -2
- package/dest/services/dummy_service.d.ts.map +1 -1
- package/dest/services/encoding.d.ts +25 -4
- package/dest/services/encoding.d.ts.map +1 -1
- package/dest/services/encoding.js +74 -6
- package/dest/services/gossipsub/scoring.d.ts +1 -1
- package/dest/services/index.d.ts +1 -1
- package/dest/services/libp2p/instrumentation.d.ts +3 -1
- package/dest/services/libp2p/instrumentation.d.ts.map +1 -1
- package/dest/services/libp2p/instrumentation.js +9 -2
- package/dest/services/libp2p/libp2p_service.d.ts +32 -72
- package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
- package/dest/services/libp2p/libp2p_service.js +796 -171
- package/dest/services/peer-manager/interface.d.ts +1 -1
- package/dest/services/peer-manager/metrics.d.ts +8 -1
- package/dest/services/peer-manager/metrics.d.ts.map +1 -1
- package/dest/services/peer-manager/metrics.js +28 -0
- package/dest/services/peer-manager/peer_manager.d.ts +1 -32
- package/dest/services/peer-manager/peer_manager.d.ts.map +1 -1
- package/dest/services/peer-manager/peer_manager.js +412 -21
- 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 +40 -2
- package/dest/services/reqresp/config.d.ts +1 -1
- package/dest/services/reqresp/connection-sampler/batch_connection_sampler.d.ts +1 -1
- package/dest/services/reqresp/connection-sampler/batch_connection_sampler.d.ts.map +1 -1
- package/dest/services/reqresp/connection-sampler/connection_sampler.d.ts +1 -4
- package/dest/services/reqresp/connection-sampler/connection_sampler.d.ts.map +1 -1
- package/dest/services/reqresp/index.d.ts +1 -1
- package/dest/services/reqresp/interface.d.ts +2 -11
- package/dest/services/reqresp/interface.d.ts.map +1 -1
- package/dest/services/reqresp/interface.js +1 -18
- package/dest/services/reqresp/metrics.d.ts +1 -1
- package/dest/services/reqresp/metrics.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/auth.d.ts +2 -2
- package/dest/services/reqresp/protocols/auth.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/auth.js +2 -2
- package/dest/services/reqresp/protocols/block.d.ts +1 -1
- package/dest/services/reqresp/protocols/block.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/block.js +3 -2
- package/dest/services/reqresp/protocols/block_txs/bitvector.d.ts +1 -1
- package/dest/services/reqresp/protocols/block_txs/bitvector.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/block_txs/block_txs_handler.d.ts +1 -1
- package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.d.ts +4 -6
- package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.js +1 -1
- package/dest/services/reqresp/protocols/block_txs/index.d.ts +1 -1
- package/dest/services/reqresp/protocols/goodbye.d.ts +1 -1
- package/dest/services/reqresp/protocols/goodbye.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/index.d.ts +1 -1
- package/dest/services/reqresp/protocols/ping.d.ts +1 -1
- package/dest/services/reqresp/protocols/status.d.ts +6 -5
- package/dest/services/reqresp/protocols/status.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/status.js +4 -3
- package/dest/services/reqresp/protocols/tx.d.ts +2 -3
- package/dest/services/reqresp/protocols/tx.d.ts.map +1 -1
- package/dest/services/reqresp/rate-limiter/index.d.ts +1 -1
- package/dest/services/reqresp/rate-limiter/rate_limiter.d.ts +2 -2
- package/dest/services/reqresp/rate-limiter/rate_limiter.d.ts.map +1 -1
- package/dest/services/reqresp/rate-limiter/rate_limits.d.ts +1 -1
- package/dest/services/reqresp/reqresp.d.ts +1 -41
- package/dest/services/reqresp/reqresp.d.ts.map +1 -1
- package/dest/services/reqresp/reqresp.js +416 -34
- package/dest/services/reqresp/status.d.ts +2 -2
- package/dest/services/reqresp/status.d.ts.map +1 -1
- package/dest/services/service.d.ts +2 -2
- package/dest/services/service.d.ts.map +1 -1
- package/dest/services/tx_collection/config.d.ts +1 -1
- package/dest/services/tx_collection/config.js +1 -1
- package/dest/services/tx_collection/fast_tx_collection.d.ts +4 -9
- package/dest/services/tx_collection/fast_tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/fast_tx_collection.js +6 -1
- package/dest/services/tx_collection/index.d.ts +1 -1
- 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/slow_tx_collection.d.ts +6 -7
- package/dest/services/tx_collection/slow_tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/slow_tx_collection.js +2 -1
- package/dest/services/tx_collection/tx_collection.d.ts +12 -11
- package/dest/services/tx_collection/tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/tx_collection.js +3 -2
- package/dest/services/tx_collection/tx_collection_sink.d.ts +3 -3
- package/dest/services/tx_collection/tx_collection_sink.d.ts.map +1 -1
- package/dest/services/tx_collection/tx_collection_sink.js +34 -4
- package/dest/services/tx_collection/tx_source.d.ts +1 -1
- package/dest/services/tx_collection/tx_source.d.ts.map +1 -1
- package/dest/services/tx_collection/tx_source.js +2 -2
- package/dest/services/tx_provider.d.ts +6 -4
- package/dest/services/tx_provider.d.ts.map +1 -1
- package/dest/services/tx_provider.js +19 -6
- package/dest/services/tx_provider_instrumentation.d.ts +5 -2
- package/dest/services/tx_provider_instrumentation.d.ts.map +1 -1
- package/dest/services/tx_provider_instrumentation.js +14 -1
- 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 +1 -1
- package/dest/test-helpers/make-enrs.d.ts +1 -1
- package/dest/test-helpers/make-enrs.js +1 -1
- package/dest/test-helpers/make-test-p2p-clients.d.ts +2 -2
- package/dest/test-helpers/make-test-p2p-clients.d.ts.map +1 -1
- 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-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 +3 -3
- package/dest/test-helpers/reqresp-nodes.d.ts.map +1 -1
- package/dest/test-helpers/reqresp-nodes.js +4 -3
- package/dest/testbench/p2p_client_testbench_worker.d.ts +1 -1
- package/dest/testbench/p2p_client_testbench_worker.js +17 -9
- package/dest/testbench/parse_log_file.d.ts +1 -1
- package/dest/testbench/testbench.d.ts +1 -1
- package/dest/testbench/testbench.js +2 -2
- package/dest/testbench/worker_client_manager.d.ts +1 -1
- package/dest/testbench/worker_client_manager.d.ts.map +1 -1
- package/dest/types/index.d.ts +1 -1
- package/dest/util.d.ts +2 -1
- package/dest/util.d.ts.map +1 -1
- package/dest/util.js +11 -2
- package/dest/versioning.d.ts +2 -2
- package/dest/versioning.d.ts.map +1 -1
- package/dest/versioning.js +2 -2
- package/package.json +21 -21
- package/src/bootstrap/bootstrap.ts +15 -4
- package/src/client/factory.ts +21 -12
- package/src/client/interface.ts +8 -5
- package/src/client/p2p_client.ts +97 -88
- package/src/config.ts +42 -21
- package/src/enr/generate-enr.ts +1 -1
- package/src/errors/attestation-pool.error.ts +13 -0
- package/src/mem_pools/attestation_pool/attestation_pool.ts +46 -5
- package/src/mem_pools/attestation_pool/attestation_pool_test_suite.ts +89 -48
- package/src/mem_pools/attestation_pool/kv_attestation_pool.ts +107 -24
- package/src/mem_pools/attestation_pool/memory_attestation_pool.ts +98 -19
- package/src/mem_pools/attestation_pool/mocks.ts +11 -8
- package/src/mem_pools/instrumentation.ts +46 -0
- 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 +368 -360
- 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 +8 -1
- package/src/mem_pools/tx_pool/tx_pool.ts +28 -8
- package/src/mem_pools/tx_pool/tx_pool_test_suite.ts +131 -18
- package/src/msg_validators/attestation_validator/attestation_validator.ts +41 -6
- package/src/msg_validators/attestation_validator/fisherman_attestation_validator.ts +91 -0
- package/src/msg_validators/attestation_validator/index.ts +1 -0
- package/src/msg_validators/block_proposal_validator/block_proposal_validator.ts +53 -12
- package/src/msg_validators/tx_validator/archive_cache.ts +1 -1
- package/src/msg_validators/tx_validator/block_header_validator.ts +2 -2
- package/src/msg_validators/tx_validator/double_spend_validator.ts +1 -1
- package/src/msg_validators/tx_validator/factory.ts +13 -6
- package/src/msg_validators/tx_validator/index.ts +1 -0
- package/src/msg_validators/tx_validator/metadata_validator.ts +8 -42
- package/src/msg_validators/tx_validator/phases_validator.ts +3 -1
- package/src/msg_validators/tx_validator/test_utils.ts +1 -1
- package/src/msg_validators/tx_validator/timestamp_validator.ts +47 -0
- package/src/services/discv5/discV5_service.ts +2 -2
- package/src/services/dummy_service.ts +1 -1
- package/src/services/encoding.ts +81 -6
- package/src/services/libp2p/instrumentation.ts +10 -1
- package/src/services/libp2p/libp2p_service.ts +430 -165
- package/src/services/peer-manager/metrics.ts +32 -0
- package/src/services/peer-manager/peer_manager.ts +24 -14
- package/src/services/peer-manager/peer_scoring.ts +46 -3
- package/src/services/reqresp/interface.ts +1 -22
- package/src/services/reqresp/protocols/auth.ts +2 -2
- package/src/services/reqresp/protocols/block.ts +3 -2
- package/src/services/reqresp/protocols/block_txs/block_txs_reqresp.ts +1 -1
- package/src/services/reqresp/protocols/status.ts +9 -8
- package/src/services/reqresp/protocols/tx.ts +1 -2
- package/src/services/reqresp/reqresp.ts +15 -11
- package/src/services/service.ts +1 -1
- package/src/services/tx_collection/config.ts +1 -1
- package/src/services/tx_collection/fast_tx_collection.ts +8 -5
- package/src/services/tx_collection/slow_tx_collection.ts +7 -6
- package/src/services/tx_collection/tx_collection.ts +12 -10
- package/src/services/tx_collection/tx_collection_sink.ts +34 -3
- package/src/services/tx_collection/tx_source.ts +2 -2
- package/src/services/tx_provider.ts +26 -9
- package/src/services/tx_provider_instrumentation.ts +19 -2
- package/src/test-helpers/make-enrs.ts +1 -1
- package/src/test-helpers/mock-pubsub.ts +1 -1
- package/src/test-helpers/mock-tx-helpers.ts +24 -0
- package/src/test-helpers/reqresp-nodes.ts +4 -3
- package/src/testbench/p2p_client_testbench_worker.ts +14 -6
- package/src/testbench/testbench.ts +2 -2
- package/src/util.ts +12 -2
- package/src/versioning.ts +3 -3
- package/dest/mem_pools/tx_pool/memory_tx_pool.d.ts +0 -68
- 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 -160
- package/src/mem_pools/tx_pool/memory_tx_pool.ts +0 -199
package/src/client/interface.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { EthAddress, L2BlockId } from '@aztec/stdlib/block';
|
|
2
2
|
import type { P2PApiFull } from '@aztec/stdlib/interfaces/server';
|
|
3
|
-
import type { BlockProposal, P2PClientType } from '@aztec/stdlib/p2p';
|
|
3
|
+
import type { BlockAttestation, BlockProposal, P2PClientType } from '@aztec/stdlib/p2p';
|
|
4
4
|
import type { Tx, TxHash } from '@aztec/stdlib/tx';
|
|
5
5
|
|
|
6
|
-
import type { ENR } from '@chainsafe/enr';
|
|
7
6
|
import type { PeerId } from '@libp2p/interface';
|
|
7
|
+
import type { ENR } from '@nethermindeth/enr';
|
|
8
8
|
|
|
9
9
|
import type { P2PConfig } from '../config.js';
|
|
10
10
|
import type { AuthRequest, StatusMessage } from '../services/index.js';
|
|
@@ -50,6 +50,9 @@ export type P2P<T extends P2PClientType = P2PClientType.Full> = P2PApiFull<T> &
|
|
|
50
50
|
*/
|
|
51
51
|
broadcastProposal(proposal: BlockProposal): Promise<void>;
|
|
52
52
|
|
|
53
|
+
/** Broadcasts block attestations to other peers. */
|
|
54
|
+
broadcastAttestations(attestations: BlockAttestation[]): Promise<void>;
|
|
55
|
+
|
|
53
56
|
/**
|
|
54
57
|
* Registers a callback from the validator client that determines how to behave when
|
|
55
58
|
* foreign block proposals are received
|
|
@@ -125,11 +128,11 @@ export type P2P<T extends P2PClientType = P2PClientType.Full> = P2PApiFull<T> &
|
|
|
125
128
|
getArchivedTxByHash(txHash: TxHash): Promise<Tx | undefined>;
|
|
126
129
|
|
|
127
130
|
/**
|
|
128
|
-
* Returns whether the given tx hash is flagged as pending or
|
|
131
|
+
* Returns whether the given tx hash is flagged as pending, mined, or deleted.
|
|
129
132
|
* @param txHash - Hash of the tx to query.
|
|
130
|
-
* @returns Pending or
|
|
133
|
+
* @returns Pending, mined, or deleted depending on its status, or undefined if not found.
|
|
131
134
|
*/
|
|
132
|
-
getTxStatus(txHash: TxHash): Promise<'pending' | 'mined' | undefined>;
|
|
135
|
+
getTxStatus(txHash: TxHash): Promise<'pending' | 'mined' | 'deleted' | undefined>;
|
|
133
136
|
|
|
134
137
|
/** Returns an iterator over pending txs on the mempool. */
|
|
135
138
|
iteratePendingTxs(): AsyncIterableIterator<Tx>;
|
package/src/client/p2p_client.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { INITIAL_L2_BLOCK_NUM } from '@aztec/constants';
|
|
1
|
+
import { GENESIS_BLOCK_HEADER_HASH, INITIAL_L2_BLOCK_NUM } from '@aztec/constants';
|
|
2
|
+
import { BlockNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
2
3
|
import { createLogger } from '@aztec/foundation/log';
|
|
3
4
|
import { DateProvider } from '@aztec/foundation/timer';
|
|
4
5
|
import type { AztecAsyncKVStore, AztecAsyncMap, AztecAsyncSingleton } from '@aztec/kv-store';
|
|
5
6
|
import type {
|
|
6
7
|
EthAddress,
|
|
7
|
-
L2Block,
|
|
8
8
|
L2BlockId,
|
|
9
|
+
L2BlockNew,
|
|
9
10
|
L2BlockSource,
|
|
10
11
|
L2BlockStream,
|
|
11
12
|
L2BlockStreamEvent,
|
|
12
13
|
L2Tips,
|
|
13
|
-
PublishedL2Block,
|
|
14
14
|
} from '@aztec/stdlib/block';
|
|
15
15
|
import type { ContractDataSource } from '@aztec/stdlib/contract';
|
|
16
16
|
import { getTimestampForSlot } from '@aztec/stdlib/epoch-helpers';
|
|
@@ -26,8 +26,8 @@ import {
|
|
|
26
26
|
trackSpan,
|
|
27
27
|
} from '@aztec/telemetry-client';
|
|
28
28
|
|
|
29
|
-
import type { ENR } from '@chainsafe/enr';
|
|
30
29
|
import type { PeerId } from '@libp2p/interface';
|
|
30
|
+
import type { ENR } from '@nethermindeth/enr';
|
|
31
31
|
|
|
32
32
|
import { type P2PConfig, getP2PDefaultConfig } from '../config.js';
|
|
33
33
|
import type { AttestationPool } from '../mem_pools/attestation_pool/attestation_pool.js';
|
|
@@ -62,14 +62,14 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
62
62
|
private provenBlockNumberAtStart = -1;
|
|
63
63
|
private finalizedBlockNumberAtStart = -1;
|
|
64
64
|
|
|
65
|
-
private synchedBlockHashes: AztecAsyncMap<
|
|
66
|
-
private synchedLatestBlockNumber: AztecAsyncSingleton<
|
|
67
|
-
private synchedProvenBlockNumber: AztecAsyncSingleton<
|
|
68
|
-
private synchedFinalizedBlockNumber: AztecAsyncSingleton<
|
|
65
|
+
private synchedBlockHashes: AztecAsyncMap<BlockNumber, string>;
|
|
66
|
+
private synchedLatestBlockNumber: AztecAsyncSingleton<BlockNumber>;
|
|
67
|
+
private synchedProvenBlockNumber: AztecAsyncSingleton<BlockNumber>;
|
|
68
|
+
private synchedFinalizedBlockNumber: AztecAsyncSingleton<BlockNumber>;
|
|
69
69
|
private synchedLatestSlot: AztecAsyncSingleton<bigint>;
|
|
70
70
|
|
|
71
71
|
private txPool: TxPool;
|
|
72
|
-
private attestationPool:
|
|
72
|
+
private attestationPool: AttestationPool;
|
|
73
73
|
|
|
74
74
|
private config: P2PConfig;
|
|
75
75
|
|
|
@@ -91,7 +91,7 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
91
91
|
_clientType: T,
|
|
92
92
|
private store: AztecAsyncKVStore,
|
|
93
93
|
private l2BlockSource: L2BlockSource & ContractDataSource,
|
|
94
|
-
mempools: MemPools
|
|
94
|
+
mempools: MemPools,
|
|
95
95
|
private p2pService: P2PService,
|
|
96
96
|
private txCollection: TxCollection,
|
|
97
97
|
config: Partial<P2PConfig> = {},
|
|
@@ -103,7 +103,7 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
103
103
|
|
|
104
104
|
this.config = { ...getP2PDefaultConfig(), ...config };
|
|
105
105
|
this.txPool = mempools.txPool;
|
|
106
|
-
this.attestationPool = mempools.attestationPool
|
|
106
|
+
this.attestationPool = mempools.attestationPool;
|
|
107
107
|
|
|
108
108
|
this.txProvider = new TxProvider(
|
|
109
109
|
this.txCollection,
|
|
@@ -121,9 +121,15 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
121
121
|
this.log.debug(`Received block proposal from ${sender.toString()}`);
|
|
122
122
|
// TODO(palla/txs): Need to subtract validatorReexecuteDeadlineMs from this deadline (see ValidatorClient.getReexecutionDeadline)
|
|
123
123
|
const constants = this.txCollection.getConstants();
|
|
124
|
-
const nextSlotTimestampSeconds = Number(getTimestampForSlot(block.slotNumber
|
|
124
|
+
const nextSlotTimestampSeconds = Number(getTimestampForSlot(SlotNumber(block.slotNumber + 1), constants));
|
|
125
125
|
const deadline = new Date(nextSlotTimestampSeconds * 1000);
|
|
126
|
-
await this.
|
|
126
|
+
const parentBlock = await this.l2BlockSource.getBlockHeaderByArchive(block.payload.header.lastArchiveRoot);
|
|
127
|
+
if (!parentBlock) {
|
|
128
|
+
this.log.debug(`Cannot collect txs for proposal as parent block not found`);
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
const blockNumber = BlockNumber(parentBlock.getBlockNumber() + 1);
|
|
132
|
+
await this.txProvider.getTxsForBlockProposal(block, blockNumber, { pinnedPeer: sender, deadline });
|
|
127
133
|
return undefined;
|
|
128
134
|
});
|
|
129
135
|
|
|
@@ -156,7 +162,7 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
156
162
|
return Promise.resolve(this.p2pService.getPeers(includePending));
|
|
157
163
|
}
|
|
158
164
|
|
|
159
|
-
public getL2BlockHash(number:
|
|
165
|
+
public getL2BlockHash(number: BlockNumber): Promise<string | undefined> {
|
|
160
166
|
return this.synchedBlockHashes.getAsync(number);
|
|
161
167
|
}
|
|
162
168
|
|
|
@@ -197,10 +203,12 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
197
203
|
}
|
|
198
204
|
}
|
|
199
205
|
|
|
206
|
+
const genesisHash = GENESIS_BLOCK_HEADER_HASH.toString();
|
|
207
|
+
|
|
200
208
|
return {
|
|
201
|
-
latest: { hash: latestBlockHash
|
|
202
|
-
proven: { hash: provenBlockHash
|
|
203
|
-
finalized: { hash: finalizedBlockHash
|
|
209
|
+
latest: { hash: latestBlockHash ?? genesisHash, number: latestBlockNumber },
|
|
210
|
+
proven: { hash: provenBlockHash ?? genesisHash, number: provenBlockNumber },
|
|
211
|
+
finalized: { hash: finalizedBlockHash ?? genesisHash, number: finalizedBlockNumber },
|
|
204
212
|
};
|
|
205
213
|
}
|
|
206
214
|
|
|
@@ -208,15 +216,16 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
208
216
|
this.log.debug(`Handling block stream event ${event.type}`);
|
|
209
217
|
switch (event.type) {
|
|
210
218
|
case 'blocks-added':
|
|
211
|
-
await this.handleLatestL2Blocks(event.blocks);
|
|
219
|
+
await this.handleLatestL2Blocks(event.blocks.map(b => b.block.toL2Block()));
|
|
212
220
|
break;
|
|
213
221
|
case 'chain-finalized': {
|
|
214
222
|
// TODO (alexg): I think we can prune the block hashes map here
|
|
215
223
|
await this.setBlockHash(event.block);
|
|
216
|
-
const from = (await this.getSyncedFinalizedBlockNum()) + 1;
|
|
224
|
+
const from = BlockNumber((await this.getSyncedFinalizedBlockNum()) + 1);
|
|
217
225
|
const limit = event.block.number - from + 1;
|
|
218
226
|
if (limit > 0) {
|
|
219
|
-
|
|
227
|
+
const oldBlocks = await this.l2BlockSource.getBlocks(from, limit);
|
|
228
|
+
await this.handleFinalizedL2Blocks(oldBlocks.map(b => b.toL2Block()));
|
|
220
229
|
}
|
|
221
230
|
break;
|
|
222
231
|
}
|
|
@@ -273,12 +282,9 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
273
282
|
const syncedProvenBlock = (await this.getSyncedProvenBlockNum()) + 1;
|
|
274
283
|
const syncedFinalizedBlock = (await this.getSyncedFinalizedBlockNum()) + 1;
|
|
275
284
|
|
|
276
|
-
if (
|
|
277
|
-
(await this.txPool.isEmpty()) &&
|
|
278
|
-
(this.attestationPool === undefined || (await this.attestationPool?.isEmpty()))
|
|
279
|
-
) {
|
|
285
|
+
if ((await this.txPool.isEmpty()) && (await this.attestationPool.isEmpty())) {
|
|
280
286
|
// if mempools are empty, we don't care about syncing prior blocks
|
|
281
|
-
this.initBlockStream(this.latestBlockNumberAtStart);
|
|
287
|
+
this.initBlockStream(BlockNumber(this.latestBlockNumberAtStart));
|
|
282
288
|
this.setCurrentState(P2PClientState.RUNNING);
|
|
283
289
|
this.syncPromise = Promise.resolve();
|
|
284
290
|
await this.p2pService.start();
|
|
@@ -326,7 +332,7 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
326
332
|
return this.p2pService.addReqRespSubProtocol(subProtocol, handler, validator);
|
|
327
333
|
}
|
|
328
334
|
|
|
329
|
-
private initBlockStream(startingBlock?:
|
|
335
|
+
private initBlockStream(startingBlock?: BlockNumber) {
|
|
330
336
|
if (!this.blockStream) {
|
|
331
337
|
const { blockRequestBatchSize: batchSize, blockCheckIntervalMS: pollIntervalMS } = this.config;
|
|
332
338
|
this.blockStream = new TraceableL2BlockStream(
|
|
@@ -365,26 +371,32 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
365
371
|
}
|
|
366
372
|
|
|
367
373
|
@trackSpan('p2pClient.broadcastProposal', async proposal => ({
|
|
368
|
-
[Attributes.
|
|
369
|
-
[Attributes.SLOT_NUMBER]: proposal.slotNumber.toNumber(),
|
|
374
|
+
[Attributes.SLOT_NUMBER]: proposal.slotNumber,
|
|
370
375
|
[Attributes.BLOCK_ARCHIVE]: proposal.archive.toString(),
|
|
371
|
-
[Attributes.P2P_ID]: (await proposal.
|
|
376
|
+
[Attributes.P2P_ID]: (await proposal.p2pMessageLoggingIdentifier()).toString(),
|
|
372
377
|
}))
|
|
373
378
|
public broadcastProposal(proposal: BlockProposal): Promise<void> {
|
|
374
|
-
this.log.verbose(`Broadcasting proposal for slot ${proposal.slotNumber
|
|
379
|
+
this.log.verbose(`Broadcasting proposal for slot ${proposal.slotNumber} to peers`);
|
|
375
380
|
return this.p2pService.propagate(proposal);
|
|
376
381
|
}
|
|
377
382
|
|
|
378
|
-
public async
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
383
|
+
public async broadcastAttestations(attestations: BlockAttestation[]): Promise<void> {
|
|
384
|
+
this.log.verbose(`Broadcasting ${attestations.length} attestations to peers`);
|
|
385
|
+
await Promise.all(attestations.map(att => this.p2pService.propagate(att)));
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
public async getAttestationsForSlot(slot: SlotNumber, proposalId?: string): Promise<BlockAttestation[]> {
|
|
389
|
+
return await (proposalId
|
|
390
|
+
? this.attestationPool.getAttestationsForSlotAndProposal(slot, proposalId)
|
|
391
|
+
: this.attestationPool.getAttestationsForSlot(slot));
|
|
384
392
|
}
|
|
385
393
|
|
|
386
394
|
public addAttestations(attestations: BlockAttestation[]): Promise<void> {
|
|
387
|
-
return this.attestationPool
|
|
395
|
+
return this.attestationPool.addAttestations(attestations);
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
public deleteAttestation(attestation: BlockAttestation): Promise<void> {
|
|
399
|
+
return this.attestationPool.deleteAttestations([attestation]);
|
|
388
400
|
}
|
|
389
401
|
|
|
390
402
|
// REVIEW: https://github.com/AztecProtocol/aztec-packages/issues/7963
|
|
@@ -599,7 +611,7 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
599
611
|
* @param txHash - Hash of the tx to query.
|
|
600
612
|
* @returns Pending or mined depending on its status, or undefined if not found.
|
|
601
613
|
*/
|
|
602
|
-
public getTxStatus(txHash: TxHash): Promise<'pending' | 'mined' | undefined> {
|
|
614
|
+
public getTxStatus(txHash: TxHash): Promise<'pending' | 'mined' | 'deleted' | undefined> {
|
|
603
615
|
return this.txPool.getTxStatus(txHash);
|
|
604
616
|
}
|
|
605
617
|
|
|
@@ -634,20 +646,20 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
634
646
|
* Public function to check the latest block number that the P2P client is synced to.
|
|
635
647
|
* @returns Block number of latest L2 Block we've synced with.
|
|
636
648
|
*/
|
|
637
|
-
public async getSyncedLatestBlockNum(): Promise<
|
|
638
|
-
return (await this.synchedLatestBlockNumber.getAsync()) ?? INITIAL_L2_BLOCK_NUM - 1;
|
|
649
|
+
public async getSyncedLatestBlockNum(): Promise<BlockNumber> {
|
|
650
|
+
return (await this.synchedLatestBlockNumber.getAsync()) ?? BlockNumber(INITIAL_L2_BLOCK_NUM - 1);
|
|
639
651
|
}
|
|
640
652
|
|
|
641
653
|
/**
|
|
642
654
|
* Public function to check the latest proven block number that the P2P client is synced to.
|
|
643
655
|
* @returns Block number of latest proven L2 Block we've synced with.
|
|
644
656
|
*/
|
|
645
|
-
public async getSyncedProvenBlockNum(): Promise<
|
|
646
|
-
return (await this.synchedProvenBlockNumber.getAsync()) ?? INITIAL_L2_BLOCK_NUM - 1;
|
|
657
|
+
public async getSyncedProvenBlockNum(): Promise<BlockNumber> {
|
|
658
|
+
return (await this.synchedProvenBlockNumber.getAsync()) ?? BlockNumber(INITIAL_L2_BLOCK_NUM - 1);
|
|
647
659
|
}
|
|
648
660
|
|
|
649
|
-
public async getSyncedFinalizedBlockNum(): Promise<
|
|
650
|
-
return (await this.synchedFinalizedBlockNumber.getAsync()) ?? INITIAL_L2_BLOCK_NUM - 1;
|
|
661
|
+
public async getSyncedFinalizedBlockNum(): Promise<BlockNumber> {
|
|
662
|
+
return (await this.synchedFinalizedBlockNumber.getAsync()) ?? BlockNumber(INITIAL_L2_BLOCK_NUM - 1);
|
|
651
663
|
}
|
|
652
664
|
|
|
653
665
|
/** Returns latest L2 slot for which we have seen an L2 block. */
|
|
@@ -663,7 +675,7 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
663
675
|
const blockNumber = await this.getSyncedLatestBlockNum();
|
|
664
676
|
const blockHash =
|
|
665
677
|
blockNumber === 0
|
|
666
|
-
?
|
|
678
|
+
? GENESIS_BLOCK_HEADER_HASH.toString()
|
|
667
679
|
: await this.l2BlockSource
|
|
668
680
|
.getBlockHeader(blockNumber)
|
|
669
681
|
.then(header => header?.hash())
|
|
@@ -671,8 +683,8 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
671
683
|
|
|
672
684
|
return {
|
|
673
685
|
state: this.currentState,
|
|
674
|
-
syncedToL2Block: { number: blockNumber, hash: blockHash },
|
|
675
|
-
}
|
|
686
|
+
syncedToL2Block: { number: blockNumber, hash: blockHash! },
|
|
687
|
+
};
|
|
676
688
|
}
|
|
677
689
|
|
|
678
690
|
/**
|
|
@@ -680,58 +692,46 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
680
692
|
* @param blocks - A list of existing blocks with txs that the P2P client needs to ensure the tx pool is reconciled with.
|
|
681
693
|
* @returns Empty promise.
|
|
682
694
|
*/
|
|
683
|
-
private async markTxsAsMinedFromBlocks(blocks:
|
|
695
|
+
private async markTxsAsMinedFromBlocks(blocks: L2BlockNew[]): Promise<void> {
|
|
684
696
|
for (const block of blocks) {
|
|
685
697
|
const txHashes = block.body.txEffects.map(txEffect => txEffect.txHash);
|
|
686
698
|
await this.txPool.markAsMined(txHashes, block.header);
|
|
687
699
|
}
|
|
688
700
|
}
|
|
689
701
|
|
|
690
|
-
/**
|
|
691
|
-
* Deletes txs from these blocks.
|
|
692
|
-
* @param blocks - A list of existing blocks with txs that the P2P client needs to ensure the tx pool is reconciled with.
|
|
693
|
-
* @returns Empty promise.
|
|
694
|
-
*/
|
|
695
|
-
private async deleteTxsFromBlocks(blocks: L2Block[]): Promise<void> {
|
|
696
|
-
this.log.debug(`Deleting txs from blocks ${blocks[0].number} to ${blocks[blocks.length - 1].number}`);
|
|
697
|
-
for (const block of blocks) {
|
|
698
|
-
const txHashes = block.body.txEffects.map(txEffect => txEffect.txHash);
|
|
699
|
-
await this.txPool.deleteTxs(txHashes);
|
|
700
|
-
}
|
|
701
|
-
}
|
|
702
|
-
|
|
703
702
|
/**
|
|
704
703
|
* Handles new mined blocks by marking the txs in them as mined.
|
|
705
704
|
* @param blocks - A list of existing blocks with txs that the P2P client needs to ensure the tx pool is reconciled with.
|
|
706
705
|
* @returns Empty promise.
|
|
707
706
|
*/
|
|
708
|
-
private async handleLatestL2Blocks(blocks:
|
|
707
|
+
private async handleLatestL2Blocks(blocks: L2BlockNew[]): Promise<void> {
|
|
709
708
|
if (!blocks.length) {
|
|
710
709
|
return Promise.resolve();
|
|
711
710
|
}
|
|
712
711
|
|
|
713
|
-
await this.markTxsAsMinedFromBlocks(blocks
|
|
714
|
-
await this.
|
|
712
|
+
await this.markTxsAsMinedFromBlocks(blocks);
|
|
713
|
+
await this.txPool.clearNonEvictableTxs();
|
|
714
|
+
await this.startCollectingMissingTxs(blocks);
|
|
715
715
|
|
|
716
|
-
const lastBlock = blocks.at(-1)
|
|
716
|
+
const lastBlock = blocks.at(-1)!;
|
|
717
717
|
|
|
718
718
|
await Promise.all(
|
|
719
719
|
blocks.map(async block =>
|
|
720
720
|
this.setBlockHash({
|
|
721
|
-
number: block.
|
|
722
|
-
hash: await block.
|
|
721
|
+
number: block.number,
|
|
722
|
+
hash: await block.hash().then(h => h.toString()),
|
|
723
723
|
}),
|
|
724
724
|
),
|
|
725
725
|
);
|
|
726
726
|
|
|
727
727
|
await this.synchedLatestBlockNumber.set(lastBlock.number);
|
|
728
|
-
await this.synchedLatestSlot.set(lastBlock.header.getSlot());
|
|
728
|
+
await this.synchedLatestSlot.set(BigInt(lastBlock.header.getSlot()));
|
|
729
729
|
this.log.verbose(`Synched to latest block ${lastBlock.number}`);
|
|
730
730
|
await this.startServiceIfSynched();
|
|
731
731
|
}
|
|
732
732
|
|
|
733
733
|
/** Request txs for unproven blocks so the prover node has more chances to get them. */
|
|
734
|
-
private async startCollectingMissingTxs(blocks:
|
|
734
|
+
private async startCollectingMissingTxs(blocks: L2BlockNew[]): Promise<void> {
|
|
735
735
|
try {
|
|
736
736
|
// TODO(#15435): If the archiver has lagged behind L1, the reported proven block number may
|
|
737
737
|
// be much lower than the actual one, and it does not update until the pending chain is
|
|
@@ -764,20 +764,24 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
764
764
|
* @param blocks - A list of finalized L2 blocks.
|
|
765
765
|
* @returns Empty promise.
|
|
766
766
|
*/
|
|
767
|
-
private async handleFinalizedL2Blocks(blocks:
|
|
768
|
-
this.log.trace(`Handling finalized blocks ${blocks.length} up to ${blocks.at(-1)?.number}`);
|
|
767
|
+
private async handleFinalizedL2Blocks(blocks: L2BlockNew[]): Promise<void> {
|
|
769
768
|
if (!blocks.length) {
|
|
770
769
|
return Promise.resolve();
|
|
771
770
|
}
|
|
771
|
+
this.log.debug(`Handling finalized blocks ${blocks.length} up to ${blocks.at(-1)?.number}`);
|
|
772
772
|
|
|
773
773
|
const lastBlockNum = blocks[blocks.length - 1].number;
|
|
774
774
|
const lastBlockSlot = blocks[blocks.length - 1].header.getSlot();
|
|
775
775
|
|
|
776
|
-
|
|
777
|
-
|
|
776
|
+
const txHashes = blocks.flatMap(block => block.body.txEffects.map(txEffect => txEffect.txHash));
|
|
777
|
+
this.log.debug(`Deleting ${txHashes.length} txs from pool from finalized blocks up to ${lastBlockNum}`);
|
|
778
|
+
await this.txPool.deleteTxs(txHashes, { permanently: true });
|
|
779
|
+
await this.txPool.cleanupDeletedMinedTxs(lastBlockNum);
|
|
780
|
+
|
|
781
|
+
await this.attestationPool.deleteAttestationsOlderThan(lastBlockSlot);
|
|
778
782
|
|
|
779
783
|
await this.synchedFinalizedBlockNumber.set(lastBlockNum);
|
|
780
|
-
this.log.debug(`Synched to finalized block ${lastBlockNum}`);
|
|
784
|
+
this.log.debug(`Synched to finalized block ${lastBlockNum} at slot ${lastBlockSlot}`);
|
|
781
785
|
|
|
782
786
|
await this.startServiceIfSynched();
|
|
783
787
|
}
|
|
@@ -786,42 +790,47 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
786
790
|
* Updates the tx pool after a chain prune.
|
|
787
791
|
* @param latestBlock - The block number the chain was pruned to.
|
|
788
792
|
*/
|
|
789
|
-
private async handlePruneL2Blocks(latestBlock:
|
|
793
|
+
private async handlePruneL2Blocks(latestBlock: BlockNumber): Promise<void> {
|
|
790
794
|
const txsToDelete = new Map<string, TxHash>();
|
|
791
795
|
const minedTxs = await this.txPool.getMinedTxHashes();
|
|
792
796
|
|
|
793
797
|
// Find transactions that reference pruned blocks in their historical header
|
|
794
798
|
for (const tx of await this.txPool.getAllTxs()) {
|
|
795
799
|
// every tx that's been generated against a block that has now been pruned is no longer valid
|
|
796
|
-
if (tx.data.constants.
|
|
800
|
+
if (tx.data.constants.anchorBlockHeader.globalVariables.blockNumber > latestBlock) {
|
|
797
801
|
const txHash = tx.getTxHash();
|
|
798
802
|
txsToDelete.set(txHash.toString(), txHash);
|
|
799
803
|
}
|
|
800
804
|
}
|
|
801
805
|
|
|
802
|
-
this.log.info(
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
);
|
|
806
|
+
this.log.info(`Detected chain prune. Removing ${txsToDelete.size} txs built against pruned blocks.`, {
|
|
807
|
+
newLatestBlock: latestBlock,
|
|
808
|
+
previousLatestBlock: await this.getSyncedLatestBlockNum(),
|
|
809
|
+
txsToDelete: Array.from(txsToDelete.keys()),
|
|
810
|
+
});
|
|
807
811
|
|
|
808
812
|
// delete invalid txs (both pending and mined)
|
|
809
813
|
await this.txPool.deleteTxs(Array.from(txsToDelete.values()));
|
|
810
814
|
|
|
811
815
|
// everything left in the mined set was built against a block on the proven chain so its still valid
|
|
812
|
-
// move back to pending the txs that were reorged out of the chain
|
|
816
|
+
// move back to pending the txs that were reorged out of the chain, unless txPoolDeleteTxsAfterReorg is set,
|
|
817
|
+
// in which case we clean them up to avoid potential reorg loops
|
|
813
818
|
// NOTE: we can't move _all_ txs back to pending because the tx pool could keep hold of mined txs for longer
|
|
814
819
|
// (see this.keepProvenTxsFor)
|
|
815
|
-
|
|
816
|
-
const txsToMoveToPending: TxHash[] = [];
|
|
820
|
+
const minedTxsFromReorg: TxHash[] = [];
|
|
817
821
|
for (const [txHash, blockNumber] of minedTxs) {
|
|
818
|
-
|
|
819
|
-
|
|
822
|
+
// We keep the txsToDelete out of this list as they have already been deleted above
|
|
823
|
+
if (blockNumber > latestBlock && !txsToDelete.has(txHash.toString())) {
|
|
824
|
+
minedTxsFromReorg.push(txHash);
|
|
820
825
|
}
|
|
821
826
|
}
|
|
822
827
|
|
|
823
|
-
this.
|
|
824
|
-
|
|
828
|
+
if (this.config.txPoolDeleteTxsAfterReorg) {
|
|
829
|
+
this.log.info(`Deleting ${minedTxsFromReorg.length} mined txs from reorg`);
|
|
830
|
+
await this.txPool.deleteTxs(minedTxsFromReorg);
|
|
831
|
+
} else {
|
|
832
|
+
await this.txPool.markMinedAsPending(minedTxsFromReorg, latestBlock);
|
|
833
|
+
}
|
|
825
834
|
|
|
826
835
|
await this.synchedLatestBlockNumber.set(latestBlock);
|
|
827
836
|
// no need to update block hashes, as they will be updated as new blocks are added
|
package/src/config.ts
CHANGED
|
@@ -9,9 +9,9 @@ import {
|
|
|
9
9
|
pickConfigMappings,
|
|
10
10
|
secretStringConfigHelper,
|
|
11
11
|
} from '@aztec/foundation/config';
|
|
12
|
-
import { Fr } from '@aztec/foundation/
|
|
12
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
13
13
|
import { type DataStoreConfig, dataConfigMappings } from '@aztec/kv-store/config';
|
|
14
|
-
import { FunctionSelector } from '@aztec/stdlib/abi';
|
|
14
|
+
import { FunctionSelector } from '@aztec/stdlib/abi/function-selector';
|
|
15
15
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
16
16
|
import { type AllowedElement, type ChainConfig, chainConfigMappings } from '@aztec/stdlib/config';
|
|
17
17
|
|
|
@@ -127,17 +127,14 @@ export interface P2PConfig extends P2PReqRespConfig, ChainConfig, TxCollectionCo
|
|
|
127
127
|
/** A list of preferred peers. */
|
|
128
128
|
preferredPeers: string[];
|
|
129
129
|
|
|
130
|
-
/** The maximum possible size of the P2P DB in KB. Overwrites the general
|
|
130
|
+
/** The maximum possible size of the P2P DB in KB. Overwrites the general dataStoreMapSizeKb. */
|
|
131
131
|
p2pStoreMapSizeKb?: number;
|
|
132
132
|
|
|
133
133
|
/** Which calls are allowed in the public setup phase of a tx. */
|
|
134
134
|
txPublicSetupAllowList: AllowedElement[];
|
|
135
135
|
|
|
136
|
-
/** The maximum
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
/** If the pool is full, it will still accept a few more txs until it reached maxTxPoolOverspillFactor * maxTxPoolSize. Then it will evict */
|
|
140
|
-
txPoolOverflowFactor: number;
|
|
136
|
+
/** The maximum number of pending txs before evicting lower priority txs. */
|
|
137
|
+
maxPendingTxCount: number;
|
|
141
138
|
|
|
142
139
|
/** The node's seen message ID cache size */
|
|
143
140
|
seenMessageCacheSize: number;
|
|
@@ -161,6 +158,15 @@ export interface P2PConfig extends P2PReqRespConfig, ChainConfig, TxCollectionCo
|
|
|
161
158
|
|
|
162
159
|
/** The probability that a transaction is discarded. - For testing purposes only */
|
|
163
160
|
dropTransactionsProbability: number;
|
|
161
|
+
|
|
162
|
+
/** Whether to delete transactions from the pool after a reorg instead of moving them back to pending. */
|
|
163
|
+
txPoolDeleteTxsAfterReorg: boolean;
|
|
164
|
+
|
|
165
|
+
/** Alters the format of p2p messages to include things like broadcast timestamp FOR TESTING ONLY */
|
|
166
|
+
debugP2PInstrumentMessages: boolean;
|
|
167
|
+
|
|
168
|
+
/** Whether to run in fisherman mode: validates all proposals and attestations but does not broadcast attestations or participate in consensus */
|
|
169
|
+
fishermanMode: boolean;
|
|
164
170
|
}
|
|
165
171
|
|
|
166
172
|
export const DEFAULT_P2P_PORT = 40400;
|
|
@@ -357,7 +363,7 @@ export const p2pConfigMappings: ConfigMappingsType<P2PConfig> = {
|
|
|
357
363
|
p2pStoreMapSizeKb: {
|
|
358
364
|
env: 'P2P_STORE_MAP_SIZE_KB',
|
|
359
365
|
parseEnv: (val: string | undefined) => (val ? +val : undefined),
|
|
360
|
-
description: 'The maximum possible size of the P2P DB in KB. Overwrites the general
|
|
366
|
+
description: 'The maximum possible size of the P2P DB in KB. Overwrites the general dataStoreMapSizeKb.',
|
|
361
367
|
},
|
|
362
368
|
txPublicSetupAllowList: {
|
|
363
369
|
env: 'TX_PUBLIC_SETUP_ALLOWLIST',
|
|
@@ -366,15 +372,12 @@ export const p2pConfigMappings: ConfigMappingsType<P2PConfig> = {
|
|
|
366
372
|
printDefault: () =>
|
|
367
373
|
'AuthRegistry, FeeJuice.increase_public_balance, Token.increase_public_balance, FPC.prepare_fee',
|
|
368
374
|
},
|
|
369
|
-
|
|
370
|
-
env: '
|
|
371
|
-
description: 'The maximum
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
env: 'P2P_TX_POOL_OVERFLOW_FACTOR',
|
|
376
|
-
description: 'How much the tx pool can overflow before it starts evicting txs. Must be greater than 1',
|
|
377
|
-
...floatConfigHelper(1.1), // 10% overflow
|
|
375
|
+
maxPendingTxCount: {
|
|
376
|
+
env: 'P2P_MAX_PENDING_TX_COUNT',
|
|
377
|
+
description: 'The maximum number of pending txs before evicting lower priority txs.',
|
|
378
|
+
// Worst case scenario: Uncompressed public/private tx is ~ 156kb
|
|
379
|
+
// This implies we are using ~156MB of memory for pending pool
|
|
380
|
+
...numberConfigHelper(1_000),
|
|
378
381
|
},
|
|
379
382
|
seenMessageCacheSize: {
|
|
380
383
|
env: 'P2P_SEEN_MSG_CACHE_SIZE',
|
|
@@ -403,7 +406,7 @@ export const p2pConfigMappings: ConfigMappingsType<P2PConfig> = {
|
|
|
403
406
|
},
|
|
404
407
|
dropTransactionsProbability: {
|
|
405
408
|
env: 'P2P_DROP_TX_CHANCE',
|
|
406
|
-
description: 'The probability that a transaction is discarded. - For testing purposes only',
|
|
409
|
+
description: 'The probability that a transaction is discarded (0 - 1). - For testing purposes only',
|
|
407
410
|
...floatConfigHelper(0),
|
|
408
411
|
},
|
|
409
412
|
disableTransactions: {
|
|
@@ -412,6 +415,22 @@ export const p2pConfigMappings: ConfigMappingsType<P2PConfig> = {
|
|
|
412
415
|
'Whether transactions are disabled for this node. This means transactions will be rejected at the RPC and P2P layers.',
|
|
413
416
|
...booleanConfigHelper(false),
|
|
414
417
|
},
|
|
418
|
+
txPoolDeleteTxsAfterReorg: {
|
|
419
|
+
env: 'P2P_TX_POOL_DELETE_TXS_AFTER_REORG',
|
|
420
|
+
description: 'Whether to delete transactions from the pool after a reorg instead of moving them back to pending.',
|
|
421
|
+
...booleanConfigHelper(false),
|
|
422
|
+
},
|
|
423
|
+
debugP2PInstrumentMessages: {
|
|
424
|
+
env: 'DEBUG_P2P_INSTRUMENT_MESSAGES',
|
|
425
|
+
description: 'Alters the format of p2p messages to include things like broadcast timestamp FOR TESTING ONLY',
|
|
426
|
+
...booleanConfigHelper(false),
|
|
427
|
+
},
|
|
428
|
+
fishermanMode: {
|
|
429
|
+
env: 'FISHERMAN_MODE',
|
|
430
|
+
description:
|
|
431
|
+
'Whether to run in fisherman mode: validates all proposals and attestations but does not broadcast attestations or participate in consensus.',
|
|
432
|
+
...booleanConfigHelper(false),
|
|
433
|
+
},
|
|
415
434
|
...p2pReqRespConfigMappings,
|
|
416
435
|
...chainConfigMappings,
|
|
417
436
|
...txCollectionConfigMappings,
|
|
@@ -441,9 +460,10 @@ export type BootnodeConfig = Pick<
|
|
|
441
460
|
| 'peerIdPrivateKeyPath'
|
|
442
461
|
| 'bootstrapNodes'
|
|
443
462
|
| 'listenAddress'
|
|
463
|
+
| 'queryForIp'
|
|
444
464
|
> &
|
|
445
465
|
Required<Pick<P2PConfig, 'p2pIp' | 'p2pPort'>> &
|
|
446
|
-
Pick<DataStoreConfig, 'dataDirectory' | '
|
|
466
|
+
Pick<DataStoreConfig, 'dataDirectory' | 'dataStoreMapSizeKb'> &
|
|
447
467
|
Pick<ChainConfig, 'l1ChainId'>;
|
|
448
468
|
|
|
449
469
|
const bootnodeConfigKeys: (keyof BootnodeConfig)[] = [
|
|
@@ -454,9 +474,10 @@ const bootnodeConfigKeys: (keyof BootnodeConfig)[] = [
|
|
|
454
474
|
'peerIdPrivateKey',
|
|
455
475
|
'peerIdPrivateKeyPath',
|
|
456
476
|
'dataDirectory',
|
|
457
|
-
'
|
|
477
|
+
'dataStoreMapSizeKb',
|
|
458
478
|
'bootstrapNodes',
|
|
459
479
|
'l1ChainId',
|
|
480
|
+
'queryForIp',
|
|
460
481
|
];
|
|
461
482
|
|
|
462
483
|
export const bootnodeConfigMappings = pickConfigMappings(
|
package/src/enr/generate-enr.ts
CHANGED
|
@@ -2,9 +2,9 @@ import type { LogFn } from '@aztec/foundation/log';
|
|
|
2
2
|
import { type ChainConfig, emptyChainConfig } from '@aztec/stdlib/config';
|
|
3
3
|
import type { ComponentsVersions } from '@aztec/stdlib/versioning';
|
|
4
4
|
|
|
5
|
-
import { ENR, SignableENR } from '@chainsafe/enr';
|
|
6
5
|
import type { PeerId } from '@libp2p/interface';
|
|
7
6
|
import { type Multiaddr, multiaddr } from '@multiformats/multiaddr';
|
|
7
|
+
import { ENR, SignableENR } from '@nethermindeth/enr';
|
|
8
8
|
|
|
9
9
|
import { AZTEC_ENR_CLIENT_VERSION_KEY, AZTEC_ENR_KEY } from '../types/index.js';
|
|
10
10
|
import { convertToMultiaddr, createLibP2PPeerIdFromPrivateKey } from '../util.js';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export class AttestationPoolError extends Error {
|
|
2
|
+
constructor(message?: string) {
|
|
3
|
+
super(message);
|
|
4
|
+
this.name = 'AttestationPoolError';
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export class ProposalSlotCapExceededError extends AttestationPoolError {
|
|
9
|
+
constructor(message?: string) {
|
|
10
|
+
super(message);
|
|
11
|
+
this.name = 'ProposalSlotCapExceededError';
|
|
12
|
+
}
|
|
13
|
+
}
|