@aztec/p2p 5.0.0-private.20260319 → 5.0.0-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -1
- package/dest/bootstrap/bootstrap.d.ts +1 -1
- package/dest/bootstrap/bootstrap.d.ts.map +1 -1
- package/dest/bootstrap/bootstrap.js +22 -6
- package/dest/client/factory.d.ts +4 -3
- package/dest/client/factory.d.ts.map +1 -1
- package/dest/client/factory.js +33 -24
- package/dest/client/interface.d.ts +43 -11
- package/dest/client/interface.d.ts.map +1 -1
- package/dest/client/p2p_client.d.ts +33 -19
- package/dest/client/p2p_client.d.ts.map +1 -1
- package/dest/client/p2p_client.js +100 -44
- package/dest/config.d.ts +137 -107
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +64 -23
- package/dest/errors/p2p-service.error.d.ts +9 -0
- package/dest/errors/p2p-service.error.d.ts.map +1 -0
- package/dest/errors/p2p-service.error.js +10 -0
- package/dest/errors/reqresp.error.d.ts +1 -20
- package/dest/errors/reqresp.error.d.ts.map +1 -1
- package/dest/errors/reqresp.error.js +0 -21
- package/dest/index.d.ts +1 -2
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +0 -1
- package/dest/mem_pools/attestation_pool/attestation_pool.d.ts +98 -56
- package/dest/mem_pools/attestation_pool/attestation_pool.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/attestation_pool.js +265 -196
- 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 +175 -59
- package/dest/mem_pools/attestation_pool/mocks.d.ts +1 -1
- package/dest/mem_pools/attestation_pool/mocks.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/mocks.js +6 -4
- package/dest/mem_pools/index.d.ts +1 -2
- package/dest/mem_pools/index.d.ts.map +1 -1
- package/dest/mem_pools/instrumentation.d.ts +1 -1
- package/dest/mem_pools/instrumentation.d.ts.map +1 -1
- package/dest/mem_pools/instrumentation.js +17 -1
- package/dest/mem_pools/tx_pool_v2/archive/tx_archive.d.ts +1 -5
- package/dest/mem_pools/tx_pool_v2/archive/tx_archive.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/archive/tx_archive.js +1 -7
- package/dest/mem_pools/tx_pool_v2/deleted_pool.d.ts +3 -3
- package/dest/mem_pools/tx_pool_v2/deleted_pool.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/deleted_pool.js +6 -6
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.js +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/index.d.ts +2 -1
- package/dest/mem_pools/tx_pool_v2/eviction/index.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/index.js +1 -0
- package/dest/mem_pools/tx_pool_v2/eviction/insufficient_fee_per_gas_eviction_rule.d.ts +16 -0
- package/dest/mem_pools/tx_pool_v2/eviction/insufficient_fee_per_gas_eviction_rule.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/eviction/insufficient_fee_per_gas_eviction_rule.js +62 -0
- package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.js +2 -2
- package/dest/mem_pools/tx_pool_v2/interfaces.d.ts +22 -5
- package/dest/mem_pools/tx_pool_v2/interfaces.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts +5 -2
- package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/tx_metadata.js +13 -6
- package/dest/mem_pools/tx_pool_v2/tx_pool_indices.d.ts +7 -1
- package/dest/mem_pools/tx_pool_v2/tx_pool_indices.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/tx_pool_indices.js +10 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts +8 -3
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2.js +7 -4
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts +8 -3
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.js +153 -111
- package/dest/msg_validators/attestation_validator/attestation_validator.d.ts +10 -3
- package/dest/msg_validators/attestation_validator/attestation_validator.d.ts.map +1 -1
- package/dest/msg_validators/attestation_validator/attestation_validator.js +38 -16
- package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.d.ts +7 -3
- package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.d.ts.map +1 -1
- package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.js +4 -5
- package/dest/msg_validators/proposal_validator/block_proposal_validator.d.ts +8 -3
- package/dest/msg_validators/proposal_validator/block_proposal_validator.d.ts.map +1 -1
- package/dest/msg_validators/proposal_validator/block_proposal_validator.js +2 -2
- package/dest/msg_validators/proposal_validator/checkpoint_proposal_validator.d.ts +8 -3
- package/dest/msg_validators/proposal_validator/checkpoint_proposal_validator.d.ts.map +1 -1
- package/dest/msg_validators/proposal_validator/checkpoint_proposal_validator.js +8 -2
- package/dest/msg_validators/proposal_validator/proposal_validator.d.ts +25 -3
- package/dest/msg_validators/proposal_validator/proposal_validator.d.ts.map +1 -1
- package/dest/msg_validators/proposal_validator/proposal_validator.js +77 -14
- 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/aggregate_tx_validator.js +8 -15
- package/dest/msg_validators/tx_validator/allowed_public_setup.js +3 -3
- package/dest/msg_validators/tx_validator/archive_cache.js +1 -1
- package/dest/msg_validators/tx_validator/cached_tx_validator.d.ts +15 -0
- package/dest/msg_validators/tx_validator/cached_tx_validator.d.ts.map +1 -0
- package/dest/msg_validators/tx_validator/cached_tx_validator.js +19 -0
- package/dest/msg_validators/tx_validator/contract_instance_validator.d.ts +9 -0
- package/dest/msg_validators/tx_validator/contract_instance_validator.d.ts.map +1 -0
- package/dest/msg_validators/tx_validator/contract_instance_validator.js +48 -0
- package/dest/msg_validators/tx_validator/data_validator.d.ts +2 -1
- package/dest/msg_validators/tx_validator/data_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/data_validator.js +36 -2
- package/dest/msg_validators/tx_validator/factory.d.ts +14 -15
- package/dest/msg_validators/tx_validator/factory.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/factory.js +36 -17
- package/dest/msg_validators/tx_validator/gas_validator.d.ts +47 -10
- package/dest/msg_validators/tx_validator/gas_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/gas_validator.js +65 -48
- package/dest/msg_validators/tx_validator/index.d.ts +3 -1
- package/dest/msg_validators/tx_validator/index.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/index.js +2 -0
- package/dest/msg_validators/tx_validator/phases_validator.js +3 -3
- package/dest/msg_validators/tx_validator/tx_proof_validator.d.ts +2 -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 +2 -0
- package/dest/msg_validators/tx_validator/tx_validation_cache.d.ts +48 -0
- package/dest/msg_validators/tx_validator/tx_validation_cache.d.ts.map +1 -0
- package/dest/msg_validators/tx_validator/tx_validation_cache.js +68 -0
- package/dest/services/data_store.d.ts +1 -1
- package/dest/services/data_store.d.ts.map +1 -1
- package/dest/services/data_store.js +5 -5
- package/dest/services/discv5/discV5_service.d.ts +13 -2
- package/dest/services/discv5/discV5_service.d.ts.map +1 -1
- package/dest/services/discv5/discV5_service.js +119 -23
- package/dest/services/discv5/persisted_enr_store.d.ts +38 -0
- package/dest/services/discv5/persisted_enr_store.d.ts.map +1 -0
- package/dest/services/discv5/persisted_enr_store.js +145 -0
- package/dest/services/dummy_service.d.ts +15 -15
- package/dest/services/dummy_service.d.ts.map +1 -1
- package/dest/services/dummy_service.js +15 -16
- package/dest/services/encoding.d.ts +8 -8
- package/dest/services/encoding.d.ts.map +1 -1
- package/dest/services/encoding.js +11 -15
- package/dest/services/gossipsub/topic_score_params.d.ts +6 -12
- package/dest/services/gossipsub/topic_score_params.d.ts.map +1 -1
- package/dest/services/gossipsub/topic_score_params.js +4 -14
- package/dest/services/libp2p/instrumentation.d.ts +3 -1
- package/dest/services/libp2p/instrumentation.d.ts.map +1 -1
- package/dest/services/libp2p/instrumentation.js +14 -0
- package/dest/services/libp2p/libp2p_service.d.ts +44 -39
- package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
- package/dest/services/libp2p/libp2p_service.js +383 -278
- package/dest/services/peer-manager/peer_manager.d.ts +20 -3
- package/dest/services/peer-manager/peer_manager.d.ts.map +1 -1
- package/dest/services/peer-manager/peer_manager.js +79 -23
- package/dest/services/peer-manager/peer_scoring.d.ts +34 -2
- package/dest/services/peer-manager/peer_scoring.d.ts.map +1 -1
- package/dest/services/peer-manager/peer_scoring.js +102 -13
- package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts +1 -8
- package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts.map +1 -1
- package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.js +38 -44
- package/dest/services/reqresp/batch-tx-requester/interface.d.ts +8 -5
- package/dest/services/reqresp/batch-tx-requester/interface.d.ts.map +1 -1
- package/dest/services/reqresp/batch-tx-requester/tx_validator.d.ts +5 -14
- package/dest/services/reqresp/batch-tx-requester/tx_validator.d.ts.map +1 -1
- package/dest/services/reqresp/batch-tx-requester/tx_validator.js +6 -20
- package/dest/services/reqresp/config.d.ts +3 -3
- package/dest/services/reqresp/config.d.ts.map +1 -1
- package/dest/services/reqresp/interface.d.ts +16 -18
- package/dest/services/reqresp/interface.d.ts.map +1 -1
- package/dest/services/reqresp/interface.js +10 -20
- package/dest/services/reqresp/metrics.d.ts +1 -1
- package/dest/services/reqresp/metrics.d.ts.map +1 -1
- package/dest/services/reqresp/metrics.js +0 -1
- package/dest/services/reqresp/protocols/block_txs/bitvector.d.ts +4 -3
- package/dest/services/reqresp/protocols/block_txs/bitvector.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/block_txs/bitvector.js +3 -2
- package/dest/services/reqresp/protocols/block_txs/block_txs_handler.d.ts +1 -1
- package/dest/services/reqresp/protocols/block_txs/block_txs_handler.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/block_txs/block_txs_handler.js +31 -28
- package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.d.ts +12 -7
- 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 +42 -24
- package/dest/services/reqresp/protocols/index.d.ts +1 -2
- package/dest/services/reqresp/protocols/index.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/index.js +0 -1
- package/dest/services/reqresp/protocols/tx.d.ts +1 -1
- package/dest/services/reqresp/protocols/tx.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/tx.js +1 -3
- package/dest/services/reqresp/rate-limiter/rate_limiter.d.ts +5 -4
- package/dest/services/reqresp/rate-limiter/rate_limiter.d.ts.map +1 -1
- package/dest/services/reqresp/rate-limiter/rate_limiter.js +10 -8
- package/dest/services/reqresp/rate-limiter/rate_limits.d.ts +1 -1
- package/dest/services/reqresp/rate-limiter/rate_limits.d.ts.map +1 -1
- package/dest/services/reqresp/rate-limiter/rate_limits.js +0 -10
- package/dest/services/reqresp/reqresp.d.ts +7 -29
- package/dest/services/reqresp/reqresp.d.ts.map +1 -1
- package/dest/services/reqresp/reqresp.js +26 -207
- package/dest/services/service.d.ts +25 -12
- package/dest/services/service.d.ts.map +1 -1
- package/dest/services/tx_collection/config.d.ts +2 -23
- package/dest/services/tx_collection/config.d.ts.map +1 -1
- package/dest/services/tx_collection/config.js +2 -55
- package/dest/services/tx_collection/file_store_tx_collection.d.ts +12 -28
- package/dest/services/tx_collection/file_store_tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/file_store_tx_collection.js +43 -83
- package/dest/services/tx_collection/file_store_tx_source.d.ts +5 -4
- package/dest/services/tx_collection/file_store_tx_source.d.ts.map +1 -1
- package/dest/services/tx_collection/file_store_tx_source.js +39 -29
- package/dest/services/tx_collection/index.d.ts +2 -3
- package/dest/services/tx_collection/index.d.ts.map +1 -1
- package/dest/services/tx_collection/index.js +0 -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/instrumentation.js +0 -2
- package/dest/services/tx_collection/tx_collection.d.ts +35 -51
- package/dest/services/tx_collection/tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/tx_collection.js +275 -119
- package/dest/services/tx_collection/tx_collection_sink.d.ts +1 -1
- package/dest/services/tx_collection/tx_collection_sink.js +2 -2
- package/dest/services/tx_collection/tx_source.d.ts +6 -5
- package/dest/services/tx_collection/tx_source.d.ts.map +1 -1
- package/dest/services/tx_collection/tx_source.js +13 -8
- package/dest/services/tx_file_store/tx_file_store.d.ts +1 -3
- package/dest/services/tx_file_store/tx_file_store.d.ts.map +1 -1
- package/dest/services/tx_file_store/tx_file_store.js +4 -14
- package/dest/services/tx_provider.d.ts +3 -1
- package/dest/services/tx_provider.d.ts.map +1 -1
- package/dest/services/tx_provider.js +3 -0
- package/dest/test-helpers/make-test-p2p-clients.d.ts +1 -1
- package/dest/test-helpers/make-test-p2p-clients.d.ts.map +1 -1
- package/dest/test-helpers/make-test-p2p-clients.js +5 -2
- package/dest/test-helpers/mock-pubsub.d.ts +23 -9
- package/dest/test-helpers/mock-pubsub.d.ts.map +1 -1
- package/dest/test-helpers/mock-pubsub.js +44 -44
- package/dest/test-helpers/reqresp-nodes.d.ts +4 -5
- package/dest/test-helpers/reqresp-nodes.d.ts.map +1 -1
- package/dest/test-helpers/reqresp-nodes.js +16 -18
- package/dest/test-helpers/test_tx_provider.d.ts +3 -1
- package/dest/test-helpers/test_tx_provider.d.ts.map +1 -1
- package/dest/test-helpers/test_tx_provider.js +3 -0
- package/dest/test-helpers/testbench-utils.d.ts +14 -14
- package/dest/test-helpers/testbench-utils.d.ts.map +1 -1
- package/dest/test-helpers/testbench-utils.js +25 -13
- package/dest/testbench/p2p_client_testbench_worker.d.ts +3 -5
- package/dest/testbench/p2p_client_testbench_worker.d.ts.map +1 -1
- package/dest/testbench/p2p_client_testbench_worker.js +102 -41
- package/dest/testbench/worker_client_manager.d.ts +10 -6
- package/dest/testbench/worker_client_manager.d.ts.map +1 -1
- package/dest/testbench/worker_client_manager.js +51 -9
- package/dest/util.d.ts +11 -6
- package/dest/util.d.ts.map +1 -1
- package/dest/util.js +35 -14
- package/dest/versioning.d.ts +3 -6
- package/dest/versioning.d.ts.map +1 -1
- package/dest/versioning.js +3 -24
- package/package.json +16 -16
- package/src/bootstrap/bootstrap.ts +17 -3
- package/src/client/factory.ts +52 -24
- package/src/client/interface.ts +38 -17
- package/src/client/p2p_client.ts +118 -76
- package/src/client/test/{tx_proposal_collector/README.md → p2p_client.batch_tx_requester.bench.README.md} +23 -53
- package/src/config.ts +130 -31
- package/src/errors/p2p-service.error.ts +11 -0
- package/src/errors/reqresp.error.ts +0 -25
- package/src/index.ts +0 -1
- package/src/mem_pools/attestation_pool/attestation_pool.ts +319 -238
- package/src/mem_pools/attestation_pool/attestation_pool_test_suite.ts +198 -62
- package/src/mem_pools/attestation_pool/mocks.ts +13 -8
- package/src/mem_pools/index.ts +0 -3
- package/src/mem_pools/instrumentation.ts +5 -1
- package/src/mem_pools/tx_pool_v2/archive/tx_archive.ts +1 -9
- package/src/mem_pools/tx_pool_v2/deleted_pool.ts +7 -7
- package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.ts +1 -1
- package/src/mem_pools/tx_pool_v2/eviction/index.ts +1 -0
- package/src/mem_pools/tx_pool_v2/eviction/insufficient_fee_per_gas_eviction_rule.ts +65 -0
- package/src/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.ts +3 -3
- package/src/mem_pools/tx_pool_v2/interfaces.ts +18 -4
- package/src/mem_pools/tx_pool_v2/tx_metadata.ts +20 -8
- package/src/mem_pools/tx_pool_v2/tx_pool_indices.ts +12 -0
- package/src/mem_pools/tx_pool_v2/tx_pool_v2.ts +8 -4
- package/src/mem_pools/tx_pool_v2/tx_pool_v2_impl.ts +163 -117
- package/src/msg_validators/attestation_validator/attestation_validator.ts +46 -15
- package/src/msg_validators/attestation_validator/fisherman_attestation_validator.ts +15 -7
- package/src/msg_validators/proposal_validator/README.md +1 -1
- package/src/msg_validators/proposal_validator/block_proposal_validator.ts +15 -3
- package/src/msg_validators/proposal_validator/checkpoint_proposal_validator.ts +26 -3
- package/src/msg_validators/proposal_validator/proposal_validator.ts +89 -11
- package/src/msg_validators/tx_validator/README.md +13 -3
- package/src/msg_validators/tx_validator/aggregate_tx_validator.ts +3 -12
- package/src/msg_validators/tx_validator/allowed_public_setup.ts +3 -3
- package/src/msg_validators/tx_validator/archive_cache.ts +1 -1
- package/src/msg_validators/tx_validator/cached_tx_validator.ts +31 -0
- package/src/msg_validators/tx_validator/contract_instance_validator.ts +56 -0
- package/src/msg_validators/tx_validator/data_validator.ts +44 -1
- package/src/msg_validators/tx_validator/factory.ts +44 -20
- package/src/msg_validators/tx_validator/gas_validator.ts +99 -54
- package/src/msg_validators/tx_validator/index.ts +2 -0
- package/src/msg_validators/tx_validator/phases_validator.ts +3 -3
- package/src/msg_validators/tx_validator/tx_proof_validator.ts +2 -0
- package/src/msg_validators/tx_validator/tx_validation_cache.ts +101 -0
- package/src/services/data_store.ts +5 -13
- package/src/services/discv5/discV5_service.ts +126 -14
- package/src/services/discv5/persisted_enr_store.ts +158 -0
- package/src/services/dummy_service.ts +20 -39
- package/src/services/encoding.ts +11 -21
- package/src/services/gossipsub/README.md +33 -11
- package/src/services/gossipsub/topic_score_params.ts +9 -18
- package/src/services/libp2p/instrumentation.ts +14 -0
- package/src/services/libp2p/libp2p_service.ts +436 -311
- package/src/services/peer-manager/peer_manager.ts +86 -22
- package/src/services/peer-manager/peer_scoring.ts +102 -8
- package/src/services/reqresp/README.md +0 -14
- package/src/services/reqresp/batch-tx-requester/batch_tx_requester.ts +42 -52
- package/src/services/reqresp/batch-tx-requester/interface.ts +11 -4
- package/src/services/reqresp/batch-tx-requester/tx_validator.ts +12 -25
- package/src/services/reqresp/config.ts +2 -2
- package/src/services/reqresp/interface.ts +21 -47
- package/src/services/reqresp/metrics.ts +0 -1
- package/src/services/reqresp/protocols/block_txs/bitvector.ts +3 -2
- package/src/services/reqresp/protocols/block_txs/block_txs_handler.ts +34 -30
- package/src/services/reqresp/protocols/block_txs/block_txs_reqresp.ts +47 -20
- package/src/services/reqresp/protocols/index.ts +0 -1
- package/src/services/reqresp/protocols/tx.ts +1 -3
- package/src/services/reqresp/rate-limiter/rate_limiter.ts +13 -9
- package/src/services/reqresp/rate-limiter/rate_limits.ts +0 -10
- package/src/services/reqresp/reqresp.ts +29 -252
- package/src/services/service.ts +31 -28
- package/src/services/tx_collection/config.ts +3 -80
- package/src/services/tx_collection/file_store_tx_collection.ts +54 -103
- package/src/services/tx_collection/file_store_tx_source.ts +43 -31
- package/src/services/tx_collection/index.ts +1 -6
- package/src/services/tx_collection/instrumentation.ts +1 -7
- package/src/services/tx_collection/tx_collection.ts +330 -173
- package/src/services/tx_collection/tx_collection_sink.ts +2 -2
- package/src/services/tx_collection/tx_source.ts +10 -8
- package/src/services/tx_file_store/tx_file_store.ts +5 -17
- package/src/services/tx_provider.ts +5 -0
- package/src/test-helpers/make-test-p2p-clients.ts +3 -0
- package/src/test-helpers/mock-pubsub.ts +46 -60
- package/src/test-helpers/reqresp-nodes.ts +12 -22
- package/src/test-helpers/test_tx_provider.ts +5 -0
- package/src/test-helpers/testbench-utils.ts +31 -26
- package/src/testbench/p2p_client_testbench_worker.ts +110 -55
- package/src/testbench/worker_client_manager.ts +59 -20
- package/src/util.ts +32 -17
- package/src/versioning.ts +3 -33
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.d.ts +0 -2
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.d.ts.map +0 -1
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.js +0 -305
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker_protocol.d.ts +0 -73
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker_protocol.d.ts.map +0 -1
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker_protocol.js +0 -8
- package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.d.ts +0 -125
- package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.js +0 -596
- package/dest/mem_pools/tx_pool/eviction/eviction_manager.d.ts +0 -32
- package/dest/mem_pools/tx_pool/eviction/eviction_manager.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/eviction/eviction_manager.js +0 -112
- package/dest/mem_pools/tx_pool/eviction/eviction_strategy.d.ts +0 -157
- package/dest/mem_pools/tx_pool/eviction/eviction_strategy.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/eviction/eviction_strategy.js +0 -52
- package/dest/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.d.ts +0 -16
- package/dest/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.js +0 -123
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.d.ts +0 -17
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.js +0 -84
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.d.ts +0 -19
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.js +0 -78
- package/dest/mem_pools/tx_pool/eviction/low_priority_eviction_rule.d.ts +0 -26
- package/dest/mem_pools/tx_pool/eviction/low_priority_eviction_rule.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/eviction/low_priority_eviction_rule.js +0 -84
- package/dest/mem_pools/tx_pool/eviction/nullifier_conflict_pre_add_rule.d.ts +0 -25
- package/dest/mem_pools/tx_pool/eviction/nullifier_conflict_pre_add_rule.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/eviction/nullifier_conflict_pre_add_rule.js +0 -57
- package/dest/mem_pools/tx_pool/index.d.ts +0 -3
- package/dest/mem_pools/tx_pool/index.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/index.js +0 -2
- package/dest/mem_pools/tx_pool/priority.d.ts +0 -12
- package/dest/mem_pools/tx_pool/priority.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/priority.js +0 -15
- package/dest/mem_pools/tx_pool/tx_pool.d.ts +0 -127
- package/dest/mem_pools/tx_pool/tx_pool.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/tx_pool.js +0 -3
- package/dest/mem_pools/tx_pool/tx_pool_test_suite.d.ts +0 -7
- package/dest/mem_pools/tx_pool/tx_pool_test_suite.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/tx_pool_test_suite.js +0 -402
- package/dest/msg_validators/clock_tolerance.d.ts +0 -21
- package/dest/msg_validators/clock_tolerance.d.ts.map +0 -1
- package/dest/msg_validators/clock_tolerance.js +0 -38
- package/dest/services/reqresp/connection-sampler/batch_connection_sampler.d.ts +0 -64
- package/dest/services/reqresp/connection-sampler/batch_connection_sampler.d.ts.map +0 -1
- package/dest/services/reqresp/connection-sampler/batch_connection_sampler.js +0 -151
- package/dest/services/reqresp/protocols/block.d.ts +0 -9
- package/dest/services/reqresp/protocols/block.d.ts.map +0 -1
- package/dest/services/reqresp/protocols/block.js +0 -32
- package/dest/services/tx_collection/fast_tx_collection.d.ts +0 -51
- package/dest/services/tx_collection/fast_tx_collection.d.ts.map +0 -1
- package/dest/services/tx_collection/fast_tx_collection.js +0 -311
- package/dest/services/tx_collection/proposal_tx_collector.d.ts +0 -48
- package/dest/services/tx_collection/proposal_tx_collector.d.ts.map +0 -1
- package/dest/services/tx_collection/proposal_tx_collector.js +0 -50
- package/dest/services/tx_collection/slow_tx_collection.d.ts +0 -57
- package/dest/services/tx_collection/slow_tx_collection.d.ts.map +0 -1
- package/dest/services/tx_collection/slow_tx_collection.js +0 -211
- package/src/client/test/tx_proposal_collector/proposal_tx_collector_worker.ts +0 -344
- package/src/client/test/tx_proposal_collector/proposal_tx_collector_worker_protocol.ts +0 -43
- package/src/mem_pools/tx_pool/README.md +0 -270
- package/src/mem_pools/tx_pool/aztec_kv_tx_pool.ts +0 -746
- package/src/mem_pools/tx_pool/eviction/eviction_manager.ts +0 -132
- package/src/mem_pools/tx_pool/eviction/eviction_strategy.ts +0 -208
- package/src/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.ts +0 -163
- package/src/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.ts +0 -104
- package/src/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.ts +0 -93
- package/src/mem_pools/tx_pool/eviction/low_priority_eviction_rule.ts +0 -106
- package/src/mem_pools/tx_pool/eviction/nullifier_conflict_pre_add_rule.ts +0 -75
- package/src/mem_pools/tx_pool/index.ts +0 -2
- package/src/mem_pools/tx_pool/priority.ts +0 -20
- package/src/mem_pools/tx_pool/tx_pool.ts +0 -141
- package/src/mem_pools/tx_pool/tx_pool_test_suite.ts +0 -321
- package/src/msg_validators/clock_tolerance.ts +0 -52
- package/src/services/reqresp/connection-sampler/batch_connection_sampler.ts +0 -161
- package/src/services/reqresp/protocols/block.ts +0 -37
- package/src/services/tx_collection/fast_tx_collection.ts +0 -361
- package/src/services/tx_collection/proposal_tx_collector.ts +0 -108
- package/src/services/tx_collection/slow_tx_collection.ts +0 -266
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
2
|
+
import type { AztecAsyncKVStore, AztecAsyncMap } from '@aztec/kv-store';
|
|
3
|
+
|
|
4
|
+
import { ENR } from '@nethermindeth/enr';
|
|
5
|
+
|
|
6
|
+
/** Map name under which discovered peer ENRs are persisted so discovery can be re-seeded after a restart. */
|
|
7
|
+
const PERSISTED_ENRS_MAP_NAME = 'discovered_peer_enrs';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* A persisted peer entry: the ENR text plus a monotonic sequence number recording when the peer was
|
|
11
|
+
* last seen. The sequence orders the store as a FIFO so eviction drops the oldest-seen peers first.
|
|
12
|
+
*/
|
|
13
|
+
interface PersistedEnr {
|
|
14
|
+
enr: string;
|
|
15
|
+
seq: number;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function parsePersistedEnr(value: string): PersistedEnr | undefined {
|
|
19
|
+
try {
|
|
20
|
+
const parsed = JSON.parse(value);
|
|
21
|
+
if (typeof parsed?.enr === 'string' && typeof parsed?.seq === 'number') {
|
|
22
|
+
return parsed;
|
|
23
|
+
}
|
|
24
|
+
} catch {
|
|
25
|
+
// Unparseable entry; caller treats it as stale.
|
|
26
|
+
}
|
|
27
|
+
return undefined;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* A bounded, transactional store of discovered peer ENRs used to re-seed discovery after a restart.
|
|
32
|
+
*
|
|
33
|
+
* Entries are keyed by nodeId (so re-seeing a peer dedups in place) and carry a monotonic sequence so
|
|
34
|
+
* the store behaves as a FIFO: when it exceeds its cap, the oldest-seen peers are evicted first. All
|
|
35
|
+
* writes run in a transaction so concurrent discovery events can't race the size check.
|
|
36
|
+
*/
|
|
37
|
+
export class PersistedEnrStore {
|
|
38
|
+
private readonly enrs: AztecAsyncMap<string, string>;
|
|
39
|
+
/** Monotonic sequence stamped on each entry; seeded from the store's max in {@link load}. */
|
|
40
|
+
private seq = 0;
|
|
41
|
+
|
|
42
|
+
constructor(
|
|
43
|
+
private readonly store: AztecAsyncKVStore,
|
|
44
|
+
private readonly maxEntries: number,
|
|
45
|
+
private readonly logger: Logger = createLogger('p2p:discv5:enr-store'),
|
|
46
|
+
) {
|
|
47
|
+
this.enrs = store.openMap(PERSISTED_ENRS_MAP_NAME);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** Adds or replaces a peer's ENR, stamping it as most-recently-seen and evicting the oldest if over cap. */
|
|
51
|
+
public async persist(enr: ENR): Promise<void> {
|
|
52
|
+
const nodeId = enr.nodeId;
|
|
53
|
+
const enrTxt = enr.encodeTxt();
|
|
54
|
+
try {
|
|
55
|
+
await this.store.transactionAsync(async () => {
|
|
56
|
+
const seq = ++this.seq;
|
|
57
|
+
const others: { nodeId: string; seq: number }[] = [];
|
|
58
|
+
for await (const [id, value] of this.enrs.entriesAsync()) {
|
|
59
|
+
if (id !== nodeId) {
|
|
60
|
+
others.push({ nodeId: id, seq: parsePersistedEnr(value)?.seq ?? 0 });
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
const overflow = others.length + 1 - this.maxEntries;
|
|
64
|
+
if (overflow > 0) {
|
|
65
|
+
others.sort((a, b) => a.seq - b.seq); // oldest-seen (lowest sequence) first
|
|
66
|
+
for (let i = 0; i < overflow; i++) {
|
|
67
|
+
await this.enrs.delete(others[i].nodeId);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
await this.enrs.set(nodeId, JSON.stringify({ enr: enrTxt, seq }));
|
|
71
|
+
});
|
|
72
|
+
} catch (err) {
|
|
73
|
+
this.logger.warn(`Failed to persist discovered ENR ${nodeId}`, err);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Refreshes an already-persisted peer's stored ENR when a newer one (higher ENR sequence) is seen.
|
|
79
|
+
* A no-op for peers we don't already track — we never add new peers via this path, only update.
|
|
80
|
+
*
|
|
81
|
+
* This exists because discv5 updates an existing routing-table entry on an ENR sequence bump without
|
|
82
|
+
* emitting an `enrAdded` event, so a peer that changes address would otherwise keep its stale ENR
|
|
83
|
+
* persisted until evicted.
|
|
84
|
+
*/
|
|
85
|
+
public async refresh(enr: ENR): Promise<void> {
|
|
86
|
+
const nodeId = enr.nodeId;
|
|
87
|
+
try {
|
|
88
|
+
await this.store.transactionAsync(async () => {
|
|
89
|
+
const existing = await this.enrs.getAsync(nodeId);
|
|
90
|
+
if (!existing) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
// Two unrelated sequence numbers are in play:
|
|
94
|
+
// - the ENR sequence (`enr.seq` / `storedEnrSeq`) is set by the *peer* and bumped whenever it
|
|
95
|
+
// revises its record (e.g. changes address); we compare these to decide whether the incoming
|
|
96
|
+
// ENR is genuinely newer and worth keeping.
|
|
97
|
+
// - our storage sequence (`this.seq`) is an internal counter used only for FIFO eviction; we
|
|
98
|
+
// stamp a fresh one so this entry counts as most-recently-seen.
|
|
99
|
+
const storedEnrSeq = this.decodeStoredEnr(existing)?.seq;
|
|
100
|
+
if (storedEnrSeq !== undefined && enr.seq <= storedEnrSeq) {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
await this.enrs.set(nodeId, JSON.stringify({ enr: enr.encodeTxt(), seq: ++this.seq }));
|
|
104
|
+
});
|
|
105
|
+
} catch (err) {
|
|
106
|
+
this.logger.warn(`Failed to refresh persisted ENR ${nodeId}`, err);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Loads all persisted ENRs, decoding each and keeping those the `accept` predicate allows. Entries
|
|
112
|
+
* that fail to decode or are rejected are removed from the store. The FIFO sequence resumes from the
|
|
113
|
+
* highest persisted value so eviction order survives restarts.
|
|
114
|
+
*/
|
|
115
|
+
public async load(accept: (enr: ENR) => boolean): Promise<ENR[]> {
|
|
116
|
+
const valid: ENR[] = [];
|
|
117
|
+
const stale: string[] = [];
|
|
118
|
+
let maxSeq = 0;
|
|
119
|
+
for await (const [nodeId, value] of this.enrs.entriesAsync()) {
|
|
120
|
+
const parsed = parsePersistedEnr(value);
|
|
121
|
+
let enr: ENR | undefined;
|
|
122
|
+
if (parsed) {
|
|
123
|
+
try {
|
|
124
|
+
enr = ENR.decodeTxt(parsed.enr);
|
|
125
|
+
} catch (err) {
|
|
126
|
+
this.logger.debug(`Dropping undecodable persisted ENR ${nodeId}`, err);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
if (!parsed || !enr || !accept(enr)) {
|
|
130
|
+
stale.push(nodeId);
|
|
131
|
+
continue;
|
|
132
|
+
}
|
|
133
|
+
maxSeq = Math.max(maxSeq, parsed.seq);
|
|
134
|
+
valid.push(enr);
|
|
135
|
+
}
|
|
136
|
+
this.seq = maxSeq;
|
|
137
|
+
if (stale.length > 0) {
|
|
138
|
+
await this.store.transactionAsync(async () => {
|
|
139
|
+
for (const nodeId of stale) {
|
|
140
|
+
await this.enrs.delete(nodeId);
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
return valid;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
private decodeStoredEnr(value: string): ENR | undefined {
|
|
148
|
+
const parsed = parsePersistedEnr(value);
|
|
149
|
+
if (!parsed) {
|
|
150
|
+
return undefined;
|
|
151
|
+
}
|
|
152
|
+
try {
|
|
153
|
+
return ENR.decodeTxt(parsed.enr);
|
|
154
|
+
} catch {
|
|
155
|
+
return undefined;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
@@ -18,16 +18,17 @@ import type {
|
|
|
18
18
|
ReqRespSubProtocol,
|
|
19
19
|
ReqRespSubProtocolHandler,
|
|
20
20
|
ReqRespSubProtocolHandlers,
|
|
21
|
-
ReqRespSubProtocolValidators,
|
|
22
21
|
SubProtocolMap,
|
|
23
22
|
} from './reqresp/interface.js';
|
|
24
23
|
import type { GoodByeReason } from './reqresp/protocols/goodbye.js';
|
|
25
24
|
import { ReqRespStatus } from './reqresp/status.js';
|
|
26
25
|
import {
|
|
27
26
|
type P2PBlockReceivedCallback,
|
|
27
|
+
type P2PCheckpointAttestationCallback,
|
|
28
28
|
type P2PCheckpointReceivedCallback,
|
|
29
29
|
type P2PDuplicateAttestationCallback,
|
|
30
30
|
type P2PDuplicateProposalCallback,
|
|
31
|
+
type P2POversizedProposalCallback,
|
|
31
32
|
type P2PService,
|
|
32
33
|
type PeerDiscoveryService,
|
|
33
34
|
PeerDiscoveryState,
|
|
@@ -37,6 +38,8 @@ import {
|
|
|
37
38
|
* A dummy implementation of the P2P Service.
|
|
38
39
|
*/
|
|
39
40
|
export class DummyP2PService implements P2PService {
|
|
41
|
+
private allNodesCheckpointReceivedCallback?: P2PCheckpointReceivedCallback;
|
|
42
|
+
|
|
40
43
|
updateConfig(_config: Partial<P2PReqRespConfig>): void {}
|
|
41
44
|
|
|
42
45
|
/** Returns an empty array for peers. */
|
|
@@ -86,18 +89,28 @@ export class DummyP2PService implements P2PService {
|
|
|
86
89
|
/**
|
|
87
90
|
* Register a callback into the validator client for when a checkpoint proposal is received
|
|
88
91
|
*/
|
|
89
|
-
public
|
|
92
|
+
public registerValidatorCheckpointReceivedCallback(_callback: P2PCheckpointReceivedCallback) {}
|
|
93
|
+
public registerAllNodesCheckpointReceivedCallback(callback: P2PCheckpointReceivedCallback) {
|
|
94
|
+
this.allNodesCheckpointReceivedCallback = callback;
|
|
95
|
+
}
|
|
90
96
|
|
|
91
97
|
/**
|
|
92
98
|
* Register a callback for when a duplicate proposal is detected
|
|
93
99
|
*/
|
|
94
100
|
public registerDuplicateProposalCallback(_callback: P2PDuplicateProposalCallback): void {}
|
|
95
101
|
|
|
102
|
+
/**
|
|
103
|
+
* Register a callback for when an oversized proposal is stored
|
|
104
|
+
*/
|
|
105
|
+
public registerOversizedProposalCallback(_callback: P2POversizedProposalCallback): void {}
|
|
106
|
+
|
|
96
107
|
/**
|
|
97
108
|
* Register a callback for when a duplicate attestation is detected
|
|
98
109
|
*/
|
|
99
110
|
public registerDuplicateAttestationCallback(_callback: P2PDuplicateAttestationCallback): void {}
|
|
100
111
|
|
|
112
|
+
public registerCheckpointAttestationCallback(_callback: P2PCheckpointAttestationCallback): void {}
|
|
113
|
+
|
|
101
114
|
/**
|
|
102
115
|
* Sends a request to a peer.
|
|
103
116
|
* @param _protocol - The protocol to send the request on.
|
|
@@ -111,19 +124,6 @@ export class DummyP2PService implements P2PService {
|
|
|
111
124
|
return Promise.resolve(undefined);
|
|
112
125
|
}
|
|
113
126
|
|
|
114
|
-
/**
|
|
115
|
-
* Sends a batch request to a peer.
|
|
116
|
-
* @param _protocol - The protocol to send the request on.
|
|
117
|
-
* @param _requests - The requests to send.
|
|
118
|
-
* @returns The responses from the peer, otherwise undefined.
|
|
119
|
-
*/
|
|
120
|
-
public sendBatchRequest<Protocol extends ReqRespSubProtocol>(
|
|
121
|
-
_protocol: Protocol,
|
|
122
|
-
_requests: InstanceType<SubProtocolMap[Protocol]['request']>[],
|
|
123
|
-
): Promise<InstanceType<SubProtocolMap[Protocol]['response']>[]> {
|
|
124
|
-
return Promise.resolve([]);
|
|
125
|
-
}
|
|
126
|
-
|
|
127
127
|
public sendRequestToPeer(
|
|
128
128
|
_peerId: PeerId,
|
|
129
129
|
_subProtocol: ReqRespSubProtocol,
|
|
@@ -145,11 +145,7 @@ export class DummyP2PService implements P2PService {
|
|
|
145
145
|
return Promise.resolve();
|
|
146
146
|
}
|
|
147
147
|
|
|
148
|
-
addReqRespSubProtocol(
|
|
149
|
-
_subProtocol: ReqRespSubProtocol,
|
|
150
|
-
_handler: ReqRespSubProtocolHandler,
|
|
151
|
-
_validator?: ReqRespSubProtocolValidators[ReqRespSubProtocol],
|
|
152
|
-
): Promise<void> {
|
|
148
|
+
addReqRespSubProtocol(_subProtocol: ReqRespSubProtocol, _handler: ReqRespSubProtocolHandler): Promise<void> {
|
|
153
149
|
return Promise.resolve();
|
|
154
150
|
}
|
|
155
151
|
|
|
@@ -178,6 +174,7 @@ export class DummyP2PService implements P2PService {
|
|
|
178
174
|
peerScoring: {
|
|
179
175
|
penalizePeer: (_peerId, _penalty) => {},
|
|
180
176
|
},
|
|
177
|
+
validateRequestedBlockTxsConsistency: () => Promise.resolve(true),
|
|
181
178
|
};
|
|
182
179
|
}
|
|
183
180
|
}
|
|
@@ -282,10 +279,8 @@ export class DummyPeerManager implements PeerManagerInterface {
|
|
|
282
279
|
|
|
283
280
|
export class DummyReqResp implements ReqRespInterface {
|
|
284
281
|
updateConfig(_config: Partial<P2PReqRespConfig>): void {}
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
_subProtocolValidators: ReqRespSubProtocolValidators,
|
|
288
|
-
): Promise<void> {
|
|
282
|
+
setShouldRejectPeer(): void {}
|
|
283
|
+
start(_subProtocolHandlers: ReqRespSubProtocolHandlers): Promise<void> {
|
|
289
284
|
return Promise.resolve();
|
|
290
285
|
}
|
|
291
286
|
stop(): Promise<void> {
|
|
@@ -297,16 +292,6 @@ export class DummyReqResp implements ReqRespInterface {
|
|
|
297
292
|
): Promise<InstanceType<SubProtocolMap[SubProtocol]['response']> | undefined> {
|
|
298
293
|
return Promise.resolve(undefined);
|
|
299
294
|
}
|
|
300
|
-
sendBatchRequest<SubProtocol extends ReqRespSubProtocol>(
|
|
301
|
-
_subProtocol: SubProtocol,
|
|
302
|
-
_requests: InstanceType<SubProtocolMap[SubProtocol]['request']>[],
|
|
303
|
-
_pinnedPeer: PeerId | undefined,
|
|
304
|
-
_timeoutMs?: number,
|
|
305
|
-
_maxPeers?: number,
|
|
306
|
-
_maxRetryAttempts?: number,
|
|
307
|
-
): Promise<InstanceType<SubProtocolMap[SubProtocol]['response']>[]> {
|
|
308
|
-
return Promise.resolve([]);
|
|
309
|
-
}
|
|
310
295
|
public sendRequestToPeer(
|
|
311
296
|
_peerId: PeerId,
|
|
312
297
|
_subProtocol: ReqRespSubProtocol,
|
|
@@ -325,11 +310,7 @@ export class DummyReqResp implements ReqRespInterface {
|
|
|
325
310
|
};
|
|
326
311
|
}
|
|
327
312
|
|
|
328
|
-
addSubProtocol(
|
|
329
|
-
_subProtocol: ReqRespSubProtocol,
|
|
330
|
-
_handler: ReqRespSubProtocolHandler,
|
|
331
|
-
_validator?: ReqRespSubProtocolValidators[ReqRespSubProtocol],
|
|
332
|
-
): Promise<void> {
|
|
313
|
+
addSubProtocol(_subProtocol: ReqRespSubProtocol, _handler: ReqRespSubProtocolHandler): Promise<void> {
|
|
333
314
|
return Promise.resolve();
|
|
334
315
|
}
|
|
335
316
|
}
|
package/src/services/encoding.ts
CHANGED
|
@@ -2,12 +2,10 @@
|
|
|
2
2
|
import { createLogger } from '@aztec/foundation/log';
|
|
3
3
|
import { MAX_TX_SIZE_KB, TopicType, getTopicFromString } from '@aztec/stdlib/p2p';
|
|
4
4
|
|
|
5
|
-
import type { RPC } from '@chainsafe/libp2p-gossipsub/message';
|
|
6
5
|
import type { DataTransform } from '@chainsafe/libp2p-gossipsub/types';
|
|
7
6
|
import type { Message } from '@libp2p/interface';
|
|
8
7
|
import { webcrypto } from 'node:crypto';
|
|
9
8
|
import { compressSync, uncompressSync } from 'snappy';
|
|
10
|
-
import xxhashFactory from 'xxhash-wasm';
|
|
11
9
|
|
|
12
10
|
/** Thrown when a Snappy-compressed response exceeds the allowed decompressed size. */
|
|
13
11
|
export class OversizedSnappyResponseError extends Error {
|
|
@@ -17,26 +15,9 @@ export class OversizedSnappyResponseError extends Error {
|
|
|
17
15
|
}
|
|
18
16
|
}
|
|
19
17
|
|
|
20
|
-
// Load WASM
|
|
21
|
-
const xxhash = await xxhashFactory();
|
|
22
|
-
|
|
23
|
-
// Use salt to prevent msgId from being mined for collisions
|
|
24
|
-
const h64Seed = BigInt(Math.floor(Math.random() * 1e9));
|
|
25
|
-
|
|
26
18
|
// Shared buffer to convert msgId to string
|
|
27
19
|
const sharedMsgIdBuf = Buffer.alloc(20);
|
|
28
20
|
|
|
29
|
-
/**
|
|
30
|
-
* The function used to generate a gossipsub message id
|
|
31
|
-
* We use the first 8 bytes of SHA256(data) for content addressing
|
|
32
|
-
*/
|
|
33
|
-
export function fastMsgIdFn(rpcMsg: RPC.Message): string {
|
|
34
|
-
if (rpcMsg.data) {
|
|
35
|
-
return xxhash.h64Raw(rpcMsg.data, h64Seed).toString(16);
|
|
36
|
-
}
|
|
37
|
-
return '0000000000000000';
|
|
38
|
-
}
|
|
39
|
-
|
|
40
21
|
export function msgIdToStrFn(msgId: Uint8Array): string {
|
|
41
22
|
// This happens serially, no need to reallocate the buffer
|
|
42
23
|
sharedMsgIdBuf.set(msgId);
|
|
@@ -49,11 +30,20 @@ export function msgIdToStrFn(msgId: Uint8Array): string {
|
|
|
49
30
|
* Follows similarly to:
|
|
50
31
|
* https://github.com/ethereum/consensus-specs/blob/v1.1.0-alpha.7/specs/altair/p2p-interface.md#topics-and-messages
|
|
51
32
|
*
|
|
33
|
+
* The topic length is framed into the hash input (`uint32be(topicLen) || topic || data`) so the
|
|
34
|
+
* `(topic, data)` boundary is unambiguous. A raw `topic || data` concatenation is not injective —
|
|
35
|
+
* shifting bytes across the boundary (e.g. `(topic + data[0], data[1:])`) yields the same bytes and
|
|
36
|
+
* thus the same id, letting an unsubscribed-topic message pre-occupy a real message's seenCache slot
|
|
37
|
+
* and suppress it as a duplicate.
|
|
38
|
+
*
|
|
52
39
|
* @param message - The libp2p message
|
|
53
40
|
* @returns The message identifier
|
|
54
41
|
*/
|
|
55
|
-
export async function getMsgIdFn({ topic, data }: Message): Promise<Uint8Array> {
|
|
56
|
-
const
|
|
42
|
+
export async function getMsgIdFn({ topic, data }: Pick<Message, 'topic' | 'data'>): Promise<Uint8Array> {
|
|
43
|
+
const topicBytes = Buffer.from(topic);
|
|
44
|
+
const framedTopicLength = Buffer.allocUnsafe(4);
|
|
45
|
+
framedTopicLength.writeUInt32BE(topicBytes.length);
|
|
46
|
+
const buffer = Buffer.concat([framedTopicLength, topicBytes, data]);
|
|
57
47
|
const hash = await webcrypto.subtle.digest('SHA-256', buffer);
|
|
58
48
|
return Buffer.from(hash.slice(0, 20));
|
|
59
49
|
}
|
|
@@ -205,7 +205,7 @@ This ensures P3 max penalty (-34) exceeds P1 + P2 max (+33), causing mesh prunin
|
|
|
205
205
|
| Topic | Expected/Slot | Decay Window | Notes |
|
|
206
206
|
|-------|--------------|--------------|-------|
|
|
207
207
|
| `tx` | Unpredictable | N/A | P3/P3b disabled |
|
|
208
|
-
| `block_proposal` | N-1 | 3 slots | N = blocks per slot
|
|
208
|
+
| `block_proposal` | N-1 | 3 slots | N = blocks per slot |
|
|
209
209
|
| `checkpoint_proposal` | 1 | 5 slots | One per slot |
|
|
210
210
|
| `checkpoint_attestation` | C (~48) | 2 slots | C = committee size |
|
|
211
211
|
|
|
@@ -223,15 +223,15 @@ Block proposal scoring is controlled by the `expectedBlockProposalsPerSlot` conf
|
|
|
223
223
|
|-------------|----------|
|
|
224
224
|
| `0` (current default) | Block proposal P3 scoring is **disabled** |
|
|
225
225
|
| Positive number | Uses the provided value as expected proposals per slot |
|
|
226
|
-
| `undefined` | Falls back to `blocksPerSlot - 1` (
|
|
226
|
+
| `undefined` | Falls back to `blocksPerSlot - 1` (N-1 when the slot fits multiple blocks, 0 when it fits one) |
|
|
227
227
|
|
|
228
228
|
**Current behavior note:** In the current implementation, if `SEQ_EXPECTED_BLOCK_PROPOSALS_PER_SLOT` is not set, config mapping applies `0` by default (scoring disabled). The `undefined` fallback above is currently reachable only if the value is explicitly provided as `undefined` in code.
|
|
229
229
|
|
|
230
230
|
**Future intent:** Once throughput is stable, we may change env parsing/defaults so an unset env var resolves to `undefined` again (re-enabling automatic fallback to `blocksPerSlot - 1`).
|
|
231
231
|
|
|
232
|
-
**Why disabled by default?**
|
|
232
|
+
**Why disabled by default?** Gossipsub expects N-1 block proposals per slot. When transaction throughput is low (as expected at launch), fewer blocks are actually built, causing peers to be incorrectly penalized for under-delivering block proposals. The default of 0 disables this scoring. Set to a positive value when throughput increases and block production is consistent.
|
|
233
233
|
|
|
234
|
-
|
|
234
|
+
When a slot fits multiple blocks, N-1 block proposals are gossiped per slot (the last block is bundled with the checkpoint). When the slot fits exactly one block, this is 0.
|
|
235
235
|
|
|
236
236
|
### Checkpoint Proposals (checkpoint_proposal)
|
|
237
237
|
|
|
@@ -254,7 +254,7 @@ The scoring parameters depend on:
|
|
|
254
254
|
| `slotDuration` | L1RollupConstants | 72s |
|
|
255
255
|
| `targetCommitteeSize` | L1RollupConstants | 48 |
|
|
256
256
|
| `heartbeatInterval` | P2PConfig.gossipsubInterval | 700ms |
|
|
257
|
-
| `blockDurationMs` | P2PConfig.blockDurationMs |
|
|
257
|
+
| `blockDurationMs` | P2PConfig.blockDurationMs | 3000ms |
|
|
258
258
|
| `expectedBlockProposalsPerSlot` | P2PConfig.expectedBlockProposalsPerSlot | 0 (disabled; current unset-env behavior) |
|
|
259
259
|
|
|
260
260
|
## Invalid Message Handling (P4)
|
|
@@ -470,7 +470,22 @@ Application scores decay by 10% per minute (`decayFactor = 0.9`):
|
|
|
470
470
|
- Score -100 → -35 after 10 minutes
|
|
471
471
|
- Score -100 → -12 after 20 minutes
|
|
472
472
|
|
|
473
|
-
This allows honest peers to recover from temporary issues.
|
|
473
|
+
This allows honest peers to recover from temporary issues — but only up to the ban threshold. Once a peer
|
|
474
|
+
crosses into the **Banned** state, decay no longer applies until the ban expires (see Ban Duration below).
|
|
475
|
+
|
|
476
|
+
### Ban Duration
|
|
477
|
+
|
|
478
|
+
Once a peer's score drops below the ban threshold (`MIN_SCORE_BEFORE_BAN = -100`) the ban is held for a configurable
|
|
479
|
+
duration:
|
|
480
|
+
|
|
481
|
+
- The score the peer held when banned is recorded in memory alongside an expiry timestamp.
|
|
482
|
+
- While the ban is active, `getScore` returns the **ban score** regardless of decay, so the peer stays in the
|
|
483
|
+
`Banned` state for the full window and cannot decay its way out early.
|
|
484
|
+
- When the ban expires it is removed and the live (decayed) score takes over again, letting the peer recover.
|
|
485
|
+
|
|
486
|
+
The ban duration is controlled by `P2P_PEER_BAN_DURATION_SECONDS` (config field `peerBanDurationSeconds`), defaulting
|
|
487
|
+
to 24 hours. Bans are held in memory only (cleared on restart). This is independent of the gossipsub topic-score
|
|
488
|
+
decay (P4, P3b), which continues to decay as described above; only the application-level ban score is pinned.
|
|
474
489
|
|
|
475
490
|
## Score Calculation Examples
|
|
476
491
|
|
|
@@ -544,15 +559,22 @@ Initial state: Total score -3003
|
|
|
544
559
|
|
|
545
560
|
After 4 slots (~5 min):
|
|
546
561
|
P4 decays to 1%: -2000 → -20
|
|
547
|
-
App score
|
|
562
|
+
App score pinned at ban floor: -1000
|
|
548
563
|
Total: -1023 → Still banned, but no longer graylisted
|
|
549
564
|
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
Total:
|
|
565
|
+
For the rest of the ban window (default 24h):
|
|
566
|
+
Topic scores (P4, P3b) keep decaying toward 0
|
|
567
|
+
App score stays pinned at the ban floor: -1000 contribution
|
|
568
|
+
Total: ~-1000 → Remains banned (cannot publish)
|
|
569
|
+
|
|
570
|
+
After the ban expires:
|
|
571
|
+
The ban is lifted; the live app score (now decayed toward 0) takes over
|
|
572
|
+
Total: recovers, peer can participate again
|
|
554
573
|
```
|
|
555
574
|
|
|
575
|
+
Unlike topic scores, the application ban score does **not** decay-recover during the ban window — that is the
|
|
576
|
+
point of the ban duration (see above). A banned peer is held for the full `P2P_PEER_BAN_DURATION_SECONDS`.
|
|
577
|
+
|
|
556
578
|
## Network Outage Analysis
|
|
557
579
|
|
|
558
580
|
What happens when a peer experiences a network outage and stops delivering messages?
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { TopicType, createTopicString } from '@aztec/stdlib/p2p';
|
|
2
|
-
import { calculateMaxBlocksPerSlot } from '@aztec/stdlib/timetable';
|
|
3
2
|
|
|
4
3
|
import { createTopicScoreParams } from '@chainsafe/libp2p-gossipsub/score';
|
|
5
4
|
|
|
@@ -13,24 +12,15 @@ export type TopicScoringNetworkParams = {
|
|
|
13
12
|
heartbeatIntervalMs: number;
|
|
14
13
|
/** Target committee size (number of validators expected to attest per slot) */
|
|
15
14
|
targetCommitteeSize: number;
|
|
16
|
-
/**
|
|
17
|
-
|
|
15
|
+
/**
|
|
16
|
+
* Max blocks per checkpoint, the network-wide config value. Used to derive expected per-slot message rates
|
|
17
|
+
* for scoring; it is a peer-rate threshold input, not a consensus deadline.
|
|
18
|
+
*/
|
|
19
|
+
maxBlocksPerCheckpoint: number;
|
|
18
20
|
/** Expected number of block proposals per slot for scoring override. 0 disables scoring, undefined falls back to blocksPerSlot - 1. */
|
|
19
21
|
expectedBlockProposalsPerSlot?: number;
|
|
20
22
|
};
|
|
21
23
|
|
|
22
|
-
/**
|
|
23
|
-
* Calculates the number of blocks per slot based on timing parameters.
|
|
24
|
-
* Uses the shared calculation from @aztec/stdlib/timetable.
|
|
25
|
-
*
|
|
26
|
-
* @param slotDurationMs - L2 slot duration in milliseconds
|
|
27
|
-
* @param blockDurationMs - Duration per block in milliseconds (undefined = single block mode)
|
|
28
|
-
* @returns Number of blocks per slot
|
|
29
|
-
*/
|
|
30
|
-
export function calculateBlocksPerSlot(slotDurationMs: number, blockDurationMs: number | undefined): number {
|
|
31
|
-
return calculateMaxBlocksPerSlot(slotDurationMs / 1000, blockDurationMs ? blockDurationMs / 1000 : undefined);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
24
|
/**
|
|
35
25
|
* Determines the decay window in slots based on expected message frequency.
|
|
36
26
|
* Low-frequency topics need longer decay windows to accumulate meaningful counter values.
|
|
@@ -276,10 +266,11 @@ export class TopicScoreParamsFactory {
|
|
|
276
266
|
};
|
|
277
267
|
|
|
278
268
|
constructor(private readonly params: TopicScoringNetworkParams) {
|
|
279
|
-
const { slotDurationMs, heartbeatIntervalMs
|
|
269
|
+
const { slotDurationMs, heartbeatIntervalMs } = params;
|
|
280
270
|
|
|
281
|
-
// Compute values that are the same for all topics
|
|
282
|
-
|
|
271
|
+
// Compute values that are the same for all topics. The block count comes straight from the network-wide
|
|
272
|
+
// max-blocks-per-checkpoint config value.
|
|
273
|
+
this.blocksPerSlot = params.maxBlocksPerCheckpoint;
|
|
283
274
|
this.heartbeatsPerSlot = slotDurationMs / heartbeatIntervalMs;
|
|
284
275
|
this.invalidDecay = computeDecay(heartbeatIntervalMs, slotDurationMs, INVALID_DECAY_WINDOW_SLOTS);
|
|
285
276
|
|
|
@@ -18,6 +18,7 @@ export class P2PInstrumentation {
|
|
|
18
18
|
private messagePrevalidationCount: UpDownCounter;
|
|
19
19
|
private messageLatency: Histogram;
|
|
20
20
|
private txReceivedCount: UpDownCounter;
|
|
21
|
+
private slowValidationCount: UpDownCounter;
|
|
21
22
|
|
|
22
23
|
private aggLatencyHisto = new Map<TopicType, RecordableHistogram>();
|
|
23
24
|
private aggValidationHisto = new Map<TopicType, RecordableHistogram>();
|
|
@@ -48,6 +49,15 @@ export class P2PInstrumentation {
|
|
|
48
49
|
|
|
49
50
|
this.txReceivedCount = createUpDownCounterWithDefault(meter, Metrics.P2P_GOSSIP_TX_RECEIVED_COUNT);
|
|
50
51
|
|
|
52
|
+
this.slowValidationCount = createUpDownCounterWithDefault(meter, Metrics.P2P_GOSSIP_SLOW_VALIDATION_COUNT, {
|
|
53
|
+
[Attributes.TOPIC_NAME]: [
|
|
54
|
+
TopicType.tx,
|
|
55
|
+
TopicType.block_proposal,
|
|
56
|
+
TopicType.checkpoint_proposal,
|
|
57
|
+
TopicType.checkpoint_attestation,
|
|
58
|
+
],
|
|
59
|
+
});
|
|
60
|
+
|
|
51
61
|
this.aggLatencyMetrics = {
|
|
52
62
|
avg: meter.createObservableGauge(Metrics.P2P_GOSSIP_AGG_MESSAGE_LATENCY_AVG),
|
|
53
63
|
max: meter.createObservableGauge(Metrics.P2P_GOSSIP_AGG_MESSAGE_LATENCY_MAX),
|
|
@@ -87,6 +97,10 @@ export class P2PInstrumentation {
|
|
|
87
97
|
this.txReceivedCount.add(count);
|
|
88
98
|
}
|
|
89
99
|
|
|
100
|
+
public incSlowValidation(topicName: TopicType) {
|
|
101
|
+
this.slowValidationCount.add(1, { [Attributes.TOPIC_NAME]: topicName });
|
|
102
|
+
}
|
|
103
|
+
|
|
90
104
|
public incMessagePrevalidationStatus(passed: boolean, topicName: TopicType | undefined) {
|
|
91
105
|
this.messagePrevalidationCount.add(1, { [Attributes.TOPIC_NAME]: topicName, [Attributes.OK]: passed });
|
|
92
106
|
}
|