@aztec/p2p 0.0.1-commit.86469d5 → 0.0.1-commit.8655d4a
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +129 -3
- package/dest/bootstrap/bootstrap.d.ts +1 -1
- package/dest/bootstrap/bootstrap.d.ts.map +1 -1
- package/dest/bootstrap/bootstrap.js +9 -1
- package/dest/client/factory.d.ts +13 -12
- package/dest/client/factory.d.ts.map +1 -1
- package/dest/client/factory.js +61 -17
- package/dest/client/interface.d.ts +58 -36
- package/dest/client/interface.d.ts.map +1 -1
- package/dest/client/p2p_client.d.ts +52 -58
- package/dest/client/p2p_client.d.ts.map +1 -1
- package/dest/client/p2p_client.js +228 -235
- package/dest/config.d.ts +162 -89
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +153 -42
- 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/errors/tx-pool.error.d.ts +8 -0
- package/dest/errors/tx-pool.error.d.ts.map +1 -0
- package/dest/errors/tx-pool.error.js +9 -0
- package/dest/index.d.ts +2 -2
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +1 -1
- package/dest/mem_pools/attestation_pool/attestation_pool.d.ts +162 -106
- package/dest/mem_pools/attestation_pool/attestation_pool.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/attestation_pool.js +511 -3
- package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.d.ts +2 -2
- package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.js +507 -125
- package/dest/mem_pools/attestation_pool/index.d.ts +2 -3
- package/dest/mem_pools/attestation_pool/index.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/index.js +1 -2
- package/dest/mem_pools/attestation_pool/mocks.d.ts +2 -2
- package/dest/mem_pools/attestation_pool/mocks.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/mocks.js +7 -5
- package/dest/mem_pools/index.d.ts +3 -3
- package/dest/mem_pools/index.d.ts.map +1 -1
- package/dest/mem_pools/index.js +1 -1
- package/dest/mem_pools/instrumentation.d.ts +4 -2
- package/dest/mem_pools/instrumentation.d.ts.map +1 -1
- package/dest/mem_pools/instrumentation.js +33 -15
- package/dest/mem_pools/interface.d.ts +5 -5
- package/dest/mem_pools/interface.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/archive/index.d.ts +2 -0
- package/dest/mem_pools/tx_pool_v2/archive/index.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/archive/index.js +1 -0
- package/dest/mem_pools/tx_pool_v2/archive/tx_archive.d.ts +43 -0
- package/dest/mem_pools/tx_pool_v2/archive/tx_archive.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/archive/tx_archive.js +103 -0
- package/dest/mem_pools/tx_pool_v2/deleted_pool.d.ts +104 -0
- package/dest/mem_pools/tx_pool_v2/deleted_pool.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/deleted_pool.js +251 -0
- package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.d.ts +47 -0
- package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.js +128 -0
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.d.ts +17 -0
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.js +94 -0
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.d.ts +19 -0
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.js +97 -0
- package/dest/mem_pools/tx_pool_v2/eviction/index.d.ts +11 -0
- package/dest/mem_pools/tx_pool_v2/eviction/index.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/eviction/index.js +12 -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/interfaces.d.ts +180 -0
- package/dest/mem_pools/tx_pool_v2/eviction/interfaces.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/eviction/interfaces.js +25 -0
- package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.d.ts +15 -0
- package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.d.ts.map +1 -0
- package/dest/mem_pools/{tx_pool → tx_pool_v2}/eviction/invalid_txs_after_mining_rule.js +16 -35
- package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.d.ts +17 -0
- package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.js +93 -0
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.d.ts +16 -0
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.js +78 -0
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.d.ts +20 -0
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.js +75 -0
- package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.d.ts +15 -0
- package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.js +19 -0
- package/dest/mem_pools/tx_pool_v2/index.d.ts +6 -0
- package/dest/mem_pools/tx_pool_v2/index.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/index.js +5 -0
- package/dest/mem_pools/tx_pool_v2/instrumentation.d.ts +15 -0
- package/dest/mem_pools/tx_pool_v2/instrumentation.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/instrumentation.js +43 -0
- package/dest/mem_pools/tx_pool_v2/interfaces.d.ts +218 -0
- package/dest/mem_pools/tx_pool_v2/interfaces.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/interfaces.js +10 -0
- package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts +137 -0
- package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/tx_metadata.js +223 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_bench_metrics.d.ts +26 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_bench_metrics.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_bench_metrics.js +70 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_indices.d.ts +108 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_indices.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_indices.js +337 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts +62 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2.js +167 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts +78 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.js +914 -0
- package/dest/msg_validators/attestation_validator/attestation_validator.d.ts +9 -3
- package/dest/msg_validators/attestation_validator/attestation_validator.d.ts.map +1 -1
- package/dest/msg_validators/attestation_validator/attestation_validator.js +37 -12
- package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.d.ts +8 -4
- 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/clock_tolerance.d.ts +12 -1
- package/dest/msg_validators/clock_tolerance.d.ts.map +1 -1
- package/dest/msg_validators/clock_tolerance.js +61 -3
- package/dest/msg_validators/proposal_validator/block_proposal_validator.d.ts +10 -4
- package/dest/msg_validators/proposal_validator/block_proposal_validator.d.ts.map +1 -1
- package/dest/msg_validators/proposal_validator/block_proposal_validator.js +10 -2
- package/dest/msg_validators/proposal_validator/checkpoint_proposal_validator.d.ts +10 -4
- package/dest/msg_validators/proposal_validator/checkpoint_proposal_validator.d.ts.map +1 -1
- package/dest/msg_validators/proposal_validator/checkpoint_proposal_validator.js +16 -2
- package/dest/msg_validators/proposal_validator/proposal_validator.d.ts +21 -8
- package/dest/msg_validators/proposal_validator/proposal_validator.d.ts.map +1 -1
- package/dest/msg_validators/proposal_validator/proposal_validator.js +90 -44
- package/dest/msg_validators/tx_validator/aggregate_tx_validator.d.ts +4 -4
- package/dest/msg_validators/tx_validator/aggregate_tx_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/aggregate_tx_validator.js +11 -18
- package/dest/msg_validators/tx_validator/allowed_public_setup.d.ts +2 -1
- package/dest/msg_validators/tx_validator/allowed_public_setup.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/allowed_public_setup.js +25 -21
- package/dest/msg_validators/tx_validator/allowed_setup_helpers.d.ts +17 -0
- package/dest/msg_validators/tx_validator/allowed_setup_helpers.d.ts.map +1 -0
- package/dest/msg_validators/tx_validator/allowed_setup_helpers.js +24 -0
- package/dest/msg_validators/tx_validator/archive_cache.js +1 -1
- package/dest/msg_validators/tx_validator/block_header_validator.d.ts +16 -3
- package/dest/msg_validators/tx_validator/block_header_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/block_header_validator.js +1 -1
- package/dest/msg_validators/tx_validator/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/double_spend_validator.d.ts +13 -3
- package/dest/msg_validators/tx_validator/double_spend_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/double_spend_validator.js +4 -4
- package/dest/msg_validators/tx_validator/factory.d.ts +135 -7
- package/dest/msg_validators/tx_validator/factory.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/factory.js +252 -61
- package/dest/msg_validators/tx_validator/fee_payer_balance.d.ts +1 -1
- package/dest/msg_validators/tx_validator/fee_payer_balance.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/fee_payer_balance.js +6 -2
- package/dest/msg_validators/tx_validator/gas_validator.d.ts +99 -3
- package/dest/msg_validators/tx_validator/gas_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/gas_validator.js +137 -53
- package/dest/msg_validators/tx_validator/index.d.ts +5 -1
- package/dest/msg_validators/tx_validator/index.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/index.js +4 -0
- package/dest/msg_validators/tx_validator/metadata_validator.d.ts +1 -1
- package/dest/msg_validators/tx_validator/metadata_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/metadata_validator.js +4 -4
- package/dest/msg_validators/tx_validator/nullifier_cache.d.ts +14 -0
- package/dest/msg_validators/tx_validator/nullifier_cache.d.ts.map +1 -0
- package/dest/msg_validators/tx_validator/nullifier_cache.js +24 -0
- package/dest/msg_validators/tx_validator/phases_validator.d.ts +22 -2
- package/dest/msg_validators/tx_validator/phases_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/phases_validator.js +72 -24
- package/dest/msg_validators/tx_validator/timestamp_validator.d.ts +20 -4
- package/dest/msg_validators/tx_validator/timestamp_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/timestamp_validator.js +6 -6
- package/dest/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 +69 -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 +2 -1
- package/dest/services/discv5/discV5_service.d.ts.map +1 -1
- package/dest/services/discv5/discV5_service.js +35 -8
- package/dest/services/dummy_service.d.ts +22 -18
- package/dest/services/dummy_service.d.ts.map +1 -1
- package/dest/services/dummy_service.js +22 -20
- package/dest/services/encoding.d.ts +7 -3
- package/dest/services/encoding.d.ts.map +1 -1
- package/dest/services/encoding.js +18 -11
- package/dest/services/gossipsub/index.d.ts +3 -0
- package/dest/services/gossipsub/index.d.ts.map +1 -0
- package/dest/services/gossipsub/index.js +2 -0
- package/dest/services/gossipsub/scoring.d.ts +21 -3
- package/dest/services/gossipsub/scoring.d.ts.map +1 -1
- package/dest/services/gossipsub/scoring.js +24 -7
- package/dest/services/gossipsub/topic_score_params.d.ts +184 -0
- package/dest/services/gossipsub/topic_score_params.d.ts.map +1 -0
- package/dest/services/gossipsub/topic_score_params.js +363 -0
- package/dest/services/index.d.ts +2 -1
- package/dest/services/index.d.ts.map +1 -1
- package/dest/services/index.js +1 -0
- package/dest/services/libp2p/instrumentation.d.ts +3 -1
- package/dest/services/libp2p/instrumentation.d.ts.map +1 -1
- package/dest/services/libp2p/instrumentation.js +14 -0
- package/dest/services/libp2p/libp2p_service.d.ts +102 -60
- package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
- package/dest/services/libp2p/libp2p_service.js +665 -530
- package/dest/services/peer-manager/metrics.d.ts +3 -1
- package/dest/services/peer-manager/metrics.d.ts.map +1 -1
- package/dest/services/peer-manager/metrics.js +6 -0
- package/dest/services/peer-manager/peer_manager.d.ts +6 -2
- package/dest/services/peer-manager/peer_manager.d.ts.map +1 -1
- package/dest/services/peer-manager/peer_manager.js +40 -11
- package/dest/services/peer-manager/peer_scoring.d.ts +7 -2
- package/dest/services/peer-manager/peer_scoring.d.ts.map +1 -1
- package/dest/services/peer-manager/peer_scoring.js +57 -12
- package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts +14 -10
- package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts.map +1 -1
- package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.js +104 -118
- package/dest/services/reqresp/batch-tx-requester/interface.d.ts +11 -11
- package/dest/services/reqresp/batch-tx-requester/interface.d.ts.map +1 -1
- package/dest/services/reqresp/batch-tx-requester/missing_txs.d.ts +11 -13
- package/dest/services/reqresp/batch-tx-requester/missing_txs.d.ts.map +1 -1
- package/dest/services/reqresp/batch-tx-requester/missing_txs.js +31 -46
- package/dest/services/reqresp/batch-tx-requester/peer_collection.d.ts +19 -11
- package/dest/services/reqresp/batch-tx-requester/peer_collection.d.ts.map +1 -1
- package/dest/services/reqresp/batch-tx-requester/peer_collection.js +52 -15
- package/dest/services/reqresp/batch-tx-requester/tx_validator.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 +25 -18
- package/dest/services/reqresp/interface.d.ts.map +1 -1
- package/dest/services/reqresp/interface.js +23 -19
- package/dest/services/reqresp/metrics.d.ts +1 -1
- package/dest/services/reqresp/metrics.d.ts.map +1 -1
- package/dest/services/reqresp/metrics.js +0 -1
- package/dest/services/reqresp/protocols/block_txs/block_txs_handler.d.ts +7 -5
- package/dest/services/reqresp/protocols/block_txs/block_txs_handler.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/block_txs/block_txs_handler.js +18 -11
- package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.d.ts +21 -10
- package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.js +27 -11
- package/dest/services/reqresp/protocols/index.d.ts +1 -2
- package/dest/services/reqresp/protocols/index.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/index.js +0 -1
- package/dest/services/reqresp/protocols/tx.d.ts +7 -1
- package/dest/services/reqresp/protocols/tx.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/tx.js +21 -3
- package/dest/services/reqresp/rate-limiter/rate_limiter.d.ts +5 -4
- package/dest/services/reqresp/rate-limiter/rate_limiter.d.ts.map +1 -1
- package/dest/services/reqresp/rate-limiter/rate_limiter.js +10 -8
- package/dest/services/reqresp/rate-limiter/rate_limits.d.ts +1 -1
- package/dest/services/reqresp/rate-limiter/rate_limits.d.ts.map +1 -1
- package/dest/services/reqresp/rate-limiter/rate_limits.js +0 -10
- package/dest/services/reqresp/reqresp.d.ts +7 -29
- package/dest/services/reqresp/reqresp.d.ts.map +1 -1
- package/dest/services/reqresp/reqresp.js +53 -218
- package/dest/services/service.d.ts +46 -13
- package/dest/services/service.d.ts.map +1 -1
- package/dest/services/tx_collection/config.d.ts +11 -14
- package/dest/services/tx_collection/config.d.ts.map +1 -1
- package/dest/services/tx_collection/config.js +26 -33
- package/dest/services/tx_collection/file_store_tx_collection.d.ts +37 -0
- package/dest/services/tx_collection/file_store_tx_collection.d.ts.map +1 -0
- package/dest/services/tx_collection/file_store_tx_collection.js +127 -0
- package/dest/services/tx_collection/file_store_tx_source.d.ts +38 -0
- package/dest/services/tx_collection/file_store_tx_source.d.ts.map +1 -0
- package/dest/services/tx_collection/file_store_tx_source.js +100 -0
- package/dest/services/tx_collection/index.d.ts +3 -3
- package/dest/services/tx_collection/index.d.ts.map +1 -1
- package/dest/services/tx_collection/index.js +1 -1
- package/dest/services/tx_collection/instrumentation.js +1 -2
- package/dest/services/tx_collection/request_tracker.d.ts +53 -0
- package/dest/services/tx_collection/request_tracker.d.ts.map +1 -0
- package/dest/services/tx_collection/request_tracker.js +84 -0
- package/dest/services/tx_collection/tx_collection.d.ts +45 -51
- package/dest/services/tx_collection/tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/tx_collection.js +296 -68
- package/dest/services/tx_collection/tx_collection_sink.d.ts +19 -9
- package/dest/services/tx_collection/tx_collection_sink.d.ts.map +1 -1
- package/dest/services/tx_collection/tx_collection_sink.js +28 -31
- package/dest/services/tx_collection/tx_source.d.ts +13 -7
- package/dest/services/tx_collection/tx_source.d.ts.map +1 -1
- package/dest/services/tx_collection/tx_source.js +26 -7
- package/dest/services/tx_file_store/config.d.ts +16 -0
- package/dest/services/tx_file_store/config.d.ts.map +1 -0
- package/dest/services/tx_file_store/config.js +22 -0
- package/dest/services/tx_file_store/index.d.ts +4 -0
- package/dest/services/tx_file_store/index.d.ts.map +1 -0
- package/dest/services/tx_file_store/index.js +3 -0
- package/dest/services/tx_file_store/instrumentation.d.ts +15 -0
- package/dest/services/tx_file_store/instrumentation.d.ts.map +1 -0
- package/dest/services/tx_file_store/instrumentation.js +29 -0
- package/dest/services/tx_file_store/tx_file_store.d.ts +46 -0
- package/dest/services/tx_file_store/tx_file_store.d.ts.map +1 -0
- package/dest/services/tx_file_store/tx_file_store.js +142 -0
- 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 +12 -8
- package/dest/test-helpers/make-test-p2p-clients.d.ts +7 -8
- package/dest/test-helpers/make-test-p2p-clients.d.ts.map +1 -1
- package/dest/test-helpers/make-test-p2p-clients.js +5 -3
- package/dest/test-helpers/mock-pubsub.d.ts +46 -6
- package/dest/test-helpers/mock-pubsub.d.ts.map +1 -1
- package/dest/test-helpers/mock-pubsub.js +115 -14
- package/dest/test-helpers/reqresp-nodes.d.ts +5 -7
- package/dest/test-helpers/reqresp-nodes.d.ts.map +1 -1
- package/dest/test-helpers/reqresp-nodes.js +19 -20
- 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 +53 -50
- package/dest/test-helpers/testbench-utils.d.ts.map +1 -1
- package/dest/test-helpers/testbench-utils.js +171 -75
- 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 +94 -48
- package/dest/testbench/worker_client_manager.d.ts +12 -6
- package/dest/testbench/worker_client_manager.d.ts.map +1 -1
- package/dest/testbench/worker_client_manager.js +57 -11
- package/dest/util.d.ts +13 -8
- 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 +15 -14
- package/src/bootstrap/bootstrap.ts +9 -1
- package/src/client/factory.ts +130 -30
- package/src/client/interface.ts +70 -44
- package/src/client/p2p_client.ts +273 -299
- package/src/client/test/{tx_proposal_collector/README.md → p2p_client.batch_tx_requester.bench.README.md} +23 -53
- package/src/config.ts +267 -46
- package/src/errors/p2p-service.error.ts +11 -0
- package/src/errors/reqresp.error.ts +0 -25
- package/src/errors/tx-pool.error.ts +12 -0
- package/src/index.ts +1 -1
- package/src/mem_pools/attestation_pool/attestation_pool.ts +575 -94
- package/src/mem_pools/attestation_pool/attestation_pool_test_suite.ts +617 -141
- package/src/mem_pools/attestation_pool/index.ts +9 -2
- package/src/mem_pools/attestation_pool/mocks.ts +14 -8
- package/src/mem_pools/index.ts +2 -2
- package/src/mem_pools/instrumentation.ts +22 -14
- package/src/mem_pools/interface.ts +4 -4
- package/src/mem_pools/tx_pool_v2/README.md +283 -0
- package/src/mem_pools/tx_pool_v2/archive/index.ts +1 -0
- package/src/mem_pools/tx_pool_v2/archive/tx_archive.ts +120 -0
- package/src/mem_pools/tx_pool_v2/deleted_pool.ts +321 -0
- package/src/mem_pools/tx_pool_v2/eviction/eviction_manager.ts +160 -0
- package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.ts +122 -0
- package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.ts +125 -0
- package/src/mem_pools/tx_pool_v2/eviction/index.ts +28 -0
- package/src/mem_pools/tx_pool_v2/eviction/insufficient_fee_per_gas_eviction_rule.ts +65 -0
- package/src/mem_pools/tx_pool_v2/eviction/interfaces.ts +219 -0
- package/src/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.ts +74 -0
- package/src/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.ts +101 -0
- package/src/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.ts +91 -0
- package/src/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.ts +99 -0
- package/src/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.ts +32 -0
- package/src/mem_pools/tx_pool_v2/index.ts +12 -0
- package/src/mem_pools/tx_pool_v2/instrumentation.ts +69 -0
- package/src/mem_pools/tx_pool_v2/interfaces.ts +250 -0
- package/src/mem_pools/tx_pool_v2/tx_metadata.ts +349 -0
- package/src/mem_pools/tx_pool_v2/tx_pool_bench_metrics.ts +77 -0
- package/src/mem_pools/tx_pool_v2/tx_pool_indices.ts +430 -0
- package/src/mem_pools/tx_pool_v2/tx_pool_v2.ts +238 -0
- package/src/mem_pools/tx_pool_v2/tx_pool_v2_impl.ts +1090 -0
- package/src/msg_validators/attestation_validator/README.md +49 -0
- package/src/msg_validators/attestation_validator/attestation_validator.ts +41 -9
- package/src/msg_validators/attestation_validator/fisherman_attestation_validator.ts +16 -9
- package/src/msg_validators/clock_tolerance.ts +79 -3
- package/src/msg_validators/proposal_validator/README.md +123 -0
- package/src/msg_validators/proposal_validator/block_proposal_validator.ts +24 -4
- package/src/msg_validators/proposal_validator/checkpoint_proposal_validator.ts +35 -7
- package/src/msg_validators/proposal_validator/proposal_validator.ts +114 -47
- package/src/msg_validators/tx_validator/README.md +127 -0
- package/src/msg_validators/tx_validator/aggregate_tx_validator.ts +8 -17
- package/src/msg_validators/tx_validator/allowed_public_setup.ts +22 -27
- package/src/msg_validators/tx_validator/allowed_setup_helpers.ts +31 -0
- package/src/msg_validators/tx_validator/archive_cache.ts +1 -1
- package/src/msg_validators/tx_validator/block_header_validator.ts +15 -3
- package/src/msg_validators/tx_validator/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/double_spend_validator.ts +11 -6
- package/src/msg_validators/tx_validator/factory.ts +407 -80
- package/src/msg_validators/tx_validator/fee_payer_balance.ts +6 -2
- package/src/msg_validators/tx_validator/gas_validator.ts +199 -54
- package/src/msg_validators/tx_validator/index.ts +4 -0
- package/src/msg_validators/tx_validator/metadata_validator.ts +12 -4
- package/src/msg_validators/tx_validator/nullifier_cache.ts +30 -0
- package/src/msg_validators/tx_validator/phases_validator.ts +82 -27
- package/src/msg_validators/tx_validator/timestamp_validator.ts +23 -18
- package/src/msg_validators/tx_validator/tx_proof_validator.ts +2 -0
- package/src/msg_validators/tx_validator/tx_validation_cache.ts +102 -0
- package/src/services/data_store.ts +5 -13
- package/src/services/discv5/discV5_service.ts +38 -5
- package/src/services/dummy_service.ts +32 -45
- package/src/services/encoding.ts +18 -10
- package/src/services/gossipsub/README.md +641 -0
- package/src/services/gossipsub/index.ts +2 -0
- package/src/services/gossipsub/scoring.ts +29 -5
- package/src/services/gossipsub/topic_score_params.ts +519 -0
- package/src/services/index.ts +1 -0
- package/src/services/libp2p/instrumentation.ts +14 -0
- package/src/services/libp2p/libp2p_service.ts +716 -586
- package/src/services/peer-manager/metrics.ts +7 -0
- package/src/services/peer-manager/peer_manager.ts +46 -11
- package/src/services/peer-manager/peer_scoring.ts +52 -5
- package/src/services/reqresp/README.md +215 -0
- package/src/services/reqresp/batch-tx-requester/README.md +53 -14
- package/src/services/reqresp/batch-tx-requester/batch_tx_requester.ts +108 -130
- package/src/services/reqresp/batch-tx-requester/interface.ts +14 -10
- package/src/services/reqresp/batch-tx-requester/missing_txs.ts +30 -71
- package/src/services/reqresp/batch-tx-requester/peer_collection.ts +68 -24
- package/src/services/reqresp/batch-tx-requester/tx_validator.ts +12 -25
- package/src/services/reqresp/config.ts +2 -2
- package/src/services/reqresp/interface.ts +45 -46
- package/src/services/reqresp/metrics.ts +0 -1
- package/src/services/reqresp/protocols/block_txs/block_txs_handler.ts +25 -14
- package/src/services/reqresp/protocols/block_txs/block_txs_reqresp.ts +38 -15
- package/src/services/reqresp/protocols/index.ts +0 -1
- package/src/services/reqresp/protocols/tx.ts +23 -3
- package/src/services/reqresp/rate-limiter/rate_limiter.ts +13 -9
- package/src/services/reqresp/rate-limiter/rate_limits.ts +0 -10
- package/src/services/reqresp/reqresp.ts +61 -264
- package/src/services/service.ts +62 -29
- package/src/services/tx_collection/config.ts +40 -49
- package/src/services/tx_collection/file_store_tx_collection.ts +153 -0
- package/src/services/tx_collection/file_store_tx_source.ts +129 -0
- package/src/services/tx_collection/index.ts +2 -6
- package/src/services/tx_collection/instrumentation.ts +1 -1
- package/src/services/tx_collection/request_tracker.ts +127 -0
- package/src/services/tx_collection/tx_collection.ts +362 -110
- package/src/services/tx_collection/tx_collection_sink.ts +32 -36
- package/src/services/tx_collection/tx_source.ts +28 -8
- package/src/services/tx_file_store/config.ts +37 -0
- package/src/services/tx_file_store/index.ts +3 -0
- package/src/services/tx_file_store/instrumentation.ts +36 -0
- package/src/services/tx_file_store/tx_file_store.ts +163 -0
- package/src/services/tx_provider.ts +15 -9
- package/src/test-helpers/make-test-p2p-clients.ts +7 -6
- package/src/test-helpers/mock-pubsub.ts +137 -14
- package/src/test-helpers/reqresp-nodes.ts +17 -29
- package/src/test-helpers/test_tx_provider.ts +5 -0
- package/src/test-helpers/testbench-utils.ts +177 -96
- package/src/testbench/p2p_client_testbench_worker.ts +100 -63
- package/src/testbench/worker_client_manager.ts +72 -25
- package/src/util.ts +40 -19
- 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/attestation_pool/kv_attestation_pool.d.ts +0 -40
- package/dest/mem_pools/attestation_pool/kv_attestation_pool.d.ts.map +0 -1
- package/dest/mem_pools/attestation_pool/kv_attestation_pool.js +0 -218
- package/dest/mem_pools/attestation_pool/memory_attestation_pool.d.ts +0 -31
- package/dest/mem_pools/attestation_pool/memory_attestation_pool.d.ts.map +0 -1
- package/dest/mem_pools/attestation_pool/memory_attestation_pool.js +0 -180
- package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.d.ts +0 -125
- package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.js +0 -596
- package/dest/mem_pools/tx_pool/eviction/eviction_manager.d.ts +0 -32
- package/dest/mem_pools/tx_pool/eviction/eviction_manager.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/eviction/eviction_manager.js +0 -112
- package/dest/mem_pools/tx_pool/eviction/eviction_strategy.d.ts +0 -157
- package/dest/mem_pools/tx_pool/eviction/eviction_strategy.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/eviction/eviction_strategy.js +0 -52
- package/dest/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.d.ts +0 -16
- package/dest/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.js +0 -122
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.d.ts +0 -17
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.d.ts +0 -19
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.js +0 -78
- package/dest/mem_pools/tx_pool/eviction/low_priority_eviction_rule.d.ts +0 -26
- package/dest/mem_pools/tx_pool/eviction/low_priority_eviction_rule.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/eviction/low_priority_eviction_rule.js +0 -84
- package/dest/mem_pools/tx_pool/eviction/nullifier_conflict_pre_add_rule.d.ts +0 -25
- package/dest/mem_pools/tx_pool/eviction/nullifier_conflict_pre_add_rule.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/eviction/nullifier_conflict_pre_add_rule.js +0 -57
- package/dest/mem_pools/tx_pool/index.d.ts +0 -3
- package/dest/mem_pools/tx_pool/index.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/index.js +0 -2
- package/dest/mem_pools/tx_pool/priority.d.ts +0 -12
- package/dest/mem_pools/tx_pool/priority.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/priority.js +0 -15
- package/dest/mem_pools/tx_pool/tx_pool.d.ts +0 -127
- package/dest/mem_pools/tx_pool/tx_pool.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/tx_pool.js +0 -3
- package/dest/mem_pools/tx_pool/tx_pool_test_suite.d.ts +0 -7
- package/dest/mem_pools/tx_pool/tx_pool_test_suite.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/tx_pool_test_suite.js +0 -400
- package/dest/msg_validators/proposal_validator/proposal_validator_test_suite.d.ts +0 -23
- package/dest/msg_validators/proposal_validator/proposal_validator_test_suite.d.ts.map +0 -1
- package/dest/msg_validators/proposal_validator/proposal_validator_test_suite.js +0 -212
- package/dest/services/reqresp/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 -53
- 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 -53
- package/dest/services/tx_collection/slow_tx_collection.d.ts.map +0 -1
- package/dest/services/tx_collection/slow_tx_collection.js +0 -177
- package/src/client/test/tx_proposal_collector/proposal_tx_collector_worker.ts +0 -336
- package/src/client/test/tx_proposal_collector/proposal_tx_collector_worker_protocol.ts +0 -43
- package/src/mem_pools/attestation_pool/kv_attestation_pool.ts +0 -320
- package/src/mem_pools/attestation_pool/memory_attestation_pool.ts +0 -264
- package/src/mem_pools/tx_pool/README.md +0 -270
- package/src/mem_pools/tx_pool/aztec_kv_tx_pool.ts +0 -746
- package/src/mem_pools/tx_pool/eviction/eviction_manager.ts +0 -132
- package/src/mem_pools/tx_pool/eviction/eviction_strategy.ts +0 -208
- package/src/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.ts +0 -162
- package/src/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.ts +0 -104
- package/src/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.ts +0 -93
- package/src/mem_pools/tx_pool/eviction/low_priority_eviction_rule.ts +0 -106
- package/src/mem_pools/tx_pool/eviction/nullifier_conflict_pre_add_rule.ts +0 -75
- package/src/mem_pools/tx_pool/index.ts +0 -2
- package/src/mem_pools/tx_pool/priority.ts +0 -20
- package/src/mem_pools/tx_pool/tx_pool.ts +0 -141
- package/src/mem_pools/tx_pool/tx_pool_test_suite.ts +0 -319
- package/src/msg_validators/proposal_validator/proposal_validator_test_suite.ts +0 -230
- package/src/services/reqresp/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 -364
- package/src/services/tx_collection/proposal_tx_collector.ts +0 -114
- package/src/services/tx_collection/slow_tx_collection.ts +0 -233
|
@@ -1,336 +0,0 @@
|
|
|
1
|
-
import { MockL2BlockSource } from '@aztec/archiver/test';
|
|
2
|
-
import { SecretValue } from '@aztec/foundation/config';
|
|
3
|
-
import { createLogger } from '@aztec/foundation/log';
|
|
4
|
-
import { sleep } from '@aztec/foundation/sleep';
|
|
5
|
-
import { DateProvider, Timer, executeTimeout } from '@aztec/foundation/timer';
|
|
6
|
-
import type { DataStoreConfig } from '@aztec/kv-store/config';
|
|
7
|
-
import { openTmpStore } from '@aztec/kv-store/lmdb-v2';
|
|
8
|
-
import type { L2BlockSource } from '@aztec/stdlib/block';
|
|
9
|
-
import type { ContractDataSource } from '@aztec/stdlib/contract';
|
|
10
|
-
import type { ClientProtocolCircuitVerifier } from '@aztec/stdlib/interfaces/server';
|
|
11
|
-
import { P2PClientType, PeerErrorSeverity } from '@aztec/stdlib/p2p';
|
|
12
|
-
import type { Tx, TxValidationResult } from '@aztec/stdlib/tx';
|
|
13
|
-
import { type TelemetryClient, getTelemetryClient } from '@aztec/telemetry-client';
|
|
14
|
-
|
|
15
|
-
import type { PeerId } from '@libp2p/interface';
|
|
16
|
-
import { peerIdFromString } from '@libp2p/peer-id';
|
|
17
|
-
|
|
18
|
-
import type { P2PConfig } from '../../../config.js';
|
|
19
|
-
import type { IBatchRequestTxValidator } from '../../../services/reqresp/batch-tx-requester/tx_validator.js';
|
|
20
|
-
import { RateLimitStatus } from '../../../services/reqresp/rate-limiter/rate_limiter.js';
|
|
21
|
-
import {
|
|
22
|
-
BatchTxRequesterCollector,
|
|
23
|
-
SendBatchRequestCollector,
|
|
24
|
-
} from '../../../services/tx_collection/proposal_tx_collector.js';
|
|
25
|
-
import { AlwaysTrueCircuitVerifier } from '../../../test-helpers/reqresp-nodes.js';
|
|
26
|
-
import {
|
|
27
|
-
BENCHMARK_CONSTANTS,
|
|
28
|
-
InMemoryAttestationPool,
|
|
29
|
-
InMemoryTxPool,
|
|
30
|
-
UNLIMITED_RATE_LIMIT_QUOTA,
|
|
31
|
-
calculateInternalTimeout,
|
|
32
|
-
createMockEpochCache,
|
|
33
|
-
createMockWorldStateSynchronizer,
|
|
34
|
-
} from '../../../test-helpers/testbench-utils.js';
|
|
35
|
-
import { createP2PClient } from '../../index.js';
|
|
36
|
-
import type { P2PClient } from '../../p2p_client.js';
|
|
37
|
-
import {
|
|
38
|
-
type WorkerCommand,
|
|
39
|
-
type WorkerResponse,
|
|
40
|
-
deserializeBlockProposal,
|
|
41
|
-
deserializeTx,
|
|
42
|
-
deserializeTxHash,
|
|
43
|
-
} from './proposal_tx_collector_worker_protocol.js';
|
|
44
|
-
|
|
45
|
-
let client: P2PClient | undefined;
|
|
46
|
-
let txPool: InMemoryTxPool | undefined;
|
|
47
|
-
let attestationPool: InMemoryAttestationPool | undefined;
|
|
48
|
-
let logger = createLogger('p2p:proposal-bench');
|
|
49
|
-
let kvStore: Awaited<ReturnType<typeof openTmpStore>> | undefined;
|
|
50
|
-
let ipcDisconnected = false;
|
|
51
|
-
|
|
52
|
-
function ensureClient(): P2PClient {
|
|
53
|
-
if (!client || !txPool) {
|
|
54
|
-
throw new Error('Worker client not started');
|
|
55
|
-
}
|
|
56
|
-
return client;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
function isIpcDisconnectError(err: unknown): boolean {
|
|
60
|
-
const code = (err as NodeJS.ErrnoException | undefined)?.code;
|
|
61
|
-
return code === 'EPIPE' || code === 'ERR_IPC_CHANNEL_CLOSED';
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
function sendMessage(message: WorkerResponse): Promise<void> {
|
|
65
|
-
const send = process.send;
|
|
66
|
-
if (!send || !process.connected || ipcDisconnected) {
|
|
67
|
-
return Promise.resolve();
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
return new Promise(resolve => {
|
|
71
|
-
const fallbackTimeout = setTimeout(() => resolve(), 2000);
|
|
72
|
-
try {
|
|
73
|
-
send.call(process, message, undefined, undefined, err => {
|
|
74
|
-
clearTimeout(fallbackTimeout);
|
|
75
|
-
if (!err) {
|
|
76
|
-
resolve();
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
|
-
if (isIpcDisconnectError(err)) {
|
|
80
|
-
ipcDisconnected = true;
|
|
81
|
-
resolve();
|
|
82
|
-
return;
|
|
83
|
-
}
|
|
84
|
-
logger.warn('Failed to send IPC message', { error: err?.message ?? String(err) });
|
|
85
|
-
resolve();
|
|
86
|
-
});
|
|
87
|
-
} catch (err: any) {
|
|
88
|
-
clearTimeout(fallbackTimeout);
|
|
89
|
-
if (isIpcDisconnectError(err)) {
|
|
90
|
-
ipcDisconnected = true;
|
|
91
|
-
resolve();
|
|
92
|
-
return;
|
|
93
|
-
}
|
|
94
|
-
logger.warn('Failed to send IPC message', { error: err?.message ?? String(err) });
|
|
95
|
-
resolve();
|
|
96
|
-
}
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
async function startClient(config: P2PConfig, clientIndex: number) {
|
|
101
|
-
txPool = new InMemoryTxPool();
|
|
102
|
-
attestationPool = new InMemoryAttestationPool();
|
|
103
|
-
const epochCache = createMockEpochCache();
|
|
104
|
-
const worldState = createMockWorldStateSynchronizer();
|
|
105
|
-
const l2BlockSource = new MockL2BlockSource();
|
|
106
|
-
const proofVerifier = new AlwaysTrueCircuitVerifier();
|
|
107
|
-
kvStore = await openTmpStore(`proposal-bench-${clientIndex}`, true, BENCHMARK_CONSTANTS.KV_STORE_MAP_SIZE_KB);
|
|
108
|
-
logger = createLogger(`p2p:proposal-bench:${clientIndex}`);
|
|
109
|
-
|
|
110
|
-
const telemetry = getTelemetryClient();
|
|
111
|
-
const deps = {
|
|
112
|
-
txPool,
|
|
113
|
-
attestationPool,
|
|
114
|
-
store: kvStore,
|
|
115
|
-
logger,
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
client = await createP2PClient(
|
|
119
|
-
P2PClientType.Full,
|
|
120
|
-
config as P2PConfig & DataStoreConfig,
|
|
121
|
-
l2BlockSource as L2BlockSource & ContractDataSource,
|
|
122
|
-
proofVerifier as ClientProtocolCircuitVerifier,
|
|
123
|
-
worldState,
|
|
124
|
-
epochCache,
|
|
125
|
-
'proposal-tx-collector-bench-worker',
|
|
126
|
-
new DateProvider(),
|
|
127
|
-
telemetry as TelemetryClient,
|
|
128
|
-
deps,
|
|
129
|
-
);
|
|
130
|
-
|
|
131
|
-
await client.start();
|
|
132
|
-
installUnlimitedRateLimits();
|
|
133
|
-
|
|
134
|
-
for (let i = 0; i < 120; i++) {
|
|
135
|
-
if (client.isReady()) {
|
|
136
|
-
return;
|
|
137
|
-
}
|
|
138
|
-
await sleep(500);
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
throw new Error('Timed out waiting for P2P client readiness');
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
function installSamplerOverrides(peerList: ReturnType<typeof peerIdFromString>[]) {
|
|
145
|
-
const reqResp = (ensureClient() as any).p2pService.reqresp as any;
|
|
146
|
-
const sampler = reqResp.connectionSampler as any;
|
|
147
|
-
|
|
148
|
-
sampler.getPeerListSortedByConnectionCountAsc = (excluding?: Set<string>) => {
|
|
149
|
-
if (!excluding || excluding.size === 0) {
|
|
150
|
-
return peerList;
|
|
151
|
-
}
|
|
152
|
-
return peerList.filter(peerId => !excluding.has(peerId.toString()));
|
|
153
|
-
};
|
|
154
|
-
sampler.samplePeersBatch = (numberToSample: number, excluding?: Map<string, boolean>) => {
|
|
155
|
-
const filtered = peerList.filter(peerId => !excluding?.has(peerId.toString()));
|
|
156
|
-
return filtered.slice(0, Math.min(numberToSample, filtered.length));
|
|
157
|
-
};
|
|
158
|
-
sampler.getPeer = (excluding?: Map<string, boolean>) => {
|
|
159
|
-
const filtered = peerList.filter(peerId => !excluding?.has(peerId.toString()));
|
|
160
|
-
return filtered[0];
|
|
161
|
-
};
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
function installUnlimitedRateLimits() {
|
|
165
|
-
const reqResp = (ensureClient() as any).p2pService.reqresp as any;
|
|
166
|
-
const rateLimiter = reqResp.rateLimiter as any;
|
|
167
|
-
|
|
168
|
-
rateLimiter.getRateLimits = () => UNLIMITED_RATE_LIMIT_QUOTA;
|
|
169
|
-
rateLimiter.allow = () => RateLimitStatus.Allowed;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
async function runCollector(cmd: Extract<WorkerCommand, { type: 'RUN_COLLECTOR' }>) {
|
|
173
|
-
const { collectorType, txHashes, blockProposal, pinnedPeerId, peerIds, timeoutMs } = cmd;
|
|
174
|
-
const reqResp = (ensureClient() as any).p2pService.reqresp as any;
|
|
175
|
-
const peerList = peerIds.map(peerId => peerIdFromString(peerId));
|
|
176
|
-
|
|
177
|
-
installSamplerOverrides(peerList);
|
|
178
|
-
installUnlimitedRateLimits();
|
|
179
|
-
|
|
180
|
-
const p2pService = {
|
|
181
|
-
reqResp,
|
|
182
|
-
connectionSampler: {
|
|
183
|
-
getPeerListSortedByConnectionCountAsc: () => peerList,
|
|
184
|
-
},
|
|
185
|
-
txValidatorConfig: {
|
|
186
|
-
l1ChainId: 1,
|
|
187
|
-
rollupVersion: 1,
|
|
188
|
-
proofVerifier: {
|
|
189
|
-
verifyProof: () => Promise.resolve({ valid: true, durationMs: 0, totalDurationMs: 0 }),
|
|
190
|
-
stop: () => Promise.resolve(),
|
|
191
|
-
},
|
|
192
|
-
},
|
|
193
|
-
peerScoring: {
|
|
194
|
-
penalizePeer: (_peerId: PeerId, _penalty: PeerErrorSeverity) => {},
|
|
195
|
-
},
|
|
196
|
-
};
|
|
197
|
-
|
|
198
|
-
const parsedTxHashes = txHashes.map(deserializeTxHash);
|
|
199
|
-
const parsedProposal = deserializeBlockProposal(blockProposal);
|
|
200
|
-
const pinnedPeer = pinnedPeerId ? peerIdFromString(pinnedPeerId) : undefined;
|
|
201
|
-
|
|
202
|
-
const timer = new Timer();
|
|
203
|
-
let fetchedCount = 0;
|
|
204
|
-
|
|
205
|
-
const internalTimeoutMs = calculateInternalTimeout(timeoutMs);
|
|
206
|
-
|
|
207
|
-
const noopTxValidator: IBatchRequestTxValidator = {
|
|
208
|
-
validateRequestedTx: (_tx: Tx): Promise<TxValidationResult> => Promise.resolve({ result: 'valid' }),
|
|
209
|
-
validateRequestedTxs: (txs: Tx[]): Promise<TxValidationResult[]> =>
|
|
210
|
-
Promise.resolve(txs.map(() => ({ result: 'valid' }))),
|
|
211
|
-
};
|
|
212
|
-
|
|
213
|
-
try {
|
|
214
|
-
if (collectorType === 'batch-requester') {
|
|
215
|
-
const collector = new BatchTxRequesterCollector(p2pService, logger, new DateProvider(), noopTxValidator);
|
|
216
|
-
const fetched = await executeTimeout(
|
|
217
|
-
(_signal: AbortSignal) => collector.collectTxs(parsedTxHashes, parsedProposal, pinnedPeer, internalTimeoutMs),
|
|
218
|
-
timeoutMs,
|
|
219
|
-
() => new Error(`Collector timed out after ${timeoutMs}ms`),
|
|
220
|
-
);
|
|
221
|
-
fetchedCount = fetched.length;
|
|
222
|
-
} else {
|
|
223
|
-
const collector = new SendBatchRequestCollector(
|
|
224
|
-
p2pService,
|
|
225
|
-
BENCHMARK_CONSTANTS.FIXED_MAX_PEERS,
|
|
226
|
-
BENCHMARK_CONSTANTS.FIXED_MAX_RETRY_ATTEMPTS,
|
|
227
|
-
);
|
|
228
|
-
const fetched = await executeTimeout(
|
|
229
|
-
(_signal: AbortSignal) => collector.collectTxs(parsedTxHashes, parsedProposal, pinnedPeer, internalTimeoutMs),
|
|
230
|
-
timeoutMs,
|
|
231
|
-
() => new Error(`Collector timed out after ${timeoutMs}ms`),
|
|
232
|
-
);
|
|
233
|
-
fetchedCount = fetched.length;
|
|
234
|
-
}
|
|
235
|
-
} catch (err: any) {
|
|
236
|
-
logger.warn(`Collector error: ${err?.message ?? String(err)}`);
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
return { durationMs: timer.ms(), fetchedCount };
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
async function stopClient() {
|
|
243
|
-
if (!client) {
|
|
244
|
-
return;
|
|
245
|
-
}
|
|
246
|
-
await client.stop();
|
|
247
|
-
if (kvStore?.close) {
|
|
248
|
-
await kvStore.close();
|
|
249
|
-
}
|
|
250
|
-
client = undefined;
|
|
251
|
-
txPool = undefined;
|
|
252
|
-
attestationPool = undefined;
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
process.on('disconnect', () => {
|
|
256
|
-
ipcDisconnected = true;
|
|
257
|
-
void stopClient().finally(() => process.exit(0));
|
|
258
|
-
});
|
|
259
|
-
|
|
260
|
-
process.on('error', err => {
|
|
261
|
-
if (isIpcDisconnectError(err)) {
|
|
262
|
-
ipcDisconnected = true;
|
|
263
|
-
return;
|
|
264
|
-
}
|
|
265
|
-
logger.warn('Worker process error', { error: err?.message ?? String(err) });
|
|
266
|
-
});
|
|
267
|
-
|
|
268
|
-
process.on('message', (msg: WorkerCommand) => {
|
|
269
|
-
void (async () => {
|
|
270
|
-
if (!msg || typeof msg !== 'object') {
|
|
271
|
-
return;
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
const requestId = msg.requestId;
|
|
275
|
-
|
|
276
|
-
try {
|
|
277
|
-
switch (msg.type) {
|
|
278
|
-
case 'START': {
|
|
279
|
-
const rawConfig = msg.config;
|
|
280
|
-
const config: P2PConfig = {
|
|
281
|
-
...rawConfig,
|
|
282
|
-
peerIdPrivateKey: rawConfig.peerIdPrivateKey ? new SecretValue(rawConfig.peerIdPrivateKey) : undefined,
|
|
283
|
-
} as P2PConfig;
|
|
284
|
-
|
|
285
|
-
await startClient(config, msg.clientIndex);
|
|
286
|
-
const peerId = (ensureClient() as any).p2pService.node.peerId.toString();
|
|
287
|
-
await sendMessage({ type: 'READY', requestId, peerId });
|
|
288
|
-
break;
|
|
289
|
-
}
|
|
290
|
-
case 'SET_TXS': {
|
|
291
|
-
if (!txPool) {
|
|
292
|
-
throw new Error('Tx pool not initialized');
|
|
293
|
-
}
|
|
294
|
-
const txs = msg.txs.map(deserializeTx);
|
|
295
|
-
const count = msg.mode === 'append' ? txPool.appendTxs(txs) : txPool.setTxs(txs);
|
|
296
|
-
await sendMessage({ type: 'TXS_SET', requestId, count });
|
|
297
|
-
break;
|
|
298
|
-
}
|
|
299
|
-
case 'SET_BLOCK_PROPOSAL': {
|
|
300
|
-
if (!attestationPool) {
|
|
301
|
-
throw new Error('Attestation pool not initialized');
|
|
302
|
-
}
|
|
303
|
-
const proposal = deserializeBlockProposal(msg.blockProposal);
|
|
304
|
-
await attestationPool.addBlockProposal(proposal);
|
|
305
|
-
await sendMessage({ type: 'BLOCK_PROPOSAL_SET', requestId, archiveRoot: proposal.archive.toString() });
|
|
306
|
-
break;
|
|
307
|
-
}
|
|
308
|
-
case 'RUN_COLLECTOR': {
|
|
309
|
-
const { durationMs, fetchedCount } = await runCollector(msg);
|
|
310
|
-
await sendMessage({ type: 'COLLECTOR_RESULT', requestId, durationMs, fetchedCount });
|
|
311
|
-
break;
|
|
312
|
-
}
|
|
313
|
-
case 'GET_PEER_COUNT': {
|
|
314
|
-
const peers = await ensureClient().getPeers();
|
|
315
|
-
await sendMessage({ type: 'PEER_COUNT', requestId, count: peers.length });
|
|
316
|
-
break;
|
|
317
|
-
}
|
|
318
|
-
case 'STOP': {
|
|
319
|
-
await stopClient();
|
|
320
|
-
await sendMessage({ type: 'STOPPED', requestId });
|
|
321
|
-
process.exit(0);
|
|
322
|
-
break;
|
|
323
|
-
}
|
|
324
|
-
default: {
|
|
325
|
-
const _exhaustive: never = msg;
|
|
326
|
-
throw new Error(`Unknown command: ${(msg as { type?: string }).type}`);
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
} catch (err: any) {
|
|
330
|
-
await sendMessage({ type: 'ERROR', requestId, error: err?.message ?? String(err) });
|
|
331
|
-
if (msg.type === 'START') {
|
|
332
|
-
process.exit(1);
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
})();
|
|
336
|
-
});
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { BlockProposal } from '@aztec/stdlib/p2p';
|
|
2
|
-
import { Tx, TxHash } from '@aztec/stdlib/tx';
|
|
3
|
-
|
|
4
|
-
import type { P2PConfig } from '../../../config.js';
|
|
5
|
-
|
|
6
|
-
export type SerializedP2PConfig = Omit<P2PConfig, 'peerIdPrivateKey'> & { peerIdPrivateKey?: string };
|
|
7
|
-
|
|
8
|
-
export type CollectorType = 'batch-requester' | 'send-batch-request';
|
|
9
|
-
|
|
10
|
-
export type WorkerCommand =
|
|
11
|
-
| { type: 'START'; requestId: string; clientIndex: number; config: SerializedP2PConfig }
|
|
12
|
-
| { type: 'SET_TXS'; requestId: string; txs: string[]; mode?: 'replace' | 'append' }
|
|
13
|
-
| { type: 'SET_BLOCK_PROPOSAL'; requestId: string; blockProposal: string }
|
|
14
|
-
| {
|
|
15
|
-
type: 'RUN_COLLECTOR';
|
|
16
|
-
requestId: string;
|
|
17
|
-
collectorType: CollectorType;
|
|
18
|
-
txHashes: string[];
|
|
19
|
-
blockProposal: string;
|
|
20
|
-
pinnedPeerId?: string;
|
|
21
|
-
peerIds: string[];
|
|
22
|
-
timeoutMs: number;
|
|
23
|
-
}
|
|
24
|
-
| { type: 'GET_PEER_COUNT'; requestId: string }
|
|
25
|
-
| { type: 'STOP'; requestId: string };
|
|
26
|
-
|
|
27
|
-
export type WorkerResponse =
|
|
28
|
-
| { type: 'READY'; requestId: string; peerId: string }
|
|
29
|
-
| { type: 'TXS_SET'; requestId: string; count: number }
|
|
30
|
-
| { type: 'BLOCK_PROPOSAL_SET'; requestId: string; archiveRoot: string }
|
|
31
|
-
| { type: 'COLLECTOR_RESULT'; requestId: string; durationMs: number; fetchedCount: number }
|
|
32
|
-
| { type: 'PEER_COUNT'; requestId: string; count: number }
|
|
33
|
-
| { type: 'STOPPED'; requestId: string }
|
|
34
|
-
| { type: 'ERROR'; requestId: string; error: string };
|
|
35
|
-
|
|
36
|
-
export const serializeTx = (tx: Tx) => tx.toBuffer().toString('hex');
|
|
37
|
-
export const deserializeTx = (hex: string) => Tx.fromBuffer(Buffer.from(hex, 'hex'));
|
|
38
|
-
|
|
39
|
-
export const serializeTxHash = (txHash: TxHash) => txHash.toString();
|
|
40
|
-
export const deserializeTxHash = (hex: string) => TxHash.fromString(hex);
|
|
41
|
-
|
|
42
|
-
export const serializeBlockProposal = (proposal: BlockProposal) => proposal.toBuffer().toString('hex');
|
|
43
|
-
export const deserializeBlockProposal = (hex: string) => BlockProposal.fromBuffer(Buffer.from(hex, 'hex'));
|
|
@@ -1,320 +0,0 @@
|
|
|
1
|
-
import { SlotNumber } from '@aztec/foundation/branded-types';
|
|
2
|
-
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
|
-
import { toArray } from '@aztec/foundation/iterable';
|
|
4
|
-
import { createLogger } from '@aztec/foundation/log';
|
|
5
|
-
import type { AztecAsyncKVStore, AztecAsyncMap, AztecAsyncMultiMap } from '@aztec/kv-store';
|
|
6
|
-
import {
|
|
7
|
-
BlockProposal,
|
|
8
|
-
CheckpointAttestation,
|
|
9
|
-
CheckpointProposal,
|
|
10
|
-
type CheckpointProposalCore,
|
|
11
|
-
} from '@aztec/stdlib/p2p';
|
|
12
|
-
import { type TelemetryClient, getTelemetryClient } from '@aztec/telemetry-client';
|
|
13
|
-
|
|
14
|
-
import { ProposalSlotCapExceededError } from '../../errors/attestation-pool.error.js';
|
|
15
|
-
import { PoolInstrumentation, PoolName, type PoolStatsCallback } from '../instrumentation.js';
|
|
16
|
-
import type { AttestationPool } from './attestation_pool.js';
|
|
17
|
-
|
|
18
|
-
export const MAX_PROPOSALS_PER_SLOT = 5;
|
|
19
|
-
export const ATTESTATION_CAP_BUFFER = 10;
|
|
20
|
-
|
|
21
|
-
export class KvAttestationPool implements AttestationPool {
|
|
22
|
-
private metrics: PoolInstrumentation<CheckpointAttestation>;
|
|
23
|
-
|
|
24
|
-
private proposals: AztecAsyncMap<
|
|
25
|
-
/* proposal.payload.archive */ string,
|
|
26
|
-
/* buffer representation of proposal */ Buffer
|
|
27
|
-
>;
|
|
28
|
-
|
|
29
|
-
// Checkpoint attestation storage
|
|
30
|
-
private checkpointAttestations: AztecAsyncMap<string, Buffer>;
|
|
31
|
-
private checkpointProposals: AztecAsyncMap<string, Buffer>;
|
|
32
|
-
private checkpointProposalsForSlot: AztecAsyncMultiMap<number, string>;
|
|
33
|
-
private checkpointAttestationsForProposal: AztecAsyncMultiMap<string, string>;
|
|
34
|
-
|
|
35
|
-
constructor(
|
|
36
|
-
private store: AztecAsyncKVStore,
|
|
37
|
-
telemetry: TelemetryClient = getTelemetryClient(),
|
|
38
|
-
private log = createLogger('aztec:attestation_pool'),
|
|
39
|
-
) {
|
|
40
|
-
this.proposals = store.openMap('proposals');
|
|
41
|
-
|
|
42
|
-
// Initialize checkpoint attestation storage
|
|
43
|
-
this.checkpointAttestations = store.openMap('checkpoint_attestations');
|
|
44
|
-
this.checkpointProposals = store.openMap('checkpoint_proposals');
|
|
45
|
-
this.checkpointProposalsForSlot = store.openMultiMap('checkpoint_proposals_for_slot');
|
|
46
|
-
this.checkpointAttestationsForProposal = store.openMultiMap('checkpoint_attestations_for_proposal');
|
|
47
|
-
|
|
48
|
-
this.metrics = new PoolInstrumentation(telemetry, PoolName.ATTESTATION_POOL, this.poolStats);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
private poolStats: PoolStatsCallback = async () => {
|
|
52
|
-
return {
|
|
53
|
-
itemCount: await this.checkpointAttestations.sizeAsync(),
|
|
54
|
-
};
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
public async isEmpty(): Promise<boolean> {
|
|
58
|
-
for await (const _ of this.checkpointAttestations.entriesAsync()) {
|
|
59
|
-
return false;
|
|
60
|
-
}
|
|
61
|
-
for await (const _ of this.proposals.entriesAsync()) {
|
|
62
|
-
return false;
|
|
63
|
-
}
|
|
64
|
-
return true;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
private getProposalKey(slot: number | bigint | Fr | string, proposalId: Fr | string | Buffer): string {
|
|
68
|
-
const slotStr = typeof slot === 'string' ? slot : new Fr(slot).toString();
|
|
69
|
-
const proposalIdStr =
|
|
70
|
-
typeof proposalId === 'string'
|
|
71
|
-
? proposalId
|
|
72
|
-
: Buffer.isBuffer(proposalId)
|
|
73
|
-
? Fr.fromBuffer(proposalId).toString()
|
|
74
|
-
: proposalId.toString();
|
|
75
|
-
|
|
76
|
-
return `${slotStr}-${proposalIdStr}`;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
private getAttestationKey(slot: number | bigint | Fr | string, proposalId: Fr | string, address: string): string {
|
|
80
|
-
return `${this.getProposalKey(slot, proposalId)}-${address}`;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
public async addBlockProposal(blockProposal: BlockProposal): Promise<void> {
|
|
84
|
-
await this.store.transactionAsync(async () => {
|
|
85
|
-
const proposalId = blockProposal.archive.toString();
|
|
86
|
-
// Strip signedTxs before storing to avoid persisting full tx data
|
|
87
|
-
await this.proposals.set(proposalId, blockProposal.withoutSignedTxs().toBuffer());
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
public async getBlockProposal(id: string): Promise<BlockProposal | undefined> {
|
|
92
|
-
const buffer = await this.proposals.getAsync(id);
|
|
93
|
-
try {
|
|
94
|
-
if (buffer && buffer.length > 0) {
|
|
95
|
-
return BlockProposal.fromBuffer(buffer);
|
|
96
|
-
}
|
|
97
|
-
} catch {
|
|
98
|
-
return Promise.resolve(undefined);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
return Promise.resolve(undefined);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
public async hasBlockProposal(idOrProposal: string | BlockProposal): Promise<boolean> {
|
|
105
|
-
const id = typeof idOrProposal === 'string' ? idOrProposal : idOrProposal.archive.toString();
|
|
106
|
-
return await this.proposals.hasAsync(id);
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
public async addCheckpointProposal(proposal: CheckpointProposal): Promise<void> {
|
|
110
|
-
if (!(await this.canAddCheckpointProposal(proposal))) {
|
|
111
|
-
throw new ProposalSlotCapExceededError(
|
|
112
|
-
`Maximum checkpoint proposals per slot reached: slot=${proposal.slotNumber} cap=${MAX_PROPOSALS_PER_SLOT} proposal=${proposal.archive.toString()}`,
|
|
113
|
-
);
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
// Extract and validate the block proposal if present
|
|
117
|
-
const blockProposal = proposal.getBlockProposal();
|
|
118
|
-
if (blockProposal && !(await this.canAddProposal(blockProposal))) {
|
|
119
|
-
throw new ProposalSlotCapExceededError(
|
|
120
|
-
`Maximum block proposals per slot reached when extracting from checkpoint: slot=${proposal.slotNumber} proposal=${blockProposal.archive.toString()}`,
|
|
121
|
-
);
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
await this.store.transactionAsync(async () => {
|
|
125
|
-
const slotKey = proposal.slotNumber;
|
|
126
|
-
const proposalId = proposal.archive.toString();
|
|
127
|
-
|
|
128
|
-
await this.checkpointProposalsForSlot.set(slotKey, proposalId);
|
|
129
|
-
// Store the checkpoint proposal as core (without lastBlock) to avoid duplication
|
|
130
|
-
await this.checkpointProposals.set(proposalId, proposal.toCore().toBuffer());
|
|
131
|
-
|
|
132
|
-
// Store the extracted block proposal separately
|
|
133
|
-
if (blockProposal) {
|
|
134
|
-
await this.proposals.set(blockProposal.archive.toString(), blockProposal.withoutSignedTxs().toBuffer());
|
|
135
|
-
}
|
|
136
|
-
});
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
public async getCheckpointProposal(id: string): Promise<CheckpointProposalCore | undefined> {
|
|
140
|
-
const buffer = await this.checkpointProposals.getAsync(id);
|
|
141
|
-
try {
|
|
142
|
-
if (buffer && buffer.length > 0) {
|
|
143
|
-
return CheckpointProposal.fromBuffer(buffer);
|
|
144
|
-
}
|
|
145
|
-
} catch {
|
|
146
|
-
return Promise.resolve(undefined);
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
return Promise.resolve(undefined);
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
public async hasCheckpointProposal(idOrProposal: string | CheckpointProposal): Promise<boolean> {
|
|
153
|
-
const id = typeof idOrProposal === 'string' ? idOrProposal : idOrProposal.archive.toString();
|
|
154
|
-
return await this.checkpointProposals.hasAsync(id);
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
public async addCheckpointAttestations(attestations: CheckpointAttestation[]): Promise<void> {
|
|
158
|
-
await this.store.transactionAsync(async () => {
|
|
159
|
-
for (const attestation of attestations) {
|
|
160
|
-
const slotNumber = attestation.payload.header.slotNumber;
|
|
161
|
-
const proposalId = attestation.archive;
|
|
162
|
-
const sender = attestation.getSender();
|
|
163
|
-
|
|
164
|
-
// Skip attestations with invalid signatures
|
|
165
|
-
if (!sender) {
|
|
166
|
-
this.log.warn(`Skipping checkpoint attestation with invalid signature for slot ${slotNumber}`, {
|
|
167
|
-
signature: attestation.signature.toString(),
|
|
168
|
-
slotNumber,
|
|
169
|
-
proposalId,
|
|
170
|
-
});
|
|
171
|
-
continue;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
const address = sender.toString();
|
|
175
|
-
|
|
176
|
-
await this.checkpointAttestations.set(
|
|
177
|
-
this.getAttestationKey(slotNumber, proposalId, address),
|
|
178
|
-
attestation.toBuffer(),
|
|
179
|
-
);
|
|
180
|
-
|
|
181
|
-
await this.checkpointProposalsForSlot.set(slotNumber, proposalId.toString());
|
|
182
|
-
await this.checkpointAttestationsForProposal.set(
|
|
183
|
-
this.getProposalKey(slotNumber, proposalId),
|
|
184
|
-
this.getAttestationKey(slotNumber, proposalId, address),
|
|
185
|
-
);
|
|
186
|
-
|
|
187
|
-
this.log.verbose(`Added checkpoint attestation for slot ${slotNumber} from ${address}`, {
|
|
188
|
-
signature: attestation.signature.toString(),
|
|
189
|
-
slotNumber,
|
|
190
|
-
address,
|
|
191
|
-
proposalId,
|
|
192
|
-
});
|
|
193
|
-
}
|
|
194
|
-
});
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
public async getCheckpointAttestationsForSlot(slot: SlotNumber): Promise<CheckpointAttestation[]> {
|
|
198
|
-
const proposalIds = await toArray(this.checkpointProposalsForSlot.getValuesAsync(slot));
|
|
199
|
-
const attestations: CheckpointAttestation[] = [];
|
|
200
|
-
|
|
201
|
-
for (const proposalId of proposalIds) {
|
|
202
|
-
attestations.push(...(await this.getCheckpointAttestationsForSlotAndProposal(slot, proposalId)));
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
return attestations;
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
public async getCheckpointAttestationsForSlotAndProposal(
|
|
209
|
-
slot: SlotNumber,
|
|
210
|
-
proposalId: string,
|
|
211
|
-
): Promise<CheckpointAttestation[]> {
|
|
212
|
-
const attestationIds = await toArray(
|
|
213
|
-
this.checkpointAttestationsForProposal.getValuesAsync(this.getProposalKey(slot, proposalId)),
|
|
214
|
-
);
|
|
215
|
-
const attestations: CheckpointAttestation[] = [];
|
|
216
|
-
|
|
217
|
-
for (const id of attestationIds) {
|
|
218
|
-
const buf = await this.checkpointAttestations.getAsync(id);
|
|
219
|
-
|
|
220
|
-
if (!buf) {
|
|
221
|
-
throw new Error('Checkpoint attestation not found ' + id);
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
const attestation = CheckpointAttestation.fromBuffer(buf);
|
|
225
|
-
attestations.push(attestation);
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
return attestations;
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
public async deleteCheckpointAttestationsOlderThan(oldestSlot: SlotNumber): Promise<void> {
|
|
232
|
-
const olderThan = await toArray(this.checkpointProposalsForSlot.keysAsync({ end: oldestSlot }));
|
|
233
|
-
for (const oldSlot of olderThan) {
|
|
234
|
-
await this.deleteCheckpointAttestationsForSlot(SlotNumber(oldSlot));
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
private async deleteCheckpointAttestationsForSlot(slot: SlotNumber): Promise<void> {
|
|
239
|
-
let numberOfAttestations = 0;
|
|
240
|
-
await this.store.transactionAsync(async () => {
|
|
241
|
-
const proposalIds = await toArray(this.checkpointProposalsForSlot.getValuesAsync(slot));
|
|
242
|
-
for (const proposalId of proposalIds) {
|
|
243
|
-
const attestations = await toArray(
|
|
244
|
-
this.checkpointAttestationsForProposal.getValuesAsync(this.getProposalKey(slot, proposalId)),
|
|
245
|
-
);
|
|
246
|
-
|
|
247
|
-
numberOfAttestations += attestations.length;
|
|
248
|
-
for (const attestation of attestations) {
|
|
249
|
-
await this.checkpointAttestations.delete(attestation);
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
await this.checkpointProposals.delete(proposalId);
|
|
253
|
-
await this.checkpointAttestationsForProposal.delete(this.getProposalKey(slot, proposalId));
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
await this.checkpointProposalsForSlot.delete(slot);
|
|
257
|
-
|
|
258
|
-
this.log.verbose(`Removed ${numberOfAttestations} checkpoint attestations for slot ${slot}`);
|
|
259
|
-
});
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
public async hasCheckpointAttestation(attestation: CheckpointAttestation): Promise<boolean> {
|
|
263
|
-
const slotNumber = attestation.payload.header.slotNumber;
|
|
264
|
-
const proposalId = attestation.archive;
|
|
265
|
-
const sender = attestation.getSender();
|
|
266
|
-
|
|
267
|
-
// Attestations with invalid signatures are never in the pool
|
|
268
|
-
if (!sender) {
|
|
269
|
-
return false;
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
const address = sender.toString();
|
|
273
|
-
const key = this.getAttestationKey(slotNumber, proposalId, address);
|
|
274
|
-
|
|
275
|
-
return await this.checkpointAttestations.hasAsync(key);
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
public canAddProposal(_block: BlockProposal): Promise<boolean> {
|
|
279
|
-
// TODO(palla/mbps): implement proposal cap logic
|
|
280
|
-
return Promise.resolve(true);
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
public async canAddCheckpointProposal(proposal: CheckpointProposal): Promise<boolean> {
|
|
284
|
-
// TODO(palla/mbps): Adjust checkpoint proposal limit to 1. Also connect to slashing condition in the caller.
|
|
285
|
-
return (
|
|
286
|
-
(await this.checkpointProposals.hasAsync(proposal.archive.toString())) ||
|
|
287
|
-
!(await this.hasReachedCheckpointProposalCap(proposal.slotNumber))
|
|
288
|
-
);
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
public async canAddCheckpointAttestation(
|
|
292
|
-
attestation: CheckpointAttestation,
|
|
293
|
-
committeeSize: number,
|
|
294
|
-
): Promise<boolean> {
|
|
295
|
-
return (
|
|
296
|
-
(await this.hasCheckpointAttestation(attestation)) ||
|
|
297
|
-
!(await this.hasReachedCheckpointAttestationCap(
|
|
298
|
-
attestation.payload.header.slotNumber,
|
|
299
|
-
attestation.archive.toString(),
|
|
300
|
-
committeeSize,
|
|
301
|
-
))
|
|
302
|
-
);
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
public async hasReachedCheckpointProposalCap(slot: SlotNumber): Promise<boolean> {
|
|
306
|
-
const uniqueProposalCount = await this.checkpointProposalsForSlot.getValueCountAsync(slot);
|
|
307
|
-
return uniqueProposalCount >= MAX_PROPOSALS_PER_SLOT;
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
public async hasReachedCheckpointAttestationCap(
|
|
311
|
-
slot: SlotNumber,
|
|
312
|
-
proposalId: string,
|
|
313
|
-
committeeSize: number,
|
|
314
|
-
): Promise<boolean> {
|
|
315
|
-
const limit = committeeSize + ATTESTATION_CAP_BUFFER;
|
|
316
|
-
return (
|
|
317
|
-
(await this.checkpointAttestationsForProposal.getValueCountAsync(this.getProposalKey(slot, proposalId))) >= limit
|
|
318
|
-
);
|
|
319
|
-
}
|
|
320
|
-
}
|